Skip to content

Commit 122e4be

Browse files
committed
Add a simple test for multiple tables
1 parent 9082bcd commit 122e4be

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/core/return_call_indirect.wast

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,27 @@
144144
)
145145
)
146146

147+
;; Multiple tables
148+
149+
(table $tab2 funcref (elem $tab-f1))
150+
(table $tab3 funcref (elem $tab-f2))
151+
152+
(func $tab-f1 (result i32) (i32.const 0x133))
153+
(func $tab-f2 (result i32) (i32.const 0x134))
154+
155+
(func (export "call-tab") (param $i i32) (result i32)
156+
(if (i32.eq (local.get $i) (i32.const 0))
157+
(then (return_call_indirect (type $out-i32) (i32.const 0)))
158+
)
159+
(if (i32.eq (local.get $i) (i32.const 1))
160+
(then (return_call_indirect 1 (type $out-i32) (i32.const 0)))
161+
)
162+
(if (i32.eq (local.get $i) (i32.const 2))
163+
(then (return_call_indirect $tab3 (type $out-i32) (i32.const 0)))
164+
)
165+
(i32.const 0)
166+
)
167+
147168
;; Recursion
148169

149170
(func $fac (export "fac") (type $over-i64)
@@ -223,6 +244,10 @@
223244
(assert_trap (invoke "dispatch-structural" (i32.const 11)) "indirect call type mismatch")
224245
(assert_trap (invoke "dispatch-structural" (i32.const 16)) "indirect call type mismatch")
225246

247+
(assert_return (invoke "call-tab" (i32.const 0)) (i32.const 0x132))
248+
(assert_return (invoke "call-tab" (i32.const 1)) (i32.const 0x133))
249+
(assert_return (invoke "call-tab" (i32.const 2)) (i32.const 0x134))
250+
226251
(assert_return (invoke "fac" (i64.const 0)) (i64.const 1))
227252
(assert_return (invoke "fac" (i64.const 1)) (i64.const 1))
228253
(assert_return (invoke "fac" (i64.const 5)) (i64.const 120))

0 commit comments

Comments
 (0)