Skip to content

Commit 0ed65eb

Browse files
Add two to four bytes utf8 character tests (#2495)
1 parent f8a775f commit 0ed65eb

10 files changed

+387
-170
lines changed

Diff for: tests/compiler/std/string-encoding.debug.wat

+11-11
Large diffs are not rendered by default.

Diff for: tests/compiler/std/string-encoding.release.wat

+56-56
Large diffs are not rendered by default.

Diff for: tests/compiler/std/string-encoding.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,15 @@ function testUTF8DecodeUnsafe(): void {
148148
}
149149
testUTF8DecodeUnsafe();
150150

151-
function testLarge(str: string): void {
151+
function testRoundtrip(str: string): void {
152152
var buf8 = String.UTF8.encode(str);
153153
assert(String.UTF8.decode(buf8) == str);
154154
var buf16 = String.UTF16.encode(str);
155155
assert(String.UTF16.decode(buf16) == str);
156156
}
157157

158158
// https://www.w3.org/2001/06/utf-8-test/UTF-8-demo.html
159-
testLarge(`Mathematics and Sciences:
159+
testRoundtrip(`Mathematics and Sciences:
160160
161161
∮ E⋅da = Q, n → ∞, ∑ f(i) = ∏ g(i), ∀x∈ℝ: ⌈x⌉ = −⌊−x⌋, α ∧ ¬β = ¬(¬α ∨ β),
162162
@@ -349,7 +349,7 @@ Box drawing alignment tests: █
349349
`);
350350

351351
// https://www.cl.cam.ac.uk/~mgk25/ucs/examples/quickbrown.txt
352-
testLarge(`Sentences that contain all letters commonly used in a language
352+
testRoundtrip(`Sentences that contain all letters commonly used in a language
353353
--------------------------------------------------------------
354354
355355
Markus Kuhn <http://www.cl.cam.ac.uk/~mgk25/> -- 2012-04-11
@@ -490,6 +490,13 @@ Turkish (tr)
490490
491491
Pijamalı hasta, yağız şoföre çabucak güvendi.
492492
(=Patient with pajamas, trusted swarthy driver quickly)
493+
494+
Other
495+
-----
496+
497+
ÀÈ / c3_80 c3_88
498+
变量 / e5_8f_98 e9_87_8f
499+
𠜎𠜱 / f0_a0_9c_8e f0_a0_9c_b1
493500
`);
494501

495502
__collect();

Diff for: tests/compiler/std/string.debug.wat

+98-7
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@
6666
(global $~lib/util/number/_K (mut i32) (i32.const 0))
6767
(global $~lib/util/number/_frc_pow (mut i64) (i64.const 0))
6868
(global $~lib/util/number/_exp_pow (mut i32) (i32.const 0))
69-
(global $~lib/rt/__rtti_base i32 (i32.const 25296))
70-
(global $~lib/memory/__data_end i32 (i32.const 25340))
71-
(global $~lib/memory/__stack_pointer (mut i32) (i32.const 41724))
72-
(global $~lib/memory/__heap_base i32 (i32.const 41724))
69+
(global $~lib/rt/__rtti_base i32 (i32.const 25392))
70+
(global $~lib/memory/__data_end i32 (i32.const 25436))
71+
(global $~lib/memory/__stack_pointer (mut i32) (i32.const 41820))
72+
(global $~lib/memory/__heap_base i32 (i32.const 41820))
7373
(memory $0 1)
7474
(data (i32.const 12) "<\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00 \00\00\00h\00i\00,\00 \00I\00\'\00m\00 \00a\00 \00s\00t\00r\00i\00n\00g\00\00\00\00\00\00\00\00\00\00\00\00\00")
7575
(data (i32.const 76) ",\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\1a\00\00\00s\00t\00d\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s\00\00\00")
@@ -539,7 +539,10 @@
539539
(data (i32.const 25180) "\1c\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\n\00\00\00W\00o\00r\00l\00d\00\00\00")
540540
(data (i32.const 25212) ",\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\16\00\00\00H\00e\00l\00l\00o\00 \00W\00o\00r\00l\00d\00\00\00\00\00\00\00")
541541
(data (i32.const 25260) "\1c\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\06\00\00\00b\00a\00r\00\00\00\00\00\00\00")
542-
(data (i32.const 25296) "\05\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\t\00\00\00\00\00\00\02A\00\00\00\00\00\00")
542+
(data (i32.const 25292) "\1c\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\04\00\00\00\c0\00\c8\00\00\00\00\00\00\00\00\00")
543+
(data (i32.const 25324) "\1c\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\04\00\00\00\d8S\cf\91\00\00\00\00\00\00\00\00")
544+
(data (i32.const 25356) "\1c\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\08\00\00\00A\d8\0e\dfA\d81\df\00\00\00\00")
545+
(data (i32.const 25392) "\05\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\t\00\00\00\00\00\00\02A\00\00\00\00\00\00")
543546
(table $0 1 1 funcref)
544547
(elem $0 (i32.const 1))
545548
(export "getString" (func $std/string/getString))
@@ -8102,8 +8105,8 @@
81028105
global.get $~lib/memory/__data_end
81038106
i32.lt_s
81048107
if
8105-
i32.const 41744
8106-
i32.const 41792
8108+
i32.const 41840
8109+
i32.const 41888
81078110
i32.const 1
81088111
i32.const 1
81098112
call $~lib/builtins/abort
@@ -24238,6 +24241,94 @@
2423824241
call $~lib/builtins/abort
2423924242
unreachable
2424024243
end
24244+
i32.const 25312
24245+
local.set $4
24246+
global.get $~lib/memory/__stack_pointer
24247+
local.get $4
24248+
i32.store $0
24249+
local.get $4
24250+
i32.const 25312
24251+
local.set $4
24252+
global.get $~lib/memory/__stack_pointer
24253+
local.get $4
24254+
i32.store $0 offset=4
24255+
local.get $4
24256+
call $~lib/string/String.__eq
24257+
i32.eqz
24258+
if
24259+
i32.const 0
24260+
i32.const 96
24261+
i32.const 816
24262+
i32.const 1
24263+
call $~lib/builtins/abort
24264+
unreachable
24265+
end
24266+
i32.const 25312
24267+
local.set $4
24268+
global.get $~lib/memory/__stack_pointer
24269+
local.get $4
24270+
i32.store $0
24271+
local.get $4
24272+
i32.const 25312
24273+
local.set $4
24274+
global.get $~lib/memory/__stack_pointer
24275+
local.get $4
24276+
i32.store $0 offset=4
24277+
local.get $4
24278+
call $~lib/string/String.__eq
24279+
i32.eqz
24280+
if
24281+
i32.const 0
24282+
i32.const 96
24283+
i32.const 817
24284+
i32.const 1
24285+
call $~lib/builtins/abort
24286+
unreachable
24287+
end
24288+
i32.const 25344
24289+
local.set $4
24290+
global.get $~lib/memory/__stack_pointer
24291+
local.get $4
24292+
i32.store $0
24293+
local.get $4
24294+
i32.const 25344
24295+
local.set $4
24296+
global.get $~lib/memory/__stack_pointer
24297+
local.get $4
24298+
i32.store $0 offset=4
24299+
local.get $4
24300+
call $~lib/string/String.__eq
24301+
i32.eqz
24302+
if
24303+
i32.const 0
24304+
i32.const 96
24305+
i32.const 818
24306+
i32.const 1
24307+
call $~lib/builtins/abort
24308+
unreachable
24309+
end
24310+
i32.const 25376
24311+
local.set $4
24312+
global.get $~lib/memory/__stack_pointer
24313+
local.get $4
24314+
i32.store $0
24315+
local.get $4
24316+
i32.const 25376
24317+
local.set $4
24318+
global.get $~lib/memory/__stack_pointer
24319+
local.get $4
24320+
i32.store $0 offset=4
24321+
local.get $4
24322+
call $~lib/string/String.__eq
24323+
i32.eqz
24324+
if
24325+
i32.const 0
24326+
i32.const 96
24327+
i32.const 819
24328+
i32.const 1
24329+
call $~lib/builtins/abort
24330+
unreachable
24331+
end
2424124332
i32.const 0
2424224333
global.set $std/string/str
2424324334
global.get $~lib/memory/__heap_base

0 commit comments

Comments
 (0)