mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 06:48:48 +00:00
Added test for .string
This commit is contained in:
parent
3cd95f8b5f
commit
06d05b1506
5 changed files with 65 additions and 7 deletions
43
regression/orig/test045.log
Normal file
43
regression/orig/test045.log
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
> 49
|
||||
34
|
||||
97
|
||||
98
|
||||
99
|
||||
34
|
||||
91
|
||||
93
|
||||
91
|
||||
49
|
||||
44
|
||||
32
|
||||
50
|
||||
44
|
||||
32
|
||||
51
|
||||
93
|
||||
96
|
||||
99
|
||||
111
|
||||
110
|
||||
115
|
||||
32
|
||||
40
|
||||
49
|
||||
44
|
||||
32
|
||||
96
|
||||
99
|
||||
111
|
||||
110
|
||||
115
|
||||
32
|
||||
40
|
||||
50
|
||||
44
|
||||
32
|
||||
96
|
||||
110
|
||||
105
|
||||
108
|
||||
41
|
||||
41
|
||||
12
regression/test045.expr
Normal file
12
regression/test045.expr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
fun printString (s) local i {
|
||||
for i := 0, i < s.length, i := i + 1 do
|
||||
write (s[i])
|
||||
od
|
||||
}
|
||||
|
||||
x := read ();
|
||||
printString (1.string);
|
||||
printString ("abc".string);
|
||||
printString ([].string);
|
||||
printString ([1, 2, 3].string);
|
||||
printString (`cons (1, `cons (2, `nil)).string)
|
||||
1
regression/test045.input
Normal file
1
regression/test045.input
Normal file
|
|
@ -0,0 +1 @@
|
|||
0
|
||||
|
|
@ -121,12 +121,14 @@ static void printValue (void *p) {
|
|||
|
||||
case SEXP_TAG:
|
||||
printStringBuf ("`%s", de_hash (TO_SEXP(p)->tag));
|
||||
if (LEN(a->tag)) {
|
||||
printStringBuf (" (");
|
||||
for (int i = 0; i < LEN(a->tag); i++) {
|
||||
printValue ((void*)((int*) a->contents)[i]);
|
||||
if (i != LEN(a->tag) - 1) printStringBuf (", ");
|
||||
}
|
||||
printStringBuf (")");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@ module Value =
|
|||
| Int n -> append (string_of_int n)
|
||||
| String s -> append "\""; append s; append "\""
|
||||
| Array a -> let n = List.length a in
|
||||
append "["; List.iteri (fun i a -> (if i < n-1 then append ", "); inner a) a; append "]"
|
||||
append "["; List.iteri (fun i a -> (if i > 0 then append ", "); inner a) a; append "]"
|
||||
| Sexp (t, a) -> let n = List.length a in
|
||||
append "`"; append t; append " ("; List.iteri (fun i a -> (if i < n-1 then append ", "); inner a) a; append ")"
|
||||
append "`"; append t; (if n > 0 then (append " ("; List.iteri (fun i a -> (if i > 0 then append ", "); inner a) a; append ")"))
|
||||
in
|
||||
inner v;
|
||||
Buffer.contents buf
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue