aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/SQLTester/SQLTester.run.mjs
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2023-08-29 15:39:57 +0000
committerstephan <stephan@noemail.net>2023-08-29 15:39:57 +0000
commit69a55ca17dc711a9b75eb738ab32336936d69fd7 (patch)
treee92325eb53315ca7872162ac4081cefc2da669dd /ext/wasm/SQLTester/SQLTester.run.mjs
parent0fc20a32c0fce51c34714363173c8a93771c1425 (diff)
downloadsqlite-69a55ca17dc711a9b75eb738ab32336936d69fd7.tar.gz
sqlite-69a55ca17dc711a9b75eb738ab32336936d69fd7.zip
Get the JS SQLTester command handlers in place sans those which have to run SQL.
FossilOrigin-Name: d21b1217964a53f33b7ba3958b34aa8560dff8ede33e66f54aa0afbab7099ec3
Diffstat (limited to 'ext/wasm/SQLTester/SQLTester.run.mjs')
-rw-r--r--ext/wasm/SQLTester/SQLTester.run.mjs41
1 files changed, 33 insertions, 8 deletions
diff --git a/ext/wasm/SQLTester/SQLTester.run.mjs b/ext/wasm/SQLTester/SQLTester.run.mjs
index 4efd068e3..dc8eaa0c1 100644
--- a/ext/wasm/SQLTester/SQLTester.run.mjs
+++ b/ext/wasm/SQLTester/SQLTester.run.mjs
@@ -1,26 +1,51 @@
import {default as ns} from './SQLTester.mjs';
+globalThis.sqlite3 = ns.sqlite3;
const log = function f(...args){
console.log('SQLTester.run:',...args);
return f;
};
-console.log("Loaded",ns);
const out = function f(...args){ return f.outer.out(...args) };
out.outer = new ns.Outer();
out.outer.getOutputPrefix = ()=>'SQLTester.run: ';
const outln = (...args)=>{ return out.outer.outln(...args) };
+const affirm = function(expr, msg){
+ if( !expr ){
+ throw new Error(arguments[1]
+ ? ("Assertion failed: "+arguments[1])
+ : "Assertion failed");
+ }
+}
+
+console.log("Loaded",ns);
+
log("ns =",ns);
out("Hi there. ").outln("SQLTester is ostensibly ready.");
-let ts = new ns.TestScript('/foo.test', ns.Util.utf8Encode(`
-# comment line
-select 1;
---testcase 0.0
-#--result 1
+let ts = new ns.TestScript('/foo.test', ns.Util.utf8Encode(
+`# comment line
+--print Starting up...
+--null NIL
+--new :memory:
+--testcase 0.0.1
+select '0.0.1';
+#--result 0.0.1
+--print done
`));
const sqt = new ns.SQLTester();
-sqt.verbosity(3);
-ts.run(sqt);
+try{
+ log( 'sqt.getCurrentDb()', sqt.getCurrentDb() );
+ sqt.openDb('/foo.db', true);
+ log( 'sqt.getCurrentDb()', sqt.getCurrentDb() );
+ sqt.verbosity(0);
+ affirm( 'NIL' !== sqt.nullValue() );
+ ts.run(sqt);
+ affirm( 'NIL' === sqt.nullValue() );
+}finally{
+ sqt.reset();
+}
+log( 'sqt.getCurrentDb()', sqt.getCurrentDb() );
+