Skip to content

Commit 19a9561

Browse files
committed
add more tests for multiple RHS
1 parent 1541864 commit 19a9561

File tree

3 files changed

+26
-45
lines changed

3 files changed

+26
-45
lines changed

src/compile.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,6 @@ compile_remove_subexpr(Compile *compile, PElement *root)
14771477
static gboolean
14781478
compile_defs_check(Compile *compile)
14791479
{
1480-
g_assert(!compile->sym->generated);
14811480
g_assert(compile->sym->next_def || !compile->has_default);
14821481

14831482
int nparam = -1;

src/factorial.def

Lines changed: 0 additions & 38 deletions
This file was deleted.

test/workspaces/test_snip.def

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,29 +59,49 @@ test_binary op_name fn
5959
}
6060
}
6161

62-
test_deconstruct = concat [
62+
test_deconstruct = [
6363
[test_deconstruct, "deconstruct"],
6464
[test_struct_deconstruct, "structure deconstruct"],
65-
[test_arg_deconstruct, "argument deconstruct"]
65+
[test_arg_deconstruct, "argument deconstruct"],
66+
[test_list_deconstruct, "list deconstruct"],
67+
[test_arg_list_deconstruct, "arg list deconstruct"]
6668
]
6769
{
68-
[a] = [12];
70+
[a] = [12];
6971
test_deconstruct = a == 12;
7072

7173
[12, (13, b)] = [12, (13, 14)];
7274
test_struct_deconstruct = b == 14;
7375

7476
fred [a] = 12;
7577
test_arg_deconstruct = fred [99] == 12;
78+
79+
c:d = [1, 2];
80+
test_list_deconstruct = c == 1 && d == [2];
81+
82+
jim (a:x) = a:[1, 2];
83+
test_arg_list_deconstruct = jim [3] == [3, 1, 2];
7684
}
7785

78-
test_multidef = concat [
79-
[test_multidef, "multiple definitions"]
86+
global_factorial 1 = 1;
87+
global_factorial n = n * global_factorial (n - 1);
88+
89+
test_multidef = [
90+
[test_local_multidef, "local multiple definitions"],
91+
[test_global_multidef, "global multiple definitions"],
92+
[test_multidef_list_pattern, "list pattern multiple definitions"]
8093
]
8194
{
8295
factorial 1 = 1;
8396
factorial n = n * factorial (n - 1);
84-
test_multidef = factorial 3 == 6;
97+
test_local_multidef = factorial 3 == 6;
98+
99+
test_global_multidef = global_factorial 3 == 6;
100+
101+
foldr fn st [] = st;
102+
foldr fn st (x:xs) = fn x (foldr fn st xs);
103+
sum = foldr add 0;
104+
test_multidef_list_pattern = sum [1..10] == 55;
85105
}
86106

87107
tests = concat [

0 commit comments

Comments
 (0)