Skip to content

Commit

Permalink
[test] Add test for table elems initialized by imported global funcref
Browse files Browse the repository at this point in the history
Fixes: #1640
  • Loading branch information
sbc100 committed Apr 17, 2023
1 parent 2a992ec commit d8d7596
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/core/elem.wast
Original file line number Diff line number Diff line change
Expand Up @@ -675,3 +675,26 @@

(assert_return (invoke $m "get" (i32.const 0)) (ref.null extern))
(assert_return (invoke $m "get" (i32.const 1)) (ref.extern 137))

;; Initializing a table with imported funcref global

(module $module4
(func (result i32)
i32.const 42
)
(global (export "f") funcref (ref.func 0))
)

(register "module4" $module4)

(module
(import "module4" "f" (global funcref))
(type $out-i32 (func (result i32)))
(table 10 funcref)
(elem (offset (i32.const 0)) funcref (global.get 0))
(func (export "call_imported_elem") (type $out-i32)
(call_indirect (type $out-i32) (i32.const 0))
)
)

(assert_return (invoke "call_imported_elem") (i32.const 42))

0 comments on commit d8d7596

Please sign in to comment.