wa-lang.org/wazero@v1.0.2/internal/integration_test/spectest/v2/testdata/memory_size.wast (about)

     1  (module
     2    (memory 0)
     3    (func (export "size") (result i32) (memory.size))
     4    (func (export "grow") (param $sz i32) (drop (memory.grow (local.get $sz))))
     5  )
     6  
     7  (assert_return (invoke "size") (i32.const 0))
     8  (assert_return (invoke "grow" (i32.const 1)))
     9  (assert_return (invoke "size") (i32.const 1))
    10  (assert_return (invoke "grow" (i32.const 4)))
    11  (assert_return (invoke "size") (i32.const 5))
    12  (assert_return (invoke "grow" (i32.const 0)))
    13  (assert_return (invoke "size") (i32.const 5))
    14  
    15  (module
    16    (memory 1)
    17    (func (export "size") (result i32) (memory.size))
    18    (func (export "grow") (param $sz i32) (drop (memory.grow (local.get $sz))))
    19  )
    20  
    21  (assert_return (invoke "size") (i32.const 1))
    22  (assert_return (invoke "grow" (i32.const 1)))
    23  (assert_return (invoke "size") (i32.const 2))
    24  (assert_return (invoke "grow" (i32.const 4)))
    25  (assert_return (invoke "size") (i32.const 6))
    26  (assert_return (invoke "grow" (i32.const 0)))
    27  (assert_return (invoke "size") (i32.const 6))
    28  
    29  (module
    30    (memory 0 2)
    31    (func (export "size") (result i32) (memory.size))
    32    (func (export "grow") (param $sz i32) (drop (memory.grow (local.get $sz))))
    33  )
    34  
    35  (assert_return (invoke "size") (i32.const 0))
    36  (assert_return (invoke "grow" (i32.const 3)))
    37  (assert_return (invoke "size") (i32.const 0))
    38  (assert_return (invoke "grow" (i32.const 1)))
    39  (assert_return (invoke "size") (i32.const 1))
    40  (assert_return (invoke "grow" (i32.const 0)))
    41  (assert_return (invoke "size") (i32.const 1))
    42  (assert_return (invoke "grow" (i32.const 4)))
    43  (assert_return (invoke "size") (i32.const 1))
    44  (assert_return (invoke "grow" (i32.const 1)))
    45  (assert_return (invoke "size") (i32.const 2))
    46  
    47  (module
    48    (memory 3 8)
    49    (func (export "size") (result i32) (memory.size))
    50    (func (export "grow") (param $sz i32) (drop (memory.grow (local.get $sz))))
    51  )
    52  
    53  (assert_return (invoke "size") (i32.const 3))
    54  (assert_return (invoke "grow" (i32.const 1)))
    55  (assert_return (invoke "size") (i32.const 4))
    56  (assert_return (invoke "grow" (i32.const 3)))
    57  (assert_return (invoke "size") (i32.const 7))
    58  (assert_return (invoke "grow" (i32.const 0)))
    59  (assert_return (invoke "size") (i32.const 7))
    60  (assert_return (invoke "grow" (i32.const 2)))
    61  (assert_return (invoke "size") (i32.const 7))
    62  (assert_return (invoke "grow" (i32.const 1)))
    63  (assert_return (invoke "size") (i32.const 8))
    64  
    65  
    66  ;; Type errors
    67  
    68  (assert_invalid
    69    (module
    70      (memory 1)
    71      (func $type-result-i32-vs-empty
    72        (memory.size)
    73      )
    74    )
    75    "type mismatch"
    76  )
    77  (assert_invalid
    78    (module
    79      (memory 1)
    80      (func $type-result-i32-vs-f32 (result f32)
    81        (memory.size)
    82      )
    83    )
    84    "type mismatch"
    85  )