diff --git a/examples/basic/test.d.ts b/examples/basic/test.d.ts index 38cb63d..fe7a6e4 100644 --- a/examples/basic/test.d.ts +++ b/examples/basic/test.d.ts @@ -4,7 +4,7 @@ declare module "main" { declare module "xtp:test" { interface harness { - assert(name: PTR, value: I64); + assert(name: PTR, value: I64, reason: PTR); call(func: PTR, input: PTR): PTR; time(func: PTR, input: PTR): I64; group(name: PTR); diff --git a/examples/basic/test.wasm b/examples/basic/test.wasm index e2d81b1..2c945ef 100644 Binary files a/examples/basic/test.wasm and b/examples/basic/test.wasm differ diff --git a/index.ts b/index.ts index 2181e4c..767f4ce 100644 --- a/index.ts +++ b/index.ts @@ -106,18 +106,25 @@ export class Test { return Test.call(funcName, input).readBuffer(); } - static assert(msg: string, value: boolean) { + static assert(name: string, value: boolean, reason: string) { // @ts-ignore: Memory - const a = Memory.fromString(msg); - assert(a.offset, !!value); + const a = Memory.fromString(name); + // @ts-ignore: Memory + const b = Memory.fromString(reason); + assert(a.offset, !!value, b.offset); a.free(); + b.free(); } static assertEqual(msg: string, x: unknown, y: unknown) { - Test.assert(msg, x === y); + const stack = new Error().stack; + stack.trim(); + Test.assert(msg, x === y, `Expected ${x} === ${y}\n${stack}`); } static assertNotEqual(msg: string, x: unknown, y: unknown) { - Test.assert(msg, x !== y); + const stack = new Error().stack; + stack.trim(); + Test.assert(msg, x !== y, `Expected ${x} !== ${y}\n${stack}`); } } diff --git a/test.d.ts b/test.d.ts index 38cb63d..fe7a6e4 100644 --- a/test.d.ts +++ b/test.d.ts @@ -4,7 +4,7 @@ declare module "main" { declare module "xtp:test" { interface harness { - assert(name: PTR, value: I64); + assert(name: PTR, value: I64, reason: PTR); call(func: PTR, input: PTR): PTR; time(func: PTR, input: PTR): I64; group(name: PTR);