| 1 |
/* Copyright 2021 Mozilla Foundation |
| 2 |
* |
| 3 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
* you may not use this file except in compliance with the License. |
| 5 |
* You may obtain a copy of the License at |
| 6 |
* |
| 7 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
* |
| 9 |
* Unless required by applicable law or agreed to in writing, software |
| 10 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
* See the License for the specific language governing permissions and |
| 13 |
* limitations under the License. |
| 14 |
*/ |
| 15 |
|
| 16 |
// ./test/core/unreachable.wast |
| 17 |
|
| 18 |
// ./test/core/unreachable.wast:3 |
| 19 |
let $0 = instantiate(`(module |
| 20 |
;; Auxiliary definitions |
| 21 |
(func $$dummy) |
| 22 |
(func $$dummy3 (param i32 i32 i32)) |
| 23 |
|
| 24 |
(func (export "type-i32") (result i32) (unreachable)) |
| 25 |
(func (export "type-i64") (result i32) (unreachable)) |
| 26 |
(func (export "type-f32") (result f64) (unreachable)) |
| 27 |
(func (export "type-f64") (result f64) (unreachable)) |
| 28 |
|
| 29 |
(func (export "as-func-first") (result i32) |
| 30 |
(unreachable) (i32.const -1) |
| 31 |
) |
| 32 |
(func (export "as-func-mid") (result i32) |
| 33 |
(call $$dummy) (unreachable) (i32.const -1) |
| 34 |
) |
| 35 |
(func (export "as-func-last") |
| 36 |
(call $$dummy) (unreachable) |
| 37 |
) |
| 38 |
(func (export "as-func-value") (result i32) |
| 39 |
(call $$dummy) (unreachable) |
| 40 |
) |
| 41 |
|
| 42 |
(func (export "as-block-first") (result i32) |
| 43 |
(block (result i32) (unreachable) (i32.const 2)) |
| 44 |
) |
| 45 |
(func (export "as-block-mid") (result i32) |
| 46 |
(block (result i32) (call $$dummy) (unreachable) (i32.const 2)) |
| 47 |
) |
| 48 |
(func (export "as-block-last") |
| 49 |
(block (nop) (call $$dummy) (unreachable)) |
| 50 |
) |
| 51 |
(func (export "as-block-value") (result i32) |
| 52 |
(block (result i32) (nop) (call $$dummy) (unreachable)) |
| 53 |
) |
| 54 |
(func (export "as-block-broke") (result i32) |
| 55 |
(block (result i32) (call $$dummy) (br 0 (i32.const 1)) (unreachable)) |
| 56 |
) |
| 57 |
|
| 58 |
(func (export "as-loop-first") (result i32) |
| 59 |
(loop (result i32) (unreachable) (i32.const 2)) |
| 60 |
) |
| 61 |
(func (export "as-loop-mid") (result i32) |
| 62 |
(loop (result i32) (call $$dummy) (unreachable) (i32.const 2)) |
| 63 |
) |
| 64 |
(func (export "as-loop-last") |
| 65 |
(loop (nop) (call $$dummy) (unreachable)) |
| 66 |
) |
| 67 |
(func (export "as-loop-broke") (result i32) |
| 68 |
(block (result i32) |
| 69 |
(loop (result i32) (call $$dummy) (br 1 (i32.const 1)) (unreachable)) |
| 70 |
) |
| 71 |
) |
| 72 |
|
| 73 |
(func (export "as-br-value") (result i32) |
| 74 |
(block (result i32) (br 0 (unreachable))) |
| 75 |
) |
| 76 |
|
| 77 |
(func (export "as-br_if-cond") |
| 78 |
(block (br_if 0 (unreachable))) |
| 79 |
) |
| 80 |
(func (export "as-br_if-value") (result i32) |
| 81 |
(block (result i32) |
| 82 |
(drop (br_if 0 (unreachable) (i32.const 1))) (i32.const 7) |
| 83 |
) |
| 84 |
) |
| 85 |
(func (export "as-br_if-value-cond") (result i32) |
| 86 |
(block (result i32) |
| 87 |
(drop (br_if 0 (i32.const 6) (unreachable))) (i32.const 7) |
| 88 |
) |
| 89 |
) |
| 90 |
|
| 91 |
(func (export "as-br_table-index") |
| 92 |
(block (br_table 0 0 0 (unreachable))) |
| 93 |
) |
| 94 |
(func (export "as-br_table-value") (result i32) |
| 95 |
(block (result i32) |
| 96 |
(br_table 0 0 0 (unreachable) (i32.const 1)) (i32.const 7) |
| 97 |
) |
| 98 |
) |
| 99 |
(func (export "as-br_table-value-2") (result i32) |
| 100 |
(block (result i32) |
| 101 |
(block (result i32) (br_table 0 1 (unreachable) (i32.const 1))) |
| 102 |
) |
| 103 |
) |
| 104 |
(func (export "as-br_table-value-index") (result i32) |
| 105 |
(block (result i32) |
| 106 |
(br_table 0 0 (i32.const 6) (unreachable)) (i32.const 7) |
| 107 |
) |
| 108 |
) |
| 109 |
(func (export "as-br_table-value-and-index") (result i32) |
| 110 |
(block (result i32) (br_table 0 0 (unreachable)) (i32.const 8)) |
| 111 |
) |
| 112 |
|
| 113 |
(func (export "as-return-value") (result i64) |
| 114 |
(return (unreachable)) |
| 115 |
) |
| 116 |
|
| 117 |
(func (export "as-if-cond") (result i32) |
| 118 |
(if (result i32) (unreachable) (then (i32.const 0)) (else (i32.const 1))) |
| 119 |
) |
| 120 |
(func (export "as-if-then") (param i32 i32) (result i32) |
| 121 |
(if (result i32) (local.get 0) (then (unreachable)) (else (local.get 1))) |
| 122 |
) |
| 123 |
(func (export "as-if-else") (param i32 i32) (result i32) |
| 124 |
(if (result i32) (local.get 0) (then (local.get 1)) (else (unreachable))) |
| 125 |
) |
| 126 |
(func (export "as-if-then-no-else") (param i32 i32) (result i32) |
| 127 |
(if (local.get 0) (then (unreachable))) (local.get 1) |
| 128 |
) |
| 129 |
|
| 130 |
(func (export "as-select-first") (param i32 i32) (result i32) |
| 131 |
(select (unreachable) (local.get 0) (local.get 1)) |
| 132 |
) |
| 133 |
(func (export "as-select-second") (param i32 i32) (result i32) |
| 134 |
(select (local.get 0) (unreachable) (local.get 1)) |
| 135 |
) |
| 136 |
(func (export "as-select-cond") (result i32) |
| 137 |
(select (i32.const 0) (i32.const 1) (unreachable)) |
| 138 |
) |
| 139 |
|
| 140 |
(func (export "as-call-first") |
| 141 |
(call $$dummy3 (unreachable) (i32.const 2) (i32.const 3)) |
| 142 |
) |
| 143 |
(func (export "as-call-mid") |
| 144 |
(call $$dummy3 (i32.const 1) (unreachable) (i32.const 3)) |
| 145 |
) |
| 146 |
(func (export "as-call-last") |
| 147 |
(call $$dummy3 (i32.const 1) (i32.const 2) (unreachable)) |
| 148 |
) |
| 149 |
|
| 150 |
(type $$sig (func (param i32 i32 i32))) |
| 151 |
(table funcref (elem $$dummy3)) |
| 152 |
(func (export "as-call_indirect-func") |
| 153 |
(call_indirect (type $$sig) |
| 154 |
(unreachable) (i32.const 1) (i32.const 2) (i32.const 3) |
| 155 |
) |
| 156 |
) |
| 157 |
(func (export "as-call_indirect-first") |
| 158 |
(call_indirect (type $$sig) |
| 159 |
(i32.const 0) (unreachable) (i32.const 2) (i32.const 3) |
| 160 |
) |
| 161 |
) |
| 162 |
(func (export "as-call_indirect-mid") |
| 163 |
(call_indirect (type $$sig) |
| 164 |
(i32.const 0) (i32.const 1) (unreachable) (i32.const 3) |
| 165 |
) |
| 166 |
) |
| 167 |
(func (export "as-call_indirect-last") |
| 168 |
(call_indirect (type $$sig) |
| 169 |
(i32.const 0) (i32.const 1) (i32.const 2) (unreachable) |
| 170 |
) |
| 171 |
) |
| 172 |
|
| 173 |
(func (export "as-local.set-value") (local f32) |
| 174 |
(local.set 0 (unreachable)) |
| 175 |
) |
| 176 |
(func (export "as-local.tee-value") (result f32) (local f32) |
| 177 |
(local.tee 0 (unreachable)) |
| 178 |
) |
| 179 |
(global $$a (mut f32) (f32.const 0)) |
| 180 |
(func (export "as-global.set-value") (result f32) |
| 181 |
(global.set $$a (unreachable)) |
| 182 |
) |
| 183 |
|
| 184 |
(memory 1) |
| 185 |
(func (export "as-load-address") (result f32) |
| 186 |
(f32.load (unreachable)) |
| 187 |
) |
| 188 |
(func (export "as-loadN-address") (result i64) |
| 189 |
(i64.load8_s (unreachable)) |
| 190 |
) |
| 191 |
|
| 192 |
(func (export "as-store-address") |
| 193 |
(f64.store (unreachable) (f64.const 7)) |
| 194 |
) |
| 195 |
(func (export "as-store-value") |
| 196 |
(i64.store (i32.const 2) (unreachable)) |
| 197 |
) |
| 198 |
|
| 199 |
(func (export "as-storeN-address") |
| 200 |
(i32.store8 (unreachable) (i32.const 7)) |
| 201 |
) |
| 202 |
(func (export "as-storeN-value") |
| 203 |
(i64.store16 (i32.const 2) (unreachable)) |
| 204 |
) |
| 205 |
|
| 206 |
(func (export "as-unary-operand") (result f32) |
| 207 |
(f32.neg (unreachable)) |
| 208 |
) |
| 209 |
|
| 210 |
(func (export "as-binary-left") (result i32) |
| 211 |
(i32.add (unreachable) (i32.const 10)) |
| 212 |
) |
| 213 |
(func (export "as-binary-right") (result i64) |
| 214 |
(i64.sub (i64.const 10) (unreachable)) |
| 215 |
) |
| 216 |
|
| 217 |
(func (export "as-test-operand") (result i32) |
| 218 |
(i32.eqz (unreachable)) |
| 219 |
) |
| 220 |
|
| 221 |
(func (export "as-compare-left") (result i32) |
| 222 |
(f64.le (unreachable) (f64.const 10)) |
| 223 |
) |
| 224 |
(func (export "as-compare-right") (result i32) |
| 225 |
(f32.ne (f32.const 10) (unreachable)) |
| 226 |
) |
| 227 |
|
| 228 |
(func (export "as-convert-operand") (result i32) |
| 229 |
(i32.wrap_i64 (unreachable)) |
| 230 |
) |
| 231 |
|
| 232 |
(func (export "as-memory.grow-size") (result i32) |
| 233 |
(memory.grow (unreachable)) |
| 234 |
) |
| 235 |
)`); |
| 236 |
|
| 237 |
// ./test/core/unreachable.wast:221 |
| 238 |
assert_trap(() => invoke($0, `type-i32`, []), `unreachable`); |
| 239 |
|
| 240 |
// ./test/core/unreachable.wast:222 |
| 241 |
assert_trap(() => invoke($0, `type-i64`, []), `unreachable`); |
| 242 |
|
| 243 |
// ./test/core/unreachable.wast:223 |
| 244 |
assert_trap(() => invoke($0, `type-f32`, []), `unreachable`); |
| 245 |
|
| 246 |
// ./test/core/unreachable.wast:224 |
| 247 |
assert_trap(() => invoke($0, `type-f64`, []), `unreachable`); |
| 248 |
|
| 249 |
// ./test/core/unreachable.wast:226 |
| 250 |
assert_trap(() => invoke($0, `as-func-first`, []), `unreachable`); |
| 251 |
|
| 252 |
// ./test/core/unreachable.wast:227 |
| 253 |
assert_trap(() => invoke($0, `as-func-mid`, []), `unreachable`); |
| 254 |
|
| 255 |
// ./test/core/unreachable.wast:228 |
| 256 |
assert_trap(() => invoke($0, `as-func-last`, []), `unreachable`); |
| 257 |
|
| 258 |
// ./test/core/unreachable.wast:229 |
| 259 |
assert_trap(() => invoke($0, `as-func-value`, []), `unreachable`); |
| 260 |
|
| 261 |
// ./test/core/unreachable.wast:231 |
| 262 |
assert_trap(() => invoke($0, `as-block-first`, []), `unreachable`); |
| 263 |
|
| 264 |
// ./test/core/unreachable.wast:232 |
| 265 |
assert_trap(() => invoke($0, `as-block-mid`, []), `unreachable`); |
| 266 |
|
| 267 |
// ./test/core/unreachable.wast:233 |
| 268 |
assert_trap(() => invoke($0, `as-block-last`, []), `unreachable`); |
| 269 |
|
| 270 |
// ./test/core/unreachable.wast:234 |
| 271 |
assert_trap(() => invoke($0, `as-block-value`, []), `unreachable`); |
| 272 |
|
| 273 |
// ./test/core/unreachable.wast:235 |
| 274 |
assert_return(() => invoke($0, `as-block-broke`, []), [value("i32", 1)]); |
| 275 |
|
| 276 |
// ./test/core/unreachable.wast:237 |
| 277 |
assert_trap(() => invoke($0, `as-loop-first`, []), `unreachable`); |
| 278 |
|
| 279 |
// ./test/core/unreachable.wast:238 |
| 280 |
assert_trap(() => invoke($0, `as-loop-mid`, []), `unreachable`); |
| 281 |
|
| 282 |
// ./test/core/unreachable.wast:239 |
| 283 |
assert_trap(() => invoke($0, `as-loop-last`, []), `unreachable`); |
| 284 |
|
| 285 |
// ./test/core/unreachable.wast:240 |
| 286 |
assert_return(() => invoke($0, `as-loop-broke`, []), [value("i32", 1)]); |
| 287 |
|
| 288 |
// ./test/core/unreachable.wast:242 |
| 289 |
assert_trap(() => invoke($0, `as-br-value`, []), `unreachable`); |
| 290 |
|
| 291 |
// ./test/core/unreachable.wast:244 |
| 292 |
assert_trap(() => invoke($0, `as-br_if-cond`, []), `unreachable`); |
| 293 |
|
| 294 |
// ./test/core/unreachable.wast:245 |
| 295 |
assert_trap(() => invoke($0, `as-br_if-value`, []), `unreachable`); |
| 296 |
|
| 297 |
// ./test/core/unreachable.wast:246 |
| 298 |
assert_trap(() => invoke($0, `as-br_if-value-cond`, []), `unreachable`); |
| 299 |
|
| 300 |
// ./test/core/unreachable.wast:248 |
| 301 |
assert_trap(() => invoke($0, `as-br_table-index`, []), `unreachable`); |
| 302 |
|
| 303 |
// ./test/core/unreachable.wast:249 |
| 304 |
assert_trap(() => invoke($0, `as-br_table-value`, []), `unreachable`); |
| 305 |
|
| 306 |
// ./test/core/unreachable.wast:250 |
| 307 |
assert_trap(() => invoke($0, `as-br_table-value-2`, []), `unreachable`); |
| 308 |
|
| 309 |
// ./test/core/unreachable.wast:251 |
| 310 |
assert_trap(() => invoke($0, `as-br_table-value-index`, []), `unreachable`); |
| 311 |
|
| 312 |
// ./test/core/unreachable.wast:252 |
| 313 |
assert_trap(() => invoke($0, `as-br_table-value-and-index`, []), `unreachable`); |
| 314 |
|
| 315 |
// ./test/core/unreachable.wast:254 |
| 316 |
assert_trap(() => invoke($0, `as-return-value`, []), `unreachable`); |
| 317 |
|
| 318 |
// ./test/core/unreachable.wast:256 |
| 319 |
assert_trap(() => invoke($0, `as-if-cond`, []), `unreachable`); |
| 320 |
|
| 321 |
// ./test/core/unreachable.wast:257 |
| 322 |
assert_trap(() => invoke($0, `as-if-then`, [1, 6]), `unreachable`); |
| 323 |
|
| 324 |
// ./test/core/unreachable.wast:258 |
| 325 |
assert_return(() => invoke($0, `as-if-then`, [0, 6]), [value("i32", 6)]); |
| 326 |
|
| 327 |
// ./test/core/unreachable.wast:259 |
| 328 |
assert_trap(() => invoke($0, `as-if-else`, [0, 6]), `unreachable`); |
| 329 |
|
| 330 |
// ./test/core/unreachable.wast:260 |
| 331 |
assert_return(() => invoke($0, `as-if-else`, [1, 6]), [value("i32", 6)]); |
| 332 |
|
| 333 |
// ./test/core/unreachable.wast:261 |
| 334 |
assert_trap(() => invoke($0, `as-if-then-no-else`, [1, 6]), `unreachable`); |
| 335 |
|
| 336 |
// ./test/core/unreachable.wast:262 |
| 337 |
assert_return(() => invoke($0, `as-if-then-no-else`, [0, 6]), [value("i32", 6)]); |
| 338 |
|
| 339 |
// ./test/core/unreachable.wast:264 |
| 340 |
assert_trap(() => invoke($0, `as-select-first`, [0, 6]), `unreachable`); |
| 341 |
|
| 342 |
// ./test/core/unreachable.wast:265 |
| 343 |
assert_trap(() => invoke($0, `as-select-first`, [1, 6]), `unreachable`); |
| 344 |
|
| 345 |
// ./test/core/unreachable.wast:266 |
| 346 |
assert_trap(() => invoke($0, `as-select-second`, [0, 6]), `unreachable`); |
| 347 |
|
| 348 |
// ./test/core/unreachable.wast:267 |
| 349 |
assert_trap(() => invoke($0, `as-select-second`, [1, 6]), `unreachable`); |
| 350 |
|
| 351 |
// ./test/core/unreachable.wast:268 |
| 352 |
assert_trap(() => invoke($0, `as-select-cond`, []), `unreachable`); |
| 353 |
|
| 354 |
// ./test/core/unreachable.wast:270 |
| 355 |
assert_trap(() => invoke($0, `as-call-first`, []), `unreachable`); |
| 356 |
|
| 357 |
// ./test/core/unreachable.wast:271 |
| 358 |
assert_trap(() => invoke($0, `as-call-mid`, []), `unreachable`); |
| 359 |
|
| 360 |
// ./test/core/unreachable.wast:272 |
| 361 |
assert_trap(() => invoke($0, `as-call-last`, []), `unreachable`); |
| 362 |
|
| 363 |
// ./test/core/unreachable.wast:274 |
| 364 |
assert_trap(() => invoke($0, `as-call_indirect-func`, []), `unreachable`); |
| 365 |
|
| 366 |
// ./test/core/unreachable.wast:275 |
| 367 |
assert_trap(() => invoke($0, `as-call_indirect-first`, []), `unreachable`); |
| 368 |
|
| 369 |
// ./test/core/unreachable.wast:276 |
| 370 |
assert_trap(() => invoke($0, `as-call_indirect-mid`, []), `unreachable`); |
| 371 |
|
| 372 |
// ./test/core/unreachable.wast:277 |
| 373 |
assert_trap(() => invoke($0, `as-call_indirect-last`, []), `unreachable`); |
| 374 |
|
| 375 |
// ./test/core/unreachable.wast:279 |
| 376 |
assert_trap(() => invoke($0, `as-local.set-value`, []), `unreachable`); |
| 377 |
|
| 378 |
// ./test/core/unreachable.wast:280 |
| 379 |
assert_trap(() => invoke($0, `as-local.tee-value`, []), `unreachable`); |
| 380 |
|
| 381 |
// ./test/core/unreachable.wast:281 |
| 382 |
assert_trap(() => invoke($0, `as-global.set-value`, []), `unreachable`); |
| 383 |
|
| 384 |
// ./test/core/unreachable.wast:283 |
| 385 |
assert_trap(() => invoke($0, `as-load-address`, []), `unreachable`); |
| 386 |
|
| 387 |
// ./test/core/unreachable.wast:284 |
| 388 |
assert_trap(() => invoke($0, `as-loadN-address`, []), `unreachable`); |
| 389 |
|
| 390 |
// ./test/core/unreachable.wast:286 |
| 391 |
assert_trap(() => invoke($0, `as-store-address`, []), `unreachable`); |
| 392 |
|
| 393 |
// ./test/core/unreachable.wast:287 |
| 394 |
assert_trap(() => invoke($0, `as-store-value`, []), `unreachable`); |
| 395 |
|
| 396 |
// ./test/core/unreachable.wast:288 |
| 397 |
assert_trap(() => invoke($0, `as-storeN-address`, []), `unreachable`); |
| 398 |
|
| 399 |
// ./test/core/unreachable.wast:289 |
| 400 |
assert_trap(() => invoke($0, `as-storeN-value`, []), `unreachable`); |
| 401 |
|
| 402 |
// ./test/core/unreachable.wast:291 |
| 403 |
assert_trap(() => invoke($0, `as-unary-operand`, []), `unreachable`); |
| 404 |
|
| 405 |
// ./test/core/unreachable.wast:293 |
| 406 |
assert_trap(() => invoke($0, `as-binary-left`, []), `unreachable`); |
| 407 |
|
| 408 |
// ./test/core/unreachable.wast:294 |
| 409 |
assert_trap(() => invoke($0, `as-binary-right`, []), `unreachable`); |
| 410 |
|
| 411 |
// ./test/core/unreachable.wast:296 |
| 412 |
assert_trap(() => invoke($0, `as-test-operand`, []), `unreachable`); |
| 413 |
|
| 414 |
// ./test/core/unreachable.wast:298 |
| 415 |
assert_trap(() => invoke($0, `as-compare-left`, []), `unreachable`); |
| 416 |
|
| 417 |
// ./test/core/unreachable.wast:299 |
| 418 |
assert_trap(() => invoke($0, `as-compare-right`, []), `unreachable`); |
| 419 |
|
| 420 |
// ./test/core/unreachable.wast:301 |
| 421 |
assert_trap(() => invoke($0, `as-convert-operand`, []), `unreachable`); |
| 422 |
|
| 423 |
// ./test/core/unreachable.wast:303 |
| 424 |
assert_trap(() => invoke($0, `as-memory.grow-size`, []), `unreachable`); |