@@ -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
87107tests = concat [
0 commit comments