wa-lang.org/wazero@v1.0.2/internal/integration_test/spectest/v2/testdata/unreachable.wast (about) 1 ;; Test `unreachable` operator 2 3 (module 4 ;; Auxiliary definitions 5 (func $dummy) 6 (func $dummy3 (param i32 i32 i32)) 7 8 (func (export "type-i32") (result i32) (unreachable)) 9 (func (export "type-i64") (result i32) (unreachable)) 10 (func (export "type-f32") (result f64) (unreachable)) 11 (func (export "type-f64") (result f64) (unreachable)) 12 13 (func (export "as-func-first") (result i32) 14 (unreachable) (i32.const -1) 15 ) 16 (func (export "as-func-mid") (result i32) 17 (call $dummy) (unreachable) (i32.const -1) 18 ) 19 (func (export "as-func-last") 20 (call $dummy) (unreachable) 21 ) 22 (func (export "as-func-value") (result i32) 23 (call $dummy) (unreachable) 24 ) 25 26 (func (export "as-block-first") (result i32) 27 (block (result i32) (unreachable) (i32.const 2)) 28 ) 29 (func (export "as-block-mid") (result i32) 30 (block (result i32) (call $dummy) (unreachable) (i32.const 2)) 31 ) 32 (func (export "as-block-last") 33 (block (nop) (call $dummy) (unreachable)) 34 ) 35 (func (export "as-block-value") (result i32) 36 (block (result i32) (nop) (call $dummy) (unreachable)) 37 ) 38 (func (export "as-block-broke") (result i32) 39 (block (result i32) (call $dummy) (br 0 (i32.const 1)) (unreachable)) 40 ) 41 42 (func (export "as-loop-first") (result i32) 43 (loop (result i32) (unreachable) (i32.const 2)) 44 ) 45 (func (export "as-loop-mid") (result i32) 46 (loop (result i32) (call $dummy) (unreachable) (i32.const 2)) 47 ) 48 (func (export "as-loop-last") 49 (loop (nop) (call $dummy) (unreachable)) 50 ) 51 (func (export "as-loop-broke") (result i32) 52 (block (result i32) 53 (loop (result i32) (call $dummy) (br 1 (i32.const 1)) (unreachable)) 54 ) 55 ) 56 57 (func (export "as-br-value") (result i32) 58 (block (result i32) (br 0 (unreachable))) 59 ) 60 61 (func (export "as-br_if-cond") 62 (block (br_if 0 (unreachable))) 63 ) 64 (func (export "as-br_if-value") (result i32) 65 (block (result i32) 66 (drop (br_if 0 (unreachable) (i32.const 1))) (i32.const 7) 67 ) 68 ) 69 (func (export "as-br_if-value-cond") (result i32) 70 (block (result i32) 71 (drop (br_if 0 (i32.const 6) (unreachable))) (i32.const 7) 72 ) 73 ) 74 75 (func (export "as-br_table-index") 76 (block (br_table 0 0 0 (unreachable))) 77 ) 78 (func (export "as-br_table-value") (result i32) 79 (block (result i32) 80 (br_table 0 0 0 (unreachable) (i32.const 1)) (i32.const 7) 81 ) 82 ) 83 (func (export "as-br_table-value-2") (result i32) 84 (block (result i32) 85 (block (result i32) (br_table 0 1 (unreachable) (i32.const 1))) 86 ) 87 ) 88 (func (export "as-br_table-value-index") (result i32) 89 (block (result i32) 90 (br_table 0 0 (i32.const 6) (unreachable)) (i32.const 7) 91 ) 92 ) 93 (func (export "as-br_table-value-and-index") (result i32) 94 (block (result i32) (br_table 0 0 (unreachable)) (i32.const 8)) 95 ) 96 97 (func (export "as-return-value") (result i64) 98 (return (unreachable)) 99 ) 100 101 (func (export "as-if-cond") (result i32) 102 (if (result i32) (unreachable) (then (i32.const 0)) (else (i32.const 1))) 103 ) 104 (func (export "as-if-then") (param i32 i32) (result i32) 105 (if (result i32) (local.get 0) (then (unreachable)) (else (local.get 1))) 106 ) 107 (func (export "as-if-else") (param i32 i32) (result i32) 108 (if (result i32) (local.get 0) (then (local.get 1)) (else (unreachable))) 109 ) 110 (func (export "as-if-then-no-else") (param i32 i32) (result i32) 111 (if (local.get 0) (then (unreachable))) (local.get 1) 112 ) 113 114 (func (export "as-select-first") (param i32 i32) (result i32) 115 (select (unreachable) (local.get 0) (local.get 1)) 116 ) 117 (func (export "as-select-second") (param i32 i32) (result i32) 118 (select (local.get 0) (unreachable) (local.get 1)) 119 ) 120 (func (export "as-select-cond") (result i32) 121 (select (i32.const 0) (i32.const 1) (unreachable)) 122 ) 123 124 (func (export "as-call-first") 125 (call $dummy3 (unreachable) (i32.const 2) (i32.const 3)) 126 ) 127 (func (export "as-call-mid") 128 (call $dummy3 (i32.const 1) (unreachable) (i32.const 3)) 129 ) 130 (func (export "as-call-last") 131 (call $dummy3 (i32.const 1) (i32.const 2) (unreachable)) 132 ) 133 134 (type $sig (func (param i32 i32 i32))) 135 (table funcref (elem $dummy3)) 136 (func (export "as-call_indirect-func") 137 (call_indirect (type $sig) 138 (unreachable) (i32.const 1) (i32.const 2) (i32.const 3) 139 ) 140 ) 141 (func (export "as-call_indirect-first") 142 (call_indirect (type $sig) 143 (i32.const 0) (unreachable) (i32.const 2) (i32.const 3) 144 ) 145 ) 146 (func (export "as-call_indirect-mid") 147 (call_indirect (type $sig) 148 (i32.const 0) (i32.const 1) (unreachable) (i32.const 3) 149 ) 150 ) 151 (func (export "as-call_indirect-last") 152 (call_indirect (type $sig) 153 (i32.const 0) (i32.const 1) (i32.const 2) (unreachable) 154 ) 155 ) 156 157 (func (export "as-local.set-value") (local f32) 158 (local.set 0 (unreachable)) 159 ) 160 (func (export "as-local.tee-value") (result f32) (local f32) 161 (local.tee 0 (unreachable)) 162 ) 163 (global $a (mut f32) (f32.const 0)) 164 (func (export "as-global.set-value") (result f32) 165 (global.set $a (unreachable)) 166 ) 167 168 (memory 1) 169 (func (export "as-load-address") (result f32) 170 (f32.load (unreachable)) 171 ) 172 (func (export "as-loadN-address") (result i64) 173 (i64.load8_s (unreachable)) 174 ) 175 176 (func (export "as-store-address") 177 (f64.store (unreachable) (f64.const 7)) 178 ) 179 (func (export "as-store-value") 180 (i64.store (i32.const 2) (unreachable)) 181 ) 182 183 (func (export "as-storeN-address") 184 (i32.store8 (unreachable) (i32.const 7)) 185 ) 186 (func (export "as-storeN-value") 187 (i64.store16 (i32.const 2) (unreachable)) 188 ) 189 190 (func (export "as-unary-operand") (result f32) 191 (f32.neg (unreachable)) 192 ) 193 194 (func (export "as-binary-left") (result i32) 195 (i32.add (unreachable) (i32.const 10)) 196 ) 197 (func (export "as-binary-right") (result i64) 198 (i64.sub (i64.const 10) (unreachable)) 199 ) 200 201 (func (export "as-test-operand") (result i32) 202 (i32.eqz (unreachable)) 203 ) 204 205 (func (export "as-compare-left") (result i32) 206 (f64.le (unreachable) (f64.const 10)) 207 ) 208 (func (export "as-compare-right") (result i32) 209 (f32.ne (f32.const 10) (unreachable)) 210 ) 211 212 (func (export "as-convert-operand") (result i32) 213 (i32.wrap_i64 (unreachable)) 214 ) 215 216 (func (export "as-memory.grow-size") (result i32) 217 (memory.grow (unreachable)) 218 ) 219 ) 220 221 (assert_trap (invoke "type-i32") "unreachable") 222 (assert_trap (invoke "type-i64") "unreachable") 223 (assert_trap (invoke "type-f32") "unreachable") 224 (assert_trap (invoke "type-f64") "unreachable") 225 226 (assert_trap (invoke "as-func-first") "unreachable") 227 (assert_trap (invoke "as-func-mid") "unreachable") 228 (assert_trap (invoke "as-func-last") "unreachable") 229 (assert_trap (invoke "as-func-value") "unreachable") 230 231 (assert_trap (invoke "as-block-first") "unreachable") 232 (assert_trap (invoke "as-block-mid") "unreachable") 233 (assert_trap (invoke "as-block-last") "unreachable") 234 (assert_trap (invoke "as-block-value") "unreachable") 235 (assert_return (invoke "as-block-broke") (i32.const 1)) 236 237 (assert_trap (invoke "as-loop-first") "unreachable") 238 (assert_trap (invoke "as-loop-mid") "unreachable") 239 (assert_trap (invoke "as-loop-last") "unreachable") 240 (assert_return (invoke "as-loop-broke") (i32.const 1)) 241 242 (assert_trap (invoke "as-br-value") "unreachable") 243 244 (assert_trap (invoke "as-br_if-cond") "unreachable") 245 (assert_trap (invoke "as-br_if-value") "unreachable") 246 (assert_trap (invoke "as-br_if-value-cond") "unreachable") 247 248 (assert_trap (invoke "as-br_table-index") "unreachable") 249 (assert_trap (invoke "as-br_table-value") "unreachable") 250 (assert_trap (invoke "as-br_table-value-2") "unreachable") 251 (assert_trap (invoke "as-br_table-value-index") "unreachable") 252 (assert_trap (invoke "as-br_table-value-and-index") "unreachable") 253 254 (assert_trap (invoke "as-return-value") "unreachable") 255 256 (assert_trap (invoke "as-if-cond") "unreachable") 257 (assert_trap (invoke "as-if-then" (i32.const 1) (i32.const 6)) "unreachable") 258 (assert_return (invoke "as-if-then" (i32.const 0) (i32.const 6)) (i32.const 6)) 259 (assert_trap (invoke "as-if-else" (i32.const 0) (i32.const 6)) "unreachable") 260 (assert_return (invoke "as-if-else" (i32.const 1) (i32.const 6)) (i32.const 6)) 261 (assert_trap (invoke "as-if-then-no-else" (i32.const 1) (i32.const 6)) "unreachable") 262 (assert_return (invoke "as-if-then-no-else" (i32.const 0) (i32.const 6)) (i32.const 6)) 263 264 (assert_trap (invoke "as-select-first" (i32.const 0) (i32.const 6)) "unreachable") 265 (assert_trap (invoke "as-select-first" (i32.const 1) (i32.const 6)) "unreachable") 266 (assert_trap (invoke "as-select-second" (i32.const 0) (i32.const 6)) "unreachable") 267 (assert_trap (invoke "as-select-second" (i32.const 1) (i32.const 6)) "unreachable") 268 (assert_trap (invoke "as-select-cond") "unreachable") 269 270 (assert_trap (invoke "as-call-first") "unreachable") 271 (assert_trap (invoke "as-call-mid") "unreachable") 272 (assert_trap (invoke "as-call-last") "unreachable") 273 274 (assert_trap (invoke "as-call_indirect-func") "unreachable") 275 (assert_trap (invoke "as-call_indirect-first") "unreachable") 276 (assert_trap (invoke "as-call_indirect-mid") "unreachable") 277 (assert_trap (invoke "as-call_indirect-last") "unreachable") 278 279 (assert_trap (invoke "as-local.set-value") "unreachable") 280 (assert_trap (invoke "as-local.tee-value") "unreachable") 281 (assert_trap (invoke "as-global.set-value") "unreachable") 282 283 (assert_trap (invoke "as-load-address") "unreachable") 284 (assert_trap (invoke "as-loadN-address") "unreachable") 285 286 (assert_trap (invoke "as-store-address") "unreachable") 287 (assert_trap (invoke "as-store-value") "unreachable") 288 (assert_trap (invoke "as-storeN-address") "unreachable") 289 (assert_trap (invoke "as-storeN-value") "unreachable") 290 291 (assert_trap (invoke "as-unary-operand") "unreachable") 292 293 (assert_trap (invoke "as-binary-left") "unreachable") 294 (assert_trap (invoke "as-binary-right") "unreachable") 295 296 (assert_trap (invoke "as-test-operand") "unreachable") 297 298 (assert_trap (invoke "as-compare-left") "unreachable") 299 (assert_trap (invoke "as-compare-right") "unreachable") 300 301 (assert_trap (invoke "as-convert-operand") "unreachable") 302 303 (assert_trap (invoke "as-memory.grow-size") "unreachable") 304