summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2022-01-10 12:40:35 -0800
committerGitHub <noreply@github.com>2022-01-10 12:40:35 -0800
commitc12de34c7d33b3ccf80f117edf78b5346bd00897 (patch)
tree741ea30521a130d463776a7cc7cce3bfede238bb /test
parent4952437ddc3d0ea07725493b14504868702f8967 (diff)
downloadbinaryen-c12de34c7d33b3ccf80f117edf78b5346bd00897.tar.gz
binaryen-c12de34c7d33b3ccf80f117edf78b5346bd00897.tar.bz2
binaryen-c12de34c7d33b3ccf80f117edf78b5346bd00897.zip
Escape \t as well as \n when writing JSON output. (#4437)
As it happens, this doesn't (normally) break the resulting EM_ASM or EM_JS strings because (IIUC) JS supports the tab literal inside of strings as well as "\t". However, it's better to preserve the original text so that it looks the same in the JS file as it did in the original source.
Diffstat (limited to 'test')
-rw-r--r--test/lld/em_asm.cpp2
-rw-r--r--test/lld/em_asm.wat8
-rw-r--r--test/lld/em_asm.wat.mem.out12
-rw-r--r--test/lld/em_asm.wat.out12
4 files changed, 17 insertions, 17 deletions
diff --git a/test/lld/em_asm.cpp b/test/lld/em_asm.cpp
index ed89783f8..b8c3db365 100644
--- a/test/lld/em_asm.cpp
+++ b/test/lld/em_asm.cpp
@@ -1,7 +1,7 @@
#include <emscripten/em_asm.h>
int main() {
- EM_ASM({ Module.print("Hello world"); });
+ EM_ASM({ Module.print("Hello \\ world\t\n"); });
int x = EM_ASM_INT({ return $0 + $1; }, 13, 27);
EM_ASM_({ Module.print("Got " + $0); }, x);
return 0;
diff --git a/test/lld/em_asm.wat b/test/lld/em_asm.wat
index 0d035496a..035030802 100644
--- a/test/lld/em_asm.wat
+++ b/test/lld/em_asm.wat
@@ -6,11 +6,11 @@
(import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i32 i32 i32) (result i32)))
(memory $0 2)
(data $.rodata (i32.const 568) "\00ii\00i\00")
- (data $em_asm (i32.const 574) "{ Module.print(\"Hello world\"); }\00{ return $0 + $1; }\00{ Module.print(\"Got \" + $0); }\00")
+ (data $em_asm (i32.const 574) "{ Module.print(\"Hello \\\\ world\\t\\n\"); }\00{ return $0 + $1; }\00{ Module.print(\"Got \" + $0); }\00")
(table $0 1 1 funcref)
(global $__stack_pointer (mut i32) (i32.const 66208))
(global $global$1 i32 (i32.const 574))
- (global $global$2 i32 (i32.const 658))
+ (global $global$2 i32 (i32.const 665))
(export "memory" (memory $0))
(export "__wasm_call_ctors" (func $__wasm_call_ctors))
(export "main" (func $main))
@@ -42,7 +42,7 @@
(i32.store
(local.get $0)
(call $emscripten_asm_const_int
- (i32.const 607)
+ (i32.const 614)
(i32.const 569)
(i32.add
(local.get $0)
@@ -52,7 +52,7 @@
)
(drop
(call $emscripten_asm_const_int
- (i32.const 627)
+ (i32.const 634)
(i32.const 572)
(local.get $0)
)
diff --git a/test/lld/em_asm.wat.mem.out b/test/lld/em_asm.wat.mem.out
index 8ace4ede4..07c9aa3e8 100644
--- a/test/lld/em_asm.wat.mem.out
+++ b/test/lld/em_asm.wat.mem.out
@@ -6,7 +6,7 @@
(import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i32 i32 i32) (result i32)))
(global $__stack_pointer (mut i32) (i32.const 66208))
(global $global$1 i32 (i32.const 574))
- (global $global$2 i32 (i32.const 658))
+ (global $global$2 i32 (i32.const 665))
(memory $0 2)
(table $0 1 1 funcref)
(export "memory" (memory $0))
@@ -39,7 +39,7 @@
(i32.store
(local.get $0)
(call $emscripten_asm_const_int
- (i32.const 607)
+ (i32.const 614)
(i32.const 569)
(i32.add
(local.get $0)
@@ -49,7 +49,7 @@
)
(drop
(call $emscripten_asm_const_int
- (i32.const 627)
+ (i32.const 634)
(i32.const 572)
(local.get $0)
)
@@ -70,9 +70,9 @@
--BEGIN METADATA --
{
"asmConsts": {
- "574": "{ Module.print(\"Hello world\"); }",
- "607": "{ return $0 + $1; }",
- "627": "{ Module.print(\"Got \" + $0); }"
+ "574": "{ Module.print(\"Hello \\ world\\t\\n\"); }",
+ "614": "{ return $0 + $1; }",
+ "634": "{ Module.print(\"Got \" + $0); }"
},
"declares": [
"emscripten_asm_const_int"
diff --git a/test/lld/em_asm.wat.out b/test/lld/em_asm.wat.out
index c0cfbe303..5a32e4bad 100644
--- a/test/lld/em_asm.wat.out
+++ b/test/lld/em_asm.wat.out
@@ -6,7 +6,7 @@
(import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i32 i32 i32) (result i32)))
(global $__stack_pointer (mut i32) (i32.const 66208))
(global $global$1 i32 (i32.const 574))
- (global $global$2 i32 (i32.const 658))
+ (global $global$2 i32 (i32.const 665))
(memory $0 2)
(data $.rodata (i32.const 568) "\00ii\00i\00")
(data $em_asm (i32.const 574) "")
@@ -41,7 +41,7 @@
(i32.store
(local.get $0)
(call $emscripten_asm_const_int
- (i32.const 607)
+ (i32.const 614)
(i32.const 569)
(i32.add
(local.get $0)
@@ -51,7 +51,7 @@
)
(drop
(call $emscripten_asm_const_int
- (i32.const 627)
+ (i32.const 634)
(i32.const 572)
(local.get $0)
)
@@ -72,9 +72,9 @@
--BEGIN METADATA --
{
"asmConsts": {
- "574": "{ Module.print(\"Hello world\"); }",
- "607": "{ return $0 + $1; }",
- "627": "{ Module.print(\"Got \" + $0); }"
+ "574": "{ Module.print(\"Hello \\ world\\t\\n\"); }",
+ "614": "{ return $0 + $1; }",
+ "634": "{ Module.print(\"Got \" + $0); }"
},
"declares": [
"emscripten_asm_const_int"