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

     1  (module
     2    (func $f1 (export "funcref") (param $x funcref) (result i32)
     3      (ref.is_null (local.get $x))
     4    )
     5    (func $f2 (export "externref") (param $x externref) (result i32)
     6      (ref.is_null (local.get $x))
     7    )
     8  
     9    (table $t1 2 funcref)
    10    (table $t2 2 externref)
    11    (elem (table $t1) (i32.const 1) func $dummy)
    12    (func $dummy)
    13  
    14    (func (export "init") (param $r externref)
    15      (table.set $t2 (i32.const 1) (local.get $r))
    16    )
    17    (func (export "deinit")
    18      (table.set $t1 (i32.const 1) (ref.null func))
    19      (table.set $t2 (i32.const 1) (ref.null extern))
    20    )
    21  
    22    (func (export "funcref-elem") (param $x i32) (result i32)
    23      (call $f1 (table.get $t1 (local.get $x)))
    24    )
    25    (func (export "externref-elem") (param $x i32) (result i32)
    26      (call $f2 (table.get $t2 (local.get $x)))
    27    )
    28  )
    29  
    30  (assert_return (invoke "funcref" (ref.null func)) (i32.const 1))
    31  (assert_return (invoke "externref" (ref.null extern)) (i32.const 1))
    32  
    33  (assert_return (invoke "externref" (ref.extern 1)) (i32.const 0))
    34  
    35  (invoke "init" (ref.extern 0))
    36  
    37  (assert_return (invoke "funcref-elem" (i32.const 0)) (i32.const 1))
    38  (assert_return (invoke "externref-elem" (i32.const 0)) (i32.const 1))
    39  
    40  (assert_return (invoke "funcref-elem" (i32.const 1)) (i32.const 0))
    41  (assert_return (invoke "externref-elem" (i32.const 1)) (i32.const 0))
    42  
    43  (invoke "deinit")
    44  
    45  (assert_return (invoke "funcref-elem" (i32.const 0)) (i32.const 1))
    46  (assert_return (invoke "externref-elem" (i32.const 0)) (i32.const 1))
    47  
    48  (assert_return (invoke "funcref-elem" (i32.const 1)) (i32.const 1))
    49  (assert_return (invoke "externref-elem" (i32.const 1)) (i32.const 1))
    50  
    51  (assert_invalid
    52    (module (func $ref-vs-num (param i32) (ref.is_null (local.get 0))))
    53    "type mismatch"
    54  )
    55  (assert_invalid
    56    (module (func $ref-vs-empty (ref.is_null)))
    57    "type mismatch"
    58  )