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

     1  (module
     2    (table $t 10 externref)
     3  
     4    (func (export "fill") (param $i i32) (param $r externref) (param $n i32)
     5      (table.fill $t (local.get $i) (local.get $r) (local.get $n))
     6    )
     7  
     8    (func (export "fill-abbrev") (param $i i32) (param $r externref) (param $n i32)
     9      (table.fill (local.get $i) (local.get $r) (local.get $n))
    10    )
    11  
    12    (func (export "get") (param $i i32) (result externref)
    13      (table.get $t (local.get $i))
    14    )
    15  )
    16  
    17  (assert_return (invoke "get" (i32.const 1)) (ref.null extern))
    18  (assert_return (invoke "get" (i32.const 2)) (ref.null extern))
    19  (assert_return (invoke "get" (i32.const 3)) (ref.null extern))
    20  (assert_return (invoke "get" (i32.const 4)) (ref.null extern))
    21  (assert_return (invoke "get" (i32.const 5)) (ref.null extern))
    22  
    23  (assert_return (invoke "fill" (i32.const 2) (ref.extern 1) (i32.const 3)))
    24  (assert_return (invoke "get" (i32.const 1)) (ref.null extern))
    25  (assert_return (invoke "get" (i32.const 2)) (ref.extern 1))
    26  (assert_return (invoke "get" (i32.const 3)) (ref.extern 1))
    27  (assert_return (invoke "get" (i32.const 4)) (ref.extern 1))
    28  (assert_return (invoke "get" (i32.const 5)) (ref.null extern))
    29  
    30  (assert_return (invoke "fill" (i32.const 4) (ref.extern 2) (i32.const 2)))
    31  (assert_return (invoke "get" (i32.const 3)) (ref.extern 1))
    32  (assert_return (invoke "get" (i32.const 4)) (ref.extern 2))
    33  (assert_return (invoke "get" (i32.const 5)) (ref.extern 2))
    34  (assert_return (invoke "get" (i32.const 6)) (ref.null extern))
    35  
    36  (assert_return (invoke "fill" (i32.const 4) (ref.extern 3) (i32.const 0)))
    37  (assert_return (invoke "get" (i32.const 3)) (ref.extern 1))
    38  (assert_return (invoke "get" (i32.const 4)) (ref.extern 2))
    39  (assert_return (invoke "get" (i32.const 5)) (ref.extern 2))
    40  
    41  (assert_return (invoke "fill" (i32.const 8) (ref.extern 4) (i32.const 2)))
    42  (assert_return (invoke "get" (i32.const 7)) (ref.null extern))
    43  (assert_return (invoke "get" (i32.const 8)) (ref.extern 4))
    44  (assert_return (invoke "get" (i32.const 9)) (ref.extern 4))
    45  
    46  (assert_return (invoke "fill-abbrev" (i32.const 9) (ref.null extern) (i32.const 1)))
    47  (assert_return (invoke "get" (i32.const 8)) (ref.extern 4))
    48  (assert_return (invoke "get" (i32.const 9)) (ref.null extern))
    49  
    50  (assert_return (invoke "fill" (i32.const 10) (ref.extern 5) (i32.const 0)))
    51  (assert_return (invoke "get" (i32.const 9)) (ref.null extern))
    52  
    53  (assert_trap
    54    (invoke "fill" (i32.const 8) (ref.extern 6) (i32.const 3))
    55    "out of bounds table access"
    56  )
    57  (assert_return (invoke "get" (i32.const 7)) (ref.null extern))
    58  (assert_return (invoke "get" (i32.const 8)) (ref.extern 4))
    59  (assert_return (invoke "get" (i32.const 9)) (ref.null extern))
    60  
    61  (assert_trap
    62    (invoke "fill" (i32.const 11) (ref.null extern) (i32.const 0))
    63    "out of bounds table access"
    64  )
    65  
    66  (assert_trap
    67    (invoke "fill" (i32.const 11) (ref.null extern) (i32.const 10))
    68    "out of bounds table access"
    69  )
    70  
    71  
    72  ;; Type errors
    73  
    74  (assert_invalid
    75    (module
    76      (table $t 10 externref)
    77      (func $type-index-value-length-empty-vs-i32-i32
    78        (table.fill $t)
    79      )
    80    )
    81    "type mismatch"
    82  )
    83  (assert_invalid
    84    (module
    85      (table $t 10 externref)
    86      (func $type-index-empty-vs-i32
    87        (table.fill $t (ref.null extern) (i32.const 1))
    88      )
    89    )
    90    "type mismatch"
    91  )
    92  (assert_invalid
    93    (module
    94      (table $t 10 externref)
    95      (func $type-value-empty-vs
    96        (table.fill $t (i32.const 1) (i32.const 1))
    97      )
    98    )
    99    "type mismatch"
   100  )
   101  (assert_invalid
   102    (module
   103      (table $t 10 externref)
   104      (func $type-length-empty-vs-i32
   105        (table.fill $t (i32.const 1) (ref.null extern))
   106      )
   107    )
   108    "type mismatch"
   109  )
   110  (assert_invalid
   111    (module
   112      (table $t 0 externref)
   113      (func $type-index-f32-vs-i32
   114        (table.fill $t (f32.const 1) (ref.null extern) (i32.const 1))
   115      )
   116    )
   117    "type mismatch"
   118  )
   119  (assert_invalid
   120    (module
   121      (table $t 0 funcref)
   122      (func $type-value-vs-funcref (param $r externref)
   123        (table.fill $t (i32.const 1) (local.get $r) (i32.const 1))
   124      )
   125    )
   126    "type mismatch"
   127  )
   128  (assert_invalid
   129    (module
   130      (table $t 0 externref)
   131      (func $type-length-f32-vs-i32
   132        (table.fill $t (i32.const 1) (ref.null extern) (f32.const 1))
   133      )
   134    )
   135    "type mismatch"
   136  )
   137  
   138  (assert_invalid
   139    (module
   140      (table $t1 1 externref)
   141      (table $t2 1 funcref)
   142      (func $type-value-externref-vs-funcref-multi (param $r externref)
   143        (table.fill $t2 (i32.const 0) (local.get $r) (i32.const 1))
   144      )
   145    )
   146    "type mismatch"
   147  )
   148  
   149  (assert_invalid
   150    (module
   151      (table $t 1 externref)
   152      (func $type-result-empty-vs-num (result i32)
   153        (table.fill $t (i32.const 0) (ref.null extern) (i32.const 1))
   154      )
   155    )
   156    "type mismatch"
   157  )