]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
wasm: minor refactoring and doc updates.
authorstephan <stephan@noemail.net>
Mon, 23 May 2022 19:38:57 +0000 (19:38 +0000)
committerstephan <stephan@noemail.net>
Mon, 23 May 2022 19:38:57 +0000 (19:38 +0000)
FossilOrigin-Name: 6044605b2a712da73600cabb967797a03ed1915dc0ab0b10edbd52525e548196

ext/fiddle/SqliteTestUtil.js [new file with mode: 0644]
ext/fiddle/testing-common.js
ext/fiddle/testing1.html
ext/fiddle/testing1.js
manifest
manifest.uuid

diff --git a/ext/fiddle/SqliteTestUtil.js b/ext/fiddle/SqliteTestUtil.js
new file mode 100644 (file)
index 0000000..964e60b
--- /dev/null
@@ -0,0 +1,54 @@
+/**
+   Helpers for writing sqlite3-specific tests.
+*/
+self/*window or worker*/.SqliteTestUtil = {
+    /** Running total of the number of tests run via
+        this API. */
+    counter: 0,
+    /**
+       If expr is a function, it is called and its result
+       is returned, coerced to a bool, else expr, coerced to
+       a bool, is returned.
+    */
+    toBool: function(expr){
+        return (expr instanceof Function) ? !!expr() : !!expr;
+    },
+    /** abort() if expr is false. If expr is a function, it
+        is called and its result is evaluated.
+    */
+    assert: function(expr, msg){
+        ++this.counter;
+        if(!this.toBool(expr)) abort(msg || "Assertion failed.");
+        return this;
+    },
+    /** Identical to assert() but throws instead of calling
+        abort(). */
+    affirm: function(expr, msg){
+        ++this.counter;
+        if(!this.toBool(expr)) throw new Error(msg || "Affirmation failed.");
+        return this;
+    },
+    /** Calls f() and squelches any exception it throws. If it
+        does not throw, this function throws. */
+    mustThrow: function(f, msg){
+        ++this.counter;
+        let err;
+        try{ f(); } catch(e){err=e;}
+        if(!err) throw new Error(msg || "Expected exception.");
+        return this;
+    },
+    /** Throws if expr is truthy or expr is a function and expr()
+        returns truthy. */
+    throwIf: function(expr, msg){
+        ++this.counter;
+        if(this.toBool(expr)) throw new Error(msg || "throwIf() failed");
+        return this;
+    },
+    /** Throws if expr is falsy or expr is a function and expr()
+        returns falsy. */
+    throwUnless: function(expr, msg){
+        ++this.counter;
+        if(!this.toBool(expr)) throw new Error(msg || "throwUnless() failed");
+        return this;
+    }
+};
index 79bb0ba9d90e200f863d83ecf5d4eb88f8db1c8f..27014812891a6072c6e2e16ec72b2944c66d4d6e 100644 (file)
         postRun: [],
         //onRuntimeInitialized: function(){},
         print: function(){
-            console.log(Array.prototype.slice.call(arguments));
+            console.log.apply(console, Array.prototype.slice.call(arguments));
         },
         printErr: function(){
-            console.error(Array.prototype.slice.call(arguments));
+            console.error.apply(console, Array.prototype.slice.call(arguments));
         },
         setStatus: function f(text){
             if(!f.last) f.last = { time: Date.now(), text: '' };
@@ -74,8 +74,8 @@
         /* Loads sqlite3-api.js and calls the given callback (if
            provided), passing it an object which contains the sqlite3
            and SQLite3 modules. Whether this is synchronous or async
-           depends on whether it's run in the main thread or a
-           worker.*/
+           depends on whether it's run in the main thread (async) or a
+           worker (synchronous). */
         loadSqliteAPI: function(callback){
             const theScript = 'sqlite3-api.js';
             if(self.importScripts){/*worker*/
             }
         }
     };
