Skip to content

Commit

Permalink
[test] Add tests ensuring table type is grown in table.grow
Browse files Browse the repository at this point in the history
  • Loading branch information
dzfrias committed Aug 18, 2024
1 parent 8ea273d commit 41a25af
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/core/imports.wast
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,26 @@
(assert_trap (invoke "call" (i32.const 3)) "uninitialized element")
(assert_trap (invoke "call" (i32.const 100)) "undefined element")

(module $Tgt
(table (export "table") 1 funcref) ;; initial size is 1
(func (export "grow") (result i32) (table.grow (ref.null func) (i32.const 1)))
)
(register "grown-table" $Tgt)
(assert_return (invoke $Tgt "grow") (i32.const 1)) ;; now size is 2
(module $Tgit1
;; imported table limits should match, because external table size is 2 now
(table (export "table") (import "grown-table" "table") 2 funcref)
(func (export "grow") (result i32) (table.grow (ref.null func) (i32.const 1)))
)
(register "grown-imported-table" $Tgit1)
(assert_return (invoke $Tgit1 "grow") (i32.const 2)) ;; now size is 3
(module $Tgit2
;; imported table limits should match, because external table size is 3 now
(import "grown-imported-table" "table" (table 3 funcref))
(func (export "size") (result i32) (table.size))
)
(assert_return (invoke $Tgit2 "size") (i32.const 3))


(module
(import "spectest" "table" (table 0 funcref))
Expand Down

0 comments on commit 41a25af

Please sign in to comment.