File tree Expand file tree Collapse file tree 2 files changed +61
-1
lines changed
packages/proposal-sign-extension-ops Expand file tree Collapse file tree 2 files changed +61
-1
lines changed Original file line number Diff line number Diff line change 2929 "@webassemblyjs/helper-test-framework" : " 1.5.6" ,
3030 "@webassemblyjs/wast-parser" : " 1.5.6" ,
3131 "@webassemblyjs/wasm-parser" : " 1.5.6" ,
32- "@webassemblyjs/wast-printer" : " 1.5.6"
32+ "@webassemblyjs/wast-printer" : " 1.5.6" ,
33+ "wabt" : " 1.0.0"
3334 }
3435}
Original file line number Diff line number Diff line change 1+ const { parse } = require ( "@webassemblyjs/wast-parser" ) ;
2+ const path = require ( "path" ) ;
3+ const wabt = require ( "wabt" ) ;
4+ const assert = require ( "assert" ) ;
5+
6+ const {
7+ getFixtures,
8+ compareStrings
9+ } = require ( "@webassemblyjs/helper-test-framework" ) ;
10+ const { readFileSync, existsSync, writeFileSync } = require ( "fs" ) ;
11+
12+ const polyfills = [
13+ {
14+ name : "i32_extend8_s" ,
15+ fixtures : [
16+ [ 0 , 0 ] ,
17+ [ 0x7f , 127 ] ,
18+ [ 0x80 , - 128 ] ,
19+ [ 0xff , - 1 ] ,
20+ [ 0x01234500 , 0 ] ,
21+ [ 0xfedcba80 , - 0x80 ] ,
22+ [ - 1 , - 1 ]
23+ ]
24+ } ,
25+ {
26+ name : "i32_extend16_s" ,
27+ fixtures : [
28+ [ 0 , 0 ] ,
29+ [ 0x7fff , 32767 ] ,
30+ [ 0x8000 , - 32768 ] ,
31+ [ 0xffff , - 1 ] ,
32+ [ 0x01230000 , 0 ] ,
33+ [ 0xfedc8000 , - 0x8000 ] ,
34+ [ - 1 , - 1 ]
35+ ]
36+ }
37+ ] ;
38+
39+ polyfills . forEach ( p => {
40+ p . path = path . join ( __dirname , `../lib/polyfills/${ p . name } .wast` ) ;
41+ } ) ;
42+
43+ polyfills . forEach ( polyfill => {
44+ describe ( polyfill . path , ( ) => {
45+ const wast = readFileSync ( polyfill . path , "utf8" ) . trim ( ) ;
46+ const wasm = wabt
47+ . parseWat ( polyfill . path , wast )
48+ . toBinary ( { write_debug_names : false } ) ;
49+
50+ it ( "should return correct values" , ( ) => {
51+ return WebAssembly . instantiate ( wasm . buffer ) . then ( result => {
52+ const polyfillFn = result . instance . exports [ polyfill . name ] ;
53+ polyfill . fixtures . forEach ( ( [ input , output ] ) => {
54+ assert . equal ( output , polyfillFn ( input ) ) ;
55+ } ) ;
56+ } ) ;
57+ } ) ;
58+ } ) ;
59+ } ) ;
You can’t perform that action at this time.
0 commit comments