summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBen Smith <binjimin@gmail.com>2018-08-15 14:26:00 -0700
committerGitHub <noreply@github.com>2018-08-15 14:26:00 -0700
commit33f758c6b43f52ea5d74cc9579c63e62de4ec33d (patch)
tree27ef60511ba675f1dfc8f58874903f1df29458b1 /test
parent0d683b182258b1e04cbbcfb319f0107b6790df36 (diff)
downloadwabt-33f758c6b43f52ea5d74cc9579c63e62de4ec33d.tar.gz
wabt-33f758c6b43f52ea5d74cc9579c63e62de4ec33d.tar.bz2
wabt-33f758c6b43f52ea5d74cc9579c63e62de4ec33d.zip
Fix: set_global on immutable global is invalid (#895)
There is a spec test for this, but spectest-interp only runs the validator in `binary-reader-interp.cc`, which is different than the validator in `validator.cc`. This is necessarily so, since some checks only make sense when the module is linked or instantiated. This fixes issue #894.
Diffstat (limited to 'test')
-rw-r--r--test/dump/setglobal.txt4
-rw-r--r--test/parse/expr/setglobal-named.txt2
-rw-r--r--test/parse/expr/setglobal.txt2
-rw-r--r--test/regress/regress-21.txt15
-rw-r--r--test/roundtrip/fold-getset-global.txt8
-rw-r--r--test/roundtrip/generate-global-names.txt4
6 files changed, 25 insertions, 10 deletions
diff --git a/test/dump/setglobal.txt b/test/dump/setglobal.txt
index 9369e2fc..3db0c46f 100644
--- a/test/dump/setglobal.txt
+++ b/test/dump/setglobal.txt
@@ -1,7 +1,7 @@
;;; TOOL: run-objdump
;;; ARGS0: -v
(module
- (global f32 (f32.const 1))
+ (global (mut f32) (f32.const 1))
(func
f32.const 2
set_global 0))
@@ -28,7 +28,7 @@
0000013: 00 ; section size (guess)
0000014: 01 ; num globals
0000015: 7d ; f32
-0000016: 00 ; global mutability
+0000016: 01 ; global mutability
0000017: 43 ; f32.const
0000018: 0000 803f ; f32 literal
000001c: 0b ; end
diff --git a/test/parse/expr/setglobal-named.txt b/test/parse/expr/setglobal-named.txt
index b6f4f33f..c8e4bdf4 100644
--- a/test/parse/expr/setglobal-named.txt
+++ b/test/parse/expr/setglobal-named.txt
@@ -1,6 +1,6 @@
;;; TOOL: wat2wasm
(module
- (global $g f32 (f32.const 1))
+ (global $g (mut f32) (f32.const 1))
(func
f32.const 2
set_global $g))
diff --git a/test/parse/expr/setglobal.txt b/test/parse/expr/setglobal.txt
index c34bb0cc..c0548596 100644
--- a/test/parse/expr/setglobal.txt
+++ b/test/parse/expr/setglobal.txt
@@ -1,6 +1,6 @@
;;; TOOL: wat2wasm
(module
- (global f32 (f32.const 1))
+ (global (mut f32) (f32.const 1))
(func
f32.const 2
set_global 0))
diff --git a/test/regress/regress-21.txt b/test/regress/regress-21.txt
new file mode 100644
index 00000000..6847e6fe
--- /dev/null
+++ b/test/regress/regress-21.txt
@@ -0,0 +1,15 @@
+;;; TOOL: wat2wasm
+;;; ERROR: 1
+(module
+ (type $foo.ty (func))
+ (global $g i32 (i32.const -1))
+ (func $foo (type $foo.ty)
+ (set_global $g (i32.const 1))
+ )
+ (export "foo" (func $foo))
+)
+(;; STDERR ;;;
+out/test/regress/regress-21.txt:7:7: error: can't set_global on immutable global at index 0.
+ (set_global $g (i32.const 1))
+ ^^^^^^^^^^
+;;; STDERR ;;)
diff --git a/test/roundtrip/fold-getset-global.txt b/test/roundtrip/fold-getset-global.txt
index 122c2a60..0766f397 100644
--- a/test/roundtrip/fold-getset-global.txt
+++ b/test/roundtrip/fold-getset-global.txt
@@ -1,8 +1,8 @@
;;; TOOL: run-roundtrip
;;; ARGS: --stdout --fold-exprs
(module
- (global i32 (i32.const 1))
- (global f32 (f32.const 1.5))
+ (global (mut i32) (i32.const 1))
+ (global (mut f32) (f32.const 1.5))
(func $fold-get-global (result i32)
get_global 1
@@ -36,6 +36,6 @@
(i32.const 1)))
(set_global 1
(f32.const 0x1p+1 (;=2;))))
- (global (;0;) i32 (i32.const 1))
- (global (;1;) f32 (f32.const 0x1.8p+0 (;=1.5;))))
+ (global (;0;) (mut i32) (i32.const 1))
+ (global (;1;) (mut f32) (f32.const 0x1.8p+0 (;=1.5;))))
;;; STDOUT ;;)
diff --git a/test/roundtrip/generate-global-names.txt b/test/roundtrip/generate-global-names.txt
index a0e0ce78..e97bbf21 100644
--- a/test/roundtrip/generate-global-names.txt
+++ b/test/roundtrip/generate-global-names.txt
@@ -2,7 +2,7 @@
;;; ARGS: --stdout --generate-names
(module
(global i32 (i32.const 42))
- (global f32 (f32.const -1.5))
+ (global (mut f32) (f32.const -1.5))
(func (result i32)
f32.const 3.0
set_global 1
@@ -15,5 +15,5 @@
set_global $g1
get_global $g0)
(global $g0 i32 (i32.const 42))
- (global $g1 f32 (f32.const -0x1.8p+0 (;=-1.5;))))
+ (global $g1 (mut f32) (f32.const -0x1.8p+0 (;=-1.5;))))
;;; STDOUT ;;)