| 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/func.wast |
| 17 |
|
| 18 |
// ./test/core/func.wast:3 |
| 19 |
let $0 = instantiate(`(module |
| 20 |
;; Auxiliary definition |
| 21 |
(type $$sig (func)) |
| 22 |
(func $$dummy) |
| 23 |
|
| 24 |
;; Syntax |
| 25 |
|
| 26 |
(func) |
| 27 |
(func (export "f")) |
| 28 |
(func $$f) |
| 29 |
(func $$h (export "g")) |
| 30 |
|
| 31 |
(func (local)) |
| 32 |
(func (local) (local)) |
| 33 |
(func (local i32)) |
| 34 |
(func (local $$x i32)) |
| 35 |
(func (local i32 f64 i64)) |
| 36 |
(func (local i32) (local f64)) |
| 37 |
(func (local i32 f32) (local $$x i64) (local) (local i32 f64)) |
| 38 |
|
| 39 |
(func (param)) |
| 40 |
(func (param) (param)) |
| 41 |
(func (param i32)) |
| 42 |
(func (param $$x i32)) |
| 43 |
(func (param i32 f64 i64)) |
| 44 |
(func (param i32) (param f64)) |
| 45 |
(func (param i32 f32) (param $$x i64) (param) (param i32 f64)) |
| 46 |
|
| 47 |
(func (result)) |
| 48 |
(func (result) (result)) |
| 49 |
(func (result i32) (unreachable)) |
| 50 |
(func (result i32 f64 f32) (unreachable)) |
| 51 |
(func (result i32) (result f64) (unreachable)) |
| 52 |
(func (result i32 f32) (result i64) (result) (result i32 f64) (unreachable)) |
| 53 |
|
| 54 |
(type $$sig-1 (func)) |
| 55 |
(type $$sig-2 (func (result i32))) |
| 56 |
(type $$sig-3 (func (param $$x i32))) |
| 57 |
(type $$sig-4 (func (param i32 f64 i32) (result i32))) |
| 58 |
|
| 59 |
(func (export "type-use-1") (type $$sig-1)) |
| 60 |
(func (export "type-use-2") (type $$sig-2) (i32.const 0)) |
| 61 |
(func (export "type-use-3") (type $$sig-3)) |
| 62 |
(func (export "type-use-4") (type $$sig-4) (i32.const 0)) |
| 63 |
(func (export "type-use-5") (type $$sig-2) (result i32) (i32.const 0)) |
| 64 |
(func (export "type-use-6") (type $$sig-3) (param i32)) |
| 65 |
(func (export "type-use-7") |
| 66 |
(type $$sig-4) (param i32) (param f64 i32) (result i32) (i32.const 0) |
| 67 |
) |
| 68 |
|
| 69 |
(func (type $$sig)) |
| 70 |
(func (type $$forward)) ;; forward reference |
| 71 |
|
| 72 |
(func $$complex |
| 73 |
(param i32 f32) (param $$x i64) (param) (param i32) |
| 74 |
(result) (result i32) (result) (result i64 i32) |
| 75 |
(local f32) (local $$y i32) (local i64 i32) (local) (local f64 i32) |
| 76 |
(unreachable) (unreachable) |
| 77 |
) |
| 78 |
(func $$complex-sig |
| 79 |
(type $$sig) |
| 80 |
(local f32) (local $$y i32) (local i64 i32) (local) (local f64 i32) |
| 81 |
(unreachable) (unreachable) |
| 82 |
) |
| 83 |
|
| 84 |
(type $$forward (func)) |
| 85 |
|
| 86 |
;; Typing of locals |
| 87 |
|
| 88 |
(func (export "local-first-i32") (result i32) (local i32 i32) (local.get 0)) |
| 89 |
(func (export "local-first-i64") (result i64) (local i64 i64) (local.get 0)) |
| 90 |
(func (export "local-first-f32") (result f32) (local f32 f32) (local.get 0)) |
| 91 |
(func (export "local-first-f64") (result f64) (local f64 f64) (local.get 0)) |
| 92 |
(func (export "local-second-i32") (result i32) (local i32 i32) (local.get 1)) |
| 93 |
(func (export "local-second-i64") (result i64) (local i64 i64) (local.get 1)) |
| 94 |
(func (export "local-second-f32") (result f32) (local f32 f32) (local.get 1)) |
| 95 |
(func (export "local-second-f64") (result f64) (local f64 f64) (local.get 1)) |
| 96 |
(func (export "local-mixed") (result f64) |
| 97 |
(local f32) (local $$x i32) (local i64 i32) (local) (local f64 i32) |
| 98 |
(drop (f32.neg (local.get 0))) |
| 99 |
(drop (i32.eqz (local.get 1))) |
| 100 |
(drop (i64.eqz (local.get 2))) |
| 101 |
(drop (i32.eqz (local.get 3))) |
| 102 |
(drop (f64.neg (local.get 4))) |
| 103 |
(drop (i32.eqz (local.get 5))) |
| 104 |
(local.get 4) |
| 105 |
) |
| 106 |
|
| 107 |
;; Typing of parameters |
| 108 |
|
| 109 |
(func (export "param-first-i32") (param i32 i32) (result i32) (local.get 0)) |
| 110 |
(func (export "param-first-i64") (param i64 i64) (result i64) (local.get 0)) |
| 111 |
(func (export "param-first-f32") (param f32 f32) (result f32) (local.get 0)) |
| 112 |
(func (export "param-first-f64") (param f64 f64) (result f64) (local.get 0)) |
| 113 |
(func (export "param-second-i32") (param i32 i32) (result i32) (local.get 1)) |
| 114 |
(func (export "param-second-i64") (param i64 i64) (result i64) (local.get 1)) |
| 115 |
(func (export "param-second-f32") (param f32 f32) (result f32) (local.get 1)) |
| 116 |
(func (export "param-second-f64") (param f64 f64) (result f64) (local.get 1)) |
| 117 |
(func (export "param-mixed") (param f32 i32) (param) (param $$x i64) (param i32 f64 i32) |
| 118 |
(result f64) |
| 119 |
(drop (f32.neg (local.get 0))) |
| 120 |
(drop (i32.eqz (local.get 1))) |
| 121 |
(drop (i64.eqz (local.get 2))) |
| 122 |
(drop (i32.eqz (local.get 3))) |
| 123 |
(drop (f64.neg (local.get 4))) |
| 124 |
(drop (i32.eqz (local.get 5))) |
| 125 |
(local.get 4) |
| 126 |
) |
| 127 |
|
| 128 |
;; Typing of results |
| 129 |
|
| 130 |
(func (export "empty")) |
| 131 |
(func (export "value-void") (call $$dummy)) |
| 132 |
(func (export "value-i32") (result i32) (i32.const 77)) |
| 133 |
(func (export "value-i64") (result i64) (i64.const 7777)) |
| 134 |
(func (export "value-f32") (result f32) (f32.const 77.7)) |
| 135 |
(func (export "value-f64") (result f64) (f64.const 77.77)) |
| 136 |
(func (export "value-i32-f64") (result i32 f64) (i32.const 77) (f64.const 7)) |
| 137 |
(func (export "value-i32-i32-i32") (result i32 i32 i32) |
| 138 |
(i32.const 1) (i32.const 2) (i32.const 3) |
| 139 |
) |
| 140 |
(func (export "value-block-void") (block (call $$dummy) (call $$dummy))) |
| 141 |
(func (export "value-block-i32") (result i32) |
| 142 |
(block (result i32) (call $$dummy) (i32.const 77)) |
| 143 |
) |
| 144 |
(func (export "value-block-i32-i64") (result i32 i64) |
| 145 |
(block (result i32 i64) (call $$dummy) (i32.const 1) (i64.const 2)) |
| 146 |
) |
| 147 |
|
| 148 |
(func (export "return-empty") (return)) |
| 149 |
(func (export "return-i32") (result i32) (return (i32.const 78))) |
| 150 |
(func (export "return-i64") (result i64) (return (i64.const 7878))) |
| 151 |
(func (export "return-f32") (result f32) (return (f32.const 78.7))) |
| 152 |
(func (export "return-f64") (result f64) (return (f64.const 78.78))) |
| 153 |
(func (export "return-i32-f64") (result i32 f64) |
| 154 |
(return (i32.const 78) (f64.const 78.78)) |
| 155 |
) |
| 156 |
(func (export "return-i32-i32-i32") (result i32 i32 i32) |
| 157 |
(return (i32.const 1) (i32.const 2) (i32.const 3)) |
| 158 |
) |
| 159 |
(func (export "return-block-i32") (result i32) |
| 160 |
(return (block (result i32) (call $$dummy) (i32.const 77))) |
| 161 |
) |
| 162 |
(func (export "return-block-i32-i64") (result i32 i64) |
| 163 |
(return (block (result i32 i64) (call $$dummy) (i32.const 1) (i64.const 2))) |
| 164 |
) |
| 165 |
|
| 166 |
(func (export "break-empty") (br 0)) |
| 167 |
(func (export "break-i32") (result i32) (br 0 (i32.const 79))) |
| 168 |
(func (export "break-i64") (result i64) (br 0 (i64.const 7979))) |
| 169 |
(func (export "break-f32") (result f32) (br 0 (f32.const 79.9))) |
| 170 |
(func (export "break-f64") (result f64) (br 0 (f64.const 79.79))) |
| 171 |
(func (export "break-i32-f64") (result i32 f64) |
| 172 |
(br 0 (i32.const 79) (f64.const 79.79)) |
| 173 |
) |
| 174 |
(func (export "break-i32-i32-i32") (result i32 i32 i32) |
| 175 |
(br 0 (i32.const 1) (i32.const 2) (i32.const 3)) |
| 176 |
) |
| 177 |
(func (export "break-block-i32") (result i32) |
| 178 |
(br 0 (block (result i32) (call $$dummy) (i32.const 77))) |
| 179 |
) |
| 180 |
(func (export "break-block-i32-i64") (result i32 i64) |
| 181 |
(br 0 (block (result i32 i64) (call $$dummy) (i32.const 1) (i64.const 2))) |
| 182 |
) |
| 183 |
|
| 184 |
(func (export "break-br_if-empty") (param i32) |
| 185 |
(br_if 0 (local.get 0)) |
| 186 |
) |
| 187 |
(func (export "break-br_if-num") (param i32) (result i32) |
| 188 |
(drop (br_if 0 (i32.const 50) (local.get 0))) (i32.const 51) |
| 189 |
) |
| 190 |
(func (export "break-br_if-num-num") (param i32) (result i32 i64) |
| 191 |
(drop (drop (br_if 0 (i32.const 50) (i64.const 51) (local.get 0)))) |
| 192 |
(i32.const 51) (i64.const 52) |
| 193 |
) |
| 194 |
|
| 195 |
(func (export "break-br_table-empty") (param i32) |
| 196 |
(br_table 0 0 0 (local.get 0)) |
| 197 |
) |
| 198 |
(func (export "break-br_table-num") (param i32) (result i32) |
| 199 |
(br_table 0 0 (i32.const 50) (local.get 0)) (i32.const 51) |
| 200 |
) |
| 201 |
(func (export "break-br_table-num-num") (param i32) (result i32 i64) |
| 202 |
(br_table 0 0 (i32.const 50) (i64.const 51) (local.get 0)) |
| 203 |
(i32.const 51) (i64.const 52) |
| 204 |
) |
| 205 |
(func (export "break-br_table-nested-empty") (param i32) |
| 206 |
(block (br_table 0 1 0 (local.get 0))) |
| 207 |
) |
| 208 |
(func (export "break-br_table-nested-num") (param i32) (result i32) |
| 209 |
(i32.add |
| 210 |
(block (result i32) |
| 211 |
(br_table 0 1 0 (i32.const 50) (local.get 0)) (i32.const 51) |
| 212 |
) |
| 213 |
(i32.const 2) |
| 214 |
) |
| 215 |
) |
| 216 |
(func (export "break-br_table-nested-num-num") (param i32) (result i32 i32) |
| 217 |
(i32.add |
| 218 |
(block (result i32 i32) |
| 219 |
(br_table 0 1 0 (i32.const 50) (i32.const 51) (local.get 0)) |
| 220 |
(i32.const 51) (i32.const -3) |
| 221 |
) |
| 222 |
) |
| 223 |
(i32.const 52) |
| 224 |
) |
| 225 |
|
| 226 |
;; Large signatures |
| 227 |
|
| 228 |
(func (export "large-sig") |
| 229 |
(param i32 i64 f32 f32 i32 f64 f32 i32 i32 i32 f32 f64 f64 f64 i32 i32 f32) |
| 230 |
(result f64 f32 i32 i32 i32 i64 f32 i32 i32 f32 f64 f64 i32 f32 i32 f64) |
| 231 |
(local.get 5) |
| 232 |
(local.get 2) |
| 233 |
(local.get 0) |
| 234 |
(local.get 8) |
| 235 |
(local.get 7) |
| 236 |
(local.get 1) |
| 237 |
(local.get 3) |
| 238 |
(local.get 9) |
| 239 |
(local.get 4) |
| 240 |
(local.get 6) |
| 241 |
(local.get 13) |
| 242 |
(local.get 11) |
| 243 |
(local.get 15) |
| 244 |
(local.get 16) |
| 245 |
(local.get 14) |
| 246 |
(local.get 12) |
| 247 |
) |
| 248 |
|
| 249 |
;; Default initialization of locals |
| 250 |
|
| 251 |
(func (export "init-local-i32") (result i32) (local i32) (local.get 0)) |
| 252 |
(func (export "init-local-i64") (result i64) (local i64) (local.get 0)) |
| 253 |
(func (export "init-local-f32") (result f32) (local f32) (local.get 0)) |
| 254 |
(func (export "init-local-f64") (result f64) (local f64) (local.get 0)) |
| 255 |
)`); |
| 256 |
|
| 257 |
// ./test/core/func.wast:241 |
| 258 |
assert_return(() => invoke($0, `type-use-1`, []), []); |
| 259 |
|
| 260 |
// ./test/core/func.wast:242 |
| 261 |
assert_return(() => invoke($0, `type-use-2`, []), [value("i32", 0)]); |
| 262 |
|
| 263 |
// ./test/core/func.wast:243 |
| 264 |
assert_return(() => invoke($0, `type-use-3`, [1]), []); |
| 265 |
|
| 266 |
// ./test/core/func.wast:244 |
| 267 |
assert_return(() => invoke($0, `type-use-4`, [1, value("f64", 1), 1]), [value("i32", 0)]); |
| 268 |
|
| 269 |
// ./test/core/func.wast:248 |
| 270 |
assert_return(() => invoke($0, `type-use-5`, []), [value("i32", 0)]); |
| 271 |
|
| 272 |
// ./test/core/func.wast:249 |
| 273 |
assert_return(() => invoke($0, `type-use-6`, [1]), []); |
| 274 |
|
| 275 |
// ./test/core/func.wast:250 |
| 276 |
assert_return(() => invoke($0, `type-use-7`, [1, value("f64", 1), 1]), [value("i32", 0)]); |
| 277 |
|
| 278 |
// ./test/core/func.wast:255 |
| 279 |
assert_return(() => invoke($0, `local-first-i32`, []), [value("i32", 0)]); |
| 280 |
|
| 281 |
// ./test/core/func.wast:256 |
| 282 |
assert_return(() => invoke($0, `local-first-i64`, []), [value("i64", 0n)]); |
| 283 |
|
| 284 |
// ./test/core/func.wast:257 |
| 285 |
assert_return(() => invoke($0, `local-first-f32`, []), [value("f32", 0)]); |
| 286 |
|
| 287 |
// ./test/core/func.wast:258 |
| 288 |
assert_return(() => invoke($0, `local-first-f64`, []), [value("f64", 0)]); |
| 289 |
|
| 290 |
// ./test/core/func.wast:259 |
| 291 |
assert_return(() => invoke($0, `local-second-i32`, []), [value("i32", 0)]); |
| 292 |
|
| 293 |
// ./test/core/func.wast:260 |
| 294 |
assert_return(() => invoke($0, `local-second-i64`, []), [value("i64", 0n)]); |
| 295 |
|
| 296 |
// ./test/core/func.wast:261 |
| 297 |
assert_return(() => invoke($0, `local-second-f32`, []), [value("f32", 0)]); |
| 298 |
|
| 299 |
// ./test/core/func.wast:262 |
| 300 |
assert_return(() => invoke($0, `local-second-f64`, []), [value("f64", 0)]); |
| 301 |
|
| 302 |
// ./test/core/func.wast:263 |
| 303 |
assert_return(() => invoke($0, `local-mixed`, []), [value("f64", 0)]); |
| 304 |
|
| 305 |
// ./test/core/func.wast:265 |
| 306 |
assert_return(() => invoke($0, `param-first-i32`, [2, 3]), [value("i32", 2)]); |
| 307 |
|
| 308 |
// ./test/core/func.wast:268 |
| 309 |
assert_return(() => invoke($0, `param-first-i64`, [2n, 3n]), [value("i64", 2n)]); |
| 310 |
|
| 311 |
// ./test/core/func.wast:271 |
| 312 |
assert_return( |
| 313 |
() => invoke($0, `param-first-f32`, [value("f32", 2), value("f32", 3)]), |
| 314 |
[value("f32", 2)], |
| 315 |
); |
| 316 |
|
| 317 |
// ./test/core/func.wast:274 |
| 318 |
assert_return( |
| 319 |
() => invoke($0, `param-first-f64`, [value("f64", 2), value("f64", 3)]), |
| 320 |
[value("f64", 2)], |
| 321 |
); |
| 322 |
|
| 323 |
// ./test/core/func.wast:277 |
| 324 |
assert_return(() => invoke($0, `param-second-i32`, [2, 3]), [value("i32", 3)]); |
| 325 |
|
| 326 |
// ./test/core/func.wast:280 |
| 327 |
assert_return(() => invoke($0, `param-second-i64`, [2n, 3n]), [value("i64", 3n)]); |
| 328 |
|
| 329 |
// ./test/core/func.wast:283 |
| 330 |
assert_return( |
| 331 |
() => invoke($0, `param-second-f32`, [value("f32", 2), value("f32", 3)]), |
| 332 |
[value("f32", 3)], |
| 333 |
); |
| 334 |
|
| 335 |
// ./test/core/func.wast:286 |
| 336 |
assert_return( |
| 337 |
() => invoke($0, `param-second-f64`, [value("f64", 2), value("f64", 3)]), |
| 338 |
[value("f64", 3)], |
| 339 |
); |
| 340 |
|
| 341 |
// ./test/core/func.wast:290 |
| 342 |
assert_return( |
| 343 |
() => invoke($0, `param-mixed`, [value("f32", 1), 2, 3n, 4, value("f64", 5.5), 6]), |
| 344 |
[value("f64", 5.5)], |
| 345 |
); |
| 346 |
|
| 347 |
// ./test/core/func.wast:298 |
| 348 |
assert_return(() => invoke($0, `empty`, []), []); |
| 349 |
|
| 350 |
// ./test/core/func.wast:299 |
| 351 |
assert_return(() => invoke($0, `value-void`, []), []); |
| 352 |
|
| 353 |
// ./test/core/func.wast:300 |
| 354 |
assert_return(() => invoke($0, `value-i32`, []), [value("i32", 77)]); |
| 355 |
|
| 356 |
// ./test/core/func.wast:301 |
| 357 |
assert_return(() => invoke($0, `value-i64`, []), [value("i64", 7777n)]); |
| 358 |
|
| 359 |
// ./test/core/func.wast:302 |
| 360 |
assert_return(() => invoke($0, `value-f32`, []), [value("f32", 77.7)]); |
| 361 |
|
| 362 |
// ./test/core/func.wast:303 |
| 363 |
assert_return(() => invoke($0, `value-f64`, []), [value("f64", 77.77)]); |
| 364 |
|
| 365 |
// ./test/core/func.wast:304 |
| 366 |
assert_return(() => invoke($0, `value-i32-f64`, []), [value("i32", 77), value("f64", 7)]); |
| 367 |
|
| 368 |
// ./test/core/func.wast:305 |
| 369 |
assert_return( |
| 370 |
() => invoke($0, `value-i32-i32-i32`, []), |
| 371 |
[value("i32", 1), value("i32", 2), value("i32", 3)], |
| 372 |
); |
| 373 |
|
| 374 |
// ./test/core/func.wast:308 |
| 375 |
assert_return(() => invoke($0, `value-block-void`, []), []); |
| 376 |
|
| 377 |
// ./test/core/func.wast:309 |
| 378 |
assert_return(() => invoke($0, `value-block-i32`, []), [value("i32", 77)]); |
| 379 |
|
| 380 |
// ./test/core/func.wast:310 |
| 381 |
assert_return(() => invoke($0, `value-block-i32-i64`, []), [value("i32", 1), value("i64", 2n)]); |
| 382 |
|
| 383 |
// ./test/core/func.wast:312 |
| 384 |
assert_return(() => invoke($0, `return-empty`, []), []); |
| 385 |
|
| 386 |
// ./test/core/func.wast:313 |
| 387 |
assert_return(() => invoke($0, `return-i32`, []), [value("i32", 78)]); |
| 388 |
|
| 389 |
// ./test/core/func.wast:314 |
| 390 |
assert_return(() => invoke($0, `return-i64`, []), [value("i64", 7878n)]); |
| 391 |
|
| 392 |
// ./test/core/func.wast:315 |
| 393 |
assert_return(() => invoke($0, `return-f32`, []), [value("f32", 78.7)]); |
| 394 |
|
| 395 |
// ./test/core/func.wast:316 |
| 396 |
assert_return(() => invoke($0, `return-f64`, []), [value("f64", 78.78)]); |
| 397 |
|
| 398 |
// ./test/core/func.wast:317 |
| 399 |
assert_return(() => invoke($0, `return-i32-f64`, []), [value("i32", 78), value("f64", 78.78)]); |
| 400 |
|
| 401 |
// ./test/core/func.wast:318 |
| 402 |
assert_return( |
| 403 |
() => invoke($0, `return-i32-i32-i32`, []), |
| 404 |
[value("i32", 1), value("i32", 2), value("i32", 3)], |
| 405 |
); |
| 406 |
|
| 407 |
// ./test/core/func.wast:321 |
| 408 |
assert_return(() => invoke($0, `return-block-i32`, []), [value("i32", 77)]); |
| 409 |
|
| 410 |
// ./test/core/func.wast:322 |
| 411 |
assert_return(() => invoke($0, `return-block-i32-i64`, []), [value("i32", 1), value("i64", 2n)]); |
| 412 |
|
| 413 |
// ./test/core/func.wast:324 |
| 414 |
assert_return(() => invoke($0, `break-empty`, []), []); |
| 415 |
|
| 416 |
// ./test/core/func.wast:325 |
| 417 |
assert_return(() => invoke($0, `break-i32`, []), [value("i32", 79)]); |
| 418 |
|
| 419 |
// ./test/core/func.wast:326 |
| 420 |
assert_return(() => invoke($0, `break-i64`, []), [value("i64", 7979n)]); |
| 421 |
|
| 422 |
// ./test/core/func.wast:327 |
| 423 |
assert_return(() => invoke($0, `break-f32`, []), [value("f32", 79.9)]); |
| 424 |
|
| 425 |
// ./test/core/func.wast:328 |
| 426 |
assert_return(() => invoke($0, `break-f64`, []), [value("f64", 79.79)]); |
| 427 |
|
| 428 |
// ./test/core/func.wast:329 |
| 429 |
assert_return(() => invoke($0, `break-i32-f64`, []), [value("i32", 79), value("f64", 79.79)]); |
| 430 |
|
| 431 |
// ./test/core/func.wast:330 |
| 432 |
assert_return( |
| 433 |
() => invoke($0, `break-i32-i32-i32`, []), |
| 434 |
[value("i32", 1), value("i32", 2), value("i32", 3)], |
| 435 |
); |
| 436 |
|
| 437 |
// ./test/core/func.wast:333 |
| 438 |
assert_return(() => invoke($0, `break-block-i32`, []), [value("i32", 77)]); |
| 439 |
|
| 440 |
// ./test/core/func.wast:334 |
| 441 |
assert_return(() => invoke($0, `break-block-i32-i64`, []), [value("i32", 1), value("i64", 2n)]); |
| 442 |
|
| 443 |
// ./test/core/func.wast:336 |
| 444 |
assert_return(() => invoke($0, `break-br_if-empty`, [0]), []); |
| 445 |
|
| 446 |
// ./test/core/func.wast:337 |
| 447 |
assert_return(() => invoke($0, `break-br_if-empty`, [2]), []); |
| 448 |
|
| 449 |
// ./test/core/func.wast:338 |
| 450 |
assert_return(() => invoke($0, `break-br_if-num`, [0]), [value("i32", 51)]); |
| 451 |
|
| 452 |
// ./test/core/func.wast:339 |
| 453 |
assert_return(() => invoke($0, `break-br_if-num`, [1]), [value("i32", 50)]); |
| 454 |
|
| 455 |
// ./test/core/func.wast:340 |
| 456 |
assert_return(() => invoke($0, `break-br_if-num-num`, [0]), [value("i32", 51), value("i64", 52n)]); |
| 457 |
|
| 458 |
// ./test/core/func.wast:343 |
| 459 |
assert_return(() => invoke($0, `break-br_if-num-num`, [1]), [value("i32", 50), value("i64", 51n)]); |
| 460 |
|
| 461 |
// ./test/core/func.wast:347 |
| 462 |
assert_return(() => invoke($0, `break-br_table-empty`, [0]), []); |
| 463 |
|
| 464 |
// ./test/core/func.wast:348 |
| 465 |
assert_return(() => invoke($0, `break-br_table-empty`, [1]), []); |
| 466 |
|
| 467 |
// ./test/core/func.wast:349 |
| 468 |
assert_return(() => invoke($0, `break-br_table-empty`, [5]), []); |
| 469 |
|
| 470 |
// ./test/core/func.wast:350 |
| 471 |
assert_return(() => invoke($0, `break-br_table-empty`, [-1]), []); |
| 472 |
|
| 473 |
// ./test/core/func.wast:351 |
| 474 |
assert_return(() => invoke($0, `break-br_table-num`, [0]), [value("i32", 50)]); |
| 475 |
|
| 476 |
// ./test/core/func.wast:352 |
| 477 |
assert_return(() => invoke($0, `break-br_table-num`, [1]), [value("i32", 50)]); |
| 478 |
|
| 479 |
// ./test/core/func.wast:353 |
| 480 |
assert_return(() => invoke($0, `break-br_table-num`, [10]), [value("i32", 50)]); |
| 481 |
|
| 482 |
// ./test/core/func.wast:354 |
| 483 |
assert_return(() => invoke($0, `break-br_table-num`, [-100]), [value("i32", 50)]); |
| 484 |
|
| 485 |
// ./test/core/func.wast:355 |
| 486 |
assert_return(() => invoke($0, `break-br_table-num-num`, [0]), [value("i32", 50), value("i64", 51n)]); |
| 487 |
|
| 488 |
// ./test/core/func.wast:358 |
| 489 |
assert_return(() => invoke($0, `break-br_table-num-num`, [1]), [value("i32", 50), value("i64", 51n)]); |
| 490 |
|
| 491 |
// ./test/core/func.wast:361 |
| 492 |
assert_return(() => invoke($0, `break-br_table-num-num`, [10]), [value("i32", 50), value("i64", 51n)]); |
| 493 |
|
| 494 |
// ./test/core/func.wast:364 |
| 495 |
assert_return(() => invoke($0, `break-br_table-num-num`, [-100]), [value("i32", 50), value("i64", 51n)]); |
| 496 |
|
| 497 |
// ./test/core/func.wast:367 |
| 498 |
assert_return(() => invoke($0, `break-br_table-nested-empty`, [0]), []); |
| 499 |
|
| 500 |
// ./test/core/func.wast:368 |
| 501 |
assert_return(() => invoke($0, `break-br_table-nested-empty`, [1]), []); |
| 502 |
|
| 503 |
// ./test/core/func.wast:369 |
| 504 |
assert_return(() => invoke($0, `break-br_table-nested-empty`, [3]), []); |
| 505 |
|
| 506 |
// ./test/core/func.wast:370 |
| 507 |
assert_return(() => invoke($0, `break-br_table-nested-empty`, [-2]), []); |
| 508 |
|
| 509 |
// ./test/core/func.wast:371 |
| 510 |
assert_return(() => invoke($0, `break-br_table-nested-num`, [0]), [value("i32", 52)]); |
| 511 |
|
| 512 |
// ./test/core/func.wast:374 |
| 513 |
assert_return(() => invoke($0, `break-br_table-nested-num`, [1]), [value("i32", 50)]); |
| 514 |
|
| 515 |
// ./test/core/func.wast:377 |
| 516 |
assert_return(() => invoke($0, `break-br_table-nested-num`, [2]), [value("i32", 52)]); |
| 517 |
|
| 518 |
// ./test/core/func.wast:380 |
| 519 |
assert_return(() => invoke($0, `break-br_table-nested-num`, [-3]), [value("i32", 52)]); |
| 520 |
|
| 521 |
// ./test/core/func.wast:383 |
| 522 |
assert_return( |
| 523 |
() => invoke($0, `break-br_table-nested-num-num`, [0]), |
| 524 |
[value("i32", 101), value("i32", 52)], |
| 525 |
); |
| 526 |
|
| 527 |
// ./test/core/func.wast:387 |
| 528 |
assert_return( |
| 529 |
() => invoke($0, `break-br_table-nested-num-num`, [1]), |
| 530 |
[value("i32", 50), value("i32", 51)], |
| 531 |
); |
| 532 |
|
| 533 |
// ./test/core/func.wast:391 |
| 534 |
assert_return( |
| 535 |
() => invoke($0, `break-br_table-nested-num-num`, [2]), |
| 536 |
[value("i32", 101), value("i32", 52)], |
| 537 |
); |
| 538 |
|
| 539 |
// ./test/core/func.wast:395 |
| 540 |
assert_return( |
| 541 |
() => invoke($0, `break-br_table-nested-num-num`, [-3]), |
| 542 |
[value("i32", 101), value("i32", 52)], |
| 543 |
); |
| 544 |
|
| 545 |
// ./test/core/func.wast:400 |
| 546 |
assert_return( |
| 547 |
() => invoke($0, `large-sig`, [ |
| 548 |
0, |
| 549 |
1n, |
| 550 |
value("f32", 2), |
| 551 |
value("f32", 3), |
| 552 |
4, |
| 553 |
value("f64", 5), |
| 554 |
value("f32", 6), |
| 555 |
7, |
| 556 |
8, |
| 557 |
9, |
| 558 |
value("f32", 10), |
| 559 |
value("f64", 11), |
| 560 |
value("f64", 12), |
| 561 |
value("f64", 13), |
| 562 |
14, |
| 563 |
15, |
| 564 |
value("f32", 16), |
| 565 |
]), |
| 566 |
[ |
| 567 |
value("f64", 5), |
| 568 |
value("f32", 2), |
| 569 |
value("i32", 0), |
| 570 |
value("i32", 8), |
| 571 |
value("i32", 7), |
| 572 |
value("i64", 1n), |
| 573 |
value("f32", 3), |
| 574 |
value("i32", 9), |
| 575 |
value("i32", 4), |
| 576 |
value("f32", 6), |
| 577 |
value("f64", 13), |
| 578 |
value("f64", 11), |
| 579 |
value("i32", 15), |
| 580 |
value("f32", 16), |
| 581 |
value("i32", 14), |
| 582 |
value("f64", 12), |
| 583 |
], |
| 584 |
); |
| 585 |
|
| 586 |
// ./test/core/func.wast:414 |
| 587 |
assert_return(() => invoke($0, `init-local-i32`, []), [value("i32", 0)]); |
| 588 |
|
| 589 |
// ./test/core/func.wast:415 |
| 590 |
assert_return(() => invoke($0, `init-local-i64`, []), [value("i64", 0n)]); |
| 591 |
|
| 592 |
// ./test/core/func.wast:416 |
| 593 |
assert_return(() => invoke($0, `init-local-f32`, []), [value("f32", 0)]); |
| 594 |
|
| 595 |
// ./test/core/func.wast:417 |
| 596 |
assert_return(() => invoke($0, `init-local-f64`, []), [value("f64", 0)]); |
| 597 |
|
| 598 |
// ./test/core/func.wast:422 |
| 599 |
let $1 = instantiate(`(module |
| 600 |
(func $$f (result f64) (f64.const 0)) ;; adds implicit type definition |
| 601 |
(func $$g (param i32)) ;; reuses explicit type definition |
| 602 |
(type $$t (func (param i32))) |
| 603 |
|
| 604 |
(func $$i32->void (type 0)) ;; (param i32) |
| 605 |
(func $$void->f64 (type 1) (f64.const 0)) ;; (result f64) |
| 606 |
(func $$check |
| 607 |
(call $$i32->void (i32.const 0)) |
| 608 |
(drop (call $$void->f64)) |
| 609 |
) |
| 610 |
)`); |
| 611 |
|
| 612 |
// ./test/core/func.wast:435 |
| 613 |
assert_invalid( |
| 614 |
() => instantiate(`(module |
| 615 |
(func $$f (result f64) (f64.const 0)) ;; adds implicit type definition |
| 616 |
(func $$g (param i32)) ;; reuses explicit type definition |
| 617 |
(func $$h (result f64) (f64.const 1)) ;; reuses implicit type definition |
| 618 |
(type $$t (func (param i32))) |
| 619 |
|
| 620 |
(func (type 2)) ;; does not exist |
| 621 |
)`), |
| 622 |
`unknown type`, |
| 623 |
); |
| 624 |
|
| 625 |
// ./test/core/func.wast:447 |
| 626 |
assert_malformed( |
| 627 |
() => instantiate(`(func $$f (result f64) (f64.const 0)) (func $$g (param i32)) (func $$h (result f64) (f64.const 1)) (type $$t (func (param i32))) (func (type 2) (param i32)) `), |
| 628 |
`unknown type`, |
| 629 |
); |
| 630 |
|
| 631 |
// ./test/core/func.wast:459 |
| 632 |
let $2 = instantiate(`(module |
| 633 |
(type $$proc (func (result i32))) |
| 634 |
(type $$sig (func (param i32) (result i32))) |
| 635 |
|
| 636 |
(func (export "f") (type $$sig) |
| 637 |
(local $$var i32) |
| 638 |
(local.get $$var) |
| 639 |
) |
| 640 |
|
| 641 |
(func $$g (type $$sig) |
| 642 |
(local $$var i32) |
| 643 |
(local.get $$var) |
| 644 |
) |
| 645 |
(func (export "g") (type $$sig) |
| 646 |
(call $$g (local.get 0)) |
| 647 |
) |
| 648 |
|
| 649 |
(func (export "p") (type $$proc) |
| 650 |
(local $$var i32) |
| 651 |
(local.set 0 (i32.const 42)) |
| 652 |
(local.get $$var) |
| 653 |
) |
| 654 |
)`); |
| 655 |
|
| 656 |
// ./test/core/func.wast:483 |
| 657 |
assert_return(() => invoke($2, `f`, [42]), [value("i32", 0)]); |
| 658 |
|
| 659 |
// ./test/core/func.wast:484 |
| 660 |
assert_return(() => invoke($2, `g`, [42]), [value("i32", 0)]); |
| 661 |
|
| 662 |
// ./test/core/func.wast:485 |
| 663 |
assert_return(() => invoke($2, `p`, []), [value("i32", 42)]); |
| 664 |
|
| 665 |
// ./test/core/func.wast:488 |
| 666 |
let $3 = instantiate(`(module |
| 667 |
(type $$sig (func)) |
| 668 |
|
| 669 |
(func $$empty-sig-1) ;; should be assigned type $$sig |
| 670 |
(func $$complex-sig-1 (param f64 i64 f64 i64 f64 i64 f32 i32)) |
| 671 |
(func $$empty-sig-2) ;; should be assigned type $$sig |
| 672 |
(func $$complex-sig-2 (param f64 i64 f64 i64 f64 i64 f32 i32)) |
| 673 |
(func $$complex-sig-3 (param f64 i64 f64 i64 f64 i64 f32 i32)) |
| 674 |
(func $$complex-sig-4 (param i64 i64 f64 i64 f64 i64 f32 i32)) |
| 675 |
(func $$complex-sig-5 (param i64 i64 f64 i64 f64 i64 f32 i32)) |
| 676 |
|
| 677 |
(type $$empty-sig-duplicate (func)) |
| 678 |
(type $$complex-sig-duplicate (func (param i64 i64 f64 i64 f64 i64 f32 i32))) |
| 679 |
(table funcref |
| 680 |
(elem |
| 681 |
$$complex-sig-3 $$empty-sig-2 $$complex-sig-1 $$complex-sig-3 $$empty-sig-1 |
| 682 |
$$complex-sig-4 $$complex-sig-5 |
| 683 |
) |
| 684 |
) |
| 685 |
|
| 686 |
(func (export "signature-explicit-reused") |
| 687 |
(call_indirect (type $$sig) (i32.const 1)) |
| 688 |
(call_indirect (type $$sig) (i32.const 4)) |
| 689 |
) |
| 690 |
|
| 691 |
(func (export "signature-implicit-reused") |
| 692 |
;; The implicit index 3 in this test depends on the function and |
| 693 |
;; type definitions, and may need adapting if they change. |
| 694 |
(call_indirect (type 3) |
| 695 |
(f64.const 0) (i64.const 0) (f64.const 0) (i64.const 0) |
| 696 |
(f64.const 0) (i64.const 0) (f32.const 0) (i32.const 0) |
| 697 |
(i32.const 0) |
| 698 |
) |
| 699 |
(call_indirect (type 3) |
| 700 |
(f64.const 0) (i64.const 0) (f64.const 0) (i64.const 0) |
| 701 |
(f64.const 0) (i64.const 0) (f32.const 0) (i32.const 0) |
| 702 |
(i32.const 2) |
| 703 |
) |
| 704 |
(call_indirect (type 3) |
| 705 |
(f64.const 0) (i64.const 0) (f64.const 0) (i64.const 0) |
| 706 |
(f64.const 0) (i64.const 0) (f32.const 0) (i32.const 0) |
| 707 |
(i32.const 3) |
| 708 |
) |
| 709 |
) |
| 710 |
|
| 711 |
(func (export "signature-explicit-duplicate") |
| 712 |
(call_indirect (type $$empty-sig-duplicate) (i32.const 1)) |
| 713 |
) |
| 714 |
|
| 715 |
(func (export "signature-implicit-duplicate") |
| 716 |
(call_indirect (type $$complex-sig-duplicate) |
| 717 |
(i64.const 0) (i64.const 0) (f64.const 0) (i64.const 0) |
| 718 |
(f64.const 0) (i64.const 0) (f32.const 0) (i32.const 0) |
| 719 |
(i32.const 5) |
| 720 |
) |
| 721 |
(call_indirect (type $$complex-sig-duplicate) |
| 722 |
(i64.const 0) (i64.const 0) (f64.const 0) (i64.const 0) |
| 723 |
(f64.const 0) (i64.const 0) (f32.const 0) (i32.const 0) |
| 724 |
(i32.const 6) |
| 725 |
) |
| 726 |
) |
| 727 |
)`); |
| 728 |
|
| 729 |
// ./test/core/func.wast:551 |
| 730 |
assert_return(() => invoke($3, `signature-explicit-reused`, []), []); |
| 731 |
|
| 732 |
// ./test/core/func.wast:552 |
| 733 |
assert_return(() => invoke($3, `signature-implicit-reused`, []), []); |
| 734 |
|
| 735 |
// ./test/core/func.wast:553 |
| 736 |
assert_return(() => invoke($3, `signature-explicit-duplicate`, []), []); |
| 737 |
|
| 738 |
// ./test/core/func.wast:554 |
| 739 |
assert_return(() => invoke($3, `signature-implicit-duplicate`, []), []); |
| 740 |
|
| 741 |
// ./test/core/func.wast:559 |
| 742 |
assert_malformed( |
| 743 |
() => instantiate(`(type $$sig (func (param i32) (result i32))) (func (type $$sig) (result i32) (param i32) (i32.const 0)) `), |
| 744 |
`unexpected token`, |
| 745 |
); |
| 746 |
|
| 747 |
// ./test/core/func.wast:566 |
| 748 |
assert_malformed( |
| 749 |
() => instantiate(`(type $$sig (func (param i32) (result i32))) (func (param i32) (type $$sig) (result i32) (i32.const 0)) `), |
| 750 |
`unexpected token`, |
| 751 |
); |
| 752 |
|
| 753 |
// ./test/core/func.wast:573 |
| 754 |
assert_malformed( |
| 755 |
() => instantiate(`(type $$sig (func (param i32) (result i32))) (func (param i32) (result i32) (type $$sig) (i32.const 0)) `), |
| 756 |
`unexpected token`, |
| 757 |
); |
| 758 |
|
| 759 |
// ./test/core/func.wast:580 |
| 760 |
assert_malformed( |
| 761 |
() => instantiate(`(type $$sig (func (param i32) (result i32))) (func (result i32) (type $$sig) (param i32) (i32.const 0)) `), |
| 762 |
`unexpected token`, |
| 763 |
); |
| 764 |
|
| 765 |
// ./test/core/func.wast:587 |
| 766 |
assert_malformed( |
| 767 |
() => instantiate(`(type $$sig (func (param i32) (result i32))) (func (result i32) (param i32) (type $$sig) (i32.const 0)) `), |
| 768 |
`unexpected token`, |
| 769 |
); |
| 770 |
|
| 771 |
// ./test/core/func.wast:594 |
| 772 |
assert_malformed( |
| 773 |
() => instantiate(`(func (result i32) (param i32) (i32.const 0)) `), |
| 774 |
`unexpected token`, |
| 775 |
); |
| 776 |
|
| 777 |
// ./test/core/func.wast:601 |
| 778 |
assert_malformed( |
| 779 |
() => instantiate(`(type $$sig (func)) (func (type $$sig) (result i32) (i32.const 0)) `), |
| 780 |
`inline function type`, |
| 781 |
); |
| 782 |
|
| 783 |
// ./test/core/func.wast:608 |
| 784 |
assert_malformed( |
| 785 |
() => instantiate(`(type $$sig (func (param i32) (result i32))) (func (type $$sig) (result i32) (i32.const 0)) `), |
| 786 |
`inline function type`, |
| 787 |
); |
| 788 |
|
| 789 |
// ./test/core/func.wast:615 |
| 790 |
assert_malformed( |
| 791 |
() => instantiate(`(type $$sig (func (param i32) (result i32))) (func (type $$sig) (param i32) (i32.const 0)) `), |
| 792 |
`inline function type`, |
| 793 |
); |
| 794 |
|
| 795 |
// ./test/core/func.wast:622 |
| 796 |
assert_malformed( |
| 797 |
() => instantiate(`(type $$sig (func (param i32 i32) (result i32))) (func (type $$sig) (param i32) (result i32) (unreachable)) `), |
| 798 |
`inline function type`, |
| 799 |
); |
| 800 |
|
| 801 |
// ./test/core/func.wast:633 |
| 802 |
assert_invalid( |
| 803 |
() => instantiate(`(module (func $$type-local-num-vs-num (result i64) (local i32) (local.get 0)))`), |
| 804 |
`type mismatch`, |
| 805 |
); |
| 806 |
|
| 807 |
// ./test/core/func.wast:637 |
| 808 |
assert_invalid( |
| 809 |
() => instantiate(`(module (func $$type-local-num-vs-num (local f32) (i32.eqz (local.get 0))))`), |
| 810 |
`type mismatch`, |
| 811 |
); |
| 812 |
|
| 813 |
// ./test/core/func.wast:641 |
| 814 |
assert_invalid( |
| 815 |
() => instantiate(`(module (func $$type-local-num-vs-num (local f64 i64) (f64.neg (local.get 1))))`), |
| 816 |
`type mismatch`, |
| 817 |
); |
| 818 |
|
| 819 |
// ./test/core/func.wast:649 |
| 820 |
assert_invalid( |
| 821 |
() => instantiate(`(module (func $$type-param-num-vs-num (param i32) (result i64) (local.get 0)))`), |
| 822 |
`type mismatch`, |
| 823 |
); |
| 824 |
|
| 825 |
// ./test/core/func.wast:653 |
| 826 |
assert_invalid( |
| 827 |
() => instantiate(`(module (func $$type-param-num-vs-num (param f32) (i32.eqz (local.get 0))))`), |
| 828 |
`type mismatch`, |
| 829 |
); |
| 830 |
|
| 831 |
// ./test/core/func.wast:657 |
| 832 |
assert_invalid( |
| 833 |
() => instantiate(`(module (func $$type-param-num-vs-num (param f64 i64) (f64.neg (local.get 1))))`), |
| 834 |
`type mismatch`, |
| 835 |
); |
| 836 |
|
| 837 |
// ./test/core/func.wast:665 |
| 838 |
assert_invalid( |
| 839 |
() => instantiate(`(module (func $$type-empty-i32 (result i32)))`), |
| 840 |
`type mismatch`, |
| 841 |
); |
| 842 |
|
| 843 |
// ./test/core/func.wast:669 |
| 844 |
assert_invalid( |
| 845 |
() => instantiate(`(module (func $$type-empty-i64 (result i64)))`), |
| 846 |
`type mismatch`, |
| 847 |
); |
| 848 |
|
| 849 |
// ./test/core/func.wast:673 |
| 850 |
assert_invalid( |
| 851 |
() => instantiate(`(module (func $$type-empty-f32 (result f32)))`), |
| 852 |
`type mismatch`, |
| 853 |
); |
| 854 |
|
| 855 |
// ./test/core/func.wast:677 |
| 856 |
assert_invalid( |
| 857 |
() => instantiate(`(module (func $$type-empty-f64 (result f64)))`), |
| 858 |
`type mismatch`, |
| 859 |
); |
| 860 |
|
| 861 |
// ./test/core/func.wast:681 |
| 862 |
assert_invalid( |
| 863 |
() => instantiate(`(module (func $$type-empty-f64-i32 (result f64 i32)))`), |
| 864 |
`type mismatch`, |
| 865 |
); |
| 866 |
|
| 867 |
// ./test/core/func.wast:686 |
| 868 |
assert_invalid( |
| 869 |
() => instantiate(`(module (func $$type-value-void-vs-num (result i32) |
| 870 |
(nop) |
| 871 |
))`), |
| 872 |
`type mismatch`, |
| 873 |
); |
| 874 |
|
| 875 |
// ./test/core/func.wast:692 |
| 876 |
assert_invalid( |
| 877 |
() => instantiate(`(module (func $$type-value-void-vs-nums (result i32 i32) |
| 878 |
(nop) |
| 879 |
))`), |
| 880 |
`type mismatch`, |
| 881 |
); |
| 882 |
|
| 883 |
// ./test/core/func.wast:698 |
| 884 |
assert_invalid( |
| 885 |
() => instantiate(`(module (func $$type-value-num-vs-void |
| 886 |
(i32.const 0) |
| 887 |
))`), |
| 888 |
`type mismatch`, |
| 889 |
); |
| 890 |
|
| 891 |
// ./test/core/func.wast:704 |
| 892 |
assert_invalid( |
| 893 |
() => instantiate(`(module (func $$type-value-nums-vs-void |
| 894 |
(i32.const 0) (i64.const 0) |
| 895 |
))`), |
| 896 |
`type mismatch`, |
| 897 |
); |
| 898 |
|
| 899 |
// ./test/core/func.wast:710 |
| 900 |
assert_invalid( |
| 901 |
() => instantiate(`(module (func $$type-value-num-vs-num (result i32) |
| 902 |
(f32.const 0) |
| 903 |
))`), |
| 904 |
`type mismatch`, |
| 905 |
); |
| 906 |
|
| 907 |
// ./test/core/func.wast:716 |
| 908 |
assert_invalid( |
| 909 |
() => instantiate(`(module (func $$type-value-num-vs-nums (result f32 f32) |
| 910 |
(f32.const 0) |
| 911 |
))`), |
| 912 |
`type mismatch`, |
| 913 |
); |
| 914 |
|
| 915 |
// ./test/core/func.wast:722 |
| 916 |
assert_invalid( |
| 917 |
() => instantiate(`(module (func $$type-value-nums-vs-num (result f32) |
| 918 |
(f32.const 0) (f32.const 0) |
| 919 |
))`), |
| 920 |
`type mismatch`, |
| 921 |
); |
| 922 |
|
| 923 |
// ./test/core/func.wast:729 |
| 924 |
assert_invalid( |
| 925 |
() => instantiate(`(module (func $$type-return-last-empty-vs-num (result i32) |
| 926 |
(return) |
| 927 |
))`), |
| 928 |
`type mismatch`, |
| 929 |
); |
| 930 |
|
| 931 |
// ./test/core/func.wast:735 |
| 932 |
assert_invalid( |
| 933 |
() => instantiate(`(module (func $$type-return-last-empty-vs-nums (result i32 i32) |
| 934 |
(return) |
| 935 |
))`), |
| 936 |
`type mismatch`, |
| 937 |
); |
| 938 |
|
| 939 |
// ./test/core/func.wast:741 |
| 940 |
assert_invalid( |
| 941 |
() => instantiate(`(module (func $$type-return-last-void-vs-num (result i32) |
| 942 |
(return (nop)) |
| 943 |
))`), |
| 944 |
`type mismatch`, |
| 945 |
); |
| 946 |
|
| 947 |
// ./test/core/func.wast:747 |
| 948 |
assert_invalid( |
| 949 |
() => instantiate(`(module (func $$type-return-last-void-vs-nums (result i32 i64) |
| 950 |
(return (nop)) |
| 951 |
))`), |
| 952 |
`type mismatch`, |
| 953 |
); |
| 954 |
|
| 955 |
// ./test/core/func.wast:753 |
| 956 |
assert_invalid( |
| 957 |
() => instantiate(`(module (func $$type-return-last-num-vs-num (result i32) |
| 958 |
(return (i64.const 0)) |
| 959 |
))`), |
| 960 |
`type mismatch`, |
| 961 |
); |
| 962 |
|
| 963 |
// ./test/core/func.wast:759 |
| 964 |
assert_invalid( |
| 965 |
() => instantiate(`(module (func $$type-return-last-num-vs-nums (result i64 i64) |
| 966 |
(return (i64.const 0)) |
| 967 |
))`), |
| 968 |
`type mismatch`, |
| 969 |
); |
| 970 |
|
| 971 |
// ./test/core/func.wast:766 |
| 972 |
assert_invalid( |
| 973 |
() => instantiate(`(module (func $$type-return-empty-vs-num (result i32) |
| 974 |
(return) (i32.const 1) |
| 975 |
))`), |
| 976 |
`type mismatch`, |
| 977 |
); |
| 978 |
|
| 979 |
// ./test/core/func.wast:772 |
| 980 |
assert_invalid( |
| 981 |
() => instantiate(`(module (func $$type-return-empty-vs-nums (result i32 i32) |
| 982 |
(return) (i32.const 1) (i32.const 2) |
| 983 |
))`), |
| 984 |
`type mismatch`, |
| 985 |
); |
| 986 |
|
| 987 |
// ./test/core/func.wast:778 |
| 988 |
assert_invalid( |
| 989 |
() => instantiate(`(module (func $$type-return-partial-vs-nums (result i32 i32) |
| 990 |
(i32.const 1) (return) (i32.const 2) |
| 991 |
))`), |
| 992 |
`type mismatch`, |
| 993 |
); |
| 994 |
|
| 995 |
// ./test/core/func.wast:784 |
| 996 |
assert_invalid( |
| 997 |
() => instantiate(`(module (func $$type-return-void-vs-num (result i32) |
| 998 |
(return (nop)) (i32.const 1) |
| 999 |
))`), |
| 1000 |
`type mismatch`, |
| 1001 |
); |
| 1002 |
|
| 1003 |
// ./test/core/func.wast:790 |
| 1004 |
assert_invalid( |
| 1005 |
() => instantiate(`(module (func $$type-return-void-vs-nums (result i32 i32) |
| 1006 |
(return (nop)) (i32.const 1) |
| 1007 |
))`), |
| 1008 |
`type mismatch`, |
| 1009 |
); |
| 1010 |
|
| 1011 |
// ./test/core/func.wast:796 |
| 1012 |
assert_invalid( |
| 1013 |
() => instantiate(`(module (func $$type-return-num-vs-num (result i32) |
| 1014 |
(return (i64.const 1)) (i32.const 1) |
| 1015 |
))`), |
| 1016 |
`type mismatch`, |
| 1017 |
); |
| 1018 |
|
| 1019 |
// ./test/core/func.wast:802 |
| 1020 |
assert_invalid( |
| 1021 |
() => instantiate(`(module (func $$type-return-num-vs-nums (result i32 i32) |
| 1022 |
(return (i64.const 1)) (i32.const 1) (i32.const 2) |
| 1023 |
))`), |
| 1024 |
`type mismatch`, |
| 1025 |
); |
| 1026 |
|
| 1027 |
// ./test/core/func.wast:808 |
| 1028 |
assert_invalid( |
| 1029 |
() => instantiate(`(module (func $$type-return-first-num-vs-num (result i32) |
| 1030 |
(return (i64.const 1)) (return (i32.const 1)) |
| 1031 |
))`), |
| 1032 |
`type mismatch`, |
| 1033 |
); |
| 1034 |
|
| 1035 |
// ./test/core/func.wast:814 |
| 1036 |
assert_invalid( |
| 1037 |
() => instantiate(`(module (func $$type-return-first-num-vs-nums (result i32 i32) |
| 1038 |
(return (i32.const 1)) (return (i32.const 1) (i32.const 2)) |
| 1039 |
))`), |
| 1040 |
`type mismatch`, |
| 1041 |
); |
| 1042 |
|
| 1043 |
// ./test/core/func.wast:821 |
| 1044 |
assert_invalid( |
| 1045 |
() => instantiate(`(module (func $$type-break-last-void-vs-num (result i32) |
| 1046 |
(br 0) |
| 1047 |
))`), |
| 1048 |
`type mismatch`, |
| 1049 |
); |
| 1050 |
|
| 1051 |
// ./test/core/func.wast:827 |
| 1052 |
assert_invalid( |
| 1053 |
() => instantiate(`(module (func $$type-break-last-void-vs-nums (result i32 i32) |
| 1054 |
(br 0) |
| 1055 |
))`), |
| 1056 |
`type mismatch`, |
| 1057 |
); |
| 1058 |
|
| 1059 |
// ./test/core/func.wast:833 |
| 1060 |
assert_invalid( |
| 1061 |
() => instantiate(`(module (func $$type-break-last-num-vs-num (result i32) |
| 1062 |
(br 0 (f32.const 0)) |
| 1063 |
))`), |
| 1064 |
`type mismatch`, |
| 1065 |
); |
| 1066 |
|
| 1067 |
// ./test/core/func.wast:839 |
| 1068 |
assert_invalid( |
| 1069 |
() => instantiate(`(module (func $$type-break-last-num-vs-nums (result i32 i32) |
| 1070 |
(br 0 (i32.const 0)) |
| 1071 |
))`), |
| 1072 |
`type mismatch`, |
| 1073 |
); |
| 1074 |
|
| 1075 |
// ./test/core/func.wast:845 |
| 1076 |
assert_invalid( |
| 1077 |
() => instantiate(`(module (func $$type-break-void-vs-num (result i32) |
| 1078 |
(br 0) (i32.const 1) |
| 1079 |
))`), |
| 1080 |
`type mismatch`, |
| 1081 |
); |
| 1082 |
|
| 1083 |
// ./test/core/func.wast:851 |
| 1084 |
assert_invalid( |
| 1085 |
() => instantiate(`(module (func $$type-break-void-vs-nums (result i32 i32) |
| 1086 |
(br 0) (i32.const 1) (i32.const 2) |
| 1087 |
))`), |
| 1088 |
`type mismatch`, |
| 1089 |
); |
| 1090 |
|
| 1091 |
// ./test/core/func.wast:857 |
| 1092 |
assert_invalid( |
| 1093 |
() => instantiate(`(module (func $$type-break-num-vs-num (result i32) |
| 1094 |
(br 0 (i64.const 1)) (i32.const 1) |
| 1095 |
))`), |
| 1096 |
`type mismatch`, |
| 1097 |
); |
| 1098 |
|
| 1099 |
// ./test/core/func.wast:863 |
| 1100 |
assert_invalid( |
| 1101 |
() => instantiate(`(module (func $$type-break-num-vs-nums (result i32 i32) |
| 1102 |
(br 0 (i32.const 1)) (i32.const 1) (i32.const 2) |
| 1103 |
))`), |
| 1104 |
`type mismatch`, |
| 1105 |
); |
| 1106 |
|
| 1107 |
// ./test/core/func.wast:869 |
| 1108 |
assert_invalid( |
| 1109 |
() => instantiate(`(module (func $$type-break-first-num-vs-num (result i32) |
| 1110 |
(br 0 (i64.const 1)) (br 0 (i32.const 1)) |
| 1111 |
))`), |
| 1112 |
`type mismatch`, |
| 1113 |
); |
| 1114 |
|
| 1115 |
// ./test/core/func.wast:876 |
| 1116 |
assert_invalid( |
| 1117 |
() => instantiate(`(module (func $$type-break-nested-empty-vs-num (result i32) |
| 1118 |
(block (br 1)) (br 0 (i32.const 1)) |
| 1119 |
))`), |
| 1120 |
`type mismatch`, |
| 1121 |
); |
| 1122 |
|
| 1123 |
// ./test/core/func.wast:882 |
| 1124 |
assert_invalid( |
| 1125 |
() => instantiate(`(module (func $$type-break-nested-empty-vs-nums (result i32 i32) |
| 1126 |
(block (br 1)) (br 0 (i32.const 1) (i32.const 2)) |
| 1127 |
))`), |
| 1128 |
`type mismatch`, |
| 1129 |
); |
| 1130 |
|
| 1131 |
// ./test/core/func.wast:888 |
| 1132 |
assert_invalid( |
| 1133 |
() => instantiate(`(module (func $$type-break-nested-void-vs-num (result i32) |
| 1134 |
(block (br 1 (nop))) (br 0 (i32.const 1)) |
| 1135 |
))`), |
| 1136 |
`type mismatch`, |
| 1137 |
); |
| 1138 |
|
| 1139 |
// ./test/core/func.wast:894 |
| 1140 |
assert_invalid( |
| 1141 |
() => instantiate(`(module (func $$type-break-nested-void-vs-nums (result i32 i32) |
| 1142 |
(block (br 1 (nop))) (br 0 (i32.const 1) (i32.const 2)) |
| 1143 |
))`), |
| 1144 |
`type mismatch`, |
| 1145 |
); |
| 1146 |
|
| 1147 |
// ./test/core/func.wast:900 |
| 1148 |
assert_invalid( |
| 1149 |
() => instantiate(`(module (func $$type-break-nested-num-vs-num (result i32) |
| 1150 |
(block (br 1 (i64.const 1))) (br 0 (i32.const 1)) |
| 1151 |
))`), |
| 1152 |
`type mismatch`, |
| 1153 |
); |
| 1154 |
|
| 1155 |
// ./test/core/func.wast:906 |
| 1156 |
assert_invalid( |
| 1157 |
() => instantiate(`(module (func $$type-break-nested-num-vs-nums (result i32 i32) |
| 1158 |
(block (result i32) (br 1 (i32.const 1))) (br 0 (i32.const 1) (i32.const 2)) |
| 1159 |
))`), |
| 1160 |
`type mismatch`, |
| 1161 |
); |
| 1162 |
|
| 1163 |
// ./test/core/func.wast:916 |
| 1164 |
assert_malformed(() => instantiate(`(func (nop) (local i32)) `), `unexpected token`); |
| 1165 |
|
| 1166 |
// ./test/core/func.wast:920 |
| 1167 |
assert_malformed(() => instantiate(`(func (nop) (param i32)) `), `unexpected token`); |
| 1168 |
|
| 1169 |
// ./test/core/func.wast:924 |
| 1170 |
assert_malformed(() => instantiate(`(func (nop) (result i32)) `), `unexpected token`); |
| 1171 |
|
| 1172 |
// ./test/core/func.wast:928 |
| 1173 |
assert_malformed(() => instantiate(`(func (local i32) (param i32)) `), `unexpected token`); |
| 1174 |
|
| 1175 |
// ./test/core/func.wast:932 |
| 1176 |
assert_malformed( |
| 1177 |
() => instantiate(`(func (local i32) (result i32) (local.get 0)) `), |
| 1178 |
`unexpected token`, |
| 1179 |
); |
| 1180 |
|
| 1181 |
// ./test/core/func.wast:936 |
| 1182 |
assert_malformed( |
| 1183 |
() => instantiate(`(func (result i32) (param i32) (local.get 0)) `), |
| 1184 |
`unexpected token`, |
| 1185 |
); |
| 1186 |
|
| 1187 |
// ./test/core/func.wast:943 |
| 1188 |
assert_malformed(() => instantiate(`(func $$foo) (func $$foo) `), `duplicate func`); |
| 1189 |
|
| 1190 |
// ./test/core/func.wast:947 |
| 1191 |
assert_malformed( |
| 1192 |
() => instantiate(`(import "" "" (func $$foo)) (func $$foo) `), |
| 1193 |
`duplicate func`, |
| 1194 |
); |
| 1195 |
|
| 1196 |
// ./test/core/func.wast:951 |
| 1197 |
assert_malformed( |
| 1198 |
() => instantiate(`(import "" "" (func $$foo)) (import "" "" (func $$foo)) `), |
| 1199 |
`duplicate func`, |
| 1200 |
); |
| 1201 |
|
| 1202 |
// ./test/core/func.wast:956 |
| 1203 |
assert_malformed( |
| 1204 |
() => instantiate(`(func (param $$foo i32) (param $$foo i32)) `), |
| 1205 |
`duplicate local`, |
| 1206 |
); |
| 1207 |
|
| 1208 |
// ./test/core/func.wast:958 |
| 1209 |
assert_malformed( |
| 1210 |
() => instantiate(`(func (param $$foo i32) (local $$foo i32)) `), |
| 1211 |
`duplicate local`, |
| 1212 |
); |
| 1213 |
|
| 1214 |
// ./test/core/func.wast:960 |
| 1215 |
assert_malformed( |
| 1216 |
() => instantiate(`(func (local $$foo i32) (local $$foo i32)) `), |
| 1217 |
`duplicate local`, |
| 1218 |
); |