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

     1  ;; Store operator as the argument of control constructs and instructions
     2  
     3  (module
     4    (memory 1)
     5  
     6    (func (export "as-block-value")
     7      (block (i32.store (i32.const 0) (i32.const 1)))
     8    )
     9    (func (export "as-loop-value")
    10      (loop (i32.store (i32.const 0) (i32.const 1)))
    11    )
    12  
    13    (func (export "as-br-value")
    14      (block (br 0 (i32.store (i32.const 0) (i32.const 1))))
    15    )
    16    (func (export "as-br_if-value")
    17      (block
    18        (br_if 0 (i32.store (i32.const 0) (i32.const 1)) (i32.const 1))
    19      )
    20    )
    21    (func (export "as-br_if-value-cond")
    22      (block
    23        (br_if 0 (i32.const 6) (i32.store (i32.const 0) (i32.const 1)))
    24      )
    25    )
    26    (func (export "as-br_table-value")
    27      (block
    28        (br_table 0 (i32.store (i32.const 0) (i32.const 1)) (i32.const 1))
    29      )
    30    )
    31  
    32    (func (export "as-return-value")
    33      (return (i32.store (i32.const 0) (i32.const 1)))
    34    )
    35  
    36    (func (export "as-if-then")
    37      (if (i32.const 1) (then (i32.store (i32.const 0) (i32.const 1))))
    38    )
    39    (func (export "as-if-else")
    40      (if (i32.const 0) (then) (else (i32.store (i32.const 0) (i32.const 1))))
    41    )
    42  )
    43  
    44  (assert_return (invoke "as-block-value"))
    45  (assert_return (invoke "as-loop-value"))
    46  
    47  (assert_return (invoke "as-br-value"))
    48  (assert_return (invoke "as-br_if-value"))
    49  (assert_return (invoke "as-br_if-value-cond"))
    50  (assert_return (invoke "as-br_table-value"))
    51  
    52  (assert_return (invoke "as-return-value"))
    53  
    54  (assert_return (invoke "as-if-then"))
    55  (assert_return (invoke "as-if-else"))
    56  
    57  (assert_malformed
    58    (module quote
    59      "(memory 1)"
    60      "(func (param i32) (i32.store32 (local.get 0) (i32.const 0)))"
    61    )
    62    "unknown operator"
    63  )
    64  (assert_malformed
    65    (module quote
    66      "(memory 1)"
    67      "(func (param i32) (i32.store64 (local.get 0) (i64.const 0)))"
    68    )
    69    "unknown operator"
    70  )
    71  
    72  (assert_malformed
    73    (module quote
    74      "(memory 1)"
    75      "(func (param i32) (i64.store64 (local.get 0) (i64.const 0)))"
    76    )
    77    "unknown operator"
    78  )
    79  
    80  (assert_malformed
    81    (module quote
    82      "(memory 1)"
    83      "(func (param i32) (f32.store32 (local.get 0) (f32.const 0)))"
    84    )
    85    "unknown operator"
    86  )
    87  (assert_malformed
    88    (module quote
    89      "(memory 1)"
    90      "(func (param i32) (f32.store64 (local.get 0) (f64.const 0)))"
    91    )
    92    "unknown operator"
    93  )
    94  
    95  (assert_malformed
    96    (module quote
    97      "(memory 1)"
    98      "(func (param i32) (f64.store32 (local.get 0) (f32.const 0)))"
    99    )
   100    "unknown operator"
   101  )
   102  (assert_malformed
   103    (module quote
   104      "(memory 1)"
   105      "(func (param i32) (f64.store64 (local.get 0) (f64.const 0)))"
   106    )
   107    "unknown operator"
   108  )
   109  ;; store should have no retval
   110  
   111  (assert_invalid
   112    (module (memory 1) (func (param i32) (result i32) (i32.store (i32.const 0) (i32.const 1))))
   113    "type mismatch"
   114  )
   115  (assert_invalid
   116    (module (memory 1) (func (param i64) (result i64) (i64.store (i32.const 0) (i64.const 1))))
   117    "type mismatch"
   118  )
   119  (assert_invalid
   120    (module (memory 1) (func (param f32) (result f32) (f32.store (i32.const 0) (f32.const 1))))
   121    "type mismatch"
   122  )
   123  (assert_invalid
   124    (module (memory 1) (func (param f64) (result f64) (f64.store (i32.const 0) (f64.const 1))))
   125    "type mismatch"
   126  )
   127  (assert_invalid
   128    (module (memory 1) (func (param i32) (result i32) (i32.store8 (i32.const 0) (i32.const 1))))
   129    "type mismatch"
   130  )
   131  (assert_invalid
   132    (module (memory 1) (func (param i32) (result i32) (i32.store16 (i32.const 0) (i32.const 1))))
   133    "type mismatch"
   134  )
   135  (assert_invalid
   136    (module (memory 1) (func (param i64) (result i64) (i64.store8 (i32.const 0) (i64.const 1))))
   137    "type mismatch"
   138  )
   139  (assert_invalid
   140    (module (memory 1) (func (param i64) (result i64) (i64.store16 (i32.const 0) (i64.const 1))))
   141    "type mismatch"
   142  )
   143  (assert_invalid
   144    (module (memory 1) (func (param i64) (result i64) (i64.store32 (i32.const 0) (i64.const 1))))
   145    "type mismatch"
   146  )
   147  
   148  
   149  (assert_invalid
   150    (module
   151      (memory 1)
   152      (func $type-address-empty
   153        (i32.store)
   154      )
   155    )
   156    "type mismatch"
   157  )
   158  (assert_invalid
   159    (module
   160      (memory 1)
   161      (func $type-value-empty
   162       (i32.const 0) (i32.store)
   163      )
   164    )
   165    "type mismatch"
   166  )
   167  (assert_invalid
   168    (module
   169      (memory 1)
   170      (func $type-address-empty-in-block
   171        (i32.const 0) (i32.const 0)
   172        (block (i32.store))
   173      )
   174    )
   175    "type mismatch"
   176  )
   177  (assert_invalid
   178    (module
   179      (memory 1)
   180      (func $type-value-empty-in-block
   181        (i32.const 0)
   182        (block (i32.const 0) (i32.store))
   183      )
   184    )
   185    "type mismatch"
   186  )
   187  (assert_invalid
   188    (module
   189      (memory 1)
   190      (func $type-address-empty-in-loop
   191        (i32.const 0) (i32.const 0)
   192        (loop (i32.store))
   193      )
   194    )
   195    "type mismatch"
   196  )
   197  (assert_invalid
   198    (module
   199      (memory 1)
   200      (func $type-value-empty-in-loop
   201        (i32.const 0)
   202        (loop (i32.const 0) (i32.store))
   203      )
   204    )
   205    "type mismatch"
   206  )
   207  (assert_invalid
   208    (module
   209      (memory 1)
   210      (func $type-address-empty-in-then
   211        (i32.const 0) (i32.const 0)
   212        (if (then (i32.store)))
   213      )
   214    )
   215    "type mismatch"
   216  )
   217  (assert_invalid
   218    (module
   219      (memory 1)
   220      (func $type-value-empty-in-then
   221        (i32.const 0)
   222        (if (then (i32.const 0) (i32.store)))
   223      )
   224    )
   225    "type mismatch"
   226  )
   227  (assert_invalid
   228    (module
   229      (memory 1)
   230      (func $type-address-empty-in-else
   231        (i32.const 0) (i32.const 0)
   232        (if (result i32) (then (i32.const 0)) (else (i32.store)))
   233      )
   234    )
   235    "type mismatch"
   236  )
   237  (assert_invalid
   238    (module
   239      (memory 1)
   240      (func $type-value-empty-in-else
   241        (i32.const 0)
   242        (if (result i32) (then (i32.const 0)) (else (i32.const 0) (i32.store)))
   243      )
   244    )
   245    "type mismatch"
   246  )
   247  (assert_invalid
   248    (module
   249      (memory 1)
   250      (func $type-address-empty-in-br
   251        (i32.const 0) (i32.const 0)
   252        (block (br 0 (i32.store)))
   253      )
   254    )
   255    "type mismatch"
   256  )
   257  (assert_invalid
   258    (module
   259      (memory 1)
   260      (func $type-value-empty-in-br
   261        (i32.const 0)
   262        (block (br 0 (i32.const 0) (i32.store)))
   263      )
   264    )
   265    "type mismatch"
   266  )
   267  (assert_invalid
   268    (module
   269      (memory 1)
   270      (func $type-address-empty-in-br_if
   271        (i32.const 0) (i32.const 0)
   272        (block (br_if 0 (i32.store) (i32.const 1)) )
   273      )
   274    )
   275    "type mismatch"
   276  )
   277  (assert_invalid
   278    (module
   279      (memory 1)
   280      (func $type-value-empty-in-br_if
   281        (i32.const 0)
   282        (block (br_if 0 (i32.const 0) (i32.store) (i32.const 1)) )
   283      )
   284    )
   285    "type mismatch"
   286  )
   287  (assert_invalid
   288    (module
   289      (memory 1)
   290      (func $type-address-empty-in-br_table
   291        (i32.const 0) (i32.const 0)
   292        (block (br_table 0 (i32.store)))
   293      )
   294    )
   295    "type mismatch"
   296  )
   297  (assert_invalid
   298    (module
   299      (memory 1)
   300      (func $type-value-empty-in-br_table
   301        (i32.const 0)
   302        (block (br_table 0 (i32.const 0) (i32.store)))
   303      )
   304    )
   305    "type mismatch"
   306  )
   307  (assert_invalid
   308    (module
   309      (memory 1)
   310      (func $type-address-empty-in-return
   311        (return (i32.store))
   312      )
   313    )
   314    "type mismatch"
   315  )
   316  (assert_invalid
   317    (module
   318      (memory 1)
   319      (func $type-value-empty-in-return
   320        (return (i32.const 0) (i32.store))
   321      )
   322    )
   323    "type mismatch"
   324  )
   325  (assert_invalid
   326    (module
   327      (memory 1)
   328      (func $type-address-empty-in-select
   329        (select (i32.store) (i32.const 1) (i32.const 2))
   330      )
   331    )
   332    "type mismatch"
   333  )
   334  (assert_invalid
   335    (module
   336      (memory 1)
   337      (func $type-value-empty-in-select
   338        (select (i32.const 0) (i32.store) (i32.const 1) (i32.const 2))
   339      )
   340    )
   341    "type mismatch"
   342  )
   343  (assert_invalid
   344    (module
   345      (memory 1)
   346      (func $type-address-empty-in-call
   347        (call 1 (i32.store))
   348      )
   349      (func (param i32) (result i32) (local.get 0))
   350    )
   351    "type mismatch"
   352  )
   353  (assert_invalid
   354    (module
   355      (memory 1)
   356      (func $type-value-empty-in-call
   357        (call 1 (i32.const 0) (i32.store))
   358      )
   359      (func (param i32) (result i32) (local.get 0))
   360    )
   361    "type mismatch"
   362  )
   363  (assert_invalid
   364    (module
   365      (memory 1)
   366      (func $f (param i32) (result i32) (local.get 0))
   367      (type $sig (func (param i32) (result i32)))
   368      (table funcref (elem $f))
   369      (func $type-address-empty-in-call_indirect
   370        (block (result i32)
   371          (call_indirect (type $sig)
   372            (i32.store) (i32.const 0)
   373          )
   374        )
   375      )
   376    )
   377    "type mismatch"
   378  )
   379  (assert_invalid
   380    (module
   381      (memory 1)
   382      (func $f (param i32) (result i32) (local.get 0))
   383      (type $sig (func (param i32) (result i32)))
   384      (table funcref (elem $f))
   385      (func $type-value-empty-in-call_indirect
   386        (block (result i32)
   387          (call_indirect (type $sig)
   388            (i32.const 0) (i32.store) (i32.const 0)
   389          )
   390        )
   391      )
   392    )
   393    "type mismatch"
   394  )
   395  
   396  
   397  ;; Type check
   398  
   399  (assert_invalid (module (memory 1) (func (i32.store (f32.const 0) (i32.const 0)))) "type mismatch")
   400  (assert_invalid (module (memory 1) (func (i32.store8 (f32.const 0) (i32.const 0)))) "type mismatch")
   401  (assert_invalid (module (memory 1) (func (i32.store16 (f32.const 0) (i32.const 0)))) "type mismatch")
   402  (assert_invalid (module (memory 1) (func (i64.store (f32.const 0) (i32.const 0)))) "type mismatch")
   403  (assert_invalid (module (memory 1) (func (i64.store8 (f32.const 0) (i64.const 0)))) "type mismatch")
   404  (assert_invalid (module (memory 1) (func (i64.store16 (f32.const 0) (i64.const 0)))) "type mismatch")
   405  (assert_invalid (module (memory 1) (func (i64.store32 (f32.const 0) (i64.const 0)))) "type mismatch")
   406  (assert_invalid (module (memory 1) (func (f32.store (f32.const 0) (f32.const 0)))) "type mismatch")
   407  (assert_invalid (module (memory 1) (func (f64.store (f32.const 0) (f64.const 0)))) "type mismatch")
   408  
   409  (assert_invalid (module (memory 1) (func (i32.store (i32.const 0) (f32.const 0)))) "type mismatch")
   410  (assert_invalid (module (memory 1) (func (i32.store8 (i32.const 0) (f32.const 0)))) "type mismatch")
   411  (assert_invalid (module (memory 1) (func (i32.store16 (i32.const 0) (f32.const 0)))) "type mismatch")
   412  (assert_invalid (module (memory 1) (func (i64.store (i32.const 0) (f32.const 0)))) "type mismatch")
   413  (assert_invalid (module (memory 1) (func (i64.store8 (i32.const 0) (f64.const 0)))) "type mismatch")
   414  (assert_invalid (module (memory 1) (func (i64.store16 (i32.const 0) (f64.const 0)))) "type mismatch")
   415  (assert_invalid (module (memory 1) (func (i64.store32 (i32.const 0) (f64.const 0)))) "type mismatch")
   416  (assert_invalid (module (memory 1) (func (f32.store (i32.const 0) (i32.const 0)))) "type mismatch")
   417  (assert_invalid (module (memory 1) (func (f64.store (i32.const 0) (i64.const 0)))) "type mismatch")