diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/typed_continuations.wast | 42 | ||||
-rw-r--r-- | test/spec/typed_continuations.wast | 38 | ||||
-rw-r--r-- | test/unit/test_features.py | 12 |
3 files changed, 92 insertions, 0 deletions
diff --git a/test/lit/typed_continuations.wast b/test/lit/typed_continuations.wast new file mode 100644 index 000000000..36797f745 --- /dev/null +++ b/test/lit/typed_continuations.wast @@ -0,0 +1,42 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. + +;; RUN: wasm-as %s -all -g -o %t.wasm +;; RUN: wasm-dis %t.wasm -all -o %t.wast +;; RUN: wasm-as %s -all -o %t.nodebug.wasm +;; RUN: wasm-dis %t.nodebug.wasm -all -o %t.nodebug.wast +;; RUN: wasm-opt %t.wast -all -o %t.text.wast -g -S +;; RUN: cat %t.wast | filecheck %s --check-prefix=CHECK-BINARY +;; RUN: cat %t.nodebug.wast | filecheck %s --check-prefix=CHECK-NODEBUG +;; RUN: cat %t.text.wast | filecheck %s --check-prefix=CHECK-TEXT + +(module + ;; CHECK-BINARY: (type $ft (func (param i32) (result i32))) + ;; CHECK-TEXT: (type $ft (func (param i32) (result i32))) + (type $ft (func (param i32) (result i32))) + ;; CHECK-BINARY: (type $ct (cont $ft)) + ;; CHECK-TEXT: (type $ct (cont $ft)) + (type $ct (cont $ft)) + + ;; CHECK-BINARY: (type $2 (func (param (ref $ct)) (result (ref $ct)))) + + ;; CHECK-BINARY: (func $id (type $2) (param $x (ref $ct)) (result (ref $ct)) + ;; CHECK-BINARY-NEXT: (local.get $x) + ;; CHECK-BINARY-NEXT: ) + ;; CHECK-TEXT: (type $2 (func (param (ref $ct)) (result (ref $ct)))) + + ;; CHECK-TEXT: (func $id (type $2) (param $x (ref $ct)) (result (ref $ct)) + ;; CHECK-TEXT-NEXT: (local.get $x) + ;; CHECK-TEXT-NEXT: ) + (func $id (param $x (ref $ct)) (result (ref $ct)) + (local.get $x) + ) +) +;; CHECK-NODEBUG: (type $0 (func (param i32) (result i32))) + +;; CHECK-NODEBUG: (type $1 (cont $0)) + +;; CHECK-NODEBUG: (type $2 (func (param (ref $1)) (result (ref $1)))) + +;; CHECK-NODEBUG: (func $0 (type $2) (param $0 (ref $1)) (result (ref $1)) +;; CHECK-NODEBUG-NEXT: (local.get $0) +;; CHECK-NODEBUG-NEXT: ) diff --git a/test/spec/typed_continuations.wast b/test/spec/typed_continuations.wast new file mode 100644 index 000000000..5f7b86f6c --- /dev/null +++ b/test/spec/typed_continuations.wast @@ -0,0 +1,38 @@ +(module + (type $ft (func (param i32) (result i32))) + (type $ct (cont $ft)) + + (func $id (param $x (ref $ct)) (result (ref $ct)) + (local.get $x) + ) +) + +(assert_invalid + (module + (type $ft (func (param i32) (result i32))) + (type $ct1 (cont $ft)) + (type $ct2 (cont $ct1)) + ) +) + +(assert_invalid + (module + (type $ft (func (param i32) (result i32))) + (type $ct (cont $ft)) + + (func $id (param $x $ct) (result i32) + (i32.const 123) + ) + ) +) + +(assert_invalid + (module + (type $ft (func (param i32) (result i32))) + (type $ct (cont $ft)) + + (func $id (type $ct) + (i32.const 123) + ) + ) +) diff --git a/test/unit/test_features.py b/test/unit/test_features.py index d2d72a8e4..cd8aebbb1 100644 --- a/test/unit/test_features.py +++ b/test/unit/test_features.py @@ -294,6 +294,18 @@ class FeatureValidationTest(utils.BinaryenTestCase): 'Tags with result types require typed ' 'continuations feature [--enable-typed-continuations]') + def test_cont_type(self): + module = ''' + (module + (type $ft (func (param i32) (result i32))) + (type $ct (cont $ft)) + (func $foo + (local $0 (ref $ct)) + ) + ) + ''' + self.check_typed_continuations(module, 'all used types should be allowed') + class TargetFeaturesSectionTest(utils.BinaryenTestCase): def test_atomics(self): |