Skip to content

Add two to four bytes utf8 character tests #2495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions tests/compiler/std/string-encoding.debug.wat

Large diffs are not rendered by default.

112 changes: 56 additions & 56 deletions tests/compiler/std/string-encoding.release.wat

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions tests/compiler/std/string-encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ function testUTF8DecodeUnsafe(): void {
}
testUTF8DecodeUnsafe();

function testLarge(str: string): void {
function testRoundtrip(str: string): void {
var buf8 = String.UTF8.encode(str);
assert(String.UTF8.decode(buf8) == str);
var buf16 = String.UTF16.encode(str);
assert(String.UTF16.decode(buf16) == str);
}

// https://www.w3.org/2001/06/utf-8-test/UTF-8-demo.html
testLarge(`Mathematics and Sciences:
testRoundtrip(`Mathematics and Sciences:

∮ E⋅da = Q, n → ∞, ∑ f(i) = ∏ g(i), ∀x∈ℝ: ⌈x⌉ = −⌊−x⌋, α ∧ ¬β = ¬(¬α ∨ β),

Expand Down Expand Up @@ -349,7 +349,7 @@ Box drawing alignment tests: █
`);

// https://www.cl.cam.ac.uk/~mgk25/ucs/examples/quickbrown.txt
testLarge(`Sentences that contain all letters commonly used in a language
testRoundtrip(`Sentences that contain all letters commonly used in a language
--------------------------------------------------------------

Markus Kuhn <http://www.cl.cam.ac.uk/~mgk25/> -- 2012-04-11
Expand Down Expand Up @@ -490,6 +490,13 @@ Turkish (tr)

Pijamalı hasta, yağız şoföre çabucak güvendi.
(=Patient with pajamas, trusted swarthy driver quickly)

Other
-----

ÀÈ / c3_80 c3_88
变量 / e5_8f_98 e9_87_8f
𠜎𠜱 / f0_a0_9c_8e f0_a0_9c_b1
`);

__collect();
105 changes: 98 additions & 7 deletions tests/compiler/std/string.debug.wat
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@
(global $~lib/util/number/_K (mut i32) (i32.const 0))
(global $~lib/util/number/_frc_pow (mut i64) (i64.const 0))
(global $~lib/util/number/_exp_pow (mut i32) (i32.const 0))
(global $~lib/rt/__rtti_base i32 (i32.const 25296))
(global $~lib/memory/__data_end i32 (i32.const 25340))
(global $~lib/memory/__stack_pointer (mut i32) (i32.const 41724))
(global $~lib/memory/__heap_base i32 (i32.const 41724))
(global $~lib/rt/__rtti_base i32 (i32.const 25392))
(global $~lib/memory/__data_end i32 (i32.const 25436))
(global $~lib/memory/__stack_pointer (mut i32) (i32.const 41820))
(global $~lib/memory/__heap_base i32 (i32.const 41820))
(memory $0 1)
(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")
(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")
Expand Down Expand Up @@ -539,7 +539,10 @@
(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")
(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")
(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")
(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")
(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")
(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")
(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")
(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")
(table $0 1 1 funcref)
(elem $0 (i32.const 1))
(export "getString" (func $std/string/getString))
Expand Down Expand Up @@ -8102,8 +8105,8 @@
global.get $~lib/memory/__data_end
i32.lt_s
if
i32.const 41744
i32.const 41792
i32.const 41840
i32.const 41888
i32.const 1
i32.const 1
call $~lib/builtins/abort
Expand Down Expand Up @@ -24238,6 +24241,94 @@
call $~lib/builtins/abort
unreachable
end
i32.const 25312
local.set $4
global.get $~lib/memory/__stack_pointer
local.get $4
i32.store $0
local.get $4
i32.const 25312
local.set $4
global.get $~lib/memory/__stack_pointer
local.get $4
i32.store $0 offset=4
local.get $4
call $~lib/string/String.__eq
i32.eqz
if
i32.const 0
i32.const 96
i32.const 816
i32.const 1
call $~lib/builtins/abort
unreachable
end
i32.const 25312
local.set $4
global.get $~lib/memory/__stack_pointer
local.get $4
i32.store $0
local.get $4
i32.const 25312
local.set $4
global.get $~lib/memory/__stack_pointer
local.get $4
i32.store $0 offset=4
local.get $4
call $~lib/string/String.__eq
i32.eqz
if
i32.const 0
i32.const 96
i32.const 817
i32.const 1
call $~lib/builtins/abort
unreachable
end
i32.const 25344
local.set $4
global.get $~lib/memory/__stack_pointer
local.get $4
i32.store $0
local.get $4
i32.const 25344
local.set $4
global.get $~lib/memory/__stack_pointer
local.get $4
i32.store $0 offset=4
local.get $4
call $~lib/string/String.__eq
i32.eqz
if
i32.const 0
i32.const 96
i32.const 818
i32.const 1
call $~lib/builtins/abort
unreachable
end
i32.const 25376
local.set $4
global.get $~lib/memory/__stack_pointer
local.get $4
i32.store $0
local.get $4
i32.const 25376
local.set $4
global.get $~lib/memory/__stack_pointer
local.get $4
i32.store $0 offset=4
local.get $4
call $~lib/string/String.__eq
i32.eqz
if
i32.const 0
i32.const 96
i32.const 819
i32.const 1
call $~lib/builtins/abort
unreachable
end
i32.const 0
global.set $std/string/str
global.get $~lib/memory/__heap_base
Expand Down
Loading