-    
-    /**
-       Helpers for writing sqlite3-specific tests.
-    */
-    self.SqliteTester = {
-        /** Running total of the number of tests run via
-            this API. */
-        counter: 0,
-        /**
-           If expr is a function, it is called and its result
-           is returned, coerced to a bool, else expr, coerced to
-           a bool, is returned.
-        */
-        toBool: function(expr){
-            return (expr instanceof Function) ? !!expr() : !!expr;
-        },
-        /** abort() if expr is false. If expr is a function, it
-            is called and its result is evaluated.
-        */
-        assert: function(expr, msg){
-            ++this.counter;
-            if(!this.toBool(expr)) abort(msg || "Assertion failed.");
-            return this;
-        },
-        /** Identical to assert() but throws instead of calling
-            abort(). */
-        affirm: function(expr, msg){
-            ++this.counter;
-            if(!this.toBool(expr)) throw new Error(msg || "Affirmation failed.");
-            return this;
-        },
-        /** Calls f() and squelches any exception it throws. If it
-            does not throw, this function throws. */
-        mustThrow: function(f, msg){
-            ++this.counter;
-            let err;
-            try{ f(); } catch(e){err=e;}
-            if(!err) throw new Error(msg || "Expected exception.");
-            return this;
-        },
-        /** Throws if expr is truthy or expr is a function and expr()
-            returns truthy. */
-        throwIf: function(expr, msg){
-            ++this.counter;
-            if(this.toBool(expr)) throw new Error(msg || "throwIf() failed");
-            return this;
-        },
-        /** Throws if expr is falsy or expr is a function and expr()
-            returns falsy. */
-        throwUnless: function(expr, msg){
-            ++this.counter;
-            if(!this.toBool(expr)) throw new Error(msg || "throwUnless() failed");
-            return this;
-        }
-    };
 
 })(self/*window or worker*/);
index 56d2cb53b3105866fd33623f9fc275b64af8e800..d428f12f653f3adbbe765e03486a55cb34dbab45 100644 (file)
@@ -25,6 +25,7 @@
     </div><!-- /emscripten bits -->
     <div>Everything on this page happens in the dev console.</div>
     <script src="testing-common.js"></script>
+    <script src="SqliteTestUtil.js"></script>
     <script src="testing1.js"></script>
     <script src="sqlite3.js"></script>
   </body>
