Skip to content

Commit 1e13a41

Browse files
committed
Testing
1 parent 0ee96a3 commit 1e13a41

File tree

9 files changed

+81
-15
lines changed

9 files changed

+81
-15
lines changed

crates/sml-core/src/pretty_print/core.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,13 @@ impl<'a> Type<'a> {
156156
}
157157
Type::Record(fields) => {
158158
if let Symbol::Tuple(_) = fields[0].label {
159-
pp.text("(");
160159
for (idx, row) in fields.iter().enumerate() {
161160
row.data.print_rename(pp, map);
162161
if idx != fields.rows.len() - 1 {
163-
pp.text(", ");
162+
pp.text(" * ");
164163
}
165164
}
166-
pp.text(")")
165+
pp
167166
} else {
168167
pp.text("{");
169168
for (idx, row) in fields.iter().enumerate() {
@@ -222,6 +221,9 @@ impl<'a> Print for Decl<'a> {
222221
vec![lam.ty, lam.body.ty],
223222
))
224223
.text(" = ")
224+
.text("fn ")
225+
.print(&lam.arg)
226+
.text(" => ")
225227
.print(&lam.body);
226228
}
227229
pp

tests/match_compile/merge.sml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
(* test pattern matching
1+
(* test pattern match compilation to decision trees
2+
23
-- args: --vv
34
-- expected stdout:
4-
-- val merge: 'a list -> 'a list -> 'a list = fn b =>
5+
-- val merge: 'a list -> 'a list -> 'a list = fn a => fn b =>
56
-- let
6-
-- val e: 'a list -> 'a list =
7+
-- val e: 'a list -> 'a list = fn d =>
78
-- let
89
-- val xs: 'a list = d
910
-- in
1011
-- xs
1112
-- end
12-
-- val g: 'a list -> 'a list =
13+
-- val g: 'a list -> 'a list = fn f =>
1314
-- let
1415
-- val ys: 'a list = f
1516
-- in
1617
-- ys
1718
-- end
18-
-- val i: ('a, 'a list, 'a, 'a list) -> 'a list =
19+
-- val i: 'a * 'a list * 'a * 'a list -> 'a list = fn h =>
1920
-- let
20-
-- val (x, xs, y, ys): ('a, 'a list, 'a, 'a list) = h
21+
-- val (x, xs, y, ys): 'a * 'a list * 'a * 'a list = h
2122
-- in
2223
-- :: (x, :: (y, merge xs ys))
2324
-- end
@@ -30,19 +31,20 @@
3031
-- | _ => g b
3132
-- | :: l =>
3233
-- let
33-
-- val (m, n): ('a, 'a list) = l
34+
-- val (m, n): 'a * 'a list = l
3435
-- in
3536
--
3637
-- case b
3738
-- of nil => e a
3839
-- | :: p =>
3940
-- let
40-
-- val (q, r): ('a, 'a list) = p
41+
-- val (q, r): 'a * 'a list = p
4142
-- in
4243
-- i (m, n, q, r)
4344
-- end
4445
-- end
4546
-- end
47+
4648
*)
4749

4850
fun merge xs [] = xs

tests/parser/empty.sml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
(* parser throws an error on empty file, or no declaration
2+
23
-- expected stdout:
34
-- 0 warnings, 1 errors
45
56
-- expected stderr:
67
-- Error
78
-- 1,1 expected declaration, but encountered EOF
9+
810
*)

tests/parser/toplevel.sml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
(* Test that the parser will issue a warning on top-level expression
2+
23
-- args: --v
34
-- expected stdout:
45
-- val _: int
@@ -7,7 +8,8 @@
78
89
-- expected stderr:
910
-- Warn
10-
-- 13,1 top level expressions are not supported! emitting `val _ = ...`
11+
-- 15,1 top level expressions are not supported! emitting `val _ = ...`
12+
1113
*)
1214

1315
if true then 1 else 0

tests/typecheck/cantunify.sml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(* Check that type unification will fail in obvious cases
2+
3+
-- args: --v
4+
-- expected stdout:
5+
-- val +: int * int -> int
6+
-- val add: int -> int -> int
7+
-- val _: int
8+
--
9+
-- 0 warnings, 1 errors
10+
11+
-- expected stderr:
12+
-- Error
13+
-- 22,9 Can't unify type constructors interned symbol and interned symbol
14+
15+
*)
16+
17+
val + = primitive "Int.add" : int * int -> int
18+
infix 3 +
19+
20+
fun add x y = x + y
21+
22+
val _ = add 3 true

tests/typecheck/cyclic.sml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
(* create a cyclic type
2+
23
-- expected stderr:
34
-- Error
4-
-- 16,21 Cyclic type detected: 'i#1 interned symbol
5+
-- 18,21 Cyclic type detected: 'i#1 interned symbol
56
--
67
-- Error
7-
-- 16,5 Cyclic type detected: 'i#1 interned symbol
8+
-- 18,5 Cyclic type detected: 'i#1 interned symbol
89
910
-- expected stdout:
1011
-- 0 warnings, 2 errors
12+
1113
*)
1214

1315

tests/typecheck/escape.sml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
(* catch escaping datatypes
2+
3+
-- expected stdout:
4+
-- 0 warnings, 1 errors
5+
6+
-- expected stderr:
7+
-- Error
8+
-- 16,5 type interned symbol escapes inner scope!
9+
10+
*)
11+
12+
val _ =
13+
let
14+
datatype t = T of int
15+
in
16+
T 10
17+
end

tests/typecheck/exception.sml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
(* check elaboration of exceptions
2+
3+
-- args: --v
4+
-- expected stdout:
5+
-- val try: int -> int
6+
-- val x: int
7+
8+
*)
9+
10+
exception EX of int;
11+
12+
fun try 0 = raise (EX 0)
13+
| try n = n
14+
15+
val x = try 1 handle EX x => x;

tests/typecheck/records.sml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
(* record types are sorted in unspecified, but fixed order
2+
23
-- args: --v
34
-- expected stdout:
45
-- val x: {a: int, b: int, c: bool}
56
-- val y: {a: int, b: int, c: bool}
6-
-- val test: {a: int, b: int, c: bool} -> (int, int)
7+
-- val test: {a: int, b: int, c: bool} -> int * int
8+
79
*)
810

911
val x = {a = 10, b = 12, c = true}

0 commit comments

Comments
 (0)