summaryrefslogtreecommitdiff
path: root/test/spec
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2019-05-31 20:02:37 -0700
committerGitHub <noreply@github.com>2019-05-31 20:02:37 -0700
commitfe99e3458f11d1a01fa3ad5b68883dbcba3903af (patch)
tree6f5eda61c7c7cba9c3b16be5e361cdc148d8b315 /test/spec
parent7306f60a4474ca1fa948bddee5c068e7c2f635f6 (diff)
downloadbinaryen-fe99e3458f11d1a01fa3ad5b68883dbcba3903af.tar.gz
binaryen-fe99e3458f11d1a01fa3ad5b68883dbcba3903af.tar.bz2
binaryen-fe99e3458f11d1a01fa3ad5b68883dbcba3903af.zip
Add event section (#2151)
This adds support for the event and the event section, as specified in https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md#changes-to-the-binary-model. Wasm events are features that suspend the current execution and transfer the control flow to a corresponding handler. Currently the only supported event kind is exceptions. For events, this includes support for - Binary file reading/writing - Wast file reading/writing - Binaryen.js API - Fuzzer - Validation - Metadce - Passes: metrics, minify-imports-and-exports, remove-unused-module-elements
Diffstat (limited to 'test/spec')
-rw-r--r--test/spec/events.wast43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/spec/events.wast b/test/spec/events.wast
new file mode 100644
index 000000000..80a6b11fe
--- /dev/null
+++ b/test/spec/events.wast
@@ -0,0 +1,43 @@
+;; Test events
+
+(module
+ (event (attr 0) (param i32))
+ (event $e (attr 0) (param i32 f32))
+
+ (event $e-params0 (attr 0) (param i32 f32))
+ (event $e-params1 (attr 0) (param i32) (param f32))
+
+ (event $e-export (export "ex0") (attr 0) (param i32))
+ (event $e-import (import "env" "im0") (attr 0) (param i32))
+
+ (import "env" "im1" (event (attr 0) (param i32 f32)))
+ (export "ex1" (event $e))
+)
+
+(assert_invalid
+ (module (event $e (attr 0) (param i32) (result i32)))
+ "Event type's result type should be none"
+)
+
+(assert_invalid
+ (module (event $e (attr 0)))
+ "There should be 1 or more values in an event type"
+)
+
+(assert_invalid
+ (module (event $e (attr 1) (param i32)))
+ "Currently only attribute 0 is supported"
+)
+
+(assert_invalid
+ (module (event $e (attr 0) (param except_ref)))
+ "Values in an event should have integer or float type"
+)
+
+(assert_invalid
+ (module
+ (type $t (param i32))
+ (event $e (attr 0) (type $t) (param i32 f32))
+ "type and param don't match"
+ )
+)