on master help sign in
Fix tests for ASCII characters in RTS (#3767)
a3d0a3aAlex Queiroz
rts/idris_rts.c+1−1
@@ -714,7 +714,7 @@ VAL idris_strCons(VM* vm, VAL x, VAL xs) {
714 int xval = GETINT(x);
714 int xval = GETINT(x);
715 int xlen = GETSTRLEN(xs);
715 int xlen = GETSTRLEN(xs);
716
716
717− if ((xval & 0x80) == 0) { // ASCII char
717+ if (xval < 0x80) { // ASCII char
718 Closure* cl = allocate(sizeof(Closure) +
718 Closure* cl = allocate(sizeof(Closure) +
719 xlen + 2, 0);
719 xlen + 2, 0);
720 SETTY(cl, CT_STRING);
720 SETTY(cl, CT_STRING);
rts/idris_utf8.c+1−1
@@ -119,7 +119,7 @@ char* idris_utf8_fromChar(int x) {
119 char* str;
119 char* str;
120 int bytes = 0, top = 0;
120 int bytes = 0, top = 0;
121
121
122− if ((x & 0x80) == 0) {
122+ if (x < 0x80) {
123 str = malloc(2);
123 str = malloc(2);
124 str[0] = (char)x;
124 str[0] = (char)x;
125 str[1] = '\0';
125 str[1] = '\0';
test/basic013/basic013.idr+2
@@ -20,6 +20,8 @@ main = do putStrLn foo
20 putStrLn (reverse (foo ++ bar))
20 putStrLn (reverse (foo ++ bar))
21 printLn (length foo)
21 printLn (length foo)
22 printLn baz
22 printLn baz
23+ printLn (strCons '\x141' "")
24+ printLn (singleton (chr 0x141))
23 let x = 4
25 let x = 4
24 let newstr = appMany (toNat x)
26 let newstr = appMany (toNat x)
25 putStrLn newstr
27 putStrLn newstr
test/basic013/expected+2
@@ -3,6 +3,8 @@
3x→xλx→xλ
3x→xλx→xλ
44
44
5'\955'
5'\955'
6+"\321"
7+"\321"
6λx→xλx→xλx→xλx→xλx→x
8λx→xλx→xλx→xλx→xλx→x
7'\955'
9'\955'
820
1020