github.com/tetratelabs/wazero@v1.7.3-0.20240513003603-48f702e154b5/internal/integration_test/spectest/v2/testdata/table_size.wast (about)

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