From 98f77e4a9aaff56e4a24919932076a4cee2a5598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Tue, 9 Mar 2021 19:46:01 +0100 Subject: move some tests --- progs/tests/_simple.sy | 23 --------- progs/tests/add.sy | 3 -- progs/tests/blob/cluster.sy | 14 ++++++ progs/tests/blob/complex.sy | 17 +++++++ progs/tests/blob/field.sy | 3 ++ progs/tests/blob/field_assign.sy | 5 ++ progs/tests/blob/field_get.sy | 7 +++ progs/tests/blob/infer.sy | 6 +++ progs/tests/blob/instantiate.sy | 5 ++ progs/tests/blob/multiple_fields.sy | 11 +++++ progs/tests/blob/simple.sy | 10 ++++ progs/tests/blob_complex.sy | 19 -------- progs/tests/blob_infer.sy | 8 ---- progs/tests/blob_simple.sy | 10 ---- progs/tests/boolean_ops.sy | 56 ---------------------- progs/tests/boolean_order.sy | 42 ---------------- progs/tests/calls_inside_calls.sy | 11 ----- progs/tests/cluster.sy | 14 ------ progs/tests/constant/declaration_order.sy | 6 +++ progs/tests/constant/declaration_order_wrong.sy | 8 ++++ progs/tests/constant/function.sy | 4 ++ progs/tests/constant/function_closure.sy | 13 +++++ progs/tests/constant/function_complex.sy | 19 ++++++++ progs/tests/constant/global_collision.sy | 10 ++++ progs/tests/constant/global_constants.sy | 17 +++++++ progs/tests/constant/in_inner_functions.sy | 20 ++++++++ progs/tests/constant_function.sy | 4 -- progs/tests/constant_function_closure.sy | 13 ----- progs/tests/constant_function_complex.sy | 19 -------- progs/tests/constants_declaration_order.sy | 6 --- progs/tests/constants_declaration_order_wrong.sy | 8 ---- progs/tests/constants_in_inner_functions.sy | 20 -------- progs/tests/div.sy | 5 -- progs/tests/else_.sy | 10 ---- progs/tests/else_if.sy | 12 ----- progs/tests/expression/add.sy | 9 ++++ progs/tests/expression/boolean_ops_count.sy | 41 ++++++++++++++++ progs/tests/expression/boolean_order.sy | 42 ++++++++++++++++ progs/tests/expression/div.sy | 5 ++ progs/tests/expression/in_rhs.sy | 3 ++ progs/tests/expression/negation.sy | 7 +++ progs/tests/expression/parenthesis.sy | 3 ++ progs/tests/expression/simple.sy | 5 ++ progs/tests/expression/sub.sy | 9 ++++ progs/tests/expression/terms_and_factors.sy | 4 ++ progs/tests/expressions.sy | 6 --- progs/tests/field.sy | 3 -- progs/tests/field_assign.sy | 5 -- progs/tests/field_get.sy | 7 --- progs/tests/for.sy | 21 -------- progs/tests/func/calls_inside_calls.sy | 11 +++++ progs/tests/func/exclamation_calling.sy | 5 ++ progs/tests/func/inner_simple.sy | 4 ++ progs/tests/func/multiple_returns.sy | 12 +++++ progs/tests/func/one_arg.sy | 5 ++ progs/tests/func/param_1.sy | 4 ++ progs/tests/func/param_2.sy | 7 +++ progs/tests/func/param_and_return.sy | 7 +++ progs/tests/func/passing_functions_as_arguments.sy | 9 ++++ .../func/passing_functions_as_arguments_mixed.sy | 9 ++++ progs/tests/func/precedence.sy | 8 ++++ progs/tests/func/return_1.sy | 6 +++ progs/tests/func/returning_closures.sy | 24 ++++++++++ progs/tests/func/three_arg.sy | 5 ++ progs/tests/func/two_arg.sy | 5 ++ progs/tests/func/uncallable_type.sy | 8 ++++ progs/tests/func/wrong_params.sy | 7 +++ progs/tests/func/wrong_ret.sy | 7 +++ progs/tests/global_collision.sy | 10 ---- progs/tests/global_constants.sy | 17 ------- progs/tests/if_else.sy | 10 ++++ progs/tests/if_else_if.sy | 12 +++++ progs/tests/in_rhs.sy | 3 -- progs/tests/instantiate.sy | 5 -- progs/tests/loop_for.sy | 37 ++++++++++++++ progs/tests/more_types.sy | 4 -- progs/tests/mul.sy | 3 -- progs/tests/multiple_fields.sy | 11 ----- progs/tests/multiple_returns.sy | 12 ----- progs/tests/negation.sy | 7 --- progs/tests/not.sy | 5 -- progs/tests/one_arg.sy | 5 -- progs/tests/param_1.sy | 4 -- progs/tests/param_2.sy | 7 --- progs/tests/param_and_return.sy | 7 --- progs/tests/parenthesis.sy | 3 -- progs/tests/passing_functions.sy | 9 ---- progs/tests/passing_functions_mixed.sy | 9 ---- progs/tests/precedence.sy | 8 ---- progs/tests/return_1.sy | 6 --- progs/tests/returning_closures.sy | 24 ---------- progs/tests/simple_add.sy | 9 ---- progs/tests/simple_sub.sy | 9 ---- progs/tests/simplest.sy | 4 -- progs/tests/sub.sy | 3 -- progs/tests/terms_and_factors.sy | 4 -- progs/tests/three_arg.sy | 5 -- progs/tests/tuple/add.sy | 3 ++ progs/tests/tuple/basic.sy | 24 ++++++++++ progs/tests/tuple/fail_invalid_singleton.sy | 7 +++ progs/tests/tuple/fail_out_of_bounds.sy | 6 +++ progs/tests/tuple/mul.sy | 3 ++ progs/tests/tuple/multiple_types.sy | 4 ++ progs/tests/tuple/sub.sy | 3 ++ progs/tests/tuple/types.sy | 4 ++ progs/tests/tuples.sy | 24 ---------- progs/tests/tuples_fail_invalid_singleton.sy | 7 --- progs/tests/tuples_fail_out_of_bounds.sy | 6 --- progs/tests/two_arg.sy | 5 -- progs/tests/types.sy | 4 -- progs/tests/uncallable_type.sy | 8 ---- progs/tests/wrong_params.sy | 7 --- progs/tests/wrong_ret.sy | 7 --- 113 files changed, 559 insertions(+), 586 deletions(-) delete mode 100644 progs/tests/_simple.sy delete mode 100644 progs/tests/add.sy create mode 100644 progs/tests/blob/cluster.sy create mode 100644 progs/tests/blob/complex.sy create mode 100644 progs/tests/blob/field.sy create mode 100644 progs/tests/blob/field_assign.sy create mode 100644 progs/tests/blob/field_get.sy create mode 100644 progs/tests/blob/infer.sy create mode 100644 progs/tests/blob/instantiate.sy create mode 100644 progs/tests/blob/multiple_fields.sy create mode 100644 progs/tests/blob/simple.sy delete mode 100644 progs/tests/blob_complex.sy delete mode 100644 progs/tests/blob_infer.sy delete mode 100644 progs/tests/blob_simple.sy delete mode 100644 progs/tests/boolean_ops.sy delete mode 100644 progs/tests/boolean_order.sy delete mode 100644 progs/tests/calls_inside_calls.sy delete mode 100644 progs/tests/cluster.sy create mode 100644 progs/tests/constant/declaration_order.sy create mode 100644 progs/tests/constant/declaration_order_wrong.sy create mode 100644 progs/tests/constant/function.sy create mode 100644 progs/tests/constant/function_closure.sy create mode 100644 progs/tests/constant/function_complex.sy create mode 100644 progs/tests/constant/global_collision.sy create mode 100644 progs/tests/constant/global_constants.sy create mode 100644 progs/tests/constant/in_inner_functions.sy delete mode 100644 progs/tests/constant_function.sy delete mode 100644 progs/tests/constant_function_closure.sy delete mode 100644 progs/tests/constant_function_complex.sy delete mode 100644 progs/tests/constants_declaration_order.sy delete mode 100644 progs/tests/constants_declaration_order_wrong.sy delete mode 100644 progs/tests/constants_in_inner_functions.sy delete mode 100644 progs/tests/div.sy delete mode 100644 progs/tests/else_.sy delete mode 100644 progs/tests/else_if.sy create mode 100644 progs/tests/expression/add.sy create mode 100644 progs/tests/expression/boolean_ops_count.sy create mode 100644 progs/tests/expression/boolean_order.sy create mode 100644 progs/tests/expression/div.sy create mode 100644 progs/tests/expression/in_rhs.sy create mode 100644 progs/tests/expression/negation.sy create mode 100644 progs/tests/expression/parenthesis.sy create mode 100644 progs/tests/expression/simple.sy create mode 100644 progs/tests/expression/sub.sy create mode 100644 progs/tests/expression/terms_and_factors.sy delete mode 100644 progs/tests/expressions.sy delete mode 100644 progs/tests/field.sy delete mode 100644 progs/tests/field_assign.sy delete mode 100644 progs/tests/field_get.sy delete mode 100644 progs/tests/for.sy create mode 100644 progs/tests/func/calls_inside_calls.sy create mode 100644 progs/tests/func/exclamation_calling.sy create mode 100644 progs/tests/func/inner_simple.sy create mode 100644 progs/tests/func/multiple_returns.sy create mode 100644 progs/tests/func/one_arg.sy create mode 100644 progs/tests/func/param_1.sy create mode 100644 progs/tests/func/param_2.sy create mode 100644 progs/tests/func/param_and_return.sy create mode 100644 progs/tests/func/passing_functions_as_arguments.sy create mode 100644 progs/tests/func/passing_functions_as_arguments_mixed.sy create mode 100644 progs/tests/func/precedence.sy create mode 100644 progs/tests/func/return_1.sy create mode 100644 progs/tests/func/returning_closures.sy create mode 100644 progs/tests/func/three_arg.sy create mode 100644 progs/tests/func/two_arg.sy create mode 100644 progs/tests/func/uncallable_type.sy create mode 100644 progs/tests/func/wrong_params.sy create mode 100644 progs/tests/func/wrong_ret.sy delete mode 100644 progs/tests/global_collision.sy delete mode 100644 progs/tests/global_constants.sy create mode 100644 progs/tests/if_else.sy create mode 100644 progs/tests/if_else_if.sy delete mode 100644 progs/tests/in_rhs.sy delete mode 100644 progs/tests/instantiate.sy create mode 100644 progs/tests/loop_for.sy delete mode 100644 progs/tests/more_types.sy delete mode 100644 progs/tests/mul.sy delete mode 100644 progs/tests/multiple_fields.sy delete mode 100644 progs/tests/multiple_returns.sy delete mode 100644 progs/tests/negation.sy delete mode 100644 progs/tests/not.sy delete mode 100644 progs/tests/one_arg.sy delete mode 100644 progs/tests/param_1.sy delete mode 100644 progs/tests/param_2.sy delete mode 100644 progs/tests/param_and_return.sy delete mode 100644 progs/tests/parenthesis.sy delete mode 100644 progs/tests/passing_functions.sy delete mode 100644 progs/tests/passing_functions_mixed.sy delete mode 100644 progs/tests/precedence.sy delete mode 100644 progs/tests/return_1.sy delete mode 100644 progs/tests/returning_closures.sy delete mode 100644 progs/tests/simple_add.sy delete mode 100644 progs/tests/simple_sub.sy delete mode 100644 progs/tests/simplest.sy delete mode 100644 progs/tests/sub.sy delete mode 100644 progs/tests/terms_and_factors.sy delete mode 100644 progs/tests/three_arg.sy create mode 100644 progs/tests/tuple/add.sy create mode 100644 progs/tests/tuple/basic.sy create mode 100644 progs/tests/tuple/fail_invalid_singleton.sy create mode 100644 progs/tests/tuple/fail_out_of_bounds.sy create mode 100644 progs/tests/tuple/mul.sy create mode 100644 progs/tests/tuple/multiple_types.sy create mode 100644 progs/tests/tuple/sub.sy create mode 100644 progs/tests/tuple/types.sy delete mode 100644 progs/tests/tuples.sy delete mode 100644 progs/tests/tuples_fail_invalid_singleton.sy delete mode 100644 progs/tests/tuples_fail_out_of_bounds.sy delete mode 100644 progs/tests/two_arg.sy delete mode 100644 progs/tests/types.sy delete mode 100644 progs/tests/uncallable_type.sy delete mode 100644 progs/tests/wrong_params.sy delete mode 100644 progs/tests/wrong_ret.sy (limited to 'progs') diff --git a/progs/tests/_simple.sy b/progs/tests/_simple.sy deleted file mode 100644 index 84bc86d..0000000 --- a/progs/tests/_simple.sy +++ /dev/null @@ -1,23 +0,0 @@ -// -// import A - -// -f :: fn { - g! - print q -} - -// -q :: 1 - -// -a := 1 - -qq :: fn { - g! - print q -} - - -// Steg 1: Hitta sektioner -// Dela sektioner, compilera felera sektioner efter varandra diff --git a/progs/tests/add.sy b/progs/tests/add.sy deleted file mode 100644 index 3fadd86..0000000 --- a/progs/tests/add.sy +++ /dev/null @@ -1,3 +0,0 @@ -start :: fn { - (1, 2, 3, 4) + (4, 3, 2, 1) <=> (5, 5, 5, 5) -} diff --git a/progs/tests/blob/cluster.sy b/progs/tests/blob/cluster.sy new file mode 100644 index 0000000..dc8ec72 --- /dev/null +++ b/progs/tests/blob/cluster.sy @@ -0,0 +1,14 @@ +start :: fn { + + blob A { a: int } + a := A() + a.a = 0 + a.a += 1 + a.a <=> 1 + a.a *= 2 + a.a <=> 2 + a.a /= 2 + a.a <=> 1 + a.a -= 1 + a.a <=> 0 +} diff --git a/progs/tests/blob/complex.sy b/progs/tests/blob/complex.sy new file mode 100644 index 0000000..88c37a7 --- /dev/null +++ b/progs/tests/blob/complex.sy @@ -0,0 +1,17 @@ +start :: fn { + a := A() + b := B() + c := C() + b2 := B() + + a + b + c + b2 + + blob A { + c: C + } + blob C { } + blob B { } +} diff --git a/progs/tests/blob/field.sy b/progs/tests/blob/field.sy new file mode 100644 index 0000000..b11e51e --- /dev/null +++ b/progs/tests/blob/field.sy @@ -0,0 +1,3 @@ +start :: fn { + blob A { a: int } +} diff --git a/progs/tests/blob/field_assign.sy b/progs/tests/blob/field_assign.sy new file mode 100644 index 0000000..4fb6dd4 --- /dev/null +++ b/progs/tests/blob/field_assign.sy @@ -0,0 +1,5 @@ +start :: fn { + blob A { a: int } + a := A() + a.a = 2 +} diff --git a/progs/tests/blob/field_get.sy b/progs/tests/blob/field_get.sy new file mode 100644 index 0000000..49bb0f2 --- /dev/null +++ b/progs/tests/blob/field_get.sy @@ -0,0 +1,7 @@ +start :: fn { + blob A { a: int } + a := A() + a.a = 2 + a.a <=> 2 + 2 <=> a.a +} diff --git a/progs/tests/blob/infer.sy b/progs/tests/blob/infer.sy new file mode 100644 index 0000000..1dd7fec --- /dev/null +++ b/progs/tests/blob/infer.sy @@ -0,0 +1,6 @@ +start :: fn { + blob A { } + + a : A = A() + a +} diff --git a/progs/tests/blob/instantiate.sy b/progs/tests/blob/instantiate.sy new file mode 100644 index 0000000..bb2f09c --- /dev/null +++ b/progs/tests/blob/instantiate.sy @@ -0,0 +1,5 @@ +start :: fn { + blob A {} + a := A() + a +} diff --git a/progs/tests/blob/multiple_fields.sy b/progs/tests/blob/multiple_fields.sy new file mode 100644 index 0000000..ce4c61f --- /dev/null +++ b/progs/tests/blob/multiple_fields.sy @@ -0,0 +1,11 @@ +start :: fn { + blob A { + a: int + b: int + } + a := A() + a.a = 2 + a.b = 3 + a.a + a.b <=> 5 + 5 <=> a.a + a.b +} diff --git a/progs/tests/blob/simple.sy b/progs/tests/blob/simple.sy new file mode 100644 index 0000000..ea832cd --- /dev/null +++ b/progs/tests/blob/simple.sy @@ -0,0 +1,10 @@ +start :: fn { + + a := A() + a + + blob A { + a: int + } + +} diff --git a/progs/tests/blob_complex.sy b/progs/tests/blob_complex.sy deleted file mode 100644 index b139a3a..0000000 --- a/progs/tests/blob_complex.sy +++ /dev/null @@ -1,19 +0,0 @@ -start :: fn { - - a := A() - b := B() - c := C() - b2 := B() - - a - b - c - b2 - - blob A { - c: C - } - blob C { } - blob B { } - -} diff --git a/progs/tests/blob_infer.sy b/progs/tests/blob_infer.sy deleted file mode 100644 index 0a1ce1b..0000000 --- a/progs/tests/blob_infer.sy +++ /dev/null @@ -1,8 +0,0 @@ -start :: fn { - - blob A { } - - a : A = A() - a - -} diff --git a/progs/tests/blob_simple.sy b/progs/tests/blob_simple.sy deleted file mode 100644 index ea832cd..0000000 --- a/progs/tests/blob_simple.sy +++ /dev/null @@ -1,10 +0,0 @@ -start :: fn { - - a := A() - a - - blob A { - a: int - } - -} diff --git a/progs/tests/boolean_ops.sy b/progs/tests/boolean_ops.sy deleted file mode 100644 index 368068b..0000000 --- a/progs/tests/boolean_ops.sy +++ /dev/null @@ -1,56 +0,0 @@ -start :: fn { - ts := 0 - t :: fn -> bool { - ts += 1 - ret true - } - - fs := 0 - f :: fn -> bool { - fs += 1 - ret false - } - - i :: fn -> bool { - - ret false - } - - if f() && i() { - - } - - if t() || i() { - // Empty - } else { - - } - - if f() && i() && i() { - - } - - if t() || i() || i() { - // Empty - } else { - - } - - fs <=> 2 - ts <=> 2 -} - - - - // if t() || i() && f() { - // // Empty - // } else { - // - // } - - // if f() && t() || i() { - // // Empty - // } else { - // - // } - diff --git a/progs/tests/boolean_order.sy b/progs/tests/boolean_order.sy deleted file mode 100644 index ecec262..0000000 --- a/progs/tests/boolean_order.sy +++ /dev/null @@ -1,42 +0,0 @@ -start :: fn { - ts := 0 - t :: fn -> bool { - ts += 1 - ret true - } - - fs := 0 - f :: fn -> bool { - fs += 1 - ret false - } - - i :: fn -> bool { - - ret false - } - - if t() || i() && i() { - // Empty - } else { - - } - - if f() && i() || t() { - // Empty - } else { - - } - - fs <=> 1 - fs = 0 - ts <=> 2 - ts = 0 - - f() && i() || f() <=> t() && f() || f() - f() && i() || f() <=> (t() && f()) || f() - t() && t() && f() || t() <=> t() || i() && i() && i() - - fs <=> 9 - ts <=> 6 -} diff --git a/progs/tests/calls_inside_calls.sy b/progs/tests/calls_inside_calls.sy deleted file mode 100644 index 5f6716b..0000000 --- a/progs/tests/calls_inside_calls.sy +++ /dev/null @@ -1,11 +0,0 @@ -start :: fn { - one := fn -> int { - ret 1 - } - add := fn a: int, b: int -> int { - ret a + b - } - add(one(), one()) <=> 2 - add(add(one(), one()), one()) <=> 3 - add(one(), add(one(), one())) <=> 3 -} diff --git a/progs/tests/cluster.sy b/progs/tests/cluster.sy deleted file mode 100644 index dc8ec72..0000000 --- a/progs/tests/cluster.sy +++ /dev/null @@ -1,14 +0,0 @@ -start :: fn { - - blob A { a: int } - a := A() - a.a = 0 - a.a += 1 - a.a <=> 1 - a.a *= 2 - a.a <=> 2 - a.a /= 2 - a.a <=> 1 - a.a -= 1 - a.a <=> 0 -} diff --git a/progs/tests/constant/declaration_order.sy b/progs/tests/constant/declaration_order.sy new file mode 100644 index 0000000..93e6117 --- /dev/null +++ b/progs/tests/constant/declaration_order.sy @@ -0,0 +1,6 @@ +b :: 1 +a :: b + 1 + +start :: fn { + a <=> b + 1 +} diff --git a/progs/tests/constant/declaration_order_wrong.sy b/progs/tests/constant/declaration_order_wrong.sy new file mode 100644 index 0000000..37f5050 --- /dev/null +++ b/progs/tests/constant/declaration_order_wrong.sy @@ -0,0 +1,8 @@ +a :: b + 1 +b :: 1 + +start :: fn { + a <=> b + 1 +} + +// errors: [ErrorKind::SyntaxError(1, _)] diff --git a/progs/tests/constant/function.sy b/progs/tests/constant/function.sy new file mode 100644 index 0000000..22ddfe2 --- /dev/null +++ b/progs/tests/constant/function.sy @@ -0,0 +1,4 @@ +a :: fn {} +start :: fn { + a() +} diff --git a/progs/tests/constant/function_closure.sy b/progs/tests/constant/function_closure.sy new file mode 100644 index 0000000..6c7f0d7 --- /dev/null +++ b/progs/tests/constant/function_closure.sy @@ -0,0 +1,13 @@ +q : int = 1 + +f :: fn -> int { + q += 1 + ret q +} + +start :: fn { + f() <=> 2 + f() <=> 3 + f() <=> 4 + f() <=> 5 +} diff --git a/progs/tests/constant/function_complex.sy b/progs/tests/constant/function_complex.sy new file mode 100644 index 0000000..6a60ebe --- /dev/null +++ b/progs/tests/constant/function_complex.sy @@ -0,0 +1,19 @@ +h :: fn -> int { + ret 3 +} + +k :: fn -> int { + ret h() +} + +a :: fn -> int { + ret q() +} + +q :: fn -> int { + ret k() +} + +start :: fn { + a() <=> 3 +} diff --git a/progs/tests/constant/global_collision.sy b/progs/tests/constant/global_collision.sy new file mode 100644 index 0000000..6bce509 --- /dev/null +++ b/progs/tests/constant/global_collision.sy @@ -0,0 +1,10 @@ +fac :: fn a: int -> int { + if a < 1 { ret 1 } + ret a * fac! a - 1 +} + +a :: fac! 4 + +start :: fn { + a <=> 24 +} diff --git a/progs/tests/constant/global_constants.sy b/progs/tests/constant/global_constants.sy new file mode 100644 index 0000000..7ee6ca5 --- /dev/null +++ b/progs/tests/constant/global_constants.sy @@ -0,0 +1,17 @@ +// TODO(ed): Pure functions +fac :: fn n: int -> int { + if n < 1 { ret 1 } + ret n * fac! n - 1 +} + +a :: fac! 4 +b :: a + fac! 2 +c := b + 1 + +start :: fn { + a <=> 24 + b <=> 24 + 2 + c <=> 24 + 2 + 1 + c += 1 + c <=> 24 + 2 + 2 +} diff --git a/progs/tests/constant/in_inner_functions.sy b/progs/tests/constant/in_inner_functions.sy new file mode 100644 index 0000000..99704e7 --- /dev/null +++ b/progs/tests/constant/in_inner_functions.sy @@ -0,0 +1,20 @@ +start :: fn { + + q : int = 0 + + f :: fn -> fn -> { + g :: fn { + q += 1 + } + ret g + } + + g := f() + g() + q <=> 1 + g() + q <=> 2 + g() + q <=> 3 + +} diff --git a/progs/tests/constant_function.sy b/progs/tests/constant_function.sy deleted file mode 100644 index 22ddfe2..0000000 --- a/progs/tests/constant_function.sy +++ /dev/null @@ -1,4 +0,0 @@ -a :: fn {} -start :: fn { - a() -} diff --git a/progs/tests/constant_function_closure.sy b/progs/tests/constant_function_closure.sy deleted file mode 100644 index 6c7f0d7..0000000 --- a/progs/tests/constant_function_closure.sy +++ /dev/null @@ -1,13 +0,0 @@ -q : int = 1 - -f :: fn -> int { - q += 1 - ret q -} - -start :: fn { - f() <=> 2 - f() <=> 3 - f() <=> 4 - f() <=> 5 -} diff --git a/progs/tests/constant_function_complex.sy b/progs/tests/constant_function_complex.sy deleted file mode 100644 index 6a60ebe..0000000 --- a/progs/tests/constant_function_complex.sy +++ /dev/null @@ -1,19 +0,0 @@ -h :: fn -> int { - ret 3 -} - -k :: fn -> int { - ret h() -} - -a :: fn -> int { - ret q() -} - -q :: fn -> int { - ret k() -} - -start :: fn { - a() <=> 3 -} diff --git a/progs/tests/constants_declaration_order.sy b/progs/tests/constants_declaration_order.sy deleted file mode 100644 index 93e6117..0000000 --- a/progs/tests/constants_declaration_order.sy +++ /dev/null @@ -1,6 +0,0 @@ -b :: 1 -a :: b + 1 - -start :: fn { - a <=> b + 1 -} diff --git a/progs/tests/constants_declaration_order_wrong.sy b/progs/tests/constants_declaration_order_wrong.sy deleted file mode 100644 index 37f5050..0000000 --- a/progs/tests/constants_declaration_order_wrong.sy +++ /dev/null @@ -1,8 +0,0 @@ -a :: b + 1 -b :: 1 - -start :: fn { - a <=> b + 1 -} - -// errors: [ErrorKind::SyntaxError(1, _)] diff --git a/progs/tests/constants_in_inner_functions.sy b/progs/tests/constants_in_inner_functions.sy deleted file mode 100644 index 99704e7..0000000 --- a/progs/tests/constants_in_inner_functions.sy +++ /dev/null @@ -1,20 +0,0 @@ -start :: fn { - - q : int = 0 - - f :: fn -> fn -> { - g :: fn { - q += 1 - } - ret g - } - - g := f() - g() - q <=> 1 - g() - q <=> 2 - g() - q <=> 3 - -} diff --git a/progs/tests/div.sy b/progs/tests/div.sy deleted file mode 100644 index df3e7bb..0000000 --- a/progs/tests/div.sy +++ /dev/null @@ -1,5 +0,0 @@ -start :: fn { - a := 2 - a /= 2 - a <=> 1 -} diff --git a/progs/tests/else_.sy b/progs/tests/else_.sy deleted file mode 100644 index 0f1d624..0000000 --- a/progs/tests/else_.sy +++ /dev/null @@ -1,10 +0,0 @@ -start :: fn { - a := 1 - res := 0 - if a == 0 { - - } else { - res = 1 - } - res <=> 1 -} diff --git a/progs/tests/else_if.sy b/progs/tests/else_if.sy deleted file mode 100644 index f31453e..0000000 --- a/progs/tests/else_if.sy +++ /dev/null @@ -1,12 +0,0 @@ -start :: fn { - a := 1 - res := 0 - if a == 0 { - - } else if a == 1 { - res = 1 - } else { - - } - res <=> 1 -} diff --git a/progs/tests/expression/add.sy b/progs/tests/expression/add.sy new file mode 100644 index 0000000..7be4012 --- /dev/null +++ b/progs/tests/expression/add.sy @@ -0,0 +1,9 @@ +start :: fn { + + a := 0 + b := 99999 + a += 1 + a <=> 1 + b <=> 99999 + +} diff --git a/progs/tests/expression/boolean_ops_count.sy b/progs/tests/expression/boolean_ops_count.sy new file mode 100644 index 0000000..b4a43e9 --- /dev/null +++ b/progs/tests/expression/boolean_ops_count.sy @@ -0,0 +1,41 @@ +start :: fn { + ts := 0 + t :: fn -> bool { + ts += 1 + ret true + } + + fs := 0 + f :: fn -> bool { + fs += 1 + ret false + } + + i :: fn -> bool { + + ret false + } + + if f() && i() { + + } + + if t() || i() { + // This block is intentionally left blank + } else { + + } + + if f() && i() && i() { + + } + + if t() || i() || i() { + // This block is intentionally left blank + } else { + + } + + fs <=> 2 + ts <=> 2 +} diff --git a/progs/tests/expression/boolean_order.sy b/progs/tests/expression/boolean_order.sy new file mode 100644 index 0000000..567c068 --- /dev/null +++ b/progs/tests/expression/boolean_order.sy @@ -0,0 +1,42 @@ +start :: fn { + ts := 0 + t :: fn -> bool { + ts += 1 + ret true + } + + fs := 0 + f :: fn -> bool { + fs += 1 + ret false + } + + i :: fn -> bool { + + ret false + } + + if t() || i() && i() { + // This block is intentionally left blank + } else { + + } + + if f() && i() || t() { + // This block is intentionally left blank + } else { + + } + + fs <=> 1 + fs = 0 + ts <=> 2 + ts = 0 + + f() && i() || f() <=> t() && f() || f() + f() && i() || f() <=> (t() && f()) || f() + t() && t() && f() || t() <=> t() || i() && i() && i() + + fs <=> 9 + ts <=> 6 +} diff --git a/progs/tests/expression/div.sy b/progs/tests/expression/div.sy new file mode 100644 index 0000000..df3e7bb --- /dev/null +++ b/progs/tests/expression/div.sy @@ -0,0 +1,5 @@ +start :: fn { + a := 2 + a /= 2 + a <=> 1 +} diff --git a/progs/tests/expression/in_rhs.sy b/progs/tests/expression/in_rhs.sy new file mode 100644 index 0000000..28ed276 --- /dev/null +++ b/progs/tests/expression/in_rhs.sy @@ -0,0 +1,3 @@ +start :: fn { + 5 <=> 1 * 2 + 3 +} diff --git a/progs/tests/expression/negation.sy b/progs/tests/expression/negation.sy new file mode 100644 index 0000000..0c702aa --- /dev/null +++ b/progs/tests/expression/negation.sy @@ -0,0 +1,7 @@ +start :: fn { + -1 <=> 0 - 1 + -1 + 2 <=> 1 + -(1 + 2) <=> -3 + 1 + -1 <=> 0 + 2 * -1 <=> -2 +} diff --git a/progs/tests/expression/parenthesis.sy b/progs/tests/expression/parenthesis.sy new file mode 100644 index 0000000..dd6fe8a --- /dev/null +++ b/progs/tests/expression/parenthesis.sy @@ -0,0 +1,3 @@ +start :: fn { + (1 + 2) * 3 <=> 9 +} diff --git a/progs/tests/expression/simple.sy b/progs/tests/expression/simple.sy new file mode 100644 index 0000000..29d7c76 --- /dev/null +++ b/progs/tests/expression/simple.sy @@ -0,0 +1,5 @@ +start :: fn { + 1 + 1 // blargh + 2 // blargh + // HARGH +} diff --git a/progs/tests/expression/sub.sy b/progs/tests/expression/sub.sy new file mode 100644 index 0000000..c220b8f --- /dev/null +++ b/progs/tests/expression/sub.sy @@ -0,0 +1,9 @@ +start :: fn { + + a := 0 + b := 99999 + a -= 1 + a <=> -1 + b <=> 99999 + +} diff --git a/progs/tests/expression/terms_and_factors.sy b/progs/tests/expression/terms_and_factors.sy new file mode 100644 index 0000000..42a48e2 --- /dev/null +++ b/progs/tests/expression/terms_and_factors.sy @@ -0,0 +1,4 @@ +start :: fn { + 1 + 1 * 2 <=> 3 + 1 * 2 + 3 <=> 5 +} diff --git a/progs/tests/expressions.sy b/progs/tests/expressions.sy deleted file mode 100644 index 99569e4..0000000 --- a/progs/tests/expressions.sy +++ /dev/null @@ -1,6 +0,0 @@ -start :: fn { - 1 + 1 // blargh - 2 // blargh - // HARGH - -} diff --git a/progs/tests/field.sy b/progs/tests/field.sy deleted file mode 100644 index b11e51e..0000000 --- a/progs/tests/field.sy +++ /dev/null @@ -1,3 +0,0 @@ -start :: fn { - blob A { a: int } -} diff --git a/progs/tests/field_assign.sy b/progs/tests/field_assign.sy deleted file mode 100644 index 4fb6dd4..0000000 --- a/progs/tests/field_assign.sy +++ /dev/null @@ -1,5 +0,0 @@ -start :: fn { - blob A { a: int } - a := A() - a.a = 2 -} diff --git a/progs/tests/field_get.sy b/progs/tests/field_get.sy deleted file mode 100644 index 49bb0f2..0000000 --- a/progs/tests/field_get.sy +++ /dev/null @@ -1,7 +0,0 @@ -start :: fn { - blob A { a: int } - a := A() - a.a = 2 - a.a <=> 2 - 2 <=> a.a -} diff --git a/progs/tests/for.sy b/progs/tests/for.sy deleted file mode 100644 index 285cbc3..0000000 --- a/progs/tests/for.sy +++ /dev/null @@ -1,21 +0,0 @@ -start :: fn { - a := 0 - for i := 0, i < 3, i = i + 1 { - a = a + i - } - a <=> 3 - - a = 0 - for i := 0, i <= 3, i = i + 1 { - a = a + i - } - a <=> 6 - - a = 0 - for i := 0, i < 3, i = i + 1 { - for j := 0, j < 3, j = j + 1 { - a = a + i * j - } - } - a <=> 9 -} diff --git a/progs/tests/func/calls_inside_calls.sy b/progs/tests/func/calls_inside_calls.sy new file mode 100644 index 0000000..5f6716b --- /dev/null +++ b/progs/tests/func/calls_inside_calls.sy @@ -0,0 +1,11 @@ +start :: fn { + one := fn -> int { + ret 1 + } + add := fn a: int, b: int -> int { + ret a + b + } + add(one(), one()) <=> 2 + add(add(one(), one()), one()) <=> 3 + add(one(), add(one(), one())) <=> 3 +} diff --git a/progs/tests/func/exclamation_calling.sy b/progs/tests/func/exclamation_calling.sy new file mode 100644 index 0000000..02dd81d --- /dev/null +++ b/progs/tests/func/exclamation_calling.sy @@ -0,0 +1,5 @@ +start :: fn { + f := fn {} + f! + +} diff --git a/progs/tests/func/inner_simple.sy b/progs/tests/func/inner_simple.sy new file mode 100644 index 0000000..14a6534 --- /dev/null +++ b/progs/tests/func/inner_simple.sy @@ -0,0 +1,4 @@ +start :: fn { + f := fn {} + f() +} diff --git a/progs/tests/func/multiple_returns.sy b/progs/tests/func/multiple_returns.sy new file mode 100644 index 0000000..6cb5e1a --- /dev/null +++ b/progs/tests/func/multiple_returns.sy @@ -0,0 +1,12 @@ +start :: fn { + f := fn a: int -> int { + if a == 1 { + ret 2 + } else { + ret 3 + } + } + f(0) <=> 3 + f(1) <=> 2 + f(2) <=> 3 +} diff --git a/progs/tests/func/one_arg.sy b/progs/tests/func/one_arg.sy new file mode 100644 index 0000000..e7dee83 --- /dev/null +++ b/progs/tests/func/one_arg.sy @@ -0,0 +1,5 @@ +start :: fn { + f := fn a:int { a <=> 1 } + f! 1 + +} diff --git a/progs/tests/func/param_1.sy b/progs/tests/func/param_1.sy new file mode 100644 index 0000000..c96089e --- /dev/null +++ b/progs/tests/func/param_1.sy @@ -0,0 +1,4 @@ +start :: fn { + f := fn a: int {} + f(1) +} diff --git a/progs/tests/func/param_2.sy b/progs/tests/func/param_2.sy new file mode 100644 index 0000000..1915c42 --- /dev/null +++ b/progs/tests/func/param_2.sy @@ -0,0 +1,7 @@ +start :: fn { + add := fn a: int, b: int -> int { + ret a + b + } + add(1, 1) <=> 2 + add(10, 20) <=> 30 +} diff --git a/progs/tests/func/param_and_return.sy b/progs/tests/func/param_and_return.sy new file mode 100644 index 0000000..2752fcc --- /dev/null +++ b/progs/tests/func/param_and_return.sy @@ -0,0 +1,7 @@ +start :: fn { + f := fn a: int -> int { + ret a * 2 + } + f(1) <=> 2 + f(5) <=> 10 +} diff --git a/progs/tests/func/passing_functions_as_arguments.sy b/progs/tests/func/passing_functions_as_arguments.sy new file mode 100644 index 0000000..e09a125 --- /dev/null +++ b/progs/tests/func/passing_functions_as_arguments.sy @@ -0,0 +1,9 @@ +start :: fn { + g := fn -> int { + ret 1 + } + f := fn inner: fn -> int -> int { + ret inner() + } + f(g) <=> 1 +} diff --git a/progs/tests/func/passing_functions_as_arguments_mixed.sy b/progs/tests/func/passing_functions_as_arguments_mixed.sy new file mode 100644 index 0000000..b08128e --- /dev/null +++ b/progs/tests/func/passing_functions_as_arguments_mixed.sy @@ -0,0 +1,9 @@ +start :: fn { + g := fn a: int -> int { + ret a * 2 + } + f := fn inner: fn int -> int, a: int -> int { + ret inner(a) + } + f(g, 2) <=> 4 +} diff --git a/progs/tests/func/precedence.sy b/progs/tests/func/precedence.sy new file mode 100644 index 0000000..ae08e05 --- /dev/null +++ b/progs/tests/func/precedence.sy @@ -0,0 +1,8 @@ +start :: fn { + f := fn a: int, b: int -> int { + ret a + b + } + 1 + f(2, 3) <=> 6 + 2 * f(2, 3) <=> 10 + f(2, 3) - (2 + 3) <=> 0 +} diff --git a/progs/tests/func/return_1.sy b/progs/tests/func/return_1.sy new file mode 100644 index 0000000..533208f --- /dev/null +++ b/progs/tests/func/return_1.sy @@ -0,0 +1,6 @@ +start :: fn { + f := fn -> int { + ret 1 + } + f() <=> 1 +} diff --git a/progs/tests/func/returning_closures.sy b/progs/tests/func/returning_closures.sy new file mode 100644 index 0000000..4d69d5a --- /dev/null +++ b/progs/tests/func/returning_closures.sy @@ -0,0 +1,24 @@ +start :: fn { + + f : fn -> fn -> int = fn -> fn -> int { + x : int = 0 + f := fn -> int { + x = x + 1 + ret x + } + f() <=> 1 + ret f + } + + a := f() + b := f() + + a() <=> 2 + a() <=> 3 + + b() <=> 2 + b() <=> 3 + + a() <=> 4 + +} diff --git a/progs/tests/func/three_arg.sy b/progs/tests/func/three_arg.sy new file mode 100644 index 0000000..56eb634 --- /dev/null +++ b/progs/tests/func/three_arg.sy @@ -0,0 +1,5 @@ +start :: fn { + f := fn a:int, b:int, c:int { c <=> 13 } + f! 1, 1 + 2, 1 + 4 * 3 + +} diff --git a/progs/tests/func/two_arg.sy b/progs/tests/func/two_arg.sy new file mode 100644 index 0000000..09ea1f7 --- /dev/null +++ b/progs/tests/func/two_arg.sy @@ -0,0 +1,5 @@ +start :: fn { + f := fn a:int, b:int { b <=> 3 } + f! 1, 1 + 2 + +} diff --git a/progs/tests/func/uncallable_type.sy b/progs/tests/func/uncallable_type.sy new file mode 100644 index 0000000..dbe6e81 --- /dev/null +++ b/progs/tests/func/uncallable_type.sy @@ -0,0 +1,8 @@ +start :: fn { + f := fn i: int { + i() + } + f +} + +// errors: [ErrorKind::InvalidProgram] diff --git a/progs/tests/func/wrong_params.sy b/progs/tests/func/wrong_params.sy new file mode 100644 index 0000000..e49e89b --- /dev/null +++ b/progs/tests/func/wrong_params.sy @@ -0,0 +1,7 @@ +start :: fn { + + f : fn -> int = fn a: int -> int {} + f +} + +// errors: [ErrorKind::TypeMismatch(_, _), ErrorKind::TypeMismatch(Type::Void, Type::Int)] diff --git a/progs/tests/func/wrong_ret.sy b/progs/tests/func/wrong_ret.sy new file mode 100644 index 0000000..6c4a9a5 --- /dev/null +++ b/progs/tests/func/wrong_ret.sy @@ -0,0 +1,7 @@ +start :: fn { + + f : fn -> int = fn {} + f +} + +// errors: [ErrorKind::TypeMismatch(_, _)] diff --git a/progs/tests/global_collision.sy b/progs/tests/global_collision.sy deleted file mode 100644 index 6bce509..0000000 --- a/progs/tests/global_collision.sy +++ /dev/null @@ -1,10 +0,0 @@ -fac :: fn a: int -> int { - if a < 1 { ret 1 } - ret a * fac! a - 1 -} - -a :: fac! 4 - -start :: fn { - a <=> 24 -} diff --git a/progs/tests/global_constants.sy b/progs/tests/global_constants.sy deleted file mode 100644 index 7ee6ca5..0000000 --- a/progs/tests/global_constants.sy +++ /dev/null @@ -1,17 +0,0 @@ -// TODO(ed): Pure functions -fac :: fn n: int -> int { - if n < 1 { ret 1 } - ret n * fac! n - 1 -} - -a :: fac! 4 -b :: a + fac! 2 -c := b + 1 - -start :: fn { - a <=> 24 - b <=> 24 + 2 - c <=> 24 + 2 + 1 - c += 1 - c <=> 24 + 2 + 2 -} diff --git a/progs/tests/if_else.sy b/progs/tests/if_else.sy new file mode 100644 index 0000000..0f1d624 --- /dev/null +++ b/progs/tests/if_else.sy @@ -0,0 +1,10 @@ +start :: fn { + a := 1 + res := 0 + if a == 0 { + + } else { + res = 1 + } + res <=> 1 +} diff --git a/progs/tests/if_else_if.sy b/progs/tests/if_else_if.sy new file mode 100644 index 0000000..f31453e --- /dev/null +++ b/progs/tests/if_else_if.sy @@ -0,0 +1,12 @@ +start :: fn { + a := 1 + res := 0 + if a == 0 { + + } else if a == 1 { + res = 1 + } else { + + } + res <=> 1 +} diff --git a/progs/tests/in_rhs.sy b/progs/tests/in_rhs.sy deleted file mode 100644 index 28ed276..0000000 --- a/progs/tests/in_rhs.sy +++ /dev/null @@ -1,3 +0,0 @@ -start :: fn { - 5 <=> 1 * 2 + 3 -} diff --git a/progs/tests/instantiate.sy b/progs/tests/instantiate.sy deleted file mode 100644 index bb2f09c..0000000 --- a/progs/tests/instantiate.sy +++ /dev/null @@ -1,5 +0,0 @@ -start :: fn { - blob A {} - a := A() - a -} diff --git a/progs/tests/loop_for.sy b/progs/tests/loop_for.sy new file mode 100644 index 0000000..f9e27d4 --- /dev/null +++ b/progs/tests/loop_for.sy @@ -0,0 +1,37 @@ +start :: fn { + a := 0 + for i := 0, i < 3, i = i + 1 { + a = a + i + } + a <=> 3 + + a = 0 + for i := 0, i <= 3, i = i + 1 { + a = a + i + } + a <=> 6 + + a = 0 + for i := 0, i < 3, i = i + 1 { + for j := 0, j < 3, j = j + 1 { + a = a + i * j + } + } + a <=> 9 + + a = 0 + for i := 0, i < 10, i = i + 1 { + for j := i, j < 10, j = j + 1 { + a = a + i * j + } + } + a <=> 1155 + + a = 0 + for i := 0, i < 10, i = i + 1 { + for j := 0, j < i, j = j + 1 { + a = a + i * j + } + } + a <=> 870 +} diff --git a/progs/tests/more_types.sy b/progs/tests/more_types.sy deleted file mode 100644 index c85403a..0000000 --- a/progs/tests/more_types.sy +++ /dev/null @@ -1,4 +0,0 @@ -start :: fn { - a: (str, bool, int) = ("abc", true, 1) - a -} diff --git a/progs/tests/mul.sy b/progs/tests/mul.sy deleted file mode 100644 index 4b33314..0000000 --- a/progs/tests/mul.sy +++ /dev/null @@ -1,3 +0,0 @@ -start :: fn { - (0, 1, 2) * (2, 3, 4) <=> (0, 3, 8) -} diff --git a/progs/tests/multiple_fields.sy b/progs/tests/multiple_fields.sy deleted file mode 100644 index ce4c61f..0000000 --- a/progs/tests/multiple_fields.sy +++ /dev/null @@ -1,11 +0,0 @@ -start :: fn { - blob A { - a: int - b: int - } - a := A() - a.a = 2 - a.b = 3 - a.a + a.b <=> 5 - 5 <=> a.a + a.b -} diff --git a/progs/tests/multiple_returns.sy b/progs/tests/multiple_returns.sy deleted file mode 100644 index 6cb5e1a..0000000 --- a/progs/tests/multiple_returns.sy +++ /dev/null @@ -1,12 +0,0 @@ -start :: fn { - f := fn a: int -> int { - if a == 1 { - ret 2 - } else { - ret 3 - } - } - f(0) <=> 3 - f(1) <=> 2 - f(2) <=> 3 -} diff --git a/progs/tests/negation.sy b/progs/tests/negation.sy deleted file mode 100644 index 0c702aa..0000000 --- a/progs/tests/negation.sy +++ /dev/null @@ -1,7 +0,0 @@ -start :: fn { - -1 <=> 0 - 1 - -1 + 2 <=> 1 - -(1 + 2) <=> -3 - 1 + -1 <=> 0 - 2 * -1 <=> -2 -} diff --git a/progs/tests/not.sy b/progs/tests/not.sy deleted file mode 100644 index 02dd81d..0000000 --- a/progs/tests/not.sy +++ /dev/null @@ -1,5 +0,0 @@ -start :: fn { - f := fn {} - f! - -} diff --git a/progs/tests/one_arg.sy b/progs/tests/one_arg.sy deleted file mode 100644 index e7dee83..0000000 --- a/progs/tests/one_arg.sy +++ /dev/null @@ -1,5 +0,0 @@ -start :: fn { - f := fn a:int { a <=> 1 } - f! 1 - -} diff --git a/progs/tests/param_1.sy b/progs/tests/param_1.sy deleted file mode 100644 index c96089e..0000000 --- a/progs/tests/param_1.sy +++ /dev/null @@ -1,4 +0,0 @@ -start :: fn { - f := fn a: int {} - f(1) -} diff --git a/progs/tests/param_2.sy b/progs/tests/param_2.sy deleted file mode 100644 index 1915c42..0000000 --- a/progs/tests/param_2.sy +++ /dev/null @@ -1,7 +0,0 @@ -start :: fn { - add := fn a: int, b: int -> int { - ret a + b - } - add(1, 1) <=> 2 - add(10, 20) <=> 30 -} diff --git a/progs/tests/param_and_return.sy b/progs/tests/param_and_return.sy deleted file mode 100644 index 2752fcc..0000000 --- a/progs/tests/param_and_return.sy +++ /dev/null @@ -1,7 +0,0 @@ -start :: fn { - f := fn a: int -> int { - ret a * 2 - } - f(1) <=> 2 - f(5) <=> 10 -} diff --git a/progs/tests/parenthesis.sy b/progs/tests/parenthesis.sy deleted file mode 100644 index dd6fe8a..0000000 --- a/progs/tests/parenthesis.sy +++ /dev/null @@ -1,3 +0,0 @@ -start :: fn { - (1 + 2) * 3 <=> 9 -} diff --git a/progs/tests/passing_functions.sy b/progs/tests/passing_functions.sy deleted file mode 100644 index e09a125..0000000 --- a/progs/tests/passing_functions.sy +++ /dev/null @@ -1,9 +0,0 @@ -start :: fn { - g := fn -> int { - ret 1 - } - f := fn inner: fn -> int -> int { - ret inner() - } - f(g) <=> 1 -} diff --git a/progs/tests/passing_functions_mixed.sy b/progs/tests/passing_functions_mixed.sy deleted file mode 100644 index b08128e..0000000 --- a/progs/tests/passing_functions_mixed.sy +++ /dev/null @@ -1,9 +0,0 @@ -start :: fn { - g := fn a: int -> int { - ret a * 2 - } - f := fn inner: fn int -> int, a: int -> int { - ret inner(a) - } - f(g, 2) <=> 4 -} diff --git a/progs/tests/precedence.sy b/progs/tests/precedence.sy deleted file mode 100644 index ae08e05..0000000 --- a/progs/tests/precedence.sy +++ /dev/null @@ -1,8 +0,0 @@ -start :: fn { - f := fn a: int, b: int -> int { - ret a + b - } - 1 + f(2, 3) <=> 6 - 2 * f(2, 3) <=> 10 - f(2, 3) - (2 + 3) <=> 0 -} diff --git a/progs/tests/return_1.sy b/progs/tests/return_1.sy deleted file mode 100644 index 533208f..0000000 --- a/progs/tests/return_1.sy +++ /dev/null @@ -1,6 +0,0 @@ -start :: fn { - f := fn -> int { - ret 1 - } - f() <=> 1 -} diff --git a/progs/tests/returning_closures.sy b/progs/tests/returning_closures.sy deleted file mode 100644 index 4d69d5a..0000000 --- a/progs/tests/returning_closures.sy +++ /dev/null @@ -1,24 +0,0 @@ -start :: fn { - - f : fn -> fn -> int = fn -> fn -> int { - x : int = 0 - f := fn -> int { - x = x + 1 - ret x - } - f() <=> 1 - ret f - } - - a := f() - b := f() - - a() <=> 2 - a() <=> 3 - - b() <=> 2 - b() <=> 3 - - a() <=> 4 - -} diff --git a/progs/tests/simple_add.sy b/progs/tests/simple_add.sy deleted file mode 100644 index 7be4012..0000000 --- a/progs/tests/simple_add.sy +++ /dev/null @@ -1,9 +0,0 @@ -start :: fn { - - a := 0 - b := 99999 - a += 1 - a <=> 1 - b <=> 99999 - -} diff --git a/progs/tests/simple_sub.sy b/progs/tests/simple_sub.sy deleted file mode 100644 index c220b8f..0000000 --- a/progs/tests/simple_sub.sy +++ /dev/null @@ -1,9 +0,0 @@ -start :: fn { - - a := 0 - b := 99999 - a -= 1 - a <=> -1 - b <=> 99999 - -} diff --git a/progs/tests/simplest.sy b/progs/tests/simplest.sy deleted file mode 100644 index 14a6534..0000000 --- a/progs/tests/simplest.sy +++ /dev/null @@ -1,4 +0,0 @@ -start :: fn { - f := fn {} - f() -} diff --git a/progs/tests/sub.sy b/progs/tests/sub.sy deleted file mode 100644 index e5d60f2..0000000 --- a/progs/tests/sub.sy +++ /dev/null @@ -1,3 +0,0 @@ -start :: fn { - (1, -2, 3, -4) - (4, 3, -2, -1) <=> (-3, 1, 1, -5) -} diff --git a/progs/tests/terms_and_factors.sy b/progs/tests/terms_and_factors.sy deleted file mode 100644 index 42a48e2..0000000 --- a/progs/tests/terms_and_factors.sy +++ /dev/null @@ -1,4 +0,0 @@ -start :: fn { - 1 + 1 * 2 <=> 3 - 1 * 2 + 3 <=> 5 -} diff --git a/progs/tests/three_arg.sy b/progs/tests/three_arg.sy deleted file mode 100644 index 56eb634..0000000 --- a/progs/tests/three_arg.sy +++ /dev/null @@ -1,5 +0,0 @@ -start :: fn { - f := fn a:int, b:int, c:int { c <=> 13 } - f! 1, 1 + 2, 1 + 4 * 3 - -} diff --git a/progs/tests/tuple/add.sy b/progs/tests/tuple/add.sy new file mode 100644 index 0000000..3fadd86 --- /dev/null +++ b/progs/tests/tuple/add.sy @@ -0,0 +1,3 @@ +start :: fn { + (1, 2, 3, 4) + (4, 3, 2, 1) <=> (5, 5, 5, 5) +} diff --git a/progs/tests/tuple/basic.sy b/progs/tests/tuple/basic.sy new file mode 100644 index 0000000..642e381 --- /dev/null +++ b/progs/tests/tuple/basic.sy @@ -0,0 +1,24 @@ +start :: fn { + a := (1,2) + a[0] <=> 1 + a[1] <=> 2 + + b := (1,) + b[0] <=> 1 + + empty := () + c := (empty,) + c[0] <=> () + + d := (1,2) + d[0] <=> d[0] + + { + q := d[2-2] + d[d[(5 + 3) * 0]] <=> d[d[(5 + 3) * 0]] + w := d[0] + q + w + q - w + q * w + } +} diff --git a/progs/tests/tuple/fail_invalid_singleton.sy b/progs/tests/tuple/fail_invalid_singleton.sy new file mode 100644 index 0000000..a8fafaa --- /dev/null +++ b/progs/tests/tuple/fail_invalid_singleton.sy @@ -0,0 +1,7 @@ +start :: fn { + a := (,) + a +} + +//TODO(gu) See #100 +// errors: [ErrorKind::SyntaxError(_, _), ErrorKind::SyntaxError(_, _), ErrorKind::SyntaxError(_, _)] diff --git a/progs/tests/tuple/fail_out_of_bounds.sy b/progs/tests/tuple/fail_out_of_bounds.sy new file mode 100644 index 0000000..cb0764a --- /dev/null +++ b/progs/tests/tuple/fail_out_of_bounds.sy @@ -0,0 +1,6 @@ +start :: fn { + a := (1, 2) + a[2] +} + +// errors: [ErrorKind::IndexOutOfBounds(_, 2, 2)] diff --git a/progs/tests/tuple/mul.sy b/progs/tests/tuple/mul.sy new file mode 100644 index 0000000..4b33314 --- /dev/null +++ b/progs/tests/tuple/mul.sy @@ -0,0 +1,3 @@ +start :: fn { + (0, 1, 2) * (2, 3, 4) <=> (0, 3, 8) +} diff --git a/progs/tests/tuple/multiple_types.sy b/progs/tests/tuple/multiple_types.sy new file mode 100644 index 0000000..c85403a --- /dev/null +++ b/progs/tests/tuple/multiple_types.sy @@ -0,0 +1,4 @@ +start :: fn { + a: (str, bool, int) = ("abc", true, 1) + a +} diff --git a/progs/tests/tuple/sub.sy b/progs/tests/tuple/sub.sy new file mode 100644 index 0000000..e5d60f2 --- /dev/null +++ b/progs/tests/tuple/sub.sy @@ -0,0 +1,3 @@ +start :: fn { + (1, -2, 3, -4) - (4, 3, -2, -1) <=> (-3, 1, 1, -5) +} diff --git a/progs/tests/tuple/types.sy b/progs/tests/tuple/types.sy new file mode 100644 index 0000000..bdcdfa4 --- /dev/null +++ b/progs/tests/tuple/types.sy @@ -0,0 +1,4 @@ +start :: fn { + a: (int, float, int) = (1, 1., 1) + a +} diff --git a/progs/tests/tuples.sy b/progs/tests/tuples.sy deleted file mode 100644 index 642e381..0000000 --- a/progs/tests/tuples.sy +++ /dev/null @@ -1,24 +0,0 @@ -start :: fn { - a := (1,2) - a[0] <=> 1 - a[1] <=> 2 - - b := (1,) - b[0] <=> 1 - - empty := () - c := (empty,) - c[0] <=> () - - d := (1,2) - d[0] <=> d[0] - - { - q := d[2-2] - d[d[(5 + 3) * 0]] <=> d[d[(5 + 3) * 0]] - w := d[0] - q + w - q - w - q * w - } -} diff --git a/progs/tests/tuples_fail_invalid_singleton.sy b/progs/tests/tuples_fail_invalid_singleton.sy deleted file mode 100644 index a8fafaa..0000000 --- a/progs/tests/tuples_fail_invalid_singleton.sy +++ /dev/null @@ -1,7 +0,0 @@ -start :: fn { - a := (,) - a -} - -//TODO(gu) See #100 -// errors: [ErrorKind::SyntaxError(_, _), ErrorKind::SyntaxError(_, _), ErrorKind::SyntaxError(_, _)] diff --git a/progs/tests/tuples_fail_out_of_bounds.sy b/progs/tests/tuples_fail_out_of_bounds.sy deleted file mode 100644 index cb0764a..0000000 --- a/progs/tests/tuples_fail_out_of_bounds.sy +++ /dev/null @@ -1,6 +0,0 @@ -start :: fn { - a := (1, 2) - a[2] -} - -// errors: [ErrorKind::IndexOutOfBounds(_, 2, 2)] diff --git a/progs/tests/two_arg.sy b/progs/tests/two_arg.sy deleted file mode 100644 index 09ea1f7..0000000 --- a/progs/tests/two_arg.sy +++ /dev/null @@ -1,5 +0,0 @@ -start :: fn { - f := fn a:int, b:int { b <=> 3 } - f! 1, 1 + 2 - -} diff --git a/progs/tests/types.sy b/progs/tests/types.sy deleted file mode 100644 index bdcdfa4..0000000 --- a/progs/tests/types.sy +++ /dev/null @@ -1,4 +0,0 @@ -start :: fn { - a: (int, float, int) = (1, 1., 1) - a -} diff --git a/progs/tests/uncallable_type.sy b/progs/tests/uncallable_type.sy deleted file mode 100644 index dbe6e81..0000000 --- a/progs/tests/uncallable_type.sy +++ /dev/null @@ -1,8 +0,0 @@ -start :: fn { - f := fn i: int { - i() - } - f -} - -// errors: [ErrorKind::InvalidProgram] diff --git a/progs/tests/wrong_params.sy b/progs/tests/wrong_params.sy deleted file mode 100644 index e49e89b..0000000 --- a/progs/tests/wrong_params.sy +++ /dev/null @@ -1,7 +0,0 @@ -start :: fn { - - f : fn -> int = fn a: int -> int {} - f -} - -// errors: [ErrorKind::TypeMismatch(_, _), ErrorKind::TypeMismatch(Type::Void, Type::Int)] diff --git a/progs/tests/wrong_ret.sy b/progs/tests/wrong_ret.sy deleted file mode 100644 index 6c4a9a5..0000000 --- a/progs/tests/wrong_ret.sy +++ /dev/null @@ -1,7 +0,0 @@ -start :: fn { - - f : fn -> int = fn {} - f -} - -// errors: [ErrorKind::TypeMismatch(_, _)] -- cgit v1.2.1