summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/spec/globals.wast
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/jit-test/tests/wasm/spec/globals.wast
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/jit-test/tests/wasm/spec/globals.wast')
-rw-r--r--js/src/jit-test/tests/wasm/spec/globals.wast97
1 files changed, 97 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/wasm/spec/globals.wast b/js/src/jit-test/tests/wasm/spec/globals.wast
new file mode 100644
index 000000000..97d928f84
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/spec/globals.wast
@@ -0,0 +1,97 @@
+;; Test globals
+
+(module
+ (global $a i32 (i32.const -2))
+ (global (;1;) f32 (f32.const -3))
+ (global (;2;) f64 (f64.const -4))
+ (global $b i64 (i64.const -5))
+
+ (global $x (mut i32) (i32.const -12))
+ (global (;5;) (mut f32) (f32.const -13))
+ (global (;6;) (mut f64) (f64.const -14))
+ (global $y (mut i64) (i64.const -15))
+
+ (func (export "get-a") (result i32) (get_global $a))
+ (func (export "get-b") (result i64) (get_global $b))
+ (func (export "get-x") (result i32) (get_global $x))
+ (func (export "get-y") (result i64) (get_global $y))
+ (func (export "set-x") (param i32) (set_global $x (get_local 0)))
+ (func (export "set-y") (param i64) (set_global $y (get_local 0)))
+
+ (func (export "get-1") (result f32) (get_global 1))
+ (func (export "get-2") (result f64) (get_global 2))
+ (func (export "get-5") (result f32) (get_global 5))
+ (func (export "get-6") (result f64) (get_global 6))
+ (func (export "set-5") (param f32) (set_global 5 (get_local 0)))
+ (func (export "set-6") (param f64) (set_global 6 (get_local 0)))
+)
+
+(assert_return (invoke "get-a") (i32.const -2))
+(assert_return (invoke "get-b") (i64.const -5))
+(assert_return (invoke "get-x") (i32.const -12))
+(assert_return (invoke "get-y") (i64.const -15))
+
+(assert_return (invoke "get-1") (f32.const -3))
+(assert_return (invoke "get-2") (f64.const -4))
+(assert_return (invoke "get-5") (f32.const -13))
+(assert_return (invoke "get-6") (f64.const -14))
+
+(assert_return (invoke "set-x" (i32.const 6)))
+(assert_return (invoke "set-y" (i64.const 7)))
+(assert_return (invoke "set-5" (f32.const 8)))
+(assert_return (invoke "set-6" (f64.const 9)))
+
+(assert_return (invoke "get-x") (i32.const 6))
+(assert_return (invoke "get-y") (i64.const 7))
+(assert_return (invoke "get-5") (f32.const 8))
+(assert_return (invoke "get-6") (f64.const 9))
+
+(assert_invalid
+ (module (global f32 (f32.const 0)) (func (set_global 0 (i32.const 1))))
+ "global is immutable"
+)
+
+(assert_invalid
+ (module (import "m" "a" (global (mut i32))))
+ "mutable globals cannot be imported"
+)
+
+(assert_invalid
+ (module (global (import "m" "a") (mut i32)))
+ "mutable globals cannot be imported"
+)
+
+(assert_invalid
+ (module (global (mut f32) (f32.const 0)) (export "a" (global 0)))
+ "mutable globals cannot be exported"
+)
+
+(assert_invalid
+ (module (global (export "a") (mut f32) (f32.const 0)))
+ "mutable globals cannot be exported"
+)
+
+(assert_invalid
+ (module (global f32 (f32.neg (f32.const 0))))
+ "constant expression required"
+)
+
+(assert_invalid
+ (module (global f32 (get_local 0)))
+ "constant expression required"
+)
+
+(assert_invalid
+ (module (global i32 (f32.const 0)))
+ "type mismatch"
+)
+
+(assert_invalid
+ (module (global i32 (get_global 0)))
+ "unknown global"
+)
+
+(assert_invalid
+ (module (global i32 (get_global 1)) (global i32 (i32.const 0)))
+ "unknown global"
+)