Skip to content

Commit

Permalink
[test] Check that memory is exported/imported with correct min limit (W…
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Apr 19, 2021
1 parent 451690f commit 7cfe091
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 @@ -566,6 +566,26 @@
(assert_return (invoke "grow" (i32.const 1)) (i32.const -1))
(assert_return (invoke "grow" (i32.const 0)) (i32.const 2))

(module $Mgm
(memory (export "memory") 1) ;; initial size is 1
(func (export "grow") (result i32) (memory.grow (i32.const 1)))
)
(register "grown-memory" $Mgm)
(assert_return (invoke $Mgm "grow") (i32.const 1)) ;; now size is 2
(module $Mgim1
;; imported memory limits should match, because external memory size is 2 now
(memory (export "memory") (import "grown-memory" "memory") 2)
(func (export "grow") (result i32) (memory.grow (i32.const 1)))
)
(register "grown-imported-memory" $Mgim1)
(assert_return (invoke $Mgim1 "grow") (i32.const 2)) ;; now size is 3
(module $Mgim2
;; imported memory limits should match, because external memory size is 3 now
(import "grown-imported-memory" "memory" (memory 3))
(func (export "size") (result i32) (memory.size))
)
(assert_return (invoke $Mgim2 "size") (i32.const 3))


;; Syntax errors

Expand Down

0 comments on commit 7cfe091

Please sign in to comment.