summaryrefslogtreecommitdiff
path: root/test/binaryen.js
diff options
context:
space:
mode:
authorDaniel Wirtz <dcode@dcode.io>2020-09-29 17:55:28 +0200
committerGitHub <noreply@github.com>2020-09-29 17:55:28 +0200
commitfa4c884f4ebfde185c9d8a3ee4e54f96c57cebed (patch)
treea41f45f78f42dd7b532d6303fc71ec76ddbdf76d /test/binaryen.js
parente9e5f30212f44927859d3dad5fe48499d860f61c (diff)
downloadbinaryen-fa4c884f4ebfde185c9d8a3ee4e54f96c57cebed.tar.gz
binaryen-fa4c884f4ebfde185c9d8a3ee4e54f96c57cebed.tar.bz2
binaryen-fa4c884f4ebfde185c9d8a3ee4e54f96c57cebed.zip
Prototype extended-name-section proposal (#3162)
Implements the parts of the Extended Name Section Proposal that are trivially applicable to Binaryen, in particular table, memory and global names. Does not yet implement label, type, elem and data names.
Diffstat (limited to 'test/binaryen.js')
-rw-r--r--test/binaryen.js/debug-names.js14
-rw-r--r--test/binaryen.js/debug-names.js.txt32
-rw-r--r--test/binaryen.js/kitchen-sink.js.txt2
3 files changed, 36 insertions, 12 deletions
diff --git a/test/binaryen.js/debug-names.js b/test/binaryen.js/debug-names.js
index 539b119aa..0be6bf365 100644
--- a/test/binaryen.js/debug-names.js
+++ b/test/binaryen.js/debug-names.js
@@ -1,13 +1,13 @@
var wast = `
-(module $hello
- (global $world i32 (i32.const 0))
+(module $hel
+ (memory $lo 0 0)
+ (table $wor 0 0 funcref)
+ (global $ld i32 (i32.const 0))
(func $of (param $wasm i32)
(local $!#$%&'*+-./:<=>?@\\^_\`|~ f64)
)
)
`;
-// Note that global names are not yet covered by the name section, so it is
-// expected that the global's name is lost after roundtripping.
console.log("=== input wast ===" + wast);
@@ -33,4 +33,10 @@ module.dispose();
console.log("=== roundtripped ===\n" + module2.emitText());
+var module3 = binaryen.readBinary(module2.emitBinary());
+
module2.dispose();
+
+console.log("=== roundtripped again ===\n" + module3.emitText());
+
+module3.dispose();
diff --git a/test/binaryen.js/debug-names.js.txt b/test/binaryen.js/debug-names.js.txt
index c982f2dc1..40e94c248 100644
--- a/test/binaryen.js/debug-names.js.txt
+++ b/test/binaryen.js/debug-names.js.txt
@@ -1,15 +1,19 @@
=== input wast ===
-(module $hello
- (global $world i32 (i32.const 0))
+(module $hel
+ (memory $lo 0 0)
+ (table $wor 0 0 funcref)
+ (global $ld i32 (i32.const 0))
(func $of (param $wasm i32)
(local $!#$%&'*+-./:<=>?@\^_`|~ f64)
)
)
=== parsed wast ===
-(module $hello
+(module $hel
(type $i32_=>_none (func (param i32)))
- (global $world i32 (i32.const 0))
+ (memory $lo 0 0)
+ (table $wor 0 0 funcref)
+ (global $ld i32 (i32.const 0))
(func $of (param $wasm i32)
(local $!#$%&'*+-./:<=>?@\^_`|~ f64)
(nop)
@@ -17,11 +21,25 @@
)
=== roundtripped ===
-(module $hello
+(module $hel
(type $i32_=>_none (func (param i32)))
- (global $global$0 i32 (i32.const 0))
+ (memory $lo 0 0)
+ (table $wor 0 0 funcref)
+ (global $ld i32 (i32.const 0))
(func $of (param $js i32)
- (local $!#$%&'*+-./:<=>?@\^_`|~ f64)
+ (local $!#$%&'*+-./:<=>?@\5c^_`|~ f64)
+ (nop)
+ )
+)
+
+=== roundtripped again ===
+(module $hel
+ (type $i32_=>_none (func (param i32)))
+ (memory $lo 0 0)
+ (table $wor 0 0 funcref)
+ (global $ld i32 (i32.const 0))
+ (func $of (param $js i32)
+ (local $!#$%&'*+-./:<=>?@\5c^_`|~ f64)
(nop)
)
)
diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt
index 9fca3ae53..491f11cec 100644
--- a/test/binaryen.js/kitchen-sink.js.txt
+++ b/test/binaryen.js/kitchen-sink.js.txt
@@ -4344,7 +4344,7 @@ module loaded from binary form:
(module
(type $i32_i32_=>_none (func (param i32 i32)))
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
- (global $global$0 i32 (i32.const 3))
+ (global $a-global i32 (i32.const 3))
(event $event$0 (attr 0) (param i32 i32))
(func $adder (param $0 i32) (param $1 i32) (result i32)
(i32.add