diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/binaryen.js/exception-handling.js.txt | 8 | ||||
-rw-r--r-- | test/binaryen.js/kitchen-sink.js.txt | 68 | ||||
-rw-r--r-- | test/lit/table-operations.wast | 36 | ||||
-rw-r--r-- | test/spec/table_fill.wast | 199 |
4 files changed, 273 insertions, 38 deletions
diff --git a/test/binaryen.js/exception-handling.js.txt b/test/binaryen.js/exception-handling.js.txt index 905e1a3a4..b1f6dab55 100644 --- a/test/binaryen.js/exception-handling.js.txt +++ b/test/binaryen.js/exception-handling.js.txt @@ -34,7 +34,7 @@ ) ) -getExpressionInfo(throw) = {"id":50,"type":1,"tag":"e"} -getExpressionInfo(rethrow) = {"id":51,"type":1,"target":"l0"} -getExpressionInfo(try_catch) = {"id":49,"type":1,"name":"l0","hasCatchAll":0,"delegateTarget":"","isDelegate":0} -getExpressionInfo(try_delegate) = {"id":49,"type":0,"name":"try_outer","hasCatchAll":1,"delegateTarget":"","isDelegate":0} +getExpressionInfo(throw) = {"id":51,"type":1,"tag":"e"} +getExpressionInfo(rethrow) = {"id":52,"type":1,"target":"l0"} +getExpressionInfo(try_catch) = {"id":50,"type":1,"name":"l0","hasCatchAll":0,"delegateTarget":"","isDelegate":0} +getExpressionInfo(try_delegate) = {"id":50,"type":0,"name":"try_outer","hasCatchAll":1,"delegateTarget":"","isDelegate":0} diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index e8cb7e0ab..6ae736ff0 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -82,40 +82,40 @@ TableGetId: 45 TableSetId: 46 TableSizeId: 47 TableGrowId: 48 -TryId: 49 -ThrowId: 50 -RethrowId: 51 -TupleMakeId: 52 -TupleExtractId: 53 -RefI31Id: 54 -I31GetId: 55 -CallRefId: 56 -RefTestId: 57 -RefCastId: 58 -BrOnId: 59 -StructNewId: 60 -StructGetId: 61 -StructSetId: 62 -ArrayNewId: 63 -ArrayNewFixedId: 66 -ArrayGetId: 67 -ArraySetId: 68 -ArrayLenId: 69 -ArrayCopy: 70 -RefAs: 74 -StringNew: 75 -StringConst: 76 -StringMeasure: 77 -StringEncode: 78 -StringConcat: 79 -StringEq: 80 -StringAs: 81 -StringWTF8Advance: 82 -StringWTF16Get: 83 -StringIterNext: 84 -StringIterMove: 85 -StringSliceWTF: 86 -StringSliceIter: 87 +TryId: 50 +ThrowId: 51 +RethrowId: 52 +TupleMakeId: 53 +TupleExtractId: 54 +RefI31Id: 55 +I31GetId: 56 +CallRefId: 57 +RefTestId: 58 +RefCastId: 59 +BrOnId: 60 +StructNewId: 61 +StructGetId: 62 +StructSetId: 63 +ArrayNewId: 64 +ArrayNewFixedId: 67 +ArrayGetId: 68 +ArraySetId: 69 +ArrayLenId: 70 +ArrayCopy: 71 +RefAs: 75 +StringNew: 76 +StringConst: 77 +StringMeasure: 78 +StringEncode: 79 +StringConcat: 80 +StringEq: 81 +StringAs: 82 +StringWTF8Advance: 83 +StringWTF16Get: 84 +StringIterNext: 85 +StringIterMove: 86 +StringSliceWTF: 87 +StringSliceIter: 88 getExpressionInfo={"id":15,"type":4,"op":6} (f32.neg (f32.const -33.61199951171875) diff --git a/test/lit/table-operations.wast b/test/lit/table-operations.wast index 35e5ea284..e3daa463b 100644 --- a/test/lit/table-operations.wast +++ b/test/lit/table-operations.wast @@ -16,6 +16,8 @@ ;; CHECK-BINARY: (type $2 (func (param i32) (result i32))) + ;; CHECK-BINARY: (type $3 (func (param i32 funcref i32))) + ;; CHECK-BINARY: (table $table-1 1 1 funcref) ;; CHECK-TEXT: (type $0 (func)) @@ -23,6 +25,8 @@ ;; CHECK-TEXT: (type $2 (func (param i32) (result i32))) + ;; CHECK-TEXT: (type $3 (func (param i32 funcref i32))) + ;; CHECK-TEXT: (table $table-1 1 1 funcref) (table $table-1 funcref (elem $foo) @@ -147,6 +151,28 @@ (func $table-grow (param $sz i32) (result i32) (table.grow $table-1 (ref.null func) (local.get $sz)) ) + + ;; CHECK-BINARY: (func $table-fill (type $3) (param $dest i32) (param $value funcref) (param $size i32) + ;; CHECK-BINARY-NEXT: (table.fill $table-1 + ;; CHECK-BINARY-NEXT: (local.get $dest) + ;; CHECK-BINARY-NEXT: (local.get $value) + ;; CHECK-BINARY-NEXT: (local.get $size) + ;; CHECK-BINARY-NEXT: ) + ;; CHECK-BINARY-NEXT: ) + ;; CHECK-TEXT: (func $table-fill (type $3) (param $dest i32) (param $value funcref) (param $size i32) + ;; CHECK-TEXT-NEXT: (table.fill $table-1 + ;; CHECK-TEXT-NEXT: (local.get $dest) + ;; CHECK-TEXT-NEXT: (local.get $value) + ;; CHECK-TEXT-NEXT: (local.get $size) + ;; CHECK-TEXT-NEXT: ) + ;; CHECK-TEXT-NEXT: ) + (func $table-fill (param $dest i32) (param $value funcref) (param $size i32) + (table.fill $table-1 + (local.get $dest) + (local.get $value) + (local.get $size) + ) + ) ) ;; CHECK-NODEBUG: (type $0 (func)) @@ -154,6 +180,8 @@ ;; CHECK-NODEBUG: (type $2 (func (param i32) (result i32))) +;; CHECK-NODEBUG: (type $3 (func (param i32 funcref i32))) + ;; CHECK-NODEBUG: (table $0 1 1 funcref) ;; CHECK-NODEBUG: (table $1 3 3 funcref) @@ -201,3 +229,11 @@ ;; CHECK-NODEBUG-NEXT: (local.get $0) ;; CHECK-NODEBUG-NEXT: ) ;; CHECK-NODEBUG-NEXT: ) + +;; CHECK-NODEBUG: (func $5 (type $3) (param $0 i32) (param $1 funcref) (param $2 i32) +;; CHECK-NODEBUG-NEXT: (table.fill $0 +;; CHECK-NODEBUG-NEXT: (local.get $0) +;; CHECK-NODEBUG-NEXT: (local.get $1) +;; CHECK-NODEBUG-NEXT: (local.get $2) +;; CHECK-NODEBUG-NEXT: ) +;; CHECK-NODEBUG-NEXT: ) diff --git a/test/spec/table_fill.wast b/test/spec/table_fill.wast new file mode 100644 index 000000000..79b5a6a83 --- /dev/null +++ b/test/spec/table_fill.wast @@ -0,0 +1,199 @@ +(module + (type $f (func (result i32))) + + (table $t 10 funcref) + + (func $0 (result i32) + (i32.const 0) + ) + + (func $1 (result i32) + (i32.const 1) + ) + + (func $2 (result i32) + (i32.const 2) + ) + + (func $3 (result i32) + (i32.const 3) + ) + + (func $4 (result i32) + (i32.const 4) + ) + + (func (export "fill-0") (param $i i32) (param $n i32) + (table.fill $t (local.get $i) (ref.func $0) (local.get $n)) + ) + + (func (export "fill-1") (param $i i32) (param $n i32) + (table.fill $t (local.get $i) (ref.func $1) (local.get $n)) + ) + + (func (export "fill-2") (param $i i32) (param $n i32) + (table.fill $t (local.get $i) (ref.func $2) (local.get $n)) + ) + + (func (export "fill-3") (param $i i32) (param $n i32) + (table.fill $t (local.get $i) (ref.func $3) (local.get $n)) + ) + + (func (export "fill-4") (param $i i32) (param $n i32) + (table.fill $t (local.get $i) (ref.func $4) (local.get $n)) + ) + + (func (export "fill-null") (param $i i32) (param $n i32) + (table.fill $t (local.get $i) (ref.null func) (local.get $n)) + ) + + (func (export "get-null") (param $i i32) (result funcref) + (table.get $t (local.get $i)) + ) + + (func (export "get") (param $i i32) (result i32) + (call_indirect $t (type $f) (local.get $i)) + ) +) + +(assert_return (invoke "get-null" (i32.const 1)) (ref.null func)) +(assert_return (invoke "get-null" (i32.const 2)) (ref.null func)) +(assert_return (invoke "get-null" (i32.const 3)) (ref.null func)) +(assert_return (invoke "get-null" (i32.const 4)) (ref.null func)) +(assert_return (invoke "get-null" (i32.const 5)) (ref.null func)) + +(assert_return (invoke "fill-1" (i32.const 2) (i32.const 3))) +(assert_return (invoke "get-null" (i32.const 1)) (ref.null func)) +(assert_return (invoke "get" (i32.const 2)) (i32.const 1)) +(assert_return (invoke "get" (i32.const 3)) (i32.const 1)) +(assert_return (invoke "get" (i32.const 4)) (i32.const 1)) +(assert_return (invoke "get-null" (i32.const 5)) (ref.null func)) + +(assert_return (invoke "fill-2" (i32.const 4) (i32.const 2))) +(assert_return (invoke "get" (i32.const 3)) (i32.const 1)) +(assert_return (invoke "get" (i32.const 4)) (i32.const 2)) +(assert_return (invoke "get" (i32.const 5)) (i32.const 2)) +(assert_return (invoke "get-null" (i32.const 6)) (ref.null func)) + +(assert_return (invoke "fill-3" (i32.const 4) (i32.const 0))) +(assert_return (invoke "get" (i32.const 3)) (i32.const 1)) +(assert_return (invoke "get" (i32.const 4)) (i32.const 2)) +(assert_return (invoke "get" (i32.const 5)) (i32.const 2)) + +(assert_return (invoke "fill-4" (i32.const 8) (i32.const 2))) +(assert_return (invoke "get-null" (i32.const 7)) (ref.null func)) +(assert_return (invoke "get" (i32.const 8)) (i32.const 4)) +(assert_return (invoke "get" (i32.const 9)) (i32.const 4)) + +(assert_return (invoke "fill-null" (i32.const 9) (i32.const 1))) +(assert_return (invoke "get" (i32.const 8)) (i32.const 4)) +(assert_return (invoke "get-null" (i32.const 9)) (ref.null func)) + +(assert_return (invoke "fill-1" (i32.const 10) (i32.const 0))) +(assert_return (invoke "get-null" (i32.const 9)) (ref.null func)) + +(assert_trap + (invoke "fill-2" (i32.const 8) (i32.const 3)) + "out of bounds table access" +) +(assert_return (invoke "get-null" (i32.const 7)) (ref.null func)) +(assert_return (invoke "get" (i32.const 8)) (i32.const 4)) +(assert_return (invoke "get-null" (i32.const 9)) (ref.null func)) + +(assert_trap + (invoke "fill" (i32.const 11) (ref.null extern) (i32.const 0)) + "out of bounds table access" +) + +(assert_trap + (invoke "fill" (i32.const 11) (ref.null extern) (i32.const 10)) + "out of bounds table access" +) + + +;; Type errors + +(assert_invalid + (module + (table $t 10 externref) + (func $type-index-value-length-empty-vs-i32-i32 + (table.fill $t) + ) + ) + "type mismatch" +) +(assert_invalid + (module + (table $t 10 externref) + (func $type-index-empty-vs-i32 + (table.fill $t (ref.null extern) (i32.const 1)) + ) + ) + "type mismatch" +) +(assert_invalid + (module + (table $t 10 externref) + (func $type-value-empty-vs + (table.fill $t (i32.const 1) (i32.const 1)) + ) + ) + "type mismatch" +) +(assert_invalid + (module + (table $t 10 externref) + (func $type-length-empty-vs-i32 + (table.fill $t (i32.const 1) (ref.null extern)) + ) + ) + "type mismatch" +) +(assert_invalid + (module + (table $t 0 externref) + (func $type-index-f32-vs-i32 + (table.fill $t (f32.const 1) (ref.null extern) (i32.const 1)) + ) + ) + "type mismatch" +) +(assert_invalid + (module + (table $t 0 funcref) + (func $type-value-vs-funcref (param $r externref) + (table.fill $t (i32.const 1) (local.get $r) (i32.const 1)) + ) + ) + "type mismatch" +) +(assert_invalid + (module + (table $t 0 externref) + (func $type-length-f32-vs-i32 + (table.fill $t (i32.const 1) (ref.null extern) (f32.const 1)) + ) + ) + "type mismatch" +) + +(assert_invalid + (module + (table $t1 1 externref) + (table $t2 1 funcref) + (func $type-value-externref-vs-funcref-multi (param $r externref) + (table.fill $t2 (i32.const 0) (local.get $r) (i32.const 1)) + ) + ) + "type mismatch" +) + +(assert_invalid + (module + (table $t 1 externref) + (func $type-result-empty-vs-num (result i32) + (table.fill $t (i32.const 0) (ref.null extern) (i32.const 1)) + ) + ) + "type mismatch" +) |