Start a wast testing harness and add some tests.
This implements a minimal wast testing harness in tests/wast.rs, which runs the wast tests under tests/wast. It also adds tests for trapping in a variety of ways, and fixes several bugs exposed by those tests.
This commit is contained in:
67
tests/wast/misc_traps.wast
Normal file
67
tests/wast/misc_traps.wast
Normal file
@@ -0,0 +1,67 @@
|
||||
(module
|
||||
(memory 1 1)
|
||||
(func (export "load_oob")
|
||||
i32.const 65536
|
||||
i32.load
|
||||
drop
|
||||
)
|
||||
)
|
||||
|
||||
(assert_trap (invoke "load_oob") "out of bounds memory access")
|
||||
(assert_trap (invoke "load_oob") "out of bounds memory access")
|
||||
|
||||
(module
|
||||
(memory 1 1)
|
||||
(func (export "store_oob")
|
||||
i32.const 65536
|
||||
i32.const 65536
|
||||
i32.store
|
||||
)
|
||||
)
|
||||
|
||||
(assert_trap (invoke "store_oob") "out of bounds memory access")
|
||||
(assert_trap (invoke "store_oob") "out of bounds memory access")
|
||||
|
||||
(module
|
||||
(memory 0 0)
|
||||
(func (export "load_oob_0")
|
||||
i32.const 0
|
||||
i32.load
|
||||
drop
|
||||
)
|
||||
)
|
||||
|
||||
(assert_trap (invoke "load_oob_0") "out of bounds memory access")
|
||||
(assert_trap (invoke "load_oob_0") "out of bounds memory access")
|
||||
|
||||
(module
|
||||
(memory 0 0)
|
||||
(func (export "store_oob_0")
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.store
|
||||
)
|
||||
)
|
||||
|
||||
(assert_trap (invoke "store_oob_0") "out of bounds memory access")
|
||||
(assert_trap (invoke "store_oob_0") "out of bounds memory access")
|
||||
|
||||
(module
|
||||
(func (export "divbyzero") (result i32)
|
||||
i32.const 1
|
||||
i32.const 0
|
||||
i32.div_s
|
||||
)
|
||||
)
|
||||
|
||||
(assert_trap (invoke "divbyzero") "integer divide by zero")
|
||||
(assert_trap (invoke "divbyzero") "integer divide by zero")
|
||||
|
||||
(module
|
||||
(func (export "unreachable")
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
|
||||
(assert_trap (invoke "unreachable") "unreachable")
|
||||
(assert_trap (invoke "unreachable") "unreachable")
|
||||
26
tests/wast/stack_overflow.wast
Normal file
26
tests/wast/stack_overflow.wast
Normal file
@@ -0,0 +1,26 @@
|
||||
(module
|
||||
(func $foo
|
||||
(call $foo)
|
||||
)
|
||||
(func (export "stack_overflow")
|
||||
(call $foo)
|
||||
)
|
||||
)
|
||||
|
||||
(assert_exhaustion (invoke "stack_overflow") "call stack exhausted")
|
||||
(assert_exhaustion (invoke "stack_overflow") "call stack exhausted")
|
||||
|
||||
(module
|
||||
(func $foo
|
||||
(call $bar)
|
||||
)
|
||||
(func $bar
|
||||
(call $foo)
|
||||
)
|
||||
(func (export "stack_overflow")
|
||||
(call $foo)
|
||||
)
|
||||
)
|
||||
|
||||
(assert_exhaustion (invoke "stack_overflow") "call stack exhausted")
|
||||
(assert_exhaustion (invoke "stack_overflow") "call stack exhausted")
|
||||
Reference in New Issue
Block a user