Skip to content

Commit

Permalink
Merge pull request #106 from WebAssembly/test.table-init-global
Browse files Browse the repository at this point in the history
[test] Test global imports as table initializers
  • Loading branch information
rossberg authored Sep 20, 2023
2 parents eab6b36 + 80de4f9 commit 0b559e9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/core/table.wast
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,36 @@
;; Table initializer

(module
(global (export "g") (ref $f) (ref.func $f))
(type $f (func))
(func $f)
)
(register "M")

(module
(global $g (import "M" "g") (ref $dummy))

(type $dummy (func))
(func $dummy)

(table $t1 10 funcref)
(table $t2 10 funcref (ref.func $dummy))
(table $t3 10 (ref $dummy) (ref.func $dummy))
(table $t4 10 funcref (global.get $g))
(table $t5 10 (ref $dummy) (global.get $g))

(func (export "get1") (result funcref) (table.get $t1 (i32.const 1)))
(func (export "get2") (result funcref) (table.get $t2 (i32.const 4)))
(func (export "get3") (result funcref) (table.get $t3 (i32.const 7)))
(func (export "get4") (result funcref) (table.get $t4 (i32.const 8)))
(func (export "get5") (result funcref) (table.get $t5 (i32.const 9)))
)

(assert_return (invoke "get1") (ref.null))
(assert_return (invoke "get2") (ref.func))
(assert_return (invoke "get3") (ref.func))
(assert_return (invoke "get4") (ref.func))
(assert_return (invoke "get5") (ref.func))


(assert_invalid
Expand Down

0 comments on commit 0b559e9

Please sign in to comment.