-
Notifications
You must be signed in to change notification settings - Fork 57
/
ref_is_null.wast
58 lines (46 loc) · 1.74 KB
/
ref_is_null.wast
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
(module
(func $f1 (export "funcref") (param $x funcref) (result i32)
(ref.is_null (local.get $x))
)
(func $f2 (export "externref") (param $x externref) (result i32)
(ref.is_null (local.get $x))
)
(table $t1 2 funcref)
(table $t2 2 externref)
(elem (table $t1) (i32.const 1) func $dummy)
(func $dummy)
(func (export "init") (param $r externref)
(table.set $t2 (i32.const 1) (local.get $r))
)
(func (export "deinit")
(table.set $t1 (i32.const 1) (ref.null func))
(table.set $t2 (i32.const 1) (ref.null extern))
)
(func (export "funcref-elem") (param $x i32) (result i32)
(call $f1 (table.get $t1 (local.get $x)))
)
(func (export "externref-elem") (param $x i32) (result i32)
(call $f2 (table.get $t2 (local.get $x)))
)
)
(assert_return (invoke "funcref" (ref.null func)) (i32.const 1))
(assert_return (invoke "externref" (ref.null extern)) (i32.const 1))
(assert_return (invoke "externref" (ref.extern 1)) (i32.const 0))
(invoke "init" (ref.extern 0))
(assert_return (invoke "funcref-elem" (i32.const 0)) (i32.const 1))
(assert_return (invoke "externref-elem" (i32.const 0)) (i32.const 1))
(assert_return (invoke "funcref-elem" (i32.const 1)) (i32.const 0))
(assert_return (invoke "externref-elem" (i32.const 1)) (i32.const 0))
(invoke "deinit")
(assert_return (invoke "funcref-elem" (i32.const 0)) (i32.const 1))
(assert_return (invoke "externref-elem" (i32.const 0)) (i32.const 1))
(assert_return (invoke "funcref-elem" (i32.const 1)) (i32.const 1))
(assert_return (invoke "externref-elem" (i32.const 1)) (i32.const 1))
(assert_invalid
(module (func $ref-vs-num (param i32) (ref.is_null (local.get 0))))
"type mismatch"
)
(assert_invalid
(module (func $ref-vs-empty (ref.is_null)))
"type mismatch"
)