1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Add convenience variants of sqlite3.wasm.peek/poke() for each numeric type to help reduce errors related to typos in the final argument (type-name strings). If wasm.xWrap.FuncPtrAdapter is called as a function, instead of a constructor, it now behaves as if it were called as a constructor (previously it threw an exception).

FossilOrigin-Name: 14e3fc01b929fa3f9a2fdbd93deb4a8aad58c111d46369c772def0437152fa75
This commit is contained in:
stephan
2022-12-14 14:28:54 +00:00
parent bca56f384f
commit feb9123a8c
6 changed files with 80 additions and 20 deletions

View File

@@ -480,6 +480,7 @@ self.sqlite3InitModule = sqlite3InitModule;
T.assert(u[i] === byteList[i])
.assert(u[i] === w.peek(m + i, 'i8'));
}
w.dealloc(m);
T.mustThrowMatching(
()=>w.allocFromTypedArray(1),
@@ -487,6 +488,25 @@ self.sqlite3InitModule = sqlite3InitModule;
);
}
{ // Test peekXYZ()/pokeXYZ()...
const m = w.alloc(8);
T.assert( 17 === w.poke8(m,17).peek8(m) )
.assert( 31987 === w.poke16(m,31987).peek16(m) )
.assert( 345678 === w.poke32(m,345678).peek32(m) )
.assert(
T.eqApprox( 345678.9, w.pokeF32(m,345678.9).peekF32(m) )
).assert(
T.eqApprox( 4567890123.4, w.pokeF64(m, 4567890123.4).peekF64(m) )
);
if(w.bigIntEnabled){
T.assert(
BigInt(Number.MAX_SAFE_INTEGER) ===
w.poke64(m, Number.MAX_SAFE_INTEGER).peek64(m)
);
}
w.dealloc(m);
}
// isPtr32()
{
const ip = w.isPtr32;