Skip to content

Commit

Permalink
Add some more string test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Jan 28, 2025
1 parent c4b456b commit 34a9c8e
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions test/asm/invalid-format.asm
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ println STRFMT("%q16s", "hello")

println STRFMT("%#d", 42)
println STRFMT("%.5d", 42)
println STRFMT("%q5d", 42)
4 changes: 3 additions & 1 deletion test/asm/invalid-format.err
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ error: invalid-format.asm(16):
Formatting type 'd' with exact flag '#'
error: invalid-format.asm(17):
Formatting type 'd' with fractional width
error: Assembly aborted (14 errors)!
error: invalid-format.asm(18):
Formatting type 'd' with fractional precision
error: Assembly aborted (15 errors)!
1 change: 1 addition & 0 deletions test/asm/invalid-format.out
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ hello
hello
42
42
42
14 changes: 14 additions & 0 deletions test/asm/invalid-utf-8-strings.asm
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,17 @@ println "\"{invalid}\" == \"{copy}\" ({d:n})"
DEF mid1 EQUS STRSUB("{invalid}", 5, 2)
DEF mid2 EQUS STRSUB("{invalid}", 9, 1)
println "\"{mid2}{mid1}\""

; characters:
; 1: U+0041 A
; 2: U+0020 space
; 3: invalid byte 0xFE
; 4: invalid byte 0x81
; 5: invalid byte 0xFF
; 6: U+0020 space
; 7: U+0042 B
REDEF invalid EQUS "A þÿ B"

DEF n = strlen("{invalid}")
DEF r = charlen("{invalid}")
println "\"{#s:invalid}\": {d:n} != {d:r}"
10 changes: 9 additions & 1 deletion test/asm/invalid-utf-8-strings.err
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,12 @@ error: invalid-utf-8-strings.asm(22):
STRSUB: Invalid UTF-8 byte 0xA3
error: invalid-utf-8-strings.asm(22):
STRSUB: Invalid UTF-8 byte 0xA4
error: Assembly aborted (22 errors)!
error: invalid-utf-8-strings.asm(35):
STRLEN: Invalid UTF-8 byte 0xFE
error: invalid-utf-8-strings.asm(35):
STRLEN: Invalid UTF-8 byte 0x81
error: invalid-utf-8-strings.asm(35):
STRLEN: Invalid UTF-8 byte 0xFF
error: invalid-utf-8-strings.asm(36):
Input string is not valid UTF-8
error: Assembly aborted (26 errors)!
1 change: 1 addition & 0 deletions test/asm/invalid-utf-8-strings.out
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"aäb漢,a��b��!" == "aäb漢,a��b��!" (12)
"b,a"
"A ��� B": 7 != 2
2 changes: 2 additions & 0 deletions test/asm/string-formatting.asm
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ def f equ -123.0456
def pi equ 3.14159
def s equs "hello"
def t equs "\"\\t\" is '\t'"
def u equs "\t\r\0\n"

println "<{ -6d:n}> <{+06u:n}> <{5x:n}> <{#16b:n}>"
println "<{u:m}> <{+3d:m}> <{#016o:m}>"
println "<{f:pi}> <{06.f:f}> <{.10f:f}>"
println "\"{#-20s:t}\", \"{#20s:t}\", \"{20s:t}\""
println "{#s:u}"

macro foo
println "\1 <{\1}>"
Expand Down
1 change: 1 addition & 0 deletions test/asm/string-formatting.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<4294967254> <-42> <&000037777777726>
<3.14159> <-00123> <-123.0455932617>
"\"\\t\" is '\t' ", " \"\\t\" is '\t'", " "\t" is ' '"
\t\r\0\n
-6d:n <300 >

0 comments on commit 34a9c8e

Please sign in to comment.