index 7f024bf032e758dcdb48d0d93a8663eed55ed1e5..a59d2d2cc27bc6a257624dbcf062e1aad1080336 100644 (file)
 const mainTest1 = function(namespace){
     const S = namespace.sqlite3.api;
     const oo = namespace.sqlite3.SQLite3;
-    const T = self.SqliteTester;
+    const T = self.SqliteTestUtil;
     console.log("Loaded module:",S.sqlite3_libversion(),
                 S.sqlite3_sourceid());
     const db = new oo.DB();
+    const log = console.log.bind(console);
     try {
-        const log = console.log.bind(console);
         T.assert(db._pDb);
         log("DB:",db.filename);
         log("Build options:",oo.compileOptionUsed());
@@ -95,7 +95,11 @@ INSERT INTO t(a,b) VALUES(1,2),(3,4),(?,?);`,
     }
 };
 
-self/*window or worker*/.Module.onRuntimeInitialized = function(){
-    console.log("Loading sqlite3-api.js...");
-    self.Module.loadSqliteAPI(mainTest1);
-};
+self/*window or worker*/.Module.postRun.push(function(theModule){
+    /** Use a timeout so that we are (hopefully) out from under the
+        module init stack when our setup gets run. */
+    
+    setTimeout(function(){
+        theModule.loadSqliteAPI(mainTest1);
+    },0);
+});
index 3d192125d290cbc4af500a0f5ca5f1ff4aaa4a74..f2a75f05f8e9197f7004e157dc9f066d4ecaf720 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C fiddle:\scleaned\sup\sand\sdocumented\sthe\sstatus-loading\sprogress\smechanism\sin\sprep\sfor\sreusing\sit\sin\sthe\ssqlite3-api\sworker.
-D 2022-05-23T16:54:18.777
+C wasm:\sminor\srefactoring\sand\sdoc\supdates.
+D 2022-05-23T19:38:57.101
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -59,15 +59,16 @@ F ext/fiddle/EXPORTED_FUNCTIONS.fiddle 487fc7c83d45c48326f731c89162ed17ab15767e5
 F ext/fiddle/EXPORTED_FUNCTIONS.sqlite3 5816adc4d4715b410a9df971c70f55fca610d3a240bd85d2ec34e75483cb54bb
 F ext/fiddle/EXPORTED_RUNTIME_METHODS 91d5dcb0168ee056fa1a340cb8ab3c23d922622f8dad39d28919dd8af2b3ade0
 F ext/fiddle/Makefile 9277c73e208b9c8093659256c9f07409c877e366480c7c22ec545ee345451d95
+F ext/fiddle/SqliteTestUtil.js e3094833660a6ddd40766b802901b5861b37f0b89c6c577ee0ce4c9d36399e61
 F ext/fiddle/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f
 F ext/fiddle/fiddle-worker.js e87c17070b979bd057a6849332f2a86660a4255ff7f1b6671e3e6026182ffd5a
 F ext/fiddle/fiddle.html 657c6c3f860c322fba3c69fa4f7a1209e2d2ce44b4bc65a3e154e3a97c047a7c
 F ext/fiddle/fiddle.js 68f5bb45fc1ae7f8ae3f6b85f465257db514d12bf50ec492259685178c452a88
 F ext/fiddle/index.md d9c1c308d8074341bc3b11d1d39073cd77754cb3ca9aeb949f23fdd8323d81cf
 F ext/fiddle/sqlite3-api.js c684fc5ce6b6c3e70f33699de2fc4bf9eaf045a217a30125a9da31737a9ca9e7
-F ext/fiddle/testing-common.js 53284264504821314f052017b54fa75ab065dcd9cbb754cc8060930498faeee8
-F ext/fiddle/testing1.html 68cec1b1c8646a071717e5979f22e4268e6d36d96ba13ad68333351acdbcf1d1
-F ext/fiddle/testing1.js d28af2b33a9c1c47668bc74b3b7d4198012a4c62e25dd35550794fcc26be3057
+F ext/fiddle/testing-common.js 723aada13d90a5ee3f0f8f5b5b88e46954becae5d2b04ded811d90106057f4ac
+F ext/fiddle/testing1.html 026502e5d5e6a250e4101f8e8948708a1295ce831a094d741839ecaf788d8533
+F ext/fiddle/testing1.js c3d529379f901846907b00f62dffe752ff5724fb39791d47b421c4afdab0f58b
 F ext/fts1/README.txt 20ac73b006a70bcfd80069bdaf59214b6cf1db5e
 F ext/fts1/ft_hash.c 3927bd880e65329bdc6f506555b228b28924921b
 F ext/fts1/ft_hash.h 06df7bba40dadd19597aa400a875dbc2fed705ea
@@ -1967,8 +1968,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P c16a7f4950d47c2f5177db7dc5d83f0f11eb0cafdce1ec688d6f1bd740d92733
-R d12da4267c62c5adab320ccc656c0131
+P 107e3497869d757265f2a4235082bf324ba1220075d1096c2a82021a5d348a6c
+R e327ce077052e8c8f39099637b67690c
 U stephan
-Z e5ea295f62c882bcf12e60eff235c6ea
+Z 572c126f779e5a94cb3892ddd8508065
 # Remove this line to create a well-formed Fossil manifest.
index 6b5e057ea107985a671c32604d0e821b5c9293b6..b561a9295aba7b33ba5d6b9f4ce705b87e591be7 100644 (file)
@@ -1 +1 @@
-107e3497869d757265f2a4235082bf324ba1220075d1096c2a82021a5d348a6c
\ No newline at end of file
+6044605b2a712da73600cabb967797a03ed1915dc0ab0b10edbd52525e548196
\ No newline at end of file