From c4b2781aa8ebfa79a706dec53d1bc459978f51b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edvard=20Th=C3=B6rnros?= Date: Mon, 22 Feb 2021 19:30:58 +0100 Subject: WIP: Fix some bugs... --- progs/tests/simple.sy | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'progs/tests') diff --git a/progs/tests/simple.sy b/progs/tests/simple.sy index 12a43c0..42b9ac2 100644 --- a/progs/tests/simple.sy +++ b/progs/tests/simple.sy @@ -1,2 +1,7 @@ -print extern_test(3.0) -print extern_test(3.0, 4.0, 5.0) +a :: 1 +a <=> 1 +b := 2 +{ + a <=> 1 + b <=> 2 +} -- cgit v1.2.1 From 8e001b54fb2f74e4e68ea2c75ab0be8db5ea9de5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edvard=20Th=C3=B6rnros?= Date: Mon, 22 Feb 2021 21:19:29 +0100 Subject: fix all the tests that had unused variables --- progs/tests/scoping.sy | 1 + progs/tests/simple.sy | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'progs/tests') diff --git a/progs/tests/scoping.sy b/progs/tests/scoping.sy index 7679948..f8e0b00 100644 --- a/progs/tests/scoping.sy +++ b/progs/tests/scoping.sy @@ -9,5 +9,6 @@ a <=> 1 { a = 2 a : int = 1 + a } a <=> 2 diff --git a/progs/tests/simple.sy b/progs/tests/simple.sy index 42b9ac2..0f69ae2 100644 --- a/progs/tests/simple.sy +++ b/progs/tests/simple.sy @@ -1,7 +1,11 @@ -a :: 1 -a <=> 1 -b := 2 +a := 0 { - a <=> 1 - b <=> 2 + b := 99999 + { + a := 99999 + a + } + b + a -= 1 } +a <=> -1 -- cgit v1.2.1 From 0a37bd9ba38d1fefe077f72640926e3fac034992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edvard=20Th=C3=B6rnros?= Date: Tue, 23 Feb 2021 19:04:11 +0100 Subject: break up sections --- progs/tests/simple.sy | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'progs/tests') diff --git a/progs/tests/simple.sy b/progs/tests/simple.sy index 12a43c0..84bc86d 100644 --- a/progs/tests/simple.sy +++ b/progs/tests/simple.sy @@ -1,2 +1,23 @@ -print extern_test(3.0) -print extern_test(3.0, 4.0, 5.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 -- cgit v1.2.1 From 9d0a930d811b825b39ee16614e645b6934130cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Fri, 5 Mar 2021 18:37:23 +0100 Subject: parse wanted errors from test files --- progs/tests/unreachable.sy | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'progs/tests') diff --git a/progs/tests/unreachable.sy b/progs/tests/unreachable.sy index f016a14..5a59ae1 100644 --- a/progs/tests/unreachable.sy +++ b/progs/tests/unreachable.sy @@ -1 +1,5 @@ - +start :: fn { + +} + +// errors: [ErrorKind::Unreachable] -- cgit v1.2.1 From 2570830850c6dadadc2c86bf9d6f3203c9aba488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Fri, 5 Mar 2021 19:07:13 +0100 Subject: convert tests to files --- progs/tests/_simple.sy | 23 +++++++++++++++++ progs/tests/auto/add.sy | 3 +++ progs/tests/auto/advanced_break.sy | 22 ++++++++++++++++ progs/tests/auto/advanced_continue.sy | 22 ++++++++++++++++ progs/tests/auto/assignment.sy | 7 ++++++ progs/tests/auto/blob_complex.sy | 19 ++++++++++++++ progs/tests/auto/blob_infer.sy | 8 ++++++ progs/tests/auto/blob_simple.sy | 10 ++++++++ progs/tests/auto/calls_inside_calls.sy | 11 ++++++++ progs/tests/auto/cluster.sy | 14 +++++++++++ progs/tests/auto/compare_constants_equality.sy | 5 ++++ progs/tests/auto/compare_constants_unequality.sy | 5 ++++ progs/tests/auto/compare_variable.sy | 9 +++++++ progs/tests/auto/conflict_markers.sy | 11 ++++++++ progs/tests/auto/constant_function.sy | 4 +++ progs/tests/auto/constant_function_closure.sy | 13 ++++++++++ progs/tests/auto/constant_function_complex.sy | 19 ++++++++++++++ progs/tests/auto/constants_in_inner_functions.sy | 20 +++++++++++++++ progs/tests/auto/div.sy | 5 ++++ progs/tests/auto/else_.sy | 10 ++++++++ progs/tests/auto/else_if.sy | 12 +++++++++ progs/tests/auto/expressions.sy | 6 +++++ progs/tests/auto/factorial.sy | 12 +++++++++ progs/tests/auto/field.sy | 3 +++ progs/tests/auto/field_assign.sy | 5 ++++ progs/tests/auto/field_get.sy | 7 ++++++ progs/tests/auto/in_rhs.sy | 3 +++ progs/tests/auto/instantiate.sy | 5 ++++ progs/tests/auto/invalid_assign.sy | 7 ++++++ progs/tests/auto/more_types.sy | 4 +++ progs/tests/auto/mul.sy | 3 +++ progs/tests/auto/multiple_fields.sy | 11 ++++++++ progs/tests/auto/multiple_returns.sy | 12 +++++++++ progs/tests/auto/negation.sy | 7 ++++++ progs/tests/auto/not.sy | 5 ++++ progs/tests/auto/one_arg.sy | 5 ++++ progs/tests/auto/param_1.sy | 4 +++ progs/tests/auto/param_2.sy | 7 ++++++ progs/tests/auto/param_and_return.sy | 7 ++++++ progs/tests/auto/parenthesis.sy | 3 +++ progs/tests/auto/passing_functions.sy | 9 +++++++ progs/tests/auto/passing_functions_mixed.sy | 9 +++++++ progs/tests/auto/precedence.sy | 8 ++++++ progs/tests/auto/return_1.sy | 6 +++++ progs/tests/auto/returning_closures.sy | 24 ++++++++++++++++++ progs/tests/auto/simple.sy | 10 ++++++++ progs/tests/auto/simple_add.sy | 9 +++++++ progs/tests/auto/simple_break.sy | 12 +++++++++ progs/tests/auto/simple_continue.sy | 12 +++++++++ progs/tests/auto/simple_sub.sy | 9 +++++++ progs/tests/auto/simplest.sy | 4 +++ progs/tests/auto/single_variable.sy | 4 +++ progs/tests/auto/stack_ordering.sy | 6 +++++ progs/tests/auto/strange.sy | 15 +++++++++++ progs/tests/auto/sub.sy | 3 +++ progs/tests/auto/terms_and_factors.sy | 4 +++ progs/tests/auto/three_arg.sy | 5 ++++ progs/tests/auto/two_arg.sy | 5 ++++ progs/tests/auto/two_variables.sy | 6 +++++ progs/tests/auto/types.sy | 4 +++ progs/tests/auto/uncallable_type.sy | 9 +++++++ progs/tests/auto/wrong_params.sy | 7 ++++++ progs/tests/auto/wrong_ret.sy | 7 ++++++ progs/tests/faulty.sy | 2 ++ progs/tests/fib.sy | 16 ++++++------ progs/tests/for.sy | 32 +++++++++++++----------- progs/tests/scoping.sy | 24 ++++++++++-------- progs/tests/simple.sy | 23 ----------------- 68 files changed, 596 insertions(+), 56 deletions(-) create mode 100644 progs/tests/_simple.sy create mode 100644 progs/tests/auto/add.sy create mode 100644 progs/tests/auto/advanced_break.sy create mode 100644 progs/tests/auto/advanced_continue.sy create mode 100644 progs/tests/auto/assignment.sy create mode 100644 progs/tests/auto/blob_complex.sy create mode 100644 progs/tests/auto/blob_infer.sy create mode 100644 progs/tests/auto/blob_simple.sy create mode 100644 progs/tests/auto/calls_inside_calls.sy create mode 100644 progs/tests/auto/cluster.sy create mode 100644 progs/tests/auto/compare_constants_equality.sy create mode 100644 progs/tests/auto/compare_constants_unequality.sy create mode 100644 progs/tests/auto/compare_variable.sy create mode 100644 progs/tests/auto/conflict_markers.sy create mode 100644 progs/tests/auto/constant_function.sy create mode 100644 progs/tests/auto/constant_function_closure.sy create mode 100644 progs/tests/auto/constant_function_complex.sy create mode 100644 progs/tests/auto/constants_in_inner_functions.sy create mode 100644 progs/tests/auto/div.sy create mode 100644 progs/tests/auto/else_.sy create mode 100644 progs/tests/auto/else_if.sy create mode 100644 progs/tests/auto/expressions.sy create mode 100644 progs/tests/auto/factorial.sy create mode 100644 progs/tests/auto/field.sy create mode 100644 progs/tests/auto/field_assign.sy create mode 100644 progs/tests/auto/field_get.sy create mode 100644 progs/tests/auto/in_rhs.sy create mode 100644 progs/tests/auto/instantiate.sy create mode 100644 progs/tests/auto/invalid_assign.sy create mode 100644 progs/tests/auto/more_types.sy create mode 100644 progs/tests/auto/mul.sy create mode 100644 progs/tests/auto/multiple_fields.sy create mode 100644 progs/tests/auto/multiple_returns.sy create mode 100644 progs/tests/auto/negation.sy create mode 100644 progs/tests/auto/not.sy create mode 100644 progs/tests/auto/one_arg.sy create mode 100644 progs/tests/auto/param_1.sy create mode 100644 progs/tests/auto/param_2.sy create mode 100644 progs/tests/auto/param_and_return.sy create mode 100644 progs/tests/auto/parenthesis.sy create mode 100644 progs/tests/auto/passing_functions.sy create mode 100644 progs/tests/auto/passing_functions_mixed.sy create mode 100644 progs/tests/auto/precedence.sy create mode 100644 progs/tests/auto/return_1.sy create mode 100644 progs/tests/auto/returning_closures.sy create mode 100644 progs/tests/auto/simple.sy create mode 100644 progs/tests/auto/simple_add.sy create mode 100644 progs/tests/auto/simple_break.sy create mode 100644 progs/tests/auto/simple_continue.sy create mode 100644 progs/tests/auto/simple_sub.sy create mode 100644 progs/tests/auto/simplest.sy create mode 100644 progs/tests/auto/single_variable.sy create mode 100644 progs/tests/auto/stack_ordering.sy create mode 100644 progs/tests/auto/strange.sy create mode 100644 progs/tests/auto/sub.sy create mode 100644 progs/tests/auto/terms_and_factors.sy create mode 100644 progs/tests/auto/three_arg.sy create mode 100644 progs/tests/auto/two_arg.sy create mode 100644 progs/tests/auto/two_variables.sy create mode 100644 progs/tests/auto/types.sy create mode 100644 progs/tests/auto/uncallable_type.sy create mode 100644 progs/tests/auto/wrong_params.sy create mode 100644 progs/tests/auto/wrong_ret.sy delete mode 100644 progs/tests/simple.sy (limited to 'progs/tests') diff --git a/progs/tests/_simple.sy b/progs/tests/_simple.sy new file mode 100644 index 0000000..84bc86d --- /dev/null +++ b/progs/tests/_simple.sy @@ -0,0 +1,23 @@ +// +// 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/auto/add.sy b/progs/tests/auto/add.sy new file mode 100644 index 0000000..4e8e643 --- /dev/null +++ b/progs/tests/auto/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/auto/advanced_break.sy b/progs/tests/auto/advanced_break.sy new file mode 100644 index 0000000..1cfcece --- /dev/null +++ b/progs/tests/auto/advanced_break.sy @@ -0,0 +1,22 @@ +start :: fn { + +a := 0 +for i := 0, i < 10, i += 1 { + q := 0 + qq := 0 + qqq := 0 + qqqq := 0 + + a = a + 1 + if i == 2 { + break + } + + q + qq + qqq + qqqq +} +a <=> 3 + +} diff --git a/progs/tests/auto/advanced_continue.sy b/progs/tests/auto/advanced_continue.sy new file mode 100644 index 0000000..70a8671 --- /dev/null +++ b/progs/tests/auto/advanced_continue.sy @@ -0,0 +1,22 @@ +start :: fn { + +a := 0 +for i := 0, i < 4, i += 1 { + q := 0 + qq := 0 + qqq := 0 + qqqq := 0 + + if i == 2 { + continue + } + a = a + 1 + + q + qq + qqq + qqqq +} +a <=> 3 + +} diff --git a/progs/tests/auto/assignment.sy b/progs/tests/auto/assignment.sy new file mode 100644 index 0000000..51cbecc --- /dev/null +++ b/progs/tests/auto/assignment.sy @@ -0,0 +1,7 @@ +start :: fn { +a := 1 + b := 2 + a = b + a <=> 2 + b <=> 2 +} diff --git a/progs/tests/auto/blob_complex.sy b/progs/tests/auto/blob_complex.sy new file mode 100644 index 0000000..d40082f --- /dev/null +++ b/progs/tests/auto/blob_complex.sy @@ -0,0 +1,19 @@ +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/auto/blob_infer.sy b/progs/tests/auto/blob_infer.sy new file mode 100644 index 0000000..cee18bf --- /dev/null +++ b/progs/tests/auto/blob_infer.sy @@ -0,0 +1,8 @@ +start :: fn { + +blob A { } + +a : A = A() +a + +} diff --git a/progs/tests/auto/blob_simple.sy b/progs/tests/auto/blob_simple.sy new file mode 100644 index 0000000..f05ec07 --- /dev/null +++ b/progs/tests/auto/blob_simple.sy @@ -0,0 +1,10 @@ +start :: fn { + +a := A() +a + +blob A { + a: int +} + +} diff --git a/progs/tests/auto/calls_inside_calls.sy b/progs/tests/auto/calls_inside_calls.sy new file mode 100644 index 0000000..578f418 --- /dev/null +++ b/progs/tests/auto/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/auto/cluster.sy b/progs/tests/auto/cluster.sy new file mode 100644 index 0000000..8f279e7 --- /dev/null +++ b/progs/tests/auto/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/auto/compare_constants_equality.sy b/progs/tests/auto/compare_constants_equality.sy new file mode 100644 index 0000000..c8c399b --- /dev/null +++ b/progs/tests/auto/compare_constants_equality.sy @@ -0,0 +1,5 @@ +start :: fn { +if 1 == 2 { + + } +} diff --git a/progs/tests/auto/compare_constants_unequality.sy b/progs/tests/auto/compare_constants_unequality.sy new file mode 100644 index 0000000..8c115b4 --- /dev/null +++ b/progs/tests/auto/compare_constants_unequality.sy @@ -0,0 +1,5 @@ +start :: fn { +if 1 != 1 { + + } +} diff --git a/progs/tests/auto/compare_variable.sy b/progs/tests/auto/compare_variable.sy new file mode 100644 index 0000000..25d21f4 --- /dev/null +++ b/progs/tests/auto/compare_variable.sy @@ -0,0 +1,9 @@ +start :: fn { +a := 1 + if a == 0 { + + } + if a != 1 { + + } +} diff --git a/progs/tests/auto/conflict_markers.sy b/progs/tests/auto/conflict_markers.sy new file mode 100644 index 0000000..715a859 --- /dev/null +++ b/progs/tests/auto/conflict_markers.sy @@ -0,0 +1,11 @@ +start :: fn { + +<<<<<<< HEAD +print extern_test(4.0) +======= +print extern_test(5.0) +>>>>>>> 2 + +} + +// errors: [ErrorKind::SyntaxError(_, _), ErrorKind::GitConflictError(2, 6)] diff --git a/progs/tests/auto/constant_function.sy b/progs/tests/auto/constant_function.sy new file mode 100644 index 0000000..2ec4019 --- /dev/null +++ b/progs/tests/auto/constant_function.sy @@ -0,0 +1,4 @@ +a :: fn {} +start :: fn { + a() +} diff --git a/progs/tests/auto/constant_function_closure.sy b/progs/tests/auto/constant_function_closure.sy new file mode 100644 index 0000000..8c54249 --- /dev/null +++ b/progs/tests/auto/constant_function_closure.sy @@ -0,0 +1,13 @@ +q := 1 + +f :: fn -> int { + q += 1 + ret q +} + +start :: fn { + f() <=> 2 + f() <=> 3 + f() <=> 4 + f() <=> 5 +} diff --git a/progs/tests/auto/constant_function_complex.sy b/progs/tests/auto/constant_function_complex.sy new file mode 100644 index 0000000..6a60ebe --- /dev/null +++ b/progs/tests/auto/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/auto/constants_in_inner_functions.sy b/progs/tests/auto/constants_in_inner_functions.sy new file mode 100644 index 0000000..3371393 --- /dev/null +++ b/progs/tests/auto/constants_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/auto/div.sy b/progs/tests/auto/div.sy new file mode 100644 index 0000000..3073270 --- /dev/null +++ b/progs/tests/auto/div.sy @@ -0,0 +1,5 @@ +start :: fn { +a := 2 +a /= 2 +a <=> 1 +} diff --git a/progs/tests/auto/else_.sy b/progs/tests/auto/else_.sy new file mode 100644 index 0000000..896aeb4 --- /dev/null +++ b/progs/tests/auto/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/auto/else_if.sy b/progs/tests/auto/else_if.sy new file mode 100644 index 0000000..18b64f6 --- /dev/null +++ b/progs/tests/auto/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/auto/expressions.sy b/progs/tests/auto/expressions.sy new file mode 100644 index 0000000..0f6d6fc --- /dev/null +++ b/progs/tests/auto/expressions.sy @@ -0,0 +1,6 @@ +start :: fn { +1 + 1 // blargh + 2 // blargh + // HARGH + +} diff --git a/progs/tests/auto/factorial.sy b/progs/tests/auto/factorial.sy new file mode 100644 index 0000000..770bc33 --- /dev/null +++ b/progs/tests/auto/factorial.sy @@ -0,0 +1,12 @@ +factorial :: fn n: int -> int { + if n <= 1 { + ret 1 + } + ret n * factorial(n - 1) +} + +start :: fn { + factorial(5) <=> 120 + factorial(6) <=> 720 + factorial(12) <=> 479001600 +} diff --git a/progs/tests/auto/field.sy b/progs/tests/auto/field.sy new file mode 100644 index 0000000..c985297 --- /dev/null +++ b/progs/tests/auto/field.sy @@ -0,0 +1,3 @@ +start :: fn { +blob A { a: int } +} diff --git a/progs/tests/auto/field_assign.sy b/progs/tests/auto/field_assign.sy new file mode 100644 index 0000000..93837ea --- /dev/null +++ b/progs/tests/auto/field_assign.sy @@ -0,0 +1,5 @@ +start :: fn { +blob A { a: int } + a := A() + a.a = 2 +} diff --git a/progs/tests/auto/field_get.sy b/progs/tests/auto/field_get.sy new file mode 100644 index 0000000..0905f6f --- /dev/null +++ b/progs/tests/auto/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/auto/in_rhs.sy b/progs/tests/auto/in_rhs.sy new file mode 100644 index 0000000..60e4873 --- /dev/null +++ b/progs/tests/auto/in_rhs.sy @@ -0,0 +1,3 @@ +start :: fn { +5 <=> 1 * 2 + 3 +} diff --git a/progs/tests/auto/instantiate.sy b/progs/tests/auto/instantiate.sy new file mode 100644 index 0000000..7d32bf9 --- /dev/null +++ b/progs/tests/auto/instantiate.sy @@ -0,0 +1,5 @@ +start :: fn { +blob A {} + a := A() + a +} diff --git a/progs/tests/auto/invalid_assign.sy b/progs/tests/auto/invalid_assign.sy new file mode 100644 index 0000000..a8b18f0 --- /dev/null +++ b/progs/tests/auto/invalid_assign.sy @@ -0,0 +1,7 @@ +start :: fn { +a := 1 +a = 0.1 +a +} + +// errors: [ErrorKind::TypeMismatch(Type::Int, Type::Float)] diff --git a/progs/tests/auto/more_types.sy b/progs/tests/auto/more_types.sy new file mode 100644 index 0000000..18d825e --- /dev/null +++ b/progs/tests/auto/more_types.sy @@ -0,0 +1,4 @@ +start :: fn { +a: (str, bool, int) = ("abc", true, 1) +a +} diff --git a/progs/tests/auto/mul.sy b/progs/tests/auto/mul.sy new file mode 100644 index 0000000..78cc14e --- /dev/null +++ b/progs/tests/auto/mul.sy @@ -0,0 +1,3 @@ +start :: fn { +(0, 1, 2) * (2, 3, 4) <=> (0, 3, 8) +} diff --git a/progs/tests/auto/multiple_fields.sy b/progs/tests/auto/multiple_fields.sy new file mode 100644 index 0000000..2a4b3c0 --- /dev/null +++ b/progs/tests/auto/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/auto/multiple_returns.sy b/progs/tests/auto/multiple_returns.sy new file mode 100644 index 0000000..8abc000 --- /dev/null +++ b/progs/tests/auto/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/auto/negation.sy b/progs/tests/auto/negation.sy new file mode 100644 index 0000000..41388d8 --- /dev/null +++ b/progs/tests/auto/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/auto/not.sy b/progs/tests/auto/not.sy new file mode 100644 index 0000000..712690a --- /dev/null +++ b/progs/tests/auto/not.sy @@ -0,0 +1,5 @@ +start :: fn { +f := fn {} + f! + +} diff --git a/progs/tests/auto/one_arg.sy b/progs/tests/auto/one_arg.sy new file mode 100644 index 0000000..9523a67 --- /dev/null +++ b/progs/tests/auto/one_arg.sy @@ -0,0 +1,5 @@ +start :: fn { +f := fn a:int { a <=> 1 } + f! 1 + +} diff --git a/progs/tests/auto/param_1.sy b/progs/tests/auto/param_1.sy new file mode 100644 index 0000000..1781eaf --- /dev/null +++ b/progs/tests/auto/param_1.sy @@ -0,0 +1,4 @@ +start :: fn { +f := fn a: int {} + f(1) +} diff --git a/progs/tests/auto/param_2.sy b/progs/tests/auto/param_2.sy new file mode 100644 index 0000000..ac5fdfd --- /dev/null +++ b/progs/tests/auto/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/auto/param_and_return.sy b/progs/tests/auto/param_and_return.sy new file mode 100644 index 0000000..7e39775 --- /dev/null +++ b/progs/tests/auto/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/auto/parenthesis.sy b/progs/tests/auto/parenthesis.sy new file mode 100644 index 0000000..b456769 --- /dev/null +++ b/progs/tests/auto/parenthesis.sy @@ -0,0 +1,3 @@ +start :: fn { +(1 + 2) * 3 <=> 9 +} diff --git a/progs/tests/auto/passing_functions.sy b/progs/tests/auto/passing_functions.sy new file mode 100644 index 0000000..d1ff70e --- /dev/null +++ b/progs/tests/auto/passing_functions.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/auto/passing_functions_mixed.sy b/progs/tests/auto/passing_functions_mixed.sy new file mode 100644 index 0000000..292e7ce --- /dev/null +++ b/progs/tests/auto/passing_functions_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/auto/precedence.sy b/progs/tests/auto/precedence.sy new file mode 100644 index 0000000..0aee658 --- /dev/null +++ b/progs/tests/auto/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/auto/return_1.sy b/progs/tests/auto/return_1.sy new file mode 100644 index 0000000..993f9fd --- /dev/null +++ b/progs/tests/auto/return_1.sy @@ -0,0 +1,6 @@ +start :: fn { +f := fn -> int { + ret 1 + } + f() <=> 1 +} diff --git a/progs/tests/auto/returning_closures.sy b/progs/tests/auto/returning_closures.sy new file mode 100644 index 0000000..1c4c091 --- /dev/null +++ b/progs/tests/auto/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/auto/simple.sy b/progs/tests/auto/simple.sy new file mode 100644 index 0000000..436dcae --- /dev/null +++ b/progs/tests/auto/simple.sy @@ -0,0 +1,10 @@ +start :: fn { + +a :: 1 +a <=> 1 +b := 2 +{ + a <=> 1 + b <=> 2 +} +} diff --git a/progs/tests/auto/simple_add.sy b/progs/tests/auto/simple_add.sy new file mode 100644 index 0000000..f1952d3 --- /dev/null +++ b/progs/tests/auto/simple_add.sy @@ -0,0 +1,9 @@ +start :: fn { + +a := 0 +b := 99999 +a += 1 +a <=> 1 +b <=> 99999 + +} diff --git a/progs/tests/auto/simple_break.sy b/progs/tests/auto/simple_break.sy new file mode 100644 index 0000000..11c06ad --- /dev/null +++ b/progs/tests/auto/simple_break.sy @@ -0,0 +1,12 @@ +start :: fn { + +a := 0 +for i := 0, i < 10, i += 1 { + a = a + 1 + if i == 2 { + break + } +} +a <=> 3 + +} diff --git a/progs/tests/auto/simple_continue.sy b/progs/tests/auto/simple_continue.sy new file mode 100644 index 0000000..ac2bf81 --- /dev/null +++ b/progs/tests/auto/simple_continue.sy @@ -0,0 +1,12 @@ +start :: fn { + +a := 0 +for i := 0, i < 4, i += 1 { + if i == 2 { + continue + } + a = a + 1 +} +a <=> 3 + +} diff --git a/progs/tests/auto/simple_sub.sy b/progs/tests/auto/simple_sub.sy new file mode 100644 index 0000000..5dad340 --- /dev/null +++ b/progs/tests/auto/simple_sub.sy @@ -0,0 +1,9 @@ +start :: fn { + +a := 0 +b := 99999 +a -= 1 +a <=> -1 +b <=> 99999 + +} diff --git a/progs/tests/auto/simplest.sy b/progs/tests/auto/simplest.sy new file mode 100644 index 0000000..5669dc0 --- /dev/null +++ b/progs/tests/auto/simplest.sy @@ -0,0 +1,4 @@ +start :: fn { +f := fn {} + f() +} diff --git a/progs/tests/auto/single_variable.sy b/progs/tests/auto/single_variable.sy new file mode 100644 index 0000000..00217d2 --- /dev/null +++ b/progs/tests/auto/single_variable.sy @@ -0,0 +1,4 @@ +start :: fn { +a := 1 + a <=> 1 +} diff --git a/progs/tests/auto/stack_ordering.sy b/progs/tests/auto/stack_ordering.sy new file mode 100644 index 0000000..85a36bd --- /dev/null +++ b/progs/tests/auto/stack_ordering.sy @@ -0,0 +1,6 @@ +start :: fn { +a := 1 + b := 2 + b <=> 2 + a <=> 1 +} diff --git a/progs/tests/auto/strange.sy b/progs/tests/auto/strange.sy new file mode 100644 index 0000000..c495041 --- /dev/null +++ b/progs/tests/auto/strange.sy @@ -0,0 +1,15 @@ +start :: fn { + +a := 0 +{ + b := 99999 + { + a := 99999 + a + } + b + a -= 1 +} +a <=> -1 + +} diff --git a/progs/tests/auto/sub.sy b/progs/tests/auto/sub.sy new file mode 100644 index 0000000..755ae67 --- /dev/null +++ b/progs/tests/auto/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/auto/terms_and_factors.sy b/progs/tests/auto/terms_and_factors.sy new file mode 100644 index 0000000..1fef724 --- /dev/null +++ b/progs/tests/auto/terms_and_factors.sy @@ -0,0 +1,4 @@ +start :: fn { +1 + 1 * 2 <=> 3 + 1 * 2 + 3 <=> 5 +} diff --git a/progs/tests/auto/three_arg.sy b/progs/tests/auto/three_arg.sy new file mode 100644 index 0000000..d948fa0 --- /dev/null +++ b/progs/tests/auto/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/auto/two_arg.sy b/progs/tests/auto/two_arg.sy new file mode 100644 index 0000000..60645b5 --- /dev/null +++ b/progs/tests/auto/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/auto/two_variables.sy b/progs/tests/auto/two_variables.sy new file mode 100644 index 0000000..9ae183f --- /dev/null +++ b/progs/tests/auto/two_variables.sy @@ -0,0 +1,6 @@ +start :: fn { +a := 1 + b := 2 + a <=> 1 + b <=> 2 +} diff --git a/progs/tests/auto/types.sy b/progs/tests/auto/types.sy new file mode 100644 index 0000000..c045b34 --- /dev/null +++ b/progs/tests/auto/types.sy @@ -0,0 +1,4 @@ +start :: fn { +a: (int, float, int) = (1, 1., 1) +a +} diff --git a/progs/tests/auto/uncallable_type.sy b/progs/tests/auto/uncallable_type.sy new file mode 100644 index 0000000..06ff71a --- /dev/null +++ b/progs/tests/auto/uncallable_type.sy @@ -0,0 +1,9 @@ +start :: fn { + + f := fn i: int { + i() + } + f +} + +// errors: [ErrorKind::InvalidProgram] diff --git a/progs/tests/auto/wrong_params.sy b/progs/tests/auto/wrong_params.sy new file mode 100644 index 0000000..6b56e90 --- /dev/null +++ b/progs/tests/auto/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/auto/wrong_ret.sy b/progs/tests/auto/wrong_ret.sy new file mode 100644 index 0000000..81f2517 --- /dev/null +++ b/progs/tests/auto/wrong_ret.sy @@ -0,0 +1,7 @@ +start :: fn { + + f : fn -> int = fn {} +f +} + +// errors: [ErrorKind::TypeMismatch(_, _)] diff --git a/progs/tests/faulty.sy b/progs/tests/faulty.sy index 369b8ff..ea1b40d 100644 --- a/progs/tests/faulty.sy +++ b/progs/tests/faulty.sy @@ -1,3 +1,5 @@ asdflökja;;;; 123 asd + +// errors: [ErrorKind::SyntaxError(_, _)] diff --git a/progs/tests/fib.sy b/progs/tests/fib.sy index 1dde6a8..62f38e7 100644 --- a/progs/tests/fib.sy +++ b/progs/tests/fib.sy @@ -1,9 +1,11 @@ -a := 0 -b := 1 +start :: fn { + a := 0 + b := 1 -for i := 0, i < 90, i = i + 1 { - c := a - a = b - b = c + b + for i := 0, i < 90, i = i + 1 { + c := a + a = b + b = c + b + } + a <=> 2880067194370816120 } -a <=> 2880067194370816120 diff --git a/progs/tests/for.sy b/progs/tests/for.sy index a9f8cd2..285cbc3 100644 --- a/progs/tests/for.sy +++ b/progs/tests/for.sy @@ -1,19 +1,21 @@ -a := 0 -for i := 0, i < 3, i = i + 1 { - a = a + i -} -a <=> 3 +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 { + 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 = 0 + for i := 0, i < 3, i = i + 1 { + for j := 0, j < 3, j = j + 1 { + a = a + i * j + } } + a <=> 9 } -a <=> 9 diff --git a/progs/tests/scoping.sy b/progs/tests/scoping.sy index f8e0b00..dfcf92c 100644 --- a/progs/tests/scoping.sy +++ b/progs/tests/scoping.sy @@ -1,14 +1,16 @@ -a : int = 1 -{ +start :: fn { + a : int = 1 + { + a <=> 1 + a : int = a + a + a <=> 2 + } a <=> 1 - a : int = a + a - a <=> 2 -} -a <=> 1 -{ - a = 2 - a : int = 1 - a + { + a = 2 + a : int = 1 + a + } + a <=> 2 } -a <=> 2 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 -- cgit v1.2.1 From 0b15a38e324c3940318df462812c42f74a544267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Fri, 5 Mar 2021 19:46:11 +0100 Subject: correct conflict marker test --- progs/tests/auto/conflict_markers.sy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'progs/tests') diff --git a/progs/tests/auto/conflict_markers.sy b/progs/tests/auto/conflict_markers.sy index 715a859..167a751 100644 --- a/progs/tests/auto/conflict_markers.sy +++ b/progs/tests/auto/conflict_markers.sy @@ -8,4 +8,4 @@ print extern_test(5.0) } -// errors: [ErrorKind::SyntaxError(_, _), ErrorKind::GitConflictError(2, 6)] +// errors: [ErrorKind::SyntaxError(_, _), ErrorKind::GitConflictError(3, 7)] -- cgit v1.2.1 From 57f02d45b7e6ec65c3f2055a2cc4b2c2737167d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Fri, 5 Mar 2021 19:49:49 +0100 Subject: actual error on invalid outer code --- progs/tests/faulty.sy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'progs/tests') diff --git a/progs/tests/faulty.sy b/progs/tests/faulty.sy index ea1b40d..67605d2 100644 --- a/progs/tests/faulty.sy +++ b/progs/tests/faulty.sy @@ -2,4 +2,4 @@ asdflökja;;;; 123 asd -// errors: [ErrorKind::SyntaxError(_, _)] +// errors: [ErrorKind::SyntaxError(_, _), ErrorKind::SyntaxError(_, _), ErrorKind::SyntaxError(_, _)] -- cgit v1.2.1 From dd38069bc1f8b696e8f0c50f43e0e7954729acf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Fri, 5 Mar 2021 20:12:39 +0100 Subject: better errors on invalid outer tokens --- progs/tests/faulty.sy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'progs/tests') diff --git a/progs/tests/faulty.sy b/progs/tests/faulty.sy index 67605d2..ea1b40d 100644 --- a/progs/tests/faulty.sy +++ b/progs/tests/faulty.sy @@ -2,4 +2,4 @@ asdflökja;;;; 123 asd -// errors: [ErrorKind::SyntaxError(_, _), ErrorKind::SyntaxError(_, _), ErrorKind::SyntaxError(_, _)] +// errors: [ErrorKind::SyntaxError(_, _)] -- cgit v1.2.1 From ba7ebb200cc5560ba0a2237df4a4985fe927b08c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Fri, 5 Mar 2021 21:08:27 +0100 Subject: almost working capturing variables --- progs/tests/auto/constant_function_closure.sy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'progs/tests') diff --git a/progs/tests/auto/constant_function_closure.sy b/progs/tests/auto/constant_function_closure.sy index 8c54249..6c7f0d7 100644 --- a/progs/tests/auto/constant_function_closure.sy +++ b/progs/tests/auto/constant_function_closure.sy @@ -1,4 +1,4 @@ -q := 1 +q : int = 1 f :: fn -> int { q += 1 -- cgit v1.2.1 From 923834f19bfea1fae768cc990b5094b52e7cd43d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edvard=20Th=C3=B6rnros?= Date: Sun, 7 Mar 2021 15:23:59 +0100 Subject: add test for constants in outer block --- progs/tests/global_constants.sy | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 progs/tests/global_constants.sy (limited to 'progs/tests') diff --git a/progs/tests/global_constants.sy b/progs/tests/global_constants.sy new file mode 100644 index 0000000..7ee6ca5 --- /dev/null +++ b/progs/tests/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 +} -- cgit v1.2.1 From bffbde3be34ce854e169ad2296f44416414fbc75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edvard=20Th=C3=B6rnros?= Date: Sun, 7 Mar 2021 15:27:19 +0100 Subject: add failing tests --- progs/tests/global_collision.sy | 11 +++++++++++ progs/tests/global_constants_edgecase.sy | 11 +++++++++++ 2 files changed, 22 insertions(+) create mode 100644 progs/tests/global_collision.sy create mode 100644 progs/tests/global_constants_edgecase.sy (limited to 'progs/tests') diff --git a/progs/tests/global_collision.sy b/progs/tests/global_collision.sy new file mode 100644 index 0000000..8dba295 --- /dev/null +++ b/progs/tests/global_collision.sy @@ -0,0 +1,11 @@ +// TODO(ed): Pure functions +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_edgecase.sy b/progs/tests/global_constants_edgecase.sy new file mode 100644 index 0000000..8dba295 --- /dev/null +++ b/progs/tests/global_constants_edgecase.sy @@ -0,0 +1,11 @@ +// TODO(ed): Pure functions +fac :: fn a: int -> int { + if a < 1 { ret 1 } + ret a * fac! a - 1 +} + +a :: fac! 4 + +start :: fn { + a <=> 24 +} -- cgit v1.2.1 From 1d8ce1dcc22a3f14b032d8be3e8a88a8cdbb538c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sun, 7 Mar 2021 15:49:01 +0100 Subject: remove double test --- progs/tests/global_constants_edgecase.sy | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 progs/tests/global_constants_edgecase.sy (limited to 'progs/tests') diff --git a/progs/tests/global_constants_edgecase.sy b/progs/tests/global_constants_edgecase.sy deleted file mode 100644 index 8dba295..0000000 --- a/progs/tests/global_constants_edgecase.sy +++ /dev/null @@ -1,11 +0,0 @@ -// TODO(ed): Pure functions -fac :: fn a: int -> int { - if a < 1 { ret 1 } - ret a * fac! a - 1 -} - -a :: fac! 4 - -start :: fn { - a <=> 24 -} -- cgit v1.2.1 From d96ca7b986573a98cefdb67026516fd014a93c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sun, 7 Mar 2021 16:07:36 +0100 Subject: fix parameters colliding with global variables --- progs/tests/global_collision.sy | 1 - 1 file changed, 1 deletion(-) (limited to 'progs/tests') diff --git a/progs/tests/global_collision.sy b/progs/tests/global_collision.sy index 8dba295..6bce509 100644 --- a/progs/tests/global_collision.sy +++ b/progs/tests/global_collision.sy @@ -1,4 +1,3 @@ -// TODO(ed): Pure functions fac :: fn a: int -> int { if a < 1 { ret 1 } ret a * fac! a - 1 -- cgit v1.2.1 From 0ce37d50dc8aa5789321949b8c661c2070f71d83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sun, 7 Mar 2021 16:38:22 +0100 Subject: add tests for constants declaration order --- progs/tests/constants_declaration_order.sy | 6 ++++++ progs/tests/constants_declaration_order_wrong.sy | 8 ++++++++ 2 files changed, 14 insertions(+) create mode 100644 progs/tests/constants_declaration_order.sy create mode 100644 progs/tests/constants_declaration_order_wrong.sy (limited to 'progs/tests') diff --git a/progs/tests/constants_declaration_order.sy b/progs/tests/constants_declaration_order.sy new file mode 100644 index 0000000..93e6117 --- /dev/null +++ b/progs/tests/constants_declaration_order.sy @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000..37f5050 --- /dev/null +++ b/progs/tests/constants_declaration_order_wrong.sy @@ -0,0 +1,8 @@ +a :: b + 1 +b :: 1 + +start :: fn { + a <=> b + 1 +} + +// errors: [ErrorKind::SyntaxError(1, _)] -- cgit v1.2.1