Skip to content

Commit 69de931

Browse files
leoyvensJannis Pohlmann
authored andcommitted
runtime: Bring back test for abort
1 parent 9679a32 commit 69de931

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

runtime/wasm/src/module/test.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,3 +455,13 @@ fn big_int_arithmetic() {
455455
let result: BigInt = module.heap.asc_get(result_ptr);
456456
assert_eq!(result, BigInt::from(1));
457457
}
458+
459+
#[test]
460+
fn abort() {
461+
let mut module = test_module(mock_data_source("wasm_test/abort.wasm"));
462+
let err = module
463+
.module
464+
.invoke_export("abort", &[], &mut module.externals)
465+
.unwrap_err();
466+
assert_eq!(err.to_string(), "Trap: Trap { kind: Host(HostExportError(\"Mapping aborted at abort.ts, line 7, column 2, with message: not true\")) }");
467+
}

runtime/wasm/wasm_test/abort.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import "allocator/arena";
2+
3+
export { memory };
4+
5+
export function abort(): void {
6+
json.toI64("1")
7+
assert(false, "not true")
8+
}
9+
10+
// Needed because we require an import section.
11+
declare namespace json {
12+
function toI64(decimal: string): i64
13+
}

runtime/wasm/wasm_test/abort.wasm

3.66 KB
Binary file not shown.

0 commit comments

Comments
 (0)