| 1 |
;; RUN: wast --assert default --snapshot tests/snapshots % -f cm-error-context |
| 2 |
|
| 3 |
;; error-context.new |
| 4 |
(component |
| 5 |
(core module $libc (memory (export "memory") 1)) |
| 6 |
(core instance $libc (instantiate $libc)) |
| 7 |
(core module $m |
| 8 |
(import "" "error-context.new" (func $error-context-new (param i32 i32) (result i32))) |
| 9 |
) |
| 10 |
(core func $error-context-new (canon error-context.new (memory $libc "memory"))) |
| 11 |
(core instance $i (instantiate $m (with "" (instance (export "error-context.new" (func $error-context-new)))))) |
| 12 |
) |
| 13 |
|
| 14 |
;; error-context.new; incorrect type |
| 15 |
(assert_invalid |
| 16 |
(component |
| 17 |
(core module $libc (memory (export "memory") 1)) |
| 18 |
(core instance $libc (instantiate $libc)) |
| 19 |
(core module $m |
| 20 |
(import "" "error-context.new" (func $error-context-new (param i32) (result i32))) |
| 21 |
) |
| 22 |
(core func $error-context-new (canon error-context.new (memory $libc "memory"))) |
| 23 |
(core instance $i (instantiate $m (with "" (instance (export "error-context.new" (func $error-context-new)))))) |
| 24 |
) |
| 25 |
"type mismatch for export `error-context.new` of module instantiation argument ``" |
| 26 |
) |
| 27 |
|
| 28 |
;; error-context.debug-message |
| 29 |
(component |
| 30 |
(core module $libc |
| 31 |
(func (export "realloc") (param i32 i32 i32 i32) (result i32) unreachable) |
| 32 |
(memory (export "memory") 1) |
| 33 |
) |
| 34 |
(core instance $libc (instantiate $libc)) |
| 35 |
(core module $m |
| 36 |
(import "" "error-context.debug-message" (func $error-context-debug-message (param i32 i32))) |
| 37 |
) |
| 38 |
(core func $error-context-debug-message (canon error-context.debug-message (memory $libc "memory") (realloc (func $libc "realloc")))) |
| 39 |
(core instance $i (instantiate $m (with "" (instance (export "error-context.debug-message" (func $error-context-debug-message)))))) |
| 40 |
) |
| 41 |
|
| 42 |
;; error-context.debug-message; incorrect type |
| 43 |
(assert_invalid |
| 44 |
(component |
| 45 |
(core module $libc |
| 46 |
(func (export "realloc") (param i32 i32 i32 i32) (result i32) unreachable) |
| 47 |
(memory (export "memory") 1) |
| 48 |
) |
| 49 |
(core instance $libc (instantiate $libc)) |
| 50 |
(core module $m |
| 51 |
(import "" "error-context.debug-message" (func $error-context-debug-message (param i32) (result i32))) |
| 52 |
) |
| 53 |
(core func $error-context-debug-message (canon error-context.debug-message (memory $libc "memory") (realloc (func $libc "realloc")))) |
| 54 |
(core instance $i (instantiate $m (with "" (instance (export "error-context.debug-message" (func $error-context-debug-message)))))) |
| 55 |
) |
| 56 |
"type mismatch for export `error-context.debug-message` of module instantiation argument ``" |
| 57 |
) |
| 58 |
|
| 59 |
;; error-context.drop |
| 60 |
(component |
| 61 |
(core module $m |
| 62 |
(import "" "error-context.drop" (func $error-context-drop (param i32))) |
| 63 |
) |
| 64 |
(core func $error-context-drop (canon error-context.drop)) |
| 65 |
(core instance $i (instantiate $m (with "" (instance (export "error-context.drop" (func $error-context-drop)))))) |
| 66 |
) |
| 67 |
|
| 68 |
;; error-context.drop; incorrect type |
| 69 |
(assert_invalid |
| 70 |
(component |
| 71 |
(core module $m |
| 72 |
(import "" "error-context.drop" (func $error-context-drop (param i32) (result i32))) |
| 73 |
) |
| 74 |
(core func $error-context-drop (canon error-context.drop)) |
| 75 |
(core instance $i (instantiate $m (with "" (instance (export "error-context.drop" (func $error-context-drop)))))) |
| 76 |
) |
| 77 |
"type mismatch for export `error-context.drop` of module instantiation argument ``" |
| 78 |
) |
| 79 |
|
| 80 |
;; can define the `error-context` type |
| 81 |
(component (type error-context)) |
| 82 |
(component (type (list error-context))) |