Skip to content

Commit c1f75b8

Browse files
committed
more unicode char tests
addd more tests in tests/execution/execution.toml: - unicode chars as UTF-8 - unicode chars as variable length escaped hex - unicode chars as fixed length escaped hex - unicode chars as fixed length escaped hex with surrogate pair - unicode chars as variable length escaped hex for SMP chars
1 parent 069be6f commit c1f75b8

File tree

2 files changed

+73
-1
lines changed

2 files changed

+73
-1
lines changed

tests/execution/engine.toml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,3 +882,73 @@ query($mm: String) {
882882
result = """
883883
null
884884
"""
885+
886+
[[units]]
887+
name = "unicode chars as UTF-8"
888+
code = """
889+
type Query {
890+
echo(arg: String): String
891+
}
892+
query {
893+
echo(arg: "hello 你好 世界 world")
894+
}
895+
"""
896+
result = """
897+
{"echo":"hello 你好 世界 world"}
898+
"""
899+
900+
[[units]]
901+
name = "unicode chars as variable length escaped hex"
902+
code = """
903+
type Query {
904+
echo(arg: String): String
905+
}
906+
query {
907+
echo(arg: "hello \\u{4f60}\\u{597d} \\u{4e16}\\u{754c} world")
908+
}
909+
"""
910+
result = """
911+
{"echo":"hello 你好 世界 world"}
912+
"""
913+
914+
[[units]]
915+
name = "unicode chars as fixed length escaped hex"
916+
code = """
917+
type Query {
918+
echo(arg: String): String
919+
}
920+
query {
921+
echo(arg: "hello \\u4f60\\u597d \\u4e16\\u754c world")
922+
}
923+
"""
924+
result = """
925+
{"echo":"hello 你好 世界 world"}
926+
"""
927+
928+
[[units]]
929+
name = "unicode chars as fixed length escaped hex with surrogate pair"
930+
code = """
931+
type Query {
932+
echo(arg: String): String
933+
}
934+
query {
935+
echo(arg: "brahmi \\ud804\\udc0a\\ud804\\udc0b\\ud804\\udc0c abc")
936+
}
937+
"""
938+
result = """
939+
{"echo":"brahmi 𑀊𑀋𑀌 abc"}
940+
"""
941+
942+
[[units]]
943+
name = "unicode chars as variable length escaped hex for SMP chars"
944+
code = """
945+
type Query {
946+
echo(arg: String): String
947+
}
948+
query {
949+
echo(arg: "brahmi \\u{1100a}\\u{1100b}\\u{1100c} abc")
950+
}
951+
"""
952+
result = """
953+
{"echo":"brahmi 𑀊𑀋𑀌 abc"}
954+
"""

tests/test_lexer.nim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,13 @@ suite "full range Unicode(UTF-8) support":
190190
scanEsc("\\u{E000}", "\u{E000}")
191191
scanEsc("\\uD83D\\uDCA9", "\u{1F4A9}")
192192
scanEsc("\\u{10FFFF}", "\u{10FFFF}")
193+
scanEsc("\\u{0A}", "\u{0A}")
194+
scanEsc("\\u{A}", "\u{A}")
193195

194196
test "orphaned surrogate":
195197
scanEscError("\\uD800", "Orphaned surrogate codepoint detected \'D800\'")
196198
scanEscError("\\uD801\\", "Orphaned surrogate codepoint detected \'D801\'")
197-
199+
198200
test "invalid sequence":
199201
scanEscError("\\uD802\\u", "Invalid unicode sequence ''")
200202
scanEscError("\\uDBFF\\uFFFF", "Invalid unicode sequence 'DBFF\\uFFFF'")

0 commit comments

Comments
 (0)