diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/binaryen.js/event.js | 2 | ||||
-rw-r--r-- | test/multivalue.wast | 144 | ||||
-rw-r--r-- | test/multivalue.wast.from-wast | 145 | ||||
-rw-r--r-- | test/multivalue.wast.fromBinary | 439 | ||||
-rw-r--r-- | test/multivalue.wast.fromBinary.noDebugInfo | 439 | ||||
-rw-r--r-- | test/spec/old_func.wast | 14 | ||||
-rw-r--r-- | test/unit/test_features.py | 76 |
7 files changed, 1233 insertions, 26 deletions
diff --git a/test/binaryen.js/event.js b/test/binaryen.js/event.js index 73af158f9..64d7659b8 100644 --- a/test/binaryen.js/event.js +++ b/test/binaryen.js/event.js @@ -7,7 +7,7 @@ function cleanInfo(info) { } var module = new binaryen.Module(); -module.setFeatures(binaryen.Features.ExceptionHandling); +module.setFeatures(binaryen.Features.ExceptionHandling | binaryen.Features.Multivalue); var pairType = binaryen.createType([binaryen.i32, binaryen.f32]); diff --git a/test/multivalue.wast b/test/multivalue.wast new file mode 100644 index 000000000..25e161ef4 --- /dev/null +++ b/test/multivalue.wast @@ -0,0 +1,144 @@ +(module + (import "env" "pair" (func $pair (result i32 i64))) + + ;; Test basic lowering of tuple.make, tuple.extract, and tuple locals + (func $triple (result i32 i64 f32) + (tuple.make + (i32.const 42) + (i64.const 7) + (f32.const 13) + ) + ) + (func $get-first (result i32) + (tuple.extract 0 + (call $triple) + ) + ) + (func $get-second (result i64) + (tuple.extract 1 + (call $triple) + ) + ) + (func $get-third (result f32) + (tuple.extract 2 + (call $triple) + ) + ) + (func $reverse (result f32 i64 i32) + (local $x (i32 i64 f32)) + (local.set $x + (call $triple) + ) + (tuple.make + (tuple.extract 2 + (local.get $x) + ) + (tuple.extract 1 + (local.get $x) + ) + (tuple.extract 0 + (local.get $x) + ) + ) + ) + + ;; Test lowering of multivalue drops + (func $drop-call + (drop + (call $pair) + ) + ) + (func $drop-tuple-make + (drop + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + (func $drop-block + (drop + (block (result i32 i64) + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + ) + + ;; Test multivalue control structures + (func $mv-return (result i32 i64) + (return + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + (func $mv-return-in-block (result i32 i64) + (block (result i32 i64) + (return + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + ) + (func $mv-block-break (result i32 i64) + (block $l (result i32 i64) + (br $l + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + ) + (func $mv-block-br-if (result i32 i64) + (block $l (result i32 i64) + (br_if $l + (tuple.make + (i32.const 42) + (i64.const 42) + ) + (i32.const 1) + ) + ) + ) + (func $mv-if (result i32 i64) + (if (result i32 i64) + (i32.const 1) + (tuple.make + (i32.const 42) + (i64.const 42) + ) + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + (func $mv-loop (result i32 i64) + (loop (result i32 i64) + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + (func $mv-switch (result i32 i64) + (block $a (result i32 i64) + (block $b (result i32 i64) + (br_table $a $b + (tuple.make + (i32.const 42) + (i64.const 42) + ) + (i32.const 0) + ) + ) + ) + ) +)
\ No newline at end of file diff --git a/test/multivalue.wast.from-wast b/test/multivalue.wast.from-wast new file mode 100644 index 000000000..57abbc21d --- /dev/null +++ b/test/multivalue.wast.from-wast @@ -0,0 +1,145 @@ +(module + (type $none_=>_i32_i64 (func (result i32 i64))) + (type $none_=>_none (func)) + (type $none_=>_f32_i64_i32 (func (result f32 i64 i32))) + (type $none_=>_i32 (func (result i32))) + (type $none_=>_i32_i64_f32 (func (result i32 i64 f32))) + (type $none_=>_i64 (func (result i64))) + (type $none_=>_f32 (func (result f32))) + (import "env" "pair" (func $pair (result i32 i64))) + (func $triple (; 1 ;) (result i32 i64 f32) + (tuple.make + (i32.const 42) + (i64.const 7) + (f32.const 13) + ) + ) + (func $get-first (; 2 ;) (result i32) + (tuple.extract 0 + (call $triple) + ) + ) + (func $get-second (; 3 ;) (result i64) + (tuple.extract 1 + (call $triple) + ) + ) + (func $get-third (; 4 ;) (result f32) + (tuple.extract 2 + (call $triple) + ) + ) + (func $reverse (; 5 ;) (result f32 i64 i32) + (local $x (i32 i64 f32)) + (local.set $x + (call $triple) + ) + (tuple.make + (tuple.extract 2 + (local.get $x) + ) + (tuple.extract 1 + (local.get $x) + ) + (tuple.extract 0 + (local.get $x) + ) + ) + ) + (func $drop-call (; 6 ;) + (drop + (call $pair) + ) + ) + (func $drop-tuple-make (; 7 ;) + (drop + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + (func $drop-block (; 8 ;) + (drop + (block $block (result i32 i64) + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + ) + (func $mv-return (; 9 ;) (result i32 i64) + (return + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + (func $mv-return-in-block (; 10 ;) (result i32 i64) + (block $block (result i32 i64) + (return + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + ) + (func $mv-block-break (; 11 ;) (result i32 i64) + (block $l (result i32 i64) + (br $l + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + ) + (func $mv-block-br-if (; 12 ;) (result i32 i64) + (block $l (result i32 i64) + (br_if $l + (tuple.make + (i32.const 42) + (i64.const 42) + ) + (i32.const 1) + ) + ) + ) + (func $mv-if (; 13 ;) (result i32 i64) + (if (result i32 i64) + (i32.const 1) + (tuple.make + (i32.const 42) + (i64.const 42) + ) + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + (func $mv-loop (; 14 ;) (result i32 i64) + (loop $loop-in (result i32 i64) + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + (func $mv-switch (; 15 ;) (result i32 i64) + (block $a (result i32 i64) + (block $b (result i32 i64) + (br_table $a $b + (tuple.make + (i32.const 42) + (i64.const 42) + ) + (i32.const 0) + ) + ) + ) + ) +) diff --git a/test/multivalue.wast.fromBinary b/test/multivalue.wast.fromBinary new file mode 100644 index 000000000..90d1331b1 --- /dev/null +++ b/test/multivalue.wast.fromBinary @@ -0,0 +1,439 @@ +(module + (type $none_=>_i32_i64 (func (result i32 i64))) + (type $none_=>_none (func)) + (type $none_=>_f32_i64_i32 (func (result f32 i64 i32))) + (type $none_=>_i32 (func (result i32))) + (type $none_=>_i32_i64_f32 (func (result i32 i64 f32))) + (type $none_=>_i64 (func (result i64))) + (type $none_=>_f32 (func (result f32))) + (import "env" "pair" (func $pair (result i32 i64))) + (func $triple (; 1 ;) (result i32 i64 f32) + (tuple.make + (i32.const 42) + (i64.const 7) + (f32.const 13) + ) + ) + (func $get-first (; 2 ;) (result i32) + (local $0 (i32 i64 f32)) + (local $1 i64) + (local $2 i32) + (local.set $0 + (call $triple) + ) + (block (result i32) + (local.set $2 + (tuple.extract 0 + (local.get $0) + ) + ) + (drop + (block (result i64) + (local.set $1 + (tuple.extract 1 + (local.get $0) + ) + ) + (drop + (tuple.extract 2 + (local.get $0) + ) + ) + (local.get $1) + ) + ) + (local.get $2) + ) + ) + (func $get-second (; 3 ;) (result i64) + (local $0 i64) + (local $1 (i32 i64 f32)) + (local $2 i64) + (local $3 i32) + (local.set $1 + (call $triple) + ) + (drop + (block (result i32) + (local.set $3 + (tuple.extract 0 + (local.get $1) + ) + ) + (local.set $0 + (block (result i64) + (local.set $2 + (tuple.extract 1 + (local.get $1) + ) + ) + (drop + (tuple.extract 2 + (local.get $1) + ) + ) + (local.get $2) + ) + ) + (local.get $3) + ) + ) + (local.get $0) + ) + (func $get-third (; 4 ;) (result f32) + (local $0 f32) + (local $1 (i32 i64 f32)) + (local $2 i64) + (local $3 i32) + (local.set $1 + (call $triple) + ) + (drop + (block (result i32) + (local.set $3 + (tuple.extract 0 + (local.get $1) + ) + ) + (drop + (block (result i64) + (local.set $2 + (tuple.extract 1 + (local.get $1) + ) + ) + (local.set $0 + (tuple.extract 2 + (local.get $1) + ) + ) + (local.get $2) + ) + ) + (local.get $3) + ) + ) + (local.get $0) + ) + (func $reverse (; 5 ;) (result f32 i64 i32) + (local $0 i32) + (local $1 i64) + (local $2 i64) + (local $3 f32) + (local $4 f32) + (local $5 (i32 i64 f32)) + (local $6 i64) + (local $7 i32) + (local $8 i64) + (local $9 i32) + (local $10 i64) + (local $11 i32) + (local $12 i64) + (local $13 i32) + (local $14 f32) + (local.set $5 + (call $triple) + ) + (local.set $0 + (block (result i32) + (local.set $7 + (tuple.extract 0 + (local.get $5) + ) + ) + (local.set $1 + (block (result i64) + (local.set $6 + (tuple.extract 1 + (local.get $5) + ) + ) + (local.set $3 + (tuple.extract 2 + (local.get $5) + ) + ) + (local.get $6) + ) + ) + (local.get $7) + ) + ) + (drop + (block (result i32) + (local.set $9 + (local.get $0) + ) + (drop + (block (result i64) + (local.set $8 + (local.get $1) + ) + (local.set $4 + (local.get $3) + ) + (local.get $8) + ) + ) + (local.get $9) + ) + ) + (tuple.make + (block (result f32) + (local.set $14 + (local.get $4) + ) + (drop + (block (result i32) + (local.set $11 + (local.get $0) + ) + (local.set $2 + (block (result i64) + (local.set $10 + (local.get $1) + ) + (drop + (local.get $3) + ) + (local.get $10) + ) + ) + (local.get $11) + ) + ) + (local.get $14) + ) + (local.get $2) + (block (result i32) + (local.set $13 + (local.get $0) + ) + (drop + (block (result i64) + (local.set $12 + (local.get $1) + ) + (drop + (local.get $3) + ) + (local.get $12) + ) + ) + (local.get $13) + ) + ) + ) + (func $drop-call (; 6 ;) + (local $0 (i32 i64)) + (local $1 i32) + (local.set $0 + (call $pair) + ) + (drop + (block (result i32) + (local.set $1 + (tuple.extract 0 + (local.get $0) + ) + ) + (drop + (tuple.extract 1 + (local.get $0) + ) + ) + (local.get $1) + ) + ) + ) + (func $drop-tuple-make (; 7 ;) + (local $0 i32) + (drop + (block (result i32) + (local.set $0 + (i32.const 42) + ) + (drop + (i64.const 42) + ) + (local.get $0) + ) + ) + ) + (func $drop-block (; 8 ;) + (local $0 (i32 i64)) + (local $1 i32) + (local.set $0 + (block $label$1 (result i32 i64) + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + (drop + (block (result i32) + (local.set $1 + (tuple.extract 0 + (local.get $0) + ) + ) + (drop + (tuple.extract 1 + (local.get $0) + ) + ) + (local.get $1) + ) + ) + ) + (func $mv-return (; 9 ;) (result i32 i64) + (return + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + (func $mv-return-in-block (; 10 ;) (result i32 i64) + (return + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + (func $mv-block-break (; 11 ;) (result i32 i64) + (local $0 (i32 i64)) + (local.set $0 + (block $label$1 (result i32 i64) + (br $label$1 + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + ) + (tuple.make + (tuple.extract 0 + (local.get $0) + ) + (tuple.extract 1 + (local.get $0) + ) + ) + ) + (func $mv-block-br-if (; 12 ;) (result i32 i64) + (local $0 (i32 i64)) + (local $1 (i32 i64)) + (local.set $1 + (block $label$1 (result i32 i64) + (local.set $0 + (br_if $label$1 + (tuple.make + (i32.const 42) + (i64.const 42) + ) + (i32.const 1) + ) + ) + (tuple.make + (tuple.extract 0 + (local.get $0) + ) + (tuple.extract 1 + (local.get $0) + ) + ) + ) + ) + (tuple.make + (tuple.extract 0 + (local.get $1) + ) + (tuple.extract 1 + (local.get $1) + ) + ) + ) + (func $mv-if (; 13 ;) (result i32 i64) + (local $0 (i32 i64)) + (local.set $0 + (if (result i32 i64) + (i32.const 1) + (tuple.make + (i32.const 42) + (i64.const 42) + ) + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + (tuple.make + (tuple.extract 0 + (local.get $0) + ) + (tuple.extract 1 + (local.get $0) + ) + ) + ) + (func $mv-loop (; 14 ;) (result i32 i64) + (local $0 (i32 i64)) + (local.set $0 + (loop $label$1 (result i32 i64) + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + (tuple.make + (tuple.extract 0 + (local.get $0) + ) + (tuple.extract 1 + (local.get $0) + ) + ) + ) + (func $mv-switch (; 15 ;) (result i32 i64) + (local $0 (i32 i64)) + (local $1 (i32 i64)) + (local.set $1 + (block $label$1 (result i32 i64) + (local.set $0 + (block $label$2 (result i32 i64) + (br_table $label$1 $label$2 + (tuple.make + (i32.const 42) + (i64.const 42) + ) + (i32.const 0) + ) + ) + ) + (tuple.make + (tuple.extract 0 + (local.get $0) + ) + (tuple.extract 1 + (local.get $0) + ) + ) + ) + ) + (tuple.make + (tuple.extract 0 + (local.get $1) + ) + (tuple.extract 1 + (local.get $1) + ) + ) + ) +) + diff --git a/test/multivalue.wast.fromBinary.noDebugInfo b/test/multivalue.wast.fromBinary.noDebugInfo new file mode 100644 index 000000000..ba4634b47 --- /dev/null +++ b/test/multivalue.wast.fromBinary.noDebugInfo @@ -0,0 +1,439 @@ +(module + (type $none_=>_i32_i64 (func (result i32 i64))) + (type $none_=>_none (func)) + (type $none_=>_f32_i64_i32 (func (result f32 i64 i32))) + (type $none_=>_i32 (func (result i32))) + (type $none_=>_i32_i64_f32 (func (result i32 i64 f32))) + (type $none_=>_i64 (func (result i64))) + (type $none_=>_f32 (func (result f32))) + (import "env" "pair" (func $fimport$0 (result i32 i64))) + (func $0 (; 1 ;) (result i32 i64 f32) + (tuple.make + (i32.const 42) + (i64.const 7) + (f32.const 13) + ) + ) + (func $1 (; 2 ;) (result i32) + (local $0 (i32 i64 f32)) + (local $1 i64) + (local $2 i32) + (local.set $0 + (call $0) + ) + (block (result i32) + (local.set $2 + (tuple.extract 0 + (local.get $0) + ) + ) + (drop + (block (result i64) + (local.set $1 + (tuple.extract 1 + (local.get $0) + ) + ) + (drop + (tuple.extract 2 + (local.get $0) + ) + ) + (local.get $1) + ) + ) + (local.get $2) + ) + ) + (func $2 (; 3 ;) (result i64) + (local $0 i64) + (local $1 (i32 i64 f32)) + (local $2 i64) + (local $3 i32) + (local.set $1 + (call $0) + ) + (drop + (block (result i32) + (local.set $3 + (tuple.extract 0 + (local.get $1) + ) + ) + (local.set $0 + (block (result i64) + (local.set $2 + (tuple.extract 1 + (local.get $1) + ) + ) + (drop + (tuple.extract 2 + (local.get $1) + ) + ) + (local.get $2) + ) + ) + (local.get $3) + ) + ) + (local.get $0) + ) + (func $3 (; 4 ;) (result f32) + (local $0 f32) + (local $1 (i32 i64 f32)) + (local $2 i64) + (local $3 i32) + (local.set $1 + (call $0) + ) + (drop + (block (result i32) + (local.set $3 + (tuple.extract 0 + (local.get $1) + ) + ) + (drop + (block (result i64) + (local.set $2 + (tuple.extract 1 + (local.get $1) + ) + ) + (local.set $0 + (tuple.extract 2 + (local.get $1) + ) + ) + (local.get $2) + ) + ) + (local.get $3) + ) + ) + (local.get $0) + ) + (func $4 (; 5 ;) (result f32 i64 i32) + (local $0 i32) + (local $1 i64) + (local $2 i64) + (local $3 f32) + (local $4 f32) + (local $5 (i32 i64 f32)) + (local $6 i64) + (local $7 i32) + (local $8 i64) + (local $9 i32) + (local $10 i64) + (local $11 i32) + (local $12 i64) + (local $13 i32) + (local $14 f32) + (local.set $5 + (call $0) + ) + (local.set $0 + (block (result i32) + (local.set $7 + (tuple.extract 0 + (local.get $5) + ) + ) + (local.set $1 + (block (result i64) + (local.set $6 + (tuple.extract 1 + (local.get $5) + ) + ) + (local.set $3 + (tuple.extract 2 + (local.get $5) + ) + ) + (local.get $6) + ) + ) + (local.get $7) + ) + ) + (drop + (block (result i32) + (local.set $9 + (local.get $0) + ) + (drop + (block (result i64) + (local.set $8 + (local.get $1) + ) + (local.set $4 + (local.get $3) + ) + (local.get $8) + ) + ) + (local.get $9) + ) + ) + (tuple.make + (block (result f32) + (local.set $14 + (local.get $4) + ) + (drop + (block (result i32) + (local.set $11 + (local.get $0) + ) + (local.set $2 + (block (result i64) + (local.set $10 + (local.get $1) + ) + (drop + (local.get $3) + ) + (local.get $10) + ) + ) + (local.get $11) + ) + ) + (local.get $14) + ) + (local.get $2) + (block (result i32) + (local.set $13 + (local.get $0) + ) + (drop + (block (result i64) + (local.set $12 + (local.get $1) + ) + (drop + (local.get $3) + ) + (local.get $12) + ) + ) + (local.get $13) + ) + ) + ) + (func $5 (; 6 ;) + (local $0 (i32 i64)) + (local $1 i32) + (local.set $0 + (call $fimport$0) + ) + (drop + (block (result i32) + (local.set $1 + (tuple.extract 0 + (local.get $0) + ) + ) + (drop + (tuple.extract 1 + (local.get $0) + ) + ) + (local.get $1) + ) + ) + ) + (func $6 (; 7 ;) + (local $0 i32) + (drop + (block (result i32) + (local.set $0 + (i32.const 42) + ) + (drop + (i64.const 42) + ) + (local.get $0) + ) + ) + ) + (func $7 (; 8 ;) + (local $0 (i32 i64)) + (local $1 i32) + (local.set $0 + (block $label$1 (result i32 i64) + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + (drop + (block (result i32) + (local.set $1 + (tuple.extract 0 + (local.get $0) + ) + ) + (drop + (tuple.extract 1 + (local.get $0) + ) + ) + (local.get $1) + ) + ) + ) + (func $8 (; 9 ;) (result i32 i64) + (return + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + (func $9 (; 10 ;) (result i32 i64) + (return + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + (func $10 (; 11 ;) (result i32 i64) + (local $0 (i32 i64)) + (local.set $0 + (block $label$1 (result i32 i64) + (br $label$1 + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + ) + (tuple.make + (tuple.extract 0 + (local.get $0) + ) + (tuple.extract 1 + (local.get $0) + ) + ) + ) + (func $11 (; 12 ;) (result i32 i64) + (local $0 (i32 i64)) + (local $1 (i32 i64)) + (local.set $1 + (block $label$1 (result i32 i64) + (local.set $0 + (br_if $label$1 + (tuple.make + (i32.const 42) + (i64.const 42) + ) + (i32.const 1) + ) + ) + (tuple.make + (tuple.extract 0 + (local.get $0) + ) + (tuple.extract 1 + (local.get $0) + ) + ) + ) + ) + (tuple.make + (tuple.extract 0 + (local.get $1) + ) + (tuple.extract 1 + (local.get $1) + ) + ) + ) + (func $12 (; 13 ;) (result i32 i64) + (local $0 (i32 i64)) + (local.set $0 + (if (result i32 i64) + (i32.const 1) + (tuple.make + (i32.const 42) + (i64.const 42) + ) + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + (tuple.make + (tuple.extract 0 + (local.get $0) + ) + (tuple.extract 1 + (local.get $0) + ) + ) + ) + (func $13 (; 14 ;) (result i32 i64) + (local $0 (i32 i64)) + (local.set $0 + (loop $label$1 (result i32 i64) + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + (tuple.make + (tuple.extract 0 + (local.get $0) + ) + (tuple.extract 1 + (local.get $0) + ) + ) + ) + (func $14 (; 15 ;) (result i32 i64) + (local $0 (i32 i64)) + (local $1 (i32 i64)) + (local.set $1 + (block $label$1 (result i32 i64) + (local.set $0 + (block $label$2 (result i32 i64) + (br_table $label$1 $label$2 + (tuple.make + (i32.const 42) + (i64.const 42) + ) + (i32.const 0) + ) + ) + ) + (tuple.make + (tuple.extract 0 + (local.get $0) + ) + (tuple.extract 1 + (local.get $0) + ) + ) + ) + ) + (tuple.make + (tuple.extract 0 + (local.get $1) + ) + (tuple.extract 1 + (local.get $1) + ) + ) + ) +) + diff --git a/test/spec/old_func.wast b/test/spec/old_func.wast index 83fb1aff3..ba06d3a65 100644 --- a/test/spec/old_func.wast +++ b/test/spec/old_func.wast @@ -344,19 +344,6 @@ ;; Invalid typing of result (assert_invalid - (module (func $type-multiple-result (result i32 i32) (unreachable))) - "invalid result arity" -) -(assert_invalid - (module - (type (func (result i32 i32))) - (func $type-multiple-result (type 0) (unreachable)) - ) - "invalid result arity" -) - - -(assert_invalid (module (func $type-empty-i32 (result i32))) "type mismatch" ) @@ -529,4 +516,3 @@ )) "type mismatch" ) - diff --git a/test/unit/test_features.py b/test/unit/test_features.py index db17c7f9d..4a79a6dd5 100644 --- a/test/unit/test_features.py +++ b/test/unit/test_features.py @@ -5,41 +5,45 @@ from . import utils class FeatureValidationTest(utils.BinaryenTestCase): - def check_feature(self, module, error, flag): + def check_feature(self, module, error, flag, const_flags=[]): p = shared.run_process(shared.WASM_OPT + - ['--mvp-features', '--print', '-o', os.devnull], + ['--mvp-features', '--print', '-o', os.devnull] + + const_flags, input=module, check=False, capture_output=True) self.assertIn(error, p.stderr) self.assertIn('Fatal: error validating input', p.stderr) self.assertNotEqual(p.returncode, 0) p = shared.run_process( shared.WASM_OPT + ['--mvp-features', '--print', '-o', os.devnull] + - flag, + const_flags + [flag], input=module, check=False, capture_output=True) self.assertEqual(p.returncode, 0) def check_simd(self, module, error): - self.check_feature(module, error, ['--enable-simd']) + self.check_feature(module, error, '--enable-simd') def check_sign_ext(self, module, error): - self.check_feature(module, error, ['--enable-sign-ext']) + self.check_feature(module, error, '--enable-sign-ext') def check_bulk_mem(self, module, error): - self.check_feature(module, error, ['--enable-bulk-memory']) + self.check_feature(module, error, '--enable-bulk-memory') def check_exception_handling(self, module, error): # Exception handling implies reference types - self.check_feature(module, error, - ['--enable-reference-types', - '--enable-exception-handling']) + self.check_feature(module, error, '--enable-exception-handling', + ['--enable-reference-types']) def check_tail_call(self, module, error): - self.check_feature(module, error, ['--enable-tail-call']) + self.check_feature(module, error, '--enable-tail-call') def check_reference_types(self, module, error): - self.check_feature(module, error, ['--enable-reference-types']) + self.check_feature(module, error, '--enable-reference-types') + + def check_multivalue(self, module, error): + self.check_feature(module, error, '--enable-multivalue', + ['--enable-exception-handling']) def test_v128_signature(self): module = ''' @@ -195,6 +199,56 @@ class FeatureValidationTest(utils.BinaryenTestCase): ''' self.check_exception_handling(module, 'Module has events') + def test_multivalue_import(self): + module = ''' + (module + (import "env" "foo" (func $foo (result i32 i64))) + ) + ''' + self.check_multivalue(module, 'Imported multivalue function ' + + '(multivalue is not enabled)') + + def test_multivalue_function(self): + module = ''' + (module + (func $foo (result i32 i64) + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + ''' + self.check_multivalue(module, 'Multivalue function results ' + + '(multivalue is not enabled)') + + def test_multivalue_event(self): + module = ''' + (module + (event $foo (attr 0) (param i32 i64)) + ) + ''' + self.check_multivalue(module, 'Multivalue event type ' + + '(multivalue is not enabled)') + + def test_multivalue_block(self): + module = ''' + (module + (func $foo + (drop + (block (result i32 i64) + (tuple.make + (i32.const 42) + (i64.const 42) + ) + ) + ) + ) + ) + ''' + self.check_multivalue(module, 'Multivalue block type ' + + '(multivalue is not enabled)') + class TargetFeaturesSectionTest(utils.BinaryenTestCase): def test_atomics(self): |