tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

binary.wast.js (48867B)


      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/binary.wast
     17 
     18 // ./test/core/binary.wast:1
     19 let $0 = instantiate(`(module binary "\\00asm\\01\\00\\00\\00")`);
     20 
     21 // ./test/core/binary.wast:2
     22 let $1 = instantiate(`(module binary "\\00asm" "\\01\\00\\00\\00")`);
     23 
     24 // ./test/core/binary.wast:3
     25 let $2 = instantiate(`(module \$M1 binary "\\00asm\\01\\00\\00\\00")`);
     26 let $M1 = $2;
     27 
     28 // ./test/core/binary.wast:4
     29 let $3 = instantiate(`(module \$M2 binary "\\00asm" "\\01\\00\\00\\00")`);
     30 let $M2 = $3;
     31 
     32 // ./test/core/binary.wast:6
     33 assert_malformed(() => instantiate(`(module binary "")`), `unexpected end`);
     34 
     35 // ./test/core/binary.wast:7
     36 assert_malformed(() => instantiate(`(module binary "\\01")`), `unexpected end`);
     37 
     38 // ./test/core/binary.wast:8
     39 assert_malformed(() => instantiate(`(module binary "\\00as")`), `unexpected end`);
     40 
     41 // ./test/core/binary.wast:9
     42 assert_malformed(
     43  () => instantiate(`(module binary "asm\\00")`),
     44  `magic header not detected`,
     45 );
     46 
     47 // ./test/core/binary.wast:10
     48 assert_malformed(
     49  () => instantiate(`(module binary "msa\\00")`),
     50  `magic header not detected`,
     51 );
     52 
     53 // ./test/core/binary.wast:11
     54 assert_malformed(
     55  () => instantiate(`(module binary "msa\\00\\01\\00\\00\\00")`),
     56  `magic header not detected`,
     57 );
     58 
     59 // ./test/core/binary.wast:12
     60 assert_malformed(
     61  () => instantiate(`(module binary "msa\\00\\00\\00\\00\\01")`),
     62  `magic header not detected`,
     63 );
     64 
     65 // ./test/core/binary.wast:13
     66 assert_malformed(
     67  () => instantiate(`(module binary "asm\\01\\00\\00\\00\\00")`),
     68  `magic header not detected`,
     69 );
     70 
     71 // ./test/core/binary.wast:14
     72 assert_malformed(
     73  () => instantiate(`(module binary "wasm\\01\\00\\00\\00")`),
     74  `magic header not detected`,
     75 );
     76 
     77 // ./test/core/binary.wast:15
     78 assert_malformed(
     79  () => instantiate(`(module binary "\\7fasm\\01\\00\\00\\00")`),
     80  `magic header not detected`,
     81 );
     82 
     83 // ./test/core/binary.wast:16
     84 assert_malformed(
     85  () => instantiate(`(module binary "\\80asm\\01\\00\\00\\00")`),
     86  `magic header not detected`,
     87 );
     88 
     89 // ./test/core/binary.wast:17
     90 assert_malformed(
     91  () => instantiate(`(module binary "\\82asm\\01\\00\\00\\00")`),
     92  `magic header not detected`,
     93 );
     94 
     95 // ./test/core/binary.wast:18
     96 assert_malformed(
     97  () => instantiate(`(module binary "\\ffasm\\01\\00\\00\\00")`),
     98  `magic header not detected`,
     99 );
    100 
    101 // ./test/core/binary.wast:21
    102 assert_malformed(
    103  () => instantiate(`(module binary "\\00\\00\\00\\01msa\\00")`),
    104  `magic header not detected`,
    105 );
    106 
    107 // ./test/core/binary.wast:24
    108 assert_malformed(
    109  () => instantiate(`(module binary "a\\00ms\\00\\01\\00\\00")`),
    110  `magic header not detected`,
    111 );
    112 
    113 // ./test/core/binary.wast:25
    114 assert_malformed(
    115  () => instantiate(`(module binary "sm\\00a\\00\\00\\01\\00")`),
    116  `magic header not detected`,
    117 );
    118 
    119 // ./test/core/binary.wast:28
    120 assert_malformed(
    121  () => instantiate(`(module binary "\\00ASM\\01\\00\\00\\00")`),
    122  `magic header not detected`,
    123 );
    124 
    125 // ./test/core/binary.wast:31
    126 assert_malformed(
    127  () => instantiate(`(module binary "\\00\\81\\a2\\94\\01\\00\\00\\00")`),
    128  `magic header not detected`,
    129 );
    130 
    131 // ./test/core/binary.wast:34
    132 assert_malformed(
    133  () => instantiate(`(module binary "\\ef\\bb\\bf\\00asm\\01\\00\\00\\00")`),
    134  `magic header not detected`,
    135 );
    136 
    137 // ./test/core/binary.wast:37
    138 assert_malformed(() => instantiate(`(module binary "\\00asm")`), `unexpected end`);
    139 
    140 // ./test/core/binary.wast:38
    141 assert_malformed(() => instantiate(`(module binary "\\00asm\\01")`), `unexpected end`);
    142 
    143 // ./test/core/binary.wast:39
    144 assert_malformed(
    145  () => instantiate(`(module binary "\\00asm\\01\\00\\00")`),
    146  `unexpected end`,
    147 );
    148 
    149 // ./test/core/binary.wast:40
    150 assert_malformed(
    151  () => instantiate(`(module binary "\\00asm\\00\\00\\00\\00")`),
    152  `unknown binary version`,
    153 );
    154 
    155 // ./test/core/binary.wast:41
    156 assert_malformed(
    157  () => instantiate(`(module binary "\\00asm\\0d\\00\\00\\00")`),
    158  `unknown binary version`,
    159 );
    160 
    161 // ./test/core/binary.wast:42
    162 assert_malformed(
    163  () => instantiate(`(module binary "\\00asm\\0e\\00\\00\\00")`),
    164  `unknown binary version`,
    165 );
    166 
    167 // ./test/core/binary.wast:43
    168 assert_malformed(
    169  () => instantiate(`(module binary "\\00asm\\00\\01\\00\\00")`),
    170  `unknown binary version`,
    171 );
    172 
    173 // ./test/core/binary.wast:44
    174 assert_malformed(
    175  () => instantiate(`(module binary "\\00asm\\00\\00\\01\\00")`),
    176  `unknown binary version`,
    177 );
    178 
    179 // ./test/core/binary.wast:45
    180 assert_malformed(
    181  () => instantiate(`(module binary "\\00asm\\00\\00\\00\\01")`),
    182  `unknown binary version`,
    183 );
    184 
    185 // ./test/core/binary.wast:48
    186 assert_malformed(
    187  () => instantiate(`(module binary "\\00asm" "\\01\\00\\00\\00" "\\0e\\01\\00")`),
    188  `malformed section id`,
    189 );
    190 
    191 // ./test/core/binary.wast:49
    192 assert_malformed(
    193  () => instantiate(`(module binary "\\00asm" "\\01\\00\\00\\00" "\\7f\\01\\00")`),
    194  `malformed section id`,
    195 );
    196 
    197 // ./test/core/binary.wast:50
    198 assert_malformed(
    199  () => instantiate(`(module binary "\\00asm" "\\01\\00\\00\\00" "\\80\\01\\00\\01\\01\\00")`),
    200  `malformed section id`,
    201 );
    202 
    203 // ./test/core/binary.wast:51
    204 assert_malformed(
    205  () => instantiate(`(module binary "\\00asm" "\\01\\00\\00\\00" "\\81\\01\\00\\01\\01\\00")`),
    206  `malformed section id`,
    207 );
    208 
    209 // ./test/core/binary.wast:52
    210 assert_malformed(
    211  () => instantiate(`(module binary "\\00asm" "\\01\\00\\00\\00" "\\ff\\01\\00\\01\\01\\00")`),
    212  `malformed section id`,
    213 );
    214 
    215 // ./test/core/binary.wast:55
    216 assert_malformed(
    217  () => instantiate(`(module binary
    218    "\\00asm" "\\01\\00\\00\\00"
    219    "\\01\\04\\01\\60\\00\\00"       ;; Type section: 1 type
    220    "\\03\\03\\02\\00\\00"          ;; Function section: 2 functions
    221    "\\0a\\0c\\02"                ;; Code section: 2 functions
    222    ;; function 0
    223    "\\04\\00"                   ;; Function size and local type count
    224    "\\41\\01"                   ;; i32.const 1
    225    "\\1a"                      ;; drop
    226    ;; Missing end marker here
    227    ;; function 1
    228    "\\05\\00"                   ;; Function size and local type count
    229    "\\41\\01"                   ;; i32.const 1
    230    "\\1a"                      ;; drop
    231    "\\0b"                      ;; end
    232  )`),
    233  `END opcode expected`,
    234 );
    235 
    236 // ./test/core/binary.wast:76
    237 assert_malformed(
    238  () => instantiate(`(module binary
    239    "\\00asm" "\\01\\00\\00\\00"
    240    "\\01\\04\\01\\60\\00\\00"       ;; Type section: 1 type
    241    "\\03\\02\\01\\00"             ;; Function section: 1 function
    242    "\\0a\\06\\01"                ;; Code section: 1 function
    243    ;; function 0
    244    "\\04\\00"                   ;; Function size and local type count
    245    "\\41\\01"                   ;; i32.const 1
    246    "\\1a"                      ;; drop
    247    ;; Missing end marker here
    248  )`),
    249  `unexpected end of section or function`,
    250 );
    251 
    252 // ./test/core/binary.wast:92
    253 assert_malformed(
    254  () => instantiate(`(module binary
    255    "\\00asm" "\\01\\00\\00\\00"
    256    "\\01\\04\\01\\60\\00\\00"       ;; Type section: 1 type
    257    "\\03\\02\\01\\00"             ;; Function section: 1 function
    258    "\\0a\\06\\01"                ;; Code section: 1 function
    259    ;; function 0
    260    "\\04\\00"                   ;; Function size and local type count
    261    "\\41\\01"                   ;; i32.const 1
    262    "\\1a"                      ;; drop
    263    ;; Missing end marker here
    264    "\\0b\\03\\01\\01\\00"          ;; Data section
    265  )`),
    266  `section size mismatch`,
    267 );
    268 
    269 // ./test/core/binary.wast:112
    270 assert_malformed(
    271  () => instantiate(`(module binary
    272    "\\00asm" "\\01\\00\\00\\00"
    273    "\\01\\04\\01\\60\\00\\00"       ;; Type section: 1 type
    274    "\\03\\02\\01\\00"             ;; Function section: 1 function
    275    "\\06\\05\\01\\7f\\00\\41\\00"    ;; Global section: 1 entry with missing end marker
    276    ;; Missing end marker here
    277    "\\0a\\04\\01\\02\\00\\0b"       ;; Code section: 1 function
    278  )`),
    279  `unexpected end of section or function`,
    280 );
    281 
    282 // ./test/core/binary.wast:125
    283 assert_malformed(
    284  () => instantiate(`(module binary
    285    "\\00asm" "\\01\\00\\00\\00"
    286    "\\01\\04\\01\\60\\00\\00"       ;; Type section
    287    "\\03\\02\\01\\00"             ;; Function section
    288    "\\0a\\0c\\01"                ;; Code section
    289 
    290    ;; function 0
    291    "\\0a\\02"
    292    "\\80\\80\\80\\80\\10\\7f"       ;; 0x100000000 i32
    293    "\\02\\7e"                   ;; 0x00000002 i64
    294    "\\0b"                      ;; end
    295  )`),
    296  `integer too large`,
    297 );
    298 
    299 // ./test/core/binary.wast:142
    300 assert_malformed(
    301  () => instantiate(`(module binary
    302    "\\00asm" "\\01\\00\\00\\00"
    303    "\\01\\04\\01\\60\\00\\00"       ;; Type section
    304    "\\03\\02\\01\\00"             ;; Function section
    305    "\\0a\\0c\\01"                ;; Code section
    306 
    307    ;; function 0
    308    "\\0a\\02"
    309    "\\80\\80\\80\\80\\10\\7f"       ;; 0x100000000 i32
    310    "\\02\\7e"                   ;; 0x00000002 i64
    311    "\\0b"                      ;; end
    312  )`),
    313  `integer too large`,
    314 );
    315 
    316 // ./test/core/binary.wast:159
    317 assert_malformed(
    318  () => instantiate(`(module binary
    319    "\\00asm" "\\01\\00\\00\\00"
    320    "\\01\\04\\01\\60\\00\\00"       ;; Type section
    321    "\\03\\02\\01\\00"             ;; Function section
    322    "\\0a\\0c\\01"                ;; Code section
    323 
    324    ;; function 0
    325    "\\0a\\02"
    326    "\\ff\\ff\\ff\\ff\\0f\\7f"       ;; 0xFFFFFFFF i32
    327    "\\02\\7e"                   ;; 0x00000002 i64
    328    "\\0b"                      ;; end
    329  )`),
    330  `too many locals`,
    331 );
    332 
    333 // ./test/core/binary.wast:175
    334 assert_malformed(
    335  () => instantiate(`(module binary
    336    "\\00asm" "\\01\\00\\00\\00"
    337    "\\01\\06\\01\\60\\02\\7f\\7f\\00" ;; Type section: (param i32 i32)
    338    "\\03\\02\\01\\00"             ;; Function section
    339    "\\0a\\1c\\01"                ;; Code section
    340 
    341    ;; function 0
    342    "\\1a\\04"
    343    "\\80\\80\\80\\80\\04\\7f"       ;; 0x40000000 i32
    344    "\\80\\80\\80\\80\\04\\7e"       ;; 0x40000000 i64
    345    "\\80\\80\\80\\80\\04\\7d"       ;; 0x40000000 f32
    346    "\\80\\80\\80\\80\\04\\7c"       ;; 0x40000000 f64
    347    "\\0b"                      ;; end
    348  )`),
    349  `too many locals`,
    350 );
    351 
    352 // ./test/core/binary.wast:194
    353 let $4 = instantiate(`(module binary
    354  "\\00asm" "\\01\\00\\00\\00"
    355  "\\01\\04\\01\\60\\00\\00"     ;; Type section
    356  "\\03\\02\\01\\00"           ;; Function section
    357  "\\0a\\0a\\01"              ;; Code section
    358 
    359  ;; function 0
    360  "\\08\\03"
    361  "\\00\\7f"                 ;; 0 i32
    362  "\\00\\7e"                 ;; 0 i64
    363  "\\02\\7d"                 ;; 2 f32
    364  "\\0b"                    ;; end
    365 )`);
    366 
    367 // ./test/core/binary.wast:209
    368 assert_malformed(
    369  () => instantiate(`(module binary
    370    "\\00asm" "\\01\\00\\00\\00"
    371    "\\01\\04\\01\\60\\00\\00"  ;; Type section
    372    "\\03\\03\\02\\00\\00"     ;; Function section with 2 functions
    373  )`),
    374  `function and code section have inconsistent lengths`,
    375 );
    376 
    377 // ./test/core/binary.wast:219
    378 assert_malformed(
    379  () => instantiate(`(module binary
    380    "\\00asm" "\\01\\00\\00\\00"
    381    "\\0a\\04\\01\\02\\00\\0b"  ;; Code section with 1 empty function
    382  )`),
    383  `function and code section have inconsistent lengths`,
    384 );
    385 
    386 // ./test/core/binary.wast:228
    387 assert_malformed(
    388  () => instantiate(`(module binary
    389    "\\00asm" "\\01\\00\\00\\00"
    390    "\\01\\04\\01\\60\\00\\00"  ;; Type section
    391    "\\03\\03\\02\\00\\00"     ;; Function section with 2 functions
    392    "\\0a\\04\\01\\02\\00\\0b"  ;; Code section with 1 empty function
    393  )`),
    394  `function and code section have inconsistent lengths`,
    395 );
    396 
    397 // ./test/core/binary.wast:239
    398 assert_malformed(
    399  () => instantiate(`(module binary
    400    "\\00asm" "\\01\\00\\00\\00"
    401    "\\01\\04\\01\\60\\00\\00"           ;; Type section
    402    "\\03\\02\\01\\00"                 ;; Function section with 1 function
    403    "\\0a\\07\\02\\02\\00\\0b\\02\\00\\0b"  ;; Code section with 2 empty functions
    404  )`),
    405  `function and code section have inconsistent lengths`,
    406 );
    407 
    408 // ./test/core/binary.wast:250
    409 let $5 = instantiate(`(module binary
    410  "\\00asm" "\\01\\00\\00\\00"
    411  "\\03\\01\\00"  ;; Function section with 0 functions
    412 )`);
    413 
    414 // ./test/core/binary.wast:256
    415 let $6 = instantiate(`(module binary
    416  "\\00asm" "\\01\\00\\00\\00"
    417  "\\0a\\01\\00"  ;; Code section with 0 functions
    418 )`);
    419 
    420 // ./test/core/binary.wast:262
    421 assert_malformed(
    422  () => instantiate(`(module binary
    423    "\\00asm" "\\01\\00\\00\\00"
    424    "\\0c\\01\\03"                ;; Data count section with value 3
    425    "\\0b\\05\\02"                ;; Data section with two entries
    426    "\\01\\00"                   ;; Passive data section
    427    "\\01\\00"                   ;; Passive data section
    428  )`),
    429  `data count and data section have inconsistent lengths`,
    430 );
    431 
    432 // ./test/core/binary.wast:274
    433 assert_malformed(
    434  () => instantiate(`(module binary
    435    "\\00asm" "\\01\\00\\00\\00"
    436    "\\0c\\01\\01"                ;; Data count section with value 1
    437    "\\0b\\05\\02"                ;; Data section with two entries
    438    "\\01\\00"                   ;; Passive data section
    439    "\\01\\00"                   ;; Passive data section
    440  )`),
    441  `data count and data section have inconsistent lengths`,
    442 );
    443 
    444 // ./test/core/binary.wast:286
    445 assert_malformed(
    446  () => instantiate(`(module binary
    447    "\\00asm" "\\01\\00\\00\\00"
    448    "\\05\\03\\01\\00\\01"          ;; Memory section with one entry
    449    "\\0c\\01\\01"                ;; Data count section with value 1
    450  )`),
    451  `data count and data section have inconsistent lengths`,
    452 );
    453 
    454 // ./test/core/binary.wast:296
    455 let $7 = instantiate(`(module binary
    456  "\\00asm" "\\01\\00\\00\\00"
    457  "\\0c\\01\\00"                  ;; Data count section with value 0
    458 )`);
    459 
    460 // ./test/core/binary.wast:302
    461 assert_malformed(
    462  () => instantiate(`(module binary
    463    "\\00asm" "\\01\\00\\00\\00"
    464 
    465    "\\01\\04\\01\\60\\00\\00"       ;; Type section
    466    "\\03\\02\\01\\00"             ;; Function section
    467    "\\05\\03\\01\\00\\00"          ;; Memory section
    468    "\\0a\\0e\\01"                ;; Code section
    469 
    470    ;; function 0
    471    "\\0c\\00"
    472    "\\41\\00"                   ;; zero args
    473    "\\41\\00"
    474    "\\41\\00"
    475    "\\fc\\08\\00\\00"             ;; memory.init
    476    "\\0b"
    477 
    478    "\\0b\\03\\01\\01\\00"          ;; Data section
    479  )`),
    480  `data count section required`,
    481 );
    482 
    483 // ./test/core/binary.wast:325
    484 assert_malformed(
    485  () => instantiate(`(module binary
    486    "\\00asm" "\\01\\00\\00\\00"
    487 
    488    "\\01\\04\\01\\60\\00\\00"       ;; Type section
    489    "\\03\\02\\01\\00"             ;; Function section
    490    "\\05\\03\\01\\00\\00"          ;; Memory section
    491    "\\0a\\07\\01"                ;; Code section
    492 
    493    ;; function 0
    494    "\\05\\00"
    495    "\\fc\\09\\00"                ;; data.drop
    496    "\\0b"
    497 
    498    "\\0b\\03\\01\\01\\00"          ;; Data section
    499  )`),
    500  `data count section required`,
    501 );
    502 
    503 // ./test/core/binary.wast:345
    504 assert_malformed(
    505  () => instantiate(`(module binary
    506    "\\00asm" "\\01\\00\\00\\00"
    507 
    508    "\\01\\04\\01\\60\\00\\00"       ;; Type section
    509 
    510    "\\03\\02\\01\\00"             ;; Function section
    511 
    512    "\\04\\04\\01"                ;; Table section with 1 entry
    513    "\\70\\00\\00"                ;; no max, minimum 0, funcref
    514 
    515    "\\05\\03\\01\\00\\00"          ;; Memory section
    516 
    517    "\\09\\07\\01"                ;; Element section with one segment
    518    "\\05\\70"                   ;; Passive, funcref
    519    "\\01"                      ;; 1 element
    520    "\\f3\\00\\0b"                ;; bad opcode, index 0, end
    521 
    522    "\\0a\\04\\01"                ;; Code section
    523 
    524    ;; function 0
    525    "\\02\\00"
    526    "\\0b"                      ;; end
    527  )`),
    528  `illegal opcode`,
    529 );
    530 
    531 // ./test/core/binary.wast:373
    532 assert_malformed(
    533  () => instantiate(`(module binary
    534    "\\00asm" "\\01\\00\\00\\00"
    535 
    536    "\\01\\04\\01\\60\\00\\00"       ;; Type section
    537 
    538    "\\03\\02\\01\\00"             ;; Function section
    539 
    540    "\\04\\04\\01"                ;; Table section with 1 entry
    541    "\\70\\00\\00"                ;; no max, minimum 0, funcref
    542 
    543    "\\05\\03\\01\\00\\00"          ;; Memory section
    544 
    545    "\\09\\07\\01"                ;; Element section with one segment
    546    "\\05\\7f"                   ;; Passive, i32
    547    "\\01"                      ;; 1 element
    548    "\\d2\\00\\0b"                ;; ref.func, index 0, end
    549 
    550    "\\0a\\04\\01"                ;; Code section
    551 
    552    ;; function 0
    553    "\\02\\00"
    554    "\\0b"                      ;; end
    555  )`),
    556  `malformed reference type`,
    557 );
    558 
    559 // ./test/core/binary.wast:401
    560 let $8 = instantiate(`(module binary
    561  "\\00asm" "\\01\\00\\00\\00"
    562 
    563  "\\01\\04\\01\\60\\00\\00"       ;; Type section
    564 
    565  "\\03\\02\\01\\00"             ;; Function section
    566 
    567  "\\04\\04\\01"                ;; Table section with 1 entry
    568  "\\70\\00\\00"                ;; no max, minimum 0, funcref
    569 
    570  "\\05\\03\\01\\00\\00"          ;; Memory section
    571 
    572  "\\09\\07\\01"                ;; Element section with one segment
    573  "\\05\\70"                   ;; Passive, funcref
    574  "\\01"                      ;; 1 element
    575  "\\d2\\00\\0b"                ;; ref.func, index 0, end
    576 
    577  "\\0a\\04\\01"                ;; Code section
    578 
    579  ;; function 0
    580  "\\02\\00"
    581  "\\0b"                      ;; end
    582 )`);
    583 
    584 // ./test/core/binary.wast:426
    585 let $9 = instantiate(`(module binary
    586  "\\00asm" "\\01\\00\\00\\00"
    587 
    588  "\\01\\04\\01\\60\\00\\00"       ;; Type section
    589 
    590  "\\03\\02\\01\\00"             ;; Function section
    591 
    592  "\\04\\04\\01"                ;; Table section with 1 entry
    593  "\\70\\00\\00"                ;; no max, minimum 0, funcref
    594 
    595  "\\05\\03\\01\\00\\00"          ;; Memory section
    596 
    597  "\\09\\07\\01"                ;; Element section with one segment
    598  "\\05\\70"                   ;; Passive, funcref
    599  "\\01"                      ;; 1 element
    600  "\\d0\\70\\0b"                ;; ref.null, end
    601 
    602  "\\0a\\04\\01"                ;; Code section
    603 
    604  ;; function 0
    605  "\\02\\00"
    606  "\\0b"                      ;; end
    607 )`);
    608 
    609 // ./test/core/binary.wast:452
    610 let $10 = instantiate(`(module binary
    611  "\\00asm" "\\01\\00\\00\\00"
    612  "\\01\\01\\00"                               ;; type count can be zero
    613 )`);
    614 
    615 // ./test/core/binary.wast:458
    616 assert_malformed(
    617  () => instantiate(`(module binary
    618    "\\00asm" "\\01\\00\\00\\00"
    619    "\\01\\07\\02"                             ;; type section with inconsistent count (2 declared, 1 given)
    620    "\\60\\00\\00"                             ;; 1st type
    621    ;; "\\60\\00\\00"                          ;; 2nd type (missed)
    622  )`),
    623  `length out of bounds`,
    624 );
    625 
    626 // ./test/core/binary.wast:469
    627 assert_malformed(
    628  () => instantiate(`(module binary
    629    "\\00asm" "\\01\\00\\00\\00"
    630    "\\01\\07\\01"                             ;; type section with inconsistent count (1 declared, 2 given)
    631    "\\60\\00\\00"                             ;; 1st type
    632    "\\60\\00\\00"                             ;; 2nd type (redundant)
    633  )`),
    634  `section size mismatch`,
    635 );
    636 
    637 // ./test/core/binary.wast:480
    638 let $11 = instantiate(`(module binary
    639    "\\00asm" "\\01\\00\\00\\00"
    640    "\\01\\05\\01"                             ;; type section
    641    "\\60\\01\\7f\\00"                          ;; type 0
    642    "\\02\\01\\00"                             ;; import count can be zero
    643 )`);
    644 
    645 // ./test/core/binary.wast:488
    646 assert_malformed(
    647  () => instantiate(`(module binary
    648      "\\00asm" "\\01\\00\\00\\00"
    649      "\\02\\04\\01"                           ;; import section with single entry
    650      "\\00"                                 ;; string length 0
    651      "\\00"                                 ;; string length 0
    652      "\\05"                                 ;; malformed import kind
    653  )`),
    654  `malformed import kind`,
    655 );
    656 
    657 // ./test/core/binary.wast:498
    658 assert_malformed(
    659  () => instantiate(`(module binary
    660      "\\00asm" "\\01\\00\\00\\00"
    661      "\\02\\05\\01"                           ;; import section with single entry
    662      "\\00"                                 ;; string length 0
    663      "\\00"                                 ;; string length 0
    664      "\\05"                                 ;; malformed import kind
    665      "\\00"                                 ;; dummy byte
    666  )`),
    667  `malformed import kind`,
    668 );
    669 
    670 // ./test/core/binary.wast:509
    671 assert_malformed(
    672  () => instantiate(`(module binary
    673      "\\00asm" "\\01\\00\\00\\00"
    674      "\\02\\04\\01"                           ;; import section with single entry
    675      "\\00"                                 ;; string length 0
    676      "\\00"                                 ;; string length 0
    677      "\\05"                                 ;; malformed import kind
    678  )`),
    679  `malformed import kind`,
    680 );
    681 
    682 // ./test/core/binary.wast:519
    683 assert_malformed(
    684  () => instantiate(`(module binary
    685      "\\00asm" "\\01\\00\\00\\00"
    686      "\\02\\05\\01"                           ;; import section with single entry
    687      "\\00"                                 ;; string length 0
    688      "\\00"                                 ;; string length 0
    689      "\\05"                                 ;; malformed import kind
    690      "\\00"                                 ;; dummy byte
    691  )`),
    692  `malformed import kind`,
    693 );
    694 
    695 // ./test/core/binary.wast:530
    696 assert_malformed(
    697  () => instantiate(`(module binary
    698      "\\00asm" "\\01\\00\\00\\00"
    699      "\\02\\04\\01"                           ;; import section with single entry
    700      "\\00"                                 ;; string length 0
    701      "\\00"                                 ;; string length 0
    702      "\\80"                                 ;; malformed import kind
    703  )`),
    704  `malformed import kind`,
    705 );
    706 
    707 // ./test/core/binary.wast:540
    708 assert_malformed(
    709  () => instantiate(`(module binary
    710      "\\00asm" "\\01\\00\\00\\00"
    711      "\\02\\05\\01"                           ;; import section with single entry
    712      "\\00"                                 ;; string length 0
    713      "\\00"                                 ;; string length 0
    714      "\\80"                                 ;; malformed import kind
    715      "\\00"                                 ;; dummy byte
    716  )`),
    717  `malformed import kind`,
    718 );
    719 
    720 // ./test/core/binary.wast:553
    721 assert_malformed(
    722  () => instantiate(`(module binary
    723      "\\00asm" "\\01\\00\\00\\00"
    724      "\\01\\05\\01"                           ;; type section
    725      "\\60\\01\\7f\\00"                        ;; type 0
    726      "\\02\\16\\02"                           ;; import section with inconsistent count (2 declared, 1 given)
    727      ;; 1st import
    728      "\\08"                                 ;; string length
    729      "\\73\\70\\65\\63\\74\\65\\73\\74"            ;; spectest
    730      "\\09"                                 ;; string length
    731      "\\70\\72\\69\\6e\\74\\5f\\69\\33\\32"         ;; print_i32
    732      "\\00\\00"                              ;; import kind, import signature index
    733      ;; 2nd import
    734      ;; (missed)
    735  )`),
    736  `unexpected end of section or function`,
    737 );
    738 
    739 // ./test/core/binary.wast:572
    740 assert_malformed(
    741  () => instantiate(`(module binary
    742      "\\00asm" "\\01\\00\\00\\00"
    743      "\\01\\09\\02"                           ;; type section
    744      "\\60\\01\\7f\\00"                        ;; type 0
    745      "\\60\\01\\7d\\00"                        ;; type 1
    746      "\\02\\2b\\01"                           ;; import section with inconsistent count (1 declared, 2 given)
    747      ;; 1st import
    748      "\\08"                                 ;; string length
    749      "\\73\\70\\65\\63\\74\\65\\73\\74"            ;; spectest
    750      "\\09"                                 ;; string length
    751      "\\70\\72\\69\\6e\\74\\5f\\69\\33\\32"         ;; print_i32
    752      "\\00\\00"                              ;; import kind, import signature index
    753      ;; 2nd import
    754      ;; (redundant)
    755      "\\08"                                 ;; string length
    756      "\\73\\70\\65\\63\\74\\65\\73\\74"            ;; spectest
    757      "\\09"                                 ;; string length
    758      "\\70\\72\\69\\6e\\74\\5f\\66\\33\\32"         ;; print_f32
    759      "\\00\\01"                              ;; import kind, import signature index
    760  )`),
    761  `section size mismatch`,
    762 );
    763 
    764 // ./test/core/binary.wast:597
    765 let $12 = instantiate(`(module binary
    766    "\\00asm" "\\01\\00\\00\\00"
    767    "\\04\\01\\00"                             ;; table count can be zero
    768 )`);
    769 
    770 // ./test/core/binary.wast:603
    771 assert_malformed(
    772  () => instantiate(`(module binary
    773      "\\00asm" "\\01\\00\\00\\00"
    774      "\\04\\01\\01"                           ;; table section with inconsistent count (1 declared, 0 given)
    775      ;; "\\70\\01\\00\\00"                     ;; table entity
    776  )`),
    777  `unexpected end of section or function`,
    778 );
    779 
    780 // ./test/core/binary.wast:613
    781 assert_malformed(
    782  () => instantiate(`(module binary
    783      "\\00asm" "\\01\\00\\00\\00"
    784      "\\04\\03\\01"                           ;; table section with one entry
    785      "\\70"                                 ;; anyfunc
    786      "\\08"                                 ;; malformed table limits flag
    787  )`),
    788  `malformed limits flags`,
    789 );
    790 
    791 // ./test/core/binary.wast:622
    792 assert_malformed(
    793  () => instantiate(`(module binary
    794      "\\00asm" "\\01\\00\\00\\00"
    795      "\\04\\04\\01"                           ;; table section with one entry
    796      "\\70"                                 ;; anyfunc
    797      "\\08"                                 ;; malformed table limits flag
    798      "\\00"                                 ;; dummy byte
    799  )`),
    800  `malformed limits flags`,
    801 );
    802 
    803 // ./test/core/binary.wast:632
    804 assert_malformed(
    805  () => instantiate(`(module binary
    806      "\\00asm" "\\01\\00\\00\\00"
    807      "\\04\\06\\01"                           ;; table section with one entry
    808      "\\70"                                 ;; anyfunc
    809      "\\81\\00"                              ;; malformed table limits flag as LEB128
    810      "\\00\\00"                              ;; dummy bytes
    811  )`),
    812  `malformed limits flags`,
    813 );
    814 
    815 // ./test/core/binary.wast:644
    816 let $13 = instantiate(`(module binary
    817    "\\00asm" "\\01\\00\\00\\00"
    818    "\\05\\01\\00"                             ;; memory count can be zero
    819 )`);
    820 
    821 // ./test/core/binary.wast:650
    822 assert_malformed(
    823  () => instantiate(`(module binary
    824      "\\00asm" "\\01\\00\\00\\00"
    825      "\\05\\01\\01"                           ;; memory section with inconsistent count (1 declared, 0 given)
    826      ;; "\\00\\00"                           ;; memory 0 (missed)
    827  )`),
    828  `unexpected end of section or function`,
    829 );
    830 
    831 // ./test/core/binary.wast:660
    832 assert_malformed(
    833  () => instantiate(`(module binary
    834      "\\00asm" "\\01\\00\\00\\00"
    835      "\\05\\02\\01"                           ;; memory section with one entry
    836      "\\08"                                 ;; malformed memory limits flag
    837  )`),
    838  `malformed limits flags`,
    839 );
    840 
    841 // ./test/core/binary.wast:668
    842 assert_malformed(
    843  () => instantiate(`(module binary
    844      "\\00asm" "\\01\\00\\00\\00"
    845      "\\05\\03\\01"                           ;; memory section with one entry
    846      "\\10"                                 ;; malformed memory limits flag
    847      "\\00"                                 ;; dummy byte
    848  )`),
    849  `malformed limits flags`,
    850 );
    851 
    852 // ./test/core/binary.wast:677
    853 assert_malformed(
    854  () => instantiate(`(module binary
    855      "\\00asm" "\\01\\00\\00\\00"
    856      "\\05\\05\\01"                           ;; memory section with one entry
    857      "\\81\\00"                              ;; malformed memory limits flag as LEB128
    858      "\\00\\00"                              ;; dummy bytes
    859  )`),
    860  `malformed limits flags`,
    861 );
    862 
    863 // ./test/core/binary.wast:686
    864 assert_malformed(
    865  () => instantiate(`(module binary
    866      "\\00asm" "\\01\\00\\00\\00"
    867      "\\05\\05\\01"                           ;; memory section with one entry
    868      "\\81\\01"                              ;; malformed memory limits flag as LEB128
    869      "\\00\\00"                              ;; dummy bytes
    870  )`),
    871  `malformed limits flags`,
    872 );
    873 
    874 // ./test/core/binary.wast:697
    875 let $14 = instantiate(`(module binary
    876  "\\00asm" "\\01\\00\\00\\00"
    877  "\\06\\01\\00"                               ;; global count can be zero
    878 )`);
    879 
    880 // ./test/core/binary.wast:703
    881 assert_malformed(
    882  () => instantiate(`(module binary
    883    "\\00asm" "\\01\\00\\00\\00"
    884    "\\06\\06\\02"                             ;; global section with inconsistent count (2 declared, 1 given)
    885    "\\7f\\00\\41\\00\\0b"                       ;; global 0
    886    ;; "\\7f\\00\\41\\00\\0b"                    ;; global 1 (missed)
    887  )`),
    888  `unexpected end of section or function`,
    889 );
    890 
    891 // ./test/core/binary.wast:714
    892 assert_malformed(
    893  () => instantiate(`(module binary
    894    "\\00asm" "\\01\\00\\00\\00"
    895    "\\06\\0b\\01"                             ;; global section with inconsistent count (1 declared, 2 given)
    896    "\\7f\\00\\41\\00\\0b"                       ;; global 0
    897    "\\7f\\00\\41\\00\\0b"                       ;; global 1 (redundant)
    898  )`),
    899  `section size mismatch`,
    900 );
    901 
    902 // ./test/core/binary.wast:725
    903 let $15 = instantiate(`(module binary
    904  "\\00asm" "\\01\\00\\00\\00"
    905  "\\01\\04\\01"                               ;; type section
    906  "\\60\\00\\00"                               ;; type 0
    907  "\\03\\03\\02\\00\\00"                         ;; func section
    908  "\\07\\01\\00"                               ;; export count can be zero
    909  "\\0a\\07\\02"                               ;; code section
    910  "\\02\\00\\0b"                               ;; function body 0
    911  "\\02\\00\\0b"                               ;; function body 1
    912 )`);
    913 
    914 // ./test/core/binary.wast:737
    915 assert_malformed(
    916  () => instantiate(`(module binary
    917    "\\00asm" "\\01\\00\\00\\00"
    918    "\\01\\04\\01"                             ;; type section
    919    "\\60\\00\\00"                             ;; type 0
    920    "\\03\\03\\02\\00\\00"                       ;; func section
    921    "\\07\\06\\02"                             ;; export section with inconsistent count (2 declared, 1 given)
    922    "\\02"                                   ;; export 0
    923    "\\66\\31"                                ;; export name
    924    "\\00\\00"                                ;; export kind, export func index
    925    ;; "\\02"                                ;; export 1 (missed)
    926    ;; "\\66\\32"                             ;; export name
    927    ;; "\\00\\01"                             ;; export kind, export func index
    928    "\\0a\\07\\02"                             ;; code section
    929    "\\02\\00\\0b"                             ;; function body 0
    930    "\\02\\00\\0b"                             ;; function body 1
    931  )`),
    932  `length out of bounds`,
    933 );
    934 
    935 // ./test/core/binary.wast:758
    936 assert_malformed(
    937  () => instantiate(`(module binary
    938    "\\00asm" "\\01\\00\\00\\00"
    939    "\\01\\04\\01"                             ;; type section
    940    "\\60\\00\\00"                             ;; type 0
    941    "\\03\\03\\02\\00\\00"                       ;; func section
    942    "\\07\\0b\\01"                             ;; export section with inconsistent count (1 declared, 2 given)
    943    "\\02"                                   ;; export 0
    944    "\\66\\31"                                ;; export name
    945    "\\00\\00"                                ;; export kind, export func index
    946    "\\02"                                   ;; export 1 (redundant)
    947    "\\66\\32"                                ;; export name
    948    "\\00\\01"                                ;; export kind, export func index
    949    "\\0a\\07\\02"                             ;; code section
    950    "\\02\\00\\0b"                             ;; function body 0
    951    "\\02\\00\\0b"                             ;; function body 1
    952  )`),
    953  `section size mismatch`,
    954 );
    955 
    956 // ./test/core/binary.wast:779
    957 let $16 = instantiate(`(module binary
    958  "\\00asm" "\\01\\00\\00\\00"
    959  "\\01\\04\\01"                               ;; type section
    960  "\\60\\00\\00"                               ;; type 0
    961  "\\03\\02\\01\\00"                            ;; func section
    962  "\\04\\04\\01"                               ;; table section
    963  "\\70\\00\\01"                               ;; table 0
    964  "\\09\\01\\00"                               ;; elem segment count can be zero
    965  "\\0a\\04\\01"                               ;; code section
    966  "\\02\\00\\0b"                               ;; function body
    967 )`);
    968 
    969 // ./test/core/binary.wast:792
    970 assert_malformed(
    971  () => instantiate(`(module binary
    972    "\\00asm" "\\01\\00\\00\\00"
    973    "\\01\\04\\01"                             ;; type section
    974    "\\60\\00\\00"                             ;; type 0
    975    "\\03\\02\\01\\00"                          ;; func section
    976    "\\04\\04\\01"                             ;; table section
    977    "\\70\\00\\01"                             ;; table 0
    978    "\\09\\07\\02"                             ;; elem with inconsistent segment count (2 declared, 1 given)
    979    "\\00\\41\\00\\0b\\01\\00"                    ;; elem 0
    980    ;; "\\00\\41\\00\\0b\\01\\00"                 ;; elem 1 (missed)
    981  )`),
    982  `unexpected end`,
    983 );
    984 
    985 // ./test/core/binary.wast:808
    986 assert_malformed(
    987  () => instantiate(`(module binary
    988    "\\00asm" "\\01\\00\\00\\00"
    989    "\\01\\04\\01"                             ;; type section
    990    "\\60\\00\\00"                             ;; type 0
    991    "\\03\\02\\01\\00"                          ;; func section
    992    "\\04\\04\\01"                             ;; table section
    993    "\\70\\00\\01"                             ;; table 0
    994    "\\09\\0a\\02"                             ;; elem with inconsistent segment count (2 declared, 1 given)
    995    "\\00\\41\\00\\0b\\01\\00"                    ;; elem 0
    996    "\\00\\41\\00"                             ;; elem 1 (partial)
    997    ;; "\\0b\\01\\00"                          ;; elem 1 (missing part)
    998  )`),
    999  `unexpected end`,
   1000 );
   1001 
   1002 // ./test/core/binary.wast:825
   1003 assert_malformed(
   1004  () => instantiate(`(module binary
   1005    "\\00asm" "\\01\\00\\00\\00"
   1006    "\\01\\04\\01"                             ;; type section
   1007    "\\60\\00\\00"                             ;; type 0
   1008    "\\03\\02\\01\\00"                          ;; func section
   1009    "\\04\\04\\01"                             ;; table section
   1010    "\\70\\00\\01"                             ;; table 0
   1011    "\\09\\0d\\01"                             ;; elem with inconsistent segment count (1 declared, 2 given)
   1012    "\\00\\41\\00\\0b\\01\\00"                    ;; elem 0
   1013    "\\00\\41\\00\\0b\\01\\00"                    ;; elem 1 (redundant)
   1014    "\\0a\\04\\01"                             ;; code section
   1015    "\\02\\00\\0b"                             ;; function body
   1016  )`),
   1017  `section size mismatch`,
   1018 );
   1019 
   1020 // ./test/core/binary.wast:843
   1021 let $17 = instantiate(`(module binary
   1022  "\\00asm" "\\01\\00\\00\\00"
   1023  "\\05\\03\\01"                               ;; memory section
   1024  "\\00\\01"                                  ;; memory 0
   1025  "\\0b\\01\\00"                               ;; data segment count can be zero
   1026 )`);
   1027 
   1028 // ./test/core/binary.wast:851
   1029 assert_malformed(
   1030  () => instantiate(`(module binary
   1031    "\\00asm" "\\01\\00\\00\\00"
   1032    "\\05\\03\\01"                             ;; memory section
   1033    "\\00\\01"                                ;; memory 0
   1034    "\\0b\\07\\02"                             ;; data with inconsistent segment count (2 declared, 1 given)
   1035    "\\00\\41\\00\\0b\\01\\61"                    ;; data 0
   1036    ;; "\\00\\41\\01\\0b\\01\\62"                 ;; data 1 (missed)
   1037  )`),
   1038  `unexpected end of section or function`,
   1039 );
   1040 
   1041 // ./test/core/binary.wast:864
   1042 assert_malformed(
   1043  () => instantiate(`(module binary
   1044    "\\00asm" "\\01\\00\\00\\00"
   1045    "\\05\\03\\01"                             ;; memory section
   1046    "\\00\\01"                                ;; memory 0
   1047    "\\0b\\0d\\01"                             ;; data with inconsistent segment count (1 declared, 2 given)
   1048    "\\00\\41\\00\\0b\\01\\61"                    ;; data 0
   1049    "\\00\\41\\01\\0b\\01\\62"                    ;; data 1 (redundant)
   1050  )`),
   1051  `section size mismatch`,
   1052 );
   1053 
   1054 // ./test/core/binary.wast:877
   1055 assert_malformed(
   1056  () => instantiate(`(module binary
   1057    "\\00asm" "\\01\\00\\00\\00"
   1058    "\\05\\03\\01"                             ;; memory section
   1059    "\\00\\01"                                ;; memory 0
   1060    "\\0b\\0c\\01"                             ;; data section
   1061    "\\00\\41\\03\\0b"                          ;; data segment 0
   1062    "\\07"                                   ;; data segment size with inconsistent lengths (7 declared, 6 given)
   1063    "\\61\\62\\63\\64\\65\\66"                    ;; 6 bytes given
   1064  )`),
   1065  `unexpected end of section or function`,
   1066 );
   1067 
   1068 // ./test/core/binary.wast:891
   1069 assert_malformed(
   1070  () => instantiate(`(module binary
   1071    "\\00asm" "\\01\\00\\00\\00"
   1072    "\\05\\03\\01"                             ;; memory section
   1073    "\\00\\01"                                ;; memory 0
   1074    "\\0b\\0c\\01"                             ;; data section
   1075    "\\00\\41\\00\\0b"                          ;; data segment 0
   1076    "\\05"                                   ;; data segment size with inconsistent lengths (5 declared, 6 given)
   1077    "\\61\\62\\63\\64\\65\\66"                    ;; 6 bytes given
   1078  )`),
   1079  `section size mismatch`,
   1080 );
   1081 
   1082 // ./test/core/binary.wast:905
   1083 let $18 = instantiate(`(module binary
   1084  "\\00asm" "\\01\\00\\00\\00"
   1085  "\\01\\04\\01"                               ;; type section
   1086  "\\60\\00\\00"                               ;; type 0
   1087  "\\03\\02\\01\\00"                            ;; func section
   1088  "\\0a\\11\\01"                               ;; code section
   1089  "\\0f\\00"                                  ;; func 0
   1090  "\\02\\40"                                  ;; block 0
   1091  "\\41\\01"                                  ;; condition of if 0
   1092  "\\04\\40"                                  ;; if 0
   1093  "\\41\\01"                                  ;; index of br_table element
   1094  "\\0e\\00"                                  ;; br_table target count can be zero
   1095  "\\02"                                     ;; break depth for default
   1096  "\\0b\\0b\\0b"                               ;; end
   1097 )`);
   1098 
   1099 // ./test/core/binary.wast:922
   1100 assert_malformed(
   1101  () => instantiate(`(module binary
   1102    "\\00asm" "\\01\\00\\00\\00"
   1103    "\\01\\25\\0c"                             ;; type section
   1104    "\\60\\00\\00"                             ;; type 0
   1105    "\\60\\00\\00"                             ;; type 1
   1106    "\\60\\00\\00"                             ;; type 2
   1107    "\\60\\00\\00"                             ;; type 3
   1108    "\\60\\00\\00"                             ;; type 4
   1109    "\\60\\00\\00"                             ;; type 5
   1110    "\\60\\00\\00"                             ;; type 6
   1111    "\\60\\00\\00"                             ;; type 7
   1112    "\\60\\00\\00"                             ;; type 8
   1113    "\\60\\00\\00"                             ;; type 9
   1114    "\\60\\00\\00"                             ;; type 10
   1115    "\\60\\00\\00"                             ;; type 11
   1116    "\\03\\02\\01\\00"                          ;; func section
   1117    "\\0a\\13\\01"                             ;; code section
   1118    "\\11\\00"                                ;; func 0
   1119    "\\02\\40"                                ;; block 0
   1120    "\\41\\01"                                ;; condition of if 0
   1121    "\\04\\40"                                ;; if 0
   1122    "\\41\\01"                                ;; index of br_table element
   1123    "\\0e\\01"                                ;; br_table with inconsistent target count (1 declared, 2 given)
   1124    "\\00"                                   ;; break depth 0
   1125    "\\01"                                   ;; break depth 1
   1126    "\\02"                                   ;; break depth for default, interpreted as a block
   1127    "\\0b"                                   ;; end, interpreted as type 11 for the block
   1128    "\\0b\\0b"                                ;; end
   1129  )`),
   1130  `unexpected end of section or function`,
   1131 );
   1132 
   1133 // ./test/core/binary.wast:956
   1134 let $19 = instantiate(`(module binary
   1135  "\\00asm" "\\01\\00\\00\\00"
   1136  "\\01\\04\\01\\60\\00\\00"       ;; Type section
   1137  "\\03\\02\\01\\00"             ;; Function section
   1138  "\\08\\01\\00"                ;; Start section: function 0
   1139 
   1140  "\\0a\\04\\01"                ;; Code section
   1141  ;; function 0
   1142  "\\02\\00"
   1143  "\\0b"                      ;; end
   1144 )`);
   1145 
   1146 // ./test/core/binary.wast:969
   1147 assert_malformed(
   1148  () => instantiate(`(module binary
   1149    "\\00asm" "\\01\\00\\00\\00"
   1150    "\\01\\04\\01\\60\\00\\00"       ;; Type section
   1151    "\\03\\02\\01\\00"             ;; Function section
   1152    "\\08\\01\\00"                ;; Start section: function 0
   1153    "\\08\\01\\00"                ;; Start section: function 0
   1154 
   1155    "\\0a\\04\\01"                ;; Code section
   1156    ;; function 0
   1157    "\\02\\00"
   1158    "\\0b"                      ;; end
   1159  )`),
   1160  `unexpected content after last section`,
   1161 );
   1162 
   1163 // ./test/core/binary.wast:986
   1164 assert_malformed(
   1165  () => instantiate(`(module binary
   1166    "\\00asm" "\\01\\00\\00\\00"
   1167    "\\01\\04\\01\\60\\00\\00"           ;; Type section
   1168    "\\03\\02\\01\\00"                 ;; Function section with 1 function
   1169    "\\03\\02\\01\\00"                 ;; Function section with 1 function
   1170    "\\0a\\07\\02\\02\\00\\0b\\02\\00\\0b"  ;; Code section with 2 empty functions
   1171  )`),
   1172  `unexpected content after last section`,
   1173 );
   1174 
   1175 // ./test/core/binary.wast:998
   1176 assert_malformed(
   1177  () => instantiate(`(module binary
   1178    "\\00asm" "\\01\\00\\00\\00"
   1179    "\\01\\04\\01\\60\\00\\00"           ;; Type section
   1180    "\\03\\03\\02\\00\\00"              ;; Function section with 2 functions
   1181    "\\0a\\04\\01\\02\\00\\0b"           ;; Code section with 1 empty function
   1182    "\\0a\\04\\01\\02\\00\\0b"           ;; Code section with 1 empty function
   1183  )`),
   1184  `unexpected content after last section`,
   1185 );
   1186 
   1187 // ./test/core/binary.wast:1010
   1188 assert_malformed(
   1189  () => instantiate(`(module binary
   1190    "\\00asm" "\\01\\00\\00\\00"
   1191    "\\0c\\01\\01"                   ;; Data count section with value "1"
   1192    "\\0c\\01\\01"                   ;; Data count section with value "1"
   1193  )`),
   1194  `unexpected content after last section`,
   1195 );
   1196 
   1197 // ./test/core/binary.wast:1020
   1198 assert_malformed(
   1199  () => instantiate(`(module binary
   1200    "\\00asm" "\\01\\00\\00\\00"
   1201    "\\0b\\01\\00"                   ;; Data section with zero entries
   1202    "\\0b\\01\\00"                   ;; Data section with zero entries
   1203  )`),
   1204  `unexpected content after last section`,
   1205 );
   1206 
   1207 // ./test/core/binary.wast:1030
   1208 assert_malformed(
   1209  () => instantiate(`(module binary
   1210    "\\00asm" "\\01\\00\\00\\00"
   1211    "\\06\\01\\00"                   ;; Global section with zero entries
   1212    "\\06\\01\\00"                   ;; Global section with zero entries
   1213  )`),
   1214  `unexpected content after last section`,
   1215 );
   1216 
   1217 // ./test/core/binary.wast:1040
   1218 assert_malformed(
   1219  () => instantiate(`(module binary
   1220    "\\00asm" "\\01\\00\\00\\00"
   1221    "\\07\\01\\00"                   ;; Export section with zero entries
   1222    "\\07\\01\\00"                   ;; Export section with zero entries
   1223  )`),
   1224  `unexpected content after last section`,
   1225 );
   1226 
   1227 // ./test/core/binary.wast:1050
   1228 assert_malformed(
   1229  () => instantiate(`(module binary
   1230      "\\00asm" "\\01\\00\\00\\00"
   1231      "\\04\\01\\00"                 ;; Table section with zero entries
   1232      "\\04\\01\\00"                 ;; Table section with zero entries
   1233  )`),
   1234  `unexpected content after last section`,
   1235 );
   1236 
   1237 // ./test/core/binary.wast:1060
   1238 assert_malformed(
   1239  () => instantiate(`(module binary
   1240      "\\00asm" "\\01\\00\\00\\00"
   1241      "\\09\\01\\00"                 ;; Element section with zero entries
   1242      "\\09\\01\\00"                 ;; Element section with zero entries
   1243  )`),
   1244  `unexpected content after last section`,
   1245 );
   1246 
   1247 // ./test/core/binary.wast:1070
   1248 assert_malformed(
   1249  () => instantiate(`(module binary
   1250      "\\00asm" "\\01\\00\\00\\00"
   1251      "\\02\\01\\00"                 ;; Import section with zero entries
   1252      "\\02\\01\\00"                 ;; Import section with zero entries
   1253  )`),
   1254  `unexpected content after last section`,
   1255 );
   1256 
   1257 // ./test/core/binary.wast:1080
   1258 assert_malformed(
   1259  () => instantiate(`(module binary
   1260    "\\00asm" "\\01\\00\\00\\00"
   1261    "\\01\\01\\00"                   ;; Type section with zero entries
   1262    "\\01\\01\\00"                   ;; Type section with zero entries
   1263  )`),
   1264  `unexpected content after last section`,
   1265 );
   1266 
   1267 // ./test/core/binary.wast:1090
   1268 assert_malformed(
   1269  () => instantiate(`(module binary
   1270    "\\00asm" "\\01\\00\\00\\00"
   1271    "\\05\\01\\00"                   ;; Memory section with zero entries
   1272    "\\05\\01\\00"                   ;; Memory section with zero entries
   1273  )`),
   1274  `unexpected content after last section`,
   1275 );
   1276 
   1277 // ./test/core/binary.wast:1100
   1278 assert_malformed(
   1279  () => instantiate(`(module binary
   1280      "\\00asm" "\\01\\00\\00\\00"
   1281      "\\02\\01\\00"                 ;; Import section with zero entries
   1282      "\\01\\01\\00"                 ;; Type section with zero entries
   1283  )`),
   1284  `unexpected content after last section`,
   1285 );
   1286 
   1287 // ./test/core/binary.wast:1110
   1288 assert_malformed(
   1289  () => instantiate(`(module binary
   1290      "\\00asm" "\\01\\00\\00\\00"
   1291      "\\03\\01\\00"                 ;; Function section with zero entries
   1292      "\\02\\01\\00"                 ;; Import section with zero entries
   1293  )`),
   1294  `unexpected content after last section`,
   1295 );
   1296 
   1297 // ./test/core/binary.wast:1120
   1298 assert_malformed(
   1299  () => instantiate(`(module binary
   1300      "\\00asm" "\\01\\00\\00\\00"
   1301      "\\04\\01\\00"                 ;; Table section with zero entries
   1302      "\\03\\01\\00"                 ;; Function section with zero entries
   1303  )`),
   1304  `unexpected content after last section`,
   1305 );
   1306 
   1307 // ./test/core/binary.wast:1130
   1308 assert_malformed(
   1309  () => instantiate(`(module binary
   1310      "\\00asm" "\\01\\00\\00\\00"
   1311      "\\05\\01\\00"                 ;; Memory section with zero entries
   1312      "\\04\\01\\00"                 ;; Table section with zero entries
   1313  )`),
   1314  `unexpected content after last section`,
   1315 );
   1316 
   1317 // ./test/core/binary.wast:1140
   1318 assert_malformed(
   1319  () => instantiate(`(module binary
   1320      "\\00asm" "\\01\\00\\00\\00"
   1321      "\\06\\01\\00"                 ;; Global section with zero entries
   1322      "\\05\\01\\00"                 ;; Memory section with zero entries
   1323  )`),
   1324  `unexpected content after last section`,
   1325 );
   1326 
   1327 // ./test/core/binary.wast:1150
   1328 assert_malformed(
   1329  () => instantiate(`(module binary
   1330      "\\00asm" "\\01\\00\\00\\00"
   1331      "\\07\\01\\00"                 ;; Export section with zero entries
   1332      "\\06\\01\\00"                 ;; Global section with zero entries
   1333  )`),
   1334  `unexpected content after last section`,
   1335 );
   1336 
   1337 // ./test/core/binary.wast:1160
   1338 assert_malformed(
   1339  () => instantiate(`(module binary
   1340      "\\00asm" "\\01\\00\\00\\00"
   1341      "\\01\\04\\01\\60\\00\\00"        ;; Type section
   1342      "\\03\\02\\01\\00"              ;; Function section
   1343      "\\08\\01\\00"                 ;; Start section: function 0
   1344      "\\07\\01\\00"                 ;; Export section with zero entries
   1345  )`),
   1346  `unexpected content after last section`,
   1347 );
   1348 
   1349 // ./test/core/binary.wast:1172
   1350 assert_malformed(
   1351  () => instantiate(`(module binary
   1352      "\\00asm" "\\01\\00\\00\\00"
   1353      "\\01\\04\\01\\60\\00\\00"        ;; Type section
   1354      "\\03\\02\\01\\00"              ;; Function section
   1355      "\\09\\01\\00"                 ;; Element section with zero entries
   1356      "\\08\\01\\00"                 ;; Start section: function 0
   1357  )`),
   1358  `unexpected content after last section`,
   1359 );
   1360 
   1361 // ./test/core/binary.wast:1184
   1362 assert_malformed(
   1363  () => instantiate(`(module binary
   1364      "\\00asm" "\\01\\00\\00\\00"
   1365      "\\0c\\01\\01"                 ;; Data count section with value "1"
   1366      "\\09\\01\\00"                 ;; Element section with zero entries
   1367  )`),
   1368  `unexpected content after last section`,
   1369 );
   1370 
   1371 // ./test/core/binary.wast:1194
   1372 assert_malformed(
   1373  () => instantiate(`(module binary
   1374      "\\00asm" "\\01\\00\\00\\00"
   1375      "\\0a\\01\\00"                 ;; Code section with zero entries
   1376      "\\0c\\01\\01"                 ;; Data count section with value "1"
   1377  )`),
   1378  `unexpected content after last section`,
   1379 );
   1380 
   1381 // ./test/core/binary.wast:1204
   1382 assert_malformed(
   1383  () => instantiate(`(module binary
   1384      "\\00asm" "\\01\\00\\00\\00"
   1385      "\\0b\\01\\00"                 ;; Data section with zero entries
   1386      "\\0a\\01\\00"                 ;; Code section with zero entries
   1387  )`),
   1388  `unexpected content after last section`,
   1389 );
   1390 
   1391 // ./test/core/binary.wast:1218
   1392 assert_malformed(
   1393  () => instantiate(`(module binary
   1394    "\\00asm" "\\01\\00\\00\\00"
   1395    "\\01\\04\\01\\60\\00\\00"       ;; Type section: 1 type
   1396    "\\03\\02\\01\\00"             ;; Function section: 1 function
   1397    "\\0a\\08\\01"                ;; Code section: 1 function
   1398    ;; function 0
   1399    "\\06\\00"                   ;; Function size and local type count
   1400    "\\00"                      ;; unreachable
   1401    "\\ff"                      ;; 0xff
   1402    "\\00"                      ;; might be interpreted as unreachable, or as the second byte
   1403                               ;; of a multi-byte instruction
   1404    "\\00"                      ;; unreachable
   1405    "\\0b"                      ;; end
   1406  )`),
   1407  `illegal opcode ff`,
   1408 );