Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make memory_trap tests use addresses relative to memory_size... #112

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions ml-proto/test/memory_trap.wast
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
(memory 100)

(export "store" $store)
(func $store (param $i i32) (param $v i32) (i32.store (get_local $i) (get_local $v)))

(func $store (param $i i32) (param $v i32) (i32.store (i32.add (memory_size) (get_local $i)) (get_local $v)))
(export "load" $load)
(func $load (param $i i32) (result i32) (i32.load (get_local $i)))
(func $load (param $i i32) (result i32) (i32.load (i32.add (memory_size) (get_local $i))))
)

(invoke "store" (i32.const 96) (i32.const 42))
(assert_return (invoke "load" (i32.const 96)) (i32.const 42))
(assert_trap (invoke "store" (i32.const 97) (i32.const 13)) "runtime: out of bounds memory access")
(assert_trap (invoke "load" (i32.const 97)) "runtime: out of bounds memory access")
(assert_trap (invoke "store" (i32.const 98) (i32.const 13)) "runtime: out of bounds memory access")
(assert_trap (invoke "load" (i32.const 98)) "runtime: out of bounds memory access")
(assert_trap (invoke "store" (i32.const 99) (i32.const 13)) "runtime: out of bounds memory access")
(assert_trap (invoke "load" (i32.const 99)) "runtime: out of bounds memory access")
(invoke "store" (i32.const -4) (i32.const 42))
(assert_return (invoke "load" (i32.const -4)) (i32.const 42))
(assert_trap (invoke "store" (i32.const -3) (i32.const 13)) "runtime: out of bounds memory access")
(assert_trap (invoke "load" (i32.const -3)) "runtime: out of bounds memory access")
(assert_trap (invoke "store" (i32.const -2) (i32.const 13)) "runtime: out of bounds memory access")
(assert_trap (invoke "load" (i32.const -2)) "runtime: out of bounds memory access")
(assert_trap (invoke "store" (i32.const -1) (i32.const 13)) "runtime: out of bounds memory access")
(assert_trap (invoke "load" (i32.const -1)) "runtime: out of bounds memory access")
(assert_trap (invoke "store" (i32.const 0) (i32.const 13)) "runtime: out of bounds memory access")
(assert_trap (invoke "load" (i32.const 0)) "runtime: out of bounds memory access")