diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/roundtrip/fold-call-import-gen-names.txt | 43 | ||||
-rw-r--r-- | test/roundtrip/generate-existing-name.txt | 25 | ||||
-rw-r--r-- | test/roundtrip/generate-from-export-name.txt | 37 | ||||
-rw-r--r-- | test/roundtrip/generate-from-import-name.txt | 29 | ||||
-rw-r--r-- | test/roundtrip/generate-func-names.txt | 14 | ||||
-rw-r--r-- | test/roundtrip/generate-func-type-names.txt | 4 | ||||
-rw-r--r-- | test/roundtrip/generate-import-names.txt | 8 |
7 files changed, 148 insertions, 12 deletions
diff --git a/test/roundtrip/fold-call-import-gen-names.txt b/test/roundtrip/fold-call-import-gen-names.txt new file mode 100644 index 00000000..9e4fa7af --- /dev/null +++ b/test/roundtrip/fold-call-import-gen-names.txt @@ -0,0 +1,43 @@ +;;; TOOL: run-roundtrip +;;; FLAGS: --stdout --fold-exprs --generate-names +(module + (import "a" "b" (func (param i32) (result i32))) + + (func (export "c") (param i64) (result i32) + get_local 0 + i32.wrap/i64) + + ;; Make sure that calls are folded properly when referencing generated names + ;; (there was a bug here). + + (func (result i32) + i32.const 1 + call 0 + i32.const 2 + call 0 + i32.add + + i64.const 3 + call 1 + drop)) + +(;; STDOUT ;;; +(module + (type $t0 (func (param i32) (result i32))) + (type $t1 (func (param i64) (result i32))) + (type $t2 (func (result i32))) + (import "a" "b" (func $a.b (type $t0))) + (func $c (type $t1) (param $p0 i64) (result i32) + (i32.wrap/i64 + (get_local $p0))) + (func $f2 (type $t2) (result i32) + (i32.add + (call $a.b + (i32.const 1)) + (call $a.b + (i32.const 2))) + (drop + (call $c + (i64.const 3)))) + (export "c" (func $c))) +;;; STDOUT ;;) diff --git a/test/roundtrip/generate-existing-name.txt b/test/roundtrip/generate-existing-name.txt new file mode 100644 index 00000000..67f7e7b6 --- /dev/null +++ b/test/roundtrip/generate-existing-name.txt @@ -0,0 +1,25 @@ +;;; TOOL: run-roundtrip +;;; FLAGS: --stdout --debug-names --generate-names + +;; The name generator should choose a different name if it already exists. This +;; can only be tested for funcs/locals, since no other names are roundtrippable +;; yet. + +(module + ;; Test func + (func) + (func $f0) + + ;; Test local + (func + (local i32) + (local $l0 i32)) +) +(;; STDOUT ;;; +(module + (type $t0 (func)) + (func $f0_1 (type $t0)) + (func $f0 (type $t0)) + (func $f2 (type $t0) + (local $l0_1 i32) (local $l0 i32))) +;;; STDOUT ;;) diff --git a/test/roundtrip/generate-from-export-name.txt b/test/roundtrip/generate-from-export-name.txt new file mode 100644 index 00000000..17fc1f84 --- /dev/null +++ b/test/roundtrip/generate-from-export-name.txt @@ -0,0 +1,37 @@ +;;; TOOL: run-roundtrip +;;; FLAGS: --stdout --debug-names --generate-names + +(module + (func (export "my_func")) + (table (export "my_table") 1 anyfunc) + (memory (export "my_memory") 1) + (global (export "my_global") i32 (i32.const 1)) + + ;; Handle name collisions + (func $foo (result i32) + (i32.const 123)) + (func $foo_1 (result i32) + (i32.const 456)) + (func (export "foo") (result i32) + (i32.const 789)) +) +(;; STDOUT ;;; +(module + (type $t0 (func)) + (type $t1 (func (result i32))) + (func $my_func (type $t0)) + (func $foo (type $t1) (result i32) + i32.const 123) + (func $foo_1 (type $t1) (result i32) + i32.const 456) + (func $foo_2 (type $t1) (result i32) + i32.const 789) + (table $my_table 1 anyfunc) + (memory $my_memory 1) + (global $my_global i32 (i32.const 1)) + (export "my_func" (func $my_func)) + (export "my_table" (table 0)) + (export "my_memory" (memory 0)) + (export "my_global" (global 0)) + (export "foo" (func $foo_2))) +;;; STDOUT ;;) diff --git a/test/roundtrip/generate-from-import-name.txt b/test/roundtrip/generate-from-import-name.txt new file mode 100644 index 00000000..d6f76029 --- /dev/null +++ b/test/roundtrip/generate-from-import-name.txt @@ -0,0 +1,29 @@ +;;; TOOL: run-roundtrip +;;; FLAGS: --stdout --debug-names --generate-names + +(module + (func (import "m1" "my_func")) + (table (import "m2" "my_table") 1 anyfunc) + (memory (import "m3" "my_memory") 1) + (global (import "m4" "my_global") i32) + + ;; Handle name collisions + (func (import "m5" "foo_1") (result f32)) + (func (import "m5" "foo") (result i32)) + (func $m5.foo (result i32) + (i32.const 123)) +) +(;; STDOUT ;;; +(module + (type $t0 (func)) + (type $t1 (func (result f32))) + (type $t2 (func (result i32))) + (import "m1" "my_func" (func $m1.my_func (type $t0))) + (import "m2" "my_table" (table $m2.my_table 1 anyfunc)) + (import "m3" "my_memory" (memory $m3.my_memory 1)) + (import "m4" "my_global" (global $m4.my_global i32)) + (import "m5" "foo_1" (func $m5.foo_1 (type $t1))) + (import "m5" "foo" (func $m5.foo_2 (type $t2))) + (func $m5.foo (type $t2) (result i32) + i32.const 123)) +;;; STDOUT ;;) diff --git a/test/roundtrip/generate-func-names.txt b/test/roundtrip/generate-func-names.txt index 39e3b4c6..50ae664f 100644 --- a/test/roundtrip/generate-func-names.txt +++ b/test/roundtrip/generate-func-names.txt @@ -4,17 +4,19 @@ (func) (func call 0) + (func (; not exported ;)) (table anyfunc (elem 0 1 0)) (export "zero" (func 0)) (export "one" (func 1))) (;; STDOUT ;;; (module (type $t0 (func)) - (func $f0 (type $t0)) - (func $f1 (type $t0) - call $f0) + (func $zero (type $t0)) + (func $one (type $t0) + call $zero) + (func $f2 (type $t0)) (table $T0 3 3 anyfunc) - (export "zero" (func $f0)) - (export "one" (func $f1)) - (elem (i32.const 0) $f0 $f1 $f0)) + (export "zero" (func $zero)) + (export "one" (func $one)) + (elem (i32.const 0) $zero $one $zero)) ;;; STDOUT ;;) diff --git a/test/roundtrip/generate-func-type-names.txt b/test/roundtrip/generate-func-type-names.txt index df3a64bd..0474a495 100644 --- a/test/roundtrip/generate-func-type-names.txt +++ b/test/roundtrip/generate-func-type-names.txt @@ -14,12 +14,12 @@ (module (type $t0 (func)) (type $t1 (func (result i32))) - (import "foo" "bar" (func $f0 (type $t0))) + (import "foo" "bar" (func $foo.bar (type $t0))) (func $f1 (type $t0)) (func $f2 (type $t1) (result i32) i32.const 0 call_indirect $t0 i32.const 1) (table $T0 1 1 anyfunc) - (elem (i32.const 0) $f0)) + (elem (i32.const 0) $foo.bar)) ;;; STDOUT ;;) diff --git a/test/roundtrip/generate-import-names.txt b/test/roundtrip/generate-import-names.txt index e745cfa8..98522503 100644 --- a/test/roundtrip/generate-import-names.txt +++ b/test/roundtrip/generate-import-names.txt @@ -13,11 +13,11 @@ (type $t0 (func (param i32))) (type $t1 (func (param f32))) (type $t2 (func)) - (import "an" "import" (func $f0 (type $t0))) - (import "another" "import" (func $f1 (type $t1))) + (import "an" "import" (func $an.import (type $t0))) + (import "another" "import" (func $another.import (type $t1))) (func $f2 (type $t2) i32.const 0 - call $f0 + call $an.import f32.const 0x0p+0 (;=0;) - call $f1)) + call $another.import)) ;;; STDOUT ;;) |