summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/example/c-api-kitchen-sink.c2
-rw-r--r--test/lit/passes/global-refining.wast28
2 files changed, 29 insertions, 1 deletions
diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c
index 5fb71b4d6..efd343be9 100644
--- a/test/example/c-api-kitchen-sink.c
+++ b/test/example/c-api-kitchen-sink.c
@@ -1176,7 +1176,7 @@ void test_core() {
makeInt32(module, 0)),
BinaryenStringNew(module,
BinaryenStringNewWTF16Array(),
- BinaryenGlobalGet(module, "i16Array-global", i8Array),
+ BinaryenGlobalGet(module, "i16Array-global", i16Array),
makeInt32(module, 0),
makeInt32(module, 0)),
BinaryenStringNew(
diff --git a/test/lit/passes/global-refining.wast b/test/lit/passes/global-refining.wast
index 8f0b3c247..81459affe 100644
--- a/test/lit/passes/global-refining.wast
+++ b/test/lit/passes/global-refining.wast
@@ -193,3 +193,31 @@
(nop)
)
)
+
+;; We can refine $a, after which we should update the global.get in the other
+;; global, or else we'd error on validation.
+;; TODO: we could optimize further here and refine the type of the global $b.
+(module
+ ;; CHECK: (type $super (sub (func)))
+ ;; CLOSD: (type $super (sub (func)))
+ (type $super (sub (func)))
+ ;; CHECK: (type $sub (sub $super (func)))
+ ;; CLOSD: (type $sub (sub $super (func)))
+ (type $sub (sub $super (func)))
+
+ ;; CHECK: (global $a (ref $sub) (ref.func $func))
+ ;; CLOSD: (global $a (ref $sub) (ref.func $func))
+ (global $a (ref $super) (ref.func $func))
+ ;; CHECK: (global $b (ref $super) (global.get $a))
+ ;; CLOSD: (global $b (ref $super) (global.get $a))
+ (global $b (ref $super) (global.get $a))
+
+ ;; CHECK: (func $func (type $sub)
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: )
+ ;; CLOSD: (func $func (type $sub)
+ ;; CLOSD-NEXT: (nop)
+ ;; CLOSD-NEXT: )
+ (func $func (type $sub)
+ )
+)