summaryrefslogtreecommitdiff
path: root/test/spec/address.wast
diff options
context:
space:
mode:
authorJay Phelps <hello@jayphelps.com>2018-09-11 16:09:45 -0400
committerAlon Zakai <alonzakai@gmail.com>2018-09-11 13:09:45 -0700
commit30de95a537857eac7c33b46cdf3606f93dff37c9 (patch)
tree989b06234755d04350f7e7a1bed1e4cf973da931 /test/spec/address.wast
parent249b4b78d765c0f83029c3afd107cbe9ea025681 (diff)
downloadbinaryen-30de95a537857eac7c33b46cdf3606f93dff37c9.tar.gz
binaryen-30de95a537857eac7c33b46cdf3606f93dff37c9.tar.bz2
binaryen-30de95a537857eac7c33b46cdf3606f93dff37c9.zip
check-in the test/spec suite instead of as submodule (#1677)
Diffstat (limited to 'test/spec/address.wast')
-rw-r--r--test/spec/address.wast34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/spec/address.wast b/test/spec/address.wast
new file mode 100644
index 000000000..4f8e34982
--- /dev/null
+++ b/test/spec/address.wast
@@ -0,0 +1,34 @@
+(module
+ (import "spectest" "print" (func $print (param i32)))
+
+ (memory 1)
+ (data (i32.const 0) "abcdefghijklmnopqrstuvwxyz")
+
+ (func (export "good") (param $i i32)
+ (call $print (i32.load8_u offset=0 (get_local $i))) ;; 97 'a'
+ (call $print (i32.load8_u offset=1 (get_local $i))) ;; 98 'b'
+ (call $print (i32.load8_u offset=2 (get_local $i))) ;; 99 'c'
+ (call $print (i32.load8_u offset=25 (get_local $i))) ;; 122 'z'
+
+ (call $print (i32.load16_u offset=0 (get_local $i))) ;; 25185 'ab'
+ (call $print (i32.load16_u align=1 (get_local $i))) ;; 25185 'ab'
+ (call $print (i32.load16_u offset=1 align=1 (get_local $i))) ;; 25442 'bc'
+ (call $print (i32.load16_u offset=2 (get_local $i))) ;; 25699 'cd'
+ (call $print (i32.load16_u offset=25 align=1 (get_local $i))) ;; 122 'z\0'
+
+ (call $print (i32.load offset=0 (get_local $i))) ;; 1684234849 'abcd'
+ (call $print (i32.load offset=1 align=1 (get_local $i))) ;; 1701077858 'bcde'
+ (call $print (i32.load offset=2 align=2 (get_local $i))) ;; 1717920867 'cdef'
+ (call $print (i32.load offset=25 align=1 (get_local $i))) ;; 122 'z\0\0\0'
+ )
+
+ (func (export "bad") (param $i i32)
+ (drop (i32.load offset=4294967295 (get_local $i)))
+ )
+)
+
+(invoke "good" (i32.const 0))
+(invoke "good" (i32.const 65507))
+(assert_trap (invoke "good" (i32.const 65508)) "out of bounds memory access")
+(assert_trap (invoke "bad" (i32.const 0)) "out of bounds memory access")
+(assert_trap (invoke "bad" (i32.const 1)) "out of bounds memory access")