| 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/if.wast |
| 17 |
|
| 18 |
// ./test/core/if.wast:3 |
| 19 |
let $0 = instantiate(`(module |
| 20 |
;; Auxiliary definition |
| 21 |
(memory 1) |
| 22 |
|
| 23 |
(func $$dummy) |
| 24 |
|
| 25 |
(func (export "empty") (param i32) |
| 26 |
(if (local.get 0) (then)) |
| 27 |
(if (local.get 0) (then) (else)) |
| 28 |
(if $$l (local.get 0) (then)) |
| 29 |
(if $$l (local.get 0) (then) (else)) |
| 30 |
) |
| 31 |
|
| 32 |
(func (export "singular") (param i32) (result i32) |
| 33 |
(if (local.get 0) (then (nop))) |
| 34 |
(if (local.get 0) (then (nop)) (else (nop))) |
| 35 |
(if (result i32) (local.get 0) (then (i32.const 7)) (else (i32.const 8))) |
| 36 |
) |
| 37 |
|
| 38 |
(func (export "multi") (param i32) (result i32 i32) |
| 39 |
(if (local.get 0) (then (call $$dummy) (call $$dummy) (call $$dummy))) |
| 40 |
(if (local.get 0) (then) (else (call $$dummy) (call $$dummy) (call $$dummy))) |
| 41 |
(if (result i32) (local.get 0) |
| 42 |
(then (call $$dummy) (call $$dummy) (i32.const 8) (call $$dummy)) |
| 43 |
(else (call $$dummy) (call $$dummy) (i32.const 9) (call $$dummy)) |
| 44 |
) |
| 45 |
(if (result i32 i64 i32) (local.get 0) |
| 46 |
(then |
| 47 |
(call $$dummy) (call $$dummy) (i32.const 1) (call $$dummy) |
| 48 |
(call $$dummy) (call $$dummy) (i64.const 2) (call $$dummy) |
| 49 |
(call $$dummy) (call $$dummy) (i32.const 3) (call $$dummy) |
| 50 |
) |
| 51 |
(else |
| 52 |
(call $$dummy) (call $$dummy) (i32.const -1) (call $$dummy) |
| 53 |
(call $$dummy) (call $$dummy) (i64.const -2) (call $$dummy) |
| 54 |
(call $$dummy) (call $$dummy) (i32.const -3) (call $$dummy) |
| 55 |
) |
| 56 |
) |
| 57 |
(drop) (drop) |
| 58 |
) |
| 59 |
|
| 60 |
(func (export "nested") (param i32 i32) (result i32) |
| 61 |
(if (result i32) (local.get 0) |
| 62 |
(then |
| 63 |
(if (local.get 1) (then (call $$dummy) (block) (nop))) |
| 64 |
(if (local.get 1) (then) (else (call $$dummy) (block) (nop))) |
| 65 |
(if (result i32) (local.get 1) |
| 66 |
(then (call $$dummy) (i32.const 9)) |
| 67 |
(else (call $$dummy) (i32.const 10)) |
| 68 |
) |
| 69 |
) |
| 70 |
(else |
| 71 |
(if (local.get 1) (then (call $$dummy) (block) (nop))) |
| 72 |
(if (local.get 1) (then) (else (call $$dummy) (block) (nop))) |
| 73 |
(if (result i32) (local.get 1) |
| 74 |
(then (call $$dummy) (i32.const 10)) |
| 75 |
(else (call $$dummy) (i32.const 11)) |
| 76 |
) |
| 77 |
) |
| 78 |
) |
| 79 |
) |
| 80 |
|
| 81 |
(func (export "as-select-first") (param i32) (result i32) |
| 82 |
(select |
| 83 |
(if (result i32) (local.get 0) |
| 84 |
(then (call $$dummy) (i32.const 1)) |
| 85 |
(else (call $$dummy) (i32.const 0)) |
| 86 |
) |
| 87 |
(i32.const 2) (i32.const 3) |
| 88 |
) |
| 89 |
) |
| 90 |
(func (export "as-select-mid") (param i32) (result i32) |
| 91 |
(select |
| 92 |
(i32.const 2) |
| 93 |
(if (result i32) (local.get 0) |
| 94 |
(then (call $$dummy) (i32.const 1)) |
| 95 |
(else (call $$dummy) (i32.const 0)) |
| 96 |
) |
| 97 |
(i32.const 3) |
| 98 |
) |
| 99 |
) |
| 100 |
(func (export "as-select-last") (param i32) (result i32) |
| 101 |
(select |
| 102 |
(i32.const 2) (i32.const 3) |
| 103 |
(if (result i32) (local.get 0) |
| 104 |
(then (call $$dummy) (i32.const 1)) |
| 105 |
(else (call $$dummy) (i32.const 0)) |
| 106 |
) |
| 107 |
) |
| 108 |
) |
| 109 |
|
| 110 |
(func (export "as-loop-first") (param i32) (result i32) |
| 111 |
(loop (result i32) |
| 112 |
(if (result i32) (local.get 0) |
| 113 |
(then (call $$dummy) (i32.const 1)) |
| 114 |
(else (call $$dummy) (i32.const 0)) |
| 115 |
) |
| 116 |
(call $$dummy) (call $$dummy) |
| 117 |
) |
| 118 |
) |
| 119 |
(func (export "as-loop-mid") (param i32) (result i32) |
| 120 |
(loop (result i32) |
| 121 |
(call $$dummy) |
| 122 |
(if (result i32) (local.get 0) |
| 123 |
(then (call $$dummy) (i32.const 1)) |
| 124 |
(else (call $$dummy) (i32.const 0)) |
| 125 |
) |
| 126 |
(call $$dummy) |
| 127 |
) |
| 128 |
) |
| 129 |
(func (export "as-loop-last") (param i32) (result i32) |
| 130 |
(loop (result i32) |
| 131 |
(call $$dummy) (call $$dummy) |
| 132 |
(if (result i32) (local.get 0) |
| 133 |
(then (call $$dummy) (i32.const 1)) |
| 134 |
(else (call $$dummy) (i32.const 0)) |
| 135 |
) |
| 136 |
) |
| 137 |
) |
| 138 |
|
| 139 |
(func (export "as-if-condition") (param i32) (result i32) |
| 140 |
(if (result i32) |
| 141 |
(if (result i32) (local.get 0) |
| 142 |
(then (i32.const 1)) (else (i32.const 0)) |
| 143 |
) |
| 144 |
(then (call $$dummy) (i32.const 2)) |
| 145 |
(else (call $$dummy) (i32.const 3)) |
| 146 |
) |
| 147 |
) |
| 148 |
|
| 149 |
(func (export "as-br_if-first") (param i32) (result i32) |
| 150 |
(block (result i32) |
| 151 |
(br_if 0 |
| 152 |
(if (result i32) (local.get 0) |
| 153 |
(then (call $$dummy) (i32.const 1)) |
| 154 |
(else (call $$dummy) (i32.const 0)) |
| 155 |
) |
| 156 |
(i32.const 2) |
| 157 |
) |
| 158 |
(return (i32.const 3)) |
| 159 |
) |
| 160 |
) |
| 161 |
(func (export "as-br_if-last") (param i32) (result i32) |
| 162 |
(block (result i32) |
| 163 |
(br_if 0 |
| 164 |
(i32.const 2) |
| 165 |
(if (result i32) (local.get 0) |
| 166 |
(then (call $$dummy) (i32.const 1)) |
| 167 |
(else (call $$dummy) (i32.const 0)) |
| 168 |
) |
| 169 |
) |
| 170 |
(return (i32.const 3)) |
| 171 |
) |
| 172 |
) |
| 173 |
|
| 174 |
(func (export "as-br_table-first") (param i32) (result i32) |
| 175 |
(block (result i32) |
| 176 |
(if (result i32) (local.get 0) |
| 177 |
(then (call $$dummy) (i32.const 1)) |
| 178 |
(else (call $$dummy) (i32.const 0)) |
| 179 |
) |
| 180 |
(i32.const 2) |
| 181 |
(br_table 0 0) |
| 182 |
) |
| 183 |
) |
| 184 |
(func (export "as-br_table-last") (param i32) (result i32) |
| 185 |
(block (result i32) |
| 186 |
(i32.const 2) |
| 187 |
(if (result i32) (local.get 0) |
| 188 |
(then (call $$dummy) (i32.const 1)) |
| 189 |
(else (call $$dummy) (i32.const 0)) |
| 190 |
) |
| 191 |
(br_table 0 0) |
| 192 |
) |
| 193 |
) |
| 194 |
|
| 195 |
(func $$func (param i32 i32) (result i32) (local.get 0)) |
| 196 |
(type $$check (func (param i32 i32) (result i32))) |
| 197 |
(table funcref (elem $$func)) |
| 198 |
(func (export "as-call_indirect-first") (param i32) (result i32) |
| 199 |
(block (result i32) |
| 200 |
(call_indirect (type $$check) |
| 201 |
(if (result i32) (local.get 0) |
| 202 |
(then (call $$dummy) (i32.const 1)) |
| 203 |
(else (call $$dummy) (i32.const 0)) |
| 204 |
) |
| 205 |
(i32.const 2) (i32.const 0) |
| 206 |
) |
| 207 |
) |
| 208 |
) |
| 209 |
(func (export "as-call_indirect-mid") (param i32) (result i32) |
| 210 |
(block (result i32) |
| 211 |
(call_indirect (type $$check) |
| 212 |
(i32.const 2) |
| 213 |
(if (result i32) (local.get 0) |
| 214 |
(then (call $$dummy) (i32.const 1)) |
| 215 |
(else (call $$dummy) (i32.const 0)) |
| 216 |
) |
| 217 |
(i32.const 0) |
| 218 |
) |
| 219 |
) |
| 220 |
) |
| 221 |
(func (export "as-call_indirect-last") (param i32) (result i32) |
| 222 |
(block (result i32) |
| 223 |
(call_indirect (type $$check) |
| 224 |
(i32.const 2) (i32.const 0) |
| 225 |
(if (result i32) (local.get 0) |
| 226 |
(then (call $$dummy) (i32.const 1)) |
| 227 |
(else (call $$dummy) (i32.const 0)) |
| 228 |
) |
| 229 |
) |
| 230 |
) |
| 231 |
) |
| 232 |
|
| 233 |
(func (export "as-store-first") (param i32) |
| 234 |
(if (result i32) (local.get 0) |
| 235 |
(then (call $$dummy) (i32.const 1)) |
| 236 |
(else (call $$dummy) (i32.const 0)) |
| 237 |
) |
| 238 |
(i32.const 2) |
| 239 |
(i32.store) |
| 240 |
) |
| 241 |
(func (export "as-store-last") (param i32) |
| 242 |
(i32.const 2) |
| 243 |
(if (result i32) (local.get 0) |
| 244 |
(then (call $$dummy) (i32.const 1)) |
| 245 |
(else (call $$dummy) (i32.const 0)) |
| 246 |
) |
| 247 |
(i32.store) |
| 248 |
) |
| 249 |
|
| 250 |
(func (export "as-memory.grow-value") (param i32) (result i32) |
| 251 |
(memory.grow |
| 252 |
(if (result i32) (local.get 0) |
| 253 |
(then (i32.const 1)) |
| 254 |
(else (i32.const 0)) |
| 255 |
) |
| 256 |
) |
| 257 |
) |
| 258 |
|
| 259 |
(func $$f (param i32) (result i32) (local.get 0)) |
| 260 |
|
| 261 |
(func (export "as-call-value") (param i32) (result i32) |
| 262 |
(call $$f |
| 263 |
(if (result i32) (local.get 0) |
| 264 |
(then (i32.const 1)) |
| 265 |
(else (i32.const 0)) |
| 266 |
) |
| 267 |
) |
| 268 |
) |
| 269 |
(func (export "as-return-value") (param i32) (result i32) |
| 270 |
(if (result i32) (local.get 0) |
| 271 |
(then (i32.const 1)) |
| 272 |
(else (i32.const 0))) |
| 273 |
(return) |
| 274 |
) |
| 275 |
(func (export "as-drop-operand") (param i32) |
| 276 |
(drop |
| 277 |
(if (result i32) (local.get 0) |
| 278 |
(then (i32.const 1)) |
| 279 |
(else (i32.const 0)) |
| 280 |
) |
| 281 |
) |
| 282 |
) |
| 283 |
(func (export "as-br-value") (param i32) (result i32) |
| 284 |
(block (result i32) |
| 285 |
(br 0 |
| 286 |
(if (result i32) (local.get 0) |
| 287 |
(then (i32.const 1)) |
| 288 |
(else (i32.const 0)) |
| 289 |
) |
| 290 |
) |
| 291 |
) |
| 292 |
) |
| 293 |
(func (export "as-local.set-value") (param i32) (result i32) |
| 294 |
(local i32) |
| 295 |
(local.set 0 |
| 296 |
(if (result i32) (local.get 0) |
| 297 |
(then (i32.const 1)) |
| 298 |
(else (i32.const 0)) |
| 299 |
) |
| 300 |
) |
| 301 |
(local.get 0) |
| 302 |
) |
| 303 |
(func (export "as-local.tee-value") (param i32) (result i32) |
| 304 |
(local.tee 0 |
| 305 |
(if (result i32) (local.get 0) |
| 306 |
(then (i32.const 1)) |
| 307 |
(else (i32.const 0)) |
| 308 |
) |
| 309 |
) |
| 310 |
) |
| 311 |
(global $$a (mut i32) (i32.const 10)) |
| 312 |
(func (export "as-global.set-value") (param i32) (result i32) |
| 313 |
(global.set $$a |
| 314 |
(if (result i32) (local.get 0) |
| 315 |
(then (i32.const 1)) |
| 316 |
(else (i32.const 0)) |
| 317 |
) |
| 318 |
) (global.get $$a) |
| 319 |
) |
| 320 |
(func (export "as-load-operand") (param i32) (result i32) |
| 321 |
(i32.load |
| 322 |
(if (result i32) (local.get 0) |
| 323 |
(then (i32.const 11)) |
| 324 |
(else (i32.const 10)) |
| 325 |
) |
| 326 |
) |
| 327 |
) |
| 328 |
|
| 329 |
(func (export "as-unary-operand") (param i32) (result i32) |
| 330 |
(i32.ctz |
| 331 |
(if (result i32) (local.get 0) |
| 332 |
(then (call $$dummy) (i32.const 13)) |
| 333 |
(else (call $$dummy) (i32.const -13)) |
| 334 |
) |
| 335 |
) |
| 336 |
) |
| 337 |
(func (export "as-binary-operand") (param i32 i32) (result i32) |
| 338 |
(i32.mul |
| 339 |
(if (result i32) (local.get 0) |
| 340 |
(then (call $$dummy) (i32.const 3)) |
| 341 |
(else (call $$dummy) (i32.const -3)) |
| 342 |
) |
| 343 |
(if (result i32) (local.get 1) |
| 344 |
(then (call $$dummy) (i32.const 4)) |
| 345 |
(else (call $$dummy) (i32.const -5)) |
| 346 |
) |
| 347 |
) |
| 348 |
) |
| 349 |
(func (export "as-test-operand") (param i32) (result i32) |
| 350 |
(i32.eqz |
| 351 |
(if (result i32) (local.get 0) |
| 352 |
(then (call $$dummy) (i32.const 13)) |
| 353 |
(else (call $$dummy) (i32.const 0)) |
| 354 |
) |
| 355 |
) |
| 356 |
) |
| 357 |
(func (export "as-compare-operand") (param i32 i32) (result i32) |
| 358 |
(f32.gt |
| 359 |
(if (result f32) (local.get 0) |
| 360 |
(then (call $$dummy) (f32.const 3)) |
| 361 |
(else (call $$dummy) (f32.const -3)) |
| 362 |
) |
| 363 |
(if (result f32) (local.get 1) |
| 364 |
(then (call $$dummy) (f32.const 4)) |
| 365 |
(else (call $$dummy) (f32.const -4)) |
| 366 |
) |
| 367 |
) |
| 368 |
) |
| 369 |
(func (export "as-binary-operands") (param i32) (result i32) |
| 370 |
(i32.mul |
| 371 |
(if (result i32 i32) (local.get 0) |
| 372 |
(then (call $$dummy) (i32.const 3) (call $$dummy) (i32.const 4)) |
| 373 |
(else (call $$dummy) (i32.const 3) (call $$dummy) (i32.const -4)) |
| 374 |
) |
| 375 |
) |
| 376 |
) |
| 377 |
(func (export "as-compare-operands") (param i32) (result i32) |
| 378 |
(f32.gt |
| 379 |
(if (result f32 f32) (local.get 0) |
| 380 |
(then (call $$dummy) (f32.const 3) (call $$dummy) (f32.const 3)) |
| 381 |
(else (call $$dummy) (f32.const -2) (call $$dummy) (f32.const -3)) |
| 382 |
) |
| 383 |
) |
| 384 |
) |
| 385 |
(func (export "as-mixed-operands") (param i32) (result i32) |
| 386 |
(if (result i32 i32) (local.get 0) |
| 387 |
(then (call $$dummy) (i32.const 3) (call $$dummy) (i32.const 4)) |
| 388 |
(else (call $$dummy) (i32.const -3) (call $$dummy) (i32.const -4)) |
| 389 |
) |
| 390 |
(i32.const 5) |
| 391 |
(i32.add) |
| 392 |
(i32.mul) |
| 393 |
) |
| 394 |
|
| 395 |
(func (export "break-bare") (result i32) |
| 396 |
(if (i32.const 1) (then (br 0) (unreachable))) |
| 397 |
(if (i32.const 1) (then (br 0) (unreachable)) (else (unreachable))) |
| 398 |
(if (i32.const 0) (then (unreachable)) (else (br 0) (unreachable))) |
| 399 |
(if (i32.const 1) (then (br_if 0 (i32.const 1)) (unreachable))) |
| 400 |
(if (i32.const 1) (then (br_if 0 (i32.const 1)) (unreachable)) (else (unreachable))) |
| 401 |
(if (i32.const 0) (then (unreachable)) (else (br_if 0 (i32.const 1)) (unreachable))) |
| 402 |
(if (i32.const 1) (then (br_table 0 (i32.const 0)) (unreachable))) |
| 403 |
(if (i32.const 1) (then (br_table 0 (i32.const 0)) (unreachable)) (else (unreachable))) |
| 404 |
(if (i32.const 0) (then (unreachable)) (else (br_table 0 (i32.const 0)) (unreachable))) |
| 405 |
(i32.const 19) |
| 406 |
) |
| 407 |
|
| 408 |
(func (export "break-value") (param i32) (result i32) |
| 409 |
(if (result i32) (local.get 0) |
| 410 |
(then (br 0 (i32.const 18)) (i32.const 19)) |
| 411 |
(else (br 0 (i32.const 21)) (i32.const 20)) |
| 412 |
) |
| 413 |
) |
| 414 |
(func (export "break-multi-value") (param i32) (result i32 i32 i64) |
| 415 |
(if (result i32 i32 i64) (local.get 0) |
| 416 |
(then |
| 417 |
(br 0 (i32.const 18) (i32.const -18) (i64.const 18)) |
| 418 |
(i32.const 19) (i32.const -19) (i64.const 19) |
| 419 |
) |
| 420 |
(else |
| 421 |
(br 0 (i32.const -18) (i32.const 18) (i64.const -18)) |
| 422 |
(i32.const -19) (i32.const 19) (i64.const -19) |
| 423 |
) |
| 424 |
) |
| 425 |
) |
| 426 |
|
| 427 |
(func (export "param") (param i32) (result i32) |
| 428 |
(i32.const 1) |
| 429 |
(if (param i32) (result i32) (local.get 0) |
| 430 |
(then (i32.const 2) (i32.add)) |
| 431 |
(else (i32.const -2) (i32.add)) |
| 432 |
) |
| 433 |
) |
| 434 |
(func (export "params") (param i32) (result i32) |
| 435 |
(i32.const 1) |
| 436 |
(i32.const 2) |
| 437 |
(if (param i32 i32) (result i32) (local.get 0) |
| 438 |
(then (i32.add)) |
| 439 |
(else (i32.sub)) |
| 440 |
) |
| 441 |
) |
| 442 |
(func (export "params-id") (param i32) (result i32) |
| 443 |
(i32.const 1) |
| 444 |
(i32.const 2) |
| 445 |
(if (param i32 i32) (result i32 i32) (local.get 0) (then)) |
| 446 |
(i32.add) |
| 447 |
) |
| 448 |
(func (export "param-break") (param i32) (result i32) |
| 449 |
(i32.const 1) |
| 450 |
(if (param i32) (result i32) (local.get 0) |
| 451 |
(then (i32.const 2) (i32.add) (br 0)) |
| 452 |
(else (i32.const -2) (i32.add) (br 0)) |
| 453 |
) |
| 454 |
) |
| 455 |
(func (export "params-break") (param i32) (result i32) |
| 456 |
(i32.const 1) |
| 457 |
(i32.const 2) |
| 458 |
(if (param i32 i32) (result i32) (local.get 0) |
| 459 |
(then (i32.add) (br 0)) |
| 460 |
(else (i32.sub) (br 0)) |
| 461 |
) |
| 462 |
) |
| 463 |
(func (export "params-id-break") (param i32) (result i32) |
| 464 |
(i32.const 1) |
| 465 |
(i32.const 2) |
| 466 |
(if (param i32 i32) (result i32 i32) (local.get 0) (then (br 0))) |
| 467 |
(i32.add) |
| 468 |
) |
| 469 |
|
| 470 |
(func (export "effects") (param i32) (result i32) |
| 471 |
(local i32) |
| 472 |
(if |
| 473 |
(block (result i32) (local.set 1 (i32.const 1)) (local.get 0)) |
| 474 |
(then |
| 475 |
(local.set 1 (i32.mul (local.get 1) (i32.const 3))) |
| 476 |
(local.set 1 (i32.sub (local.get 1) (i32.const 5))) |
| 477 |
(local.set 1 (i32.mul (local.get 1) (i32.const 7))) |
| 478 |
(br 0) |
| 479 |
(local.set 1 (i32.mul (local.get 1) (i32.const 100))) |
| 480 |
) |
| 481 |
(else |
| 482 |
(local.set 1 (i32.mul (local.get 1) (i32.const 5))) |
| 483 |
(local.set 1 (i32.sub (local.get 1) (i32.const 7))) |
| 484 |
(local.set 1 (i32.mul (local.get 1) (i32.const 3))) |
| 485 |
(br 0) |
| 486 |
(local.set 1 (i32.mul (local.get 1) (i32.const 1000))) |
| 487 |
) |
| 488 |
) |
| 489 |
(local.get 1) |
| 490 |
) |
| 491 |
|
| 492 |
;; Examples |
| 493 |
|
| 494 |
(func $$add64_u_with_carry (export "add64_u_with_carry") |
| 495 |
(param $$i i64) (param $$j i64) (param $$c i32) (result i64 i32) |
| 496 |
(local $$k i64) |
| 497 |
(local.set $$k |
| 498 |
(i64.add |
| 499 |
(i64.add (local.get $$i) (local.get $$j)) |
| 500 |
(i64.extend_i32_u (local.get $$c)) |
| 501 |
) |
| 502 |
) |
| 503 |
(return (local.get $$k) (i64.lt_u (local.get $$k) (local.get $$i))) |
| 504 |
) |
| 505 |
|
| 506 |
(func $$add64_u_saturated (export "add64_u_saturated") |
| 507 |
(param i64 i64) (result i64) |
| 508 |
(call $$add64_u_with_carry (local.get 0) (local.get 1) (i32.const 0)) |
| 509 |
(if (param i64) (result i64) |
| 510 |
(then (drop) (i64.const -1)) |
| 511 |
) |
| 512 |
) |
| 513 |
|
| 514 |
;; Block signature syntax |
| 515 |
|
| 516 |
(type $$block-sig-1 (func)) |
| 517 |
(type $$block-sig-2 (func (result i32))) |
| 518 |
(type $$block-sig-3 (func (param $$x i32))) |
| 519 |
(type $$block-sig-4 (func (param i32 f64 i32) (result i32 f64 i32))) |
| 520 |
|
| 521 |
(func (export "type-use") |
| 522 |
(if (type $$block-sig-1) (i32.const 1) (then)) |
| 523 |
(if (type $$block-sig-2) (i32.const 1) |
| 524 |
(then (i32.const 0)) (else (i32.const 2)) |
| 525 |
) |
| 526 |
(if (type $$block-sig-3) (i32.const 1) (then (drop)) (else (drop))) |
| 527 |
(i32.const 0) (f64.const 0) (i32.const 0) |
| 528 |
(if (type $$block-sig-4) (i32.const 1) (then)) |
| 529 |
(drop) (drop) (drop) |
| 530 |
(if (type $$block-sig-2) (result i32) (i32.const 1) |
| 531 |
(then (i32.const 0)) (else (i32.const 2)) |
| 532 |
) |
| 533 |
(if (type $$block-sig-3) (param i32) (i32.const 1) |
| 534 |
(then (drop)) (else (drop)) |
| 535 |
) |
| 536 |
(i32.const 0) (f64.const 0) (i32.const 0) |
| 537 |
(if (type $$block-sig-4) |
| 538 |
(param i32) (param f64 i32) (result i32 f64) (result i32) |
| 539 |
(i32.const 1) (then) |
| 540 |
) |
| 541 |
(drop) (drop) (drop) |
| 542 |
) |
| 543 |
)`); |
| 544 |
|
| 545 |
// ./test/core/if.wast:529 |
| 546 |
assert_return(() => invoke($0, `empty`, [0]), []); |
| 547 |
|
| 548 |
// ./test/core/if.wast:530 |
| 549 |
assert_return(() => invoke($0, `empty`, [1]), []); |
| 550 |
|
| 551 |
// ./test/core/if.wast:531 |
| 552 |
assert_return(() => invoke($0, `empty`, [100]), []); |
| 553 |
|
| 554 |
// ./test/core/if.wast:532 |
| 555 |
assert_return(() => invoke($0, `empty`, [-2]), []); |
| 556 |
|
| 557 |
// ./test/core/if.wast:534 |
| 558 |
assert_return(() => invoke($0, `singular`, [0]), [value("i32", 8)]); |
| 559 |
|
| 560 |
// ./test/core/if.wast:535 |
| 561 |
assert_return(() => invoke($0, `singular`, [1]), [value("i32", 7)]); |
| 562 |
|
| 563 |
// ./test/core/if.wast:536 |
| 564 |
assert_return(() => invoke($0, `singular`, [10]), [value("i32", 7)]); |
| 565 |
|
| 566 |
// ./test/core/if.wast:537 |
| 567 |
assert_return(() => invoke($0, `singular`, [-10]), [value("i32", 7)]); |
| 568 |
|
| 569 |
// ./test/core/if.wast:539 |
| 570 |
assert_return(() => invoke($0, `multi`, [0]), [value("i32", 9), value("i32", -1)]); |
| 571 |
|
| 572 |
// ./test/core/if.wast:540 |
| 573 |
assert_return(() => invoke($0, `multi`, [1]), [value("i32", 8), value("i32", 1)]); |
| 574 |
|
| 575 |
// ./test/core/if.wast:541 |
| 576 |
assert_return(() => invoke($0, `multi`, [13]), [value("i32", 8), value("i32", 1)]); |
| 577 |
|
| 578 |
// ./test/core/if.wast:542 |
| 579 |
assert_return(() => invoke($0, `multi`, [-5]), [value("i32", 8), value("i32", 1)]); |
| 580 |
|
| 581 |
// ./test/core/if.wast:544 |
| 582 |
assert_return(() => invoke($0, `nested`, [0, 0]), [value("i32", 11)]); |
| 583 |
|
| 584 |
// ./test/core/if.wast:545 |
| 585 |
assert_return(() => invoke($0, `nested`, [1, 0]), [value("i32", 10)]); |
| 586 |
|
| 587 |
// ./test/core/if.wast:546 |
| 588 |
assert_return(() => invoke($0, `nested`, [0, 1]), [value("i32", 10)]); |
| 589 |
|
| 590 |
// ./test/core/if.wast:547 |
| 591 |
assert_return(() => invoke($0, `nested`, [3, 2]), [value("i32", 9)]); |
| 592 |
|
| 593 |
// ./test/core/if.wast:548 |
| 594 |
assert_return(() => invoke($0, `nested`, [0, -100]), [value("i32", 10)]); |
| 595 |
|
| 596 |
// ./test/core/if.wast:549 |
| 597 |
assert_return(() => invoke($0, `nested`, [10, 10]), [value("i32", 9)]); |
| 598 |
|
| 599 |
// ./test/core/if.wast:550 |
| 600 |
assert_return(() => invoke($0, `nested`, [0, -1]), [value("i32", 10)]); |
| 601 |
|
| 602 |
// ./test/core/if.wast:551 |
| 603 |
assert_return(() => invoke($0, `nested`, [-111, -2]), [value("i32", 9)]); |
| 604 |
|
| 605 |
// ./test/core/if.wast:553 |
| 606 |
assert_return(() => invoke($0, `as-select-first`, [0]), [value("i32", 0)]); |
| 607 |
|
| 608 |
// ./test/core/if.wast:554 |
| 609 |
assert_return(() => invoke($0, `as-select-first`, [1]), [value("i32", 1)]); |
| 610 |
|
| 611 |
// ./test/core/if.wast:555 |
| 612 |
assert_return(() => invoke($0, `as-select-mid`, [0]), [value("i32", 2)]); |
| 613 |
|
| 614 |
// ./test/core/if.wast:556 |
| 615 |
assert_return(() => invoke($0, `as-select-mid`, [1]), [value("i32", 2)]); |
| 616 |
|
| 617 |
// ./test/core/if.wast:557 |
| 618 |
assert_return(() => invoke($0, `as-select-last`, [0]), [value("i32", 3)]); |
| 619 |
|
| 620 |
// ./test/core/if.wast:558 |
| 621 |
assert_return(() => invoke($0, `as-select-last`, [1]), [value("i32", 2)]); |
| 622 |
|
| 623 |
// ./test/core/if.wast:560 |
| 624 |
assert_return(() => invoke($0, `as-loop-first`, [0]), [value("i32", 0)]); |
| 625 |
|
| 626 |
// ./test/core/if.wast:561 |
| 627 |
assert_return(() => invoke($0, `as-loop-first`, [1]), [value("i32", 1)]); |
| 628 |
|
| 629 |
// ./test/core/if.wast:562 |
| 630 |
assert_return(() => invoke($0, `as-loop-mid`, [0]), [value("i32", 0)]); |
| 631 |
|
| 632 |
// ./test/core/if.wast:563 |
| 633 |
assert_return(() => invoke($0, `as-loop-mid`, [1]), [value("i32", 1)]); |
| 634 |
|
| 635 |
// ./test/core/if.wast:564 |
| 636 |
assert_return(() => invoke($0, `as-loop-last`, [0]), [value("i32", 0)]); |
| 637 |
|
| 638 |
// ./test/core/if.wast:565 |
| 639 |
assert_return(() => invoke($0, `as-loop-last`, [1]), [value("i32", 1)]); |
| 640 |
|
| 641 |
// ./test/core/if.wast:567 |
| 642 |
assert_return(() => invoke($0, `as-if-condition`, [0]), [value("i32", 3)]); |
| 643 |
|
| 644 |
// ./test/core/if.wast:568 |
| 645 |
assert_return(() => invoke($0, `as-if-condition`, [1]), [value("i32", 2)]); |
| 646 |
|
| 647 |
// ./test/core/if.wast:570 |
| 648 |
assert_return(() => invoke($0, `as-br_if-first`, [0]), [value("i32", 0)]); |
| 649 |
|
| 650 |
// ./test/core/if.wast:571 |
| 651 |
assert_return(() => invoke($0, `as-br_if-first`, [1]), [value("i32", 1)]); |
| 652 |
|
| 653 |
// ./test/core/if.wast:572 |
| 654 |
assert_return(() => invoke($0, `as-br_if-last`, [0]), [value("i32", 3)]); |
| 655 |
|
| 656 |
// ./test/core/if.wast:573 |
| 657 |
assert_return(() => invoke($0, `as-br_if-last`, [1]), [value("i32", 2)]); |
| 658 |
|
| 659 |
// ./test/core/if.wast:575 |
| 660 |
assert_return(() => invoke($0, `as-br_table-first`, [0]), [value("i32", 0)]); |
| 661 |
|
| 662 |
// ./test/core/if.wast:576 |
| 663 |
assert_return(() => invoke($0, `as-br_table-first`, [1]), [value("i32", 1)]); |
| 664 |
|
| 665 |
// ./test/core/if.wast:577 |
| 666 |
assert_return(() => invoke($0, `as-br_table-last`, [0]), [value("i32", 2)]); |
| 667 |
|
| 668 |
// ./test/core/if.wast:578 |
| 669 |
assert_return(() => invoke($0, `as-br_table-last`, [1]), [value("i32", 2)]); |
| 670 |
|
| 671 |
// ./test/core/if.wast:580 |
| 672 |
assert_return(() => invoke($0, `as-call_indirect-first`, [0]), [value("i32", 0)]); |
| 673 |
|
| 674 |
// ./test/core/if.wast:581 |
| 675 |
assert_return(() => invoke($0, `as-call_indirect-first`, [1]), [value("i32", 1)]); |
| 676 |
|
| 677 |
// ./test/core/if.wast:582 |
| 678 |
assert_return(() => invoke($0, `as-call_indirect-mid`, [0]), [value("i32", 2)]); |
| 679 |
|
| 680 |
// ./test/core/if.wast:583 |
| 681 |
assert_return(() => invoke($0, `as-call_indirect-mid`, [1]), [value("i32", 2)]); |
| 682 |
|
| 683 |
// ./test/core/if.wast:584 |
| 684 |
assert_return(() => invoke($0, `as-call_indirect-last`, [0]), [value("i32", 2)]); |
| 685 |
|
| 686 |
// ./test/core/if.wast:585 |
| 687 |
assert_trap(() => invoke($0, `as-call_indirect-last`, [1]), `undefined element`); |
| 688 |
|
| 689 |
// ./test/core/if.wast:587 |
| 690 |
assert_return(() => invoke($0, `as-store-first`, [0]), []); |
| 691 |
|
| 692 |
// ./test/core/if.wast:588 |
| 693 |
assert_return(() => invoke($0, `as-store-first`, [1]), []); |
| 694 |
|
| 695 |
// ./test/core/if.wast:589 |
| 696 |
assert_return(() => invoke($0, `as-store-last`, [0]), []); |
| 697 |
|
| 698 |
// ./test/core/if.wast:590 |
| 699 |
assert_return(() => invoke($0, `as-store-last`, [1]), []); |
| 700 |
|
| 701 |
// ./test/core/if.wast:592 |
| 702 |
assert_return(() => invoke($0, `as-memory.grow-value`, [0]), [value("i32", 1)]); |
| 703 |
|
| 704 |
// ./test/core/if.wast:593 |
| 705 |
assert_return(() => invoke($0, `as-memory.grow-value`, [1]), [value("i32", 1)]); |
| 706 |
|
| 707 |
// ./test/core/if.wast:595 |
| 708 |
assert_return(() => invoke($0, `as-call-value`, [0]), [value("i32", 0)]); |
| 709 |
|
| 710 |
// ./test/core/if.wast:596 |
| 711 |
assert_return(() => invoke($0, `as-call-value`, [1]), [value("i32", 1)]); |
| 712 |
|
| 713 |
// ./test/core/if.wast:598 |
| 714 |
assert_return(() => invoke($0, `as-return-value`, [0]), [value("i32", 0)]); |
| 715 |
|
| 716 |
// ./test/core/if.wast:599 |
| 717 |
assert_return(() => invoke($0, `as-return-value`, [1]), [value("i32", 1)]); |
| 718 |
|
| 719 |
// ./test/core/if.wast:601 |
| 720 |
assert_return(() => invoke($0, `as-drop-operand`, [0]), []); |
| 721 |
|
| 722 |
// ./test/core/if.wast:602 |
| 723 |
assert_return(() => invoke($0, `as-drop-operand`, [1]), []); |
| 724 |
|
| 725 |
// ./test/core/if.wast:604 |
| 726 |
assert_return(() => invoke($0, `as-br-value`, [0]), [value("i32", 0)]); |
| 727 |
|
| 728 |
// ./test/core/if.wast:605 |
| 729 |
assert_return(() => invoke($0, `as-br-value`, [1]), [value("i32", 1)]); |
| 730 |
|
| 731 |
// ./test/core/if.wast:607 |
| 732 |
assert_return(() => invoke($0, `as-local.set-value`, [0]), [value("i32", 0)]); |
| 733 |
|
| 734 |
// ./test/core/if.wast:608 |
| 735 |
assert_return(() => invoke($0, `as-local.set-value`, [1]), [value("i32", 1)]); |
| 736 |
|
| 737 |
// ./test/core/if.wast:610 |
| 738 |
assert_return(() => invoke($0, `as-local.tee-value`, [0]), [value("i32", 0)]); |
| 739 |
|
| 740 |
// ./test/core/if.wast:611 |
| 741 |
assert_return(() => invoke($0, `as-local.tee-value`, [1]), [value("i32", 1)]); |
| 742 |
|
| 743 |
// ./test/core/if.wast:613 |
| 744 |
assert_return(() => invoke($0, `as-global.set-value`, [0]), [value("i32", 0)]); |
| 745 |
|
| 746 |
// ./test/core/if.wast:614 |
| 747 |
assert_return(() => invoke($0, `as-global.set-value`, [1]), [value("i32", 1)]); |
| 748 |
|
| 749 |
// ./test/core/if.wast:616 |
| 750 |
assert_return(() => invoke($0, `as-load-operand`, [0]), [value("i32", 0)]); |
| 751 |
|
| 752 |
// ./test/core/if.wast:617 |
| 753 |
assert_return(() => invoke($0, `as-load-operand`, [1]), [value("i32", 0)]); |
| 754 |
|
| 755 |
// ./test/core/if.wast:619 |
| 756 |
assert_return(() => invoke($0, `as-unary-operand`, [0]), [value("i32", 0)]); |
| 757 |
|
| 758 |
// ./test/core/if.wast:620 |
| 759 |
assert_return(() => invoke($0, `as-unary-operand`, [1]), [value("i32", 0)]); |
| 760 |
|
| 761 |
// ./test/core/if.wast:621 |
| 762 |
assert_return(() => invoke($0, `as-unary-operand`, [-1]), [value("i32", 0)]); |
| 763 |
|
| 764 |
// ./test/core/if.wast:623 |
| 765 |
assert_return(() => invoke($0, `as-binary-operand`, [0, 0]), [value("i32", 15)]); |
| 766 |
|
| 767 |
// ./test/core/if.wast:624 |
| 768 |
assert_return(() => invoke($0, `as-binary-operand`, [0, 1]), [value("i32", -12)]); |
| 769 |
|
| 770 |
// ./test/core/if.wast:625 |
| 771 |
assert_return(() => invoke($0, `as-binary-operand`, [1, 0]), [value("i32", -15)]); |
| 772 |
|
| 773 |
// ./test/core/if.wast:626 |
| 774 |
assert_return(() => invoke($0, `as-binary-operand`, [1, 1]), [value("i32", 12)]); |
| 775 |
|
| 776 |
// ./test/core/if.wast:628 |
| 777 |
assert_return(() => invoke($0, `as-test-operand`, [0]), [value("i32", 1)]); |
| 778 |
|
| 779 |
// ./test/core/if.wast:629 |
| 780 |
assert_return(() => invoke($0, `as-test-operand`, [1]), [value("i32", 0)]); |
| 781 |
|
| 782 |
// ./test/core/if.wast:631 |
| 783 |
assert_return(() => invoke($0, `as-compare-operand`, [0, 0]), [value("i32", 1)]); |
| 784 |
|
| 785 |
// ./test/core/if.wast:632 |
| 786 |
assert_return(() => invoke($0, `as-compare-operand`, [0, 1]), [value("i32", 0)]); |
| 787 |
|
| 788 |
// ./test/core/if.wast:633 |
| 789 |
assert_return(() => invoke($0, `as-compare-operand`, [1, 0]), [value("i32", 1)]); |
| 790 |
|
| 791 |
// ./test/core/if.wast:634 |
| 792 |
assert_return(() => invoke($0, `as-compare-operand`, [1, 1]), [value("i32", 0)]); |
| 793 |
|
| 794 |
// ./test/core/if.wast:636 |
| 795 |
assert_return(() => invoke($0, `as-binary-operands`, [0]), [value("i32", -12)]); |
| 796 |
|
| 797 |
// ./test/core/if.wast:637 |
| 798 |
assert_return(() => invoke($0, `as-binary-operands`, [1]), [value("i32", 12)]); |
| 799 |
|
| 800 |
// ./test/core/if.wast:639 |
| 801 |
assert_return(() => invoke($0, `as-compare-operands`, [0]), [value("i32", 1)]); |
| 802 |
|
| 803 |
// ./test/core/if.wast:640 |
| 804 |
assert_return(() => invoke($0, `as-compare-operands`, [1]), [value("i32", 0)]); |
| 805 |
|
| 806 |
// ./test/core/if.wast:642 |
| 807 |
assert_return(() => invoke($0, `as-mixed-operands`, [0]), [value("i32", -3)]); |
| 808 |
|
| 809 |
// ./test/core/if.wast:643 |
| 810 |
assert_return(() => invoke($0, `as-mixed-operands`, [1]), [value("i32", 27)]); |
| 811 |
|
| 812 |
// ./test/core/if.wast:645 |
| 813 |
assert_return(() => invoke($0, `break-bare`, []), [value("i32", 19)]); |
| 814 |
|
| 815 |
// ./test/core/if.wast:646 |
| 816 |
assert_return(() => invoke($0, `break-value`, [1]), [value("i32", 18)]); |
| 817 |
|
| 818 |
// ./test/core/if.wast:647 |
| 819 |
assert_return(() => invoke($0, `break-value`, [0]), [value("i32", 21)]); |
| 820 |
|
| 821 |
// ./test/core/if.wast:648 |
| 822 |
assert_return( |
| 823 |
() => invoke($0, `break-multi-value`, [0]), |
| 824 |
[value("i32", -18), value("i32", 18), value("i64", -18n)], |
| 825 |
); |
| 826 |
|
| 827 |
// ./test/core/if.wast:651 |
| 828 |
assert_return( |
| 829 |
() => invoke($0, `break-multi-value`, [1]), |
| 830 |
[value("i32", 18), value("i32", -18), value("i64", 18n)], |
| 831 |
); |
| 832 |
|
| 833 |
// ./test/core/if.wast:655 |
| 834 |
assert_return(() => invoke($0, `param`, [0]), [value("i32", -1)]); |
| 835 |
|
| 836 |
// ./test/core/if.wast:656 |
| 837 |
assert_return(() => invoke($0, `param`, [1]), [value("i32", 3)]); |
| 838 |
|
| 839 |
// ./test/core/if.wast:657 |
| 840 |
assert_return(() => invoke($0, `params`, [0]), [value("i32", -1)]); |
| 841 |
|
| 842 |
// ./test/core/if.wast:658 |
| 843 |
assert_return(() => invoke($0, `params`, [1]), [value("i32", 3)]); |
| 844 |
|
| 845 |
// ./test/core/if.wast:659 |
| 846 |
assert_return(() => invoke($0, `params-id`, [0]), [value("i32", 3)]); |
| 847 |
|
| 848 |
// ./test/core/if.wast:660 |
| 849 |
assert_return(() => invoke($0, `params-id`, [1]), [value("i32", 3)]); |
| 850 |
|
| 851 |
// ./test/core/if.wast:661 |
| 852 |
assert_return(() => invoke($0, `param-break`, [0]), [value("i32", -1)]); |
| 853 |
|
| 854 |
// ./test/core/if.wast:662 |
| 855 |
assert_return(() => invoke($0, `param-break`, [1]), [value("i32", 3)]); |
| 856 |
|
| 857 |
// ./test/core/if.wast:663 |
| 858 |
assert_return(() => invoke($0, `params-break`, [0]), [value("i32", -1)]); |
| 859 |
|
| 860 |
// ./test/core/if.wast:664 |
| 861 |
assert_return(() => invoke($0, `params-break`, [1]), [value("i32", 3)]); |
| 862 |
|
| 863 |
// ./test/core/if.wast:665 |
| 864 |
assert_return(() => invoke($0, `params-id-break`, [0]), [value("i32", 3)]); |
| 865 |
|
| 866 |
// ./test/core/if.wast:666 |
| 867 |
assert_return(() => invoke($0, `params-id-break`, [1]), [value("i32", 3)]); |
| 868 |
|
| 869 |
// ./test/core/if.wast:668 |
| 870 |
assert_return(() => invoke($0, `effects`, [1]), [value("i32", -14)]); |
| 871 |
|
| 872 |
// ./test/core/if.wast:669 |
| 873 |
assert_return(() => invoke($0, `effects`, [0]), [value("i32", -6)]); |
| 874 |
|
| 875 |
// ./test/core/if.wast:671 |
| 876 |
assert_return(() => invoke($0, `add64_u_with_carry`, [0n, 0n, 0]), [value("i64", 0n), value("i32", 0)]); |
| 877 |
|
| 878 |
// ./test/core/if.wast:675 |
| 879 |
assert_return( |
| 880 |
() => invoke($0, `add64_u_with_carry`, [100n, 124n, 0]), |
| 881 |
[value("i64", 224n), value("i32", 0)], |
| 882 |
); |
| 883 |
|
| 884 |
// ./test/core/if.wast:679 |
| 885 |
assert_return( |
| 886 |
() => invoke($0, `add64_u_with_carry`, [-1n, 0n, 0]), |
| 887 |
[value("i64", -1n), value("i32", 0)], |
| 888 |
); |
| 889 |
|
| 890 |
// ./test/core/if.wast:683 |
| 891 |
assert_return(() => invoke($0, `add64_u_with_carry`, [-1n, 1n, 0]), [value("i64", 0n), value("i32", 1)]); |
| 892 |
|
| 893 |
// ./test/core/if.wast:687 |
| 894 |
assert_return( |
| 895 |
() => invoke($0, `add64_u_with_carry`, [-1n, -1n, 0]), |
| 896 |
[value("i64", -2n), value("i32", 1)], |
| 897 |
); |
| 898 |
|
| 899 |
// ./test/core/if.wast:691 |
| 900 |
assert_return(() => invoke($0, `add64_u_with_carry`, [-1n, 0n, 1]), [value("i64", 0n), value("i32", 1)]); |
| 901 |
|
| 902 |
// ./test/core/if.wast:695 |
| 903 |
assert_return(() => invoke($0, `add64_u_with_carry`, [-1n, 1n, 1]), [value("i64", 1n), value("i32", 1)]); |
| 904 |
|
| 905 |
// ./test/core/if.wast:699 |
| 906 |
assert_return( |
| 907 |
() => invoke($0, `add64_u_with_carry`, [ |
| 908 |
-9223372036854775808n, |
| 909 |
-9223372036854775808n, |
| 910 |
0, |
| 911 |
]), |
| 912 |
[value("i64", 0n), value("i32", 1)], |
| 913 |
); |
| 914 |
|
| 915 |
// ./test/core/if.wast:704 |
| 916 |
assert_return(() => invoke($0, `add64_u_saturated`, [0n, 0n]), [value("i64", 0n)]); |
| 917 |
|
| 918 |
// ./test/core/if.wast:707 |
| 919 |
assert_return(() => invoke($0, `add64_u_saturated`, [1230n, 23n]), [value("i64", 1253n)]); |
| 920 |
|
| 921 |
// ./test/core/if.wast:710 |
| 922 |
assert_return(() => invoke($0, `add64_u_saturated`, [-1n, 0n]), [value("i64", -1n)]); |
| 923 |
|
| 924 |
// ./test/core/if.wast:713 |
| 925 |
assert_return(() => invoke($0, `add64_u_saturated`, [-1n, 1n]), [value("i64", -1n)]); |
| 926 |
|
| 927 |
// ./test/core/if.wast:716 |
| 928 |
assert_return(() => invoke($0, `add64_u_saturated`, [-1n, -1n]), [value("i64", -1n)]); |
| 929 |
|
| 930 |
// ./test/core/if.wast:719 |
| 931 |
assert_return( |
| 932 |
() => invoke($0, `add64_u_saturated`, [-9223372036854775808n, -9223372036854775808n]), |
| 933 |
[value("i64", -1n)], |
| 934 |
); |
| 935 |
|
| 936 |
// ./test/core/if.wast:723 |
| 937 |
assert_return(() => invoke($0, `type-use`, []), []); |
| 938 |
|
| 939 |
// ./test/core/if.wast:725 |
| 940 |
assert_malformed( |
| 941 |
() => instantiate(`(type $$sig (func (param i32) (result i32))) (func (i32.const 0) (if (type $$sig) (result i32) (param i32) (i32.const 1) (then)) ) `), |
| 942 |
`unexpected token`, |
| 943 |
); |
| 944 |
|
| 945 |
// ./test/core/if.wast:734 |
| 946 |
assert_malformed( |
| 947 |
() => instantiate(`(type $$sig (func (param i32) (result i32))) (func (i32.const 0) (if (param i32) (type $$sig) (result i32) (i32.const 1) (then)) ) `), |
| 948 |
`unexpected token`, |
| 949 |
); |
| 950 |
|
| 951 |
// ./test/core/if.wast:743 |
| 952 |
assert_malformed( |
| 953 |
() => instantiate(`(type $$sig (func (param i32) (result i32))) (func (i32.const 0) (if (param i32) (result i32) (type $$sig) (i32.const 1) (then)) ) `), |
| 954 |
`unexpected token`, |
| 955 |
); |
| 956 |
|
| 957 |
// ./test/core/if.wast:752 |
| 958 |
assert_malformed( |
| 959 |
() => instantiate(`(type $$sig (func (param i32) (result i32))) (func (i32.const 0) (if (result i32) (type $$sig) (param i32) (i32.const 1) (then)) ) `), |
| 960 |
`unexpected token`, |
| 961 |
); |
| 962 |
|
| 963 |
// ./test/core/if.wast:761 |
| 964 |
assert_malformed( |
| 965 |
() => instantiate(`(type $$sig (func (param i32) (result i32))) (func (i32.const 0) (if (result i32) (param i32) (type $$sig) (i32.const 1) (then)) ) `), |
| 966 |
`unexpected token`, |
| 967 |
); |
| 968 |
|
| 969 |
// ./test/core/if.wast:770 |
| 970 |
assert_malformed( |
| 971 |
() => instantiate(`(func (i32.const 0) (if (result i32) (param i32) (i32.const 1) (then))) `), |
| 972 |
`unexpected token`, |
| 973 |
); |
| 974 |
|
| 975 |
// ./test/core/if.wast:777 |
| 976 |
assert_malformed( |
| 977 |
() => instantiate(`(func (i32.const 0) (i32.const 1) (if (param $$x i32) (then (drop)) (else (drop))) ) `), |
| 978 |
`unexpected token`, |
| 979 |
); |
| 980 |
|
| 981 |
// ./test/core/if.wast:785 |
| 982 |
assert_malformed( |
| 983 |
() => instantiate(`(type $$sig (func)) (func (i32.const 1) (if (type $$sig) (result i32) (then (i32.const 0)) (else (i32.const 2))) (unreachable) ) `), |
| 984 |
`inline function type`, |
| 985 |
); |
| 986 |
|
| 987 |
// ./test/core/if.wast:795 |
| 988 |
assert_malformed( |
| 989 |
() => instantiate(`(type $$sig (func (param i32) (result i32))) (func (i32.const 1) (if (type $$sig) (result i32) (then (i32.const 0)) (else (i32.const 2))) (unreachable) ) `), |
| 990 |
`inline function type`, |
| 991 |
); |
| 992 |
|
| 993 |
// ./test/core/if.wast:805 |
| 994 |
assert_malformed( |
| 995 |
() => instantiate(`(type $$sig (func (param i32) (result i32))) (func (i32.const 0) (i32.const 1) (if (type $$sig) (param i32) (then (drop)) (else (drop))) (unreachable) ) `), |
| 996 |
`inline function type`, |
| 997 |
); |
| 998 |
|
| 999 |
// ./test/core/if.wast:815 |
| 1000 |
assert_malformed( |
| 1001 |
() => instantiate(`(type $$sig (func (param i32 i32) (result i32))) (func (i32.const 0) (i32.const 1) (if (type $$sig) (param i32) (result i32) (then)) (unreachable) ) `), |
| 1002 |
`inline function type`, |
| 1003 |
); |
| 1004 |
|
| 1005 |
// ./test/core/if.wast:825 |
| 1006 |
assert_invalid( |
| 1007 |
() => instantiate(`(module |
| 1008 |
(type $$sig (func)) |
| 1009 |
(func (i32.const 1) (if (type $$sig) (i32.const 0) (then))) |
| 1010 |
)`), |
| 1011 |
`type mismatch`, |
| 1012 |
); |
| 1013 |
|
| 1014 |
// ./test/core/if.wast:833 |
| 1015 |
assert_invalid( |
| 1016 |
() => instantiate(`(module (func $$type-empty-i32 (result i32) (if (i32.const 0) (then))))`), |
| 1017 |
`type mismatch`, |
| 1018 |
); |
| 1019 |
|
| 1020 |
// ./test/core/if.wast:837 |
| 1021 |
assert_invalid( |
| 1022 |
() => instantiate(`(module (func $$type-empty-i64 (result i64) (if (i32.const 0) (then))))`), |
| 1023 |
`type mismatch`, |
| 1024 |
); |
| 1025 |
|
| 1026 |
// ./test/core/if.wast:841 |
| 1027 |
assert_invalid( |
| 1028 |
() => instantiate(`(module (func $$type-empty-f32 (result f32) (if (i32.const 0) (then))))`), |
| 1029 |
`type mismatch`, |
| 1030 |
); |
| 1031 |
|
| 1032 |
// ./test/core/if.wast:845 |
| 1033 |
assert_invalid( |
| 1034 |
() => instantiate(`(module (func $$type-empty-f64 (result f64) (if (i32.const 0) (then))))`), |
| 1035 |
`type mismatch`, |
| 1036 |
); |
| 1037 |
|
| 1038 |
// ./test/core/if.wast:850 |
| 1039 |
assert_invalid( |
| 1040 |
() => instantiate(`(module (func $$type-empty-i32 (result i32) (if (i32.const 0) (then) (else))))`), |
| 1041 |
`type mismatch`, |
| 1042 |
); |
| 1043 |
|
| 1044 |
// ./test/core/if.wast:854 |
| 1045 |
assert_invalid( |
| 1046 |
() => instantiate(`(module (func $$type-empty-i64 (result i64) (if (i32.const 0) (then) (else))))`), |
| 1047 |
`type mismatch`, |
| 1048 |
); |
| 1049 |
|
| 1050 |
// ./test/core/if.wast:858 |
| 1051 |
assert_invalid( |
| 1052 |
() => instantiate(`(module (func $$type-empty-f32 (result f32) (if (i32.const 0) (then) (else))))`), |
| 1053 |
`type mismatch`, |
| 1054 |
); |
| 1055 |
|
| 1056 |
// ./test/core/if.wast:862 |
| 1057 |
assert_invalid( |
| 1058 |
() => instantiate(`(module (func $$type-empty-f64 (result f64) (if (i32.const 0) (then) (else))))`), |
| 1059 |
`type mismatch`, |
| 1060 |
); |
| 1061 |
|
| 1062 |
// ./test/core/if.wast:867 |
| 1063 |
assert_invalid( |
| 1064 |
() => instantiate(`(module (func $$type-then-value-num-vs-void |
| 1065 |
(if (i32.const 1) (then (i32.const 1))) |
| 1066 |
))`), |
| 1067 |
`type mismatch`, |
| 1068 |
); |
| 1069 |
|
| 1070 |
// ./test/core/if.wast:873 |
| 1071 |
assert_invalid( |
| 1072 |
() => instantiate(`(module (func $$type-then-value-num-vs-void-else |
| 1073 |
(if (i32.const 1) (then (i32.const 1)) (else)) |
| 1074 |
))`), |
| 1075 |
`type mismatch`, |
| 1076 |
); |
| 1077 |
|
| 1078 |
// ./test/core/if.wast:879 |
| 1079 |
assert_invalid( |
| 1080 |
() => instantiate(`(module (func $$type-else-value-num-vs-void |
| 1081 |
(if (i32.const 1) (then) (else (i32.const 1))) |
| 1082 |
))`), |
| 1083 |
`type mismatch`, |
| 1084 |
); |
| 1085 |
|
| 1086 |
// ./test/core/if.wast:885 |
| 1087 |
assert_invalid( |
| 1088 |
() => instantiate(`(module (func $$type-both-value-num-vs-void |
| 1089 |
(if (i32.const 1) (then (i32.const 1)) (else (i32.const 1))) |
| 1090 |
))`), |
| 1091 |
`type mismatch`, |
| 1092 |
); |
| 1093 |
|
| 1094 |
// ./test/core/if.wast:892 |
| 1095 |
assert_invalid( |
| 1096 |
() => instantiate(`(module (func $$type-then-value-nums-vs-void |
| 1097 |
(if (i32.const 1) (then (i32.const 1) (i32.const 2))) |
| 1098 |
))`), |
| 1099 |
`type mismatch`, |
| 1100 |
); |
| 1101 |
|
| 1102 |
// ./test/core/if.wast:898 |
| 1103 |
assert_invalid( |
| 1104 |
() => instantiate(`(module (func $$type-then-value-nums-vs-void-else |
| 1105 |
(if (i32.const 1) (then (i32.const 1) (i32.const 2)) (else)) |
| 1106 |
))`), |
| 1107 |
`type mismatch`, |
| 1108 |
); |
| 1109 |
|
| 1110 |
// ./test/core/if.wast:904 |
| 1111 |
assert_invalid( |
| 1112 |
() => instantiate(`(module (func $$type-else-value-nums-vs-void |
| 1113 |
(if (i32.const 1) (then) (else (i32.const 1) (i32.const 2))) |
| 1114 |
))`), |
| 1115 |
`type mismatch`, |
| 1116 |
); |
| 1117 |
|
| 1118 |
// ./test/core/if.wast:910 |
| 1119 |
assert_invalid( |
| 1120 |
() => instantiate(`(module (func $$type-both-value-nums-vs-void |
| 1121 |
(if (i32.const 1) (then (i32.const 1) (i32.const 2)) (else (i32.const 2) (i32.const 1))) |
| 1122 |
))`), |
| 1123 |
`type mismatch`, |
| 1124 |
); |
| 1125 |
|
| 1126 |
// ./test/core/if.wast:917 |
| 1127 |
assert_invalid( |
| 1128 |
() => instantiate(`(module (func $$type-then-value-empty-vs-num (result i32) |
| 1129 |
(if (result i32) (i32.const 1) (then) (else (i32.const 0))) |
| 1130 |
))`), |
| 1131 |
`type mismatch`, |
| 1132 |
); |
| 1133 |
|
| 1134 |
// ./test/core/if.wast:923 |
| 1135 |
assert_invalid( |
| 1136 |
() => instantiate(`(module (func $$type-else-value-empty-vs-num (result i32) |
| 1137 |
(if (result i32) (i32.const 1) (then (i32.const 0)) (else)) |
| 1138 |
))`), |
| 1139 |
`type mismatch`, |
| 1140 |
); |
| 1141 |
|
| 1142 |
// ./test/core/if.wast:929 |
| 1143 |
assert_invalid( |
| 1144 |
() => instantiate(`(module (func $$type-both-value-empty-vs-num (result i32) |
| 1145 |
(if (result i32) (i32.const 1) (then) (else)) |
| 1146 |
))`), |
| 1147 |
`type mismatch`, |
| 1148 |
); |
| 1149 |
|
| 1150 |
// ./test/core/if.wast:936 |
| 1151 |
assert_invalid( |
| 1152 |
() => instantiate(`(module (func $$type-then-value-empty-vs-nums (result i32 i32) |
| 1153 |
(if (result i32 i32) (i32.const 1) (then) (else (i32.const 0) (i32.const 2))) |
| 1154 |
))`), |
| 1155 |
`type mismatch`, |
| 1156 |
); |
| 1157 |
|
| 1158 |
// ./test/core/if.wast:942 |
| 1159 |
assert_invalid( |
| 1160 |
() => instantiate(`(module (func $$type-else-value-empty-vs-nums (result i32 i32) |
| 1161 |
(if (result i32 i32) (i32.const 1) (then (i32.const 0) (i32.const 1)) (else)) |
| 1162 |
))`), |
| 1163 |
`type mismatch`, |
| 1164 |
); |
| 1165 |
|
| 1166 |
// ./test/core/if.wast:948 |
| 1167 |
assert_invalid( |
| 1168 |
() => instantiate(`(module (func $$type-both-value-empty-vs-nums (result i32 i32) |
| 1169 |
(if (result i32 i32) (i32.const 1) (then) (else)) |
| 1170 |
))`), |
| 1171 |
`type mismatch`, |
| 1172 |
); |
| 1173 |
|
| 1174 |
// ./test/core/if.wast:955 |
| 1175 |
assert_invalid( |
| 1176 |
() => instantiate(`(module (func $$type-no-else-vs-num (result i32) |
| 1177 |
(if (result i32) (i32.const 1) (then (i32.const 1))) |
| 1178 |
))`), |
| 1179 |
`type mismatch`, |
| 1180 |
); |
| 1181 |
|
| 1182 |
// ./test/core/if.wast:961 |
| 1183 |
assert_invalid( |
| 1184 |
() => instantiate(`(module (func $$type-no-else-vs-nums (result i32 i32) |
| 1185 |
(if (result i32 i32) (i32.const 1) (then (i32.const 1) (i32.const 1))) |
| 1186 |
))`), |
| 1187 |
`type mismatch`, |
| 1188 |
); |
| 1189 |
|
| 1190 |
// ./test/core/if.wast:968 |
| 1191 |
assert_invalid( |
| 1192 |
() => instantiate(`(module (func $$type-then-value-void-vs-num (result i32) |
| 1193 |
(if (result i32) (i32.const 1) (then (nop)) (else (i32.const 0))) |
| 1194 |
))`), |
| 1195 |
`type mismatch`, |
| 1196 |
); |
| 1197 |
|
| 1198 |
// ./test/core/if.wast:974 |
| 1199 |
assert_invalid( |
| 1200 |
() => instantiate(`(module (func $$type-else-value-void-vs-num (result i32) |
| 1201 |
(if (result i32) (i32.const 1) (then (i32.const 0)) (else (nop))) |
| 1202 |
))`), |
| 1203 |
`type mismatch`, |
| 1204 |
); |
| 1205 |
|
| 1206 |
// ./test/core/if.wast:980 |
| 1207 |
assert_invalid( |
| 1208 |
() => instantiate(`(module (func $$type-both-value-void-vs-num (result i32) |
| 1209 |
(if (result i32) (i32.const 1) (then (nop)) (else (nop))) |
| 1210 |
))`), |
| 1211 |
`type mismatch`, |
| 1212 |
); |
| 1213 |
|
| 1214 |
// ./test/core/if.wast:987 |
| 1215 |
assert_invalid( |
| 1216 |
() => instantiate(`(module (func $$type-then-value-void-vs-nums (result i32 i32) |
| 1217 |
(if (result i32 i32) (i32.const 1) (then (nop)) (else (i32.const 0) (i32.const 0))) |
| 1218 |
))`), |
| 1219 |
`type mismatch`, |
| 1220 |
); |
| 1221 |
|
| 1222 |
// ./test/core/if.wast:993 |
| 1223 |
assert_invalid( |
| 1224 |
() => instantiate(`(module (func $$type-else-value-void-vs-nums (result i32 i32) |
| 1225 |
(if (result i32 i32) (i32.const 1) (then (i32.const 0) (i32.const 0)) (else (nop))) |
| 1226 |
))`), |
| 1227 |
`type mismatch`, |
| 1228 |
); |
| 1229 |
|
| 1230 |
// ./test/core/if.wast:999 |
| 1231 |
assert_invalid( |
| 1232 |
() => instantiate(`(module (func $$type-both-value-void-vs-nums (result i32 i32) |
| 1233 |
(if (result i32 i32) (i32.const 1) (then (nop)) (else (nop))) |
| 1234 |
))`), |
| 1235 |
`type mismatch`, |
| 1236 |
); |
| 1237 |
|
| 1238 |
// ./test/core/if.wast:1006 |
| 1239 |
assert_invalid( |
| 1240 |
() => instantiate(`(module (func $$type-then-value-num-vs-num (result i32) |
| 1241 |
(if (result i32) (i32.const 1) (then (i64.const 1)) (else (i32.const 1))) |
| 1242 |
))`), |
| 1243 |
`type mismatch`, |
| 1244 |
); |
| 1245 |
|
| 1246 |
// ./test/core/if.wast:1012 |
| 1247 |
assert_invalid( |
| 1248 |
() => instantiate(`(module (func $$type-else-value-num-vs-num (result i32) |
| 1249 |
(if (result i32) (i32.const 1) (then (i32.const 1)) (else (i64.const 1))) |
| 1250 |
))`), |
| 1251 |
`type mismatch`, |
| 1252 |
); |
| 1253 |
|
| 1254 |
// ./test/core/if.wast:1018 |
| 1255 |
assert_invalid( |
| 1256 |
() => instantiate(`(module (func $$type-both-value-num-vs-num (result i32) |
| 1257 |
(if (result i32) (i32.const 1) (then (i64.const 1)) (else (i64.const 1))) |
| 1258 |
))`), |
| 1259 |
`type mismatch`, |
| 1260 |
); |
| 1261 |
|
| 1262 |
// ./test/core/if.wast:1025 |
| 1263 |
assert_invalid( |
| 1264 |
() => instantiate(`(module (func $$type-then-value-num-vs-nums (result i32 i32) |
| 1265 |
(if (result i32 i32) (i32.const 1) (then (i32.const 1)) (else (i32.const 1) (i32.const 1))) |
| 1266 |
))`), |
| 1267 |
`type mismatch`, |
| 1268 |
); |
| 1269 |
|
| 1270 |
// ./test/core/if.wast:1031 |
| 1271 |
assert_invalid( |
| 1272 |
() => instantiate(`(module (func $$type-else-value-num-vs-nums (result i32 i32) |
| 1273 |
(if (result i32 i32) (i32.const 1) (then (i32.const 1) (i32.const 1)) (else (i32.const 1))) |
| 1274 |
))`), |
| 1275 |
`type mismatch`, |
| 1276 |
); |
| 1277 |
|
| 1278 |
// ./test/core/if.wast:1037 |
| 1279 |
assert_invalid( |
| 1280 |
() => instantiate(`(module (func $$type-both-value-num-vs-nums (result i32 i32) |
| 1281 |
(if (result i32 i32) (i32.const 1) (then (i32.const 1)) (else (i32.const 1))) |
| 1282 |
))`), |
| 1283 |
`type mismatch`, |
| 1284 |
); |
| 1285 |
|
| 1286 |
// ./test/core/if.wast:1044 |
| 1287 |
assert_invalid( |
| 1288 |
() => instantiate(`(module (func $$type-then-value-partial-vs-nums (result i32 i32) |
| 1289 |
(i32.const 0) |
| 1290 |
(if (result i32 i32) (i32.const 1) (then (i32.const 1)) (else (i32.const 1) (i32.const 1))) |
| 1291 |
))`), |
| 1292 |
`type mismatch`, |
| 1293 |
); |
| 1294 |
|
| 1295 |
// ./test/core/if.wast:1051 |
| 1296 |
assert_invalid( |
| 1297 |
() => instantiate(`(module (func $$type-else-value-partial-vs-nums (result i32 i32) |
| 1298 |
(i32.const 0) |
| 1299 |
(if (result i32 i32) (i32.const 1) (then (i32.const 1) (i32.const 1)) (else (i32.const 1))) |
| 1300 |
))`), |
| 1301 |
`type mismatch`, |
| 1302 |
); |
| 1303 |
|
| 1304 |
// ./test/core/if.wast:1058 |
| 1305 |
assert_invalid( |
| 1306 |
() => instantiate(`(module (func $$type-both-value-partial-vs-nums (result i32 i32) |
| 1307 |
(i32.const 0) |
| 1308 |
(if (result i32 i32) (i32.const 1) (then (i32.const 1)) (else (i32.const 1))) |
| 1309 |
))`), |
| 1310 |
`type mismatch`, |
| 1311 |
); |
| 1312 |
|
| 1313 |
// ./test/core/if.wast:1066 |
| 1314 |
assert_invalid( |
| 1315 |
() => instantiate(`(module (func $$type-then-value-nums-vs-num (result i32) |
| 1316 |
(if (result i32) (i32.const 1) (then (i32.const 1) (i32.const 1)) (else (i32.const 1))) |
| 1317 |
))`), |
| 1318 |
`type mismatch`, |
| 1319 |
); |
| 1320 |
|
| 1321 |
// ./test/core/if.wast:1072 |
| 1322 |
assert_invalid( |
| 1323 |
() => instantiate(`(module (func $$type-else-value-nums-vs-num (result i32) |
| 1324 |
(if (result i32) (i32.const 1) (then (i32.const 1)) (else (i32.const 1) (i32.const 1))) |
| 1325 |
))`), |
| 1326 |
`type mismatch`, |
| 1327 |
); |
| 1328 |
|
| 1329 |
// ./test/core/if.wast:1078 |
| 1330 |
assert_invalid( |
| 1331 |
() => instantiate(`(module (func $$type-both-value-nums-vs-num (result i32) |
| 1332 |
(if (result i32) (i32.const 1) (then (i32.const 1) (i32.const 1)) (else (i32.const 1) (i32.const 1))) |
| 1333 |
))`), |
| 1334 |
`type mismatch`, |
| 1335 |
); |
| 1336 |
|
| 1337 |
// ./test/core/if.wast:1085 |
| 1338 |
assert_invalid( |
| 1339 |
() => instantiate(`(module (func $$type-both-different-value-num-vs-num (result i32) |
| 1340 |
(if (result i32) (i32.const 1) (then (i64.const 1)) (else (f64.const 1))) |
| 1341 |
))`), |
| 1342 |
`type mismatch`, |
| 1343 |
); |
| 1344 |
|
| 1345 |
// ./test/core/if.wast:1091 |
| 1346 |
assert_invalid( |
| 1347 |
() => instantiate(`(module (func $$type-both-different-value-nums-vs-nums (result i32 i32) |
| 1348 |
(if (result i32 i32) (i32.const 1) (then (i32.const 1) (i32.const 1) (i32.const 1)) (else (i32.const 1))) |
| 1349 |
))`), |
| 1350 |
`type mismatch`, |
| 1351 |
); |
| 1352 |
|
| 1353 |
// ./test/core/if.wast:1098 |
| 1354 |
assert_invalid( |
| 1355 |
() => instantiate(`(module (func $$type-then-value-unreached-select (result i32) |
| 1356 |
(if (result i64) |
| 1357 |
(i32.const 0) |
| 1358 |
(then (select (unreachable) (unreachable) (unreachable))) |
| 1359 |
(else (i64.const 0)) |
| 1360 |
) |
| 1361 |
))`), |
| 1362 |
`type mismatch`, |
| 1363 |
); |
| 1364 |
|
| 1365 |
// ./test/core/if.wast:1108 |
| 1366 |
assert_invalid( |
| 1367 |
() => instantiate(`(module (func $$type-else-value-unreached-select (result i32) |
| 1368 |
(if (result i64) |
| 1369 |
(i32.const 1) |
| 1370 |
(then (i64.const 0)) |
| 1371 |
(else (select (unreachable) (unreachable) (unreachable))) |
| 1372 |
) |
| 1373 |
))`), |
| 1374 |
`type mismatch`, |
| 1375 |
); |
| 1376 |
|
| 1377 |
// ./test/core/if.wast:1118 |
| 1378 |
assert_invalid( |
| 1379 |
() => instantiate(`(module (func $$type-else-value-unreached-select (result i32) |
| 1380 |
(if (result i64) |
| 1381 |
(i32.const 1) |
| 1382 |
(then (select (unreachable) (unreachable) (unreachable))) |
| 1383 |
(else (select (unreachable) (unreachable) (unreachable))) |
| 1384 |
) |
| 1385 |
))`), |
| 1386 |
`type mismatch`, |
| 1387 |
); |
| 1388 |
|
| 1389 |
// ./test/core/if.wast:1129 |
| 1390 |
assert_invalid( |
| 1391 |
() => instantiate(`(module (func $$type-then-break-last-void-vs-num (result i32) |
| 1392 |
(if (result i32) (i32.const 1) (then (br 0)) (else (i32.const 1))) |
| 1393 |
))`), |
| 1394 |
`type mismatch`, |
| 1395 |
); |
| 1396 |
|
| 1397 |
// ./test/core/if.wast:1135 |
| 1398 |
assert_invalid( |
| 1399 |
() => instantiate(`(module (func $$type-else-break-last-void-vs-num (result i32) |
| 1400 |
(if (result i32) (i32.const 1) (then (i32.const 1)) (else (br 0))) |
| 1401 |
))`), |
| 1402 |
`type mismatch`, |
| 1403 |
); |
| 1404 |
|
| 1405 |
// ./test/core/if.wast:1141 |
| 1406 |
assert_invalid( |
| 1407 |
() => instantiate(`(module (func $$type-then-break-last-void-vs-nums (result i32 i32) |
| 1408 |
(if (result i32 i32) (i32.const 1) (then (br 0)) (else (i32.const 1) (i32.const 1))) |
| 1409 |
))`), |
| 1410 |
`type mismatch`, |
| 1411 |
); |
| 1412 |
|
| 1413 |
// ./test/core/if.wast:1147 |
| 1414 |
assert_invalid( |
| 1415 |
() => instantiate(`(module (func $$type-else-break-last-void-vs-nums (result i32 i32) |
| 1416 |
(if (result i32 i32) (i32.const 1) (then (i32.const 1) (i32.const 1)) (else (br 0))) |
| 1417 |
))`), |
| 1418 |
`type mismatch`, |
| 1419 |
); |
| 1420 |
|
| 1421 |
// ./test/core/if.wast:1154 |
| 1422 |
assert_invalid( |
| 1423 |
() => instantiate(`(module (func $$type-then-break-empty-vs-num (result i32) |
| 1424 |
(if (result i32) (i32.const 1) |
| 1425 |
(then (br 0) (i32.const 1)) |
| 1426 |
(else (i32.const 1)) |
| 1427 |
) |
| 1428 |
))`), |
| 1429 |
`type mismatch`, |
| 1430 |
); |
| 1431 |
|
| 1432 |
// ./test/core/if.wast:1163 |
| 1433 |
assert_invalid( |
| 1434 |
() => instantiate(`(module (func $$type-else-break-empty-vs-num (result i32) |
| 1435 |
(if (result i32) (i32.const 1) |
| 1436 |
(then (i32.const 1)) |
| 1437 |
(else (br 0) (i32.const 1)) |
| 1438 |
) |
| 1439 |
))`), |
| 1440 |
`type mismatch`, |
| 1441 |
); |
| 1442 |
|
| 1443 |
// ./test/core/if.wast:1172 |
| 1444 |
assert_invalid( |
| 1445 |
() => instantiate(`(module (func $$type-then-break-empty-vs-nums (result i32 i32) |
| 1446 |
(if (result i32 i32) (i32.const 1) |
| 1447 |
(then (br 0) (i32.const 1) (i32.const 1)) |
| 1448 |
(else (i32.const 1) (i32.const 1)) |
| 1449 |
) |
| 1450 |
))`), |
| 1451 |
`type mismatch`, |
| 1452 |
); |
| 1453 |
|
| 1454 |
// ./test/core/if.wast:1181 |
| 1455 |
assert_invalid( |
| 1456 |
() => instantiate(`(module (func $$type-else-break-empty-vs-nums (result i32 i32) |
| 1457 |
(if (result i32 i32) (i32.const 1) |
| 1458 |
(then (i32.const 1) (i32.const 1)) |
| 1459 |
(else (br 0) (i32.const 1) (i32.const 1)) |
| 1460 |
) |
| 1461 |
))`), |
| 1462 |
`type mismatch`, |
| 1463 |
); |
| 1464 |
|
| 1465 |
// ./test/core/if.wast:1191 |
| 1466 |
assert_invalid( |
| 1467 |
() => instantiate(`(module (func $$type-then-break-void-vs-num (result i32) |
| 1468 |
(if (result i32) (i32.const 1) |
| 1469 |
(then (br 0 (nop)) (i32.const 1)) |
| 1470 |
(else (i32.const 1)) |
| 1471 |
) |
| 1472 |
))`), |
| 1473 |
`type mismatch`, |
| 1474 |
); |
| 1475 |
|
| 1476 |
// ./test/core/if.wast:1200 |
| 1477 |
assert_invalid( |
| 1478 |
() => instantiate(`(module (func $$type-else-break-void-vs-num (result i32) |
| 1479 |
(if (result i32) (i32.const 1) |
| 1480 |
(then (i32.const 1)) |
| 1481 |
(else (br 0 (nop)) (i32.const 1)) |
| 1482 |
) |
| 1483 |
))`), |
| 1484 |
`type mismatch`, |
| 1485 |
); |
| 1486 |
|
| 1487 |
// ./test/core/if.wast:1209 |
| 1488 |
assert_invalid( |
| 1489 |
() => instantiate(`(module (func $$type-then-break-void-vs-nums (result i32 i32) |
| 1490 |
(if (result i32 i32) (i32.const 1) |
| 1491 |
(then (br 0 (nop)) (i32.const 1) (i32.const 1)) |
| 1492 |
(else (i32.const 1) (i32.const 1)) |
| 1493 |
) |
| 1494 |
))`), |
| 1495 |
`type mismatch`, |
| 1496 |
); |
| 1497 |
|
| 1498 |
// ./test/core/if.wast:1218 |
| 1499 |
assert_invalid( |
| 1500 |
() => instantiate(`(module (func $$type-else-break-void-vs-nums (result i32 i32) |
| 1501 |
(if (result i32 i32) (i32.const 1) |
| 1502 |
(then (i32.const 1) (i32.const 1)) |
| 1503 |
(else (br 0 (nop)) (i32.const 1) (i32.const 1)) |
| 1504 |
) |
| 1505 |
))`), |
| 1506 |
`type mismatch`, |
| 1507 |
); |
| 1508 |
|
| 1509 |
// ./test/core/if.wast:1228 |
| 1510 |
assert_invalid( |
| 1511 |
() => instantiate(`(module (func $$type-then-break-num-vs-num (result i32) |
| 1512 |
(if (result i32) (i32.const 1) |
| 1513 |
(then (br 0 (i64.const 1)) (i32.const 1)) |
| 1514 |
(else (i32.const 1)) |
| 1515 |
) |
| 1516 |
))`), |
| 1517 |
`type mismatch`, |
| 1518 |
); |
| 1519 |
|
| 1520 |
// ./test/core/if.wast:1237 |
| 1521 |
assert_invalid( |
| 1522 |
() => instantiate(`(module (func $$type-else-break-num-vs-num (result i32) |
| 1523 |
(if (result i32) (i32.const 1) |
| 1524 |
(then (i32.const 1)) |
| 1525 |
(else (br 0 (i64.const 1)) (i32.const 1)) |
| 1526 |
) |
| 1527 |
))`), |
| 1528 |
`type mismatch`, |
| 1529 |
); |
| 1530 |
|
| 1531 |
// ./test/core/if.wast:1246 |
| 1532 |
assert_invalid( |
| 1533 |
() => instantiate(`(module (func $$type-then-break-num-vs-nums (result i32 i32) |
| 1534 |
(if (result i32 i32) (i32.const 1) |
| 1535 |
(then (br 0 (i64.const 1)) (i32.const 1) (i32.const 1)) |
| 1536 |
(else (i32.const 1) (i32.const 1)) |
| 1537 |
) |
| 1538 |
))`), |
| 1539 |
`type mismatch`, |
| 1540 |
); |
| 1541 |
|
| 1542 |
// ./test/core/if.wast:1255 |
| 1543 |
assert_invalid( |
| 1544 |
() => instantiate(`(module (func $$type-else-break-num-vs-nums (result i32 i32) |
| 1545 |
(if (result i32 i32) (i32.const 1) |
| 1546 |
(then (i32.const 1) (i32.const 1)) |
| 1547 |
(else (br 0 (i64.const 1)) (i32.const 1) (i32.const 1)) |
| 1548 |
) |
| 1549 |
))`), |
| 1550 |
`type mismatch`, |
| 1551 |
); |
| 1552 |
|
| 1553 |
// ./test/core/if.wast:1264 |
| 1554 |
assert_invalid( |
| 1555 |
() => instantiate(`(module (func $$type-then-break-partial-vs-nums (result i32 i32) |
| 1556 |
(i32.const 1) |
| 1557 |
(if (result i32 i32) (i32.const 1) |
| 1558 |
(then (br 0 (i64.const 1)) (i32.const 1)) |
| 1559 |
(else (i32.const 1)) |
| 1560 |
) |
| 1561 |
))`), |
| 1562 |
`type mismatch`, |
| 1563 |
); |
| 1564 |
|
| 1565 |
// ./test/core/if.wast:1274 |
| 1566 |
assert_invalid( |
| 1567 |
() => instantiate(`(module (func $$type-else-break-partial-vs-nums (result i32 i32) |
| 1568 |
(i32.const 1) |
| 1569 |
(if (result i32 i32) (i32.const 1) |
| 1570 |
(then (i32.const 1)) |
| 1571 |
(else (br 0 (i64.const 1)) (i32.const 1)) |
| 1572 |
) |
| 1573 |
))`), |
| 1574 |
`type mismatch`, |
| 1575 |
); |
| 1576 |
|
| 1577 |
// ./test/core/if.wast:1285 |
| 1578 |
assert_invalid( |
| 1579 |
() => instantiate(`(module |
| 1580 |
(func $$type-condition-empty |
| 1581 |
(if (then)) |
| 1582 |
) |
| 1583 |
)`), |
| 1584 |
`type mismatch`, |
| 1585 |
); |
| 1586 |
|
| 1587 |
// ./test/core/if.wast:1293 |
| 1588 |
assert_invalid( |
| 1589 |
() => instantiate(`(module |
| 1590 |
(func $$type-condition-empty-in-block |
| 1591 |
(i32.const 0) |
| 1592 |
(block (if (then))) |
| 1593 |
) |
| 1594 |
)`), |
| 1595 |
`type mismatch`, |
| 1596 |
); |
| 1597 |
|
| 1598 |
// ./test/core/if.wast:1302 |
| 1599 |
assert_invalid( |
| 1600 |
() => instantiate(`(module |
| 1601 |
(func $$type-condition-empty-in-loop |
| 1602 |
(i32.const 0) |
| 1603 |
(loop (if (then))) |
| 1604 |
) |
| 1605 |
)`), |
| 1606 |
`type mismatch`, |
| 1607 |
); |
| 1608 |
|
| 1609 |
// ./test/core/if.wast:1311 |
| 1610 |
assert_invalid( |
| 1611 |
() => instantiate(`(module |
| 1612 |
(func $$type-condition-empty-in-then |
| 1613 |
(i32.const 0) (i32.const 0) |
| 1614 |
(if (then (if (then)))) |
| 1615 |
) |
| 1616 |
)`), |
| 1617 |
`type mismatch`, |
| 1618 |
); |
| 1619 |
|
| 1620 |
// ./test/core/if.wast:1320 |
| 1621 |
assert_invalid( |
| 1622 |
() => instantiate(`(module |
| 1623 |
(func $$type-condition-empty-in-else |
| 1624 |
(i32.const 0) (i32.const 0) |
| 1625 |
(if (result i32) (then (i32.const 0)) (else (if (then)) (i32.const 0))) |
| 1626 |
(drop) |
| 1627 |
) |
| 1628 |
)`), |
| 1629 |
`type mismatch`, |
| 1630 |
); |
| 1631 |
|
| 1632 |
// ./test/core/if.wast:1330 |
| 1633 |
assert_invalid( |
| 1634 |
() => instantiate(`(module |
| 1635 |
(func $$type-condition-empty-in-br |
| 1636 |
(i32.const 0) |
| 1637 |
(block (br 0 (if(then))) (drop)) |
| 1638 |
) |
| 1639 |
)`), |
| 1640 |
`type mismatch`, |
| 1641 |
); |
| 1642 |
|
| 1643 |
// ./test/core/if.wast:1339 |
| 1644 |
assert_invalid( |
| 1645 |
() => instantiate(`(module |
| 1646 |
(func $$type-condition-empty-in-br_if |
| 1647 |
(i32.const 0) |
| 1648 |
(block (br_if 0 (if(then)) (i32.const 1)) (drop)) |
| 1649 |
) |
| 1650 |
)`), |
| 1651 |
`type mismatch`, |
| 1652 |
); |
| 1653 |
|
| 1654 |
// ./test/core/if.wast:1348 |
| 1655 |
assert_invalid( |
| 1656 |
() => instantiate(`(module |
| 1657 |
(func $$type-condition-empty-in-br_table |
| 1658 |
(i32.const 0) |
| 1659 |
(block (br_table 0 (if(then))) (drop)) |
| 1660 |
) |
| 1661 |
)`), |
| 1662 |
`type mismatch`, |
| 1663 |
); |
| 1664 |
|
| 1665 |
// ./test/core/if.wast:1357 |
| 1666 |
assert_invalid( |
| 1667 |
() => instantiate(`(module |
| 1668 |
(func $$type-condition-empty-in-return |
| 1669 |
(return (if(then))) (drop) |
| 1670 |
) |
| 1671 |
)`), |
| 1672 |
`type mismatch`, |
| 1673 |
); |
| 1674 |
|
| 1675 |
// ./test/core/if.wast:1365 |
| 1676 |
assert_invalid( |
| 1677 |
() => instantiate(`(module |
| 1678 |
(func $$type-condition-empty-in-select |
| 1679 |
(select (if(then)) (i32.const 1) (i32.const 2)) (drop) |
| 1680 |
) |
| 1681 |
)`), |
| 1682 |
`type mismatch`, |
| 1683 |
); |
| 1684 |
|
| 1685 |
// ./test/core/if.wast:1373 |
| 1686 |
assert_invalid( |
| 1687 |
() => instantiate(`(module |
| 1688 |
(func $$type-condition-empty-in-call |
| 1689 |
(call 1 (if(then))) (drop) |
| 1690 |
) |
| 1691 |
(func (param i32) (result i32) (local.get 0)) |
| 1692 |
)`), |
| 1693 |
`type mismatch`, |
| 1694 |
); |
| 1695 |
|
| 1696 |
// ./test/core/if.wast:1382 |
| 1697 |
assert_invalid( |
| 1698 |
() => instantiate(`(module |
| 1699 |
(func $$f (param i32) (result i32) (local.get 0)) |
| 1700 |
(type $$sig (func (param i32) (result i32))) |
| 1701 |
(table funcref (elem $$f)) |
| 1702 |
(func $$type-condition-empty-in-call_indirect |
| 1703 |
(block (result i32) |
| 1704 |
(call_indirect (type $$sig) |
| 1705 |
(if(then)) (i32.const 0) |
| 1706 |
) |
| 1707 |
(drop) |
| 1708 |
) |
| 1709 |
) |
| 1710 |
)`), |
| 1711 |
`type mismatch`, |
| 1712 |
); |
| 1713 |
|
| 1714 |
// ./test/core/if.wast:1398 |
| 1715 |
assert_invalid( |
| 1716 |
() => instantiate(`(module |
| 1717 |
(func $$type-condition-empty-in-local.set |
| 1718 |
(local i32) |
| 1719 |
(local.set 0 (if(then))) (local.get 0) (drop) |
| 1720 |
) |
| 1721 |
)`), |
| 1722 |
`type mismatch`, |
| 1723 |
); |
| 1724 |
|
| 1725 |
// ./test/core/if.wast:1407 |
| 1726 |
assert_invalid( |
| 1727 |
() => instantiate(`(module |
| 1728 |
(func $$type-condition-empty-in-local.tee |
| 1729 |
(local i32) |
| 1730 |
(local.tee 0 (if(then))) (drop) |
| 1731 |
) |
| 1732 |
)`), |
| 1733 |
`type mismatch`, |
| 1734 |
); |
| 1735 |
|
| 1736 |
// ./test/core/if.wast:1416 |
| 1737 |
assert_invalid( |
| 1738 |
() => instantiate(`(module |
| 1739 |
(global $$x (mut i32) (i32.const 0)) |
| 1740 |
(func $$type-condition-empty-in-global.set |
| 1741 |
(global.set $$x (if(then))) (global.get $$x) (drop) |
| 1742 |
) |
| 1743 |
)`), |
| 1744 |
`type mismatch`, |
| 1745 |
); |
| 1746 |
|
| 1747 |
// ./test/core/if.wast:1425 |
| 1748 |
assert_invalid( |
| 1749 |
() => instantiate(`(module |
| 1750 |
(memory 0) |
| 1751 |
(func $$type-condition-empty-in-memory.grow |
| 1752 |
(memory.grow (if(then))) (drop) |
| 1753 |
) |
| 1754 |
)`), |
| 1755 |
`type mismatch`, |
| 1756 |
); |
| 1757 |
|
| 1758 |
// ./test/core/if.wast:1434 |
| 1759 |
assert_invalid( |
| 1760 |
() => instantiate(`(module |
| 1761 |
(memory 0) |
| 1762 |
(func $$type-condition-empty-in-load |
| 1763 |
(i32.load (if(then))) (drop) |
| 1764 |
) |
| 1765 |
)`), |
| 1766 |
`type mismatch`, |
| 1767 |
); |
| 1768 |
|
| 1769 |
// ./test/core/if.wast:1443 |
| 1770 |
assert_invalid( |
| 1771 |
() => instantiate(`(module |
| 1772 |
(memory 1) |
| 1773 |
(func $$type-condition-empty-in-store |
| 1774 |
(i32.store (if(then)) (i32.const 1)) |
| 1775 |
) |
| 1776 |
)`), |
| 1777 |
`type mismatch`, |
| 1778 |
); |
| 1779 |
|
| 1780 |
// ./test/core/if.wast:1453 |
| 1781 |
assert_invalid( |
| 1782 |
() => instantiate(`(module (func $$type-param-void-vs-num |
| 1783 |
(if (param i32) (i32.const 1) (then (drop))) |
| 1784 |
))`), |
| 1785 |
`type mismatch`, |
| 1786 |
); |
| 1787 |
|
| 1788 |
// ./test/core/if.wast:1459 |
| 1789 |
assert_invalid( |
| 1790 |
() => instantiate(`(module (func $$type-param-void-vs-nums |
| 1791 |
(if (param i32 f64) (i32.const 1) (then (drop) (drop))) |
| 1792 |
))`), |
| 1793 |
`type mismatch`, |
| 1794 |
); |
| 1795 |
|
| 1796 |
// ./test/core/if.wast:1465 |
| 1797 |
assert_invalid( |
| 1798 |
() => instantiate(`(module (func $$type-param-num-vs-num |
| 1799 |
(f32.const 0) (if (param i32) (i32.const 1) (then (drop))) |
| 1800 |
))`), |
| 1801 |
`type mismatch`, |
| 1802 |
); |
| 1803 |
|
| 1804 |
// ./test/core/if.wast:1471 |
| 1805 |
assert_invalid( |
| 1806 |
() => instantiate(`(module (func $$type-param-num-vs-nums |
| 1807 |
(f32.const 0) (if (param f32 i32) (i32.const 1) (then (drop) (drop))) |
| 1808 |
))`), |
| 1809 |
`type mismatch`, |
| 1810 |
); |
| 1811 |
|
| 1812 |
// ./test/core/if.wast:1477 |
| 1813 |
assert_invalid( |
| 1814 |
() => instantiate(`(module (func $$type-param-nested-void-vs-num |
| 1815 |
(block (if (param i32) (i32.const 1) (then (drop)))) |
| 1816 |
))`), |
| 1817 |
`type mismatch`, |
| 1818 |
); |
| 1819 |
|
| 1820 |
// ./test/core/if.wast:1483 |
| 1821 |
assert_invalid( |
| 1822 |
() => instantiate(`(module (func $$type-param-void-vs-nums |
| 1823 |
(block (if (param i32 f64) (i32.const 1) (then (drop) (drop)))) |
| 1824 |
))`), |
| 1825 |
`type mismatch`, |
| 1826 |
); |
| 1827 |
|
| 1828 |
// ./test/core/if.wast:1489 |
| 1829 |
assert_invalid( |
| 1830 |
() => instantiate(`(module (func $$type-param-num-vs-num |
| 1831 |
(block (f32.const 0) (if (param i32) (i32.const 1) (then (drop)))) |
| 1832 |
))`), |
| 1833 |
`type mismatch`, |
| 1834 |
); |
| 1835 |
|
| 1836 |
// ./test/core/if.wast:1495 |
| 1837 |
assert_invalid( |
| 1838 |
() => instantiate(`(module (func $$type-param-num-vs-nums |
| 1839 |
(block (f32.const 0) (if (param f32 i32) (i32.const 1) (then (drop) (drop)))) |
| 1840 |
))`), |
| 1841 |
`type mismatch`, |
| 1842 |
); |
| 1843 |
|
| 1844 |
// ./test/core/if.wast:1502 |
| 1845 |
assert_malformed( |
| 1846 |
() => instantiate(`(func (param i32) (result i32) if (param $$x i32) end) `), |
| 1847 |
`unexpected token`, |
| 1848 |
); |
| 1849 |
|
| 1850 |
// ./test/core/if.wast:1506 |
| 1851 |
assert_malformed( |
| 1852 |
() => instantiate(`(func (param i32) (result i32) (if (param $$x i32) (then))) `), |
| 1853 |
`unexpected token`, |
| 1854 |
); |
| 1855 |
|
| 1856 |
// ./test/core/if.wast:1511 |
| 1857 |
assert_malformed(() => instantiate(`(func i32.const 0 if end $$l) `), `mismatching label`); |
| 1858 |
|
| 1859 |
// ./test/core/if.wast:1515 |
| 1860 |
assert_malformed( |
| 1861 |
() => instantiate(`(func i32.const 0 if $$a end $$l) `), |
| 1862 |
`mismatching label`, |
| 1863 |
); |
| 1864 |
|
| 1865 |
// ./test/core/if.wast:1519 |
| 1866 |
assert_malformed( |
| 1867 |
() => instantiate(`(func i32.const 0 if else $$l end) `), |
| 1868 |
`mismatching label`, |
| 1869 |
); |
| 1870 |
|
| 1871 |
// ./test/core/if.wast:1523 |
| 1872 |
assert_malformed( |
| 1873 |
() => instantiate(`(func i32.const 0 if $$a else $$l end) `), |
| 1874 |
`mismatching label`, |
| 1875 |
); |
| 1876 |
|
| 1877 |
// ./test/core/if.wast:1527 |
| 1878 |
assert_malformed( |
| 1879 |
() => instantiate(`(func i32.const 0 if else end $$l) `), |
| 1880 |
`mismatching label`, |
| 1881 |
); |
| 1882 |
|
| 1883 |
// ./test/core/if.wast:1531 |
| 1884 |
assert_malformed( |
| 1885 |
() => instantiate(`(func i32.const 0 if else $$l end $$l) `), |
| 1886 |
`mismatching label`, |
| 1887 |
); |
| 1888 |
|
| 1889 |
// ./test/core/if.wast:1535 |
| 1890 |
assert_malformed( |
| 1891 |
() => instantiate(`(func i32.const 0 if else $$l1 end $$l2) `), |
| 1892 |
`mismatching label`, |
| 1893 |
); |
| 1894 |
|
| 1895 |
// ./test/core/if.wast:1539 |
| 1896 |
assert_malformed( |
| 1897 |
() => instantiate(`(func i32.const 0 if $$a else end $$l) `), |
| 1898 |
`mismatching label`, |
| 1899 |
); |
| 1900 |
|
| 1901 |
// ./test/core/if.wast:1543 |
| 1902 |
assert_malformed( |
| 1903 |
() => instantiate(`(func i32.const 0 if $$a else $$a end $$l) `), |
| 1904 |
`mismatching label`, |
| 1905 |
); |
| 1906 |
|
| 1907 |
// ./test/core/if.wast:1547 |
| 1908 |
assert_malformed( |
| 1909 |
() => instantiate(`(func i32.const 0 if $$a else $$l end $$l) `), |
| 1910 |
`mismatching label`, |
| 1911 |
); |