diff options
author | stephan <stephan@noemail.net> | 2025-02-03 18:01:42 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2025-02-03 18:01:42 +0000 |
commit | 6e5802fc744d3345b03fa4bbce98c1889c8bcc54 (patch) | |
tree | bc59fed6e53c8122b70e4719f657d79fb25ce0ea /ext/wasm/tester1.c-pp.js | |
parent | 3cd34ab981ebed34bce66c19bb9144e40c6e9204 (diff) | |
download | sqlite-6e5802fc744d3345b03fa4bbce98c1889c8bcc54.tar.gz sqlite-6e5802fc744d3345b03fa4bbce98c1889c8bcc54.zip |
Improve the JS-side sqlite3_set_auxdata() test to also trigger the case that the aux data actually gets reused. Test changes only, no library code.
FossilOrigin-Name: 9f27379d860518e6e097a2c999da04176812260a61bf11fe495c3efd76971806
Diffstat (limited to 'ext/wasm/tester1.c-pp.js')
-rw-r--r-- | ext/wasm/tester1.c-pp.js | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index 9038d6832..28d61de07 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -3445,7 +3445,6 @@ globalThis.sqlite3InitModule = sqlite3InitModule; const stack = wasm.pstack.pointer; const pAux = wasm.pstack.alloc(4); let pAuxDestructed = 0; - const args = []; const pAuxDtor = wasm.installFunction('v(p)', function(ptr){ //log("freeing auxdata"); ++pAuxDestructed; @@ -3457,10 +3456,11 @@ globalThis.sqlite3InitModule = sqlite3InitModule; wasm.uninstallFunction(pAuxDtor); } }; + let nAuxSet = 0 /* how many times we set aux data */; + let nAuxReused = 0 /* how many times we reused aux data */; try{ db.createFunction("auxtest",{ xFunc: function(pCx, x, y){ - args.push(x); T.assert(wasm.isPtr(pCx)); const localAux = capi.sqlite3_get_auxdata(pCx, 0); if( !localAux ){ @@ -3477,15 +3477,12 @@ globalThis.sqlite3InitModule = sqlite3InitModule; pointer this function, and cleanup (at some point) using wasm.uninstallFunction(). */ + ++nAuxSet; capi.sqlite3_set_auxdata(pCx, 0, pAux, pAuxDtor); }else{ - /* This is never actually hit in this example and it's - not entirely clear how to cause it to. The point of - this test, however, is to demonstrate that the - finalizer impl gets triggered, so we're not going to - fret over this at the moment. */ - //log("seen auxdata",localAux); + //log("reusing auxdata",localAux); T.assert(pAux===localAux); + ++nAuxReused; } return x; } @@ -3493,13 +3490,14 @@ globalThis.sqlite3InitModule = sqlite3InitModule; db.exec([ "create table t(a);", "insert into t(a) values(1),(2),(3);", - "select auxtest(a,a), auxtest(a,a) from t order by a" + "select auxtest(1,a), auxtest(1,a) from t order by a" ]); }finally{ db.close(); wasm.pstack.restore(stack); } - T.assert(6===args.length); + T.assert(nAuxSet>0).assert(nAuxReused>0) + .assert(6===nAuxReused+nAuxSet); T.assert(pAuxDestructed>0); T.assert(pAuxDtorDestructed); } |