summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/example/c-api-kitchen-sink.c6
-rw-r--r--test/passes/dae_all-features.txt20
-rw-r--r--test/passes/dae_all-features.wast21
-rw-r--r--test/passes/duplicate-function-elimination_all-features.txt13
-rw-r--r--test/passes/duplicate-function-elimination_all-features.wast18
5 files changed, 75 insertions, 3 deletions
diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c
index 9e6366d36..aa82723b4 100644
--- a/test/example/c-api-kitchen-sink.c
+++ b/test/example/c-api-kitchen-sink.c
@@ -893,12 +893,12 @@ void test_core() {
BinaryenModuleSetFeatures(module, features);
assert(BinaryenModuleGetFeatures(module) == features);
- // Verify it validates
- assert(BinaryenModuleValidate(module));
-
// Print it out
BinaryenModulePrint(module);
+ // Verify it validates
+ assert(BinaryenModuleValidate(module));
+
// Clean up the module, which owns all the objects we created above
BinaryenModuleDispose(module);
}
diff --git a/test/passes/dae_all-features.txt b/test/passes/dae_all-features.txt
index 4ca21576f..ea439bc9e 100644
--- a/test/passes/dae_all-features.txt
+++ b/test/passes/dae_all-features.txt
@@ -292,3 +292,23 @@
(ref.func $0)
)
)
+(module
+ (type $none_=>_none (func))
+ (type $i64 (func (param i64)))
+ (global $global$0 (ref $i64) (ref.func $0))
+ (export "even" (func $1))
+ (func $0 (param $0 i64)
+ (unreachable)
+ )
+ (func $1
+ (call_ref
+ (i64.const 0)
+ (global.get $global$0)
+ )
+ )
+ (func $2
+ (call $0
+ (i64.const 0)
+ )
+ )
+)
diff --git a/test/passes/dae_all-features.wast b/test/passes/dae_all-features.wast
index 097c144cc..55e935f3b 100644
--- a/test/passes/dae_all-features.wast
+++ b/test/passes/dae_all-features.wast
@@ -172,3 +172,24 @@
(ref.func $0)
)
)
+(module
+ (type $i64 (func (param i64)))
+ (global $global$0 (ref $i64) (ref.func $0))
+ (export "even" (func $1))
+ ;; the argument to this function cannot be removed due to the ref.func of it
+ ;; in a global
+ (func $0 (param $0 i64)
+ (unreachable)
+ )
+ (func $1
+ (call_ref
+ (i64.const 0)
+ (global.get $global$0)
+ )
+ )
+ (func $2
+ (call $0
+ (i64.const 0)
+ )
+ )
+)
diff --git a/test/passes/duplicate-function-elimination_all-features.txt b/test/passes/duplicate-function-elimination_all-features.txt
index a7a751f76..6dd5a1004 100644
--- a/test/passes/duplicate-function-elimination_all-features.txt
+++ b/test/passes/duplicate-function-elimination_all-features.txt
@@ -19,3 +19,16 @@
(nop)
)
)
+(module
+ (type $func (func (result i32)))
+ (global $global$0 (ref $func) (ref.func $foo))
+ (export "export" (func $2))
+ (func $foo (result i32)
+ (unreachable)
+ )
+ (func $2 (result i32)
+ (call_ref
+ (global.get $global$0)
+ )
+ )
+)
diff --git a/test/passes/duplicate-function-elimination_all-features.wast b/test/passes/duplicate-function-elimination_all-features.wast
index 116542c96..1d04e878c 100644
--- a/test/passes/duplicate-function-elimination_all-features.wast
+++ b/test/passes/duplicate-function-elimination_all-features.wast
@@ -21,3 +21,21 @@
(func $foo ;; happens to share a name with the memory
)
)
+;; renaming after deduplication must update ref.funcs in globals
+(module
+ (type $func (func (result i32)))
+ (global $global$0 (ref $func) (ref.func $bar))
+ ;; These two identical functions can be merged. The ref.func in the global must
+ ;; be updated accordingly.
+ (func $foo (result i32)
+ (unreachable)
+ )
+ (func $bar (result i32)
+ (unreachable)
+ )
+ (func "export" (result i32)
+ (call_ref
+ (global.get $global$0)
+ )
+ )
+)