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