From 6515244634bb69de33fcb94a8b056480f32e16fa Mon Sep 17 00:00:00 2001 From: "Heinz N. Gies" Date: Fri, 22 Sep 2023 12:27:40 +0200 Subject: [PATCH] Add tests that force imut for Signed-off-by: Heinz N. Gies --- tests/script.rs | 6 ++++++ tests/script_error.rs | 1 + tests/script_errors/bad_fold_imut/error.txt | 5 +++++ tests/script_errors/bad_fold_imut/script.tremor | 3 +++ tests/script_runtime_error.rs | 1 + tests/script_runtime_errors/bad_fold_type_imut/error.txt | 5 +++++ tests/script_runtime_errors/bad_fold_type_imut/in | 1 + .../script_runtime_errors/bad_fold_type_imut/script.tremor | 3 +++ tests/scripts/fold_array_imut/in | 1 + tests/scripts/fold_array_imut/out | 1 + tests/scripts/fold_array_imut/script.tremor | 3 +++ tests/scripts/fold_array_initial_imut/in | 1 + tests/scripts/fold_array_initial_imut/out | 1 + tests/scripts/fold_array_initial_imut/script.tremor | 3 +++ tests/scripts/fold_array_initial_op_imut/in | 1 + tests/scripts/fold_array_initial_op_imut/out | 1 + tests/scripts/fold_array_initial_op_imut/script.tremor | 3 +++ tests/scripts/fold_number_imut/in | 1 + tests/scripts/fold_number_imut/out | 1 + tests/scripts/fold_number_imut/script.tremor | 3 +++ tests/scripts/fold_number_op_imut/in | 1 + tests/scripts/fold_number_op_imut/out | 1 + tests/scripts/fold_number_op_imut/script.tremor | 3 +++ tests/scripts/fold_record_imut/in | 1 + tests/scripts/fold_record_imut/out | 1 + tests/scripts/fold_record_imut/script.tremor | 3 +++ 26 files changed, 55 insertions(+) create mode 100644 tests/script_errors/bad_fold_imut/error.txt create mode 100644 tests/script_errors/bad_fold_imut/script.tremor create mode 100644 tests/script_runtime_errors/bad_fold_type_imut/error.txt create mode 100644 tests/script_runtime_errors/bad_fold_type_imut/in create mode 100644 tests/script_runtime_errors/bad_fold_type_imut/script.tremor create mode 100644 tests/scripts/fold_array_imut/in create mode 100644 tests/scripts/fold_array_imut/out create mode 100644 tests/scripts/fold_array_imut/script.tremor create mode 100644 tests/scripts/fold_array_initial_imut/in create mode 100644 tests/scripts/fold_array_initial_imut/out create mode 100644 tests/scripts/fold_array_initial_imut/script.tremor create mode 100644 tests/scripts/fold_array_initial_op_imut/in create mode 100644 tests/scripts/fold_array_initial_op_imut/out create mode 100644 tests/scripts/fold_array_initial_op_imut/script.tremor create mode 100644 tests/scripts/fold_number_imut/in create mode 100644 tests/scripts/fold_number_imut/out create mode 100644 tests/scripts/fold_number_imut/script.tremor create mode 100644 tests/scripts/fold_number_op_imut/in create mode 100644 tests/scripts/fold_number_op_imut/out create mode 100644 tests/scripts/fold_number_op_imut/script.tremor create mode 100644 tests/scripts/fold_record_imut/in create mode 100644 tests/scripts/fold_record_imut/out create mode 100644 tests/scripts/fold_record_imut/script.tremor diff --git a/tests/script.rs b/tests/script.rs index da9082bf02..912db1a2bb 100644 --- a/tests/script.rs +++ b/tests/script.rs @@ -166,6 +166,12 @@ test_cases!( fold_array_initial_op, fold_array_initial, fold_array, + fold_number_op_imut, + fold_number_imut, + fold_record_imut, + fold_array_initial_op_imut, + fold_array_initial_imut, + fold_array_imut, record_add, nested_use_with_path, multi_use, diff --git a/tests/script_error.rs b/tests/script_error.rs index 6dd4e063f2..c047c7aa23 100644 --- a/tests/script_error.rs +++ b/tests/script_error.rs @@ -130,6 +130,7 @@ test_cases!( pp_nest_cyclic, // INSERT bad_fold, + bad_fold_imut, strnig_as_ident, sub_overflow, mul_overflow, diff --git a/tests/script_errors/bad_fold_imut/error.txt b/tests/script_errors/bad_fold_imut/error.txt new file mode 100644 index 0000000000..0e35841b4e --- /dev/null +++ b/tests/script_errors/bad_fold_imut/error.txt @@ -0,0 +1,5 @@ +Error: + 1 | (for event of + 2 | case (k, v) => v + 3 | into [] use merge end) + | ^^^^^ Found the token `merge` but expected one of `*`, `+`, `-`, `/` \ No newline at end of file diff --git a/tests/script_errors/bad_fold_imut/script.tremor b/tests/script_errors/bad_fold_imut/script.tremor new file mode 100644 index 0000000000..e62834673f --- /dev/null +++ b/tests/script_errors/bad_fold_imut/script.tremor @@ -0,0 +1,3 @@ +(for event of + case (k, v) => v +into [] use merge end) diff --git a/tests/script_runtime_error.rs b/tests/script_runtime_error.rs index d6b7bfa9c3..4664021999 100644 --- a/tests/script_runtime_error.rs +++ b/tests/script_runtime_error.rs @@ -163,6 +163,7 @@ test_cases!( subslice_out_of_bounds, // INSERT bad_fold_type, + bad_fold_type_imut, bad_merge2, bad_merge, meta_and_use, diff --git a/tests/script_runtime_errors/bad_fold_type_imut/error.txt b/tests/script_runtime_errors/bad_fold_type_imut/error.txt new file mode 100644 index 0000000000..56f8afe00d --- /dev/null +++ b/tests/script_runtime_errors/bad_fold_type_imut/error.txt @@ -0,0 +1,5 @@ +Error: + 1 | (for event of + 2 | case (k,v) => [k, v] + | ^^^^^^ Type error: Expected object, found array + 3 | into {} end) \ No newline at end of file diff --git a/tests/script_runtime_errors/bad_fold_type_imut/in b/tests/script_runtime_errors/bad_fold_type_imut/in new file mode 100644 index 0000000000..6ed63af507 --- /dev/null +++ b/tests/script_runtime_errors/bad_fold_type_imut/in @@ -0,0 +1 @@ +[1,2] diff --git a/tests/script_runtime_errors/bad_fold_type_imut/script.tremor b/tests/script_runtime_errors/bad_fold_type_imut/script.tremor new file mode 100644 index 0000000000..77952799f5 --- /dev/null +++ b/tests/script_runtime_errors/bad_fold_type_imut/script.tremor @@ -0,0 +1,3 @@ +(for event of + case (k,v) => [k, v] +into {} end) diff --git a/tests/scripts/fold_array_imut/in b/tests/scripts/fold_array_imut/in new file mode 100644 index 0000000000..fde6c1d745 --- /dev/null +++ b/tests/scripts/fold_array_imut/in @@ -0,0 +1 @@ +[1,2,3,4] \ No newline at end of file diff --git a/tests/scripts/fold_array_imut/out b/tests/scripts/fold_array_imut/out new file mode 100644 index 0000000000..a36dc1925d --- /dev/null +++ b/tests/scripts/fold_array_imut/out @@ -0,0 +1 @@ +[2,3,4,5] \ No newline at end of file diff --git a/tests/scripts/fold_array_imut/script.tremor b/tests/scripts/fold_array_imut/script.tremor new file mode 100644 index 0000000000..20f42016f0 --- /dev/null +++ b/tests/scripts/fold_array_imut/script.tremor @@ -0,0 +1,3 @@ +(for event of + case (k, v) => v + 1 +end) diff --git a/tests/scripts/fold_array_initial_imut/in b/tests/scripts/fold_array_initial_imut/in new file mode 100644 index 0000000000..fde6c1d745 --- /dev/null +++ b/tests/scripts/fold_array_initial_imut/in @@ -0,0 +1 @@ +[1,2,3,4] \ No newline at end of file diff --git a/tests/scripts/fold_array_initial_imut/out b/tests/scripts/fold_array_initial_imut/out new file mode 100644 index 0000000000..a36dc1925d --- /dev/null +++ b/tests/scripts/fold_array_initial_imut/out @@ -0,0 +1 @@ +[2,3,4,5] \ No newline at end of file diff --git a/tests/scripts/fold_array_initial_imut/script.tremor b/tests/scripts/fold_array_initial_imut/script.tremor new file mode 100644 index 0000000000..8c8cdb590e --- /dev/null +++ b/tests/scripts/fold_array_initial_imut/script.tremor @@ -0,0 +1,3 @@ +(for event of + case (k, v) => v + 1 +into [] end) diff --git a/tests/scripts/fold_array_initial_op_imut/in b/tests/scripts/fold_array_initial_op_imut/in new file mode 100644 index 0000000000..fde6c1d745 --- /dev/null +++ b/tests/scripts/fold_array_initial_op_imut/in @@ -0,0 +1 @@ +[1,2,3,4] \ No newline at end of file diff --git a/tests/scripts/fold_array_initial_op_imut/out b/tests/scripts/fold_array_initial_op_imut/out new file mode 100644 index 0000000000..e77ca8d9ec --- /dev/null +++ b/tests/scripts/fold_array_initial_op_imut/out @@ -0,0 +1 @@ +[1,2,3,4,5] \ No newline at end of file diff --git a/tests/scripts/fold_array_initial_op_imut/script.tremor b/tests/scripts/fold_array_initial_op_imut/script.tremor new file mode 100644 index 0000000000..bc52b47cd2 --- /dev/null +++ b/tests/scripts/fold_array_initial_op_imut/script.tremor @@ -0,0 +1,3 @@ +(for event of + case (k, v) => v + 1 +into [1] use + end) diff --git a/tests/scripts/fold_number_imut/in b/tests/scripts/fold_number_imut/in new file mode 100644 index 0000000000..fde6c1d745 --- /dev/null +++ b/tests/scripts/fold_number_imut/in @@ -0,0 +1 @@ +[1,2,3,4] \ No newline at end of file diff --git a/tests/scripts/fold_number_imut/out b/tests/scripts/fold_number_imut/out new file mode 100644 index 0000000000..9a037142aa --- /dev/null +++ b/tests/scripts/fold_number_imut/out @@ -0,0 +1 @@ +10 \ No newline at end of file diff --git a/tests/scripts/fold_number_imut/script.tremor b/tests/scripts/fold_number_imut/script.tremor new file mode 100644 index 0000000000..de4d689e38 --- /dev/null +++ b/tests/scripts/fold_number_imut/script.tremor @@ -0,0 +1,3 @@ +(for event of + case (k, v) => v +into 0 end) diff --git a/tests/scripts/fold_number_op_imut/in b/tests/scripts/fold_number_op_imut/in new file mode 100644 index 0000000000..fde6c1d745 --- /dev/null +++ b/tests/scripts/fold_number_op_imut/in @@ -0,0 +1 @@ +[1,2,3,4] \ No newline at end of file diff --git a/tests/scripts/fold_number_op_imut/out b/tests/scripts/fold_number_op_imut/out new file mode 100644 index 0000000000..cabf43b5dd --- /dev/null +++ b/tests/scripts/fold_number_op_imut/out @@ -0,0 +1 @@ +24 \ No newline at end of file diff --git a/tests/scripts/fold_number_op_imut/script.tremor b/tests/scripts/fold_number_op_imut/script.tremor new file mode 100644 index 0000000000..ff33ea7d28 --- /dev/null +++ b/tests/scripts/fold_number_op_imut/script.tremor @@ -0,0 +1,3 @@ +(for event of + case (k, v) => v +into 1 use * end) diff --git a/tests/scripts/fold_record_imut/in b/tests/scripts/fold_record_imut/in new file mode 100644 index 0000000000..fde6c1d745 --- /dev/null +++ b/tests/scripts/fold_record_imut/in @@ -0,0 +1 @@ +[1,2,3,4] \ No newline at end of file diff --git a/tests/scripts/fold_record_imut/out b/tests/scripts/fold_record_imut/out new file mode 100644 index 0000000000..c1de738c02 --- /dev/null +++ b/tests/scripts/fold_record_imut/out @@ -0,0 +1 @@ +{"0":2,"1":3,"2":4,"3":5} \ No newline at end of file diff --git a/tests/scripts/fold_record_imut/script.tremor b/tests/scripts/fold_record_imut/script.tremor new file mode 100644 index 0000000000..b3d24d59b5 --- /dev/null +++ b/tests/scripts/fold_record_imut/script.tremor @@ -0,0 +1,3 @@ +(for event of + case (k, v) => {"#{k}": v + 1} +into {} end)