diff --git a/Cargo.lock b/Cargo.lock index 3435febc32..23275b42f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1305,12 +1305,15 @@ dependencies = [ "leo-package", "leo-parser", "leo-state", + "leo-synthesizer", + "leo-test-framework", "num-bigint", "pest", "rand", "rand_core", "rand_xorshift", "serde", + "serde_yaml", "sha2", "snarkvm-algorithms", "snarkvm-curves", @@ -1444,9 +1447,11 @@ dependencies = [ name = "leo-synthesizer" version = "1.4.0" dependencies = [ + "hex", "num-bigint", "serde", "serde_json", + "sha2", "snarkvm-curves", "snarkvm-fields", "snarkvm-gadgets", diff --git a/compiler/Cargo.toml b/compiler/Cargo.toml index ab918e75ec..5fac72ec42 100644 --- a/compiler/Cargo.toml +++ b/compiler/Cargo.toml @@ -49,6 +49,10 @@ version = "1.4.0" path = "../asg-passes" version = "1.4.0" +[dependencies.leo-synthesizer] +path = "../synthesizer" +version = "1.4.0" + [dependencies.snarkvm-curves] version = "0.2.2" default-features = false @@ -117,6 +121,13 @@ default-features = false [dev-dependencies.tempfile] version = "3.0.4" +[dev-dependencies.serde_yaml] +version = "0.8" + +[dev-dependencies.leo-test-framework] +path = "../test-framework" +version = "1.4.0" + [features] default = [ ] ci_skip = [ "leo-ast/ci_skip" ] diff --git a/compiler/tests/address/console_assert_fail.leo b/compiler/otests/address/console_assert_fail.leo similarity index 100% rename from compiler/tests/address/console_assert_fail.leo rename to compiler/otests/address/console_assert_fail.leo diff --git a/compiler/tests/address/console_assert_pass.leo b/compiler/otests/address/console_assert_pass.leo similarity index 100% rename from compiler/tests/address/console_assert_pass.leo rename to compiler/otests/address/console_assert_pass.leo diff --git a/compiler/tests/address/empty.leo b/compiler/otests/address/empty.leo similarity index 100% rename from compiler/tests/address/empty.leo rename to compiler/otests/address/empty.leo diff --git a/compiler/tests/address/equal.leo b/compiler/otests/address/equal.leo similarity index 100% rename from compiler/tests/address/equal.leo rename to compiler/otests/address/equal.leo diff --git a/compiler/tests/address/implicit_invalid.leo b/compiler/otests/address/implicit_invalid.leo similarity index 100% rename from compiler/tests/address/implicit_invalid.leo rename to compiler/otests/address/implicit_invalid.leo diff --git a/compiler/tests/address/implicit_valid.leo b/compiler/otests/address/implicit_valid.leo similarity index 100% rename from compiler/tests/address/implicit_valid.leo rename to compiler/otests/address/implicit_valid.leo diff --git a/compiler/tests/address/input.leo b/compiler/otests/address/input.leo similarity index 100% rename from compiler/tests/address/input.leo rename to compiler/otests/address/input.leo diff --git a/compiler/tests/address/invalid_length.leo b/compiler/otests/address/invalid_length.leo similarity index 100% rename from compiler/tests/address/invalid_length.leo rename to compiler/otests/address/invalid_length.leo diff --git a/compiler/tests/address/invalid_prefix.leo b/compiler/otests/address/invalid_prefix.leo similarity index 100% rename from compiler/tests/address/invalid_prefix.leo rename to compiler/otests/address/invalid_prefix.leo diff --git a/compiler/tests/address/mod.rs b/compiler/otests/address/mod.rs similarity index 100% rename from compiler/tests/address/mod.rs rename to compiler/otests/address/mod.rs diff --git a/compiler/tests/address/ternary.leo b/compiler/otests/address/ternary.leo similarity index 100% rename from compiler/tests/address/ternary.leo rename to compiler/otests/address/ternary.leo diff --git a/compiler/tests/address/valid.leo b/compiler/otests/address/valid.leo similarity index 100% rename from compiler/tests/address/valid.leo rename to compiler/otests/address/valid.leo diff --git a/compiler/tests/array/initializer.leo b/compiler/otests/array/initializer.leo similarity index 100% rename from compiler/tests/array/initializer.leo rename to compiler/otests/array/initializer.leo diff --git a/compiler/tests/array/initializer_fail.leo b/compiler/otests/array/initializer_fail.leo similarity index 100% rename from compiler/tests/array/initializer_fail.leo rename to compiler/otests/array/initializer_fail.leo diff --git a/compiler/tests/array/initializer_input.leo b/compiler/otests/array/initializer_input.leo similarity index 100% rename from compiler/tests/array/initializer_input.leo rename to compiler/otests/array/initializer_input.leo diff --git a/compiler/tests/array/inline.leo b/compiler/otests/array/inline.leo similarity index 100% rename from compiler/tests/array/inline.leo rename to compiler/otests/array/inline.leo diff --git a/compiler/tests/array/input/initializer_fail.in b/compiler/otests/array/input/initializer_fail.in similarity index 100% rename from compiler/tests/array/input/initializer_fail.in rename to compiler/otests/array/input/initializer_fail.in diff --git a/compiler/tests/array/input/inline_fail.leo b/compiler/otests/array/input/inline_fail.leo similarity index 100% rename from compiler/tests/array/input/inline_fail.leo rename to compiler/otests/array/input/inline_fail.leo diff --git a/compiler/tests/array/input/input_nested_3x2.in b/compiler/otests/array/input/input_nested_3x2.in similarity index 100% rename from compiler/tests/array/input/input_nested_3x2.in rename to compiler/otests/array/input/input_nested_3x2.in diff --git a/compiler/tests/array/input/input_nested_3x2_fail.in b/compiler/otests/array/input/input_nested_3x2_fail.in similarity index 100% rename from compiler/tests/array/input/input_nested_3x2_fail.in rename to compiler/otests/array/input/input_nested_3x2_fail.in diff --git a/compiler/tests/array/input/input_tuple_3x2.in b/compiler/otests/array/input/input_tuple_3x2.in similarity index 100% rename from compiler/tests/array/input/input_tuple_3x2.in rename to compiler/otests/array/input/input_tuple_3x2.in diff --git a/compiler/tests/array/input/input_tuple_3x2_fail.in b/compiler/otests/array/input/input_tuple_3x2_fail.in similarity index 100% rename from compiler/tests/array/input/input_tuple_3x2_fail.in rename to compiler/otests/array/input/input_tuple_3x2_fail.in diff --git a/compiler/tests/array/input/registers_ones.in b/compiler/otests/array/input/registers_ones.in similarity index 100% rename from compiler/tests/array/input/registers_ones.in rename to compiler/otests/array/input/registers_ones.in diff --git a/compiler/tests/array/input/registers_zeros.in b/compiler/otests/array/input/registers_zeros.in similarity index 100% rename from compiler/tests/array/input/registers_zeros.in rename to compiler/otests/array/input/registers_zeros.in diff --git a/compiler/tests/array/input/six_zeros.in b/compiler/otests/array/input/six_zeros.in similarity index 100% rename from compiler/tests/array/input/six_zeros.in rename to compiler/otests/array/input/six_zeros.in diff --git a/compiler/tests/array/input/three_ones.in b/compiler/otests/array/input/three_ones.in similarity index 100% rename from compiler/tests/array/input/three_ones.in rename to compiler/otests/array/input/three_ones.in diff --git a/compiler/tests/array/input/type_nested_value_nested_3x2.in b/compiler/otests/array/input/type_nested_value_nested_3x2.in similarity index 100% rename from compiler/tests/array/input/type_nested_value_nested_3x2.in rename to compiler/otests/array/input/type_nested_value_nested_3x2.in diff --git a/compiler/tests/array/input/type_nested_value_nested_3x2_fail.in b/compiler/otests/array/input/type_nested_value_nested_3x2_fail.in similarity index 100% rename from compiler/tests/array/input/type_nested_value_nested_3x2_fail.in rename to compiler/otests/array/input/type_nested_value_nested_3x2_fail.in diff --git a/compiler/tests/array/input/type_nested_value_nested_4x3x2.in b/compiler/otests/array/input/type_nested_value_nested_4x3x2.in similarity index 100% rename from compiler/tests/array/input/type_nested_value_nested_4x3x2.in rename to compiler/otests/array/input/type_nested_value_nested_4x3x2.in diff --git a/compiler/tests/array/input/type_nested_value_nested_4x3x2_fail.in b/compiler/otests/array/input/type_nested_value_nested_4x3x2_fail.in similarity index 100% rename from compiler/tests/array/input/type_nested_value_nested_4x3x2_fail.in rename to compiler/otests/array/input/type_nested_value_nested_4x3x2_fail.in diff --git a/compiler/tests/array/input/type_nested_value_tuple_3x2.in b/compiler/otests/array/input/type_nested_value_tuple_3x2.in similarity index 100% rename from compiler/tests/array/input/type_nested_value_tuple_3x2.in rename to compiler/otests/array/input/type_nested_value_tuple_3x2.in diff --git a/compiler/tests/array/input/type_nested_value_tuple_3x2_fail.in b/compiler/otests/array/input/type_nested_value_tuple_3x2_fail.in similarity index 100% rename from compiler/tests/array/input/type_nested_value_tuple_3x2_fail.in rename to compiler/otests/array/input/type_nested_value_tuple_3x2_fail.in diff --git a/compiler/tests/array/input/type_nested_value_tuple_4x3x2.in b/compiler/otests/array/input/type_nested_value_tuple_4x3x2.in similarity index 100% rename from compiler/tests/array/input/type_nested_value_tuple_4x3x2.in rename to compiler/otests/array/input/type_nested_value_tuple_4x3x2.in diff --git a/compiler/tests/array/input/type_nested_value_tuple_4x3x2_fail.in b/compiler/otests/array/input/type_nested_value_tuple_4x3x2_fail.in similarity index 100% rename from compiler/tests/array/input/type_nested_value_tuple_4x3x2_fail.in rename to compiler/otests/array/input/type_nested_value_tuple_4x3x2_fail.in diff --git a/compiler/tests/array/input/type_tuple_value_nested_3x2.in b/compiler/otests/array/input/type_tuple_value_nested_3x2.in similarity index 100% rename from compiler/tests/array/input/type_tuple_value_nested_3x2.in rename to compiler/otests/array/input/type_tuple_value_nested_3x2.in diff --git a/compiler/tests/array/input/type_tuple_value_nested_3x2_fail.in b/compiler/otests/array/input/type_tuple_value_nested_3x2_fail.in similarity index 100% rename from compiler/tests/array/input/type_tuple_value_nested_3x2_fail.in rename to compiler/otests/array/input/type_tuple_value_nested_3x2_fail.in diff --git a/compiler/tests/array/input/type_tuple_value_nested_4x3x2.in b/compiler/otests/array/input/type_tuple_value_nested_4x3x2.in similarity index 100% rename from compiler/tests/array/input/type_tuple_value_nested_4x3x2.in rename to compiler/otests/array/input/type_tuple_value_nested_4x3x2.in diff --git a/compiler/tests/array/input/type_tuple_value_nested_4x3x2_fail.in b/compiler/otests/array/input/type_tuple_value_nested_4x3x2_fail.in similarity index 100% rename from compiler/tests/array/input/type_tuple_value_nested_4x3x2_fail.in rename to compiler/otests/array/input/type_tuple_value_nested_4x3x2_fail.in diff --git a/compiler/tests/array/input/type_tuple_value_tuple_3x2.in b/compiler/otests/array/input/type_tuple_value_tuple_3x2.in similarity index 100% rename from compiler/tests/array/input/type_tuple_value_tuple_3x2.in rename to compiler/otests/array/input/type_tuple_value_tuple_3x2.in diff --git a/compiler/tests/array/input/type_tuple_value_tuple_3x2_fail.in b/compiler/otests/array/input/type_tuple_value_tuple_3x2_fail.in similarity index 100% rename from compiler/tests/array/input/type_tuple_value_tuple_3x2_fail.in rename to compiler/otests/array/input/type_tuple_value_tuple_3x2_fail.in diff --git a/compiler/tests/array/input/type_tuple_value_tuple_4x3x2.in b/compiler/otests/array/input/type_tuple_value_tuple_4x3x2.in similarity index 100% rename from compiler/tests/array/input/type_tuple_value_tuple_4x3x2.in rename to compiler/otests/array/input/type_tuple_value_tuple_4x3x2.in diff --git a/compiler/tests/array/input/type_tuple_value_tuple_4x3x2_fail.in b/compiler/otests/array/input/type_tuple_value_tuple_4x3x2_fail.in similarity index 100% rename from compiler/tests/array/input/type_tuple_value_tuple_4x3x2_fail.in rename to compiler/otests/array/input/type_tuple_value_tuple_4x3x2_fail.in diff --git a/compiler/tests/array/input_nested_3x2.leo b/compiler/otests/array/input_nested_3x2.leo similarity index 100% rename from compiler/tests/array/input_nested_3x2.leo rename to compiler/otests/array/input_nested_3x2.leo diff --git a/compiler/tests/array/input_nested_3x2_fail.leo b/compiler/otests/array/input_nested_3x2_fail.leo similarity index 100% rename from compiler/tests/array/input_nested_3x2_fail.leo rename to compiler/otests/array/input_nested_3x2_fail.leo diff --git a/compiler/tests/array/input_tuple_3x2.leo b/compiler/otests/array/input_tuple_3x2.leo similarity index 100% rename from compiler/tests/array/input_tuple_3x2.leo rename to compiler/otests/array/input_tuple_3x2.leo diff --git a/compiler/tests/array/input_tuple_3x2_fail.leo b/compiler/otests/array/input_tuple_3x2_fail.leo similarity index 100% rename from compiler/tests/array/input_tuple_3x2_fail.leo rename to compiler/otests/array/input_tuple_3x2_fail.leo diff --git a/compiler/tests/array/mod.rs b/compiler/otests/array/mod.rs similarity index 100% rename from compiler/tests/array/mod.rs rename to compiler/otests/array/mod.rs diff --git a/compiler/tests/array/multi_fail_initializer.leo b/compiler/otests/array/multi_fail_initializer.leo similarity index 100% rename from compiler/tests/array/multi_fail_initializer.leo rename to compiler/otests/array/multi_fail_initializer.leo diff --git a/compiler/tests/array/multi_fail_inline.leo b/compiler/otests/array/multi_fail_inline.leo similarity index 100% rename from compiler/tests/array/multi_fail_inline.leo rename to compiler/otests/array/multi_fail_inline.leo diff --git a/compiler/tests/array/multi_initializer.leo b/compiler/otests/array/multi_initializer.leo similarity index 100% rename from compiler/tests/array/multi_initializer.leo rename to compiler/otests/array/multi_initializer.leo diff --git a/compiler/tests/array/multi_initializer_fail.leo b/compiler/otests/array/multi_initializer_fail.leo similarity index 100% rename from compiler/tests/array/multi_initializer_fail.leo rename to compiler/otests/array/multi_initializer_fail.leo diff --git a/compiler/tests/array/nested.leo b/compiler/otests/array/nested.leo similarity index 100% rename from compiler/tests/array/nested.leo rename to compiler/otests/array/nested.leo diff --git a/compiler/tests/array/nested_3x2_value.leo b/compiler/otests/array/nested_3x2_value.leo similarity index 100% rename from compiler/tests/array/nested_3x2_value.leo rename to compiler/otests/array/nested_3x2_value.leo diff --git a/compiler/tests/array/nested_3x2_value_fail.leo b/compiler/otests/array/nested_3x2_value_fail.leo similarity index 100% rename from compiler/tests/array/nested_3x2_value_fail.leo rename to compiler/otests/array/nested_3x2_value_fail.leo diff --git a/compiler/tests/array/output/registers_ones.out b/compiler/otests/array/output/registers_ones.out similarity index 100% rename from compiler/tests/array/output/registers_ones.out rename to compiler/otests/array/output/registers_ones.out diff --git a/compiler/tests/array/output/registers_zeros.out b/compiler/otests/array/output/registers_zeros.out similarity index 100% rename from compiler/tests/array/output/registers_zeros.out rename to compiler/otests/array/output/registers_zeros.out diff --git a/compiler/tests/array/registers.leo b/compiler/otests/array/registers.leo similarity index 100% rename from compiler/tests/array/registers.leo rename to compiler/otests/array/registers.leo diff --git a/compiler/tests/array/slice.leo b/compiler/otests/array/slice.leo similarity index 100% rename from compiler/tests/array/slice.leo rename to compiler/otests/array/slice.leo diff --git a/compiler/tests/array/slice_lower.leo b/compiler/otests/array/slice_lower.leo similarity index 100% rename from compiler/tests/array/slice_lower.leo rename to compiler/otests/array/slice_lower.leo diff --git a/compiler/tests/array/spread.leo b/compiler/otests/array/spread.leo similarity index 100% rename from compiler/tests/array/spread.leo rename to compiler/otests/array/spread.leo diff --git a/compiler/tests/array/tuple_3x2_value.leo b/compiler/otests/array/tuple_3x2_value.leo similarity index 100% rename from compiler/tests/array/tuple_3x2_value.leo rename to compiler/otests/array/tuple_3x2_value.leo diff --git a/compiler/tests/array/tuple_3x2_value_fail.leo b/compiler/otests/array/tuple_3x2_value_fail.leo similarity index 100% rename from compiler/tests/array/tuple_3x2_value_fail.leo rename to compiler/otests/array/tuple_3x2_value_fail.leo diff --git a/compiler/tests/array/type_fail.leo b/compiler/otests/array/type_fail.leo similarity index 100% rename from compiler/tests/array/type_fail.leo rename to compiler/otests/array/type_fail.leo diff --git a/compiler/tests/array/type_input_3x2.leo b/compiler/otests/array/type_input_3x2.leo similarity index 100% rename from compiler/tests/array/type_input_3x2.leo rename to compiler/otests/array/type_input_3x2.leo diff --git a/compiler/tests/array/type_input_4x3x2.leo b/compiler/otests/array/type_input_4x3x2.leo similarity index 100% rename from compiler/tests/array/type_input_4x3x2.leo rename to compiler/otests/array/type_input_4x3x2.leo diff --git a/compiler/tests/array/type_nested_value_nested_3x2.leo b/compiler/otests/array/type_nested_value_nested_3x2.leo similarity index 100% rename from compiler/tests/array/type_nested_value_nested_3x2.leo rename to compiler/otests/array/type_nested_value_nested_3x2.leo diff --git a/compiler/tests/array/type_nested_value_nested_3x2_fail.leo b/compiler/otests/array/type_nested_value_nested_3x2_fail.leo similarity index 100% rename from compiler/tests/array/type_nested_value_nested_3x2_fail.leo rename to compiler/otests/array/type_nested_value_nested_3x2_fail.leo diff --git a/compiler/tests/array/type_nested_value_nested_4x3x2.leo b/compiler/otests/array/type_nested_value_nested_4x3x2.leo similarity index 100% rename from compiler/tests/array/type_nested_value_nested_4x3x2.leo rename to compiler/otests/array/type_nested_value_nested_4x3x2.leo diff --git a/compiler/tests/array/type_nested_value_nested_4x3x2_fail.leo b/compiler/otests/array/type_nested_value_nested_4x3x2_fail.leo similarity index 100% rename from compiler/tests/array/type_nested_value_nested_4x3x2_fail.leo rename to compiler/otests/array/type_nested_value_nested_4x3x2_fail.leo diff --git a/compiler/tests/array/type_nested_value_tuple_3x2.leo b/compiler/otests/array/type_nested_value_tuple_3x2.leo similarity index 100% rename from compiler/tests/array/type_nested_value_tuple_3x2.leo rename to compiler/otests/array/type_nested_value_tuple_3x2.leo diff --git a/compiler/tests/array/type_nested_value_tuple_3x2_fail.leo b/compiler/otests/array/type_nested_value_tuple_3x2_fail.leo similarity index 100% rename from compiler/tests/array/type_nested_value_tuple_3x2_fail.leo rename to compiler/otests/array/type_nested_value_tuple_3x2_fail.leo diff --git a/compiler/tests/array/type_nested_value_tuple_4x3x2.leo b/compiler/otests/array/type_nested_value_tuple_4x3x2.leo similarity index 100% rename from compiler/tests/array/type_nested_value_tuple_4x3x2.leo rename to compiler/otests/array/type_nested_value_tuple_4x3x2.leo diff --git a/compiler/tests/array/type_nested_value_tuple_4x3x2_fail.leo b/compiler/otests/array/type_nested_value_tuple_4x3x2_fail.leo similarity index 100% rename from compiler/tests/array/type_nested_value_tuple_4x3x2_fail.leo rename to compiler/otests/array/type_nested_value_tuple_4x3x2_fail.leo diff --git a/compiler/tests/array/type_tuple_value_nested_3x2.leo b/compiler/otests/array/type_tuple_value_nested_3x2.leo similarity index 100% rename from compiler/tests/array/type_tuple_value_nested_3x2.leo rename to compiler/otests/array/type_tuple_value_nested_3x2.leo diff --git a/compiler/tests/array/type_tuple_value_nested_3x2_fail.leo b/compiler/otests/array/type_tuple_value_nested_3x2_fail.leo similarity index 100% rename from compiler/tests/array/type_tuple_value_nested_3x2_fail.leo rename to compiler/otests/array/type_tuple_value_nested_3x2_fail.leo diff --git a/compiler/tests/array/type_tuple_value_nested_4x3x2.leo b/compiler/otests/array/type_tuple_value_nested_4x3x2.leo similarity index 100% rename from compiler/tests/array/type_tuple_value_nested_4x3x2.leo rename to compiler/otests/array/type_tuple_value_nested_4x3x2.leo diff --git a/compiler/tests/array/type_tuple_value_nested_4x3x2_fail.leo b/compiler/otests/array/type_tuple_value_nested_4x3x2_fail.leo similarity index 100% rename from compiler/tests/array/type_tuple_value_nested_4x3x2_fail.leo rename to compiler/otests/array/type_tuple_value_nested_4x3x2_fail.leo diff --git a/compiler/tests/array/type_tuple_value_tuple_3x2.leo b/compiler/otests/array/type_tuple_value_tuple_3x2.leo similarity index 100% rename from compiler/tests/array/type_tuple_value_tuple_3x2.leo rename to compiler/otests/array/type_tuple_value_tuple_3x2.leo diff --git a/compiler/tests/array/type_tuple_value_tuple_3x2_fail.leo b/compiler/otests/array/type_tuple_value_tuple_3x2_fail.leo similarity index 100% rename from compiler/tests/array/type_tuple_value_tuple_3x2_fail.leo rename to compiler/otests/array/type_tuple_value_tuple_3x2_fail.leo diff --git a/compiler/tests/array/type_tuple_value_tuple_4x3x2.leo b/compiler/otests/array/type_tuple_value_tuple_4x3x2.leo similarity index 100% rename from compiler/tests/array/type_tuple_value_tuple_4x3x2.leo rename to compiler/otests/array/type_tuple_value_tuple_4x3x2.leo diff --git a/compiler/tests/array/type_tuple_value_tuple_4x3x2_fail.leo b/compiler/otests/array/type_tuple_value_tuple_4x3x2_fail.leo similarity index 100% rename from compiler/tests/array/type_tuple_value_tuple_4x3x2_fail.leo rename to compiler/otests/array/type_tuple_value_tuple_4x3x2_fail.leo diff --git a/compiler/tests/array/variable_slice_fail.leo b/compiler/otests/array/variable_slice_fail.leo similarity index 100% rename from compiler/tests/array/variable_slice_fail.leo rename to compiler/otests/array/variable_slice_fail.leo diff --git a/compiler/tests/boolean/all.leo b/compiler/otests/boolean/all.leo similarity index 100% rename from compiler/tests/boolean/all.leo rename to compiler/otests/boolean/all.leo diff --git a/compiler/tests/boolean/assert_eq_input.leo b/compiler/otests/boolean/assert_eq_input.leo similarity index 100% rename from compiler/tests/boolean/assert_eq_input.leo rename to compiler/otests/boolean/assert_eq_input.leo diff --git a/compiler/tests/boolean/conditional_mut.leo b/compiler/otests/boolean/conditional_mut.leo similarity index 100% rename from compiler/tests/boolean/conditional_mut.leo rename to compiler/otests/boolean/conditional_mut.leo diff --git a/compiler/tests/boolean/false_and_false.leo b/compiler/otests/boolean/false_and_false.leo similarity index 100% rename from compiler/tests/boolean/false_and_false.leo rename to compiler/otests/boolean/false_and_false.leo diff --git a/compiler/tests/boolean/false_or_false.leo b/compiler/otests/boolean/false_or_false.leo similarity index 100% rename from compiler/tests/boolean/false_or_false.leo rename to compiler/otests/boolean/false_or_false.leo diff --git a/compiler/tests/boolean/input/registers_false.in b/compiler/otests/boolean/input/registers_false.in similarity index 100% rename from compiler/tests/boolean/input/registers_false.in rename to compiler/otests/boolean/input/registers_false.in diff --git a/compiler/tests/boolean/input/registers_true.in b/compiler/otests/boolean/input/registers_true.in similarity index 100% rename from compiler/tests/boolean/input/registers_true.in rename to compiler/otests/boolean/input/registers_true.in diff --git a/compiler/tests/boolean/input/true_false.in b/compiler/otests/boolean/input/true_false.in similarity index 100% rename from compiler/tests/boolean/input/true_false.in rename to compiler/otests/boolean/input/true_false.in diff --git a/compiler/tests/boolean/input/true_true.in b/compiler/otests/boolean/input/true_true.in similarity index 100% rename from compiler/tests/boolean/input/true_true.in rename to compiler/otests/boolean/input/true_true.in diff --git a/compiler/tests/boolean/mod.rs b/compiler/otests/boolean/mod.rs similarity index 100% rename from compiler/tests/boolean/mod.rs rename to compiler/otests/boolean/mod.rs diff --git a/compiler/tests/boolean/not_false.leo b/compiler/otests/boolean/not_false.leo similarity index 100% rename from compiler/tests/boolean/not_false.leo rename to compiler/otests/boolean/not_false.leo diff --git a/compiler/tests/boolean/not_mutable.leo b/compiler/otests/boolean/not_mutable.leo similarity index 100% rename from compiler/tests/boolean/not_mutable.leo rename to compiler/otests/boolean/not_mutable.leo diff --git a/compiler/tests/boolean/not_true.leo b/compiler/otests/boolean/not_true.leo similarity index 100% rename from compiler/tests/boolean/not_true.leo rename to compiler/otests/boolean/not_true.leo diff --git a/compiler/tests/boolean/not_u32.leo b/compiler/otests/boolean/not_u32.leo similarity index 100% rename from compiler/tests/boolean/not_u32.leo rename to compiler/otests/boolean/not_u32.leo diff --git a/compiler/tests/boolean/output/registers_false.out b/compiler/otests/boolean/output/registers_false.out similarity index 100% rename from compiler/tests/boolean/output/registers_false.out rename to compiler/otests/boolean/output/registers_false.out diff --git a/compiler/tests/boolean/output/registers_true.out b/compiler/otests/boolean/output/registers_true.out similarity index 100% rename from compiler/tests/boolean/output/registers_true.out rename to compiler/otests/boolean/output/registers_true.out diff --git a/compiler/tests/boolean/output_register.leo b/compiler/otests/boolean/output_register.leo similarity index 100% rename from compiler/tests/boolean/output_register.leo rename to compiler/otests/boolean/output_register.leo diff --git a/compiler/tests/boolean/true_and_false.leo b/compiler/otests/boolean/true_and_false.leo similarity index 100% rename from compiler/tests/boolean/true_and_false.leo rename to compiler/otests/boolean/true_and_false.leo diff --git a/compiler/tests/boolean/true_and_true.leo b/compiler/otests/boolean/true_and_true.leo similarity index 100% rename from compiler/tests/boolean/true_and_true.leo rename to compiler/otests/boolean/true_and_true.leo diff --git a/compiler/tests/boolean/true_and_u32.leo b/compiler/otests/boolean/true_and_u32.leo similarity index 100% rename from compiler/tests/boolean/true_and_u32.leo rename to compiler/otests/boolean/true_and_u32.leo diff --git a/compiler/tests/boolean/true_or_false.leo b/compiler/otests/boolean/true_or_false.leo similarity index 100% rename from compiler/tests/boolean/true_or_false.leo rename to compiler/otests/boolean/true_or_false.leo diff --git a/compiler/tests/boolean/true_or_true.leo b/compiler/otests/boolean/true_or_true.leo similarity index 100% rename from compiler/tests/boolean/true_or_true.leo rename to compiler/otests/boolean/true_or_true.leo diff --git a/compiler/tests/boolean/true_or_u32.leo b/compiler/otests/boolean/true_or_u32.leo similarity index 100% rename from compiler/tests/boolean/true_or_u32.leo rename to compiler/otests/boolean/true_or_u32.leo diff --git a/compiler/tests/canonicalization/array_expansion.json b/compiler/otests/canonicalization/array_expansion.json similarity index 100% rename from compiler/tests/canonicalization/array_expansion.json rename to compiler/otests/canonicalization/array_expansion.json diff --git a/compiler/tests/canonicalization/array_expansion.leo b/compiler/otests/canonicalization/array_expansion.leo similarity index 100% rename from compiler/tests/canonicalization/array_expansion.leo rename to compiler/otests/canonicalization/array_expansion.leo diff --git a/compiler/tests/canonicalization/array_size_zero_fail.leo b/compiler/otests/canonicalization/array_size_zero_fail.leo similarity index 100% rename from compiler/tests/canonicalization/array_size_zero_fail.leo rename to compiler/otests/canonicalization/array_size_zero_fail.leo diff --git a/compiler/tests/canonicalization/big_self_in_circuit_replacement.json b/compiler/otests/canonicalization/big_self_in_circuit_replacement.json similarity index 100% rename from compiler/tests/canonicalization/big_self_in_circuit_replacement.json rename to compiler/otests/canonicalization/big_self_in_circuit_replacement.json diff --git a/compiler/tests/canonicalization/big_self_in_circuit_replacement.leo b/compiler/otests/canonicalization/big_self_in_circuit_replacement.leo similarity index 100% rename from compiler/tests/canonicalization/big_self_in_circuit_replacement.leo rename to compiler/otests/canonicalization/big_self_in_circuit_replacement.leo diff --git a/compiler/tests/canonicalization/big_self_outside_circuit_fail.leo b/compiler/otests/canonicalization/big_self_outside_circuit_fail.leo similarity index 100% rename from compiler/tests/canonicalization/big_self_outside_circuit_fail.leo rename to compiler/otests/canonicalization/big_self_outside_circuit_fail.leo diff --git a/compiler/tests/canonicalization/compound_assignment.json b/compiler/otests/canonicalization/compound_assignment.json similarity index 100% rename from compiler/tests/canonicalization/compound_assignment.json rename to compiler/otests/canonicalization/compound_assignment.json diff --git a/compiler/tests/canonicalization/compound_assignment.leo b/compiler/otests/canonicalization/compound_assignment.leo similarity index 100% rename from compiler/tests/canonicalization/compound_assignment.leo rename to compiler/otests/canonicalization/compound_assignment.leo diff --git a/compiler/tests/canonicalization/input/array_expansion.in b/compiler/otests/canonicalization/input/array_expansion.in similarity index 100% rename from compiler/tests/canonicalization/input/array_expansion.in rename to compiler/otests/canonicalization/input/array_expansion.in diff --git a/compiler/tests/canonicalization/mod.rs b/compiler/otests/canonicalization/mod.rs similarity index 100% rename from compiler/tests/canonicalization/mod.rs rename to compiler/otests/canonicalization/mod.rs diff --git a/compiler/tests/circuits/const_self_variable.leo b/compiler/otests/circuits/const_self_variable.leo similarity index 100% rename from compiler/tests/circuits/const_self_variable.leo rename to compiler/otests/circuits/const_self_variable.leo diff --git a/compiler/tests/circuits/const_self_variable_fail.leo b/compiler/otests/circuits/const_self_variable_fail.leo similarity index 100% rename from compiler/tests/circuits/const_self_variable_fail.leo rename to compiler/otests/circuits/const_self_variable_fail.leo diff --git a/compiler/tests/circuits/define_circuit_inside_circuit_function.leo b/compiler/otests/circuits/define_circuit_inside_circuit_function.leo similarity index 100% rename from compiler/tests/circuits/define_circuit_inside_circuit_function.leo rename to compiler/otests/circuits/define_circuit_inside_circuit_function.leo diff --git a/compiler/tests/circuits/duplicate_name_context.leo b/compiler/otests/circuits/duplicate_name_context.leo similarity index 100% rename from compiler/tests/circuits/duplicate_name_context.leo rename to compiler/otests/circuits/duplicate_name_context.leo diff --git a/compiler/tests/circuits/inline.leo b/compiler/otests/circuits/inline.leo similarity index 100% rename from compiler/tests/circuits/inline.leo rename to compiler/otests/circuits/inline.leo diff --git a/compiler/tests/circuits/inline_fail.leo b/compiler/otests/circuits/inline_fail.leo similarity index 100% rename from compiler/tests/circuits/inline_fail.leo rename to compiler/otests/circuits/inline_fail.leo diff --git a/compiler/tests/circuits/inline_member_fail.leo b/compiler/otests/circuits/inline_member_fail.leo similarity index 100% rename from compiler/tests/circuits/inline_member_fail.leo rename to compiler/otests/circuits/inline_member_fail.leo diff --git a/compiler/tests/circuits/inline_member_pass.leo b/compiler/otests/circuits/inline_member_pass.leo similarity index 100% rename from compiler/tests/circuits/inline_member_pass.leo rename to compiler/otests/circuits/inline_member_pass.leo diff --git a/compiler/tests/circuits/inline_undefined.leo b/compiler/otests/circuits/inline_undefined.leo similarity index 100% rename from compiler/tests/circuits/inline_undefined.leo rename to compiler/otests/circuits/inline_undefined.leo diff --git a/compiler/tests/circuits/member_function.leo b/compiler/otests/circuits/member_function.leo similarity index 100% rename from compiler/tests/circuits/member_function.leo rename to compiler/otests/circuits/member_function.leo diff --git a/compiler/tests/circuits/member_function_fail.leo b/compiler/otests/circuits/member_function_fail.leo similarity index 100% rename from compiler/tests/circuits/member_function_fail.leo rename to compiler/otests/circuits/member_function_fail.leo diff --git a/compiler/tests/circuits/member_function_invalid.leo b/compiler/otests/circuits/member_function_invalid.leo similarity index 100% rename from compiler/tests/circuits/member_function_invalid.leo rename to compiler/otests/circuits/member_function_invalid.leo diff --git a/compiler/tests/circuits/member_function_nested.leo b/compiler/otests/circuits/member_function_nested.leo similarity index 100% rename from compiler/tests/circuits/member_function_nested.leo rename to compiler/otests/circuits/member_function_nested.leo diff --git a/compiler/tests/circuits/member_static_function.leo b/compiler/otests/circuits/member_static_function.leo similarity index 100% rename from compiler/tests/circuits/member_static_function.leo rename to compiler/otests/circuits/member_static_function.leo diff --git a/compiler/tests/circuits/member_static_function_invalid.leo b/compiler/otests/circuits/member_static_function_invalid.leo similarity index 100% rename from compiler/tests/circuits/member_static_function_invalid.leo rename to compiler/otests/circuits/member_static_function_invalid.leo diff --git a/compiler/tests/circuits/member_static_function_nested.leo b/compiler/otests/circuits/member_static_function_nested.leo similarity index 100% rename from compiler/tests/circuits/member_static_function_nested.leo rename to compiler/otests/circuits/member_static_function_nested.leo diff --git a/compiler/tests/circuits/member_static_function_undefined.leo b/compiler/otests/circuits/member_static_function_undefined.leo similarity index 100% rename from compiler/tests/circuits/member_static_function_undefined.leo rename to compiler/otests/circuits/member_static_function_undefined.leo diff --git a/compiler/tests/circuits/member_variable.leo b/compiler/otests/circuits/member_variable.leo similarity index 100% rename from compiler/tests/circuits/member_variable.leo rename to compiler/otests/circuits/member_variable.leo diff --git a/compiler/tests/circuits/member_variable_and_function.leo b/compiler/otests/circuits/member_variable_and_function.leo similarity index 100% rename from compiler/tests/circuits/member_variable_and_function.leo rename to compiler/otests/circuits/member_variable_and_function.leo diff --git a/compiler/tests/circuits/member_variable_fail.leo b/compiler/otests/circuits/member_variable_fail.leo similarity index 100% rename from compiler/tests/circuits/member_variable_fail.leo rename to compiler/otests/circuits/member_variable_fail.leo diff --git a/compiler/tests/circuits/mod.rs b/compiler/otests/circuits/mod.rs similarity index 100% rename from compiler/tests/circuits/mod.rs rename to compiler/otests/circuits/mod.rs diff --git a/compiler/tests/circuits/mut_function_fail.leo b/compiler/otests/circuits/mut_function_fail.leo similarity index 100% rename from compiler/tests/circuits/mut_function_fail.leo rename to compiler/otests/circuits/mut_function_fail.leo diff --git a/compiler/tests/circuits/mut_self_function_fail.leo b/compiler/otests/circuits/mut_self_function_fail.leo similarity index 100% rename from compiler/tests/circuits/mut_self_function_fail.leo rename to compiler/otests/circuits/mut_self_function_fail.leo diff --git a/compiler/tests/circuits/mut_self_static_function_fail.leo b/compiler/otests/circuits/mut_self_static_function_fail.leo similarity index 100% rename from compiler/tests/circuits/mut_self_static_function_fail.leo rename to compiler/otests/circuits/mut_self_static_function_fail.leo diff --git a/compiler/tests/circuits/mut_self_variable.leo b/compiler/otests/circuits/mut_self_variable.leo similarity index 100% rename from compiler/tests/circuits/mut_self_variable.leo rename to compiler/otests/circuits/mut_self_variable.leo diff --git a/compiler/tests/circuits/mut_self_variable_branch.leo b/compiler/otests/circuits/mut_self_variable_branch.leo similarity index 100% rename from compiler/tests/circuits/mut_self_variable_branch.leo rename to compiler/otests/circuits/mut_self_variable_branch.leo diff --git a/compiler/tests/circuits/mut_self_variable_conditional.leo b/compiler/otests/circuits/mut_self_variable_conditional.leo similarity index 100% rename from compiler/tests/circuits/mut_self_variable_conditional.leo rename to compiler/otests/circuits/mut_self_variable_conditional.leo diff --git a/compiler/tests/circuits/mut_self_variable_fail.leo b/compiler/otests/circuits/mut_self_variable_fail.leo similarity index 100% rename from compiler/tests/circuits/mut_self_variable_fail.leo rename to compiler/otests/circuits/mut_self_variable_fail.leo diff --git a/compiler/tests/circuits/mut_static_function_fail.leo b/compiler/otests/circuits/mut_static_function_fail.leo similarity index 100% rename from compiler/tests/circuits/mut_static_function_fail.leo rename to compiler/otests/circuits/mut_static_function_fail.leo diff --git a/compiler/tests/circuits/mut_variable.leo b/compiler/otests/circuits/mut_variable.leo similarity index 100% rename from compiler/tests/circuits/mut_variable.leo rename to compiler/otests/circuits/mut_variable.leo diff --git a/compiler/tests/circuits/mut_variable_fail.leo b/compiler/otests/circuits/mut_variable_fail.leo similarity index 100% rename from compiler/tests/circuits/mut_variable_fail.leo rename to compiler/otests/circuits/mut_variable_fail.leo diff --git a/compiler/tests/circuits/mutable_call_immutable_context.leo b/compiler/otests/circuits/mutable_call_immutable_context.leo similarity index 100% rename from compiler/tests/circuits/mutable_call_immutable_context.leo rename to compiler/otests/circuits/mutable_call_immutable_context.leo diff --git a/compiler/tests/circuits/pedersen_mock.leo b/compiler/otests/circuits/pedersen_mock.leo similarity index 100% rename from compiler/tests/circuits/pedersen_mock.leo rename to compiler/otests/circuits/pedersen_mock.leo diff --git a/compiler/tests/circuits/self_circuit.leo b/compiler/otests/circuits/self_circuit.leo similarity index 100% rename from compiler/tests/circuits/self_circuit.leo rename to compiler/otests/circuits/self_circuit.leo diff --git a/compiler/tests/circuits/self_fail.leo b/compiler/otests/circuits/self_fail.leo similarity index 100% rename from compiler/tests/circuits/self_fail.leo rename to compiler/otests/circuits/self_fail.leo diff --git a/compiler/tests/circuits/self_member.leo b/compiler/otests/circuits/self_member.leo similarity index 100% rename from compiler/tests/circuits/self_member.leo rename to compiler/otests/circuits/self_member.leo diff --git a/compiler/tests/circuits/self_member_invalid.leo b/compiler/otests/circuits/self_member_invalid.leo similarity index 100% rename from compiler/tests/circuits/self_member_invalid.leo rename to compiler/otests/circuits/self_member_invalid.leo diff --git a/compiler/tests/circuits/self_member_undefined.leo b/compiler/otests/circuits/self_member_undefined.leo similarity index 100% rename from compiler/tests/circuits/self_member_undefined.leo rename to compiler/otests/circuits/self_member_undefined.leo diff --git a/compiler/tests/compiler/main.leo b/compiler/otests/compiler/main.leo similarity index 100% rename from compiler/tests/compiler/main.leo rename to compiler/otests/compiler/main.leo diff --git a/compiler/tests/compiler/mod.rs b/compiler/otests/compiler/mod.rs similarity index 100% rename from compiler/tests/compiler/mod.rs rename to compiler/otests/compiler/mod.rs diff --git a/compiler/tests/compiler_output/empty.out b/compiler/otests/compiler_output/empty.out similarity index 100% rename from compiler/tests/compiler_output/empty.out rename to compiler/otests/compiler_output/empty.out diff --git a/compiler/tests/console/assert.leo b/compiler/otests/console/assert.leo similarity index 100% rename from compiler/tests/console/assert.leo rename to compiler/otests/console/assert.leo diff --git a/compiler/tests/console/conditional_assert.leo b/compiler/otests/console/conditional_assert.leo similarity index 100% rename from compiler/tests/console/conditional_assert.leo rename to compiler/otests/console/conditional_assert.leo diff --git a/compiler/tests/console/debug.leo b/compiler/otests/console/debug.leo similarity index 100% rename from compiler/tests/console/debug.leo rename to compiler/otests/console/debug.leo diff --git a/compiler/tests/console/error.leo b/compiler/otests/console/error.leo similarity index 100% rename from compiler/tests/console/error.leo rename to compiler/otests/console/error.leo diff --git a/compiler/tests/console/input/input_equal.in b/compiler/otests/console/input/input_equal.in similarity index 100% rename from compiler/tests/console/input/input_equal.in rename to compiler/otests/console/input/input_equal.in diff --git a/compiler/tests/console/input/input_unequal.in b/compiler/otests/console/input/input_unequal.in similarity index 100% rename from compiler/tests/console/input/input_unequal.in rename to compiler/otests/console/input/input_unequal.in diff --git a/compiler/tests/console/log.leo b/compiler/otests/console/log.leo similarity index 100% rename from compiler/tests/console/log.leo rename to compiler/otests/console/log.leo diff --git a/compiler/tests/console/log_conditional.leo b/compiler/otests/console/log_conditional.leo similarity index 100% rename from compiler/tests/console/log_conditional.leo rename to compiler/otests/console/log_conditional.leo diff --git a/compiler/tests/console/log_fail.leo b/compiler/otests/console/log_fail.leo similarity index 100% rename from compiler/tests/console/log_fail.leo rename to compiler/otests/console/log_fail.leo diff --git a/compiler/tests/console/log_input.leo b/compiler/otests/console/log_input.leo similarity index 100% rename from compiler/tests/console/log_input.leo rename to compiler/otests/console/log_input.leo diff --git a/compiler/tests/console/log_parameter.leo b/compiler/otests/console/log_parameter.leo similarity index 100% rename from compiler/tests/console/log_parameter.leo rename to compiler/otests/console/log_parameter.leo diff --git a/compiler/tests/console/log_parameter_fail_empty.leo b/compiler/otests/console/log_parameter_fail_empty.leo similarity index 100% rename from compiler/tests/console/log_parameter_fail_empty.leo rename to compiler/otests/console/log_parameter_fail_empty.leo diff --git a/compiler/tests/console/log_parameter_fail_none.leo b/compiler/otests/console/log_parameter_fail_none.leo similarity index 100% rename from compiler/tests/console/log_parameter_fail_none.leo rename to compiler/otests/console/log_parameter_fail_none.leo diff --git a/compiler/tests/console/log_parameter_fail_unknown.leo b/compiler/otests/console/log_parameter_fail_unknown.leo similarity index 100% rename from compiler/tests/console/log_parameter_fail_unknown.leo rename to compiler/otests/console/log_parameter_fail_unknown.leo diff --git a/compiler/tests/console/log_parameter_many.leo b/compiler/otests/console/log_parameter_many.leo similarity index 100% rename from compiler/tests/console/log_parameter_many.leo rename to compiler/otests/console/log_parameter_many.leo diff --git a/compiler/tests/console/mod.rs b/compiler/otests/console/mod.rs similarity index 100% rename from compiler/tests/console/mod.rs rename to compiler/otests/console/mod.rs diff --git a/compiler/tests/core/core_circuit_invalid.leo b/compiler/otests/core/core_circuit_invalid.leo similarity index 100% rename from compiler/tests/core/core_circuit_invalid.leo rename to compiler/otests/core/core_circuit_invalid.leo diff --git a/compiler/tests/core/core_circuit_star_fail.leo b/compiler/otests/core/core_circuit_star_fail.leo similarity index 100% rename from compiler/tests/core/core_circuit_star_fail.leo rename to compiler/otests/core/core_circuit_star_fail.leo diff --git a/compiler/tests/core/core_package_invalid.leo b/compiler/otests/core/core_package_invalid.leo similarity index 100% rename from compiler/tests/core/core_package_invalid.leo rename to compiler/otests/core/core_package_invalid.leo diff --git a/compiler/tests/core/core_unstable_package_invalid.leo b/compiler/otests/core/core_unstable_package_invalid.leo similarity index 100% rename from compiler/tests/core/core_unstable_package_invalid.leo rename to compiler/otests/core/core_unstable_package_invalid.leo diff --git a/compiler/tests/core/mod.rs b/compiler/otests/core/mod.rs similarity index 100% rename from compiler/tests/core/mod.rs rename to compiler/otests/core/mod.rs diff --git a/compiler/tests/core/packages/mod.rs b/compiler/otests/core/packages/mod.rs similarity index 100% rename from compiler/tests/core/packages/mod.rs rename to compiler/otests/core/packages/mod.rs diff --git a/compiler/tests/core/packages/unstable/blake2s/arguments_length_fail.leo b/compiler/otests/core/packages/unstable/blake2s/arguments_length_fail.leo similarity index 100% rename from compiler/tests/core/packages/unstable/blake2s/arguments_length_fail.leo rename to compiler/otests/core/packages/unstable/blake2s/arguments_length_fail.leo diff --git a/compiler/tests/core/packages/unstable/blake2s/arguments_type_fail.leo b/compiler/otests/core/packages/unstable/blake2s/arguments_type_fail.leo similarity index 100% rename from compiler/tests/core/packages/unstable/blake2s/arguments_type_fail.leo rename to compiler/otests/core/packages/unstable/blake2s/arguments_type_fail.leo diff --git a/compiler/tests/core/packages/unstable/blake2s/blake2s_input.leo b/compiler/otests/core/packages/unstable/blake2s/blake2s_input.leo similarity index 100% rename from compiler/tests/core/packages/unstable/blake2s/blake2s_input.leo rename to compiler/otests/core/packages/unstable/blake2s/blake2s_input.leo diff --git a/compiler/tests/core/packages/unstable/blake2s/blake2s_random.leo b/compiler/otests/core/packages/unstable/blake2s/blake2s_random.leo similarity index 100% rename from compiler/tests/core/packages/unstable/blake2s/blake2s_random.leo rename to compiler/otests/core/packages/unstable/blake2s/blake2s_random.leo diff --git a/compiler/tests/core/packages/unstable/blake2s/inputs/valid_input.in b/compiler/otests/core/packages/unstable/blake2s/inputs/valid_input.in similarity index 100% rename from compiler/tests/core/packages/unstable/blake2s/inputs/valid_input.in rename to compiler/otests/core/packages/unstable/blake2s/inputs/valid_input.in diff --git a/compiler/tests/core/packages/unstable/blake2s/mod.rs b/compiler/otests/core/packages/unstable/blake2s/mod.rs similarity index 100% rename from compiler/tests/core/packages/unstable/blake2s/mod.rs rename to compiler/otests/core/packages/unstable/blake2s/mod.rs diff --git a/compiler/tests/core/packages/unstable/blake2s/outputs/valid_output.out b/compiler/otests/core/packages/unstable/blake2s/outputs/valid_output.out similarity index 100% rename from compiler/tests/core/packages/unstable/blake2s/outputs/valid_output.out rename to compiler/otests/core/packages/unstable/blake2s/outputs/valid_output.out diff --git a/compiler/tests/core/packages/unstable/mod.rs b/compiler/otests/core/packages/unstable/mod.rs similarity index 100% rename from compiler/tests/core/packages/unstable/mod.rs rename to compiler/otests/core/packages/unstable/mod.rs diff --git a/compiler/tests/core/unstable_blake2s.leo b/compiler/otests/core/unstable_blake2s.leo similarity index 100% rename from compiler/tests/core/unstable_blake2s.leo rename to compiler/otests/core/unstable_blake2s.leo diff --git a/compiler/tests/definition/mod.rs b/compiler/otests/definition/mod.rs similarity index 100% rename from compiler/tests/definition/mod.rs rename to compiler/otests/definition/mod.rs diff --git a/compiler/tests/definition/out_of_order.leo b/compiler/otests/definition/out_of_order.leo similarity index 100% rename from compiler/tests/definition/out_of_order.leo rename to compiler/otests/definition/out_of_order.leo diff --git a/compiler/tests/definition/out_of_order_with_import.leo b/compiler/otests/definition/out_of_order_with_import.leo similarity index 100% rename from compiler/tests/definition/out_of_order_with_import.leo rename to compiler/otests/definition/out_of_order_with_import.leo diff --git a/compiler/tests/field/add.leo b/compiler/otests/field/add.leo similarity index 100% rename from compiler/tests/field/add.leo rename to compiler/otests/field/add.leo diff --git a/compiler/tests/field/console_assert.leo b/compiler/otests/field/console_assert.leo similarity index 100% rename from compiler/tests/field/console_assert.leo rename to compiler/otests/field/console_assert.leo diff --git a/compiler/tests/field/div.leo b/compiler/otests/field/div.leo similarity index 100% rename from compiler/tests/field/div.leo rename to compiler/otests/field/div.leo diff --git a/compiler/tests/field/eq.leo b/compiler/otests/field/eq.leo similarity index 100% rename from compiler/tests/field/eq.leo rename to compiler/otests/field/eq.leo diff --git a/compiler/tests/field/field.leo b/compiler/otests/field/field.leo similarity index 100% rename from compiler/tests/field/field.leo rename to compiler/otests/field/field.leo diff --git a/compiler/tests/field/input/register_one.in b/compiler/otests/field/input/register_one.in similarity index 100% rename from compiler/tests/field/input/register_one.in rename to compiler/otests/field/input/register_one.in diff --git a/compiler/tests/field/input/register_zero.in b/compiler/otests/field/input/register_zero.in similarity index 100% rename from compiler/tests/field/input/register_zero.in rename to compiler/otests/field/input/register_zero.in diff --git a/compiler/tests/field/mod.rs b/compiler/otests/field/mod.rs similarity index 100% rename from compiler/tests/field/mod.rs rename to compiler/otests/field/mod.rs diff --git a/compiler/tests/field/mul.leo b/compiler/otests/field/mul.leo similarity index 100% rename from compiler/tests/field/mul.leo rename to compiler/otests/field/mul.leo diff --git a/compiler/tests/field/negate.leo b/compiler/otests/field/negate.leo similarity index 100% rename from compiler/tests/field/negate.leo rename to compiler/otests/field/negate.leo diff --git a/compiler/tests/field/no_space_between_literal.leo b/compiler/otests/field/no_space_between_literal.leo similarity index 100% rename from compiler/tests/field/no_space_between_literal.leo rename to compiler/otests/field/no_space_between_literal.leo diff --git a/compiler/tests/field/output/register_one.out b/compiler/otests/field/output/register_one.out similarity index 100% rename from compiler/tests/field/output/register_one.out rename to compiler/otests/field/output/register_one.out diff --git a/compiler/tests/field/output/register_zero.out b/compiler/otests/field/output/register_zero.out similarity index 100% rename from compiler/tests/field/output/register_zero.out rename to compiler/otests/field/output/register_zero.out diff --git a/compiler/tests/field/output_register.leo b/compiler/otests/field/output_register.leo similarity index 100% rename from compiler/tests/field/output_register.leo rename to compiler/otests/field/output_register.leo diff --git a/compiler/tests/field/sub.leo b/compiler/otests/field/sub.leo similarity index 100% rename from compiler/tests/field/sub.leo rename to compiler/otests/field/sub.leo diff --git a/compiler/tests/field/ternary.leo b/compiler/otests/field/ternary.leo similarity index 100% rename from compiler/tests/field/ternary.leo rename to compiler/otests/field/ternary.leo diff --git a/compiler/tests/function/array_input.leo b/compiler/otests/function/array_input.leo similarity index 100% rename from compiler/tests/function/array_input.leo rename to compiler/otests/function/array_input.leo diff --git a/compiler/tests/function/array_params_direct_call.leo b/compiler/otests/function/array_params_direct_call.leo similarity index 100% rename from compiler/tests/function/array_params_direct_call.leo rename to compiler/otests/function/array_params_direct_call.leo diff --git a/compiler/tests/function/conditional_return.leo b/compiler/otests/function/conditional_return.leo similarity index 100% rename from compiler/tests/function/conditional_return.leo rename to compiler/otests/function/conditional_return.leo diff --git a/compiler/tests/function/duplicate_definition.leo b/compiler/otests/function/duplicate_definition.leo similarity index 100% rename from compiler/tests/function/duplicate_definition.leo rename to compiler/otests/function/duplicate_definition.leo diff --git a/compiler/tests/function/empty.leo b/compiler/otests/function/empty.leo similarity index 100% rename from compiler/tests/function/empty.leo rename to compiler/otests/function/empty.leo diff --git a/compiler/tests/function/input/conditional_return.in b/compiler/otests/function/input/conditional_return.in similarity index 100% rename from compiler/tests/function/input/conditional_return.in rename to compiler/otests/function/input/conditional_return.in diff --git a/compiler/tests/function/input/newlines.in b/compiler/otests/function/input/newlines.in similarity index 100% rename from compiler/tests/function/input/newlines.in rename to compiler/otests/function/input/newlines.in diff --git a/compiler/tests/function/input/registers.in b/compiler/otests/function/input/registers.in similarity index 100% rename from compiler/tests/function/input/registers.in rename to compiler/otests/function/input/registers.in diff --git a/compiler/tests/function/iteration.leo b/compiler/otests/function/iteration.leo similarity index 100% rename from compiler/tests/function/iteration.leo rename to compiler/otests/function/iteration.leo diff --git a/compiler/tests/function/iteration_repeated.leo b/compiler/otests/function/iteration_repeated.leo similarity index 100% rename from compiler/tests/function/iteration_repeated.leo rename to compiler/otests/function/iteration_repeated.leo diff --git a/compiler/tests/function/mod.rs b/compiler/otests/function/mod.rs similarity index 100% rename from compiler/tests/function/mod.rs rename to compiler/otests/function/mod.rs diff --git a/compiler/tests/function/multiple_returns.leo b/compiler/otests/function/multiple_returns.leo similarity index 100% rename from compiler/tests/function/multiple_returns.leo rename to compiler/otests/function/multiple_returns.leo diff --git a/compiler/tests/function/multiple_returns_fail.leo b/compiler/otests/function/multiple_returns_fail.leo similarity index 100% rename from compiler/tests/function/multiple_returns_fail.leo rename to compiler/otests/function/multiple_returns_fail.leo diff --git a/compiler/tests/function/multiple_returns_fail_conditional.leo b/compiler/otests/function/multiple_returns_fail_conditional.leo similarity index 100% rename from compiler/tests/function/multiple_returns_fail_conditional.leo rename to compiler/otests/function/multiple_returns_fail_conditional.leo diff --git a/compiler/tests/function/multiple_returns_main.leo b/compiler/otests/function/multiple_returns_main.leo similarity index 100% rename from compiler/tests/function/multiple_returns_main.leo rename to compiler/otests/function/multiple_returns_main.leo diff --git a/compiler/tests/function/newlines.leo b/compiler/otests/function/newlines.leo similarity index 100% rename from compiler/tests/function/newlines.leo rename to compiler/otests/function/newlines.leo diff --git a/compiler/tests/function/output/conditional_return.out b/compiler/otests/function/output/conditional_return.out similarity index 100% rename from compiler/tests/function/output/conditional_return.out rename to compiler/otests/function/output/conditional_return.out diff --git a/compiler/tests/function/output/newlines.out b/compiler/otests/function/output/newlines.out similarity index 100% rename from compiler/tests/function/output/newlines.out rename to compiler/otests/function/output/newlines.out diff --git a/compiler/tests/function/output/registers.out b/compiler/otests/function/output/registers.out similarity index 100% rename from compiler/tests/function/output/registers.out rename to compiler/otests/function/output/registers.out diff --git a/compiler/tests/function/repeated.leo b/compiler/otests/function/repeated.leo similarity index 100% rename from compiler/tests/function/repeated.leo rename to compiler/otests/function/repeated.leo diff --git a/compiler/tests/function/return.leo b/compiler/otests/function/return.leo similarity index 100% rename from compiler/tests/function/return.leo rename to compiler/otests/function/return.leo diff --git a/compiler/tests/function/return_array_nested_fail.leo b/compiler/otests/function/return_array_nested_fail.leo similarity index 100% rename from compiler/tests/function/return_array_nested_fail.leo rename to compiler/otests/function/return_array_nested_fail.leo diff --git a/compiler/tests/function/return_array_nested_pass.leo b/compiler/otests/function/return_array_nested_pass.leo similarity index 100% rename from compiler/tests/function/return_array_nested_pass.leo rename to compiler/otests/function/return_array_nested_pass.leo diff --git a/compiler/tests/function/return_array_tuple_fail.leo b/compiler/otests/function/return_array_tuple_fail.leo similarity index 100% rename from compiler/tests/function/return_array_tuple_fail.leo rename to compiler/otests/function/return_array_tuple_fail.leo diff --git a/compiler/tests/function/return_array_tuple_pass.leo b/compiler/otests/function/return_array_tuple_pass.leo similarity index 100% rename from compiler/tests/function/return_array_tuple_pass.leo rename to compiler/otests/function/return_array_tuple_pass.leo diff --git a/compiler/tests/function/return_tuple.leo b/compiler/otests/function/return_tuple.leo similarity index 100% rename from compiler/tests/function/return_tuple.leo rename to compiler/otests/function/return_tuple.leo diff --git a/compiler/tests/function/return_tuple_conditional.leo b/compiler/otests/function/return_tuple_conditional.leo similarity index 100% rename from compiler/tests/function/return_tuple_conditional.leo rename to compiler/otests/function/return_tuple_conditional.leo diff --git a/compiler/tests/function/scope_fail.leo b/compiler/otests/function/scope_fail.leo similarity index 100% rename from compiler/tests/function/scope_fail.leo rename to compiler/otests/function/scope_fail.leo diff --git a/compiler/tests/function/undefined.leo b/compiler/otests/function/undefined.leo similarity index 100% rename from compiler/tests/function/undefined.leo rename to compiler/otests/function/undefined.leo diff --git a/compiler/tests/function/value_unchanged.leo b/compiler/otests/function/value_unchanged.leo similarity index 100% rename from compiler/tests/function/value_unchanged.leo rename to compiler/otests/function/value_unchanged.leo diff --git a/compiler/tests/group/add.leo b/compiler/otests/group/add.leo similarity index 100% rename from compiler/tests/group/add.leo rename to compiler/otests/group/add.leo diff --git a/compiler/tests/group/assert_eq.leo b/compiler/otests/group/assert_eq.leo similarity index 100% rename from compiler/tests/group/assert_eq.leo rename to compiler/otests/group/assert_eq.leo diff --git a/compiler/tests/group/both_sign_high.leo b/compiler/otests/group/both_sign_high.leo similarity index 100% rename from compiler/tests/group/both_sign_high.leo rename to compiler/otests/group/both_sign_high.leo diff --git a/compiler/tests/group/both_sign_inferred.leo b/compiler/otests/group/both_sign_inferred.leo similarity index 100% rename from compiler/tests/group/both_sign_inferred.leo rename to compiler/otests/group/both_sign_inferred.leo diff --git a/compiler/tests/group/both_sign_low.leo b/compiler/otests/group/both_sign_low.leo similarity index 100% rename from compiler/tests/group/both_sign_low.leo rename to compiler/otests/group/both_sign_low.leo diff --git a/compiler/tests/group/eq.leo b/compiler/otests/group/eq.leo similarity index 100% rename from compiler/tests/group/eq.leo rename to compiler/otests/group/eq.leo diff --git a/compiler/tests/group/input.leo b/compiler/otests/group/input.leo similarity index 100% rename from compiler/tests/group/input.leo rename to compiler/otests/group/input.leo diff --git a/compiler/tests/group/input/invalid.in b/compiler/otests/group/input/invalid.in similarity index 100% rename from compiler/tests/group/input/invalid.in rename to compiler/otests/group/input/invalid.in diff --git a/compiler/tests/group/input/point.in b/compiler/otests/group/input/point.in similarity index 100% rename from compiler/tests/group/input/point.in rename to compiler/otests/group/input/point.in diff --git a/compiler/tests/group/input/valid.in b/compiler/otests/group/input/valid.in similarity index 100% rename from compiler/tests/group/input/valid.in rename to compiler/otests/group/input/valid.in diff --git a/compiler/tests/group/mod.rs b/compiler/otests/group/mod.rs similarity index 100% rename from compiler/tests/group/mod.rs rename to compiler/otests/group/mod.rs diff --git a/compiler/tests/group/negate.leo b/compiler/otests/group/negate.leo similarity index 100% rename from compiler/tests/group/negate.leo rename to compiler/otests/group/negate.leo diff --git a/compiler/tests/group/no_space_between_literal.leo b/compiler/otests/group/no_space_between_literal.leo similarity index 100% rename from compiler/tests/group/no_space_between_literal.leo rename to compiler/otests/group/no_space_between_literal.leo diff --git a/compiler/tests/group/one.leo b/compiler/otests/group/one.leo similarity index 100% rename from compiler/tests/group/one.leo rename to compiler/otests/group/one.leo diff --git a/compiler/tests/group/point.leo b/compiler/otests/group/point.leo similarity index 100% rename from compiler/tests/group/point.leo rename to compiler/otests/group/point.leo diff --git a/compiler/tests/group/point_input.leo b/compiler/otests/group/point_input.leo similarity index 100% rename from compiler/tests/group/point_input.leo rename to compiler/otests/group/point_input.leo diff --git a/compiler/tests/group/positive_and_negative.leo b/compiler/otests/group/positive_and_negative.leo similarity index 100% rename from compiler/tests/group/positive_and_negative.leo rename to compiler/otests/group/positive_and_negative.leo diff --git a/compiler/tests/group/sub.leo b/compiler/otests/group/sub.leo similarity index 100% rename from compiler/tests/group/sub.leo rename to compiler/otests/group/sub.leo diff --git a/compiler/tests/group/ternary.leo b/compiler/otests/group/ternary.leo similarity index 100% rename from compiler/tests/group/ternary.leo rename to compiler/otests/group/ternary.leo diff --git a/compiler/tests/group/x_and_y.leo b/compiler/otests/group/x_and_y.leo similarity index 100% rename from compiler/tests/group/x_and_y.leo rename to compiler/otests/group/x_and_y.leo diff --git a/compiler/tests/group/x_sign_high.leo b/compiler/otests/group/x_sign_high.leo similarity index 100% rename from compiler/tests/group/x_sign_high.leo rename to compiler/otests/group/x_sign_high.leo diff --git a/compiler/tests/group/x_sign_inferred.leo b/compiler/otests/group/x_sign_inferred.leo similarity index 100% rename from compiler/tests/group/x_sign_inferred.leo rename to compiler/otests/group/x_sign_inferred.leo diff --git a/compiler/tests/group/x_sign_low.leo b/compiler/otests/group/x_sign_low.leo similarity index 100% rename from compiler/tests/group/x_sign_low.leo rename to compiler/otests/group/x_sign_low.leo diff --git a/compiler/tests/group/y_sign_high.leo b/compiler/otests/group/y_sign_high.leo similarity index 100% rename from compiler/tests/group/y_sign_high.leo rename to compiler/otests/group/y_sign_high.leo diff --git a/compiler/tests/group/y_sign_inferred.leo b/compiler/otests/group/y_sign_inferred.leo similarity index 100% rename from compiler/tests/group/y_sign_inferred.leo rename to compiler/otests/group/y_sign_inferred.leo diff --git a/compiler/tests/group/y_sign_low.leo b/compiler/otests/group/y_sign_low.leo similarity index 100% rename from compiler/tests/group/y_sign_low.leo rename to compiler/otests/group/y_sign_low.leo diff --git a/compiler/tests/group/zero.leo b/compiler/otests/group/zero.leo similarity index 100% rename from compiler/tests/group/zero.leo rename to compiler/otests/group/zero.leo diff --git a/compiler/tests/import/alias.leo b/compiler/otests/import/alias.leo similarity index 100% rename from compiler/tests/import/alias.leo rename to compiler/otests/import/alias.leo diff --git a/compiler/tests/import/basic.leo b/compiler/otests/import/basic.leo similarity index 100% rename from compiler/tests/import/basic.leo rename to compiler/otests/import/basic.leo diff --git a/compiler/tests/import/imports/bar/.gitignore b/compiler/otests/import/imports/bar/.gitignore similarity index 100% rename from compiler/tests/import/imports/bar/.gitignore rename to compiler/otests/import/imports/bar/.gitignore diff --git a/compiler/tests/import/imports/bar/Leo.toml b/compiler/otests/import/imports/bar/Leo.toml similarity index 100% rename from compiler/tests/import/imports/bar/Leo.toml rename to compiler/otests/import/imports/bar/Leo.toml diff --git a/compiler/tests/import/imports/bar/src/bat/bat.leo b/compiler/otests/import/imports/bar/src/bat/bat.leo similarity index 100% rename from compiler/tests/import/imports/bar/src/bat/bat.leo rename to compiler/otests/import/imports/bar/src/bat/bat.leo diff --git a/compiler/tests/import/imports/bar/src/baz.leo b/compiler/otests/import/imports/bar/src/baz.leo similarity index 100% rename from compiler/tests/import/imports/bar/src/baz.leo rename to compiler/otests/import/imports/bar/src/baz.leo diff --git a/compiler/tests/import/imports/bar/src/lib.leo b/compiler/otests/import/imports/bar/src/lib.leo similarity index 100% rename from compiler/tests/import/imports/bar/src/lib.leo rename to compiler/otests/import/imports/bar/src/lib.leo diff --git a/compiler/tests/import/imports/car/.gitignore b/compiler/otests/import/imports/car/.gitignore similarity index 100% rename from compiler/tests/import/imports/car/.gitignore rename to compiler/otests/import/imports/car/.gitignore diff --git a/compiler/tests/import/imports/car/Leo.toml b/compiler/otests/import/imports/car/Leo.toml similarity index 100% rename from compiler/tests/import/imports/car/Leo.toml rename to compiler/otests/import/imports/car/Leo.toml diff --git a/compiler/tests/import/imports/car/src/lib.leo b/compiler/otests/import/imports/car/src/lib.leo similarity index 100% rename from compiler/tests/import/imports/car/src/lib.leo rename to compiler/otests/import/imports/car/src/lib.leo diff --git a/compiler/tests/import/many_import.leo b/compiler/otests/import/many_import.leo similarity index 100% rename from compiler/tests/import/many_import.leo rename to compiler/otests/import/many_import.leo diff --git a/compiler/tests/import/many_import_star.leo b/compiler/otests/import/many_import_star.leo similarity index 100% rename from compiler/tests/import/many_import_star.leo rename to compiler/otests/import/many_import_star.leo diff --git a/compiler/tests/import/mod.rs b/compiler/otests/import/mod.rs similarity index 100% rename from compiler/tests/import/mod.rs rename to compiler/otests/import/mod.rs diff --git a/compiler/tests/import/multiple.leo b/compiler/otests/import/multiple.leo similarity index 100% rename from compiler/tests/import/multiple.leo rename to compiler/otests/import/multiple.leo diff --git a/compiler/tests/import/names.leo b/compiler/otests/import/names.leo similarity index 100% rename from compiler/tests/import/names.leo rename to compiler/otests/import/names.leo diff --git a/compiler/tests/import/names_a_dash.leo b/compiler/otests/import/names_a_dash.leo similarity index 100% rename from compiler/tests/import/names_a_dash.leo rename to compiler/otests/import/names_a_dash.leo diff --git a/compiler/tests/import/names_dash_a.leo b/compiler/otests/import/names_dash_a.leo similarity index 100% rename from compiler/tests/import/names_dash_a.leo rename to compiler/otests/import/names_dash_a.leo diff --git a/compiler/tests/import/names_dollar.leo b/compiler/otests/import/names_dollar.leo similarity index 100% rename from compiler/tests/import/names_dollar.leo rename to compiler/otests/import/names_dollar.leo diff --git a/compiler/tests/import/names_underscore.leo b/compiler/otests/import/names_underscore.leo similarity index 100% rename from compiler/tests/import/names_underscore.leo rename to compiler/otests/import/names_underscore.leo diff --git a/compiler/tests/import/src/a-9.leo b/compiler/otests/import/src/a-9.leo similarity index 100% rename from compiler/tests/import/src/a-9.leo rename to compiler/otests/import/src/a-9.leo diff --git a/compiler/tests/import/src/a0-f.leo b/compiler/otests/import/src/a0-f.leo similarity index 100% rename from compiler/tests/import/src/a0-f.leo rename to compiler/otests/import/src/a0-f.leo diff --git a/compiler/tests/import/src/hello-world.leo b/compiler/otests/import/src/hello-world.leo similarity index 100% rename from compiler/tests/import/src/hello-world.leo rename to compiler/otests/import/src/hello-world.leo diff --git a/compiler/tests/import/src/test-import.leo b/compiler/otests/import/src/test-import.leo similarity index 100% rename from compiler/tests/import/src/test-import.leo rename to compiler/otests/import/src/test-import.leo diff --git a/compiler/tests/import/star.leo b/compiler/otests/import/star.leo similarity index 100% rename from compiler/tests/import/star.leo rename to compiler/otests/import/star.leo diff --git a/compiler/tests/import/star_fail.leo b/compiler/otests/import/star_fail.leo similarity index 100% rename from compiler/tests/import/star_fail.leo rename to compiler/otests/import/star_fail.leo diff --git a/compiler/tests/input_files/mod.rs b/compiler/otests/input_files/mod.rs similarity index 100% rename from compiler/tests/input_files/mod.rs rename to compiler/otests/input_files/mod.rs diff --git a/compiler/tests/input_files/program_input/input/main.in b/compiler/otests/input_files/program_input/input/main.in similarity index 100% rename from compiler/tests/input_files/program_input/input/main.in rename to compiler/otests/input_files/program_input/input/main.in diff --git a/compiler/tests/input_files/program_input/input/main_array.in b/compiler/otests/input_files/program_input/input/main_array.in similarity index 100% rename from compiler/tests/input_files/program_input/input/main_array.in rename to compiler/otests/input_files/program_input/input/main_array.in diff --git a/compiler/tests/input_files/program_input/input/main_array_fail.in b/compiler/otests/input_files/program_input/input/main_array_fail.in similarity index 100% rename from compiler/tests/input_files/program_input/input/main_array_fail.in rename to compiler/otests/input_files/program_input/input/main_array_fail.in diff --git a/compiler/tests/input_files/program_input/input/main_fail_name.in b/compiler/otests/input_files/program_input/input/main_fail_name.in similarity index 100% rename from compiler/tests/input_files/program_input/input/main_fail_name.in rename to compiler/otests/input_files/program_input/input/main_fail_name.in diff --git a/compiler/tests/input_files/program_input/input/main_fail_type.in b/compiler/otests/input_files/program_input/input/main_fail_type.in similarity index 100% rename from compiler/tests/input_files/program_input/input/main_fail_type.in rename to compiler/otests/input_files/program_input/input/main_fail_type.in diff --git a/compiler/tests/input_files/program_input/input/main_field.in b/compiler/otests/input_files/program_input/input/main_field.in similarity index 100% rename from compiler/tests/input_files/program_input/input/main_field.in rename to compiler/otests/input_files/program_input/input/main_field.in diff --git a/compiler/tests/input_files/program_input/input/main_group.in b/compiler/otests/input_files/program_input/input/main_group.in similarity index 100% rename from compiler/tests/input_files/program_input/input/main_group.in rename to compiler/otests/input_files/program_input/input/main_group.in diff --git a/compiler/tests/input_files/program_input/input/main_multi_dimension_array.in b/compiler/otests/input_files/program_input/input/main_multi_dimension_array.in similarity index 100% rename from compiler/tests/input_files/program_input/input/main_multi_dimension_array.in rename to compiler/otests/input_files/program_input/input/main_multi_dimension_array.in diff --git a/compiler/tests/input_files/program_input/input/main_multiple.in b/compiler/otests/input_files/program_input/input/main_multiple.in similarity index 100% rename from compiler/tests/input_files/program_input/input/main_multiple.in rename to compiler/otests/input_files/program_input/input/main_multiple.in diff --git a/compiler/tests/input_files/program_input/input/main_tuple_fail.in b/compiler/otests/input_files/program_input/input/main_tuple_fail.in similarity index 100% rename from compiler/tests/input_files/program_input/input/main_tuple_fail.in rename to compiler/otests/input_files/program_input/input/main_tuple_fail.in diff --git a/compiler/tests/input_files/program_input/main.leo b/compiler/otests/input_files/program_input/main.leo similarity index 100% rename from compiler/tests/input_files/program_input/main.leo rename to compiler/otests/input_files/program_input/main.leo diff --git a/compiler/tests/input_files/program_input/main_array.leo b/compiler/otests/input_files/program_input/main_array.leo similarity index 100% rename from compiler/tests/input_files/program_input/main_array.leo rename to compiler/otests/input_files/program_input/main_array.leo diff --git a/compiler/tests/input_files/program_input/main_array_fail.leo b/compiler/otests/input_files/program_input/main_array_fail.leo similarity index 100% rename from compiler/tests/input_files/program_input/main_array_fail.leo rename to compiler/otests/input_files/program_input/main_array_fail.leo diff --git a/compiler/tests/input_files/program_input/main_field.leo b/compiler/otests/input_files/program_input/main_field.leo similarity index 100% rename from compiler/tests/input_files/program_input/main_field.leo rename to compiler/otests/input_files/program_input/main_field.leo diff --git a/compiler/tests/input_files/program_input/main_group.leo b/compiler/otests/input_files/program_input/main_group.leo similarity index 100% rename from compiler/tests/input_files/program_input/main_group.leo rename to compiler/otests/input_files/program_input/main_group.leo diff --git a/compiler/tests/input_files/program_input/main_multi_dimension_array.leo b/compiler/otests/input_files/program_input/main_multi_dimension_array.leo similarity index 100% rename from compiler/tests/input_files/program_input/main_multi_dimension_array.leo rename to compiler/otests/input_files/program_input/main_multi_dimension_array.leo diff --git a/compiler/tests/input_files/program_input/main_multiple.leo b/compiler/otests/input_files/program_input/main_multiple.leo similarity index 100% rename from compiler/tests/input_files/program_input/main_multiple.leo rename to compiler/otests/input_files/program_input/main_multiple.leo diff --git a/compiler/tests/input_files/program_input/main_tuple_fail.leo b/compiler/otests/input_files/program_input/main_tuple_fail.leo similarity index 100% rename from compiler/tests/input_files/program_input/main_tuple_fail.leo rename to compiler/otests/input_files/program_input/main_tuple_fail.leo diff --git a/compiler/tests/input_files/program_input/mod.rs b/compiler/otests/input_files/program_input/mod.rs similarity index 100% rename from compiler/tests/input_files/program_input/mod.rs rename to compiler/otests/input_files/program_input/mod.rs diff --git a/compiler/tests/input_files/program_input_and_program_state/access.leo b/compiler/otests/input_files/program_input_and_program_state/access.leo similarity index 100% rename from compiler/tests/input_files/program_input_and_program_state/access.leo rename to compiler/otests/input_files/program_input_and_program_state/access.leo diff --git a/compiler/tests/input_files/program_input_and_program_state/input/basic.in b/compiler/otests/input_files/program_input_and_program_state/input/basic.in similarity index 100% rename from compiler/tests/input_files/program_input_and_program_state/input/basic.in rename to compiler/otests/input_files/program_input_and_program_state/input/basic.in diff --git a/compiler/tests/input_files/program_input_and_program_state/input/basic.state b/compiler/otests/input_files/program_input_and_program_state/input/basic.state similarity index 100% rename from compiler/tests/input_files/program_input_and_program_state/input/basic.state rename to compiler/otests/input_files/program_input_and_program_state/input/basic.state diff --git a/compiler/tests/input_files/program_input_and_program_state/input/token_withdraw.in b/compiler/otests/input_files/program_input_and_program_state/input/token_withdraw.in similarity index 100% rename from compiler/tests/input_files/program_input_and_program_state/input/token_withdraw.in rename to compiler/otests/input_files/program_input_and_program_state/input/token_withdraw.in diff --git a/compiler/tests/input_files/program_input_and_program_state/input/token_withdraw.state b/compiler/otests/input_files/program_input_and_program_state/input/token_withdraw.state similarity index 100% rename from compiler/tests/input_files/program_input_and_program_state/input/token_withdraw.state rename to compiler/otests/input_files/program_input_and_program_state/input/token_withdraw.state diff --git a/compiler/tests/input_files/program_input_and_program_state/mod.rs b/compiler/otests/input_files/program_input_and_program_state/mod.rs similarity index 100% rename from compiler/tests/input_files/program_input_and_program_state/mod.rs rename to compiler/otests/input_files/program_input_and_program_state/mod.rs diff --git a/compiler/tests/input_files/program_input_constants/input/main.in b/compiler/otests/input_files/program_input_constants/input/main.in similarity index 100% rename from compiler/tests/input_files/program_input_constants/input/main.in rename to compiler/otests/input_files/program_input_constants/input/main.in diff --git a/compiler/tests/input_files/program_input_constants/input/main_array.in b/compiler/otests/input_files/program_input_constants/input/main_array.in similarity index 100% rename from compiler/tests/input_files/program_input_constants/input/main_array.in rename to compiler/otests/input_files/program_input_constants/input/main_array.in diff --git a/compiler/tests/input_files/program_input_constants/input/main_array_fail.in b/compiler/otests/input_files/program_input_constants/input/main_array_fail.in similarity index 100% rename from compiler/tests/input_files/program_input_constants/input/main_array_fail.in rename to compiler/otests/input_files/program_input_constants/input/main_array_fail.in diff --git a/compiler/tests/input_files/program_input_constants/input/main_double_declaration_fail.in b/compiler/otests/input_files/program_input_constants/input/main_double_declaration_fail.in similarity index 100% rename from compiler/tests/input_files/program_input_constants/input/main_double_declaration_fail.in rename to compiler/otests/input_files/program_input_constants/input/main_double_declaration_fail.in diff --git a/compiler/tests/input_files/program_input_constants/input/main_fail_name.in b/compiler/otests/input_files/program_input_constants/input/main_fail_name.in similarity index 100% rename from compiler/tests/input_files/program_input_constants/input/main_fail_name.in rename to compiler/otests/input_files/program_input_constants/input/main_fail_name.in diff --git a/compiler/tests/input_files/program_input_constants/input/main_fail_type.in b/compiler/otests/input_files/program_input_constants/input/main_fail_type.in similarity index 100% rename from compiler/tests/input_files/program_input_constants/input/main_fail_type.in rename to compiler/otests/input_files/program_input_constants/input/main_fail_type.in diff --git a/compiler/tests/input_files/program_input_constants/input/main_field.in b/compiler/otests/input_files/program_input_constants/input/main_field.in similarity index 100% rename from compiler/tests/input_files/program_input_constants/input/main_field.in rename to compiler/otests/input_files/program_input_constants/input/main_field.in diff --git a/compiler/tests/input_files/program_input_constants/input/main_group.in b/compiler/otests/input_files/program_input_constants/input/main_group.in similarity index 100% rename from compiler/tests/input_files/program_input_constants/input/main_group.in rename to compiler/otests/input_files/program_input_constants/input/main_group.in diff --git a/compiler/tests/input_files/program_input_constants/input/main_multi_dimension_array.in b/compiler/otests/input_files/program_input_constants/input/main_multi_dimension_array.in similarity index 100% rename from compiler/tests/input_files/program_input_constants/input/main_multi_dimension_array.in rename to compiler/otests/input_files/program_input_constants/input/main_multi_dimension_array.in diff --git a/compiler/tests/input_files/program_input_constants/input/main_multiple.in b/compiler/otests/input_files/program_input_constants/input/main_multiple.in similarity index 100% rename from compiler/tests/input_files/program_input_constants/input/main_multiple.in rename to compiler/otests/input_files/program_input_constants/input/main_multiple.in diff --git a/compiler/tests/input_files/program_input_constants/input/main_not_const_input_fail.in b/compiler/otests/input_files/program_input_constants/input/main_not_const_input_fail.in similarity index 100% rename from compiler/tests/input_files/program_input_constants/input/main_not_const_input_fail.in rename to compiler/otests/input_files/program_input_constants/input/main_not_const_input_fail.in diff --git a/compiler/tests/input_files/program_input_constants/input/main_tuple_fail.in b/compiler/otests/input_files/program_input_constants/input/main_tuple_fail.in similarity index 100% rename from compiler/tests/input_files/program_input_constants/input/main_tuple_fail.in rename to compiler/otests/input_files/program_input_constants/input/main_tuple_fail.in diff --git a/compiler/tests/input_files/program_input_constants/input/main_type_mismatch.in b/compiler/otests/input_files/program_input_constants/input/main_type_mismatch.in similarity index 100% rename from compiler/tests/input_files/program_input_constants/input/main_type_mismatch.in rename to compiler/otests/input_files/program_input_constants/input/main_type_mismatch.in diff --git a/compiler/tests/input_files/program_input_constants/main.leo b/compiler/otests/input_files/program_input_constants/main.leo similarity index 100% rename from compiler/tests/input_files/program_input_constants/main.leo rename to compiler/otests/input_files/program_input_constants/main.leo diff --git a/compiler/tests/input_files/program_input_constants/main_array.leo b/compiler/otests/input_files/program_input_constants/main_array.leo similarity index 100% rename from compiler/tests/input_files/program_input_constants/main_array.leo rename to compiler/otests/input_files/program_input_constants/main_array.leo diff --git a/compiler/tests/input_files/program_input_constants/main_array_fail.leo b/compiler/otests/input_files/program_input_constants/main_array_fail.leo similarity index 100% rename from compiler/tests/input_files/program_input_constants/main_array_fail.leo rename to compiler/otests/input_files/program_input_constants/main_array_fail.leo diff --git a/compiler/tests/input_files/program_input_constants/main_field.leo b/compiler/otests/input_files/program_input_constants/main_field.leo similarity index 100% rename from compiler/tests/input_files/program_input_constants/main_field.leo rename to compiler/otests/input_files/program_input_constants/main_field.leo diff --git a/compiler/tests/input_files/program_input_constants/main_group.leo b/compiler/otests/input_files/program_input_constants/main_group.leo similarity index 100% rename from compiler/tests/input_files/program_input_constants/main_group.leo rename to compiler/otests/input_files/program_input_constants/main_group.leo diff --git a/compiler/tests/input_files/program_input_constants/main_multi_dimension_array.leo b/compiler/otests/input_files/program_input_constants/main_multi_dimension_array.leo similarity index 100% rename from compiler/tests/input_files/program_input_constants/main_multi_dimension_array.leo rename to compiler/otests/input_files/program_input_constants/main_multi_dimension_array.leo diff --git a/compiler/tests/input_files/program_input_constants/main_multiple.leo b/compiler/otests/input_files/program_input_constants/main_multiple.leo similarity index 100% rename from compiler/tests/input_files/program_input_constants/main_multiple.leo rename to compiler/otests/input_files/program_input_constants/main_multiple.leo diff --git a/compiler/tests/input_files/program_input_constants/main_tuple_fail.leo b/compiler/otests/input_files/program_input_constants/main_tuple_fail.leo similarity index 100% rename from compiler/tests/input_files/program_input_constants/main_tuple_fail.leo rename to compiler/otests/input_files/program_input_constants/main_tuple_fail.leo diff --git a/compiler/tests/input_files/program_input_constants/mod.rs b/compiler/otests/input_files/program_input_constants/mod.rs similarity index 100% rename from compiler/tests/input_files/program_input_constants/mod.rs rename to compiler/otests/input_files/program_input_constants/mod.rs diff --git a/compiler/tests/input_files/program_registers/input/array.in b/compiler/otests/input_files/program_registers/input/array.in similarity index 100% rename from compiler/tests/input_files/program_registers/input/array.in rename to compiler/otests/input_files/program_registers/input/array.in diff --git a/compiler/tests/input_files/program_registers/input/main.in b/compiler/otests/input_files/program_registers/input/main.in similarity index 100% rename from compiler/tests/input_files/program_registers/input/main.in rename to compiler/otests/input_files/program_registers/input/main.in diff --git a/compiler/tests/input_files/program_registers/mod.rs b/compiler/otests/input_files/program_registers/mod.rs similarity index 100% rename from compiler/tests/input_files/program_registers/mod.rs rename to compiler/otests/input_files/program_registers/mod.rs diff --git a/compiler/tests/input_files/program_registers/output/registers_array.out b/compiler/otests/input_files/program_registers/output/registers_array.out similarity index 100% rename from compiler/tests/input_files/program_registers/output/registers_array.out rename to compiler/otests/input_files/program_registers/output/registers_array.out diff --git a/compiler/tests/input_files/program_registers/output/registers_pass.out b/compiler/otests/input_files/program_registers/output/registers_pass.out similarity index 100% rename from compiler/tests/input_files/program_registers/output/registers_pass.out rename to compiler/otests/input_files/program_registers/output/registers_pass.out diff --git a/compiler/tests/input_files/program_registers/registers_array.leo b/compiler/otests/input_files/program_registers/registers_array.leo similarity index 100% rename from compiler/tests/input_files/program_registers/registers_array.leo rename to compiler/otests/input_files/program_registers/registers_array.leo diff --git a/compiler/tests/input_files/program_registers/registers_fail.leo b/compiler/otests/input_files/program_registers/registers_fail.leo similarity index 100% rename from compiler/tests/input_files/program_registers/registers_fail.leo rename to compiler/otests/input_files/program_registers/registers_fail.leo diff --git a/compiler/tests/input_files/program_registers/registers_pass.leo b/compiler/otests/input_files/program_registers/registers_pass.leo similarity index 100% rename from compiler/tests/input_files/program_registers/registers_pass.leo rename to compiler/otests/input_files/program_registers/registers_pass.leo diff --git a/compiler/tests/input_files/program_state/access_all.leo b/compiler/otests/input_files/program_state/access_all.leo similarity index 100% rename from compiler/tests/input_files/program_state/access_all.leo rename to compiler/otests/input_files/program_state/access_all.leo diff --git a/compiler/tests/input_files/program_state/access_state.leo b/compiler/otests/input_files/program_state/access_state.leo similarity index 100% rename from compiler/tests/input_files/program_state/access_state.leo rename to compiler/otests/input_files/program_state/access_state.leo diff --git a/compiler/tests/input_files/program_state/input/basic.state b/compiler/otests/input_files/program_state/input/basic.state similarity index 100% rename from compiler/tests/input_files/program_state/input/basic.state rename to compiler/otests/input_files/program_state/input/basic.state diff --git a/compiler/tests/input_files/program_state/input/section_invalid.state b/compiler/otests/input_files/program_state/input/section_invalid.state similarity index 100% rename from compiler/tests/input_files/program_state/input/section_invalid.state rename to compiler/otests/input_files/program_state/input/section_invalid.state diff --git a/compiler/tests/input_files/program_state/input/section_undefined.state b/compiler/otests/input_files/program_state/input/section_undefined.state similarity index 100% rename from compiler/tests/input_files/program_state/input/section_undefined.state rename to compiler/otests/input_files/program_state/input/section_undefined.state diff --git a/compiler/tests/input_files/program_state/input/token_withdraw.state b/compiler/otests/input_files/program_state/input/token_withdraw.state similarity index 100% rename from compiler/tests/input_files/program_state/input/token_withdraw.state rename to compiler/otests/input_files/program_state/input/token_withdraw.state diff --git a/compiler/tests/input_files/program_state/input/visibility_fail.state b/compiler/otests/input_files/program_state/input/visibility_fail.state similarity index 100% rename from compiler/tests/input_files/program_state/input/visibility_fail.state rename to compiler/otests/input_files/program_state/input/visibility_fail.state diff --git a/compiler/tests/input_files/program_state/mod.rs b/compiler/otests/input_files/program_state/mod.rs similarity index 100% rename from compiler/tests/input_files/program_state/mod.rs rename to compiler/otests/input_files/program_state/mod.rs diff --git a/compiler/tests/integers/i128/add.leo b/compiler/otests/integers/i128/add.leo similarity index 100% rename from compiler/tests/integers/i128/add.leo rename to compiler/otests/integers/i128/add.leo diff --git a/compiler/tests/integers/i128/console_assert.leo b/compiler/otests/integers/i128/console_assert.leo similarity index 100% rename from compiler/tests/integers/i128/console_assert.leo rename to compiler/otests/integers/i128/console_assert.leo diff --git a/compiler/tests/integers/i128/div.leo b/compiler/otests/integers/i128/div.leo similarity index 100% rename from compiler/tests/integers/i128/div.leo rename to compiler/otests/integers/i128/div.leo diff --git a/compiler/tests/integers/i128/eq.leo b/compiler/otests/integers/i128/eq.leo similarity index 100% rename from compiler/tests/integers/i128/eq.leo rename to compiler/otests/integers/i128/eq.leo diff --git a/compiler/tests/integers/i128/ge.leo b/compiler/otests/integers/i128/ge.leo similarity index 100% rename from compiler/tests/integers/i128/ge.leo rename to compiler/otests/integers/i128/ge.leo diff --git a/compiler/tests/integers/i128/gt.leo b/compiler/otests/integers/i128/gt.leo similarity index 100% rename from compiler/tests/integers/i128/gt.leo rename to compiler/otests/integers/i128/gt.leo diff --git a/compiler/tests/integers/i128/input.leo b/compiler/otests/integers/i128/input.leo similarity index 100% rename from compiler/tests/integers/i128/input.leo rename to compiler/otests/integers/i128/input.leo diff --git a/compiler/tests/integers/i128/le.leo b/compiler/otests/integers/i128/le.leo similarity index 100% rename from compiler/tests/integers/i128/le.leo rename to compiler/otests/integers/i128/le.leo diff --git a/compiler/tests/integers/i128/lt.leo b/compiler/otests/integers/i128/lt.leo similarity index 100% rename from compiler/tests/integers/i128/lt.leo rename to compiler/otests/integers/i128/lt.leo diff --git a/compiler/tests/integers/i128/max.leo b/compiler/otests/integers/i128/max.leo similarity index 100% rename from compiler/tests/integers/i128/max.leo rename to compiler/otests/integers/i128/max.leo diff --git a/compiler/tests/integers/i128/max_fail.leo b/compiler/otests/integers/i128/max_fail.leo similarity index 100% rename from compiler/tests/integers/i128/max_fail.leo rename to compiler/otests/integers/i128/max_fail.leo diff --git a/compiler/tests/integers/i128/min.leo b/compiler/otests/integers/i128/min.leo similarity index 100% rename from compiler/tests/integers/i128/min.leo rename to compiler/otests/integers/i128/min.leo diff --git a/compiler/tests/integers/i128/min_fail.leo b/compiler/otests/integers/i128/min_fail.leo similarity index 100% rename from compiler/tests/integers/i128/min_fail.leo rename to compiler/otests/integers/i128/min_fail.leo diff --git a/compiler/tests/integers/i128/mod.rs b/compiler/otests/integers/i128/mod.rs similarity index 100% rename from compiler/tests/integers/i128/mod.rs rename to compiler/otests/integers/i128/mod.rs diff --git a/compiler/tests/integers/i128/mul.leo b/compiler/otests/integers/i128/mul.leo similarity index 100% rename from compiler/tests/integers/i128/mul.leo rename to compiler/otests/integers/i128/mul.leo diff --git a/compiler/tests/integers/i128/ne.leo b/compiler/otests/integers/i128/ne.leo similarity index 100% rename from compiler/tests/integers/i128/ne.leo rename to compiler/otests/integers/i128/ne.leo diff --git a/compiler/tests/integers/i128/negate.leo b/compiler/otests/integers/i128/negate.leo similarity index 100% rename from compiler/tests/integers/i128/negate.leo rename to compiler/otests/integers/i128/negate.leo diff --git a/compiler/tests/integers/i128/negate_min.leo b/compiler/otests/integers/i128/negate_min.leo similarity index 100% rename from compiler/tests/integers/i128/negate_min.leo rename to compiler/otests/integers/i128/negate_min.leo diff --git a/compiler/tests/integers/i128/negate_zero.leo b/compiler/otests/integers/i128/negate_zero.leo similarity index 100% rename from compiler/tests/integers/i128/negate_zero.leo rename to compiler/otests/integers/i128/negate_zero.leo diff --git a/compiler/tests/integers/i128/no_space_between_literal.leo b/compiler/otests/integers/i128/no_space_between_literal.leo similarity index 100% rename from compiler/tests/integers/i128/no_space_between_literal.leo rename to compiler/otests/integers/i128/no_space_between_literal.leo diff --git a/compiler/tests/integers/i128/pow.leo b/compiler/otests/integers/i128/pow.leo similarity index 100% rename from compiler/tests/integers/i128/pow.leo rename to compiler/otests/integers/i128/pow.leo diff --git a/compiler/tests/integers/i128/sub.leo b/compiler/otests/integers/i128/sub.leo similarity index 100% rename from compiler/tests/integers/i128/sub.leo rename to compiler/otests/integers/i128/sub.leo diff --git a/compiler/tests/integers/i128/ternary.leo b/compiler/otests/integers/i128/ternary.leo similarity index 100% rename from compiler/tests/integers/i128/ternary.leo rename to compiler/otests/integers/i128/ternary.leo diff --git a/compiler/tests/integers/i16/add.leo b/compiler/otests/integers/i16/add.leo similarity index 100% rename from compiler/tests/integers/i16/add.leo rename to compiler/otests/integers/i16/add.leo diff --git a/compiler/tests/integers/i16/console_assert.leo b/compiler/otests/integers/i16/console_assert.leo similarity index 100% rename from compiler/tests/integers/i16/console_assert.leo rename to compiler/otests/integers/i16/console_assert.leo diff --git a/compiler/tests/integers/i16/div.leo b/compiler/otests/integers/i16/div.leo similarity index 100% rename from compiler/tests/integers/i16/div.leo rename to compiler/otests/integers/i16/div.leo diff --git a/compiler/tests/integers/i16/eq.leo b/compiler/otests/integers/i16/eq.leo similarity index 100% rename from compiler/tests/integers/i16/eq.leo rename to compiler/otests/integers/i16/eq.leo diff --git a/compiler/tests/integers/i16/ge.leo b/compiler/otests/integers/i16/ge.leo similarity index 100% rename from compiler/tests/integers/i16/ge.leo rename to compiler/otests/integers/i16/ge.leo diff --git a/compiler/tests/integers/i16/gt.leo b/compiler/otests/integers/i16/gt.leo similarity index 100% rename from compiler/tests/integers/i16/gt.leo rename to compiler/otests/integers/i16/gt.leo diff --git a/compiler/tests/integers/i16/input.leo b/compiler/otests/integers/i16/input.leo similarity index 100% rename from compiler/tests/integers/i16/input.leo rename to compiler/otests/integers/i16/input.leo diff --git a/compiler/tests/integers/i16/le.leo b/compiler/otests/integers/i16/le.leo similarity index 100% rename from compiler/tests/integers/i16/le.leo rename to compiler/otests/integers/i16/le.leo diff --git a/compiler/tests/integers/i16/lt.leo b/compiler/otests/integers/i16/lt.leo similarity index 100% rename from compiler/tests/integers/i16/lt.leo rename to compiler/otests/integers/i16/lt.leo diff --git a/compiler/tests/integers/i16/max.leo b/compiler/otests/integers/i16/max.leo similarity index 100% rename from compiler/tests/integers/i16/max.leo rename to compiler/otests/integers/i16/max.leo diff --git a/compiler/tests/integers/i16/max_fail.leo b/compiler/otests/integers/i16/max_fail.leo similarity index 100% rename from compiler/tests/integers/i16/max_fail.leo rename to compiler/otests/integers/i16/max_fail.leo diff --git a/compiler/tests/integers/i16/min.leo b/compiler/otests/integers/i16/min.leo similarity index 100% rename from compiler/tests/integers/i16/min.leo rename to compiler/otests/integers/i16/min.leo diff --git a/compiler/tests/integers/i16/min_fail.leo b/compiler/otests/integers/i16/min_fail.leo similarity index 100% rename from compiler/tests/integers/i16/min_fail.leo rename to compiler/otests/integers/i16/min_fail.leo diff --git a/compiler/tests/integers/i16/mod.rs b/compiler/otests/integers/i16/mod.rs similarity index 100% rename from compiler/tests/integers/i16/mod.rs rename to compiler/otests/integers/i16/mod.rs diff --git a/compiler/tests/integers/i16/mul.leo b/compiler/otests/integers/i16/mul.leo similarity index 100% rename from compiler/tests/integers/i16/mul.leo rename to compiler/otests/integers/i16/mul.leo diff --git a/compiler/tests/integers/i16/ne.leo b/compiler/otests/integers/i16/ne.leo similarity index 100% rename from compiler/tests/integers/i16/ne.leo rename to compiler/otests/integers/i16/ne.leo diff --git a/compiler/tests/integers/i16/negate.leo b/compiler/otests/integers/i16/negate.leo similarity index 100% rename from compiler/tests/integers/i16/negate.leo rename to compiler/otests/integers/i16/negate.leo diff --git a/compiler/tests/integers/i16/negate_min.leo b/compiler/otests/integers/i16/negate_min.leo similarity index 100% rename from compiler/tests/integers/i16/negate_min.leo rename to compiler/otests/integers/i16/negate_min.leo diff --git a/compiler/tests/integers/i16/negate_zero.leo b/compiler/otests/integers/i16/negate_zero.leo similarity index 100% rename from compiler/tests/integers/i16/negate_zero.leo rename to compiler/otests/integers/i16/negate_zero.leo diff --git a/compiler/tests/integers/i16/no_space_between_literal.leo b/compiler/otests/integers/i16/no_space_between_literal.leo similarity index 100% rename from compiler/tests/integers/i16/no_space_between_literal.leo rename to compiler/otests/integers/i16/no_space_between_literal.leo diff --git a/compiler/tests/integers/i16/pow.leo b/compiler/otests/integers/i16/pow.leo similarity index 100% rename from compiler/tests/integers/i16/pow.leo rename to compiler/otests/integers/i16/pow.leo diff --git a/compiler/tests/integers/i16/sub.leo b/compiler/otests/integers/i16/sub.leo similarity index 100% rename from compiler/tests/integers/i16/sub.leo rename to compiler/otests/integers/i16/sub.leo diff --git a/compiler/tests/integers/i16/ternary.leo b/compiler/otests/integers/i16/ternary.leo similarity index 100% rename from compiler/tests/integers/i16/ternary.leo rename to compiler/otests/integers/i16/ternary.leo diff --git a/compiler/tests/integers/i32/add.leo b/compiler/otests/integers/i32/add.leo similarity index 100% rename from compiler/tests/integers/i32/add.leo rename to compiler/otests/integers/i32/add.leo diff --git a/compiler/tests/integers/i32/console_assert.leo b/compiler/otests/integers/i32/console_assert.leo similarity index 100% rename from compiler/tests/integers/i32/console_assert.leo rename to compiler/otests/integers/i32/console_assert.leo diff --git a/compiler/tests/integers/i32/div.leo b/compiler/otests/integers/i32/div.leo similarity index 100% rename from compiler/tests/integers/i32/div.leo rename to compiler/otests/integers/i32/div.leo diff --git a/compiler/tests/integers/i32/eq.leo b/compiler/otests/integers/i32/eq.leo similarity index 100% rename from compiler/tests/integers/i32/eq.leo rename to compiler/otests/integers/i32/eq.leo diff --git a/compiler/tests/integers/i32/ge.leo b/compiler/otests/integers/i32/ge.leo similarity index 100% rename from compiler/tests/integers/i32/ge.leo rename to compiler/otests/integers/i32/ge.leo diff --git a/compiler/tests/integers/i32/gt.leo b/compiler/otests/integers/i32/gt.leo similarity index 100% rename from compiler/tests/integers/i32/gt.leo rename to compiler/otests/integers/i32/gt.leo diff --git a/compiler/tests/integers/i32/input.leo b/compiler/otests/integers/i32/input.leo similarity index 100% rename from compiler/tests/integers/i32/input.leo rename to compiler/otests/integers/i32/input.leo diff --git a/compiler/tests/integers/i32/le.leo b/compiler/otests/integers/i32/le.leo similarity index 100% rename from compiler/tests/integers/i32/le.leo rename to compiler/otests/integers/i32/le.leo diff --git a/compiler/tests/integers/i32/lt.leo b/compiler/otests/integers/i32/lt.leo similarity index 100% rename from compiler/tests/integers/i32/lt.leo rename to compiler/otests/integers/i32/lt.leo diff --git a/compiler/tests/integers/i32/max.leo b/compiler/otests/integers/i32/max.leo similarity index 100% rename from compiler/tests/integers/i32/max.leo rename to compiler/otests/integers/i32/max.leo diff --git a/compiler/tests/integers/i32/max_fail.leo b/compiler/otests/integers/i32/max_fail.leo similarity index 100% rename from compiler/tests/integers/i32/max_fail.leo rename to compiler/otests/integers/i32/max_fail.leo diff --git a/compiler/tests/integers/i32/min.leo b/compiler/otests/integers/i32/min.leo similarity index 100% rename from compiler/tests/integers/i32/min.leo rename to compiler/otests/integers/i32/min.leo diff --git a/compiler/tests/integers/i32/min_fail.leo b/compiler/otests/integers/i32/min_fail.leo similarity index 100% rename from compiler/tests/integers/i32/min_fail.leo rename to compiler/otests/integers/i32/min_fail.leo diff --git a/compiler/tests/integers/i32/mod.rs b/compiler/otests/integers/i32/mod.rs similarity index 100% rename from compiler/tests/integers/i32/mod.rs rename to compiler/otests/integers/i32/mod.rs diff --git a/compiler/tests/integers/i32/mul.leo b/compiler/otests/integers/i32/mul.leo similarity index 100% rename from compiler/tests/integers/i32/mul.leo rename to compiler/otests/integers/i32/mul.leo diff --git a/compiler/tests/integers/i32/ne.leo b/compiler/otests/integers/i32/ne.leo similarity index 100% rename from compiler/tests/integers/i32/ne.leo rename to compiler/otests/integers/i32/ne.leo diff --git a/compiler/tests/integers/i32/negate.leo b/compiler/otests/integers/i32/negate.leo similarity index 100% rename from compiler/tests/integers/i32/negate.leo rename to compiler/otests/integers/i32/negate.leo diff --git a/compiler/tests/integers/i32/negate_min.leo b/compiler/otests/integers/i32/negate_min.leo similarity index 100% rename from compiler/tests/integers/i32/negate_min.leo rename to compiler/otests/integers/i32/negate_min.leo diff --git a/compiler/tests/integers/i32/negate_zero.leo b/compiler/otests/integers/i32/negate_zero.leo similarity index 100% rename from compiler/tests/integers/i32/negate_zero.leo rename to compiler/otests/integers/i32/negate_zero.leo diff --git a/compiler/tests/integers/i32/no_space_between_literal.leo b/compiler/otests/integers/i32/no_space_between_literal.leo similarity index 100% rename from compiler/tests/integers/i32/no_space_between_literal.leo rename to compiler/otests/integers/i32/no_space_between_literal.leo diff --git a/compiler/tests/integers/i32/pow.leo b/compiler/otests/integers/i32/pow.leo similarity index 100% rename from compiler/tests/integers/i32/pow.leo rename to compiler/otests/integers/i32/pow.leo diff --git a/compiler/tests/integers/i32/sub.leo b/compiler/otests/integers/i32/sub.leo similarity index 100% rename from compiler/tests/integers/i32/sub.leo rename to compiler/otests/integers/i32/sub.leo diff --git a/compiler/tests/integers/i32/ternary.leo b/compiler/otests/integers/i32/ternary.leo similarity index 100% rename from compiler/tests/integers/i32/ternary.leo rename to compiler/otests/integers/i32/ternary.leo diff --git a/compiler/tests/integers/i64/add.leo b/compiler/otests/integers/i64/add.leo similarity index 100% rename from compiler/tests/integers/i64/add.leo rename to compiler/otests/integers/i64/add.leo diff --git a/compiler/tests/integers/i64/console_assert.leo b/compiler/otests/integers/i64/console_assert.leo similarity index 100% rename from compiler/tests/integers/i64/console_assert.leo rename to compiler/otests/integers/i64/console_assert.leo diff --git a/compiler/tests/integers/i64/div.leo b/compiler/otests/integers/i64/div.leo similarity index 100% rename from compiler/tests/integers/i64/div.leo rename to compiler/otests/integers/i64/div.leo diff --git a/compiler/tests/integers/i64/eq.leo b/compiler/otests/integers/i64/eq.leo similarity index 100% rename from compiler/tests/integers/i64/eq.leo rename to compiler/otests/integers/i64/eq.leo diff --git a/compiler/tests/integers/i64/ge.leo b/compiler/otests/integers/i64/ge.leo similarity index 100% rename from compiler/tests/integers/i64/ge.leo rename to compiler/otests/integers/i64/ge.leo diff --git a/compiler/tests/integers/i64/gt.leo b/compiler/otests/integers/i64/gt.leo similarity index 100% rename from compiler/tests/integers/i64/gt.leo rename to compiler/otests/integers/i64/gt.leo diff --git a/compiler/tests/integers/i64/input.leo b/compiler/otests/integers/i64/input.leo similarity index 100% rename from compiler/tests/integers/i64/input.leo rename to compiler/otests/integers/i64/input.leo diff --git a/compiler/tests/integers/i64/le.leo b/compiler/otests/integers/i64/le.leo similarity index 100% rename from compiler/tests/integers/i64/le.leo rename to compiler/otests/integers/i64/le.leo diff --git a/compiler/tests/integers/i64/lt.leo b/compiler/otests/integers/i64/lt.leo similarity index 100% rename from compiler/tests/integers/i64/lt.leo rename to compiler/otests/integers/i64/lt.leo diff --git a/compiler/tests/integers/i64/max.leo b/compiler/otests/integers/i64/max.leo similarity index 100% rename from compiler/tests/integers/i64/max.leo rename to compiler/otests/integers/i64/max.leo diff --git a/compiler/tests/integers/i64/max_fail.leo b/compiler/otests/integers/i64/max_fail.leo similarity index 100% rename from compiler/tests/integers/i64/max_fail.leo rename to compiler/otests/integers/i64/max_fail.leo diff --git a/compiler/tests/integers/i64/min.leo b/compiler/otests/integers/i64/min.leo similarity index 100% rename from compiler/tests/integers/i64/min.leo rename to compiler/otests/integers/i64/min.leo diff --git a/compiler/tests/integers/i64/min_fail.leo b/compiler/otests/integers/i64/min_fail.leo similarity index 100% rename from compiler/tests/integers/i64/min_fail.leo rename to compiler/otests/integers/i64/min_fail.leo diff --git a/compiler/tests/integers/i64/mod.rs b/compiler/otests/integers/i64/mod.rs similarity index 100% rename from compiler/tests/integers/i64/mod.rs rename to compiler/otests/integers/i64/mod.rs diff --git a/compiler/tests/integers/i64/mul.leo b/compiler/otests/integers/i64/mul.leo similarity index 100% rename from compiler/tests/integers/i64/mul.leo rename to compiler/otests/integers/i64/mul.leo diff --git a/compiler/tests/integers/i64/ne.leo b/compiler/otests/integers/i64/ne.leo similarity index 100% rename from compiler/tests/integers/i64/ne.leo rename to compiler/otests/integers/i64/ne.leo diff --git a/compiler/tests/integers/i64/negate.leo b/compiler/otests/integers/i64/negate.leo similarity index 100% rename from compiler/tests/integers/i64/negate.leo rename to compiler/otests/integers/i64/negate.leo diff --git a/compiler/tests/integers/i64/negate_min.leo b/compiler/otests/integers/i64/negate_min.leo similarity index 100% rename from compiler/tests/integers/i64/negate_min.leo rename to compiler/otests/integers/i64/negate_min.leo diff --git a/compiler/tests/integers/i64/negate_zero.leo b/compiler/otests/integers/i64/negate_zero.leo similarity index 100% rename from compiler/tests/integers/i64/negate_zero.leo rename to compiler/otests/integers/i64/negate_zero.leo diff --git a/compiler/tests/integers/i64/no_space_between_literal.leo b/compiler/otests/integers/i64/no_space_between_literal.leo similarity index 100% rename from compiler/tests/integers/i64/no_space_between_literal.leo rename to compiler/otests/integers/i64/no_space_between_literal.leo diff --git a/compiler/tests/integers/i64/pow.leo b/compiler/otests/integers/i64/pow.leo similarity index 100% rename from compiler/tests/integers/i64/pow.leo rename to compiler/otests/integers/i64/pow.leo diff --git a/compiler/tests/integers/i64/sub.leo b/compiler/otests/integers/i64/sub.leo similarity index 100% rename from compiler/tests/integers/i64/sub.leo rename to compiler/otests/integers/i64/sub.leo diff --git a/compiler/tests/integers/i64/ternary.leo b/compiler/otests/integers/i64/ternary.leo similarity index 100% rename from compiler/tests/integers/i64/ternary.leo rename to compiler/otests/integers/i64/ternary.leo diff --git a/compiler/tests/integers/i8/add.leo b/compiler/otests/integers/i8/add.leo similarity index 100% rename from compiler/tests/integers/i8/add.leo rename to compiler/otests/integers/i8/add.leo diff --git a/compiler/tests/integers/i8/console_assert.leo b/compiler/otests/integers/i8/console_assert.leo similarity index 100% rename from compiler/tests/integers/i8/console_assert.leo rename to compiler/otests/integers/i8/console_assert.leo diff --git a/compiler/tests/integers/i8/div.leo b/compiler/otests/integers/i8/div.leo similarity index 100% rename from compiler/tests/integers/i8/div.leo rename to compiler/otests/integers/i8/div.leo diff --git a/compiler/tests/integers/i8/eq.leo b/compiler/otests/integers/i8/eq.leo similarity index 100% rename from compiler/tests/integers/i8/eq.leo rename to compiler/otests/integers/i8/eq.leo diff --git a/compiler/tests/integers/i8/ge.leo b/compiler/otests/integers/i8/ge.leo similarity index 100% rename from compiler/tests/integers/i8/ge.leo rename to compiler/otests/integers/i8/ge.leo diff --git a/compiler/tests/integers/i8/gt.leo b/compiler/otests/integers/i8/gt.leo similarity index 100% rename from compiler/tests/integers/i8/gt.leo rename to compiler/otests/integers/i8/gt.leo diff --git a/compiler/tests/integers/i8/input.leo b/compiler/otests/integers/i8/input.leo similarity index 100% rename from compiler/tests/integers/i8/input.leo rename to compiler/otests/integers/i8/input.leo diff --git a/compiler/tests/integers/i8/le.leo b/compiler/otests/integers/i8/le.leo similarity index 100% rename from compiler/tests/integers/i8/le.leo rename to compiler/otests/integers/i8/le.leo diff --git a/compiler/tests/integers/i8/lt.leo b/compiler/otests/integers/i8/lt.leo similarity index 100% rename from compiler/tests/integers/i8/lt.leo rename to compiler/otests/integers/i8/lt.leo diff --git a/compiler/tests/integers/i8/max.leo b/compiler/otests/integers/i8/max.leo similarity index 100% rename from compiler/tests/integers/i8/max.leo rename to compiler/otests/integers/i8/max.leo diff --git a/compiler/tests/integers/i8/max_fail.leo b/compiler/otests/integers/i8/max_fail.leo similarity index 100% rename from compiler/tests/integers/i8/max_fail.leo rename to compiler/otests/integers/i8/max_fail.leo diff --git a/compiler/tests/integers/i8/min.leo b/compiler/otests/integers/i8/min.leo similarity index 100% rename from compiler/tests/integers/i8/min.leo rename to compiler/otests/integers/i8/min.leo diff --git a/compiler/tests/integers/i8/min_fail.leo b/compiler/otests/integers/i8/min_fail.leo similarity index 100% rename from compiler/tests/integers/i8/min_fail.leo rename to compiler/otests/integers/i8/min_fail.leo diff --git a/compiler/tests/integers/i8/mod.rs b/compiler/otests/integers/i8/mod.rs similarity index 100% rename from compiler/tests/integers/i8/mod.rs rename to compiler/otests/integers/i8/mod.rs diff --git a/compiler/tests/integers/i8/mul.leo b/compiler/otests/integers/i8/mul.leo similarity index 100% rename from compiler/tests/integers/i8/mul.leo rename to compiler/otests/integers/i8/mul.leo diff --git a/compiler/tests/integers/i8/ne.leo b/compiler/otests/integers/i8/ne.leo similarity index 100% rename from compiler/tests/integers/i8/ne.leo rename to compiler/otests/integers/i8/ne.leo diff --git a/compiler/tests/integers/i8/negate.leo b/compiler/otests/integers/i8/negate.leo similarity index 100% rename from compiler/tests/integers/i8/negate.leo rename to compiler/otests/integers/i8/negate.leo diff --git a/compiler/tests/integers/i8/negate_min.leo b/compiler/otests/integers/i8/negate_min.leo similarity index 100% rename from compiler/tests/integers/i8/negate_min.leo rename to compiler/otests/integers/i8/negate_min.leo diff --git a/compiler/tests/integers/i8/negate_zero.leo b/compiler/otests/integers/i8/negate_zero.leo similarity index 100% rename from compiler/tests/integers/i8/negate_zero.leo rename to compiler/otests/integers/i8/negate_zero.leo diff --git a/compiler/tests/integers/i8/no_space_between_literal.leo b/compiler/otests/integers/i8/no_space_between_literal.leo similarity index 100% rename from compiler/tests/integers/i8/no_space_between_literal.leo rename to compiler/otests/integers/i8/no_space_between_literal.leo diff --git a/compiler/tests/integers/i8/pow.leo b/compiler/otests/integers/i8/pow.leo similarity index 100% rename from compiler/tests/integers/i8/pow.leo rename to compiler/otests/integers/i8/pow.leo diff --git a/compiler/tests/integers/i8/sub.leo b/compiler/otests/integers/i8/sub.leo similarity index 100% rename from compiler/tests/integers/i8/sub.leo rename to compiler/otests/integers/i8/sub.leo diff --git a/compiler/tests/integers/i8/ternary.leo b/compiler/otests/integers/i8/ternary.leo similarity index 100% rename from compiler/tests/integers/i8/ternary.leo rename to compiler/otests/integers/i8/ternary.leo diff --git a/compiler/tests/integers/int_macro.rs b/compiler/otests/integers/int_macro.rs similarity index 100% rename from compiler/tests/integers/int_macro.rs rename to compiler/otests/integers/int_macro.rs diff --git a/compiler/tests/integers/integer_tester.rs b/compiler/otests/integers/integer_tester.rs similarity index 100% rename from compiler/tests/integers/integer_tester.rs rename to compiler/otests/integers/integer_tester.rs diff --git a/compiler/tests/integers/mod.rs b/compiler/otests/integers/mod.rs similarity index 100% rename from compiler/tests/integers/mod.rs rename to compiler/otests/integers/mod.rs diff --git a/compiler/tests/integers/u128/add.leo b/compiler/otests/integers/u128/add.leo similarity index 100% rename from compiler/tests/integers/u128/add.leo rename to compiler/otests/integers/u128/add.leo diff --git a/compiler/tests/integers/u128/console_assert.leo b/compiler/otests/integers/u128/console_assert.leo similarity index 100% rename from compiler/tests/integers/u128/console_assert.leo rename to compiler/otests/integers/u128/console_assert.leo diff --git a/compiler/tests/integers/u128/div.leo b/compiler/otests/integers/u128/div.leo similarity index 100% rename from compiler/tests/integers/u128/div.leo rename to compiler/otests/integers/u128/div.leo diff --git a/compiler/tests/integers/u128/eq.leo b/compiler/otests/integers/u128/eq.leo similarity index 100% rename from compiler/tests/integers/u128/eq.leo rename to compiler/otests/integers/u128/eq.leo diff --git a/compiler/tests/integers/u128/ge.leo b/compiler/otests/integers/u128/ge.leo similarity index 100% rename from compiler/tests/integers/u128/ge.leo rename to compiler/otests/integers/u128/ge.leo diff --git a/compiler/tests/integers/u128/gt.leo b/compiler/otests/integers/u128/gt.leo similarity index 100% rename from compiler/tests/integers/u128/gt.leo rename to compiler/otests/integers/u128/gt.leo diff --git a/compiler/tests/integers/u128/input.leo b/compiler/otests/integers/u128/input.leo similarity index 100% rename from compiler/tests/integers/u128/input.leo rename to compiler/otests/integers/u128/input.leo diff --git a/compiler/tests/integers/u128/le.leo b/compiler/otests/integers/u128/le.leo similarity index 100% rename from compiler/tests/integers/u128/le.leo rename to compiler/otests/integers/u128/le.leo diff --git a/compiler/tests/integers/u128/lt.leo b/compiler/otests/integers/u128/lt.leo similarity index 100% rename from compiler/tests/integers/u128/lt.leo rename to compiler/otests/integers/u128/lt.leo diff --git a/compiler/tests/integers/u128/max.leo b/compiler/otests/integers/u128/max.leo similarity index 100% rename from compiler/tests/integers/u128/max.leo rename to compiler/otests/integers/u128/max.leo diff --git a/compiler/tests/integers/u128/max_fail.leo b/compiler/otests/integers/u128/max_fail.leo similarity index 100% rename from compiler/tests/integers/u128/max_fail.leo rename to compiler/otests/integers/u128/max_fail.leo diff --git a/compiler/tests/integers/u128/min.leo b/compiler/otests/integers/u128/min.leo similarity index 100% rename from compiler/tests/integers/u128/min.leo rename to compiler/otests/integers/u128/min.leo diff --git a/compiler/tests/integers/u128/min_fail.leo b/compiler/otests/integers/u128/min_fail.leo similarity index 100% rename from compiler/tests/integers/u128/min_fail.leo rename to compiler/otests/integers/u128/min_fail.leo diff --git a/compiler/tests/integers/u128/mod.rs b/compiler/otests/integers/u128/mod.rs similarity index 100% rename from compiler/tests/integers/u128/mod.rs rename to compiler/otests/integers/u128/mod.rs diff --git a/compiler/tests/integers/u128/mul.leo b/compiler/otests/integers/u128/mul.leo similarity index 100% rename from compiler/tests/integers/u128/mul.leo rename to compiler/otests/integers/u128/mul.leo diff --git a/compiler/tests/integers/u128/ne.leo b/compiler/otests/integers/u128/ne.leo similarity index 100% rename from compiler/tests/integers/u128/ne.leo rename to compiler/otests/integers/u128/ne.leo diff --git a/compiler/tests/integers/u128/no_space_between_literal.leo b/compiler/otests/integers/u128/no_space_between_literal.leo similarity index 100% rename from compiler/tests/integers/u128/no_space_between_literal.leo rename to compiler/otests/integers/u128/no_space_between_literal.leo diff --git a/compiler/tests/integers/u128/pow.leo b/compiler/otests/integers/u128/pow.leo similarity index 100% rename from compiler/tests/integers/u128/pow.leo rename to compiler/otests/integers/u128/pow.leo diff --git a/compiler/tests/integers/u128/sub.leo b/compiler/otests/integers/u128/sub.leo similarity index 100% rename from compiler/tests/integers/u128/sub.leo rename to compiler/otests/integers/u128/sub.leo diff --git a/compiler/tests/integers/u128/ternary.leo b/compiler/otests/integers/u128/ternary.leo similarity index 100% rename from compiler/tests/integers/u128/ternary.leo rename to compiler/otests/integers/u128/ternary.leo diff --git a/compiler/tests/integers/u16/add.leo b/compiler/otests/integers/u16/add.leo similarity index 100% rename from compiler/tests/integers/u16/add.leo rename to compiler/otests/integers/u16/add.leo diff --git a/compiler/tests/integers/u16/console_assert.leo b/compiler/otests/integers/u16/console_assert.leo similarity index 100% rename from compiler/tests/integers/u16/console_assert.leo rename to compiler/otests/integers/u16/console_assert.leo diff --git a/compiler/tests/integers/u16/div.leo b/compiler/otests/integers/u16/div.leo similarity index 100% rename from compiler/tests/integers/u16/div.leo rename to compiler/otests/integers/u16/div.leo diff --git a/compiler/tests/integers/u16/eq.leo b/compiler/otests/integers/u16/eq.leo similarity index 100% rename from compiler/tests/integers/u16/eq.leo rename to compiler/otests/integers/u16/eq.leo diff --git a/compiler/tests/integers/u16/ge.leo b/compiler/otests/integers/u16/ge.leo similarity index 100% rename from compiler/tests/integers/u16/ge.leo rename to compiler/otests/integers/u16/ge.leo diff --git a/compiler/tests/integers/u16/gt.leo b/compiler/otests/integers/u16/gt.leo similarity index 100% rename from compiler/tests/integers/u16/gt.leo rename to compiler/otests/integers/u16/gt.leo diff --git a/compiler/tests/integers/u16/input.leo b/compiler/otests/integers/u16/input.leo similarity index 100% rename from compiler/tests/integers/u16/input.leo rename to compiler/otests/integers/u16/input.leo diff --git a/compiler/tests/integers/u16/le.leo b/compiler/otests/integers/u16/le.leo similarity index 100% rename from compiler/tests/integers/u16/le.leo rename to compiler/otests/integers/u16/le.leo diff --git a/compiler/tests/integers/u16/lt.leo b/compiler/otests/integers/u16/lt.leo similarity index 100% rename from compiler/tests/integers/u16/lt.leo rename to compiler/otests/integers/u16/lt.leo diff --git a/compiler/tests/integers/u16/max.leo b/compiler/otests/integers/u16/max.leo similarity index 100% rename from compiler/tests/integers/u16/max.leo rename to compiler/otests/integers/u16/max.leo diff --git a/compiler/tests/integers/u16/max_fail.leo b/compiler/otests/integers/u16/max_fail.leo similarity index 100% rename from compiler/tests/integers/u16/max_fail.leo rename to compiler/otests/integers/u16/max_fail.leo diff --git a/compiler/tests/integers/u16/min.leo b/compiler/otests/integers/u16/min.leo similarity index 100% rename from compiler/tests/integers/u16/min.leo rename to compiler/otests/integers/u16/min.leo diff --git a/compiler/tests/integers/u16/min_fail.leo b/compiler/otests/integers/u16/min_fail.leo similarity index 100% rename from compiler/tests/integers/u16/min_fail.leo rename to compiler/otests/integers/u16/min_fail.leo diff --git a/compiler/tests/integers/u16/mod.rs b/compiler/otests/integers/u16/mod.rs similarity index 100% rename from compiler/tests/integers/u16/mod.rs rename to compiler/otests/integers/u16/mod.rs diff --git a/compiler/tests/integers/u16/mul.leo b/compiler/otests/integers/u16/mul.leo similarity index 100% rename from compiler/tests/integers/u16/mul.leo rename to compiler/otests/integers/u16/mul.leo diff --git a/compiler/tests/integers/u16/ne.leo b/compiler/otests/integers/u16/ne.leo similarity index 100% rename from compiler/tests/integers/u16/ne.leo rename to compiler/otests/integers/u16/ne.leo diff --git a/compiler/tests/integers/u16/no_space_between_literal.leo b/compiler/otests/integers/u16/no_space_between_literal.leo similarity index 100% rename from compiler/tests/integers/u16/no_space_between_literal.leo rename to compiler/otests/integers/u16/no_space_between_literal.leo diff --git a/compiler/tests/integers/u16/pow.leo b/compiler/otests/integers/u16/pow.leo similarity index 100% rename from compiler/tests/integers/u16/pow.leo rename to compiler/otests/integers/u16/pow.leo diff --git a/compiler/tests/integers/u16/sub.leo b/compiler/otests/integers/u16/sub.leo similarity index 100% rename from compiler/tests/integers/u16/sub.leo rename to compiler/otests/integers/u16/sub.leo diff --git a/compiler/tests/integers/u16/ternary.leo b/compiler/otests/integers/u16/ternary.leo similarity index 100% rename from compiler/tests/integers/u16/ternary.leo rename to compiler/otests/integers/u16/ternary.leo diff --git a/compiler/tests/integers/u32/add.leo b/compiler/otests/integers/u32/add.leo similarity index 100% rename from compiler/tests/integers/u32/add.leo rename to compiler/otests/integers/u32/add.leo diff --git a/compiler/tests/integers/u32/console_assert.leo b/compiler/otests/integers/u32/console_assert.leo similarity index 100% rename from compiler/tests/integers/u32/console_assert.leo rename to compiler/otests/integers/u32/console_assert.leo diff --git a/compiler/tests/integers/u32/div.leo b/compiler/otests/integers/u32/div.leo similarity index 100% rename from compiler/tests/integers/u32/div.leo rename to compiler/otests/integers/u32/div.leo diff --git a/compiler/tests/integers/u32/eq.leo b/compiler/otests/integers/u32/eq.leo similarity index 100% rename from compiler/tests/integers/u32/eq.leo rename to compiler/otests/integers/u32/eq.leo diff --git a/compiler/tests/integers/u32/ge.leo b/compiler/otests/integers/u32/ge.leo similarity index 100% rename from compiler/tests/integers/u32/ge.leo rename to compiler/otests/integers/u32/ge.leo diff --git a/compiler/tests/integers/u32/gt.leo b/compiler/otests/integers/u32/gt.leo similarity index 100% rename from compiler/tests/integers/u32/gt.leo rename to compiler/otests/integers/u32/gt.leo diff --git a/compiler/tests/integers/u32/input.leo b/compiler/otests/integers/u32/input.leo similarity index 100% rename from compiler/tests/integers/u32/input.leo rename to compiler/otests/integers/u32/input.leo diff --git a/compiler/tests/integers/u32/le.leo b/compiler/otests/integers/u32/le.leo similarity index 100% rename from compiler/tests/integers/u32/le.leo rename to compiler/otests/integers/u32/le.leo diff --git a/compiler/tests/integers/u32/lt.leo b/compiler/otests/integers/u32/lt.leo similarity index 100% rename from compiler/tests/integers/u32/lt.leo rename to compiler/otests/integers/u32/lt.leo diff --git a/compiler/tests/integers/u32/max.leo b/compiler/otests/integers/u32/max.leo similarity index 100% rename from compiler/tests/integers/u32/max.leo rename to compiler/otests/integers/u32/max.leo diff --git a/compiler/tests/integers/u32/max_fail.leo b/compiler/otests/integers/u32/max_fail.leo similarity index 100% rename from compiler/tests/integers/u32/max_fail.leo rename to compiler/otests/integers/u32/max_fail.leo diff --git a/compiler/tests/integers/u32/min.leo b/compiler/otests/integers/u32/min.leo similarity index 100% rename from compiler/tests/integers/u32/min.leo rename to compiler/otests/integers/u32/min.leo diff --git a/compiler/tests/integers/u32/min_fail.leo b/compiler/otests/integers/u32/min_fail.leo similarity index 100% rename from compiler/tests/integers/u32/min_fail.leo rename to compiler/otests/integers/u32/min_fail.leo diff --git a/compiler/tests/integers/u32/mod.rs b/compiler/otests/integers/u32/mod.rs similarity index 100% rename from compiler/tests/integers/u32/mod.rs rename to compiler/otests/integers/u32/mod.rs diff --git a/compiler/tests/integers/u32/mul.leo b/compiler/otests/integers/u32/mul.leo similarity index 100% rename from compiler/tests/integers/u32/mul.leo rename to compiler/otests/integers/u32/mul.leo diff --git a/compiler/tests/integers/u32/ne.leo b/compiler/otests/integers/u32/ne.leo similarity index 100% rename from compiler/tests/integers/u32/ne.leo rename to compiler/otests/integers/u32/ne.leo diff --git a/compiler/tests/integers/u32/no_space_between_literal.leo b/compiler/otests/integers/u32/no_space_between_literal.leo similarity index 100% rename from compiler/tests/integers/u32/no_space_between_literal.leo rename to compiler/otests/integers/u32/no_space_between_literal.leo diff --git a/compiler/tests/integers/u32/pow.leo b/compiler/otests/integers/u32/pow.leo similarity index 100% rename from compiler/tests/integers/u32/pow.leo rename to compiler/otests/integers/u32/pow.leo diff --git a/compiler/tests/integers/u32/sub.leo b/compiler/otests/integers/u32/sub.leo similarity index 100% rename from compiler/tests/integers/u32/sub.leo rename to compiler/otests/integers/u32/sub.leo diff --git a/compiler/tests/integers/u32/ternary.leo b/compiler/otests/integers/u32/ternary.leo similarity index 100% rename from compiler/tests/integers/u32/ternary.leo rename to compiler/otests/integers/u32/ternary.leo diff --git a/compiler/tests/integers/u64/add.leo b/compiler/otests/integers/u64/add.leo similarity index 100% rename from compiler/tests/integers/u64/add.leo rename to compiler/otests/integers/u64/add.leo diff --git a/compiler/tests/integers/u64/console_assert.leo b/compiler/otests/integers/u64/console_assert.leo similarity index 100% rename from compiler/tests/integers/u64/console_assert.leo rename to compiler/otests/integers/u64/console_assert.leo diff --git a/compiler/tests/integers/u64/div.leo b/compiler/otests/integers/u64/div.leo similarity index 100% rename from compiler/tests/integers/u64/div.leo rename to compiler/otests/integers/u64/div.leo diff --git a/compiler/tests/integers/u64/eq.leo b/compiler/otests/integers/u64/eq.leo similarity index 100% rename from compiler/tests/integers/u64/eq.leo rename to compiler/otests/integers/u64/eq.leo diff --git a/compiler/tests/integers/u64/ge.leo b/compiler/otests/integers/u64/ge.leo similarity index 100% rename from compiler/tests/integers/u64/ge.leo rename to compiler/otests/integers/u64/ge.leo diff --git a/compiler/tests/integers/u64/gt.leo b/compiler/otests/integers/u64/gt.leo similarity index 100% rename from compiler/tests/integers/u64/gt.leo rename to compiler/otests/integers/u64/gt.leo diff --git a/compiler/tests/integers/u64/input.leo b/compiler/otests/integers/u64/input.leo similarity index 100% rename from compiler/tests/integers/u64/input.leo rename to compiler/otests/integers/u64/input.leo diff --git a/compiler/tests/integers/u64/le.leo b/compiler/otests/integers/u64/le.leo similarity index 100% rename from compiler/tests/integers/u64/le.leo rename to compiler/otests/integers/u64/le.leo diff --git a/compiler/tests/integers/u64/lt.leo b/compiler/otests/integers/u64/lt.leo similarity index 100% rename from compiler/tests/integers/u64/lt.leo rename to compiler/otests/integers/u64/lt.leo diff --git a/compiler/tests/integers/u64/max.leo b/compiler/otests/integers/u64/max.leo similarity index 100% rename from compiler/tests/integers/u64/max.leo rename to compiler/otests/integers/u64/max.leo diff --git a/compiler/tests/integers/u64/max_fail.leo b/compiler/otests/integers/u64/max_fail.leo similarity index 100% rename from compiler/tests/integers/u64/max_fail.leo rename to compiler/otests/integers/u64/max_fail.leo diff --git a/compiler/tests/integers/u64/min.leo b/compiler/otests/integers/u64/min.leo similarity index 100% rename from compiler/tests/integers/u64/min.leo rename to compiler/otests/integers/u64/min.leo diff --git a/compiler/tests/integers/u64/min_fail.leo b/compiler/otests/integers/u64/min_fail.leo similarity index 100% rename from compiler/tests/integers/u64/min_fail.leo rename to compiler/otests/integers/u64/min_fail.leo diff --git a/compiler/tests/integers/u64/mod.rs b/compiler/otests/integers/u64/mod.rs similarity index 100% rename from compiler/tests/integers/u64/mod.rs rename to compiler/otests/integers/u64/mod.rs diff --git a/compiler/tests/integers/u64/mul.leo b/compiler/otests/integers/u64/mul.leo similarity index 100% rename from compiler/tests/integers/u64/mul.leo rename to compiler/otests/integers/u64/mul.leo diff --git a/compiler/tests/integers/u64/ne.leo b/compiler/otests/integers/u64/ne.leo similarity index 100% rename from compiler/tests/integers/u64/ne.leo rename to compiler/otests/integers/u64/ne.leo diff --git a/compiler/tests/integers/u64/no_space_between_literal.leo b/compiler/otests/integers/u64/no_space_between_literal.leo similarity index 100% rename from compiler/tests/integers/u64/no_space_between_literal.leo rename to compiler/otests/integers/u64/no_space_between_literal.leo diff --git a/compiler/tests/integers/u64/pow.leo b/compiler/otests/integers/u64/pow.leo similarity index 100% rename from compiler/tests/integers/u64/pow.leo rename to compiler/otests/integers/u64/pow.leo diff --git a/compiler/tests/integers/u64/sub.leo b/compiler/otests/integers/u64/sub.leo similarity index 100% rename from compiler/tests/integers/u64/sub.leo rename to compiler/otests/integers/u64/sub.leo diff --git a/compiler/tests/integers/u64/ternary.leo b/compiler/otests/integers/u64/ternary.leo similarity index 100% rename from compiler/tests/integers/u64/ternary.leo rename to compiler/otests/integers/u64/ternary.leo diff --git a/compiler/tests/integers/u8/add.leo b/compiler/otests/integers/u8/add.leo similarity index 100% rename from compiler/tests/integers/u8/add.leo rename to compiler/otests/integers/u8/add.leo diff --git a/compiler/tests/integers/u8/console_assert.leo b/compiler/otests/integers/u8/console_assert.leo similarity index 100% rename from compiler/tests/integers/u8/console_assert.leo rename to compiler/otests/integers/u8/console_assert.leo diff --git a/compiler/tests/integers/u8/div.leo b/compiler/otests/integers/u8/div.leo similarity index 100% rename from compiler/tests/integers/u8/div.leo rename to compiler/otests/integers/u8/div.leo diff --git a/compiler/tests/integers/u8/eq.leo b/compiler/otests/integers/u8/eq.leo similarity index 100% rename from compiler/tests/integers/u8/eq.leo rename to compiler/otests/integers/u8/eq.leo diff --git a/compiler/tests/integers/u8/ge.leo b/compiler/otests/integers/u8/ge.leo similarity index 100% rename from compiler/tests/integers/u8/ge.leo rename to compiler/otests/integers/u8/ge.leo diff --git a/compiler/tests/integers/u8/gt.leo b/compiler/otests/integers/u8/gt.leo similarity index 100% rename from compiler/tests/integers/u8/gt.leo rename to compiler/otests/integers/u8/gt.leo diff --git a/compiler/tests/integers/u8/input.leo b/compiler/otests/integers/u8/input.leo similarity index 100% rename from compiler/tests/integers/u8/input.leo rename to compiler/otests/integers/u8/input.leo diff --git a/compiler/tests/integers/u8/le.leo b/compiler/otests/integers/u8/le.leo similarity index 100% rename from compiler/tests/integers/u8/le.leo rename to compiler/otests/integers/u8/le.leo diff --git a/compiler/tests/integers/u8/lt.leo b/compiler/otests/integers/u8/lt.leo similarity index 100% rename from compiler/tests/integers/u8/lt.leo rename to compiler/otests/integers/u8/lt.leo diff --git a/compiler/tests/integers/u8/max.leo b/compiler/otests/integers/u8/max.leo similarity index 100% rename from compiler/tests/integers/u8/max.leo rename to compiler/otests/integers/u8/max.leo diff --git a/compiler/tests/integers/u8/max_fail.leo b/compiler/otests/integers/u8/max_fail.leo similarity index 100% rename from compiler/tests/integers/u8/max_fail.leo rename to compiler/otests/integers/u8/max_fail.leo diff --git a/compiler/tests/integers/u8/min.leo b/compiler/otests/integers/u8/min.leo similarity index 100% rename from compiler/tests/integers/u8/min.leo rename to compiler/otests/integers/u8/min.leo diff --git a/compiler/tests/integers/u8/min_fail.leo b/compiler/otests/integers/u8/min_fail.leo similarity index 100% rename from compiler/tests/integers/u8/min_fail.leo rename to compiler/otests/integers/u8/min_fail.leo diff --git a/compiler/tests/integers/u8/mod.rs b/compiler/otests/integers/u8/mod.rs similarity index 100% rename from compiler/tests/integers/u8/mod.rs rename to compiler/otests/integers/u8/mod.rs diff --git a/compiler/tests/integers/u8/mul.leo b/compiler/otests/integers/u8/mul.leo similarity index 100% rename from compiler/tests/integers/u8/mul.leo rename to compiler/otests/integers/u8/mul.leo diff --git a/compiler/tests/integers/u8/ne.leo b/compiler/otests/integers/u8/ne.leo similarity index 100% rename from compiler/tests/integers/u8/ne.leo rename to compiler/otests/integers/u8/ne.leo diff --git a/compiler/tests/integers/u8/no_space_between_literal.leo b/compiler/otests/integers/u8/no_space_between_literal.leo similarity index 100% rename from compiler/tests/integers/u8/no_space_between_literal.leo rename to compiler/otests/integers/u8/no_space_between_literal.leo diff --git a/compiler/tests/integers/u8/pow.leo b/compiler/otests/integers/u8/pow.leo similarity index 100% rename from compiler/tests/integers/u8/pow.leo rename to compiler/otests/integers/u8/pow.leo diff --git a/compiler/tests/integers/u8/sub.leo b/compiler/otests/integers/u8/sub.leo similarity index 100% rename from compiler/tests/integers/u8/sub.leo rename to compiler/otests/integers/u8/sub.leo diff --git a/compiler/tests/integers/u8/ternary.leo b/compiler/otests/integers/u8/ternary.leo similarity index 100% rename from compiler/tests/integers/u8/ternary.leo rename to compiler/otests/integers/u8/ternary.leo diff --git a/compiler/tests/integers/uint_macro.rs b/compiler/otests/integers/uint_macro.rs similarity index 100% rename from compiler/tests/integers/uint_macro.rs rename to compiler/otests/integers/uint_macro.rs diff --git a/compiler/tests/mod.rs b/compiler/otests/mod.rs similarity index 100% rename from compiler/tests/mod.rs rename to compiler/otests/mod.rs diff --git a/compiler/tests/mutability/array.leo b/compiler/otests/mutability/array.leo similarity index 100% rename from compiler/tests/mutability/array.leo rename to compiler/otests/mutability/array.leo diff --git a/compiler/tests/mutability/array_mut.leo b/compiler/otests/mutability/array_mut.leo similarity index 100% rename from compiler/tests/mutability/array_mut.leo rename to compiler/otests/mutability/array_mut.leo diff --git a/compiler/tests/mutability/array_splice_mut.leo b/compiler/otests/mutability/array_splice_mut.leo similarity index 100% rename from compiler/tests/mutability/array_splice_mut.leo rename to compiler/otests/mutability/array_splice_mut.leo diff --git a/compiler/tests/mutability/array_tuple_mut.leo b/compiler/otests/mutability/array_tuple_mut.leo similarity index 100% rename from compiler/tests/mutability/array_tuple_mut.leo rename to compiler/otests/mutability/array_tuple_mut.leo diff --git a/compiler/tests/mutability/circuit.leo b/compiler/otests/mutability/circuit.leo similarity index 100% rename from compiler/tests/mutability/circuit.leo rename to compiler/otests/mutability/circuit.leo diff --git a/compiler/tests/mutability/circuit_function_mut.leo b/compiler/otests/mutability/circuit_function_mut.leo similarity index 100% rename from compiler/tests/mutability/circuit_function_mut.leo rename to compiler/otests/mutability/circuit_function_mut.leo diff --git a/compiler/tests/mutability/circuit_mut.leo b/compiler/otests/mutability/circuit_mut.leo similarity index 100% rename from compiler/tests/mutability/circuit_mut.leo rename to compiler/otests/mutability/circuit_mut.leo diff --git a/compiler/tests/mutability/circuit_static_function_mut.leo b/compiler/otests/mutability/circuit_static_function_mut.leo similarity index 100% rename from compiler/tests/mutability/circuit_static_function_mut.leo rename to compiler/otests/mutability/circuit_static_function_mut.leo diff --git a/compiler/tests/mutability/circuit_variable_mut.leo b/compiler/otests/mutability/circuit_variable_mut.leo similarity index 100% rename from compiler/tests/mutability/circuit_variable_mut.leo rename to compiler/otests/mutability/circuit_variable_mut.leo diff --git a/compiler/tests/mutability/cond_mut.leo b/compiler/otests/mutability/cond_mut.leo similarity index 100% rename from compiler/tests/mutability/cond_mut.leo rename to compiler/otests/mutability/cond_mut.leo diff --git a/compiler/tests/mutability/const.leo b/compiler/otests/mutability/const.leo similarity index 100% rename from compiler/tests/mutability/const.leo rename to compiler/otests/mutability/const.leo diff --git a/compiler/tests/mutability/function_input.leo b/compiler/otests/mutability/function_input.leo similarity index 100% rename from compiler/tests/mutability/function_input.leo rename to compiler/otests/mutability/function_input.leo diff --git a/compiler/tests/mutability/function_input_mut.leo b/compiler/otests/mutability/function_input_mut.leo similarity index 100% rename from compiler/tests/mutability/function_input_mut.leo rename to compiler/otests/mutability/function_input_mut.leo diff --git a/compiler/tests/mutability/let.leo b/compiler/otests/mutability/let.leo similarity index 100% rename from compiler/tests/mutability/let.leo rename to compiler/otests/mutability/let.leo diff --git a/compiler/tests/mutability/let_mut.leo b/compiler/otests/mutability/let_mut.leo similarity index 100% rename from compiler/tests/mutability/let_mut.leo rename to compiler/otests/mutability/let_mut.leo diff --git a/compiler/tests/mutability/let_mut_nested.leo b/compiler/otests/mutability/let_mut_nested.leo similarity index 100% rename from compiler/tests/mutability/let_mut_nested.leo rename to compiler/otests/mutability/let_mut_nested.leo diff --git a/compiler/tests/mutability/mod.rs b/compiler/otests/mutability/mod.rs similarity index 100% rename from compiler/tests/mutability/mod.rs rename to compiler/otests/mutability/mod.rs diff --git a/compiler/tests/mutability/swap.leo b/compiler/otests/mutability/swap.leo similarity index 100% rename from compiler/tests/mutability/swap.leo rename to compiler/otests/mutability/swap.leo diff --git a/compiler/tests/statements/block.leo b/compiler/otests/statements/block.leo similarity index 100% rename from compiler/tests/statements/block.leo rename to compiler/otests/statements/block.leo diff --git a/compiler/tests/statements/conditional/assert.leo b/compiler/otests/statements/conditional/assert.leo similarity index 100% rename from compiler/tests/statements/conditional/assert.leo rename to compiler/otests/statements/conditional/assert.leo diff --git a/compiler/tests/statements/conditional/chain.leo b/compiler/otests/statements/conditional/chain.leo similarity index 100% rename from compiler/tests/statements/conditional/chain.leo rename to compiler/otests/statements/conditional/chain.leo diff --git a/compiler/tests/statements/conditional/cond_switch.leo b/compiler/otests/statements/conditional/cond_switch.leo similarity index 100% rename from compiler/tests/statements/conditional/cond_switch.leo rename to compiler/otests/statements/conditional/cond_switch.leo diff --git a/compiler/tests/statements/conditional/for_loop.leo b/compiler/otests/statements/conditional/for_loop.leo similarity index 100% rename from compiler/tests/statements/conditional/for_loop.leo rename to compiler/otests/statements/conditional/for_loop.leo diff --git a/compiler/tests/statements/conditional/input/cond_switch.in b/compiler/otests/statements/conditional/input/cond_switch.in similarity index 100% rename from compiler/tests/statements/conditional/input/cond_switch.in rename to compiler/otests/statements/conditional/input/cond_switch.in diff --git a/compiler/tests/statements/conditional/input/registers_one.in b/compiler/otests/statements/conditional/input/registers_one.in similarity index 100% rename from compiler/tests/statements/conditional/input/registers_one.in rename to compiler/otests/statements/conditional/input/registers_one.in diff --git a/compiler/tests/statements/conditional/input/registers_zero.in b/compiler/otests/statements/conditional/input/registers_zero.in similarity index 100% rename from compiler/tests/statements/conditional/input/registers_zero.in rename to compiler/otests/statements/conditional/input/registers_zero.in diff --git a/compiler/tests/statements/conditional/mod.rs b/compiler/otests/statements/conditional/mod.rs similarity index 100% rename from compiler/tests/statements/conditional/mod.rs rename to compiler/otests/statements/conditional/mod.rs diff --git a/compiler/tests/statements/conditional/multiple_returns.leo b/compiler/otests/statements/conditional/multiple_returns.leo similarity index 100% rename from compiler/tests/statements/conditional/multiple_returns.leo rename to compiler/otests/statements/conditional/multiple_returns.leo diff --git a/compiler/tests/statements/conditional/mutate.leo b/compiler/otests/statements/conditional/mutate.leo similarity index 100% rename from compiler/tests/statements/conditional/mutate.leo rename to compiler/otests/statements/conditional/mutate.leo diff --git a/compiler/tests/statements/conditional/nested.leo b/compiler/otests/statements/conditional/nested.leo similarity index 100% rename from compiler/tests/statements/conditional/nested.leo rename to compiler/otests/statements/conditional/nested.leo diff --git a/compiler/tests/statements/conditional/output/cond_switch.out b/compiler/otests/statements/conditional/output/cond_switch.out similarity index 100% rename from compiler/tests/statements/conditional/output/cond_switch.out rename to compiler/otests/statements/conditional/output/cond_switch.out diff --git a/compiler/tests/statements/conditional/output/registers_one.out b/compiler/otests/statements/conditional/output/registers_one.out similarity index 100% rename from compiler/tests/statements/conditional/output/registers_one.out rename to compiler/otests/statements/conditional/output/registers_one.out diff --git a/compiler/tests/statements/conditional/output/registers_zero.out b/compiler/otests/statements/conditional/output/registers_zero.out similarity index 100% rename from compiler/tests/statements/conditional/output/registers_zero.out rename to compiler/otests/statements/conditional/output/registers_zero.out diff --git a/compiler/tests/statements/iteration_basic.leo b/compiler/otests/statements/iteration_basic.leo similarity index 100% rename from compiler/tests/statements/iteration_basic.leo rename to compiler/otests/statements/iteration_basic.leo diff --git a/compiler/tests/statements/iteration_input.in b/compiler/otests/statements/iteration_input.in similarity index 100% rename from compiler/tests/statements/iteration_input.in rename to compiler/otests/statements/iteration_input.in diff --git a/compiler/tests/statements/iteration_input.leo b/compiler/otests/statements/iteration_input.leo similarity index 100% rename from compiler/tests/statements/iteration_input.leo rename to compiler/otests/statements/iteration_input.leo diff --git a/compiler/tests/statements/iteration_type_fail.leo b/compiler/otests/statements/iteration_type_fail.leo similarity index 100% rename from compiler/tests/statements/iteration_type_fail.leo rename to compiler/otests/statements/iteration_type_fail.leo diff --git a/compiler/tests/statements/iteration_variable.leo b/compiler/otests/statements/iteration_variable.leo similarity index 100% rename from compiler/tests/statements/iteration_variable.leo rename to compiler/otests/statements/iteration_variable.leo diff --git a/compiler/tests/statements/mod.rs b/compiler/otests/statements/mod.rs similarity index 100% rename from compiler/tests/statements/mod.rs rename to compiler/otests/statements/mod.rs diff --git a/compiler/tests/statements/num_returns_fail.leo b/compiler/otests/statements/num_returns_fail.leo similarity index 100% rename from compiler/tests/statements/num_returns_fail.leo rename to compiler/otests/statements/num_returns_fail.leo diff --git a/compiler/tests/statements/ternary_basic.leo b/compiler/otests/statements/ternary_basic.leo similarity index 100% rename from compiler/tests/statements/ternary_basic.leo rename to compiler/otests/statements/ternary_basic.leo diff --git a/compiler/tests/syntax/compare_mismatched_types.leo b/compiler/otests/syntax/compare_mismatched_types.leo similarity index 100% rename from compiler/tests/syntax/compare_mismatched_types.leo rename to compiler/otests/syntax/compare_mismatched_types.leo diff --git a/compiler/tests/syntax/identifiers/address_fail.leo b/compiler/otests/syntax/identifiers/address_fail.leo similarity index 100% rename from compiler/tests/syntax/identifiers/address_fail.leo rename to compiler/otests/syntax/identifiers/address_fail.leo diff --git a/compiler/tests/syntax/identifiers/console_fail.leo b/compiler/otests/syntax/identifiers/console_fail.leo similarity index 100% rename from compiler/tests/syntax/identifiers/console_fail.leo rename to compiler/otests/syntax/identifiers/console_fail.leo diff --git a/compiler/tests/syntax/identifiers/field_fail.leo b/compiler/otests/syntax/identifiers/field_fail.leo similarity index 100% rename from compiler/tests/syntax/identifiers/field_fail.leo rename to compiler/otests/syntax/identifiers/field_fail.leo diff --git a/compiler/tests/syntax/identifiers/group_fail.leo b/compiler/otests/syntax/identifiers/group_fail.leo similarity index 100% rename from compiler/tests/syntax/identifiers/group_fail.leo rename to compiler/otests/syntax/identifiers/group_fail.leo diff --git a/compiler/tests/syntax/identifiers/i8_fail.leo b/compiler/otests/syntax/identifiers/i8_fail.leo similarity index 100% rename from compiler/tests/syntax/identifiers/i8_fail.leo rename to compiler/otests/syntax/identifiers/i8_fail.leo diff --git a/compiler/tests/syntax/identifiers/input_fail.leo b/compiler/otests/syntax/identifiers/input_fail.leo similarity index 100% rename from compiler/tests/syntax/identifiers/input_fail.leo rename to compiler/otests/syntax/identifiers/input_fail.leo diff --git a/compiler/tests/syntax/identifiers/mod.rs b/compiler/otests/syntax/identifiers/mod.rs similarity index 100% rename from compiler/tests/syntax/identifiers/mod.rs rename to compiler/otests/syntax/identifiers/mod.rs diff --git a/compiler/tests/syntax/identifiers/self_keyword_fail.leo b/compiler/otests/syntax/identifiers/self_keyword_fail.leo similarity index 100% rename from compiler/tests/syntax/identifiers/self_keyword_fail.leo rename to compiler/otests/syntax/identifiers/self_keyword_fail.leo diff --git a/compiler/tests/syntax/identifiers/self_type_fail.leo b/compiler/otests/syntax/identifiers/self_type_fail.leo similarity index 100% rename from compiler/tests/syntax/identifiers/self_type_fail.leo rename to compiler/otests/syntax/identifiers/self_type_fail.leo diff --git a/compiler/tests/syntax/identifiers/true_fail.leo b/compiler/otests/syntax/identifiers/true_fail.leo similarity index 100% rename from compiler/tests/syntax/identifiers/true_fail.leo rename to compiler/otests/syntax/identifiers/true_fail.leo diff --git a/compiler/tests/syntax/identifiers/u8_fail.leo b/compiler/otests/syntax/identifiers/u8_fail.leo similarity index 100% rename from compiler/tests/syntax/identifiers/u8_fail.leo rename to compiler/otests/syntax/identifiers/u8_fail.leo diff --git a/compiler/tests/syntax/input_semicolon.leo b/compiler/otests/syntax/input_semicolon.leo similarity index 100% rename from compiler/tests/syntax/input_semicolon.leo rename to compiler/otests/syntax/input_semicolon.leo diff --git a/compiler/tests/syntax/mod.rs b/compiler/otests/syntax/mod.rs similarity index 100% rename from compiler/tests/syntax/mod.rs rename to compiler/otests/syntax/mod.rs diff --git a/compiler/tests/syntax/semicolon.leo b/compiler/otests/syntax/semicolon.leo similarity index 100% rename from compiler/tests/syntax/semicolon.leo rename to compiler/otests/syntax/semicolon.leo diff --git a/compiler/tests/syntax/undefined.leo b/compiler/otests/syntax/undefined.leo similarity index 100% rename from compiler/tests/syntax/undefined.leo rename to compiler/otests/syntax/undefined.leo diff --git a/compiler/tests/tuples/access.leo b/compiler/otests/tuples/access.leo similarity index 100% rename from compiler/tests/tuples/access.leo rename to compiler/otests/tuples/access.leo diff --git a/compiler/tests/tuples/basic.leo b/compiler/otests/tuples/basic.leo similarity index 100% rename from compiler/tests/tuples/basic.leo rename to compiler/otests/tuples/basic.leo diff --git a/compiler/tests/tuples/function.leo b/compiler/otests/tuples/function.leo similarity index 100% rename from compiler/tests/tuples/function.leo rename to compiler/otests/tuples/function.leo diff --git a/compiler/tests/tuples/function_multiple.leo b/compiler/otests/tuples/function_multiple.leo similarity index 100% rename from compiler/tests/tuples/function_multiple.leo rename to compiler/otests/tuples/function_multiple.leo diff --git a/compiler/tests/tuples/function_typed.leo b/compiler/otests/tuples/function_typed.leo similarity index 100% rename from compiler/tests/tuples/function_typed.leo rename to compiler/otests/tuples/function_typed.leo diff --git a/compiler/tests/tuples/input.leo b/compiler/otests/tuples/input.leo similarity index 100% rename from compiler/tests/tuples/input.leo rename to compiler/otests/tuples/input.leo diff --git a/compiler/tests/tuples/inputs/input.in b/compiler/otests/tuples/inputs/input.in similarity index 100% rename from compiler/tests/tuples/inputs/input.in rename to compiler/otests/tuples/inputs/input.in diff --git a/compiler/tests/tuples/mod.rs b/compiler/otests/tuples/mod.rs similarity index 100% rename from compiler/tests/tuples/mod.rs rename to compiler/otests/tuples/mod.rs diff --git a/compiler/tests/tuples/multiple.leo b/compiler/otests/tuples/multiple.leo similarity index 100% rename from compiler/tests/tuples/multiple.leo rename to compiler/otests/tuples/multiple.leo diff --git a/compiler/tests/tuples/multiple_typed.leo b/compiler/otests/tuples/multiple_typed.leo similarity index 100% rename from compiler/tests/tuples/multiple_typed.leo rename to compiler/otests/tuples/multiple_typed.leo diff --git a/compiler/tests/tuples/nested.leo b/compiler/otests/tuples/nested.leo similarity index 100% rename from compiler/tests/tuples/nested.leo rename to compiler/otests/tuples/nested.leo diff --git a/compiler/tests/tuples/nested_access.leo b/compiler/otests/tuples/nested_access.leo similarity index 100% rename from compiler/tests/tuples/nested_access.leo rename to compiler/otests/tuples/nested_access.leo diff --git a/compiler/tests/tuples/nested_typed.leo b/compiler/otests/tuples/nested_typed.leo similarity index 100% rename from compiler/tests/tuples/nested_typed.leo rename to compiler/otests/tuples/nested_typed.leo diff --git a/compiler/tests/tuples/typed.leo b/compiler/otests/tuples/typed.leo similarity index 100% rename from compiler/tests/tuples/typed.leo rename to compiler/otests/tuples/typed.leo diff --git a/compiler/src/compiler.rs b/compiler/src/compiler.rs index 0b19ea3b77..fe86c87749 100644 --- a/compiler/src/compiler.rs +++ b/compiler/src/compiler.rs @@ -16,14 +16,7 @@ //! Compiles a Leo program from a file path. -use crate::{ - constraints::{generate_constraints, generate_test_constraints}, - errors::CompilerError, - CompilerOptions, - GroupType, - OutputBytes, - OutputFile, -}; +use crate::{CompilerOptions, GroupType, Output, OutputFile, constraints::{generate_constraints, generate_test_constraints}, errors::CompilerError}; pub use leo_asg::{new_context, AsgContext as Context, AsgContext}; use leo_asg::{Asg, AsgPass, FormattedError, Program as AsgProgram}; use leo_ast::{Input, MainInput, Program as AstProgram}; @@ -264,7 +257,7 @@ impl<'a, F: PrimeField, G: GroupType> Compiler<'a, F, G> { /// /// Synthesizes the circuit with program input to verify correctness. /// - pub fn compile_constraints>(&self, cs: &mut CS) -> Result { + pub fn compile_constraints>(&self, cs: &mut CS) -> Result { generate_constraints::(cs, &self.asg.as_ref().unwrap(), &self.program_input) } @@ -329,7 +322,7 @@ impl<'a, F: PrimeField, G: GroupType> ConstraintSynthesizer for Compiler<' // Write results to file let output_file = OutputFile::new(&package_name); - output_file.write(&output_directory, result.bytes()).unwrap(); + output_file.write(&output_directory, result.to_string().as_bytes()).unwrap(); Ok(()) } diff --git a/compiler/src/constraints/constraints.rs b/compiler/src/constraints/constraints.rs index 5931d7a080..ba6c84ba75 100644 --- a/compiler/src/constraints/constraints.rs +++ b/compiler/src/constraints/constraints.rs @@ -16,7 +16,7 @@ //! Generates R1CS constraints for a compiled Leo program. -use crate::{errors::CompilerError, ConstrainedProgram, GroupType, OutputBytes, OutputFile}; +use crate::{errors::CompilerError, ConstrainedProgram, GroupType, Output, OutputFile}; use leo_asg::Program; use leo_ast::Input; use leo_input::LeoInputParser; @@ -30,7 +30,7 @@ pub fn generate_constraints<'a, F: PrimeField, G: GroupType, CS: ConstraintSy cs: &mut CS, program: &Program<'a>, input: &Input, -) -> Result { +) -> Result { let mut resolved_program = ConstrainedProgram::::new(program.clone()); let main = { @@ -121,7 +121,7 @@ pub fn generate_test_constraints<'a, F: PrimeField, G: GroupType>( let output = result?; let output_file = OutputFile::new(&output_file_name); - output_file.write(output_directory, output.bytes()).unwrap(); + output_file.write(output_directory, output.to_string().as_bytes()).unwrap(); // increment passed tests passed += 1; diff --git a/compiler/src/function/main_function.rs b/compiler/src/function/main_function.rs index 3a2eb27e13..942cfc62c6 100644 --- a/compiler/src/function/main_function.rs +++ b/compiler/src/function/main_function.rs @@ -16,7 +16,7 @@ //! Enforces constraints on the main function of a compiled Leo program. -use crate::{errors::FunctionError, program::ConstrainedProgram, GroupType, OutputBytes}; +use crate::{errors::FunctionError, program::ConstrainedProgram, GroupType, Output}; use leo_asg::{Expression, Function, FunctionQualifier}; use leo_ast::Input; @@ -31,7 +31,7 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { cs: &mut CS, function: &'a Function<'a>, input: &Input, - ) -> Result { + ) -> Result { let registers = input.get_registers(); // Iterate over main function input variables and allocate new values @@ -123,8 +123,8 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { let span = function.span.clone().unwrap_or_default(); let result_value = self.enforce_function(cs, function, None, &arguments)?; - let output_bytes = OutputBytes::new_from_constrained_value(&self.asg, registers, result_value, &span)?; + let output = Output::new(&self.asg, registers, result_value, &span)?; - Ok(output_bytes) + Ok(output) } } diff --git a/compiler/src/lib.rs b/compiler/src/lib.rs index 6b36c3d356..2c64bb668a 100644 --- a/compiler/src/lib.rs +++ b/compiler/src/lib.rs @@ -62,3 +62,6 @@ pub use stage::*; pub mod option; pub use option::*; + +#[cfg(test)] +mod test; \ No newline at end of file diff --git a/compiler/src/output/mod.rs b/compiler/src/output/mod.rs index a5c2e0951b..a952c78b9c 100644 --- a/compiler/src/output/mod.rs +++ b/compiler/src/output/mod.rs @@ -15,7 +15,103 @@ // along with the Leo library. If not, see . pub mod output_file; +use std::{collections::BTreeMap, fmt}; + pub use self::output_file::*; pub mod output_bytes; pub use self::output_bytes::*; + +use crate::{errors::OutputBytesError, ConstrainedValue, GroupType, REGISTERS_VARIABLE_NAME}; +use leo_asg::Program; +use leo_ast::{Parameter, Registers, Span}; + +use snarkvm_fields::PrimeField; + +use serde::{Deserialize, Serialize}; + +#[derive(Deserialize, Serialize, Debug)] +pub struct OutputRegister { + #[serde(rename = "type")] + pub type_: String, + pub value: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct Output { + pub registers: BTreeMap, +} + +impl fmt::Display for Output { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "[{}]\n", REGISTERS_VARIABLE_NAME)?; + // format: "token_id: u64 = 1u64;" + for (name, register) in self.registers.iter() { + write!(f, "{}: {} = {};\n", name, register.type_, register.value)?; + } + Ok(()) + } +} + +impl Into for Output { + fn into(self) -> OutputBytes { + OutputBytes::from(self.to_string().into_bytes()) + } +} + +impl Output { + pub fn new<'a, F: PrimeField, G: GroupType>( + program: &Program<'a>, + registers: &Registers, + value: ConstrainedValue<'a, F, G>, + span: &Span, + ) -> Result { + let return_values = match value { + ConstrainedValue::Tuple(values) => values, + value => vec![value], + }; + let register_hashmap = registers.values(); + + // Create vector of parameter values in alphabetical order + let mut register_values = register_hashmap + .into_iter() + .map(|register| register.0) + .collect::>(); + + register_values.sort_by(|a, b| a.variable.name.cmp(&b.variable.name)); + + // Return an error if we do not have enough return registers + if register_values.len() < return_values.len() { + return Err(OutputBytesError::not_enough_registers(span)); + } + + let mut registers = BTreeMap::new(); + + for (parameter, value) in register_values.into_iter().zip(return_values.into_iter()) { + let name = parameter.variable.name; + + // Check register type == return value type. + let register_type = program.scope.resolve_ast_type(¶meter.type_)?; + let return_value_type = value.to_type(span)?; + + if !register_type.is_assignable_from(&return_value_type) { + return Err(OutputBytesError::mismatched_output_types( + ®ister_type, + &return_value_type, + span, + )); + } + + let value = value.to_string(); + + registers.insert(name.to_string(), OutputRegister { + type_: register_type.to_string(), + value, + }); + } + + Ok(Output { + registers, + }) + } +} \ No newline at end of file diff --git a/compiler/src/test.rs b/compiler/src/test.rs new file mode 100644 index 0000000000..7a8ae4907c --- /dev/null +++ b/compiler/src/test.rs @@ -0,0 +1,151 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use std::{path::{Path, PathBuf}}; + +use leo_asg::*; +use leo_synthesizer::{CircuitSynthesizer, SerializedCircuit, SummarizedCircuit}; +use leo_test_framework::{Test, runner::{Namespace, ParseType, Runner}}; +use serde_yaml::Value; +use snarkvm_curves::{bls12_377::Bls12_377, edwards_bls12::Fq}; + +use crate::{ConstrainedValue, Output, compiler::Compiler, errors::CompilerError, targets::edwards_bls12::EdwardsGroupType}; + +pub type EdwardsTestCompiler = Compiler<'static, Fq, EdwardsGroupType>; +pub type EdwardsConstrainedValue = ConstrainedValue<'static, Fq, EdwardsGroupType>; + +//convenience function for tests, leaks memory +pub(crate) fn make_test_context() -> AsgContext<'static> { + let allocator = Box::leak(Box::new(new_alloc_context())); + new_context(allocator) +} + +fn new_compiler() -> EdwardsTestCompiler { + let program_name = "test".to_string(); + let path = PathBuf::from("/test/src/main.leo"); + let output_dir = PathBuf::from("/output/"); + + EdwardsTestCompiler::new(program_name, path, output_dir, make_test_context()) +} + +pub(crate) fn parse_program(program_string: &str) -> Result { + let mut compiler = new_compiler(); + + compiler.parse_program_from_string(program_string)?; + + Ok(compiler) +} + +struct CompileNamespace; + +#[derive(serde::Deserialize, serde::Serialize)] +struct OutputItem { + pub input_file: String, + pub output: Output, +} + +#[derive(serde::Deserialize, serde::Serialize)] +struct CompileOutput { + pub circuit: SummarizedCircuit, + pub output: Vec, +} + +impl Namespace for CompileNamespace { + fn parse_type(&self) -> ParseType { + ParseType::Whole + } + + fn run_test(&self, test: Test) -> Result { + let parsed = parse_program(&test.content).map_err(|x| x.to_string())?; + + // (name, content) + let mut inputs = vec![]; + + if let Some(input) = test.config.get("input_file") { + let input_file: PathBuf = test.path.parent().expect("no test parent dir").into(); + if let Some(name) = input.as_str() { + let mut input_file = input_file; + input_file.push(input.as_str().expect("input_file was not a string or array")); + inputs.push((name.to_string(), std::fs::read_to_string(&input_file).expect("failed to read test input file"))); + } else if let Some(seq) = input.as_sequence() { + for name in seq { + let mut input_file = input_file.clone(); + input_file.push(name.as_str().expect("input_file was not a string")); + inputs.push((name.as_str().expect("input_file item was not a string").to_string(), std::fs::read_to_string(&input_file).expect("failed to read test input file"))); + } + } + } + if inputs.is_empty() { + inputs.push(("empty".to_string(), "".to_string())); + } + + let state = if let Some(input) = test.config.get("state_file") { + let mut input_file: PathBuf = test.path.parent().expect("no test parent dir").into(); + input_file.push(input.as_str().expect("state_file was not a string")); + std::fs::read_to_string(&input_file).expect("failed to read test state file") + } else { + "".to_string() + }; + + let mut output_items = vec![]; + + let mut last_circuit = None; + for input in inputs { + let mut parsed = parsed.clone(); + parsed.parse_input(&input.1, Path::new("input"), &state, Path::new("state")).map_err(|x| x.to_string())?; + let mut cs: CircuitSynthesizer = Default::default(); + let output = parsed.compile_constraints(&mut cs).map_err(|x| x.to_string())?; + let circuit: SummarizedCircuit = SerializedCircuit::from(cs).into(); + if let Some(last_circuit) = last_circuit.as_ref() { + if last_circuit != &circuit { + eprintln!("{}\n{}", serde_yaml::to_string(last_circuit).unwrap(), serde_yaml::to_string(&circuit).unwrap()); + return Err("circuit changed on different input files".to_string()); + } + } else { + last_circuit = Some(circuit); + } + output_items.push(OutputItem { + input_file: input.0, + output, + }); + } + + + + + let final_output = CompileOutput { + circuit: last_circuit.unwrap(), + output: output_items, + }; + Ok(serde_yaml::to_value(&final_output).expect("serialization failed")) + } +} + +struct TestRunner; + +impl Runner for TestRunner { + fn resolve_namespace(&self, name: &str) -> Option> { + Some(match name { + "Compile" => Box::new(CompileNamespace), + _ => return None, + }) + } +} + +#[test] +pub fn compiler_tests() { + leo_test_framework::run_tests(&TestRunner, "compiler"); +} diff --git a/parser/src/test.rs b/parser/src/test.rs index b6dbf7ae49..cd1fad285d 100644 --- a/parser/src/test.rs +++ b/parser/src/test.rs @@ -15,7 +15,7 @@ // along with the Leo library. If not, see . use leo_ast::{Expression, ExpressionStatement, Span, Statement, ValueExpression}; -use leo_test_framework::runner::{Namespace, ParseType, Runner}; +use leo_test_framework::{Test, runner::{Namespace, ParseType, Runner}}; use serde_yaml::Value; use tokenizer::Token; @@ -28,8 +28,8 @@ impl Namespace for TokenNamespace { ParseType::Line } - fn run_test(&self, test: &str) -> Result { - let output = tokenizer::tokenize("test", test.into()); + fn run_test(&self, test: Test) -> Result { + let output = tokenizer::tokenize("test", test.content.into()); output .map(|tokens| { Value::String( @@ -63,8 +63,8 @@ impl Namespace for ParseExpressionNamespace { ParseType::Line } - fn run_test(&self, test: &str) -> Result { - let tokenizer = tokenizer::tokenize("test", test.into()).map_err(|x| x.to_string())?; + fn run_test(&self, test: Test) -> Result { + let tokenizer = tokenizer::tokenize("test", test.content.into()).map_err(|x| x.to_string())?; if tokenizer .iter() .all(|x| matches!(x.token, Token::CommentLine(_) | Token::CommentBlock(_))) @@ -91,8 +91,8 @@ impl Namespace for ParseStatementNamespace { ParseType::ContinuousLines } - fn run_test(&self, test: &str) -> Result { - let tokenizer = tokenizer::tokenize("test", test.into()).map_err(|x| x.to_string())?; + fn run_test(&self, test: Test) -> Result { + let tokenizer = tokenizer::tokenize("test", test.content.into()).map_err(|x| x.to_string())?; if tokenizer .iter() .all(|x| matches!(x.token, Token::CommentLine(_) | Token::CommentBlock(_))) @@ -119,8 +119,8 @@ impl Namespace for ParseNamespace { ParseType::Whole } - fn run_test(&self, test: &str) -> Result { - let tokenizer = tokenizer::tokenize("test", test.into()).map_err(|x| x.to_string())?; + fn run_test(&self, test: Test) -> Result { + let tokenizer = tokenizer::tokenize("test", test.content.into()).map_err(|x| x.to_string())?; let mut tokens = ParserContext::new(tokenizer); let parsed = tokens.parse_program().map_err(|x| x.to_string())?; diff --git a/synthesizer/Cargo.toml b/synthesizer/Cargo.toml index 8a0f57fece..b78dbf1860 100644 --- a/synthesizer/Cargo.toml +++ b/synthesizer/Cargo.toml @@ -41,3 +41,9 @@ features = [ "derive" ] [dependencies.serde_json] version = "1.0" + +[dependencies.sha2] +version = "0.9" + +[dependencies.hex] +version = "0.4" diff --git a/synthesizer/src/circuit_synthesizer.rs b/synthesizer/src/circuit_synthesizer.rs index ed9361ca7d..2433869d30 100644 --- a/synthesizer/src/circuit_synthesizer.rs +++ b/synthesizer/src/circuit_synthesizer.rs @@ -20,9 +20,9 @@ use snarkvm_r1cs::{ConstraintSystem, Index, LinearCombination, OptionalVec, Synt #[derive(Default)] pub struct Namespace { - constraint_indices: Vec, - public_var_indices: Vec, - private_var_indices: Vec, + pub constraint_indices: Vec, + pub public_var_indices: Vec, + pub private_var_indices: Vec, } pub struct ConstraintSet { @@ -53,6 +53,17 @@ pub struct CircuitSynthesizer { pub namespaces: Vec, } +impl Default for CircuitSynthesizer { + fn default() -> Self { + Self { + constraints: Default::default(), + public_variables: Default::default(), + private_variables: Default::default(), + namespaces: Default::default(), + } + } +} + impl ConstraintSystem for CircuitSynthesizer { type Root = Self; diff --git a/synthesizer/src/lib.rs b/synthesizer/src/lib.rs index a220def1fe..80dbc44a44 100644 --- a/synthesizer/src/lib.rs +++ b/synthesizer/src/lib.rs @@ -20,6 +20,9 @@ pub use self::circuit_synthesizer::*; pub mod serialized_circuit; pub use self::serialized_circuit::*; +pub mod summarized_circuit; +pub use self::summarized_circuit::*; + pub mod serialized_field; pub use self::serialized_field::*; diff --git a/synthesizer/src/summarized_circuit.rs b/synthesizer/src/summarized_circuit.rs new file mode 100644 index 0000000000..77ee96b87d --- /dev/null +++ b/synthesizer/src/summarized_circuit.rs @@ -0,0 +1,45 @@ +use serde::{Deserialize, Serialize}; +use sha2::{Digest, Sha256}; + +use crate::SerializedCircuit; + +#[derive(Serialize, Deserialize, PartialEq)] +pub struct SummarizedCircuit { + pub num_public_variables: usize, + pub num_private_variables: usize, + pub num_constraints: usize, + + // pub public_variables: String, + // pub private_variables: String, + + pub at: String, + pub bt: String, + pub ct: String, +} + +fn hash_field(input: &str) -> String { + let mut hasher = Sha256::new(); + hasher.update(input.as_bytes()); + let output = hasher.finalize(); + hex::encode(&output[..]) +} + +impl From for SummarizedCircuit { + fn from(other: SerializedCircuit) -> Self { + Self { + num_public_variables: other.num_public_variables, + num_private_variables: other.num_private_variables, + num_constraints: other.num_constraints, + // public_variables: hash_field(&serde_json::to_string(&other.public_variables) + // .expect("failed to serialize public_variables")), + // private_variables: hash_field(&serde_json::to_string(&other.private_variables) + // .expect("failed to serialize private_variables")), + at: hash_field(&serde_json::to_string(&other.at) + .expect("failed to serialize at")), + bt: hash_field(&serde_json::to_string(&other.bt) + .expect("failed to serialize bt")), + ct: hash_field(&serde_json::to_string(&other.ct) + .expect("failed to serialize ct")), + } + } +} \ No newline at end of file diff --git a/test-framework/src/error.rs b/test-framework/src/error.rs index c49ebe75f1..fbf8f8dadd 100644 --- a/test-framework/src/error.rs +++ b/test-framework/src/error.rs @@ -45,6 +45,7 @@ pub enum TestError { output: String, }, MismatchedTestExpectationLength, + MissingTestConfig, } impl fmt::Display for TestError { @@ -75,6 +76,7 @@ impl fmt::Display for TestError { write!(f, "test #{} expected error\n{}\ngot\n{}", index + 1, expected, output) } TestError::MismatchedTestExpectationLength => write!(f, "invalid number of test expectations"), + TestError::MissingTestConfig => write!(f, "missing test config"), } } } diff --git a/test-framework/src/runner.rs b/test-framework/src/runner.rs index 0a473e73b5..94990c1735 100644 --- a/test-framework/src/runner.rs +++ b/test-framework/src/runner.rs @@ -15,7 +15,7 @@ // along with the Leo library. If not, see . use serde_yaml::Value; -use std::path::{Path, PathBuf}; +use std::{collections::BTreeMap, path::{Path, PathBuf}}; use crate::{error::*, fetch::find_tests, output::TestExpectation, test::*}; @@ -26,10 +26,17 @@ pub enum ParseType { Whole, } +pub struct Test { + pub name: String, + pub content: String, + pub path: PathBuf, + pub config: BTreeMap, +} + pub trait Namespace { fn parse_type(&self) -> ParseType; - fn run_test(&self, test: &str) -> Result; + fn run_test(&self, test: Test) -> Result; } pub trait Runner { @@ -55,7 +62,12 @@ pub fn run_tests(runner: &T, expectation_category: &str) { for (path, content) in tests.into_iter() { let config = extract_test_config(&content); if config.is_none() { - panic!("missing configuration for {}", path); + //panic!("missing configuration for {}", path); + // fail_categories.push(TestFailure { + // path, + // errors: vec![TestError::MissingTestConfig], + // }); + continue; } let config = config.unwrap(); let namespace = runner.resolve_namespace(&config.namespace); @@ -69,14 +81,21 @@ pub fn run_tests(runner: &T, expectation_category: &str) { let mut expectation_path = expectation_dir.clone(); expectation_path.push(expectation_category); expectation_path.push(relative_path.parent().expect("no parent dir for test")); - let mut test_name = relative_path + let mut expectation_name = relative_path .file_name() .expect("no file name for test") .to_str() .unwrap() .to_string(); - test_name += ".out"; - expectation_path.push(&test_name); + expectation_name += ".out"; + expectation_path.push(&expectation_name); + + let test_name = relative_path + .file_stem() + .expect("no file name for test") + .to_str() + .unwrap() + .to_string(); let expectations: Option = if expectation_path.exists() { if !std::env::var("CLEAR_LEO_TEST_EXPECTATIONS") @@ -120,13 +139,17 @@ pub fn run_tests(runner: &T, expectation_category: &str) { .as_mut() .map(|x| x.next()) .flatten() - .map(|x| x.as_str()) - .flatten(); - let output = namespace.run_test(&test); + .cloned(); + let output = namespace.run_test(Test { + name: test_name.clone(), + content: test.clone(), + path: path.into(), + config: config.extra.clone(), + }); if let Some(error) = emit_errors( output.as_ref().map_err(|x| &**x), &config.expectation, - expected_output.map(|x| Value::String(x.to_string())), + expected_output, i, ) { fail_tests += 1; diff --git a/test-framework/src/test.rs b/test-framework/src/test.rs index 3e1f64694b..13845f896c 100644 --- a/test-framework/src/test.rs +++ b/test-framework/src/test.rs @@ -1,3 +1,5 @@ +use std::collections::BTreeMap; + // Copyright (C) 2019-2021 Aleo Systems Inc. // This file is part of the Leo library. @@ -24,6 +26,8 @@ pub enum TestExpectationMode { pub struct TestConfig { pub namespace: String, pub expectation: TestExpectationMode, + #[serde(flatten)] + pub extra: BTreeMap, } pub fn extract_test_config(source: &str) -> Option { diff --git a/tests/compiler/address/address1.in b/tests/compiler/address/address1.in new file mode 100644 index 0000000000..1f1fd1870c --- /dev/null +++ b/tests/compiler/address/address1.in @@ -0,0 +1,5 @@ +[main] +x: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; + +[registers] +a: bool = false; \ No newline at end of file diff --git a/tests/compiler/address/address2.in b/tests/compiler/address/address2.in new file mode 100644 index 0000000000..8ee7606602 --- /dev/null +++ b/tests/compiler/address/address2.in @@ -0,0 +1,5 @@ +[main] +x: address = aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpq3dq05r; + +[registers] +a: bool = false; \ No newline at end of file diff --git a/tests/compiler/address/equal.leo b/tests/compiler/address/equal.leo new file mode 100644 index 0000000000..db5189b4ec --- /dev/null +++ b/tests/compiler/address/equal.leo @@ -0,0 +1,13 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - address1.in + - address2.in +*/ + +function main(x: address) -> bool { + const sender = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; + + return x == sender; +} \ No newline at end of file diff --git a/tests/compiler/address/ternary.leo b/tests/compiler/address/ternary.leo new file mode 100644 index 0000000000..5df233efa2 --- /dev/null +++ b/tests/compiler/address/ternary.leo @@ -0,0 +1,14 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - address1.in + - address2.in +*/ + +function main(x: address) -> bool { + const sender = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; + const receiver = aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpq3dq05r; + + return x == sender ? receiver == x : sender == x; +} \ No newline at end of file diff --git a/tests/compiler/array/equal_initializer.leo b/tests/compiler/array/equal_initializer.leo new file mode 100644 index 0000000000..dda9dfc250 --- /dev/null +++ b/tests/compiler/array/equal_initializer.leo @@ -0,0 +1,11 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - input/six_zeros.in + - input/count_to_6.in +*/ + +function main(a: [u8; (3, 2)]) -> bool { + return a == [0u8; (3, 2)]; +} \ No newline at end of file diff --git a/tests/compiler/array/equal_initializer_2.leo b/tests/compiler/array/equal_initializer_2.leo new file mode 100644 index 0000000000..db7b7be89c --- /dev/null +++ b/tests/compiler/array/equal_initializer_2.leo @@ -0,0 +1,11 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - input/six_zeros.in + - input/count_to_6.in +*/ + +function main(a: [u8; (3, 2)]) -> bool { + return a == [[1u8, 2], [3, 4], [5, 6]]; +} \ No newline at end of file diff --git a/tests/compiler/array/input/count_to_6.in b/tests/compiler/array/input/count_to_6.in new file mode 100644 index 0000000000..64ae8f82f6 --- /dev/null +++ b/tests/compiler/array/input/count_to_6.in @@ -0,0 +1,5 @@ +[main] +a: [[u8; 2]; 3] = [[1, 2], [3, 4], [5, 6]]; + +[registers] +x: bool = false; \ No newline at end of file diff --git a/tests/compiler/array/input/initializer_fail.in b/tests/compiler/array/input/initializer_fail.in new file mode 100644 index 0000000000..0ff699aa13 --- /dev/null +++ b/tests/compiler/array/input/initializer_fail.in @@ -0,0 +1,2 @@ +[main] +a: [u8; (3, 2)] = [0u8; (2, 2)]; diff --git a/tests/compiler/array/input/input_nested_3x2.in b/tests/compiler/array/input/input_nested_3x2.in new file mode 100644 index 0000000000..9eaafe9bdd --- /dev/null +++ b/tests/compiler/array/input/input_nested_3x2.in @@ -0,0 +1,2 @@ +[main] +a: [u8; (3, 2)] = [[0u8; 2]; 3]; diff --git a/tests/compiler/array/input/input_nested_3x2_fail.in b/tests/compiler/array/input/input_nested_3x2_fail.in new file mode 100644 index 0000000000..d1c114a08b --- /dev/null +++ b/tests/compiler/array/input/input_nested_3x2_fail.in @@ -0,0 +1,2 @@ +[main] +a: [u8; (3, 2)] = [[0u8; 3]; 2)]; diff --git a/tests/compiler/array/input/input_tuple_3x2.in b/tests/compiler/array/input/input_tuple_3x2.in new file mode 100644 index 0000000000..1c0bd495ec --- /dev/null +++ b/tests/compiler/array/input/input_tuple_3x2.in @@ -0,0 +1,2 @@ +[main] +a: [u8; (3, 2)] = [0u8; (3, 2)]; diff --git a/tests/compiler/array/input/input_tuple_3x2_fail.in b/tests/compiler/array/input/input_tuple_3x2_fail.in new file mode 100644 index 0000000000..c281d9d464 --- /dev/null +++ b/tests/compiler/array/input/input_tuple_3x2_fail.in @@ -0,0 +1,2 @@ +[main] +a: [u8; (3, 2)] = [0u8; (2, 3)]; diff --git a/tests/compiler/array/input/registers_ones.in b/tests/compiler/array/input/registers_ones.in new file mode 100644 index 0000000000..fab79f69a0 --- /dev/null +++ b/tests/compiler/array/input/registers_ones.in @@ -0,0 +1,2 @@ +[registers] +r: [u8; 3] = [1u8, 1u8, 1u8]; diff --git a/tests/compiler/array/input/registers_zeros.in b/tests/compiler/array/input/registers_zeros.in new file mode 100644 index 0000000000..e9aa65cf9b --- /dev/null +++ b/tests/compiler/array/input/registers_zeros.in @@ -0,0 +1,2 @@ +[registers] +r: [u8; 3] = [0u8, 0u8, 0u8]; diff --git a/tests/compiler/array/input/six_zeros.in b/tests/compiler/array/input/six_zeros.in new file mode 100644 index 0000000000..1f46c17666 --- /dev/null +++ b/tests/compiler/array/input/six_zeros.in @@ -0,0 +1,5 @@ +[main] +a: [u8; (3, 2)] = [0; (3, 2)]; + +[registers] +x: bool = false; \ No newline at end of file diff --git a/tests/compiler/array/input/three_ones.in b/tests/compiler/array/input/three_ones.in new file mode 100644 index 0000000000..80d095f864 --- /dev/null +++ b/tests/compiler/array/input/three_ones.in @@ -0,0 +1,2 @@ +[main] +a: [u8; 3] = [1, 1, 1]; \ No newline at end of file diff --git a/tests/compiler/array/input/type_nested_value_nested_3x2.in b/tests/compiler/array/input/type_nested_value_nested_3x2.in new file mode 100644 index 0000000000..21fc9b953f --- /dev/null +++ b/tests/compiler/array/input/type_nested_value_nested_3x2.in @@ -0,0 +1,2 @@ +[main] +a: [[u8; 2]; 3] = [[0; 2]; 3]; diff --git a/tests/compiler/array/input/type_nested_value_nested_3x2_fail.in b/tests/compiler/array/input/type_nested_value_nested_3x2_fail.in new file mode 100644 index 0000000000..280b38b909 --- /dev/null +++ b/tests/compiler/array/input/type_nested_value_nested_3x2_fail.in @@ -0,0 +1,2 @@ +[main] +a: [[u8; 2]; 3] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) diff --git a/tests/compiler/array/input/type_nested_value_nested_4x3x2.in b/tests/compiler/array/input/type_nested_value_nested_4x3x2.in new file mode 100644 index 0000000000..53ca13b024 --- /dev/null +++ b/tests/compiler/array/input/type_nested_value_nested_4x3x2.in @@ -0,0 +1,2 @@ +[main] +a: [[[u8; 2]; 3]; 4] = [[[0; 2]; 3]; 4]; diff --git a/tests/compiler/array/input/type_nested_value_nested_4x3x2_fail.in b/tests/compiler/array/input/type_nested_value_nested_4x3x2_fail.in new file mode 100644 index 0000000000..11f44a76a4 --- /dev/null +++ b/tests/compiler/array/input/type_nested_value_nested_4x3x2_fail.in @@ -0,0 +1,2 @@ +[main] +a: [[[u8; 2]; 3]; 4] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) diff --git a/tests/compiler/array/input/type_nested_value_tuple_3x2.in b/tests/compiler/array/input/type_nested_value_tuple_3x2.in new file mode 100644 index 0000000000..689e164b73 --- /dev/null +++ b/tests/compiler/array/input/type_nested_value_tuple_3x2.in @@ -0,0 +1,2 @@ +[main] +a: [[u8; 2]; 3] = [0; (3, 2)]; diff --git a/tests/compiler/array/input/type_nested_value_tuple_3x2_fail.in b/tests/compiler/array/input/type_nested_value_tuple_3x2_fail.in new file mode 100644 index 0000000000..4a43d7d816 --- /dev/null +++ b/tests/compiler/array/input/type_nested_value_tuple_3x2_fail.in @@ -0,0 +1,2 @@ +[main] +a: [[u8; 2]; 3] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) diff --git a/tests/compiler/array/input/type_nested_value_tuple_4x3x2.in b/tests/compiler/array/input/type_nested_value_tuple_4x3x2.in new file mode 100644 index 0000000000..649a7154ad --- /dev/null +++ b/tests/compiler/array/input/type_nested_value_tuple_4x3x2.in @@ -0,0 +1,2 @@ +[main] +a: [[[u8; 2]; 3]; 4] = [0; (4, 3, 2)]; diff --git a/tests/compiler/array/input/type_nested_value_tuple_4x3x2_fail.in b/tests/compiler/array/input/type_nested_value_tuple_4x3x2_fail.in new file mode 100644 index 0000000000..eed469d6ac --- /dev/null +++ b/tests/compiler/array/input/type_nested_value_tuple_4x3x2_fail.in @@ -0,0 +1,2 @@ +[main] +a: [[[u8; 2]; 3]; 4] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering) diff --git a/tests/compiler/array/input/type_tuple_value_nested_3x2.in b/tests/compiler/array/input/type_tuple_value_nested_3x2.in new file mode 100644 index 0000000000..cb3943365b --- /dev/null +++ b/tests/compiler/array/input/type_tuple_value_nested_3x2.in @@ -0,0 +1,2 @@ +[main] +a: [u8; (3, 2)] = [[0; 2]; 3]; diff --git a/tests/compiler/array/input/type_tuple_value_nested_3x2_fail.in b/tests/compiler/array/input/type_tuple_value_nested_3x2_fail.in new file mode 100644 index 0000000000..c787cbffd9 --- /dev/null +++ b/tests/compiler/array/input/type_tuple_value_nested_3x2_fail.in @@ -0,0 +1,2 @@ +[main] +a: [u8; (3, 2)] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) diff --git a/tests/compiler/array/input/type_tuple_value_nested_4x3x2.in b/tests/compiler/array/input/type_tuple_value_nested_4x3x2.in new file mode 100644 index 0000000000..8105eae543 --- /dev/null +++ b/tests/compiler/array/input/type_tuple_value_nested_4x3x2.in @@ -0,0 +1,2 @@ +[main] +a: [u8; (4, 3, 2)] = [[[0; 2]; 3]; 4]; diff --git a/tests/compiler/array/input/type_tuple_value_nested_4x3x2_fail.in b/tests/compiler/array/input/type_tuple_value_nested_4x3x2_fail.in new file mode 100644 index 0000000000..3e194e590d --- /dev/null +++ b/tests/compiler/array/input/type_tuple_value_nested_4x3x2_fail.in @@ -0,0 +1,2 @@ +[main] +a: [u8; (4, 3, 2)] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) diff --git a/tests/compiler/array/input/type_tuple_value_tuple_3x2.in b/tests/compiler/array/input/type_tuple_value_tuple_3x2.in new file mode 100644 index 0000000000..cbfeb6d5f1 --- /dev/null +++ b/tests/compiler/array/input/type_tuple_value_tuple_3x2.in @@ -0,0 +1,2 @@ +[main] +a: [u8; (3, 2)] = [0; (3, 2)]; diff --git a/tests/compiler/array/input/type_tuple_value_tuple_3x2_fail.in b/tests/compiler/array/input/type_tuple_value_tuple_3x2_fail.in new file mode 100644 index 0000000000..3409e8aaa9 --- /dev/null +++ b/tests/compiler/array/input/type_tuple_value_tuple_3x2_fail.in @@ -0,0 +1,2 @@ +[main] +a: [u8; (3, 2)] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) diff --git a/tests/compiler/array/input/type_tuple_value_tuple_4x3x2.in b/tests/compiler/array/input/type_tuple_value_tuple_4x3x2.in new file mode 100644 index 0000000000..6fd97ee2d2 --- /dev/null +++ b/tests/compiler/array/input/type_tuple_value_tuple_4x3x2.in @@ -0,0 +1,2 @@ +[main] +a: [u8; (4, 3, 2)] = [0; (4, 3, 2)]; diff --git a/tests/compiler/array/input/type_tuple_value_tuple_4x3x2_fail.in b/tests/compiler/array/input/type_tuple_value_tuple_4x3x2_fail.in new file mode 100644 index 0000000000..d6de4af3c5 --- /dev/null +++ b/tests/compiler/array/input/type_tuple_value_tuple_4x3x2_fail.in @@ -0,0 +1,2 @@ +[main] +a: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering) diff --git a/tests/compiler/array/input_nested_3x2.leo b/tests/compiler/array/input_nested_3x2.leo new file mode 100644 index 0000000000..b7e59a5dc0 --- /dev/null +++ b/tests/compiler/array/input_nested_3x2.leo @@ -0,0 +1,3 @@ +function main(a: [u8; (3, 2)]) { + console.assert(a == [[0u8; 2]; 3]); +} diff --git a/tests/compiler/array/input_nested_3x2_fail.leo b/tests/compiler/array/input_nested_3x2_fail.leo new file mode 100644 index 0000000000..1f5bf7b334 --- /dev/null +++ b/tests/compiler/array/input_nested_3x2_fail.leo @@ -0,0 +1,3 @@ +function main(a: [u8; (3, 2)]) { + console.assert(a == [[0u8; 2]; 3)]); // This should be written the right way as this test is for the input file. +} diff --git a/tests/compiler/array/input_tuple_3x2.leo b/tests/compiler/array/input_tuple_3x2.leo new file mode 100644 index 0000000000..4c3c001f41 --- /dev/null +++ b/tests/compiler/array/input_tuple_3x2.leo @@ -0,0 +1,3 @@ +function main(a: [u8; (3, 2)]) { + console.assert(a == [0u8; (3, 2)]); +} diff --git a/tests/compiler/array/input_tuple_3x2_fail.leo b/tests/compiler/array/input_tuple_3x2_fail.leo new file mode 100644 index 0000000000..4c3c001f41 --- /dev/null +++ b/tests/compiler/array/input_tuple_3x2_fail.leo @@ -0,0 +1,3 @@ +function main(a: [u8; (3, 2)]) { + console.assert(a == [0u8; (3, 2)]); +} diff --git a/tests/compiler/array/mod.rs b/tests/compiler/array/mod.rs new file mode 100644 index 0000000000..7acbd1af2f --- /dev/null +++ b/tests/compiler/array/mod.rs @@ -0,0 +1,716 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + get_output, + parse_program, + parse_program_with_input, + EdwardsTestCompiler, +}; + +pub fn output_ones(program: EdwardsTestCompiler) { + let expected = include_bytes!("output/registers_ones.out"); + let actual = get_output(program); + + assert!(expected.eq(actual.bytes().as_slice())); +} + +pub fn output_zeros(program: EdwardsTestCompiler) { + let expected = include_bytes!("output/registers_zeros.out"); + let actual = get_output(program); + + assert!(expected.eq(actual.bytes().as_slice())); +} + +// Registers + +#[test] +fn test_registers() { + let program_string = include_str!("registers.leo"); + let ones_input_string = include_str!("input/registers_ones.in"); + let zeros_input_string = include_str!("input/registers_zeros.in"); + + // test ones input register => ones output register + let program = parse_program_with_input(program_string, ones_input_string).unwrap(); + + output_ones(program); + + // test zeros input register => zeros output register + let program = parse_program_with_input(program_string, zeros_input_string).unwrap(); + + output_zeros(program); +} + +// Expressions + +#[test] +fn test_inline() { + let program_string = include_str!("inline.leo"); + let input_string = include_str!("input/three_ones.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_nested() { + let program_string = include_str!("nested.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_inline_fail() { + let program_string = include_str!("inline.leo"); + let program = parse_program(program_string).unwrap(); + + let _err = expect_compiler_error(program); +} + +#[test] +fn test_initializer() { + let program_string = include_str!("initializer.leo"); + let input_string = include_str!("input/three_ones.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_initializer_fail() { + let program_string = include_str!("initializer_fail.leo"); + let input_string = include_str!("input/three_ones.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); + + assert!(syntax_error); +} + +#[test] +fn test_initializer_input() { + let program_string = include_str!("initializer_input.leo"); + let input_string = include_str!("input/six_zeros.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_initializer_input_fail() { + let program_string = include_str!("initializer_input.leo"); + let input_string = include_str!("input/initializer_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); + + assert!(syntax_error); +} + +#[test] +fn test_input_nested_3x2() { + let program_string = include_str!("input_nested_3x2.leo"); + let input_string = include_str!("input/input_nested_3x2.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_input_nested_3x2_fail() { + let program_string = include_str!("input_nested_3x2_fail.leo"); + let input_string = include_str!("input/input_nested_3x2_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); + + assert!(syntax_error); +} + +#[test] +fn test_input_tuple_3x2() { + let program_string = include_str!("input_tuple_3x2.leo"); + let input_string = include_str!("input/input_tuple_3x2.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_input_tuple_3x2_fail() { + let program_string = include_str!("input_tuple_3x2_fail.leo"); + let input_string = include_str!("input/input_tuple_3x2_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); + + assert!(syntax_error); +} + +#[test] +fn test_multi_fail_initializer() { + let program_string = include_str!("multi_fail_initializer.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_multi_inline_fail() { + let program_string = include_str!("multi_fail_inline.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_multi_initializer() { + let program_string = include_str!("multi_initializer.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_multi_initializer_fail() { + let program_string = include_str!("multi_initializer_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_nested_3x2_value() { + let program_string = include_str!("nested_3x2_value.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_nested_3x2_value_fail() { + let program_string = include_str!("nested_3x2_value_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_tuple_3x2_value() { + let program_string = include_str!("tuple_3x2_value.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_tuple_3x2_value_fail() { + let program_string = include_str!("tuple_3x2_value_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_spread() { + let program_string = include_str!("spread.leo"); + let input_string = include_str!("input/three_ones.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_slice() { + let program_string = include_str!("slice.leo"); + let input_string = include_str!("input/three_ones.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_slice_lower() { + let program_string = include_str!("slice_lower.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +// Array type tests + +#[test] +fn test_type_fail() { + let program_string = include_str!("type_fail.leo"); + let syntax_error = parse_program(program_string).is_err(); + + assert!(syntax_error); +} + +#[test] +fn test_type_nested_value_nested_3x2() { + let program_string = include_str!("type_nested_value_nested_3x2.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_type_nested_value_nested_3x2_fail() { + let program_string = include_str!("type_nested_value_nested_3x2_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_type_nested_value_nested_4x3x2() { + let program_string = include_str!("type_nested_value_nested_4x3x2.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_type_nested_value_nested_4x3x2_fail() { + let program_string = include_str!("type_nested_value_nested_4x3x2_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_type_nested_value_tuple_3x2() { + let program_string = include_str!("type_nested_value_tuple_3x2.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_type_nested_value_tuple_3x2_fail() { + let program_string = include_str!("type_nested_value_tuple_3x2_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_type_nested_value_tuple_4x3x2() { + let program_string = include_str!("type_nested_value_tuple_4x3x2.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_type_nested_value_tuple_4x3x2_fail() { + let program_string = include_str!("type_nested_value_tuple_4x3x2_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_type_tuple_value_nested_3x2() { + let program_string = include_str!("type_tuple_value_nested_3x2.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_type_tuple_value_nested_3x2_fail() { + let program_string = include_str!("type_tuple_value_nested_3x2_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_type_tuple_value_nested_4x3x2() { + let program_string = include_str!("type_tuple_value_nested_4x3x2.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_type_tuple_value_nested_4x3x2_fail() { + let program_string = include_str!("type_tuple_value_nested_4x3x2_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_type_tuple_value_tuple_3x2() { + let program_string = include_str!("type_tuple_value_tuple_3x2.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_type_tuple_value_tuple_3x2_fail() { + let program_string = include_str!("type_tuple_value_tuple_3x2_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_type_tuple_value_tuple_4x3x2() { + let program_string = include_str!("type_tuple_value_tuple_4x3x2.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_type_tuple_value_tuple_4x3x2_fail() { + let program_string = include_str!("type_tuple_value_tuple_4x3x2_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +// Tests for nested multi-dimensional arrays as input to the program + +#[test] +fn test_input_type_nested_value_nested_3x2() { + let program_string = include_str!("type_input_3x2.leo"); + let input_string = include_str!("input/type_nested_value_nested_3x2.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_input_type_nested_value_nested_3x2_fail() { + let program_string = include_str!("type_input_3x2.leo"); + let input_string = include_str!("input/type_nested_value_nested_3x2_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); + + assert!(syntax_error); +} + +#[test] +fn test_input_type_nested_value_nested_4x3x2() { + let program_string = include_str!("type_input_4x3x2.leo"); + let input_string = include_str!("input/type_nested_value_nested_4x3x2.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_input_type_nested_value_nested_4x3x2_fail() { + let program_string = include_str!("type_input_4x3x2.leo"); + let input_string = include_str!("input/type_nested_value_nested_4x3x2_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); + + assert!(syntax_error); +} + +#[test] +fn test_input_type_nested_value_tuple_3x2() { + let program_string = include_str!("type_input_3x2.leo"); + let input_string = include_str!("input/type_nested_value_tuple_3x2.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_input_type_nested_value_tuple_3x2_fail() { + let program_string = include_str!("type_input_3x2.leo"); + let input_string = include_str!("input/type_nested_value_tuple_3x2_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); + + assert!(syntax_error); +} + +#[test] +fn test_input_type_nested_value_tuple_4x3x2() { + let program_string = include_str!("type_input_4x3x2.leo"); + let input_string = include_str!("input/type_nested_value_tuple_4x3x2.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program) +} + +#[test] +fn test_input_type_nested_value_tuple_4x3x2_fail() { + let program_string = include_str!("type_input_4x3x2.leo"); + let input_string = include_str!("input/type_nested_value_tuple_4x3x2_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); + + assert!(syntax_error); +} + +// Tests for multi-dimensional arrays using tuple syntax as input to the program + +#[test] +fn test_input_type_tuple_value_nested_3x2() { + let program_string = include_str!("type_input_3x2.leo"); + let input_string = include_str!("input/type_tuple_value_nested_3x2.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_input_type_tuple_value_nested_3x2_fail() { + let program_string = include_str!("type_input_3x2.leo"); + let input_string = include_str!("input/type_tuple_value_nested_3x2_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); + + assert!(syntax_error); +} + +#[test] +fn test_input_type_tuple_value_nested_4x3x2() { + let program_string = include_str!("type_input_4x3x2.leo"); + let input_string = include_str!("input/type_tuple_value_nested_4x3x2.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_input_type_tuple_value_nested_4x3x2_fail() { + let program_string = include_str!("type_input_4x3x2.leo"); + let input_string = include_str!("input/type_tuple_value_nested_4x3x2_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); + + assert!(syntax_error); +} + +#[test] +fn test_input_type_tuple_value_tuple_3x2() { + let program_string = include_str!("type_input_3x2.leo"); + let input_string = include_str!("input/type_tuple_value_tuple_3x2.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_input_type_tuple_value_tuple_3x2_fail() { + let program_string = include_str!("type_input_3x2.leo"); + let input_string = include_str!("input/type_tuple_value_tuple_3x2_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); + + assert!(syntax_error); +} + +#[test] +fn test_input_type_tuple_value_tuple_4x3x2() { + let program_string = include_str!("type_input_4x3x2.leo"); + let input_string = include_str!("input/type_tuple_value_tuple_4x3x2.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_input_type_tuple_value_tuple_4x3x2_fail() { + let program_string = include_str!("type_input_4x3x2.leo"); + let input_string = include_str!("input/type_tuple_value_tuple_4x3x2_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); + + assert!(syntax_error); +} + +#[test] +fn test_variable_slice_fail() { + let program_string = include_str!("variable_slice_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_array_index() { + let program_string = r#" + function main(i: u32) { + let b = [1u8, 2, 3, 4]; + + console.assert(2 == b[i]); + console.assert(3 == b[2]); + } + "#; + let input_string = r#" + [main] + i: u32 = 1; + "#; + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_array_index_bounds_fail() { + let program_string = r#" + function main(i: u32) { + let b = [1u8, 2, 3, 4]; + + console.assert(2 == b[i]); + } + "#; + let input_string = r#" + [main] + i: u32 = 4; + "#; + let program = parse_program_with_input(program_string, input_string).unwrap(); + + expect_compiler_error(program); +} + +#[test] +fn test_const_array_index_bounds_fail() { + let program_string = r#" + function main() { + let b = [1u8, 2, 3, 4]; + const i: u32 = 4; + + console.assert(2 == b[i]); + } + "#; + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_array_range_index() { + let program_string = r#" + function main(i: u32) { + let b = [1u8, 2, 3, 4]; + + console.assert([1u8, 2] == b[0..i]); + console.assert([3u8, 4] == b[i..4]); + } + "#; + let input_string = r#" + [main] + i: u32 = 2; + "#; + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_array_range_index_dyn() { + let program_string = r#" + function main(i: u32) { + let b = [1u8, 2, 3, 4]; + + console.assert([1u8, 2] == b[..i]); + console.assert([3u8, 4] == b[i..]); + } + "#; + let input_string = r#" + [main] + i: u32 = 2; + "#; + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_array_range_index_full_dyn() { + let program_string = r#" + function main(i: u32, y: u32) { + let b = [1u8, 2, 3, 4]; + + console.assert([3u8, 4] == b[i..y]); + } + "#; + let input_string = r#" + [main] + i: u32 = 2; + y: u32 = 4; + "#; + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_array_range_index_out_of_bounds_fail() { + let program_string = r#" + function main() { + let b = [1u8, 2, 3, 4]; + + console.assert([1, 2] == b[3..5]); + } + "#; + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_array_range_index_invalid_bounds_fail() { + let program_string = r#" + function main() { + let b = [1u8, 2, 3, 4]; + + console.assert([1, 2] == b[2..1]); + } + "#; + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_array_range_index_full_dyn_resized_fail() { + let program_string = r#" + function main(i: u32, y: u32) { + let b = [1u8, 2, 3, 4]; + + console.assert([3u8, 4] == b[i..y]); + } + "#; + let input_string = r#" + [main] + i: u32 = 1; + y: u32 = 4; + "#; + let program = parse_program_with_input(program_string, input_string).unwrap(); + + expect_compiler_error(program); +} + +#[test] +fn test_array_range_index_full_dyn_bounds_fail() { + let program_string = r#" + function main(i: u32, y: u32) { + let b = [1u8, 2, 3, 4]; + + console.assert([3u8, 4] == b[i..y]); + } + "#; + let input_string = r#" + [main] + i: u32 = 3; + y: u32 = 5; + "#; + let program = parse_program_with_input(program_string, input_string).unwrap(); + + expect_compiler_error(program); +} diff --git a/tests/compiler/array/multi_fail_initializer.leo b/tests/compiler/array/multi_fail_initializer.leo new file mode 100644 index 0000000000..be1ab315bd --- /dev/null +++ b/tests/compiler/array/multi_fail_initializer.leo @@ -0,0 +1,3 @@ +function main() { + const arr: [u8; (2, 2)] = [[1u8; 2]; 1]; // incorrect dimensions +} \ No newline at end of file diff --git a/tests/compiler/array/multi_fail_inline.leo b/tests/compiler/array/multi_fail_inline.leo new file mode 100644 index 0000000000..49c9296798 --- /dev/null +++ b/tests/compiler/array/multi_fail_inline.leo @@ -0,0 +1,4 @@ +function main() { + const arr: [u8; (2, 2)] = [[1u8, 1u8], + [1u8]]; // incorrect dimensions +} \ No newline at end of file diff --git a/tests/compiler/array/multi_initializer.leo b/tests/compiler/array/multi_initializer.leo new file mode 100644 index 0000000000..6133542ef0 --- /dev/null +++ b/tests/compiler/array/multi_initializer.leo @@ -0,0 +1,7 @@ +function main() { + const a: [u8; (2, 2, 2)] = [1u8; (2, 2, 2)]; + + const b: [u8; (2, 2, 2)] = [[[1u8; 2]; 2]; 2]; + + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/array/multi_initializer_fail.leo b/tests/compiler/array/multi_initializer_fail.leo new file mode 100644 index 0000000000..e38a8fdaee --- /dev/null +++ b/tests/compiler/array/multi_initializer_fail.leo @@ -0,0 +1,3 @@ +function main() { + const arr: [u8; (2, 2)] = [1u8; (2, 1)]; // incorrect dimensions +} \ No newline at end of file diff --git a/tests/compiler/array/nested.leo b/tests/compiler/array/nested.leo new file mode 100644 index 0000000000..80fc5511bf --- /dev/null +++ b/tests/compiler/array/nested.leo @@ -0,0 +1,4 @@ +function main () { + const x = [false; (2, 2)]; + const y: bool = x[0][0]; +} diff --git a/tests/compiler/array/nested_3x2_value.leo b/tests/compiler/array/nested_3x2_value.leo new file mode 100644 index 0000000000..c5f64c997e --- /dev/null +++ b/tests/compiler/array/nested_3x2_value.leo @@ -0,0 +1,8 @@ +// Multidimensional array syntax in leo +function main() { + const a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline + + const b: [u32; (3, 2)] = [[0; 2]; 3]; // initializer + + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/array/nested_3x2_value_fail.leo b/tests/compiler/array/nested_3x2_value_fail.leo new file mode 100644 index 0000000000..a187a51991 --- /dev/null +++ b/tests/compiler/array/nested_3x2_value_fail.leo @@ -0,0 +1,4 @@ +// Multidimensional array syntax in leo +function main() { + const a: [u32; (3, 2)] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) +} diff --git a/tests/compiler/array/registers.leo b/tests/compiler/array/registers.leo new file mode 100644 index 0000000000..98d129207f --- /dev/null +++ b/tests/compiler/array/registers.leo @@ -0,0 +1,3 @@ +function main() -> [u8; 3] { + return input.registers.r; +} diff --git a/tests/compiler/array/slice.leo b/tests/compiler/array/slice.leo new file mode 100644 index 0000000000..9ff83dbbb8 --- /dev/null +++ b/tests/compiler/array/slice.leo @@ -0,0 +1,6 @@ +// `{from}..{to}` copies the elements of one array into another exclusively +function main(a: [u8; 3]) { + const b = [1u8; 4]; + + console.assert(a == b[0..3]); +} diff --git a/tests/compiler/array/slice_lower.leo b/tests/compiler/array/slice_lower.leo new file mode 100644 index 0000000000..0af6fbd937 --- /dev/null +++ b/tests/compiler/array/slice_lower.leo @@ -0,0 +1,8 @@ +function main() { + const arr: [u32; 9] = [0, 1, 2, 3, 4, 5, 6, 7, 8]; + const expected: [u32; 2] = [0, 1]; + + const actual = arr[..2]; // Should produce [0, 1] + + console.assert(expected == actual); +} \ No newline at end of file diff --git a/tests/compiler/array/spread.leo b/tests/compiler/array/spread.leo new file mode 100644 index 0000000000..8bd2861aae --- /dev/null +++ b/tests/compiler/array/spread.leo @@ -0,0 +1,7 @@ +// A spread operator `...` copies the elements of one array into another +function main(a: [u8; 3]) { + const b = [1u8, 1u8]; + const c = [1u8, ...b]; + + console.assert(a == c); +} \ No newline at end of file diff --git a/tests/compiler/array/tuple_3x2_value.leo b/tests/compiler/array/tuple_3x2_value.leo new file mode 100644 index 0000000000..b6659539d5 --- /dev/null +++ b/tests/compiler/array/tuple_3x2_value.leo @@ -0,0 +1,8 @@ +// Multidimensional array syntax in leo +function main() { + const a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline + + const b: [u32; (3, 2)] = [0; (3, 2)]; // initializer + + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/array/tuple_3x2_value_fail.leo b/tests/compiler/array/tuple_3x2_value_fail.leo new file mode 100644 index 0000000000..78593ab696 --- /dev/null +++ b/tests/compiler/array/tuple_3x2_value_fail.leo @@ -0,0 +1,4 @@ +// Multidimensional array syntax in leo +function main() { + const a: [u32; (3, 2)] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) +} diff --git a/tests/compiler/array/type_fail.leo b/tests/compiler/array/type_fail.leo new file mode 100644 index 0000000000..356bba976a --- /dev/null +++ b/tests/compiler/array/type_fail.leo @@ -0,0 +1,3 @@ +function main() { + const a: [u8; -2] = [0u32; 2]; +} \ No newline at end of file diff --git a/tests/compiler/array/type_input_3x2.leo b/tests/compiler/array/type_input_3x2.leo new file mode 100644 index 0000000000..ea60a0cc24 --- /dev/null +++ b/tests/compiler/array/type_input_3x2.leo @@ -0,0 +1,5 @@ +function main(a: [[u8; 2]; 3]) { + const b = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/array/type_input_4x3x2.leo b/tests/compiler/array/type_input_4x3x2.leo new file mode 100644 index 0000000000..2d9c4cff22 --- /dev/null +++ b/tests/compiler/array/type_input_4x3x2.leo @@ -0,0 +1,8 @@ +function main(a: [[[u8; 2]; 3]; 4]) { + const b = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline + + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/array/type_nested_value_nested_3x2.leo b/tests/compiler/array/type_nested_value_nested_3x2.leo new file mode 100644 index 0000000000..bcf5bae674 --- /dev/null +++ b/tests/compiler/array/type_nested_value_nested_3x2.leo @@ -0,0 +1,7 @@ +function main() { + const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + + const b: [[u8; 2]; 3] = [[0; 2]; 3]; // initializer + + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/array/type_nested_value_nested_3x2_fail.leo b/tests/compiler/array/type_nested_value_nested_3x2_fail.leo new file mode 100644 index 0000000000..56c8916fb0 --- /dev/null +++ b/tests/compiler/array/type_nested_value_nested_3x2_fail.leo @@ -0,0 +1,3 @@ +function main() { + const b: [[u8; 2]; 3] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) +} \ No newline at end of file diff --git a/tests/compiler/array/type_nested_value_nested_4x3x2.leo b/tests/compiler/array/type_nested_value_nested_4x3x2.leo new file mode 100644 index 0000000000..1691fa26c7 --- /dev/null +++ b/tests/compiler/array/type_nested_value_nested_4x3x2.leo @@ -0,0 +1,10 @@ +function main() { + const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline + + const b: [[[u8; 2]; 3]; 4] = [[[0; 2]; 3]; 4]; // initializer + + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/array/type_nested_value_nested_4x3x2_fail.leo b/tests/compiler/array/type_nested_value_nested_4x3x2_fail.leo new file mode 100644 index 0000000000..480327a91d --- /dev/null +++ b/tests/compiler/array/type_nested_value_nested_4x3x2_fail.leo @@ -0,0 +1,3 @@ +function main() { + const b: [[[u8; 2]; 3]; 4] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) +} \ No newline at end of file diff --git a/tests/compiler/array/type_nested_value_tuple_3x2.leo b/tests/compiler/array/type_nested_value_tuple_3x2.leo new file mode 100644 index 0000000000..5f14084d55 --- /dev/null +++ b/tests/compiler/array/type_nested_value_tuple_3x2.leo @@ -0,0 +1,7 @@ +function main() { + const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + + const b: [[u8; 2]; 3] = [0; (3, 2)]; // initializer + + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/array/type_nested_value_tuple_3x2_fail.leo b/tests/compiler/array/type_nested_value_tuple_3x2_fail.leo new file mode 100644 index 0000000000..3bfb559615 --- /dev/null +++ b/tests/compiler/array/type_nested_value_tuple_3x2_fail.leo @@ -0,0 +1,3 @@ +function main() { + const b: [[u8; 2]; 3] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) +} \ No newline at end of file diff --git a/tests/compiler/array/type_nested_value_tuple_4x3x2.leo b/tests/compiler/array/type_nested_value_tuple_4x3x2.leo new file mode 100644 index 0000000000..88a5143bd2 --- /dev/null +++ b/tests/compiler/array/type_nested_value_tuple_4x3x2.leo @@ -0,0 +1,10 @@ +function main() { + const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline + + const b: [[[u8; 2]; 3]; 4] = [0; (4, 3, 2)]; // initializer + + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/array/type_nested_value_tuple_4x3x2_fail.leo b/tests/compiler/array/type_nested_value_tuple_4x3x2_fail.leo new file mode 100644 index 0000000000..ce1219a37b --- /dev/null +++ b/tests/compiler/array/type_nested_value_tuple_4x3x2_fail.leo @@ -0,0 +1,3 @@ +function main() { + const b: [[[u8; 2]; 3]; 4] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering) +} \ No newline at end of file diff --git a/tests/compiler/array/type_tuple_value_nested_3x2.leo b/tests/compiler/array/type_tuple_value_nested_3x2.leo new file mode 100644 index 0000000000..81195e03a1 --- /dev/null +++ b/tests/compiler/array/type_tuple_value_nested_3x2.leo @@ -0,0 +1,7 @@ +function main() { + const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + + const b: [u8; (3, 2)] = [[0; 2]; 3]; // initializer + + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/array/type_tuple_value_nested_3x2_fail.leo b/tests/compiler/array/type_tuple_value_nested_3x2_fail.leo new file mode 100644 index 0000000000..e84f025a9f --- /dev/null +++ b/tests/compiler/array/type_tuple_value_nested_3x2_fail.leo @@ -0,0 +1,3 @@ +function main() { + const b: [u8; (2, 3)] = [[0; 2]; 3]; // initializer (incorrectly reversed ordering) +} \ No newline at end of file diff --git a/tests/compiler/array/type_tuple_value_nested_4x3x2.leo b/tests/compiler/array/type_tuple_value_nested_4x3x2.leo new file mode 100644 index 0000000000..322a6f7601 --- /dev/null +++ b/tests/compiler/array/type_tuple_value_nested_4x3x2.leo @@ -0,0 +1,10 @@ +function main() { + const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline + + const b: [u8; (4, 3, 2)] = [[[0; 2]; 3]; 4]; // initializer + + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/array/type_tuple_value_nested_4x3x2_fail.leo b/tests/compiler/array/type_tuple_value_nested_4x3x2_fail.leo new file mode 100644 index 0000000000..cbb7ccbf76 --- /dev/null +++ b/tests/compiler/array/type_tuple_value_nested_4x3x2_fail.leo @@ -0,0 +1,3 @@ +function main() { + const b: [u8; (4, 3, 2)] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) +} \ No newline at end of file diff --git a/tests/compiler/array/type_tuple_value_tuple_3x2.leo b/tests/compiler/array/type_tuple_value_tuple_3x2.leo new file mode 100644 index 0000000000..d451a9c1a8 --- /dev/null +++ b/tests/compiler/array/type_tuple_value_tuple_3x2.leo @@ -0,0 +1,7 @@ +function main() { + const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + + const b: [u8; (3, 2)] = [0; (3, 2)]; // initializer + + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/array/type_tuple_value_tuple_3x2_fail.leo b/tests/compiler/array/type_tuple_value_tuple_3x2_fail.leo new file mode 100644 index 0000000000..884a75db9d --- /dev/null +++ b/tests/compiler/array/type_tuple_value_tuple_3x2_fail.leo @@ -0,0 +1,3 @@ +function main() { + const b: [u8; (2, 3)] = [0; (3, 2)]; // initializer (incorrectly reversed ordering) +} \ No newline at end of file diff --git a/tests/compiler/array/type_tuple_value_tuple_4x3x2.leo b/tests/compiler/array/type_tuple_value_tuple_4x3x2.leo new file mode 100644 index 0000000000..1205b1dc9c --- /dev/null +++ b/tests/compiler/array/type_tuple_value_tuple_4x3x2.leo @@ -0,0 +1,10 @@ +function main() { + const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline + + const b: [u8; (4, 3, 2)] = [0; (4, 3, 2)]; // initializer + + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/array/type_tuple_value_tuple_4x3x2_fail.leo b/tests/compiler/array/type_tuple_value_tuple_4x3x2_fail.leo new file mode 100644 index 0000000000..31e2a5e552 --- /dev/null +++ b/tests/compiler/array/type_tuple_value_tuple_4x3x2_fail.leo @@ -0,0 +1,3 @@ +function main() { + const b: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed order) +} \ No newline at end of file diff --git a/tests/compiler/array/variable_slice_fail.leo b/tests/compiler/array/variable_slice_fail.leo new file mode 100644 index 0000000000..e79d64112f --- /dev/null +++ b/tests/compiler/array/variable_slice_fail.leo @@ -0,0 +1,7 @@ +function main() { + const a = [1u8; 10]; + for i in 0..10 { + const x = a[i..10]; + console.debug("{}", x); + } +} \ No newline at end of file diff --git a/tests/compiler/boolean/and.leo b/tests/compiler/boolean/and.leo new file mode 100644 index 0000000000..738d413251 --- /dev/null +++ b/tests/compiler/boolean/and.leo @@ -0,0 +1,13 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - input/false_false.in + - input/false_true.in + - input/true_false.in + - input/true_true.in +*/ + +function main(a: bool, b: bool) -> bool { + return a && b; +} \ No newline at end of file diff --git a/tests/compiler/boolean/conditional.leo b/tests/compiler/boolean/conditional.leo new file mode 100644 index 0000000000..c1e9d23606 --- /dev/null +++ b/tests/compiler/boolean/conditional.leo @@ -0,0 +1,13 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - input/false_false.in + - input/false_true.in + - input/true_false.in + - input/true_true.in +*/ + +function main(a: bool, b: bool) -> bool { + return a ? b : false; +} \ No newline at end of file diff --git a/tests/compiler/boolean/equal.leo b/tests/compiler/boolean/equal.leo new file mode 100644 index 0000000000..f31f34de9b --- /dev/null +++ b/tests/compiler/boolean/equal.leo @@ -0,0 +1,13 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - input/false_false.in + - input/false_true.in + - input/true_false.in + - input/true_true.in +*/ + +function main(a: bool, b: bool) -> bool { + return a == b; +} \ No newline at end of file diff --git a/tests/compiler/boolean/input/false_false.in b/tests/compiler/boolean/input/false_false.in new file mode 100644 index 0000000000..c00c52afd9 --- /dev/null +++ b/tests/compiler/boolean/input/false_false.in @@ -0,0 +1,6 @@ +[main] +a: bool = false; +b: bool = false; + +[registers] +x: bool = false; \ No newline at end of file diff --git a/tests/compiler/boolean/input/false_true.in b/tests/compiler/boolean/input/false_true.in new file mode 100644 index 0000000000..a5b8e98d4d --- /dev/null +++ b/tests/compiler/boolean/input/false_true.in @@ -0,0 +1,6 @@ +[main] +a: bool = false; +b: bool = true; + +[registers] +x: bool = false; \ No newline at end of file diff --git a/tests/compiler/boolean/input/true_false.in b/tests/compiler/boolean/input/true_false.in new file mode 100644 index 0000000000..5713d072da --- /dev/null +++ b/tests/compiler/boolean/input/true_false.in @@ -0,0 +1,6 @@ +[main] +a: bool = true; +b: bool = false; + +[registers] +x: bool = false; \ No newline at end of file diff --git a/tests/compiler/boolean/input/true_true.in b/tests/compiler/boolean/input/true_true.in new file mode 100644 index 0000000000..5e8c2ba4ec --- /dev/null +++ b/tests/compiler/boolean/input/true_true.in @@ -0,0 +1,6 @@ +[main] +a: bool = true; +b: bool = true; + +[registers] +x: bool = false; \ No newline at end of file diff --git a/tests/compiler/boolean/not_equal.leo b/tests/compiler/boolean/not_equal.leo new file mode 100644 index 0000000000..62a1bef945 --- /dev/null +++ b/tests/compiler/boolean/not_equal.leo @@ -0,0 +1,13 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - input/false_false.in + - input/false_true.in + - input/true_false.in + - input/true_true.in +*/ + +function main(a: bool, b: bool) -> bool { + return a != b; +} \ No newline at end of file diff --git a/tests/compiler/boolean/or.leo b/tests/compiler/boolean/or.leo new file mode 100644 index 0000000000..59488b6d98 --- /dev/null +++ b/tests/compiler/boolean/or.leo @@ -0,0 +1,13 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - input/false_false.in + - input/false_true.in + - input/true_false.in + - input/true_true.in +*/ + +function main(a: bool, b: bool) -> bool { + return a || b; +} \ No newline at end of file diff --git a/tests/compiler/circuits/const_self_variable.leo b/tests/compiler/circuits/const_self_variable.leo new file mode 100644 index 0000000000..8ba32ba0df --- /dev/null +++ b/tests/compiler/circuits/const_self_variable.leo @@ -0,0 +1,13 @@ +circuit Foo { + a: u8, + + function use_a(const self) -> u8 { + return self.a + 1; + } +} + +function main() { + let f = Foo { a: 0u8 }; + + console.assert(1u8 == f.use_a()); +} \ No newline at end of file diff --git a/tests/compiler/circuits/const_self_variable_fail.leo b/tests/compiler/circuits/const_self_variable_fail.leo new file mode 100644 index 0000000000..fca9620946 --- /dev/null +++ b/tests/compiler/circuits/const_self_variable_fail.leo @@ -0,0 +1,13 @@ +circuit Foo { + a: u8, + + function set_a(const self, new: u8) { + self.a = new; + } +} + +function main() { + let f = Foo { a: 0u8 }; + + f.set_a(1u8); +} \ No newline at end of file diff --git a/tests/compiler/circuits/define_circuit_inside_circuit_function.leo b/tests/compiler/circuits/define_circuit_inside_circuit_function.leo new file mode 100644 index 0000000000..cedabf2185 --- /dev/null +++ b/tests/compiler/circuits/define_circuit_inside_circuit_function.leo @@ -0,0 +1,13 @@ +circuit Foo { + a: u32, +} + +circuit Bar { + function bar() { + const f = Foo { a: 0u32 }; + } +} + +function main() { + const b = Bar::bar(); +} \ No newline at end of file diff --git a/tests/compiler/circuits/duplicate_name_context.leo b/tests/compiler/circuits/duplicate_name_context.leo new file mode 100644 index 0000000000..8644d27fcb --- /dev/null +++ b/tests/compiler/circuits/duplicate_name_context.leo @@ -0,0 +1,13 @@ +circuit Bar { + b2: u32 + + function add_five(z:u32) -> u32 { + return z+5u32; + } +} + +function main () { + const Bar = 66u32; + const k1 = Bar{ b2: 30u32 }; + const k2 = Bar::add_five(55u32); +} \ No newline at end of file diff --git a/tests/compiler/circuits/inline.leo b/tests/compiler/circuits/inline.leo new file mode 100644 index 0000000000..9ba06f4191 --- /dev/null +++ b/tests/compiler/circuits/inline.leo @@ -0,0 +1,7 @@ +circuit Foo { + x: u32 +} + +function main() { + const a = Foo { x: 1u32 }; +} \ No newline at end of file diff --git a/tests/compiler/circuits/inline_fail.leo b/tests/compiler/circuits/inline_fail.leo new file mode 100644 index 0000000000..01597005fb --- /dev/null +++ b/tests/compiler/circuits/inline_fail.leo @@ -0,0 +1,7 @@ +circuit Foo { + x: u32 +} + +function main() { + const a = Foo { y: 0u32 }; +} \ No newline at end of file diff --git a/tests/compiler/circuits/inline_member_fail.leo b/tests/compiler/circuits/inline_member_fail.leo new file mode 100644 index 0000000000..59f6d7992b --- /dev/null +++ b/tests/compiler/circuits/inline_member_fail.leo @@ -0,0 +1,8 @@ +circuit Foo { + x: u8 +} + +function main() { + const y: u8 = 1; + const a = Foo { y }; +} \ No newline at end of file diff --git a/tests/compiler/circuits/inline_member_pass.leo b/tests/compiler/circuits/inline_member_pass.leo new file mode 100644 index 0000000000..6fd7f7dff7 --- /dev/null +++ b/tests/compiler/circuits/inline_member_pass.leo @@ -0,0 +1,13 @@ +circuit Foo { + x: u8 + + function new(x: u8) -> Self { + return Self { x }; + } +} + +function main() { + const x: u8 = 1; + const a = Foo { x }; + const b = Foo::new(x); +} \ No newline at end of file diff --git a/tests/compiler/circuits/inline_undefined.leo b/tests/compiler/circuits/inline_undefined.leo new file mode 100644 index 0000000000..40c4cf722c --- /dev/null +++ b/tests/compiler/circuits/inline_undefined.leo @@ -0,0 +1,3 @@ +function main() { + const a = Foo { }; +} \ No newline at end of file diff --git a/tests/compiler/circuits/member_function.leo b/tests/compiler/circuits/member_function.leo new file mode 100644 index 0000000000..eee44be448 --- /dev/null +++ b/tests/compiler/circuits/member_function.leo @@ -0,0 +1,13 @@ +circuit Foo { + x: u32, + + function echo(self) -> u32 { + return self.x; + } +} + +function main() { + const a = Foo { x: 1u32 }; + + console.assert(a.echo() == 1u32); +} \ No newline at end of file diff --git a/tests/compiler/circuits/member_function_fail.leo b/tests/compiler/circuits/member_function_fail.leo new file mode 100644 index 0000000000..57b15383a3 --- /dev/null +++ b/tests/compiler/circuits/member_function_fail.leo @@ -0,0 +1,10 @@ +circuit Foo { + function echo(x: u32) -> u32 { + return x; + } +} + +function main() { + const a = Foo { }; + const err = a.echoed(1u32); +} \ No newline at end of file diff --git a/tests/compiler/circuits/member_function_invalid.leo b/tests/compiler/circuits/member_function_invalid.leo new file mode 100644 index 0000000000..7283cf144d --- /dev/null +++ b/tests/compiler/circuits/member_function_invalid.leo @@ -0,0 +1,10 @@ +circuit Foo { + function echo(x: u32) -> u32 { + return x; + } +} + +function main() { + const a = Foo { }; + const err = a.echo(1u32); // echo is a static function and must be accessed using `::` +} \ No newline at end of file diff --git a/tests/compiler/circuits/member_function_nested.leo b/tests/compiler/circuits/member_function_nested.leo new file mode 100644 index 0000000000..b8bf172947 --- /dev/null +++ b/tests/compiler/circuits/member_function_nested.leo @@ -0,0 +1,18 @@ +circuit Foo { + x: u32, + + function add_x(self, y: u32) -> u32 { + return self.x + y; + } + + function call_add_x(self, y: u32) -> u32 { + return self.add_x(y); + } +} + +function main() { + const a = Foo { x: 1u32 }; + const b = a.add_x(1u32); + + console.assert(b == 2u32); +} diff --git a/tests/compiler/circuits/member_static_function.leo b/tests/compiler/circuits/member_static_function.leo new file mode 100644 index 0000000000..68f6065754 --- /dev/null +++ b/tests/compiler/circuits/member_static_function.leo @@ -0,0 +1,11 @@ +circuit Foo { + function echo(x: u32) -> u32 { + return x; + } +} + +function main() { + const a = Foo::echo(1u32); + + console.assert(a == 1u32); +} \ No newline at end of file diff --git a/tests/compiler/circuits/member_static_function_invalid.leo b/tests/compiler/circuits/member_static_function_invalid.leo new file mode 100644 index 0000000000..b886cff8fa --- /dev/null +++ b/tests/compiler/circuits/member_static_function_invalid.leo @@ -0,0 +1,9 @@ +circuit Foo { + function echo(x: u32) -> u32 { + return x; + } +} + +function main() { + const err = Foo.echo(1u32); // Invalid, echo is a static function and must be accessed using `::` +} \ No newline at end of file diff --git a/tests/compiler/circuits/member_static_function_nested.leo b/tests/compiler/circuits/member_static_function_nested.leo new file mode 100644 index 0000000000..ef536e3f6e --- /dev/null +++ b/tests/compiler/circuits/member_static_function_nested.leo @@ -0,0 +1,15 @@ +circuit Foo { + function qux() {} + + function bar() { + Self::qux(); + } + + function baz() { + Self::bar(); + } +} + +function main() { + Foo::baz(); +} \ No newline at end of file diff --git a/tests/compiler/circuits/member_static_function_undefined.leo b/tests/compiler/circuits/member_static_function_undefined.leo new file mode 100644 index 0000000000..121c80e34c --- /dev/null +++ b/tests/compiler/circuits/member_static_function_undefined.leo @@ -0,0 +1,9 @@ +circuit Foo { + function echo(x: u32) -> u32 { + return x; + } +} + +function main() { + const err = Foo::echoed(1u32); +} \ No newline at end of file diff --git a/tests/compiler/circuits/member_variable.leo b/tests/compiler/circuits/member_variable.leo new file mode 100644 index 0000000000..a3f3fbe7e6 --- /dev/null +++ b/tests/compiler/circuits/member_variable.leo @@ -0,0 +1,9 @@ +circuit Foo { + x: u32, +} + +function main() { + const a = Foo { x: 1u32 }; + + console.assert(a.x == 1u32); +} \ No newline at end of file diff --git a/tests/compiler/circuits/member_variable_and_function.leo b/tests/compiler/circuits/member_variable_and_function.leo new file mode 100644 index 0000000000..f90cdca072 --- /dev/null +++ b/tests/compiler/circuits/member_variable_and_function.leo @@ -0,0 +1,15 @@ +circuit Foo { + foo: u32, + + function bar() -> u32 { + return 1u32; + } +} + +function main() { + const a = Foo { foo: 1 }; + + const b = a.foo + Foo::bar(); + + console.assert(b == 2u32); +} diff --git a/tests/compiler/circuits/member_variable_fail.leo b/tests/compiler/circuits/member_variable_fail.leo new file mode 100644 index 0000000000..fdf42068d5 --- /dev/null +++ b/tests/compiler/circuits/member_variable_fail.leo @@ -0,0 +1,9 @@ +circuit Foo { + x: u32 +} + +function main() { + const a = Foo { x: 1u32 }; + + const err = a.y; +} \ No newline at end of file diff --git a/tests/compiler/circuits/mod.rs b/tests/compiler/circuits/mod.rs new file mode 100644 index 0000000000..093e2263e1 --- /dev/null +++ b/tests/compiler/circuits/mod.rs @@ -0,0 +1,318 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{assert_satisfied, expect_asg_error, parse_program}; + +// Expressions + +#[test] +fn test_inline() { + let program_string = include_str!("inline.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_inline_fail() { + let program_string = include_str!("inline_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_inline_undefined() { + let program_string = include_str!("inline_undefined.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +// Members + +#[test] +fn test_member_variable() { + let program_string = include_str!("member_variable.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_member_variable_fail() { + let program_string = include_str!("member_variable_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_member_variable_and_function() { + let program_string = include_str!("member_variable_and_function.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_member_function() { + let program_string = include_str!("member_function.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_member_function_fail() { + let program_string = include_str!("member_function_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_member_function_invalid() { + let program_string = include_str!("member_function_invalid.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_member_function_nested() { + let program_string = include_str!("member_function_nested.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_member_static_function() { + let program_string = include_str!("member_static_function.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_member_static_function_nested() { + let program_string = include_str!("member_static_function_nested.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_member_static_function_invalid() { + let program_string = include_str!("member_static_function_invalid.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error) +} + +#[test] +fn test_member_static_function_undefined() { + let program_string = include_str!("member_static_function_undefined.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error) +} + +// Constant +#[test] +fn test_const_self_variable() { + let program_string = include_str!("const_self_variable.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_const_self_variable_fail() { + let program_string = include_str!("const_self_variable_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +// Mutability + +#[test] +fn test_mutate_function_fail() { + let program_string = include_str!("mut_function_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_mutate_self_variable() { + let program_string = include_str!("mut_self_variable.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_mutate_self_variable_branch() { + let program_string = include_str!("mut_self_variable_branch.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_mutate_self_variable_conditional() { + let program_string = include_str!("mut_self_variable_conditional.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_mutate_self_variable_fail() { + let program_string = include_str!("mut_self_variable_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_mutate_self_function_fail() { + let program_string = include_str!("mut_self_function_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_mutate_self_static_function_fail() { + let program_string = include_str!("mut_self_static_function_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_mutate_static_function_fail() { + let program_string = include_str!("mut_static_function_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_mutate_variable() { + let program_string = include_str!("mut_variable.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_mutate_variable_fail() { + let program_string = include_str!("mut_variable_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +// Self + +#[test] +fn test_self_fail() { + let program_string = include_str!("self_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_self_member_pass() { + let program_string = include_str!("self_member.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_self_member_invalid() { + let program_string = include_str!("self_member_invalid.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_self_member_undefined() { + let program_string = include_str!("self_member_undefined.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +// Inline circuit member + +#[test] +fn test_inline_member_pass() { + let program_string = include_str!("inline_member_pass.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_inline_member_fail() { + let program_string = include_str!("inline_member_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +// All + +#[test] +fn test_pedersen_mock() { + let program_string = include_str!("pedersen_mock.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_define_circuit_inside_circuit_function() { + let program_string = include_str!("define_circuit_inside_circuit_function.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_duplicate_name_context() { + let program_string = include_str!("duplicate_name_context.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_mutable_call_immutable_context() { + let program_string = include_str!("mutable_call_immutable_context.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} diff --git a/tests/compiler/circuits/mut_function_fail.leo b/tests/compiler/circuits/mut_function_fail.leo new file mode 100644 index 0000000000..44583810dd --- /dev/null +++ b/tests/compiler/circuits/mut_function_fail.leo @@ -0,0 +1,11 @@ +circuit Foo { + a: u8, + + function bar() {} +} + +function main() { + let f = Foo { a: 0u8 }; + + f.bar = 1u8; +} \ No newline at end of file diff --git a/tests/compiler/circuits/mut_self_function_fail.leo b/tests/compiler/circuits/mut_self_function_fail.leo new file mode 100644 index 0000000000..b81b18e743 --- /dev/null +++ b/tests/compiler/circuits/mut_self_function_fail.leo @@ -0,0 +1,15 @@ +circuit Foo { + a: u8, + + function bar() {} + + function set_a(mut self, new: u8) { + self.bar = new; + } +} + +function main() { + let f = Foo { a: 0u8 }; + + f.set_a(1u8); +} \ No newline at end of file diff --git a/tests/compiler/circuits/mut_self_static_function_fail.leo b/tests/compiler/circuits/mut_self_static_function_fail.leo new file mode 100644 index 0000000000..b81b18e743 --- /dev/null +++ b/tests/compiler/circuits/mut_self_static_function_fail.leo @@ -0,0 +1,15 @@ +circuit Foo { + a: u8, + + function bar() {} + + function set_a(mut self, new: u8) { + self.bar = new; + } +} + +function main() { + let f = Foo { a: 0u8 }; + + f.set_a(1u8); +} \ No newline at end of file diff --git a/tests/compiler/circuits/mut_self_variable.leo b/tests/compiler/circuits/mut_self_variable.leo new file mode 100644 index 0000000000..dc2047d872 --- /dev/null +++ b/tests/compiler/circuits/mut_self_variable.leo @@ -0,0 +1,22 @@ +circuit Foo { + a: u8, + + function set_a(mut self, new: u8) { + self.a = new; + console.assert(self.a == new); + } +} + +function main() { + let f = Foo { a: 0u8 }; + + console.assert(f.a == 0u8); + + f.set_a(1u8); + + console.assert(f.a == 1u8); + + f.set_a(2u8); + + console.assert(f.a == 2u8); +} \ No newline at end of file diff --git a/tests/compiler/circuits/mut_self_variable_branch.leo b/tests/compiler/circuits/mut_self_variable_branch.leo new file mode 100644 index 0000000000..1c2f126f08 --- /dev/null +++ b/tests/compiler/circuits/mut_self_variable_branch.leo @@ -0,0 +1,32 @@ +circuit Foo { + a: u8, + + function set_a(mut self, condition: bool, new: u8) { + if condition { + self.a = new; + console.assert(self.a == new); + } + } +} + +function main() { + let f = Foo { a: 0u8 }; + + console.assert(f.a == 0u8); + + f.set_a(false, 1u8); + + console.assert(f.a == 0u8); + + f.set_a(true, 1u8); + + console.assert(f.a == 1u8); + + f.set_a(false, 2u8); + + console.assert(f.a == 1u8); + + f.set_a(true, 2u8); + + console.assert(f.a == 2u8); +} \ No newline at end of file diff --git a/tests/compiler/circuits/mut_self_variable_conditional.leo b/tests/compiler/circuits/mut_self_variable_conditional.leo new file mode 100644 index 0000000000..61a5e354dc --- /dev/null +++ b/tests/compiler/circuits/mut_self_variable_conditional.leo @@ -0,0 +1,15 @@ +function main() { + let f = Foo { a: 0u32 }; + + f.bar(); +} + +circuit Foo { + a: u32 + + function bar(mut self) { + if true { + self.a = 5u32; // Mutating a variable inside a conditional statement should work. + } + } +} \ No newline at end of file diff --git a/tests/compiler/circuits/mut_self_variable_fail.leo b/tests/compiler/circuits/mut_self_variable_fail.leo new file mode 100644 index 0000000000..4db62a4d3e --- /dev/null +++ b/tests/compiler/circuits/mut_self_variable_fail.leo @@ -0,0 +1,13 @@ +circuit Foo { + a: u8, + + function set_a(self, new: u8) { + self.a = new; + } +} + +function main() { + let f = Foo { a: 0u8 }; + + f.set_a(1u8); +} \ No newline at end of file diff --git a/tests/compiler/circuits/mut_static_function_fail.leo b/tests/compiler/circuits/mut_static_function_fail.leo new file mode 100644 index 0000000000..e7db3a1df9 --- /dev/null +++ b/tests/compiler/circuits/mut_static_function_fail.leo @@ -0,0 +1,9 @@ +circuit Foo { + function bar() {} +} + +function main() { + let f = Foo { a: 0u8 }; + + f.bar = 1u8; +} \ No newline at end of file diff --git a/tests/compiler/circuits/mut_variable.leo b/tests/compiler/circuits/mut_variable.leo new file mode 100644 index 0000000000..ddc7412038 --- /dev/null +++ b/tests/compiler/circuits/mut_variable.leo @@ -0,0 +1,17 @@ +circuit Foo { + a: u8, +} + +function main() { + let f = Foo { a: 0u8 }; + + console.assert(f.a == 0u8); + + f.a = 1u8; + + console.assert(f.a == 1u8); + + f.a = 2u8; + + console.assert(f.a == 2u8); +} \ No newline at end of file diff --git a/tests/compiler/circuits/mut_variable_fail.leo b/tests/compiler/circuits/mut_variable_fail.leo new file mode 100644 index 0000000000..e116b33d5c --- /dev/null +++ b/tests/compiler/circuits/mut_variable_fail.leo @@ -0,0 +1,9 @@ +circuit Foo { + a: u8, +} + +function main() { + const f = Foo { a: 0u8 }; + + f.a = 1u8; +} \ No newline at end of file diff --git a/tests/compiler/circuits/mutable_call_immutable_context.leo b/tests/compiler/circuits/mutable_call_immutable_context.leo new file mode 100644 index 0000000000..d235d11cb7 --- /dev/null +++ b/tests/compiler/circuits/mutable_call_immutable_context.leo @@ -0,0 +1,25 @@ +circuit TestMe { + x: u8, + + function test_me(mut self) -> u8 { + self.x += 1; + return self.x; + } + + function new() -> Self { + return Self { x: 1u8 }; + } +} + +function my_fn() -> TestMe { + return TestMe { x: 0u8 }; +} + +function main () { + const t = TestMe {x: 6u8}.test_me(); + console.assert(t == 7u8); + const u = my_fn().test_me(); + console.assert(u == 1u8); + const v = TestMe::new().test_me(); + console.assert(v == 2u8); +} \ No newline at end of file diff --git a/tests/compiler/circuits/pedersen_mock.leo b/tests/compiler/circuits/pedersen_mock.leo new file mode 100644 index 0000000000..0fc6752f2f --- /dev/null +++ b/tests/compiler/circuits/pedersen_mock.leo @@ -0,0 +1,27 @@ +circuit PedersenHash { + parameters: [u32; 512] + + function new(parameters: [u32; 512]) -> Self { + return Self { parameters: parameters }; + } + + function hash(self, bits: [bool; 512]) -> u32 { + let digest: u32 = 0; + for i in 0..512 { + const base = bits[i] ? self.parameters[i] : 0u32; + digest += base; + } + return digest; + } +} + +// The 'pedersen_hash' main function. +function main() { + const parameters = [0u32; 512]; + const pedersen = PedersenHash::new(parameters); + const hash_input: [bool; 512] = [true; 512]; + + const res = pedersen.hash(hash_input); + + console.assert(res == 0u32); +} diff --git a/tests/compiler/circuits/self_circuit.leo b/tests/compiler/circuits/self_circuit.leo new file mode 100644 index 0000000000..6faa42278b --- /dev/null +++ b/tests/compiler/circuits/self_circuit.leo @@ -0,0 +1,9 @@ +circuit Foo { + static function new() -> Self { + return Self { }; + } +} + +function main() { + const a = Foo::new(); +} \ No newline at end of file diff --git a/tests/compiler/circuits/self_fail.leo b/tests/compiler/circuits/self_fail.leo new file mode 100644 index 0000000000..e4e878dc89 --- /dev/null +++ b/tests/compiler/circuits/self_fail.leo @@ -0,0 +1,3 @@ +function main() { + Self::main(); +} \ No newline at end of file diff --git a/tests/compiler/circuits/self_member.leo b/tests/compiler/circuits/self_member.leo new file mode 100644 index 0000000000..237baac9de --- /dev/null +++ b/tests/compiler/circuits/self_member.leo @@ -0,0 +1,14 @@ +circuit Foo { + f: u32, + + function bar(self) -> u32 { + return self.f; + } +} + +function main() { + const a = Foo { f: 1u32 }; + const b = a.bar(); + + console.assert(b == 1u32); +} \ No newline at end of file diff --git a/tests/compiler/circuits/self_member_invalid.leo b/tests/compiler/circuits/self_member_invalid.leo new file mode 100644 index 0000000000..7283b3260a --- /dev/null +++ b/tests/compiler/circuits/self_member_invalid.leo @@ -0,0 +1,12 @@ +circuit Foo { + f: u32, + + function bar() -> u32 { + return f; + } +} + +function main() -> u32 { + const foo = Foo { f: 1u32 }; + const err = foo.bar(); +} \ No newline at end of file diff --git a/tests/compiler/circuits/self_member_undefined.leo b/tests/compiler/circuits/self_member_undefined.leo new file mode 100644 index 0000000000..8b52d305a3 --- /dev/null +++ b/tests/compiler/circuits/self_member_undefined.leo @@ -0,0 +1,10 @@ +circuit Foo { + function bar() -> u32 { + return self.f; + } +} + +function main() { + const foo = Foo { }; + const err = foo.bar(); +} \ No newline at end of file diff --git a/tests/compiler/console/assert.leo b/tests/compiler/console/assert.leo new file mode 100644 index 0000000000..ba6be77256 --- /dev/null +++ b/tests/compiler/console/assert.leo @@ -0,0 +1,3 @@ +function main(a: bool) { + console.assert(a == true); +} \ No newline at end of file diff --git a/tests/compiler/console/conditional_assert.leo b/tests/compiler/console/conditional_assert.leo new file mode 100644 index 0000000000..f2c1591e9c --- /dev/null +++ b/tests/compiler/console/conditional_assert.leo @@ -0,0 +1,7 @@ +function main(a: bool) { + if a { + console.assert(a == true); + } else { + console.assert(a == false); + } +} \ No newline at end of file diff --git a/tests/compiler/console/debug.leo b/tests/compiler/console/debug.leo new file mode 100644 index 0000000000..54e6eb539f --- /dev/null +++ b/tests/compiler/console/debug.leo @@ -0,0 +1,3 @@ +function main() { + console.debug("hello debug"); +} \ No newline at end of file diff --git a/tests/compiler/console/error.leo b/tests/compiler/console/error.leo new file mode 100644 index 0000000000..86d13f8cee --- /dev/null +++ b/tests/compiler/console/error.leo @@ -0,0 +1,3 @@ +function main() { + console.error("hello error"); +} \ No newline at end of file diff --git a/tests/compiler/console/input/input_equal.in b/tests/compiler/console/input/input_equal.in new file mode 100644 index 0000000000..c147902071 --- /dev/null +++ b/tests/compiler/console/input/input_equal.in @@ -0,0 +1,3 @@ +[main] +a: u32 = 1; +b: u32 = 1; diff --git a/tests/compiler/console/input/input_unequal.in b/tests/compiler/console/input/input_unequal.in new file mode 100644 index 0000000000..37e9e6a578 --- /dev/null +++ b/tests/compiler/console/input/input_unequal.in @@ -0,0 +1,3 @@ +[main] +a: u32 = 1; +b: u32 = 0; diff --git a/tests/compiler/console/log.leo b/tests/compiler/console/log.leo new file mode 100644 index 0000000000..a190ca4ba9 --- /dev/null +++ b/tests/compiler/console/log.leo @@ -0,0 +1,3 @@ +function main() { + console.log("hello world"); +} \ No newline at end of file diff --git a/tests/compiler/console/log_conditional.leo b/tests/compiler/console/log_conditional.leo new file mode 100644 index 0000000000..a9fdb6e698 --- /dev/null +++ b/tests/compiler/console/log_conditional.leo @@ -0,0 +1,6 @@ +// Conditionally add two u32 integers and log the result to the console. +function main(a: u32, b: u32) { + if a == b { + console.log("{}=={}",a,b); // This line should not fail. + } +} \ No newline at end of file diff --git a/tests/compiler/console/log_fail.leo b/tests/compiler/console/log_fail.leo new file mode 100644 index 0000000000..dafa6bea8e --- /dev/null +++ b/tests/compiler/console/log_fail.leo @@ -0,0 +1,3 @@ +function main() { + console.log( hello ); +} \ No newline at end of file diff --git a/tests/compiler/console/log_input.leo b/tests/compiler/console/log_input.leo new file mode 100644 index 0000000000..c4fd0a8b12 --- /dev/null +++ b/tests/compiler/console/log_input.leo @@ -0,0 +1,3 @@ +function main(a: bool) { + console.log("a = {}", a); +} \ No newline at end of file diff --git a/tests/compiler/console/log_parameter.leo b/tests/compiler/console/log_parameter.leo new file mode 100644 index 0000000000..ebcb931a2b --- /dev/null +++ b/tests/compiler/console/log_parameter.leo @@ -0,0 +1,3 @@ +function main() { + console.log("{}", 1u32); +} \ No newline at end of file diff --git a/tests/compiler/console/log_parameter_fail_empty.leo b/tests/compiler/console/log_parameter_fail_empty.leo new file mode 100644 index 0000000000..81b42c0919 --- /dev/null +++ b/tests/compiler/console/log_parameter_fail_empty.leo @@ -0,0 +1,3 @@ +function main() { + console.log("{}"); +} \ No newline at end of file diff --git a/tests/compiler/console/log_parameter_fail_none.leo b/tests/compiler/console/log_parameter_fail_none.leo new file mode 100644 index 0000000000..c92fdfbb2d --- /dev/null +++ b/tests/compiler/console/log_parameter_fail_none.leo @@ -0,0 +1,3 @@ +function main() { + console.log("", 1u32); +} \ No newline at end of file diff --git a/tests/compiler/console/log_parameter_fail_unknown.leo b/tests/compiler/console/log_parameter_fail_unknown.leo new file mode 100644 index 0000000000..757f4c27c3 --- /dev/null +++ b/tests/compiler/console/log_parameter_fail_unknown.leo @@ -0,0 +1,3 @@ +function main() { + console.log("{}", a); +} \ No newline at end of file diff --git a/tests/compiler/console/log_parameter_many.leo b/tests/compiler/console/log_parameter_many.leo new file mode 100644 index 0000000000..60455ebbb0 --- /dev/null +++ b/tests/compiler/console/log_parameter_many.leo @@ -0,0 +1,3 @@ +function main() { + console.log("{} {}", 1u32, true); +} \ No newline at end of file diff --git a/tests/compiler/console/mod.rs b/tests/compiler/console/mod.rs new file mode 100644 index 0000000000..d3ce931675 --- /dev/null +++ b/tests/compiler/console/mod.rs @@ -0,0 +1,169 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + parse_program, + parse_program_with_input, +}; +use leo_ast::InputValue; + +#[test] +fn test_log() { + let program_string = include_str!("log.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_log_fail() { + let program_string = include_str!("log_fail.leo"); + + assert!(parse_program(program_string).is_err()); +} + +#[test] +fn test_log_parameter() { + let program_string = include_str!("log_parameter.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_log_parameter_many() { + let program_string = include_str!("log_parameter_many.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_log_parameter_fail_empty() { + let program_string = include_str!("log_parameter_fail_empty.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_log_parameter_fail_none() { + let program_string = include_str!("log_parameter_fail_empty.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_log_parameter_fail_unknown() { + let program_string = include_str!("log_parameter_fail_unknown.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_log_input() { + let program_string = include_str!("log_input.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]); + + program.set_main_input(main_input); + + assert_satisfied(program); +} + +#[test] +fn test_log_conditional() { + let program_string = include_str!("log_conditional.leo"); + let input_equal_string = include_str!("input/input_equal.in"); + + let program = parse_program_with_input(program_string, input_equal_string).unwrap(); + + assert_satisfied(program); + + let input_unequal_string = include_str!("input/input_unequal.in"); + + let program = parse_program_with_input(program_string, input_unequal_string).unwrap(); + + assert_satisfied(program); +} + +// Debug + +#[test] +fn test_debug() { + let program_string = include_str!("debug.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +// Error + +#[test] +fn test_error() { + let program_string = include_str!("error.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +// Assertion + +#[test] +fn test_assert() { + let program_string = include_str!("assert.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]); + + program.set_main_input(main_input); + + assert_satisfied(program); + + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(false)))]); + + program.set_main_input(main_input); + + expect_compiler_error(program); +} + +#[test] +fn test_conditional_assert() { + let program_string = include_str!("conditional_assert.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]); + program.set_main_input(main_input); + + assert_satisfied(program); + + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(false)))]); + + program.set_main_input(main_input); + + assert_satisfied(program); +} diff --git a/tests/compiler/core/core_circuit_invalid.leo b/tests/compiler/core/core_circuit_invalid.leo new file mode 100644 index 0000000000..4a42bda032 --- /dev/null +++ b/tests/compiler/core/core_circuit_invalid.leo @@ -0,0 +1,3 @@ +import core.unstable.blake2s.BadCircuit; // `BadCircuit` is not included in the blake2s package + +function main() {} diff --git a/tests/compiler/core/core_circuit_star_fail.leo b/tests/compiler/core/core_circuit_star_fail.leo new file mode 100644 index 0000000000..14b54b0d69 --- /dev/null +++ b/tests/compiler/core/core_circuit_star_fail.leo @@ -0,0 +1,3 @@ +import core.*; // You cannot import all dependencies from core at once + +function main() {} diff --git a/tests/compiler/core/core_package_invalid.leo b/tests/compiler/core/core_package_invalid.leo new file mode 100644 index 0000000000..7cbcf93ecc --- /dev/null +++ b/tests/compiler/core/core_package_invalid.leo @@ -0,0 +1,3 @@ +import core.bad_circuit; // `bad_circuit` is not a core package + +function main() {} diff --git a/tests/compiler/core/core_unstable_package_invalid.leo b/tests/compiler/core/core_unstable_package_invalid.leo new file mode 100644 index 0000000000..35e6c0d1ba --- /dev/null +++ b/tests/compiler/core/core_unstable_package_invalid.leo @@ -0,0 +1,3 @@ +import core.unstable.bad_circuit; // `bad_circuit` is not a core unstable package + +function main() {} diff --git a/tests/compiler/core/mod.rs b/tests/compiler/core/mod.rs new file mode 100644 index 0000000000..c4a6bb48a5 --- /dev/null +++ b/tests/compiler/core/mod.rs @@ -0,0 +1,59 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +pub mod packages; + +use crate::{assert_satisfied, expect_asg_error, parse_program}; + +#[test] +fn test_core_circuit_invalid() { + let program_string = include_str!("core_package_invalid.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_core_circuit_star_fail() { + let program_string = include_str!("core_circuit_star_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_core_package_invalid() { + let program_string = include_str!("core_package_invalid.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_core_unstable_package_invalid() { + let program_string = include_str!("core_unstable_package_invalid.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_unstable_blake2s_sanity() { + let program_string = include_str!("unstable_blake2s.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} diff --git a/tests/compiler/core/packages/mod.rs b/tests/compiler/core/packages/mod.rs new file mode 100644 index 0000000000..6093aa3391 --- /dev/null +++ b/tests/compiler/core/packages/mod.rs @@ -0,0 +1,17 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +pub mod unstable; diff --git a/tests/compiler/core/packages/unstable/blake2s/arguments_length_fail.leo b/tests/compiler/core/packages/unstable/blake2s/arguments_length_fail.leo new file mode 100644 index 0000000000..614490432d --- /dev/null +++ b/tests/compiler/core/packages/unstable/blake2s/arguments_length_fail.leo @@ -0,0 +1,9 @@ +import core.unstable.blake2s.Blake2s; + +function main() { + const seed: [u8; 32] = [0; 32]; + + const result = Blake2s::hash(seed); // function `hash` takes 2 arguments + + console.log("Result: {}", result); +} diff --git a/tests/compiler/core/packages/unstable/blake2s/arguments_type_fail.leo b/tests/compiler/core/packages/unstable/blake2s/arguments_type_fail.leo new file mode 100644 index 0000000000..f80e7b0205 --- /dev/null +++ b/tests/compiler/core/packages/unstable/blake2s/arguments_type_fail.leo @@ -0,0 +1,10 @@ +import core.unstable.blake2s.Blake2s; + +function main() { + const seed: [u8; 32] = [0; 32]; + const message: [u16; 32] = [0; 32]; // message should be type [u8; 32] + + const result = Blake2s::hash(seed, message); + + console.log("Result: {}", result); +} diff --git a/tests/compiler/core/packages/unstable/blake2s/blake2s_input.leo b/tests/compiler/core/packages/unstable/blake2s/blake2s_input.leo new file mode 100644 index 0000000000..51de777341 --- /dev/null +++ b/tests/compiler/core/packages/unstable/blake2s/blake2s_input.leo @@ -0,0 +1,5 @@ +import core.unstable.blake2s.Blake2s; + +function main(seed: [u8; 32], message: [u8; 32]) -> [u8; 32] { + return Blake2s::hash(seed, message); +} diff --git a/tests/compiler/core/packages/unstable/blake2s/blake2s_random.leo b/tests/compiler/core/packages/unstable/blake2s/blake2s_random.leo new file mode 100644 index 0000000000..c9592fcbf8 --- /dev/null +++ b/tests/compiler/core/packages/unstable/blake2s/blake2s_random.leo @@ -0,0 +1,7 @@ +import core.unstable.blake2s.Blake2s; + +function main(seed: [u8; 32], message: [u8; 32], expected: [u8; 32]) { + const actual = Blake2s::hash(seed, message); + + console.assert(expected == actual); +} diff --git a/tests/compiler/core/packages/unstable/blake2s/inputs/valid_input.in b/tests/compiler/core/packages/unstable/blake2s/inputs/valid_input.in new file mode 100644 index 0000000000..6f5064f41d --- /dev/null +++ b/tests/compiler/core/packages/unstable/blake2s/inputs/valid_input.in @@ -0,0 +1,6 @@ +[main] +seed: [u8; 32] = [0; 32]; +message: [u8; 32] = [0; 32]; + +[registers] +r0: [u8; 32] = [0; 32]; \ No newline at end of file diff --git a/tests/compiler/core/packages/unstable/blake2s/mod.rs b/tests/compiler/core/packages/unstable/blake2s/mod.rs new file mode 100644 index 0000000000..ce9a23b2f3 --- /dev/null +++ b/tests/compiler/core/packages/unstable/blake2s/mod.rs @@ -0,0 +1,106 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{ + assert_satisfied, + expect_asg_error, + generate_main_input, + get_output, + parse_program, + parse_program_with_input, +}; + +use leo_ast::InputValue; +use leo_input::types::{IntegerType, U8Type, UnsignedIntegerType}; +use rand::Rng; +use rand_core::SeedableRng; +use rand_xorshift::XorShiftRng; +use snarkvm_algorithms::{prf::blake2s::Blake2s as B2SPRF, traits::PRF}; + +#[test] +fn test_arguments_length_fail() { + let program_string = include_str!("arguments_length_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_arguments_type_fail() { + let program_string = include_str!("arguments_type_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_blake2s_input() { + let input_string = include_str!("inputs/valid_input.in"); + let program_string = include_str!("blake2s_input.leo"); + let expected_string = include_str!("outputs/valid_output.out"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + let actual_bytes = get_output(program); + let actual_string = std::str::from_utf8(actual_bytes.bytes().as_slice()).unwrap(); + + assert_eq!(expected_string, actual_string) +} + +#[test] +fn test_blake2s_random() { + let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + + let mut seed = [0u8; 32]; + rng.fill(&mut seed); + + let mut message = [0u8; 32]; + rng.fill(&mut message); + + // Use snarkvm-algorithms blake2s evaluate to get expected value + let expected = B2SPRF::evaluate(&seed, &message).unwrap().to_vec(); + + // Create program input values for seed, message, and expected values + let seed_input_value = bytes_gadget_to_input(seed.to_vec()); + let message_input_value = bytes_gadget_to_input(message.to_vec()); + let expected_value = bytes_gadget_to_input(expected); + + // The `blake2s_random.leo` program will compute a blake2s hash digest and compare it against + // the expected value + let bytes = include_str!("blake2s_random.leo"); + let mut program = parse_program(bytes).unwrap(); + + let main_input = generate_main_input(vec![ + ("seed", Some(seed_input_value)), + ("message", Some(message_input_value)), + ("expected", Some(expected_value)), + ]); + + // Load input values into Leo program + program.set_main_input(main_input); + + assert_satisfied(program); +} + +fn bytes_gadget_to_input(bytes: Vec) -> InputValue { + let u8_type = IntegerType::Unsigned(UnsignedIntegerType::U8Type(U8Type {})); + let bytes = bytes + .into_iter() + .map(|byte| InputValue::Integer(u8_type.clone(), byte.to_string())) + .collect::>(); + + InputValue::Array(bytes) +} diff --git a/tests/compiler/core/packages/unstable/blake2s/outputs/valid_output.out b/tests/compiler/core/packages/unstable/blake2s/outputs/valid_output.out new file mode 100644 index 0000000000..f8f60f3e4e --- /dev/null +++ b/tests/compiler/core/packages/unstable/blake2s/outputs/valid_output.out @@ -0,0 +1,2 @@ +[registers] +r0: [u8; 32] = [174, 9, 219, 124, 213, 79, 66, 180, 144, 239, 9, 182, 188, 84, 26, 246, 136, 228, 149, 155, 184, 197, 63, 53, 154, 111, 86, 227, 138, 180, 84, 163]; diff --git a/tests/compiler/core/packages/unstable/mod.rs b/tests/compiler/core/packages/unstable/mod.rs new file mode 100644 index 0000000000..16304197fe --- /dev/null +++ b/tests/compiler/core/packages/unstable/mod.rs @@ -0,0 +1,17 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +pub mod blake2s; diff --git a/tests/compiler/core/unstable_blake2s.leo b/tests/compiler/core/unstable_blake2s.leo new file mode 100644 index 0000000000..c430d9a837 --- /dev/null +++ b/tests/compiler/core/unstable_blake2s.leo @@ -0,0 +1,10 @@ +import core.unstable.blake2s.Blake2s; + +function main() { + const seed: [u8; 32] = [0; 32]; + const message: [u8; 32] = [0; 32]; + + const result = Blake2s::hash(seed, message); + + console.log("Result: {}", result); +} diff --git a/tests/compiler/definition/mod.rs b/tests/compiler/definition/mod.rs new file mode 100644 index 0000000000..e5faf8b2de --- /dev/null +++ b/tests/compiler/definition/mod.rs @@ -0,0 +1,38 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{assert_satisfied, import::set_local_dir, parse_program}; + +#[test] +fn test_out_of_order() { + let program_string = include_str!("out_of_order.leo"); + + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +#[ignore] +fn test_out_of_order_with_import() { + set_local_dir(); + + let program_string = include_str!("out_of_order_with_import.leo"); + + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} diff --git a/tests/compiler/definition/out_of_order.leo b/tests/compiler/definition/out_of_order.leo new file mode 100644 index 0000000000..69d46d0e74 --- /dev/null +++ b/tests/compiler/definition/out_of_order.leo @@ -0,0 +1,6 @@ +@test +function fake_test() {} + +function main() {} + +circuit Foo {} \ No newline at end of file diff --git a/tests/compiler/definition/out_of_order_with_import.leo b/tests/compiler/definition/out_of_order_with_import.leo new file mode 100644 index 0000000000..04e5ddf12b --- /dev/null +++ b/tests/compiler/definition/out_of_order_with_import.leo @@ -0,0 +1,7 @@ +test function fake_test() {} + +function main() {} + +import test_import.foo; + +circuit Foo {} \ No newline at end of file diff --git a/tests/compiler/field/add.leo b/tests/compiler/field/add.leo new file mode 100644 index 0000000000..8dc2c7df4e --- /dev/null +++ b/tests/compiler/field/add.leo @@ -0,0 +1,3 @@ +function main(a: field, b: field, c: field) { + console.assert(a + b == c); +} \ No newline at end of file diff --git a/tests/compiler/field/console_assert.leo b/tests/compiler/field/console_assert.leo new file mode 100644 index 0000000000..c7224bcea5 --- /dev/null +++ b/tests/compiler/field/console_assert.leo @@ -0,0 +1,3 @@ +function main(a: field, b: field) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/field/div.leo b/tests/compiler/field/div.leo new file mode 100644 index 0000000000..028b06fad2 --- /dev/null +++ b/tests/compiler/field/div.leo @@ -0,0 +1,3 @@ +function main(a: field, b: field, c: field) { + console.assert(a / b == c); +} \ No newline at end of file diff --git a/tests/compiler/field/eq.leo b/tests/compiler/field/eq.leo new file mode 100644 index 0000000000..e64307d8de --- /dev/null +++ b/tests/compiler/field/eq.leo @@ -0,0 +1,3 @@ +function main(a: field, b: field, c: bool) { + console.assert(a == b == c); +} \ No newline at end of file diff --git a/tests/compiler/field/field.leo b/tests/compiler/field/field.leo new file mode 100644 index 0000000000..5d5732e906 --- /dev/null +++ b/tests/compiler/field/field.leo @@ -0,0 +1,4 @@ +function main() { + const negOneField: field = -1field; + const oneField = 1field; +} \ No newline at end of file diff --git a/tests/compiler/field/input/register_one.in b/tests/compiler/field/input/register_one.in new file mode 100644 index 0000000000..50ca7c02dd --- /dev/null +++ b/tests/compiler/field/input/register_one.in @@ -0,0 +1,2 @@ +[registers] +r: field = 1; \ No newline at end of file diff --git a/tests/compiler/field/input/register_zero.in b/tests/compiler/field/input/register_zero.in new file mode 100644 index 0000000000..15d3fe0c68 --- /dev/null +++ b/tests/compiler/field/input/register_zero.in @@ -0,0 +1,2 @@ +[registers] +r: field = 0; \ No newline at end of file diff --git a/tests/compiler/field/mod.rs b/tests/compiler/field/mod.rs new file mode 100644 index 0000000000..f5ccb6c116 --- /dev/null +++ b/tests/compiler/field/mod.rs @@ -0,0 +1,369 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{assert_satisfied, expect_compiler_error, generate_main_input, parse_program}; +use leo_ast::InputValue; + +use snarkvm_curves::edwards_bls12::Fq; +use snarkvm_utilities::bytes::ToBytes; + +use num_bigint::BigUint; +use rand::{Rng, SeedableRng}; +use rand_xorshift::XorShiftRng; + +// Helper function to convert field element into decimal base 10 string +pub fn field_to_decimal_string(f: Fq) -> String { + // write field to buffer + + let mut buf = Vec::new(); + + f.write(&mut buf).unwrap(); + + // convert to big integer + + let f_bigint = BigUint::from_bytes_le(&buf); + + f_bigint.to_str_radix(10) +} + +#[test] +fn test_negate() { + use std::ops::Neg; + + let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + + for _ in 0..10 { + let a: Fq = rng.gen(); + let b = a.neg(); + + let a_string = field_to_decimal_string(a); + let b_string = field_to_decimal_string(b); + + let program_string = include_str!("negate.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Field(a_string))), + ("b", Some(InputValue::Field(b_string))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program) + } +} + +#[test] +fn test_field() { + let program_string = include_str!("field.leo"); + let mut program = parse_program(program_string).unwrap(); + + assert_satisfied(program) +} + +#[test] +fn test_no_space_between_literal() { + let program_string = include_str!("no_space_between_literal.leo"); + let mut program = parse_program(program_string).unwrap(); + + expect_compiler_error(program) +} + +#[test] +fn test_add() { + use std::ops::Add; + + let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + + for _ in 0..10 { + let a: Fq = rng.gen(); + let b: Fq = rng.gen(); + let c = a.add(&b); + + let a_string = field_to_decimal_string(a); + let b_string = field_to_decimal_string(b); + let c_string = field_to_decimal_string(c); + + let program_string = include_str!("add.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Field(a_string))), + ("b", Some(InputValue::Field(b_string))), + ("c", Some(InputValue::Field(c_string))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program) + } +} + +#[test] +fn test_sub() { + use std::ops::Sub; + + let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + + for _ in 0..10 { + let a: Fq = rng.gen(); + let b: Fq = rng.gen(); + let c = a.sub(&b); + + let a_string = field_to_decimal_string(a); + let b_string = field_to_decimal_string(b); + let c_string = field_to_decimal_string(c); + + let program_string = include_str!("sub.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Field(a_string))), + ("b", Some(InputValue::Field(b_string))), + ("c", Some(InputValue::Field(c_string))), + ]); + program.set_main_input(main_input); + + assert_satisfied(program) + } +} + +#[test] +fn test_div() { + use std::ops::Div; + + let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + + for _ in 0..10 { + let a: Fq = rng.gen(); + let b: Fq = rng.gen(); + let c = a.div(&b); + + let a_string = field_to_decimal_string(a); + let b_string = field_to_decimal_string(b); + let c_string = field_to_decimal_string(c); + + let program_string = include_str!("div.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Field(a_string))), + ("b", Some(InputValue::Field(b_string))), + ("c", Some(InputValue::Field(c_string))), + ]); + program.set_main_input(main_input); + + assert_satisfied(program) + } +} + +#[test] +fn test_mul() { + use std::ops::Mul; + + let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + + for _ in 0..10 { + let a: Fq = rng.gen(); + let b: Fq = rng.gen(); + let c = a.mul(&b); + + let a_string = field_to_decimal_string(a); + let b_string = field_to_decimal_string(b); + let c_string = field_to_decimal_string(c); + + let program_string = include_str!("mul.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Field(a_string))), + ("b", Some(InputValue::Field(b_string))), + ("c", Some(InputValue::Field(c_string))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program) + } +} + +#[test] +fn test_eq() { + let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + + for _ in 0..10 { + let a: Fq = rng.gen(); + let b: Fq = rng.gen(); + + let a_string = field_to_decimal_string(a); + let b_string = field_to_decimal_string(b); + + // test equal + + let program_string = include_str!("eq.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Field(a_string.clone()))), + ("b", Some(InputValue::Field(a_string.clone()))), + ("c", Some(InputValue::Boolean(true))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + + // test not equal + + let c = a.eq(&b); + + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Field(a_string))), + ("b", Some(InputValue::Field(b_string))), + ("c", Some(InputValue::Boolean(c))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } +} + +#[test] +fn test_console_assert_pass() { + let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + + for _ in 0..10 { + let a: Fq = rng.gen(); + + let a_string = field_to_decimal_string(a); + + let program_string = include_str!("console_assert.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Field(a_string.clone()))), + ("b", Some(InputValue::Field(a_string))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } +} + +#[test] +fn test_console_assert_fail() { + let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + + for _ in 0..10 { + let a: Fq = rng.gen(); + let b: Fq = rng.gen(); + + if a == b { + continue; + } + + let a_string = field_to_decimal_string(a); + let b_string = field_to_decimal_string(b); + + let program_string = include_str!("console_assert.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Field(a_string))), + ("b", Some(InputValue::Field(b_string))), + ]); + + program.set_main_input(main_input); + + expect_compiler_error(program); + } +} + +#[test] +fn test_ternary() { + let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + + let a: Fq = rng.gen(); + let b: Fq = rng.gen(); + + let a_string = field_to_decimal_string(a); + let b_string = field_to_decimal_string(b); + + let program_string = include_str!("ternary.leo"); + let mut program = parse_program(program_string).unwrap(); + + // true -> field a + let main_input = generate_main_input(vec![ + ("s", Some(InputValue::Boolean(true))), + ("a", Some(InputValue::Field(a_string.clone()))), + ("b", Some(InputValue::Field(b_string.clone()))), + ("c", Some(InputValue::Field(a_string.clone()))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + + let mut program = parse_program(program_string).unwrap(); + + // false -> field b + let main_input = generate_main_input(vec![ + ("s", Some(InputValue::Boolean(false))), + ("a", Some(InputValue::Field(a_string))), + ("b", Some(InputValue::Field(b_string.clone()))), + ("c", Some(InputValue::Field(b_string))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); +} + +// +// pub fn output_one(program: EdwardsTestCompiler) { +// let expected = include_str!("output_/register_one.out"); +// let actual = get_output(program); +// +// assert_eq!(expected, actual.program_string().as_slice()); +// } +// +// pub fn output_zero(program: EdwardsTestCompiler) { +// let expected = include_str!("output_/register_zero.out"); +// let actual = get_output(program); +// +// assert_eq!(expected, actual.program_string().as_slice()); +// } +// +// #[test] +// fn test_registers() { +// let program_bytes = include_str!("output_register.leo"); +// let one_input_bytes = include_str!("input/register_one.in"); +// let zero_input_bytes = include_str!("input/register_zero.in"); +// +// // test 1field input register => 1field output register +// let program = parse_program_with_input(program_bytes, one_input_bytes).unwrap(); +// +// output_one(program); +// +// // test 0field input register => 0field output register +// let program = parse_program_with_input(program_bytes, zero_input_bytes).unwrap(); +// +// output_zero(program); +// } diff --git a/tests/compiler/field/mul.leo b/tests/compiler/field/mul.leo new file mode 100644 index 0000000000..7df7c83830 --- /dev/null +++ b/tests/compiler/field/mul.leo @@ -0,0 +1,3 @@ +function main(a: field, b: field, c: field) { + console.assert(a * b == c); +} \ No newline at end of file diff --git a/tests/compiler/field/negate.leo b/tests/compiler/field/negate.leo new file mode 100644 index 0000000000..94c730207a --- /dev/null +++ b/tests/compiler/field/negate.leo @@ -0,0 +1,3 @@ +function main(a: field, b: field) { + console.assert(-a == b); +} \ No newline at end of file diff --git a/tests/compiler/field/no_space_between_literal.leo b/tests/compiler/field/no_space_between_literal.leo new file mode 100644 index 0000000000..9ac9dcd5db --- /dev/null +++ b/tests/compiler/field/no_space_between_literal.leo @@ -0,0 +1,3 @@ +function main() { + const f = 1 field; +} \ No newline at end of file diff --git a/tests/compiler/field/output/register_one.out b/tests/compiler/field/output/register_one.out new file mode 100644 index 0000000000..16556c1c51 --- /dev/null +++ b/tests/compiler/field/output/register_one.out @@ -0,0 +1,2 @@ +[registers] +r: field = 1; diff --git a/tests/compiler/field/output/register_zero.out b/tests/compiler/field/output/register_zero.out new file mode 100644 index 0000000000..2ba759ffc8 --- /dev/null +++ b/tests/compiler/field/output/register_zero.out @@ -0,0 +1,2 @@ +[registers] +r: field = 0; diff --git a/tests/compiler/field/output_register.leo b/tests/compiler/field/output_register.leo new file mode 100644 index 0000000000..e27a3947bd --- /dev/null +++ b/tests/compiler/field/output_register.leo @@ -0,0 +1,3 @@ +function main(registers) -> field { + return registers.r; +} \ No newline at end of file diff --git a/tests/compiler/field/sub.leo b/tests/compiler/field/sub.leo new file mode 100644 index 0000000000..2c84b24647 --- /dev/null +++ b/tests/compiler/field/sub.leo @@ -0,0 +1,3 @@ +function main(a: field, b: field, c: field) { + console.assert(a - b == c); +} \ No newline at end of file diff --git a/tests/compiler/field/ternary.leo b/tests/compiler/field/ternary.leo new file mode 100644 index 0000000000..05cb161b46 --- /dev/null +++ b/tests/compiler/field/ternary.leo @@ -0,0 +1,5 @@ +function main(s: bool, a: field, b: field, c: field) { + const r = s ? a : b; + + console.assert(r == c); +} \ No newline at end of file diff --git a/tests/compiler/function/array_input.leo b/tests/compiler/function/array_input.leo new file mode 100644 index 0000000000..899c0e4af6 --- /dev/null +++ b/tests/compiler/function/array_input.leo @@ -0,0 +1,6 @@ +function foo(a: [u8; 1]) {} + +function main() { + const a: [u16; 1] = [1; 1]; + foo(a); +} \ No newline at end of file diff --git a/tests/compiler/function/array_params_direct_call.leo b/tests/compiler/function/array_params_direct_call.leo new file mode 100644 index 0000000000..86762aabc7 --- /dev/null +++ b/tests/compiler/function/array_params_direct_call.leo @@ -0,0 +1,9 @@ +function do_nothing(arr: [u32; 2]) {} + +function main() { + const arr: [u32; 2] = [0; 2]; + + do_nothing(arr); + do_nothing([...arr]); + do_nothing(arr[0u32..]); +} \ No newline at end of file diff --git a/tests/compiler/function/conditional_return.leo b/tests/compiler/function/conditional_return.leo new file mode 100644 index 0000000000..e27dd7aea5 --- /dev/null +++ b/tests/compiler/function/conditional_return.leo @@ -0,0 +1,7 @@ +function main(x: u8) -> u8 { + if x == 2u8 { + return 3u8; + } else { + return 4u8; + } +} \ No newline at end of file diff --git a/tests/compiler/function/duplicate_definition.leo b/tests/compiler/function/duplicate_definition.leo new file mode 100644 index 0000000000..cddc9ce7f2 --- /dev/null +++ b/tests/compiler/function/duplicate_definition.leo @@ -0,0 +1,7 @@ +function main() { + console.log("{}", 1u8); +} + +function main() { + console.log("{}", 2u8); +} \ No newline at end of file diff --git a/tests/compiler/function/empty.leo b/tests/compiler/function/empty.leo new file mode 100644 index 0000000000..f06c976158 --- /dev/null +++ b/tests/compiler/function/empty.leo @@ -0,0 +1,5 @@ +function empty() { } + +function main() { + empty(); +} \ No newline at end of file diff --git a/tests/compiler/function/input/conditional_return.in b/tests/compiler/function/input/conditional_return.in new file mode 100644 index 0000000000..d2d57dc93c --- /dev/null +++ b/tests/compiler/function/input/conditional_return.in @@ -0,0 +1,5 @@ +[main] +x: u8 = 1u8; + +[registers] +x: u8 = 0; diff --git a/tests/compiler/function/input/newlines.in b/tests/compiler/function/input/newlines.in new file mode 100644 index 0000000000..fbd23658c0 --- /dev/null +++ b/tests/compiler/function/input/newlines.in @@ -0,0 +1,7 @@ +[main] +a: u32 = 0; +b: u32 = 0; + +[registers] +a: u32 = 0; +b: u32 = 0; \ No newline at end of file diff --git a/tests/compiler/function/input/registers.in b/tests/compiler/function/input/registers.in new file mode 100644 index 0000000000..306191c516 --- /dev/null +++ b/tests/compiler/function/input/registers.in @@ -0,0 +1,3 @@ +[registers] +a: bool = true; +b: bool = false; diff --git a/tests/compiler/function/iteration.leo b/tests/compiler/function/iteration.leo new file mode 100644 index 0000000000..9be86b5a7c --- /dev/null +++ b/tests/compiler/function/iteration.leo @@ -0,0 +1,13 @@ +function one() -> u32 { + return 1u32; +} + +function main() { + let a = 0u32; + + for i in 0..10 { + a += one(); + } + + console.assert(a == 10u32); +} \ No newline at end of file diff --git a/tests/compiler/function/iteration_repeated.leo b/tests/compiler/function/iteration_repeated.leo new file mode 100644 index 0000000000..ef4f992d96 --- /dev/null +++ b/tests/compiler/function/iteration_repeated.leo @@ -0,0 +1,15 @@ +function iteration() -> u32 { + let a = 0u32; + + for i in 0..10 { + a += 1; + } + + return a; +} + +function main() { + const total = iteration() + iteration(); + + console.assert(total == 20); +} \ No newline at end of file diff --git a/tests/compiler/function/mod.rs b/tests/compiler/function/mod.rs new file mode 100644 index 0000000000..8dfb865d90 --- /dev/null +++ b/tests/compiler/function/mod.rs @@ -0,0 +1,221 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{assert_satisfied, expect_asg_error, get_output, parse_program, parse_program_with_input}; + +#[test] +fn test_conditional_return() { + let input_string = include_str!("input/conditional_return.in"); + let program_string = include_str!("conditional_return.leo"); + let program = parse_program_with_input(program_string, input_string).unwrap(); + + let expected_string = include_str!("output/conditional_return.out"); + let actual_bytes = get_output(program); + let actual_string = std::str::from_utf8(actual_bytes.bytes().as_slice()).unwrap(); + + assert_eq!(expected_string, actual_string); +} + +#[test] +fn test_empty() { + let program_string = include_str!("empty.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_iteration() { + let program_string = include_str!("iteration.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_iteration_repeated() { + let program_string = include_str!("iteration_repeated.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_newlines() { + let input_string = include_str!("input/newlines.in"); + let program_string = include_str!("newlines.leo"); + let program = parse_program_with_input(program_string, input_string).unwrap(); + + let expected_string = include_str!("output/newlines.out"); + let actual_bytes = get_output(program); + let actual_string = std::str::from_utf8(actual_bytes.bytes().as_slice()).unwrap(); + + assert_eq!(expected_string, actual_string); +} + +#[test] +fn test_multiple_returns() { + let program_string = include_str!("multiple_returns.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_multiple_returns_fail() { + let program_string = include_str!("multiple_returns_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_multiple_returns_fail_conditional() { + let program_string = include_str!("multiple_returns_fail_conditional.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_multiple_returns_main() { + let program_string = include_str!("multiple_returns_main.leo"); + let input_string = include_str!("input/registers.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + let expected_string = include_str!("output/registers.out"); + let actual_bytes = get_output(program); + let actual_string = std::str::from_utf8(actual_bytes.bytes().as_slice()).unwrap(); + + assert_eq!(expected_string, actual_string); +} + +#[test] +fn test_repeated_function_call() { + let program_string = include_str!("repeated.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_return() { + let program_string = include_str!("return.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_scope_fail() { + let program_string = include_str!("scope_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_undefined() { + let program_string = include_str!("undefined.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_value_unchanged() { + let program_string = include_str!("value_unchanged.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_array_input() { + let program_string = include_str!("array_input.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error) +} + +// Test return multidimensional arrays + +#[test] +fn test_return_array_nested_fail() { + let program_string = include_str!("return_array_nested_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_return_array_nested_pass() { + let program_string = include_str!("return_array_nested_pass.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_return_array_tuple_fail() { + let program_string = include_str!("return_array_tuple_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_return_array_tuple_pass() { + let program_string = include_str!("return_array_tuple_pass.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +// Test return tuples + +#[test] +fn test_return_tuple() { + let program_string = include_str!("return_tuple.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_return_tuple_conditional() { + let program_string = include_str!("return_tuple_conditional.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_array_params_direct_call() { + let program_string = include_str!("array_params_direct_call.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_duplicate_function_definition() { + let program_string = include_str!("duplicate_definition.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} diff --git a/tests/compiler/function/multiple_returns.leo b/tests/compiler/function/multiple_returns.leo new file mode 100644 index 0000000000..73797c6ca3 --- /dev/null +++ b/tests/compiler/function/multiple_returns.leo @@ -0,0 +1,10 @@ +function tuple() -> (bool, bool) { + return (true, false); +} + +function main() { + const (a, b) = tuple(); + + console.assert(a == true); + console.assert(b == false); +} \ No newline at end of file diff --git a/tests/compiler/function/multiple_returns_fail.leo b/tests/compiler/function/multiple_returns_fail.leo new file mode 100644 index 0000000000..c4539bb1a0 --- /dev/null +++ b/tests/compiler/function/multiple_returns_fail.leo @@ -0,0 +1,7 @@ +function main () -> i8 { + if true { + return 1i8; //ignored + } + return 2i8; //ignored + return 3i8; //returns +} diff --git a/tests/compiler/function/multiple_returns_fail_conditional.leo b/tests/compiler/function/multiple_returns_fail_conditional.leo new file mode 100644 index 0000000000..ded39534a4 --- /dev/null +++ b/tests/compiler/function/multiple_returns_fail_conditional.leo @@ -0,0 +1,9 @@ +function main () -> u16 { + if false { + const a = 1u16; + const b = a + 1u16; + return b; + } else if false { + return 0u16; + } +} \ No newline at end of file diff --git a/tests/compiler/function/multiple_returns_main.leo b/tests/compiler/function/multiple_returns_main.leo new file mode 100644 index 0000000000..8590cdd71e --- /dev/null +++ b/tests/compiler/function/multiple_returns_main.leo @@ -0,0 +1,3 @@ +function main() -> (bool, bool) { + return (input.registers.a, input.registers.b); +} diff --git a/tests/compiler/function/newlines.leo b/tests/compiler/function/newlines.leo new file mode 100644 index 0000000000..e0b10dead1 --- /dev/null +++ b/tests/compiler/function/newlines.leo @@ -0,0 +1,9 @@ +function main( + a: u32, + b: u32, +) -> ( + u32, + u32, +) { + return (a, b); +} \ No newline at end of file diff --git a/tests/compiler/function/output/conditional_return.out b/tests/compiler/function/output/conditional_return.out new file mode 100644 index 0000000000..29d80c1cfc --- /dev/null +++ b/tests/compiler/function/output/conditional_return.out @@ -0,0 +1,2 @@ +[registers] +x: u8 = 4; diff --git a/tests/compiler/function/output/newlines.out b/tests/compiler/function/output/newlines.out new file mode 100644 index 0000000000..197a64cc63 --- /dev/null +++ b/tests/compiler/function/output/newlines.out @@ -0,0 +1,3 @@ +[registers] +a: u32 = 0; +b: u32 = 0; diff --git a/tests/compiler/function/output/registers.out b/tests/compiler/function/output/registers.out new file mode 100644 index 0000000000..306191c516 --- /dev/null +++ b/tests/compiler/function/output/registers.out @@ -0,0 +1,3 @@ +[registers] +a: bool = true; +b: bool = false; diff --git a/tests/compiler/function/repeated.leo b/tests/compiler/function/repeated.leo new file mode 100644 index 0000000000..2f9bc43d77 --- /dev/null +++ b/tests/compiler/function/repeated.leo @@ -0,0 +1,9 @@ +function one() -> bool { + return true; +} + +function main() { + const a = one() && one(); + + console.assert(a == true); +} \ No newline at end of file diff --git a/tests/compiler/function/return.leo b/tests/compiler/function/return.leo new file mode 100644 index 0000000000..e839700ee3 --- /dev/null +++ b/tests/compiler/function/return.leo @@ -0,0 +1,7 @@ +function one() -> u32 { + return 1u32; +} + +function main() { + console.assert(one() == 1u32); +} \ No newline at end of file diff --git a/tests/compiler/function/return_array_nested_fail.leo b/tests/compiler/function/return_array_nested_fail.leo new file mode 100644 index 0000000000..0db89a09e3 --- /dev/null +++ b/tests/compiler/function/return_array_nested_fail.leo @@ -0,0 +1,7 @@ +function array_3x2_tuple() -> [[u8; 2]; 3] { + return [0u8; (2, 3)]; // The correct 3x2 array tuple is `[0u8; (3, 2)]` +} + +function main() { + const b = array_3x2_tuple(); +} \ No newline at end of file diff --git a/tests/compiler/function/return_array_nested_pass.leo b/tests/compiler/function/return_array_nested_pass.leo new file mode 100644 index 0000000000..c7586f3f08 --- /dev/null +++ b/tests/compiler/function/return_array_nested_pass.leo @@ -0,0 +1,12 @@ +function array_3x2_nested() -> [[u8; 2]; 3] { + return [[0u8; 2]; 3]; +} + +function array_3x2_tuple() -> [[u8; 2]; 3] { + return [0u8; (3, 2)]; +} + +function main() { + const a = array_3x2_nested(); + const b = array_3x2_tuple(); +} \ No newline at end of file diff --git a/tests/compiler/function/return_array_tuple_fail.leo b/tests/compiler/function/return_array_tuple_fail.leo new file mode 100644 index 0000000000..d2afcd2790 --- /dev/null +++ b/tests/compiler/function/return_array_tuple_fail.leo @@ -0,0 +1,7 @@ +function array_3x2_nested() -> [u8; (3, 2)] { + return [[0u8; 3]; 2]; // The correct 3x2 nested array is `[0u8; 2]; 3]` +} + +function main() { + const a = array_3x2_nested(); +} \ No newline at end of file diff --git a/tests/compiler/function/return_array_tuple_pass.leo b/tests/compiler/function/return_array_tuple_pass.leo new file mode 100644 index 0000000000..6f5a63e806 --- /dev/null +++ b/tests/compiler/function/return_array_tuple_pass.leo @@ -0,0 +1,12 @@ +function array_3x2_nested() -> [u8; (3, 2)] { + return [[0u8; 2]; 3]; +} + +function array_3x2_tuple() -> [u8; (3, 2)] { + return [0u8; (3, 2)]; +} + +function main() { + const a = array_3x2_nested(); + const b = array_3x2_tuple(); +} \ No newline at end of file diff --git a/tests/compiler/function/return_tuple.leo b/tests/compiler/function/return_tuple.leo new file mode 100644 index 0000000000..24328aeaaa --- /dev/null +++ b/tests/compiler/function/return_tuple.leo @@ -0,0 +1,11 @@ +// Returns a tuple of tuples. +function tuples() -> ((u8, u8), u32) { + const a: (u8, u8) = (1, 2); + const b: u32 = 3; + + return (a, b); +} + +function main() { + const t = tuples(); +} \ No newline at end of file diff --git a/tests/compiler/function/return_tuple_conditional.leo b/tests/compiler/function/return_tuple_conditional.leo new file mode 100644 index 0000000000..b8040d47ec --- /dev/null +++ b/tests/compiler/function/return_tuple_conditional.leo @@ -0,0 +1,15 @@ +// Returns a tuple using a conditional "if" statement. +function tuple_conditional () -> ( + i64, + i64 +) { + if true { + return (1, 1); + } else { + return (2, 2); + } +} + +function main() { + const t = tuple_conditional(); +} \ No newline at end of file diff --git a/tests/compiler/function/scope_fail.leo b/tests/compiler/function/scope_fail.leo new file mode 100644 index 0000000000..693682d297 --- /dev/null +++ b/tests/compiler/function/scope_fail.leo @@ -0,0 +1,8 @@ +function foo() -> field { + return myGlobal; +} + +function main() { + const myGlobal = 42field; + const err = foo(); +} \ No newline at end of file diff --git a/tests/compiler/function/undefined.leo b/tests/compiler/function/undefined.leo new file mode 100644 index 0000000000..e1db3b9f09 --- /dev/null +++ b/tests/compiler/function/undefined.leo @@ -0,0 +1,3 @@ +function main() { + my_function(); +} \ No newline at end of file diff --git a/tests/compiler/function/value_unchanged.leo b/tests/compiler/function/value_unchanged.leo new file mode 100644 index 0000000000..e116736316 --- /dev/null +++ b/tests/compiler/function/value_unchanged.leo @@ -0,0 +1,19 @@ +// Functions input in leo are pass-by-value. +// +// Program execution: +// line 15: variable `a` is defined with value `1`. +// line 16: value `1` is copied and passed into function `bad_mutate()`. +// line 10: variable `x` is defined with value `1`. +// line 11: variable `x` is set to value `0`. +// line 18: program returns the value of `a`. + +function bad_mutate(x: u32) { + x = 0; // <- does not change `a` +} + +function main() { + const a = 1u32; + bad_mutate(a); + + console.assert(a == 1u32); // <- value `a` is still `1u32` +} \ No newline at end of file diff --git a/tests/compiler/group/add.leo b/tests/compiler/group/add.leo new file mode 100644 index 0000000000..bb84df2d6c --- /dev/null +++ b/tests/compiler/group/add.leo @@ -0,0 +1,3 @@ +function main(a: group, b: group, c: group) { + console.assert(a + b == c); +} \ No newline at end of file diff --git a/tests/compiler/group/assert_eq.leo b/tests/compiler/group/assert_eq.leo new file mode 100644 index 0000000000..3886a07bbf --- /dev/null +++ b/tests/compiler/group/assert_eq.leo @@ -0,0 +1,3 @@ +function main(a: group, b: group) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/group/both_sign_high.leo b/tests/compiler/group/both_sign_high.leo new file mode 100644 index 0000000000..4c93573e1e --- /dev/null +++ b/tests/compiler/group/both_sign_high.leo @@ -0,0 +1,3 @@ +function main() { + const element = (+, +)group; +} \ No newline at end of file diff --git a/tests/compiler/group/both_sign_inferred.leo b/tests/compiler/group/both_sign_inferred.leo new file mode 100644 index 0000000000..0bbd360ba0 --- /dev/null +++ b/tests/compiler/group/both_sign_inferred.leo @@ -0,0 +1,3 @@ +function main() { + const element = (_, _)group; +} \ No newline at end of file diff --git a/tests/compiler/group/both_sign_low.leo b/tests/compiler/group/both_sign_low.leo new file mode 100644 index 0000000000..1cb4f46c55 --- /dev/null +++ b/tests/compiler/group/both_sign_low.leo @@ -0,0 +1,3 @@ +function main() { + const element = (-, -)group; +} \ No newline at end of file diff --git a/tests/compiler/group/eq.leo b/tests/compiler/group/eq.leo new file mode 100644 index 0000000000..89701d9c99 --- /dev/null +++ b/tests/compiler/group/eq.leo @@ -0,0 +1,3 @@ +function main(a: group, b: group, c: bool) { + console.assert(a == b == c); +} \ No newline at end of file diff --git a/tests/compiler/group/input.leo b/tests/compiler/group/input.leo new file mode 100644 index 0000000000..3886a07bbf --- /dev/null +++ b/tests/compiler/group/input.leo @@ -0,0 +1,3 @@ +function main(a: group, b: group) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/group/input/invalid.in b/tests/compiler/group/input/invalid.in new file mode 100644 index 0000000000..d55c096738 --- /dev/null +++ b/tests/compiler/group/input/invalid.in @@ -0,0 +1,3 @@ +[main] +a: group = (1, 0)group; +b: group = (+, +)group; diff --git a/tests/compiler/group/input/point.in b/tests/compiler/group/input/point.in new file mode 100644 index 0000000000..9d49d9d847 --- /dev/null +++ b/tests/compiler/group/input/point.in @@ -0,0 +1,2 @@ +[main] +a: group = (7374112779530666882856915975292384652154477718021969292781165691637980424078, 3435195339177955418892975564890903138308061187980579490487898366607011481796)group; \ No newline at end of file diff --git a/tests/compiler/group/input/valid.in b/tests/compiler/group/input/valid.in new file mode 100644 index 0000000000..651a28bea6 --- /dev/null +++ b/tests/compiler/group/input/valid.in @@ -0,0 +1,3 @@ +[main] +a: group = (0, -)group; +b: group = (0, _)group; diff --git a/tests/compiler/group/mod.rs b/tests/compiler/group/mod.rs new file mode 100644 index 0000000000..f4cf84448c --- /dev/null +++ b/tests/compiler/group/mod.rs @@ -0,0 +1,407 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{ + assert_satisfied, expect_compiler_error, expect_synthesis_error, field::field_to_decimal_string, + generate_main_input, parse_program, parse_program_with_input, +}; +use leo_ast::{GroupCoordinate, GroupTuple, GroupValue, InputValue, Span}; + +use snarkvm_curves::edwards_bls12::EdwardsAffine; + +use rand::{Rng, SeedableRng}; +use rand_xorshift::XorShiftRng; + +pub fn group_element_to_input_value(g: EdwardsAffine) -> GroupValue { + let x = field_to_decimal_string(g.x); + let y = field_to_decimal_string(g.y); + + format!("({}, {})", x, y); + + let fake_span = Span { + text: "".to_string(), + line: 0, + start: 0, + end: 0, + }; + + GroupValue::Tuple(GroupTuple { + x: GroupCoordinate::Number(x, fake_span), + y: GroupCoordinate::Number(y, fake_span), + span: fake_span, + }) +} + +#[test] +fn test_no_space_between_literal() { + let program_string = include_str!("no_space_between_literal.leo"); + let mut program = parse_program(program_string).unwrap(); + + expect_compiler_error(program) +} + +#[test] +fn test_one() { + let program_string = include_str!("one.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_zero() { + let program_string = include_str!("zero.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_point() { + let program_string = include_str!("point.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_x_sign_high() { + let program_string = include_str!("x_sign_high.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_x_sign_low() { + let program_string = include_str!("x_sign_low.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_x_sign_inferred() { + let program_string = include_str!("x_sign_inferred.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_y_sign_high() { + let program_string = include_str!("y_sign_high.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_y_sign_low() { + let program_string = include_str!("y_sign_low.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_y_sign_inferred() { + let program_string = include_str!("y_sign_inferred.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_both_sign_high() { + let program_string = include_str!("both_sign_high.leo"); + + let program = parse_program(program_string).unwrap(); + + expect_compiler_error(program); +} + +#[test] +fn test_both_sign_low() { + let program_string = include_str!("both_sign_low.leo"); + + let program = parse_program(program_string).unwrap(); + + expect_compiler_error(program); +} + +#[test] +fn test_both_sign_inferred() { + let program_string = include_str!("both_sign_inferred.leo"); + + let program = parse_program(program_string).unwrap(); + + expect_compiler_error(program); +} + +#[test] +fn test_point_input() { + let program_string = include_str!("point_input.leo"); + let input_bytes = include_str!("input/point.in"); + + let program = parse_program_with_input(program_string, input_bytes).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_input() { + let program_string = include_str!("input.leo"); + let input_string_pass = include_str!("input/valid.in"); + let input_string_fail = include_str!("input/invalid.in"); + + let program = parse_program_with_input(program_string, input_string_pass).unwrap(); + + assert_satisfied(program); + + let program = parse_program_with_input(program_string, input_string_fail).unwrap(); + + expect_compiler_error(program); +} + +#[test] +fn test_negate() { + use std::ops::Neg; + + let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + + for _ in 0..10 { + let a: EdwardsAffine = rng.gen(); + let b = a.neg(); + + let a_element = group_element_to_input_value(a); + let b_element = group_element_to_input_value(b); + + let program_string = include_str!("negate.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Group(a_element))), + ("b", Some(InputValue::Group(b_element))), + ]); + program.set_main_input(main_input); + + assert_satisfied(program) + } +} + +#[test] +fn test_add() { + use std::ops::Add; + + let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + + for _ in 0..10 { + let a: EdwardsAffine = rng.gen(); + let b: EdwardsAffine = rng.gen(); + let c = a.add(&b); + + let a_element = group_element_to_input_value(a); + let b_element = group_element_to_input_value(b); + let c_element = group_element_to_input_value(c); + + let program_string = include_str!("add.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Group(a_element))), + ("b", Some(InputValue::Group(b_element))), + ("c", Some(InputValue::Group(c_element))), + ]); + program.set_main_input(main_input); + + assert_satisfied(program) + } +} + +#[test] +fn test_sub() { + use std::ops::Sub; + + let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + + for _ in 0..10 { + let a: EdwardsAffine = rng.gen(); + let b: EdwardsAffine = rng.gen(); + let c = a.sub(&b); + + let a_element = group_element_to_input_value(a); + let b_element = group_element_to_input_value(b); + let c_element = group_element_to_input_value(c); + + let program_string = include_str!("sub.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Group(a_element))), + ("b", Some(InputValue::Group(b_element))), + ("c", Some(InputValue::Group(c_element))), + ]); + program.set_main_input(main_input); + + assert_satisfied(program) + } +} + +#[test] +fn test_console_assert_pass() { + let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + + for _ in 0..10 { + let a: EdwardsAffine = rng.gen(); + + let a_element = group_element_to_input_value(a); + + let program_string = include_str!("assert_eq.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Group(a_element.clone()))), + ("b", Some(InputValue::Group(a_element))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } +} + +#[test] +fn test_console_assert_fail() { + let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + + for _ in 0..10 { + let a: EdwardsAffine = rng.gen(); + let b: EdwardsAffine = rng.gen(); + + if a == b { + continue; + } + + let a_element = group_element_to_input_value(a); + let b_element = group_element_to_input_value(b); + + let program_string = include_str!("assert_eq.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Group(a_element))), + ("b", Some(InputValue::Group(b_element))), + ]); + + program.set_main_input(main_input); + + expect_compiler_error(program); + } +} + +#[test] +fn test_eq() { + let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + + for _ in 0..10 { + let a: EdwardsAffine = rng.gen(); + let b: EdwardsAffine = rng.gen(); + + let a_element = group_element_to_input_value(a); + let b_element = group_element_to_input_value(b); + + // test equal + + let program_string = include_str!("eq.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Group(a_element.clone()))), + ("b", Some(InputValue::Group(a_element.clone()))), + ("c", Some(InputValue::Boolean(true))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + + // test not equal + + let c = a.eq(&b); + + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Group(a_element))), + ("b", Some(InputValue::Group(b_element))), + ("c", Some(InputValue::Boolean(c))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } +} + +#[test] +fn test_ternary() { + let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + + let a: EdwardsAffine = rng.gen(); + let b: EdwardsAffine = rng.gen(); + + let a_element = group_element_to_input_value(a); + let b_element = group_element_to_input_value(b); + + let program_string = include_str!("ternary.leo"); + let mut program = parse_program(program_string).unwrap(); + + // true -> field a + let main_input = generate_main_input(vec![ + ("s", Some(InputValue::Boolean(true))), + ("a", Some(InputValue::Group(a_element.clone()))), + ("b", Some(InputValue::Group(b_element.clone()))), + ("c", Some(InputValue::Group(a_element.clone()))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + + let mut program = parse_program(program_string).unwrap(); + + // false -> field b + let main_input = generate_main_input(vec![ + ("s", Some(InputValue::Boolean(false))), + ("a", Some(InputValue::Group(a_element))), + ("b", Some(InputValue::Group(b_element.clone()))), + ("c", Some(InputValue::Group(b_element))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); +} + +#[test] +fn test_positive_and_negative() { + let program_string = include_str!("positive_and_negative.leo"); + + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} diff --git a/tests/compiler/group/negate.leo b/tests/compiler/group/negate.leo new file mode 100644 index 0000000000..506d8d73ce --- /dev/null +++ b/tests/compiler/group/negate.leo @@ -0,0 +1,3 @@ +function main(a: group, b: group) { + console.assert(-a == b); +} \ No newline at end of file diff --git a/tests/compiler/group/no_space_between_literal.leo b/tests/compiler/group/no_space_between_literal.leo new file mode 100644 index 0000000000..af53e5dffe --- /dev/null +++ b/tests/compiler/group/no_space_between_literal.leo @@ -0,0 +1,3 @@ +function main() { + const g = (0,1) group; +} \ No newline at end of file diff --git a/tests/compiler/group/one.leo b/tests/compiler/group/one.leo new file mode 100644 index 0000000000..510110150b --- /dev/null +++ b/tests/compiler/group/one.leo @@ -0,0 +1,3 @@ +function main() { + const element = 1group; +} \ No newline at end of file diff --git a/tests/compiler/group/point.leo b/tests/compiler/group/point.leo new file mode 100644 index 0000000000..5e68415a0d --- /dev/null +++ b/tests/compiler/group/point.leo @@ -0,0 +1,3 @@ +function main() { + const point = (7374112779530666882856915975292384652154477718021969292781165691637980424078, 3435195339177955418892975564890903138308061187980579490487898366607011481796)group; +} \ No newline at end of file diff --git a/tests/compiler/group/point_input.leo b/tests/compiler/group/point_input.leo new file mode 100644 index 0000000000..a3a8e63bd3 --- /dev/null +++ b/tests/compiler/group/point_input.leo @@ -0,0 +1,3 @@ +function main(a: group) { + const b = a; +} \ No newline at end of file diff --git a/tests/compiler/group/positive_and_negative.leo b/tests/compiler/group/positive_and_negative.leo new file mode 100644 index 0000000000..5d29e36ef2 --- /dev/null +++ b/tests/compiler/group/positive_and_negative.leo @@ -0,0 +1,10 @@ +function main() { + const pos_element = 1group; + const neg_element = -1group; + + const pair_x_pos = (1, _)group; + const pair_x_neg = (-1, _)group; + + const pair_y_pos = (_, 1)group; + const pair_y_neg = (_, -1)group; +} \ No newline at end of file diff --git a/tests/compiler/group/sub.leo b/tests/compiler/group/sub.leo new file mode 100644 index 0000000000..dfe82d8e31 --- /dev/null +++ b/tests/compiler/group/sub.leo @@ -0,0 +1,3 @@ +function main(a: group, b: group, c: group) { + console.assert(a - b == c); +} \ No newline at end of file diff --git a/tests/compiler/group/ternary.leo b/tests/compiler/group/ternary.leo new file mode 100644 index 0000000000..97fba1f5b6 --- /dev/null +++ b/tests/compiler/group/ternary.leo @@ -0,0 +1,5 @@ +function main(s: bool, a: group, b: group, c: group) { + const r = s ? a : b; + + console.assert(r == c); +} \ No newline at end of file diff --git a/tests/compiler/group/x_and_y.leo b/tests/compiler/group/x_and_y.leo new file mode 100644 index 0000000000..a350a7ad6b --- /dev/null +++ b/tests/compiler/group/x_and_y.leo @@ -0,0 +1,3 @@ +function main(element: group) { + const b = element; +} \ No newline at end of file diff --git a/tests/compiler/group/x_sign_high.leo b/tests/compiler/group/x_sign_high.leo new file mode 100644 index 0000000000..f38b54ad9a --- /dev/null +++ b/tests/compiler/group/x_sign_high.leo @@ -0,0 +1,3 @@ +function main() { + const element = (0, +)group; +} \ No newline at end of file diff --git a/tests/compiler/group/x_sign_inferred.leo b/tests/compiler/group/x_sign_inferred.leo new file mode 100644 index 0000000000..02c5ac988b --- /dev/null +++ b/tests/compiler/group/x_sign_inferred.leo @@ -0,0 +1,3 @@ +function main() { + const element = (0, _)group; +} \ No newline at end of file diff --git a/tests/compiler/group/x_sign_low.leo b/tests/compiler/group/x_sign_low.leo new file mode 100644 index 0000000000..ad74d18b64 --- /dev/null +++ b/tests/compiler/group/x_sign_low.leo @@ -0,0 +1,3 @@ +function main() { + const element = (0, -)group; +} \ No newline at end of file diff --git a/tests/compiler/group/y_sign_high.leo b/tests/compiler/group/y_sign_high.leo new file mode 100644 index 0000000000..af2a20149d --- /dev/null +++ b/tests/compiler/group/y_sign_high.leo @@ -0,0 +1,3 @@ +function main() { + const element = (+, 1)group; +} \ No newline at end of file diff --git a/tests/compiler/group/y_sign_inferred.leo b/tests/compiler/group/y_sign_inferred.leo new file mode 100644 index 0000000000..a4efa6a982 --- /dev/null +++ b/tests/compiler/group/y_sign_inferred.leo @@ -0,0 +1,3 @@ +function main() { + const element = (_, 1)group; +} \ No newline at end of file diff --git a/tests/compiler/group/y_sign_low.leo b/tests/compiler/group/y_sign_low.leo new file mode 100644 index 0000000000..f557ed0d35 --- /dev/null +++ b/tests/compiler/group/y_sign_low.leo @@ -0,0 +1,3 @@ +function main() { + const element = (-, 1)group; +} \ No newline at end of file diff --git a/tests/compiler/group/zero.leo b/tests/compiler/group/zero.leo new file mode 100644 index 0000000000..6cdd4c960e --- /dev/null +++ b/tests/compiler/group/zero.leo @@ -0,0 +1,3 @@ +function main() { + const element = 0group; +} \ No newline at end of file diff --git a/tests/compiler/import/alias.leo b/tests/compiler/import/alias.leo new file mode 100644 index 0000000000..f153b5a128 --- /dev/null +++ b/tests/compiler/import/alias.leo @@ -0,0 +1,5 @@ +import test-import.foo as bar; + +function main() { + console.assert(bar() == 1u32); +} \ No newline at end of file diff --git a/tests/compiler/import/basic.leo b/tests/compiler/import/basic.leo new file mode 100644 index 0000000000..53d243efaa --- /dev/null +++ b/tests/compiler/import/basic.leo @@ -0,0 +1,5 @@ +import test-import.foo; + +function main() { + console.assert(foo() == 1u32); +} \ No newline at end of file diff --git a/tests/compiler/import/imports/bar/.gitignore b/tests/compiler/import/imports/bar/.gitignore new file mode 100755 index 0000000000..ea1472ec1f --- /dev/null +++ b/tests/compiler/import/imports/bar/.gitignore @@ -0,0 +1 @@ +output/ diff --git a/tests/compiler/import/imports/bar/Leo.toml b/tests/compiler/import/imports/bar/Leo.toml new file mode 100755 index 0000000000..8e22d51a95 --- /dev/null +++ b/tests/compiler/import/imports/bar/Leo.toml @@ -0,0 +1,3 @@ +[package] +name = "bar" +version = "0.1.0" diff --git a/tests/compiler/import/imports/bar/src/bat/bat.leo b/tests/compiler/import/imports/bar/src/bat/bat.leo new file mode 100755 index 0000000000..a7d2fc83d4 --- /dev/null +++ b/tests/compiler/import/imports/bar/src/bat/bat.leo @@ -0,0 +1,3 @@ +circuit Bat { + t: u32 +} \ No newline at end of file diff --git a/tests/compiler/import/imports/bar/src/baz.leo b/tests/compiler/import/imports/bar/src/baz.leo new file mode 100755 index 0000000000..1bb268a84c --- /dev/null +++ b/tests/compiler/import/imports/bar/src/baz.leo @@ -0,0 +1,7 @@ +circuit Baz { + z: u32 +} + +circuit Bazzar { + a: u32 +} \ No newline at end of file diff --git a/tests/compiler/import/imports/bar/src/lib.leo b/tests/compiler/import/imports/bar/src/lib.leo new file mode 100755 index 0000000000..c169f5935e --- /dev/null +++ b/tests/compiler/import/imports/bar/src/lib.leo @@ -0,0 +1,3 @@ +circuit Bar { + r: u32 +} \ No newline at end of file diff --git a/tests/compiler/import/imports/car/.gitignore b/tests/compiler/import/imports/car/.gitignore new file mode 100755 index 0000000000..ea1472ec1f --- /dev/null +++ b/tests/compiler/import/imports/car/.gitignore @@ -0,0 +1 @@ +output/ diff --git a/tests/compiler/import/imports/car/Leo.toml b/tests/compiler/import/imports/car/Leo.toml new file mode 100755 index 0000000000..15b76f1d76 --- /dev/null +++ b/tests/compiler/import/imports/car/Leo.toml @@ -0,0 +1,3 @@ +[package] +name = "car" +version = "0.1.0" diff --git a/tests/compiler/import/imports/car/src/lib.leo b/tests/compiler/import/imports/car/src/lib.leo new file mode 100755 index 0000000000..b1e037fd38 --- /dev/null +++ b/tests/compiler/import/imports/car/src/lib.leo @@ -0,0 +1,3 @@ +circuit Car { + c: u32 +} \ No newline at end of file diff --git a/tests/compiler/import/many_import.leo b/tests/compiler/import/many_import.leo new file mode 100644 index 0000000000..08ae494c4f --- /dev/null +++ b/tests/compiler/import/many_import.leo @@ -0,0 +1,26 @@ +import test-import.( // local import + Point, + foo, +); + +import bar.( // imports directory import + Bar, + baz.(Baz, Bazzar), + bat.bat.Bat, +); + +import car.Car; // imports directory import + +function main() { + const point = Point { x: 1u32, y: 1u32 }; + const foo = foo(); + + const bar = Bar { r: 1u32 }; + const baz = Baz { z: 1u32 }; + const bazzar = Bazzar { a: 1u32 }; + const bat = Bat { t: 1u32 }; + + const car = Car { c: 1u32 }; + + console.assert(car.c == 1u32); +} \ No newline at end of file diff --git a/tests/compiler/import/many_import_star.leo b/tests/compiler/import/many_import_star.leo new file mode 100644 index 0000000000..575487a929 --- /dev/null +++ b/tests/compiler/import/many_import_star.leo @@ -0,0 +1,19 @@ +import test-import.*; // local import + +import bar.*; // imports directory import +import bar.baz.*; // imports directory import +import bar.bat.bat.*; // imports directory import +import car.*; // imports directory import + +function main() { + const point = Point { x: 1u32, y: 1u32 }; + const foo = foo(); + + const bar = Bar { r: 1u32 }; + const bat = Bat { t: 1u32 }; + const baz = Baz { z: 1u32 }; + + const car = Car { c: 1u32 }; + + console.assert(car.c == 1u32); +} \ No newline at end of file diff --git a/tests/compiler/import/mod.rs b/tests/compiler/import/mod.rs new file mode 100644 index 0000000000..1a3440b577 --- /dev/null +++ b/tests/compiler/import/mod.rs @@ -0,0 +1,154 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{assert_satisfied, parse_program}; + +use std::env::{current_dir, set_current_dir}; + +static TEST_SOURCE_DIRECTORY: &str = "tests/import"; + +// Import tests rely on knowledge of local directories. They should be run locally only. + +pub fn set_local_dir() { + let mut local = current_dir().unwrap(); + local.push(TEST_SOURCE_DIRECTORY); + + set_current_dir(local).unwrap(); +} + +#[test] +#[ignore] +fn test_basic() { + set_local_dir(); + + let program_string = include_str!("basic.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +#[ignore] +fn test_multiple() { + set_local_dir(); + + let program_string = include_str!("multiple.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +#[ignore] +fn test_star() { + set_local_dir(); + + let program_string = include_str!("star.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +#[ignore] +fn test_star_fail() { + set_local_dir(); + + let program_string = include_str!("star_fail.leo"); + assert!(parse_program(program_string).is_err()); +} + +#[test] +#[ignore] +fn test_alias() { + set_local_dir(); + + let program_string = include_str!("alias.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +// naming tests +#[test] +#[ignore] +fn test_names_pass() { + set_local_dir(); + + let program_string = include_str!("names.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +#[ignore] +fn test_names_fail_1() { + set_local_dir(); + + let program_string = include_str!("names_dash_a.leo"); + assert!(parse_program(program_string).is_err()); +} + +#[test] +#[ignore] +fn test_names_fail_2() { + set_local_dir(); + + let program_string = include_str!("names_a_dash.leo"); + assert!(parse_program(program_string).is_err()); +} + +#[test] +#[ignore] +fn test_names_fail_3() { + set_local_dir(); + + let program_string = include_str!("names_underscore.leo"); + assert!(parse_program(program_string).is_err()); +} + +#[test] +#[ignore] +fn test_names_fail_4() { + set_local_dir(); + + let program_string = include_str!("names_dollar.leo"); + assert!(parse_program(program_string).is_err()); +} + +// more complex tests +#[test] +#[ignore] +fn test_many_import() { + set_local_dir(); + + let program_string = include_str!("many_import.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +#[ignore] +fn test_many_import_star() { + set_local_dir(); + + let program_string = include_str!("many_import_star.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} diff --git a/tests/compiler/import/multiple.leo b/tests/compiler/import/multiple.leo new file mode 100644 index 0000000000..4bd181c02d --- /dev/null +++ b/tests/compiler/import/multiple.leo @@ -0,0 +1,10 @@ +import test-import.( + Point, + foo +); + +function main() { + const a = Point { x: 1u32, y: 0u32 }; + + console.assert(a.x == 1u32); +} \ No newline at end of file diff --git a/tests/compiler/import/names.leo b/tests/compiler/import/names.leo new file mode 100644 index 0000000000..d3ce50829a --- /dev/null +++ b/tests/compiler/import/names.leo @@ -0,0 +1,5 @@ +import a0-f.foo; +import a-9.bar; +import hello-world.hello; + +function main() {} \ No newline at end of file diff --git a/tests/compiler/import/names_a_dash.leo b/tests/compiler/import/names_a_dash.leo new file mode 100644 index 0000000000..ec136176b2 --- /dev/null +++ b/tests/compiler/import/names_a_dash.leo @@ -0,0 +1,3 @@ +import a-.foo; + +function main() {} \ No newline at end of file diff --git a/tests/compiler/import/names_dash_a.leo b/tests/compiler/import/names_dash_a.leo new file mode 100644 index 0000000000..95ccb7e4a5 --- /dev/null +++ b/tests/compiler/import/names_dash_a.leo @@ -0,0 +1,3 @@ +import -a.foo; + +function main() {} \ No newline at end of file diff --git a/tests/compiler/import/names_dollar.leo b/tests/compiler/import/names_dollar.leo new file mode 100644 index 0000000000..e4eaec3719 --- /dev/null +++ b/tests/compiler/import/names_dollar.leo @@ -0,0 +1,3 @@ +import money$.foo; + +function main() {} \ No newline at end of file diff --git a/tests/compiler/import/names_underscore.leo b/tests/compiler/import/names_underscore.leo new file mode 100644 index 0000000000..c5822ebadd --- /dev/null +++ b/tests/compiler/import/names_underscore.leo @@ -0,0 +1,3 @@ +import hello_world.foo; + +function main() {} \ No newline at end of file diff --git a/tests/compiler/import/src/a-9.leo b/tests/compiler/import/src/a-9.leo new file mode 100644 index 0000000000..8cd9f87f14 --- /dev/null +++ b/tests/compiler/import/src/a-9.leo @@ -0,0 +1 @@ +function bar() {} \ No newline at end of file diff --git a/tests/compiler/import/src/a0-f.leo b/tests/compiler/import/src/a0-f.leo new file mode 100644 index 0000000000..c99ad3b713 --- /dev/null +++ b/tests/compiler/import/src/a0-f.leo @@ -0,0 +1 @@ +function foo() {} \ No newline at end of file diff --git a/tests/compiler/import/src/hello-world.leo b/tests/compiler/import/src/hello-world.leo new file mode 100644 index 0000000000..2d96e74c4c --- /dev/null +++ b/tests/compiler/import/src/hello-world.leo @@ -0,0 +1 @@ +function hello() {} \ No newline at end of file diff --git a/tests/compiler/import/src/test-import.leo b/tests/compiler/import/src/test-import.leo new file mode 100644 index 0000000000..9a57d433f4 --- /dev/null +++ b/tests/compiler/import/src/test-import.leo @@ -0,0 +1,8 @@ +circuit Point { + x: u32 + y: u32 +} + +function foo() -> u32 { + return 1u32; +} \ No newline at end of file diff --git a/tests/compiler/import/star.leo b/tests/compiler/import/star.leo new file mode 100644 index 0000000000..69d0791627 --- /dev/null +++ b/tests/compiler/import/star.leo @@ -0,0 +1,7 @@ +import test-import.*; + +function main() { + const a = Point { x: 1u32, y: 0u32 }; + + console.assert(foo() == 1u32); +} \ No newline at end of file diff --git a/tests/compiler/import/star_fail.leo b/tests/compiler/import/star_fail.leo new file mode 100644 index 0000000000..47f2efeda7 --- /dev/null +++ b/tests/compiler/import/star_fail.leo @@ -0,0 +1,4 @@ +// importing `*` from a directory is illegal +import bar.bat.*; + +function main() {} \ No newline at end of file diff --git a/tests/compiler/input_files/mod.rs b/tests/compiler/input_files/mod.rs new file mode 100644 index 0000000000..af220752b8 --- /dev/null +++ b/tests/compiler/input_files/mod.rs @@ -0,0 +1,21 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +mod program_input; +mod program_input_and_program_state; +mod program_input_constants; +mod program_registers; +mod program_state; diff --git a/tests/compiler/input_files/program_input/input/main.in b/tests/compiler/input_files/program_input/input/main.in new file mode 100644 index 0000000000..16ba5231af --- /dev/null +++ b/tests/compiler/input_files/program_input/input/main.in @@ -0,0 +1,2 @@ +[main] +a: bool = true; \ No newline at end of file diff --git a/tests/compiler/input_files/program_input/input/main_array.in b/tests/compiler/input_files/program_input/input/main_array.in new file mode 100644 index 0000000000..34db280b2e --- /dev/null +++ b/tests/compiler/input_files/program_input/input/main_array.in @@ -0,0 +1,2 @@ +[main] +x: [i16; 1] = [0i16; 1]; diff --git a/tests/compiler/input_files/program_input/input/main_array_fail.in b/tests/compiler/input_files/program_input/input/main_array_fail.in new file mode 100644 index 0000000000..efdc161ee4 --- /dev/null +++ b/tests/compiler/input_files/program_input/input/main_array_fail.in @@ -0,0 +1,2 @@ +[main] +x: [i16; 1] = [0i16; 1]; \ No newline at end of file diff --git a/tests/compiler/input_files/program_input/input/main_fail_name.in b/tests/compiler/input_files/program_input/input/main_fail_name.in new file mode 100644 index 0000000000..411529499c --- /dev/null +++ b/tests/compiler/input_files/program_input/input/main_fail_name.in @@ -0,0 +1,2 @@ +[main] +bad_name: bool = true; \ No newline at end of file diff --git a/tests/compiler/input_files/program_input/input/main_fail_type.in b/tests/compiler/input_files/program_input/input/main_fail_type.in new file mode 100644 index 0000000000..a5cf30c8cc --- /dev/null +++ b/tests/compiler/input_files/program_input/input/main_fail_type.in @@ -0,0 +1,2 @@ +[main] +a: u8 = 1; \ No newline at end of file diff --git a/tests/compiler/input_files/program_input/input/main_field.in b/tests/compiler/input_files/program_input/input/main_field.in new file mode 100644 index 0000000000..fe9eebbd56 --- /dev/null +++ b/tests/compiler/input_files/program_input/input/main_field.in @@ -0,0 +1,3 @@ +[main] +a: field = 1; +b: field = -1; \ No newline at end of file diff --git a/tests/compiler/input_files/program_input/input/main_group.in b/tests/compiler/input_files/program_input/input/main_group.in new file mode 100644 index 0000000000..2a7aecd0ad --- /dev/null +++ b/tests/compiler/input_files/program_input/input/main_group.in @@ -0,0 +1,4 @@ +[main] +a: group = 1group; +b: group = -1group; +c: group = (0, -1)group; \ No newline at end of file diff --git a/tests/compiler/input_files/program_input/input/main_multi_dimension_array.in b/tests/compiler/input_files/program_input/input/main_multi_dimension_array.in new file mode 100644 index 0000000000..e62ec2f232 --- /dev/null +++ b/tests/compiler/input_files/program_input/input/main_multi_dimension_array.in @@ -0,0 +1,2 @@ +[main] +x: [i16; (2, 2, 3)] = [0i16; (2, 2, 3)]; \ No newline at end of file diff --git a/tests/compiler/input_files/program_input/input/main_multiple.in b/tests/compiler/input_files/program_input/input/main_multiple.in new file mode 100644 index 0000000000..546c971bf8 --- /dev/null +++ b/tests/compiler/input_files/program_input/input/main_multiple.in @@ -0,0 +1,3 @@ +[main] +a: bool = true; +b: bool = false; diff --git a/tests/compiler/input_files/program_input/input/main_tuple_fail.in b/tests/compiler/input_files/program_input/input/main_tuple_fail.in new file mode 100644 index 0000000000..aada924c29 --- /dev/null +++ b/tests/compiler/input_files/program_input/input/main_tuple_fail.in @@ -0,0 +1,2 @@ +[main] +x: (u8, bool) = (10, true); // wrong size here; main expects (u8, bool, u8) \ No newline at end of file diff --git a/tests/compiler/input_files/program_input/main.leo b/tests/compiler/input_files/program_input/main.leo new file mode 100644 index 0000000000..ba6be77256 --- /dev/null +++ b/tests/compiler/input_files/program_input/main.leo @@ -0,0 +1,3 @@ +function main(a: bool) { + console.assert(a == true); +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_input/main_array.leo b/tests/compiler/input_files/program_input/main_array.leo new file mode 100644 index 0000000000..dd7f265457 --- /dev/null +++ b/tests/compiler/input_files/program_input/main_array.leo @@ -0,0 +1,4 @@ +function main (x: [i16; 1]) { + console.log("{}", x); + console.assert(x[0] == 0); +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_input/main_array_fail.leo b/tests/compiler/input_files/program_input/main_array_fail.leo new file mode 100644 index 0000000000..d8c6f301d8 --- /dev/null +++ b/tests/compiler/input_files/program_input/main_array_fail.leo @@ -0,0 +1,3 @@ +function main(x: [i16; 2]){ + console.log("x: {}", x); +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_input/main_field.leo b/tests/compiler/input_files/program_input/main_field.leo new file mode 100644 index 0000000000..19bf456ee7 --- /dev/null +++ b/tests/compiler/input_files/program_input/main_field.leo @@ -0,0 +1,5 @@ +function main(a: field, b: field) { + // Change to assert when == is implemented for field. + console.log("a: {}", a); + console.log("b: {}", b); +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_input/main_group.leo b/tests/compiler/input_files/program_input/main_group.leo new file mode 100644 index 0000000000..b7795ac7e7 --- /dev/null +++ b/tests/compiler/input_files/program_input/main_group.leo @@ -0,0 +1,6 @@ +function main(a: group, b: group, c: group) { + // Change to assert when == is implemented for group. + console.log("a: {}", a); + console.log("b: {}", b); + console.log("c: {}", c); +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_input/main_multi_dimension_array.leo b/tests/compiler/input_files/program_input/main_multi_dimension_array.leo new file mode 100644 index 0000000000..7c89cc1082 --- /dev/null +++ b/tests/compiler/input_files/program_input/main_multi_dimension_array.leo @@ -0,0 +1,9 @@ +function main(x: [i16; (2, 2, 3)]){ + console.log("x: {}", x); + + const y: [i16; (2, 2, 3)] = [0i16; (2, 2, 3)]; + console.log("y: {}", y); + + console.assert(x[0][0][0] == y[0][0][0]); + console.assert(x[1][1][2] == y[1][1][2]); +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_input/main_multiple.leo b/tests/compiler/input_files/program_input/main_multiple.leo new file mode 100644 index 0000000000..eb5ef8d1f6 --- /dev/null +++ b/tests/compiler/input_files/program_input/main_multiple.leo @@ -0,0 +1,4 @@ +function main(a: bool, b: bool) { + console.assert(a == true); + console.assert(b == false); +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_input/main_tuple_fail.leo b/tests/compiler/input_files/program_input/main_tuple_fail.leo new file mode 100644 index 0000000000..7874773eff --- /dev/null +++ b/tests/compiler/input_files/program_input/main_tuple_fail.leo @@ -0,0 +1,3 @@ +function main(x: (u8, bool, u8)) { + console.log("x: {}", x); +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_input/mod.rs b/tests/compiler/input_files/program_input/mod.rs new file mode 100644 index 0000000000..9fa79b9790 --- /dev/null +++ b/tests/compiler/input_files/program_input/mod.rs @@ -0,0 +1,125 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{assert_satisfied, expect_compiler_error, parse_program_with_input, EdwardsTestCompiler}; +use leo_compiler::errors::CompilerError; + +fn expect_fail(program: EdwardsTestCompiler) { + match expect_compiler_error(program) { + CompilerError::FunctionError(_) => {} + err => panic!("expected input parser error, got {:?}", err), + } +} + +#[test] +fn test_input_pass() { + let program_string = include_str!("main.leo"); + let input_string = include_str!("input/main.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_input_array_fail() { + let program_string = include_str!("main_array.leo"); + let input_string = include_str!("input/main_array.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_input_multi_dimension_array() { + let program_string = include_str!("main_multi_dimension_array.leo"); + let input_string = include_str!("input/main_multi_dimension_array.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_input_fail_name() { + let program_string = include_str!("main.leo"); + let input_string = include_str!("input/main_fail_name.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + expect_fail(program); +} + +#[test] +fn test_input_fail_type() { + let program_string = include_str!("main.leo"); + let input_string = include_str!("input/main_fail_type.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + expect_fail(program); +} + +#[test] +fn test_input_multiple() { + let program_string = include_str!("main_multiple.leo"); + let input_string = include_str!("input/main_multiple.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_input_array_dimensions_mismatch() { + let program_string = include_str!("main_array_fail.leo"); + let input_string = include_str!("input/main_array_fail.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + expect_fail(program); +} + +#[test] +fn test_tuple_size_mismatch() { + let program_string = include_str!("main_tuple_fail.leo"); + let input_string = include_str!("input/main_tuple_fail.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + expect_fail(program); +} + +#[test] +fn test_field_input() { + let program_string = include_str!("main_field.leo"); + let input_string = include_str!("input/main_field.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_group_input() { + let program_string = include_str!("main_group.leo"); + let input_string = include_str!("input/main_group.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} diff --git a/tests/compiler/input_files/program_input_and_program_state/access.leo b/tests/compiler/input_files/program_input_and_program_state/access.leo new file mode 100644 index 0000000000..819f6c6c1e --- /dev/null +++ b/tests/compiler/input_files/program_input_and_program_state/access.leo @@ -0,0 +1,11 @@ +function main(data: [u8; 32]) { + console.assert(input.registers.value_balance == 0u64); + + console.assert(input.state.leaf_index == 0u32); + + console.assert(input.record.value == 5u64); + + console.assert(input.state_leaf.network_id == 0u8); + + console.assert(data == [0u8; 32]); +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_and_program_state/input/basic.in b/tests/compiler/input_files/program_input_and_program_state/input/basic.in new file mode 100644 index 0000000000..b62eee0443 --- /dev/null +++ b/tests/compiler/input_files/program_input_and_program_state/input/basic.in @@ -0,0 +1,5 @@ +[main] +a: bool = true; + +[registers] +b: bool = true; \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_and_program_state/input/basic.state b/tests/compiler/input_files/program_input_and_program_state/input/basic.state new file mode 100644 index 0000000000..78706190fe --- /dev/null +++ b/tests/compiler/input_files/program_input_and_program_state/input/basic.state @@ -0,0 +1,12 @@ +[[public]] + +[state] +a: bool = true; + +[[private]] + +[record] +a: bool = true; + +[state_leaf] +a: bool = true; \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_and_program_state/input/token_withdraw.in b/tests/compiler/input_files/program_input_and_program_state/input/token_withdraw.in new file mode 100644 index 0000000000..0d4ece3b1c --- /dev/null +++ b/tests/compiler/input_files/program_input_and_program_state/input/token_withdraw.in @@ -0,0 +1,6 @@ +[main] +data: [u8; 32] = [0u8; 32]; + +[registers] +token_id: [u8; 32] = [0u8; 32]; +value_balance: u64 = 0; \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_and_program_state/input/token_withdraw.state b/tests/compiler/input_files/program_input_and_program_state/input/token_withdraw.state new file mode 100644 index 0000000000..219fc44776 --- /dev/null +++ b/tests/compiler/input_files/program_input_and_program_state/input/token_withdraw.state @@ -0,0 +1,24 @@ +[[public]] + +[state] +leaf_index: u32 = 0; +root: [u8; 32] = [0u8; 32]; + +[[private]] + +[record] +serial_number: [u8; 32] = [0u8; 32]; +commitment: [u8; 32] = [0u8; 32]; +owner: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; +value: u64 = 5; +payload: [u8; 32] = [0u8; 32]; +birth_program_id: [u8; 32] = [0u8; 32]; +death_program_id: [u8; 32] = [0u8; 32]; +serial_number_nonce: [u8; 32] = [0u8; 32]; +commitment_randomness: [u8; 32] = [0u8; 32]; + +[state_leaf] +path: [u8; 128] = [0u8; 128]; +memo: [u8; 32] = [0u8; 32]; +network_id: u8 = 0; +leaf_randomness: [u8; 32] = [0u8; 32]; \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_and_program_state/mod.rs b/tests/compiler/input_files/program_input_and_program_state/mod.rs new file mode 100644 index 0000000000..25541030ab --- /dev/null +++ b/tests/compiler/input_files/program_input_and_program_state/mod.rs @@ -0,0 +1,44 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{assert_satisfied, parse_input_and_state, parse_program_with_input_and_state}; + +#[test] +fn test_basic() { + let input_string = include_str!("input/basic.in"); + let state_string = include_str!("input/basic.state"); + + parse_input_and_state(input_string, state_string).unwrap(); +} + +#[test] +fn test_full() { + let input_string = include_str!("input/token_withdraw.in"); + let state_string = include_str!("input/token_withdraw.state"); + + parse_input_and_state(input_string, state_string).unwrap(); +} + +#[test] +fn test_access() { + let program_string = include_str!("access.leo"); + let input_string = include_str!("input/token_withdraw.in"); + let state_string = include_str!("input/token_withdraw.state"); + + let program = parse_program_with_input_and_state(program_string, input_string, state_string).unwrap(); + + assert_satisfied(program); +} diff --git a/tests/compiler/input_files/program_input_constants/input/main.in b/tests/compiler/input_files/program_input_constants/input/main.in new file mode 100644 index 0000000000..625ffc1ffb --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/input/main.in @@ -0,0 +1,2 @@ +[constants] +a: bool = true; \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_constants/input/main_array.in b/tests/compiler/input_files/program_input_constants/input/main_array.in new file mode 100644 index 0000000000..3fe6502e8f --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/input/main_array.in @@ -0,0 +1,2 @@ +[constants] +x: [i16; 1] = [0i16; 1]; diff --git a/tests/compiler/input_files/program_input_constants/input/main_array_fail.in b/tests/compiler/input_files/program_input_constants/input/main_array_fail.in new file mode 100644 index 0000000000..e63331af22 --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/input/main_array_fail.in @@ -0,0 +1,2 @@ +[constants] +x: [i16; 1] = [0i16; 1]; \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_constants/input/main_double_declaration_fail.in b/tests/compiler/input_files/program_input_constants/input/main_double_declaration_fail.in new file mode 100644 index 0000000000..fcc95402a3 --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/input/main_double_declaration_fail.in @@ -0,0 +1,5 @@ +[main] +a: bool = true; + +[constants] +a: bool = false; \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_constants/input/main_fail_name.in b/tests/compiler/input_files/program_input_constants/input/main_fail_name.in new file mode 100644 index 0000000000..0cae21cc28 --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/input/main_fail_name.in @@ -0,0 +1,2 @@ +[constants] +bad_name: bool = true; \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_constants/input/main_fail_type.in b/tests/compiler/input_files/program_input_constants/input/main_fail_type.in new file mode 100644 index 0000000000..0bb8f694fd --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/input/main_fail_type.in @@ -0,0 +1,2 @@ +[constants] +a: u8 = 1; \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_constants/input/main_field.in b/tests/compiler/input_files/program_input_constants/input/main_field.in new file mode 100644 index 0000000000..deea2a01a3 --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/input/main_field.in @@ -0,0 +1,3 @@ +[constants] +a: field = 1; +b: field = -1; \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_constants/input/main_group.in b/tests/compiler/input_files/program_input_constants/input/main_group.in new file mode 100644 index 0000000000..52e52dc6a8 --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/input/main_group.in @@ -0,0 +1,4 @@ +[constants] +a: group = 1group; +b: group = -1group; +c: group = (0, -1)group; \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_constants/input/main_multi_dimension_array.in b/tests/compiler/input_files/program_input_constants/input/main_multi_dimension_array.in new file mode 100644 index 0000000000..0d052ae99b --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/input/main_multi_dimension_array.in @@ -0,0 +1,2 @@ +[constants] +x: [i16; (2, 2, 3)] = [0i16; (2, 2, 3)]; \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_constants/input/main_multiple.in b/tests/compiler/input_files/program_input_constants/input/main_multiple.in new file mode 100644 index 0000000000..3e61056b7b --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/input/main_multiple.in @@ -0,0 +1,3 @@ +[constants] +a: bool = true; +b: bool = false; diff --git a/tests/compiler/input_files/program_input_constants/input/main_not_const_input_fail.in b/tests/compiler/input_files/program_input_constants/input/main_not_const_input_fail.in new file mode 100644 index 0000000000..b2aaee854e --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/input/main_not_const_input_fail.in @@ -0,0 +1,2 @@ +[main] +a: bool = true; // expecting const a, not main a \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_constants/input/main_tuple_fail.in b/tests/compiler/input_files/program_input_constants/input/main_tuple_fail.in new file mode 100644 index 0000000000..4341911fba --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/input/main_tuple_fail.in @@ -0,0 +1,2 @@ +[constants] +x: (u8, bool) = (10, true); // wrong size here; main expects (u8, bool, u8) \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_constants/input/main_type_mismatch.in b/tests/compiler/input_files/program_input_constants/input/main_type_mismatch.in new file mode 100644 index 0000000000..d50f65428d --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/input/main_type_mismatch.in @@ -0,0 +1,2 @@ +[constants] +a: u8 = 10; \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_constants/main.leo b/tests/compiler/input_files/program_input_constants/main.leo new file mode 100644 index 0000000000..0c33516ba8 --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/main.leo @@ -0,0 +1,3 @@ +function main(const a: bool) { + console.assert(a == true); +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_constants/main_array.leo b/tests/compiler/input_files/program_input_constants/main_array.leo new file mode 100644 index 0000000000..aa592183da --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/main_array.leo @@ -0,0 +1,4 @@ +function main (const x: [i16; 1]) { + console.log("{}", x); + console.assert(x[0] == 0); +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_constants/main_array_fail.leo b/tests/compiler/input_files/program_input_constants/main_array_fail.leo new file mode 100644 index 0000000000..6e7656f9b9 --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/main_array_fail.leo @@ -0,0 +1,3 @@ +function main(const x: [i16; 2]){ + console.log("x: {}", x); +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_constants/main_field.leo b/tests/compiler/input_files/program_input_constants/main_field.leo new file mode 100644 index 0000000000..60fc67fc74 --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/main_field.leo @@ -0,0 +1,5 @@ +function main(const a: field, const b: field) { + // Change to assert when == is implemented for field. + console.log("a: {}", a); + console.log("b: {}", b); +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_constants/main_group.leo b/tests/compiler/input_files/program_input_constants/main_group.leo new file mode 100644 index 0000000000..93accf710d --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/main_group.leo @@ -0,0 +1,6 @@ +function main(const a: group, const b: group, const c: group) { + // Change to assert when == is implemented for group. + console.log("a: {}", a); + console.log("b: {}", b); + console.log("c: {}", c); +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_constants/main_multi_dimension_array.leo b/tests/compiler/input_files/program_input_constants/main_multi_dimension_array.leo new file mode 100644 index 0000000000..56a1b3c7cf --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/main_multi_dimension_array.leo @@ -0,0 +1,9 @@ +function main(const x: [i16; (2, 2, 3)]){ + console.log("x: {}", x); + + let y: [i16; (2, 2, 3)] = [0i16; (2, 2, 3)]; + console.log("y: {}", y); + + console.assert(x[0][0][0] == y[0][0][0]); + console.assert(x[1][1][2] == y[1][1][2]); +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_constants/main_multiple.leo b/tests/compiler/input_files/program_input_constants/main_multiple.leo new file mode 100644 index 0000000000..2c2179cc3d --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/main_multiple.leo @@ -0,0 +1,4 @@ +function main(const a: bool, const b: bool) { + console.assert(a == true); + console.assert(b == false); +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_constants/main_tuple_fail.leo b/tests/compiler/input_files/program_input_constants/main_tuple_fail.leo new file mode 100644 index 0000000000..639ec42835 --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/main_tuple_fail.leo @@ -0,0 +1,3 @@ +function main(const x: (u8, bool, u8)) { + console.log("x: {}", x); +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_input_constants/mod.rs b/tests/compiler/input_files/program_input_constants/mod.rs new file mode 100644 index 0000000000..284aef6312 --- /dev/null +++ b/tests/compiler/input_files/program_input_constants/mod.rs @@ -0,0 +1,145 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{assert_satisfied, expect_compiler_error, parse_program_with_input, EdwardsTestCompiler}; +use leo_compiler::errors::CompilerError; + +fn expect_fail(program: EdwardsTestCompiler) { + match expect_compiler_error(program) { + CompilerError::FunctionError(_) => {} + err => panic!("expected input parser error, got {:?}", err), + } +} + +#[test] +fn test_input_pass() { + let program_string = include_str!("main.leo"); + let input_string = include_str!("input/main.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_input_array_fail() { + let program_string = include_str!("main_array.leo"); + let input_string = include_str!("input/main_array.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_input_multi_dimension_array() { + let program_string = include_str!("main_multi_dimension_array.leo"); + let input_string = include_str!("input/main_multi_dimension_array.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_input_fail_name() { + let program_string = include_str!("main.leo"); + let input_string = include_str!("input/main_fail_name.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + expect_fail(program); +} + +#[test] +fn test_input_fail_type() { + let program_string = include_str!("main.leo"); + let input_string = include_str!("input/main_fail_type.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + expect_fail(program); +} + +#[test] +fn test_input_multiple() { + let program_string = include_str!("main_multiple.leo"); + let input_string = include_str!("input/main_multiple.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_input_array_dimensions_mismatch() { + let program_string = include_str!("main_array_fail.leo"); + let input_string = include_str!("input/main_array_fail.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + expect_fail(program); +} + +#[test] +fn test_input_double_declaration() { + let program_string = include_str!("main.leo"); + let input_string = include_str!("input/main_double_declaration_fail.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + expect_fail(program); +} + +#[test] +fn test_non_constant_input() { + let program_string = include_str!("main.leo"); + let input_string = include_str!("input/main_not_const_input_fail.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + expect_fail(program); +} + +#[test] +fn test_tuple_size_mismatch() { + let program_string = include_str!("main_tuple_fail.leo"); + let input_string = include_str!("input/main_tuple_fail.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + expect_fail(program); +} + +#[test] +fn test_field_input() { + let program_string = include_str!("main_field.leo"); + let input_string = include_str!("input/main_field.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_group_input() { + let program_string = include_str!("main_group.leo"); + let input_string = include_str!("input/main_group.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + assert_satisfied(program); +} diff --git a/tests/compiler/input_files/program_registers/input/array.in b/tests/compiler/input_files/program_registers/input/array.in new file mode 100644 index 0000000000..a952dda5a6 --- /dev/null +++ b/tests/compiler/input_files/program_registers/input/array.in @@ -0,0 +1,2 @@ +[registers] +r2: [[u8; 4]; 2] = [[0u64, 0u64, 0u64, 0u64], [0u64, 0u64, 0u64, 0u64]]; \ No newline at end of file diff --git a/tests/compiler/input_files/program_registers/input/main.in b/tests/compiler/input_files/program_registers/input/main.in new file mode 100644 index 0000000000..1bff5e584f --- /dev/null +++ b/tests/compiler/input_files/program_registers/input/main.in @@ -0,0 +1,4 @@ +[main] + +[registers] +r: u8 = 0u8; \ No newline at end of file diff --git a/tests/compiler/input_files/program_registers/mod.rs b/tests/compiler/input_files/program_registers/mod.rs new file mode 100644 index 0000000000..b172c141e0 --- /dev/null +++ b/tests/compiler/input_files/program_registers/mod.rs @@ -0,0 +1,53 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{expect_compiler_error, get_output, parse_program_with_input}; + +#[test] +fn test_registers_pass() { + let program_string = include_str!("registers_pass.leo"); + let input_string = include_str!("input/main.in"); + let expected = include_bytes!("output/registers_pass.out"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + let actual = get_output(program); + + assert!(expected.eq(actual.bytes().as_slice())); +} + +#[test] +fn test_registers_fail() { + let program_string = include_str!("registers_fail.leo"); + let input_string = include_str!("input/main.in"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + expect_compiler_error(program); +} + +#[test] +fn test_registers_array() { + let program_string = include_str!("registers_array.leo"); + let input_string = include_str!("input/array.in"); + let expected = include_bytes!("output/registers_array.out"); + + let program = parse_program_with_input(program_string, input_string).unwrap(); + + let actual = get_output(program); + + assert!(expected.eq(actual.bytes().as_slice())); +} diff --git a/tests/compiler/input_files/program_registers/output/registers_array.out b/tests/compiler/input_files/program_registers/output/registers_array.out new file mode 100644 index 0000000000..20294ac107 --- /dev/null +++ b/tests/compiler/input_files/program_registers/output/registers_array.out @@ -0,0 +1,2 @@ +[registers] +r2: [[u8; 4]; 2] = [[1, 2, 3, 4], [5, 6, 7, 8]]; diff --git a/tests/compiler/input_files/program_registers/output/registers_pass.out b/tests/compiler/input_files/program_registers/output/registers_pass.out new file mode 100644 index 0000000000..e26ba9195e --- /dev/null +++ b/tests/compiler/input_files/program_registers/output/registers_pass.out @@ -0,0 +1,2 @@ +[registers] +r: u8 = 1; diff --git a/tests/compiler/input_files/program_registers/registers_array.leo b/tests/compiler/input_files/program_registers/registers_array.leo new file mode 100644 index 0000000000..324515c13f --- /dev/null +++ b/tests/compiler/input_files/program_registers/registers_array.leo @@ -0,0 +1,3 @@ +function main () -> [[u8; 4]; 2] { + return [[1u8, 2u8, 3u8, 4u8], [5u8, 6u8, 7u8, 8u8]]; +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_registers/registers_fail.leo b/tests/compiler/input_files/program_registers/registers_fail.leo new file mode 100644 index 0000000000..78af2bb5d8 --- /dev/null +++ b/tests/compiler/input_files/program_registers/registers_fail.leo @@ -0,0 +1,3 @@ +function main() -> bool { + return false; +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_registers/registers_pass.leo b/tests/compiler/input_files/program_registers/registers_pass.leo new file mode 100644 index 0000000000..ff5ef4a0cd --- /dev/null +++ b/tests/compiler/input_files/program_registers/registers_pass.leo @@ -0,0 +1,3 @@ +function main() -> u8 { + return 1u8; +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_state/access_all.leo b/tests/compiler/input_files/program_state/access_all.leo new file mode 100644 index 0000000000..bf85a3f722 --- /dev/null +++ b/tests/compiler/input_files/program_state/access_all.leo @@ -0,0 +1,8 @@ +function main() { + console.assert(input.state.root == [0u8; 32]); + + const expected: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; + //console.assert(input.record.owner, expected); + + console.assert(input.state_leaf.network_id == 0u8); +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_state/access_state.leo b/tests/compiler/input_files/program_state/access_state.leo new file mode 100644 index 0000000000..a7afe50a5f --- /dev/null +++ b/tests/compiler/input_files/program_state/access_state.leo @@ -0,0 +1,3 @@ +function main() { + console.assert(input.state.root == [0u8; 32]); +} \ No newline at end of file diff --git a/tests/compiler/input_files/program_state/input/basic.state b/tests/compiler/input_files/program_state/input/basic.state new file mode 100644 index 0000000000..2f40f7f1c4 --- /dev/null +++ b/tests/compiler/input_files/program_state/input/basic.state @@ -0,0 +1,10 @@ +[[public]] +[state] +root: bool = true; + +[[private]] +[record] +id: bool = false; + +[state_leaf] +leaf: bool = true; \ No newline at end of file diff --git a/tests/compiler/input_files/program_state/input/section_invalid.state b/tests/compiler/input_files/program_state/input/section_invalid.state new file mode 100644 index 0000000000..955b881192 --- /dev/null +++ b/tests/compiler/input_files/program_state/input/section_invalid.state @@ -0,0 +1,4 @@ +[[public]] + +[record] +a: bool = true; \ No newline at end of file diff --git a/tests/compiler/input_files/program_state/input/section_undefined.state b/tests/compiler/input_files/program_state/input/section_undefined.state new file mode 100644 index 0000000000..5f881cbb29 --- /dev/null +++ b/tests/compiler/input_files/program_state/input/section_undefined.state @@ -0,0 +1,4 @@ +[[public]] + +[invalid] +a: bool = true; \ No newline at end of file diff --git a/tests/compiler/input_files/program_state/input/token_withdraw.state b/tests/compiler/input_files/program_state/input/token_withdraw.state new file mode 100644 index 0000000000..219fc44776 --- /dev/null +++ b/tests/compiler/input_files/program_state/input/token_withdraw.state @@ -0,0 +1,24 @@ +[[public]] + +[state] +leaf_index: u32 = 0; +root: [u8; 32] = [0u8; 32]; + +[[private]] + +[record] +serial_number: [u8; 32] = [0u8; 32]; +commitment: [u8; 32] = [0u8; 32]; +owner: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; +value: u64 = 5; +payload: [u8; 32] = [0u8; 32]; +birth_program_id: [u8; 32] = [0u8; 32]; +death_program_id: [u8; 32] = [0u8; 32]; +serial_number_nonce: [u8; 32] = [0u8; 32]; +commitment_randomness: [u8; 32] = [0u8; 32]; + +[state_leaf] +path: [u8; 128] = [0u8; 128]; +memo: [u8; 32] = [0u8; 32]; +network_id: u8 = 0; +leaf_randomness: [u8; 32] = [0u8; 32]; \ No newline at end of file diff --git a/tests/compiler/input_files/program_state/input/visibility_fail.state b/tests/compiler/input_files/program_state/input/visibility_fail.state new file mode 100644 index 0000000000..c5928ddcbd --- /dev/null +++ b/tests/compiler/input_files/program_state/input/visibility_fail.state @@ -0,0 +1 @@ +[[pure]] \ No newline at end of file diff --git a/tests/compiler/input_files/program_state/mod.rs b/tests/compiler/input_files/program_state/mod.rs new file mode 100644 index 0000000000..c5959196f5 --- /dev/null +++ b/tests/compiler/input_files/program_state/mod.rs @@ -0,0 +1,78 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{assert_satisfied, parse_program_with_state, parse_state}; + +#[test] +fn test_basic() { + let state_string = include_str!("input/basic.state"); + + parse_state(state_string).unwrap(); +} + +#[test] +fn test_token_withdraw() { + let state_string = include_str!("input/token_withdraw.state"); + + parse_state(state_string).unwrap(); +} + +#[test] +fn test_access_state() { + let program_string = include_str!("access_state.leo"); + let state_string = include_str!("input/token_withdraw.state"); + + let program = parse_program_with_state(program_string, state_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_access_all() { + let program_string = include_str!("access_all.leo"); + let state_string = include_str!("input/token_withdraw.state"); + + let program = parse_program_with_state(program_string, state_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_visibility_fail() { + let state_string = include_str!("input/visibility_fail.state"); + + let is_err = parse_state(state_string).is_err(); + + assert!(is_err); +} + +#[test] +fn test_section_undefined() { + let state_string = include_str!("input/section_undefined.state"); + + let is_err = parse_state(state_string).is_err(); + + assert!(is_err); +} + +#[test] +fn test_section_invalid() { + let state_string = include_str!("input/section_invalid.state"); + + let is_err = parse_state(state_string).is_err(); + + assert!(is_err); +} diff --git a/tests/compiler/integers/i128/add.leo b/tests/compiler/integers/i128/add.leo new file mode 100644 index 0000000000..e35648f545 --- /dev/null +++ b/tests/compiler/integers/i128/add.leo @@ -0,0 +1,3 @@ +function main(a: i128, b: i128, c: i128) { + console.assert(a + b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i128/console_assert.leo b/tests/compiler/integers/i128/console_assert.leo new file mode 100644 index 0000000000..c89021f609 --- /dev/null +++ b/tests/compiler/integers/i128/console_assert.leo @@ -0,0 +1,3 @@ +function main(a: i128, b: i128) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/i128/div.leo b/tests/compiler/integers/i128/div.leo new file mode 100644 index 0000000000..ffaeae19a8 --- /dev/null +++ b/tests/compiler/integers/i128/div.leo @@ -0,0 +1,3 @@ +function main(a: i128, b: i128, c: i128) { + console.assert(a / b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i128/eq.leo b/tests/compiler/integers/i128/eq.leo new file mode 100644 index 0000000000..f4beddc8fc --- /dev/null +++ b/tests/compiler/integers/i128/eq.leo @@ -0,0 +1,3 @@ +function main(a: i128, b: i128, c: bool) { + console.assert(a == b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i128/ge.leo b/tests/compiler/integers/i128/ge.leo new file mode 100644 index 0000000000..1fbbd68073 --- /dev/null +++ b/tests/compiler/integers/i128/ge.leo @@ -0,0 +1,3 @@ +function main(a: i128, b: i128, c: bool) { + console.assert(a >= b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i128/gt.leo b/tests/compiler/integers/i128/gt.leo new file mode 100644 index 0000000000..27849afbe8 --- /dev/null +++ b/tests/compiler/integers/i128/gt.leo @@ -0,0 +1,3 @@ +function main(a: i128, b: i128, c: bool) { + console.assert(a > b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i128/input.leo b/tests/compiler/integers/i128/input.leo new file mode 100644 index 0000000000..c89021f609 --- /dev/null +++ b/tests/compiler/integers/i128/input.leo @@ -0,0 +1,3 @@ +function main(a: i128, b: i128) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/i128/le.leo b/tests/compiler/integers/i128/le.leo new file mode 100644 index 0000000000..ea0c3c9e1d --- /dev/null +++ b/tests/compiler/integers/i128/le.leo @@ -0,0 +1,3 @@ +function main(a: i128, b: i128, c: bool) { + console.assert(a <= b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i128/lt.leo b/tests/compiler/integers/i128/lt.leo new file mode 100644 index 0000000000..bde4def85c --- /dev/null +++ b/tests/compiler/integers/i128/lt.leo @@ -0,0 +1,3 @@ +function main(a: i128, b: i128, c: bool) { + console.assert(a < b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i128/max.leo b/tests/compiler/integers/i128/max.leo new file mode 100644 index 0000000000..5ba44213e1 --- /dev/null +++ b/tests/compiler/integers/i128/max.leo @@ -0,0 +1,3 @@ +function main() { + const a: i128 = 170141183460469231731687303715884105727; +} \ No newline at end of file diff --git a/tests/compiler/integers/i128/max_fail.leo b/tests/compiler/integers/i128/max_fail.leo new file mode 100644 index 0000000000..a9a46afd7f --- /dev/null +++ b/tests/compiler/integers/i128/max_fail.leo @@ -0,0 +1,3 @@ +function main() { + const a: i128 = 170141183460469231731687303715884105728; +} \ No newline at end of file diff --git a/tests/compiler/integers/i128/min.leo b/tests/compiler/integers/i128/min.leo new file mode 100644 index 0000000000..19509a3fb0 --- /dev/null +++ b/tests/compiler/integers/i128/min.leo @@ -0,0 +1,3 @@ +function main() { + const a: i128 = -170141183460469231731687303715884105728; +} \ No newline at end of file diff --git a/tests/compiler/integers/i128/min_fail.leo b/tests/compiler/integers/i128/min_fail.leo new file mode 100644 index 0000000000..918f0e439d --- /dev/null +++ b/tests/compiler/integers/i128/min_fail.leo @@ -0,0 +1,3 @@ +function main() { + const a: i128 = -170141183460469231731687303715884105729; +} \ No newline at end of file diff --git a/tests/compiler/integers/i128/mod.rs b/tests/compiler/integers/i128/mod.rs new file mode 100644 index 0000000000..ead011f14e --- /dev/null +++ b/tests/compiler/integers/i128/mod.rs @@ -0,0 +1,142 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + integers::{expect_computation_error, IntegerTester}, + parse_program, +}; +use leo_ast::InputValue; +use leo_input::types::{I128Type, IntegerType, SignedIntegerType}; + +test_int!( + TestI128, + i128, + IntegerType::Signed(SignedIntegerType::I128Type(I128Type {})), + Int128 +); + +#[test] +fn test_i128_min() { + TestI128::test_min(); +} + +#[test] +fn test_i128_min_fail() { + TestI128::test_min_fail(); +} + +#[test] +fn test_i128_max() { + TestI128::test_max(); +} + +#[test] +fn test_i128_max_fail() { + TestI128::test_max_fail(); +} + +#[test] +fn test_i128_neg() { + TestI128::test_negate(); +} + +#[test] +fn test_i128_neg_max_fail() { + TestI128::test_negate_min_fail(); +} + +#[test] +fn test_i128_neg_zero() { + TestI128::test_negate_zero(); +} + +#[test] +fn test_i128_add() { + TestI128::test_add(); +} + +#[test] +fn test_i128_sub() { + TestI128::test_sub(); +} + +#[test] +fn test_i128_mul() { + TestI128::test_mul(); +} + +#[test] +#[ignore] // takes several minutes +fn test_i128_div() { + TestI128::test_div(); +} + +#[test] +fn test_i128_pow() { + TestI128::test_pow(); +} + +#[test] +fn test_i128_eq() { + TestI128::test_eq(); +} + +#[test] +fn test_i128_ne() { + TestI128::test_ne(); +} + +#[test] +fn test_i128_ge() { + TestI128::test_ge(); +} + +#[test] +fn test_i128_gt() { + TestI128::test_gt(); +} + +#[test] +fn test_i128_le() { + TestI128::test_le(); +} + +#[test] +fn test_i128_lt() { + TestI128::test_lt(); +} + +#[test] +fn test_i128_assert_eq() { + TestI128::test_console_assert(); +} + +#[test] +fn test_i128_ternary() { + TestI128::test_ternary(); +} + +#[test] +fn test_no_space_between_literal() { + let program_string = include_str!("no_space_between_literal.leo"); + let program = parse_program(program_string); + + assert!(program.is_err()); +} diff --git a/tests/compiler/integers/i128/mul.leo b/tests/compiler/integers/i128/mul.leo new file mode 100644 index 0000000000..25b902d53c --- /dev/null +++ b/tests/compiler/integers/i128/mul.leo @@ -0,0 +1,3 @@ +function main(a: i128, b: i128, c: i128) { + console.assert(a * b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i128/ne.leo b/tests/compiler/integers/i128/ne.leo new file mode 100644 index 0000000000..dae148b49c --- /dev/null +++ b/tests/compiler/integers/i128/ne.leo @@ -0,0 +1,3 @@ +function main(a: i128, b: i128, c: bool) { + console.assert(a != b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i128/negate.leo b/tests/compiler/integers/i128/negate.leo new file mode 100644 index 0000000000..437ee06390 --- /dev/null +++ b/tests/compiler/integers/i128/negate.leo @@ -0,0 +1,3 @@ +function main(a: i128, b: i128) { + console.assert(-a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/i128/negate_min.leo b/tests/compiler/integers/i128/negate_min.leo new file mode 100644 index 0000000000..c9de272960 --- /dev/null +++ b/tests/compiler/integers/i128/negate_min.leo @@ -0,0 +1,4 @@ +function main() { + const a: i128 = -170141183460469231731687303715884105728; + const b = -a; +} \ No newline at end of file diff --git a/tests/compiler/integers/i128/negate_zero.leo b/tests/compiler/integers/i128/negate_zero.leo new file mode 100644 index 0000000000..e079baf393 --- /dev/null +++ b/tests/compiler/integers/i128/negate_zero.leo @@ -0,0 +1,5 @@ +function main() { + const a = 0i128; + + console.assert(-a == 0i128); +} \ No newline at end of file diff --git a/tests/compiler/integers/i128/no_space_between_literal.leo b/tests/compiler/integers/i128/no_space_between_literal.leo new file mode 100644 index 0000000000..3142fb5724 --- /dev/null +++ b/tests/compiler/integers/i128/no_space_between_literal.leo @@ -0,0 +1,3 @@ +function main() { + const i = 1 i128; +} \ No newline at end of file diff --git a/tests/compiler/integers/i128/pow.leo b/tests/compiler/integers/i128/pow.leo new file mode 100644 index 0000000000..05536aad51 --- /dev/null +++ b/tests/compiler/integers/i128/pow.leo @@ -0,0 +1,3 @@ +function main(a: i128, b: i128, c: i128) { + console.assert(a ** b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i128/sub.leo b/tests/compiler/integers/i128/sub.leo new file mode 100644 index 0000000000..3a723eec49 --- /dev/null +++ b/tests/compiler/integers/i128/sub.leo @@ -0,0 +1,3 @@ +function main(a: i128, b: i128, c: i128) { + console.assert(a - b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i128/ternary.leo b/tests/compiler/integers/i128/ternary.leo new file mode 100644 index 0000000000..3783463b22 --- /dev/null +++ b/tests/compiler/integers/i128/ternary.leo @@ -0,0 +1,5 @@ +function main(s: bool, a: i128, b: i128, c: i128) { + const r = s ? a : b; + + console.assert(r == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/add.leo b/tests/compiler/integers/i16/add.leo new file mode 100644 index 0000000000..556ae65c3a --- /dev/null +++ b/tests/compiler/integers/i16/add.leo @@ -0,0 +1,3 @@ +function main(a: i16, b: i16, c: i16) { + console.assert(a + b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/console_assert.leo b/tests/compiler/integers/i16/console_assert.leo new file mode 100644 index 0000000000..3afb25b207 --- /dev/null +++ b/tests/compiler/integers/i16/console_assert.leo @@ -0,0 +1,3 @@ +function main(a: i16, b: i16) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/div.leo b/tests/compiler/integers/i16/div.leo new file mode 100644 index 0000000000..6d0c8f4614 --- /dev/null +++ b/tests/compiler/integers/i16/div.leo @@ -0,0 +1,3 @@ +function main(a: i16, b: i16, c: i16) { + console.assert(a / b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/eq.leo b/tests/compiler/integers/i16/eq.leo new file mode 100644 index 0000000000..338e3e50f6 --- /dev/null +++ b/tests/compiler/integers/i16/eq.leo @@ -0,0 +1,3 @@ +function main(a: i16, b: i16, c: bool) { + console.assert(a == b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/ge.leo b/tests/compiler/integers/i16/ge.leo new file mode 100644 index 0000000000..68a4d40bf8 --- /dev/null +++ b/tests/compiler/integers/i16/ge.leo @@ -0,0 +1,3 @@ +function main(a: i16, b: i16, c: bool) { + console.assert(a >= b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/gt.leo b/tests/compiler/integers/i16/gt.leo new file mode 100644 index 0000000000..75d9bfb612 --- /dev/null +++ b/tests/compiler/integers/i16/gt.leo @@ -0,0 +1,3 @@ +function main(a: i16, b: i16, c: bool) { + console.assert(a > b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/input.leo b/tests/compiler/integers/i16/input.leo new file mode 100644 index 0000000000..3afb25b207 --- /dev/null +++ b/tests/compiler/integers/i16/input.leo @@ -0,0 +1,3 @@ +function main(a: i16, b: i16) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/le.leo b/tests/compiler/integers/i16/le.leo new file mode 100644 index 0000000000..ff112c7fbc --- /dev/null +++ b/tests/compiler/integers/i16/le.leo @@ -0,0 +1,3 @@ +function main(a: i16, b: i16, c: bool) { + console.assert(a <= b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/lt.leo b/tests/compiler/integers/i16/lt.leo new file mode 100644 index 0000000000..46c57aabe6 --- /dev/null +++ b/tests/compiler/integers/i16/lt.leo @@ -0,0 +1,3 @@ +function main(a: i16, b: i16, c: bool) { + console.assert(a < b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/max.leo b/tests/compiler/integers/i16/max.leo new file mode 100644 index 0000000000..2b70b3cc56 --- /dev/null +++ b/tests/compiler/integers/i16/max.leo @@ -0,0 +1,3 @@ +function main() { + const a: i16 = 32767; +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/max_fail.leo b/tests/compiler/integers/i16/max_fail.leo new file mode 100644 index 0000000000..209bcc6518 --- /dev/null +++ b/tests/compiler/integers/i16/max_fail.leo @@ -0,0 +1,3 @@ +function main() { + const a: i16 = 32768; +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/min.leo b/tests/compiler/integers/i16/min.leo new file mode 100644 index 0000000000..3d05bef95a --- /dev/null +++ b/tests/compiler/integers/i16/min.leo @@ -0,0 +1,3 @@ +function main() { + const a: i16 = -32768; +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/min_fail.leo b/tests/compiler/integers/i16/min_fail.leo new file mode 100644 index 0000000000..13d7c8b7f2 --- /dev/null +++ b/tests/compiler/integers/i16/min_fail.leo @@ -0,0 +1,3 @@ +function main() { + const a: i16 = -32769; +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/mod.rs b/tests/compiler/integers/i16/mod.rs new file mode 100644 index 0000000000..6f415a0877 --- /dev/null +++ b/tests/compiler/integers/i16/mod.rs @@ -0,0 +1,141 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + integers::{expect_computation_error, IntegerTester}, + parse_program, +}; +use leo_ast::InputValue; +use leo_input::types::{I16Type, IntegerType, SignedIntegerType}; + +test_int!( + TestI16, + i16, + IntegerType::Signed(SignedIntegerType::I16Type(I16Type {})), + Int16 +); + +#[test] +fn test_i16_min() { + TestI16::test_min(); +} + +#[test] +fn test_i16_min_fail() { + TestI16::test_min_fail(); +} + +#[test] +fn test_i16_max() { + TestI16::test_max(); +} + +#[test] +fn test_i16_max_fail() { + TestI16::test_max_fail(); +} + +#[test] +fn test_i16_neg() { + TestI16::test_negate(); +} + +#[test] +fn test_i16_neg_max_fail() { + TestI16::test_negate_min_fail(); +} + +#[test] +fn test_i16_neg_zero() { + TestI16::test_negate_zero(); +} + +#[test] +fn test_i16_add() { + TestI16::test_add(); +} + +#[test] +fn test_i16_sub() { + TestI16::test_sub(); +} + +#[test] +fn test_i16_mul() { + TestI16::test_mul(); +} + +#[test] +fn test_i16_div() { + TestI16::test_div(); +} + +#[test] +fn test_i16_pow() { + TestI16::test_pow(); +} + +#[test] +fn test_i16_eq() { + TestI16::test_eq(); +} + +#[test] +fn test_i16_ne() { + TestI16::test_ne(); +} + +#[test] +fn test_i16_ge() { + TestI16::test_ge(); +} + +#[test] +fn test_i16_gt() { + TestI16::test_gt(); +} + +#[test] +fn test_i16_le() { + TestI16::test_le(); +} + +#[test] +fn test_i16_lt() { + TestI16::test_lt(); +} + +#[test] +fn test_i16_console_assert() { + TestI16::test_console_assert(); +} + +#[test] +fn test_i16_ternary() { + TestI16::test_ternary(); +} + +#[test] +fn test_no_space_between_literal() { + let program_string = include_str!("no_space_between_literal.leo"); + let program = parse_program(program_string); + + assert!(program.is_err()); +} diff --git a/tests/compiler/integers/i16/mul.leo b/tests/compiler/integers/i16/mul.leo new file mode 100644 index 0000000000..6fd19b703a --- /dev/null +++ b/tests/compiler/integers/i16/mul.leo @@ -0,0 +1,3 @@ +function main(a: i16, b: i16, c: i16) { + console.assert(a * b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/ne.leo b/tests/compiler/integers/i16/ne.leo new file mode 100644 index 0000000000..f0a9472678 --- /dev/null +++ b/tests/compiler/integers/i16/ne.leo @@ -0,0 +1,3 @@ +function main(a: i16, b: i16, c: bool) { + console.assert(a != b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/negate.leo b/tests/compiler/integers/i16/negate.leo new file mode 100644 index 0000000000..1d2644dce7 --- /dev/null +++ b/tests/compiler/integers/i16/negate.leo @@ -0,0 +1,3 @@ +function main(a: i16, b: i16) { + console.assert(-a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/negate_min.leo b/tests/compiler/integers/i16/negate_min.leo new file mode 100644 index 0000000000..d52a356396 --- /dev/null +++ b/tests/compiler/integers/i16/negate_min.leo @@ -0,0 +1,4 @@ +function main() { + const a = -32768i16; + const b = -a; +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/negate_zero.leo b/tests/compiler/integers/i16/negate_zero.leo new file mode 100644 index 0000000000..20f8a4fba7 --- /dev/null +++ b/tests/compiler/integers/i16/negate_zero.leo @@ -0,0 +1,5 @@ +function main() { + const a = 0i16; + + console.assert(-a == 0i16); +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/no_space_between_literal.leo b/tests/compiler/integers/i16/no_space_between_literal.leo new file mode 100644 index 0000000000..96c6b2a914 --- /dev/null +++ b/tests/compiler/integers/i16/no_space_between_literal.leo @@ -0,0 +1,3 @@ +function main() { + const i = 1 i16; +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/pow.leo b/tests/compiler/integers/i16/pow.leo new file mode 100644 index 0000000000..769d2d2fbb --- /dev/null +++ b/tests/compiler/integers/i16/pow.leo @@ -0,0 +1,3 @@ +function main(a: i16, b: i16, c: i16) { + console.assert(a ** b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/sub.leo b/tests/compiler/integers/i16/sub.leo new file mode 100644 index 0000000000..e935935187 --- /dev/null +++ b/tests/compiler/integers/i16/sub.leo @@ -0,0 +1,3 @@ +function main(a: i16, b: i16, c: i16) { + console.assert(a - b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i16/ternary.leo b/tests/compiler/integers/i16/ternary.leo new file mode 100644 index 0000000000..d66c73cb93 --- /dev/null +++ b/tests/compiler/integers/i16/ternary.leo @@ -0,0 +1,5 @@ +function main(s: bool, a: i16, b: i16, c: i16) { + const r = s ? a : b; + + console.assert(r == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/add.leo b/tests/compiler/integers/i32/add.leo new file mode 100644 index 0000000000..3d8fb1b1d2 --- /dev/null +++ b/tests/compiler/integers/i32/add.leo @@ -0,0 +1,3 @@ +function main(a: i32, b: i32, c: i32) { + console.assert(a + b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/console_assert.leo b/tests/compiler/integers/i32/console_assert.leo new file mode 100644 index 0000000000..a2d6980e9a --- /dev/null +++ b/tests/compiler/integers/i32/console_assert.leo @@ -0,0 +1,3 @@ +function main(a: i32, b: i32) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/div.leo b/tests/compiler/integers/i32/div.leo new file mode 100644 index 0000000000..3189a354f0 --- /dev/null +++ b/tests/compiler/integers/i32/div.leo @@ -0,0 +1,3 @@ +function main(a: i32, b: i32, c: i32) { + console.assert(a / b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/eq.leo b/tests/compiler/integers/i32/eq.leo new file mode 100644 index 0000000000..bac7af0be0 --- /dev/null +++ b/tests/compiler/integers/i32/eq.leo @@ -0,0 +1,3 @@ +function main(a: i32, b: i32, c: bool) { + console.assert(a == b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/ge.leo b/tests/compiler/integers/i32/ge.leo new file mode 100644 index 0000000000..362521fc82 --- /dev/null +++ b/tests/compiler/integers/i32/ge.leo @@ -0,0 +1,3 @@ +function main(a: i32, b: i32, c: bool) { + console.assert(a >= b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/gt.leo b/tests/compiler/integers/i32/gt.leo new file mode 100644 index 0000000000..63ddcaa85c --- /dev/null +++ b/tests/compiler/integers/i32/gt.leo @@ -0,0 +1,3 @@ +function main(a: i32, b: i32, c: bool) { + console.assert(a > b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/input.leo b/tests/compiler/integers/i32/input.leo new file mode 100644 index 0000000000..a2d6980e9a --- /dev/null +++ b/tests/compiler/integers/i32/input.leo @@ -0,0 +1,3 @@ +function main(a: i32, b: i32) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/le.leo b/tests/compiler/integers/i32/le.leo new file mode 100644 index 0000000000..948c66b1fc --- /dev/null +++ b/tests/compiler/integers/i32/le.leo @@ -0,0 +1,3 @@ +function main(a: i32, b: i32, c: bool) { + console.assert(a <= b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/lt.leo b/tests/compiler/integers/i32/lt.leo new file mode 100644 index 0000000000..72a8fb0d53 --- /dev/null +++ b/tests/compiler/integers/i32/lt.leo @@ -0,0 +1,3 @@ +function main(a: i32, b: i32, c: bool) { + console.assert(a < b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/max.leo b/tests/compiler/integers/i32/max.leo new file mode 100644 index 0000000000..074c75f1a6 --- /dev/null +++ b/tests/compiler/integers/i32/max.leo @@ -0,0 +1,3 @@ +function main() { + const a: i32 = 2147483647; +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/max_fail.leo b/tests/compiler/integers/i32/max_fail.leo new file mode 100644 index 0000000000..af2877ff5e --- /dev/null +++ b/tests/compiler/integers/i32/max_fail.leo @@ -0,0 +1,3 @@ +function main() { + const a: i32 = 2147483648; +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/min.leo b/tests/compiler/integers/i32/min.leo new file mode 100644 index 0000000000..8436268ce6 --- /dev/null +++ b/tests/compiler/integers/i32/min.leo @@ -0,0 +1,3 @@ +function main() { + const a: i32 = -2147483648; +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/min_fail.leo b/tests/compiler/integers/i32/min_fail.leo new file mode 100644 index 0000000000..11a683b087 --- /dev/null +++ b/tests/compiler/integers/i32/min_fail.leo @@ -0,0 +1,3 @@ +function main() { + const a: i32 = -2147483649; +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/mod.rs b/tests/compiler/integers/i32/mod.rs new file mode 100644 index 0000000000..b8a6925ac2 --- /dev/null +++ b/tests/compiler/integers/i32/mod.rs @@ -0,0 +1,141 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + integers::{expect_computation_error, IntegerTester}, + parse_program, +}; +use leo_ast::InputValue; +use leo_input::types::{I32Type, IntegerType, SignedIntegerType}; + +test_int!( + TestI32, + i32, + IntegerType::Signed(SignedIntegerType::I32Type(I32Type {})), + Int32 +); + +#[test] +fn test_i32_min() { + TestI32::test_min(); +} + +#[test] +fn test_i32_min_fail() { + TestI32::test_min_fail(); +} + +#[test] +fn test_i32_max() { + TestI32::test_max(); +} + +#[test] +fn test_i32_max_fail() { + TestI32::test_max_fail(); +} + +#[test] +fn test_i32_neg() { + TestI32::test_negate(); +} + +#[test] +fn test_i32_neg_max_fail() { + TestI32::test_negate_min_fail(); +} + +#[test] +fn test_i32_neg_zero() { + TestI32::test_negate_zero(); +} + +#[test] +fn test_i32_add() { + TestI32::test_add(); +} + +#[test] +fn test_i32_sub() { + TestI32::test_sub(); +} + +#[test] +fn test_i32_mul() { + TestI32::test_mul(); +} + +#[test] +fn test_i32_div() { + TestI32::test_div(); +} + +#[test] +fn test_i32_pow() { + TestI32::test_pow(); +} + +#[test] +fn test_i32_eq() { + TestI32::test_eq(); +} + +#[test] +fn test_i32_ne() { + TestI32::test_ne(); +} + +#[test] +fn test_i32_ge() { + TestI32::test_ge(); +} + +#[test] +fn test_i32_gt() { + TestI32::test_gt(); +} + +#[test] +fn test_i32_le() { + TestI32::test_le(); +} + +#[test] +fn test_i32_lt() { + TestI32::test_lt(); +} + +#[test] +fn test_i32_console_assert() { + TestI32::test_console_assert(); +} + +#[test] +fn test_i32_ternary() { + TestI32::test_ternary(); +} + +#[test] +fn test_no_space_between_literal() { + let program_string = include_str!("no_space_between_literal.leo"); + let program = parse_program(program_string); + + assert!(program.is_err()); +} diff --git a/tests/compiler/integers/i32/mul.leo b/tests/compiler/integers/i32/mul.leo new file mode 100644 index 0000000000..50ba5b4128 --- /dev/null +++ b/tests/compiler/integers/i32/mul.leo @@ -0,0 +1,3 @@ +function main(a: i32, b: i32, c: i32) { + console.assert(a * b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/ne.leo b/tests/compiler/integers/i32/ne.leo new file mode 100644 index 0000000000..dcc1a185d1 --- /dev/null +++ b/tests/compiler/integers/i32/ne.leo @@ -0,0 +1,3 @@ +function main(a: i32, b: i32, c: bool) { + console.assert(a != b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/negate.leo b/tests/compiler/integers/i32/negate.leo new file mode 100644 index 0000000000..eef94c934f --- /dev/null +++ b/tests/compiler/integers/i32/negate.leo @@ -0,0 +1,3 @@ +function main(a: i32, b: i32) { + console.assert(-a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/negate_min.leo b/tests/compiler/integers/i32/negate_min.leo new file mode 100644 index 0000000000..a96455d57a --- /dev/null +++ b/tests/compiler/integers/i32/negate_min.leo @@ -0,0 +1,4 @@ +function main() { + const a = -2147483648i32; + const b = -a; +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/negate_zero.leo b/tests/compiler/integers/i32/negate_zero.leo new file mode 100644 index 0000000000..a3807b1f8a --- /dev/null +++ b/tests/compiler/integers/i32/negate_zero.leo @@ -0,0 +1,5 @@ +function main() { + const a = 0i32; + + console.assert(-a == 0i32); +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/no_space_between_literal.leo b/tests/compiler/integers/i32/no_space_between_literal.leo new file mode 100644 index 0000000000..845a7f403e --- /dev/null +++ b/tests/compiler/integers/i32/no_space_between_literal.leo @@ -0,0 +1,3 @@ +function main() { + const i = 1 i32; +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/pow.leo b/tests/compiler/integers/i32/pow.leo new file mode 100644 index 0000000000..ebb131e30b --- /dev/null +++ b/tests/compiler/integers/i32/pow.leo @@ -0,0 +1,3 @@ +function main(a: i32, b: i32, c: i32) { + console.assert(a ** b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/sub.leo b/tests/compiler/integers/i32/sub.leo new file mode 100644 index 0000000000..1f054a5ddf --- /dev/null +++ b/tests/compiler/integers/i32/sub.leo @@ -0,0 +1,3 @@ +function main(a: i32, b: i32, c: i32) { + console.assert(a - b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i32/ternary.leo b/tests/compiler/integers/i32/ternary.leo new file mode 100644 index 0000000000..790769d62f --- /dev/null +++ b/tests/compiler/integers/i32/ternary.leo @@ -0,0 +1,5 @@ +function main(s: bool, a: i32, b: i32, c: i32) { + const r = s ? a : b; + + console.assert(r == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/add.leo b/tests/compiler/integers/i64/add.leo new file mode 100644 index 0000000000..aefdbb178f --- /dev/null +++ b/tests/compiler/integers/i64/add.leo @@ -0,0 +1,3 @@ +function main(a: i64, b: i64, c: i64) { + console.assert(a + b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/console_assert.leo b/tests/compiler/integers/i64/console_assert.leo new file mode 100644 index 0000000000..ab9a5d6e91 --- /dev/null +++ b/tests/compiler/integers/i64/console_assert.leo @@ -0,0 +1,3 @@ +function main(a: i64, b: i64) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/div.leo b/tests/compiler/integers/i64/div.leo new file mode 100644 index 0000000000..142e4ab801 --- /dev/null +++ b/tests/compiler/integers/i64/div.leo @@ -0,0 +1,3 @@ +function main(a: i64, b: i64, c: i64) { + console.assert(a / b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/eq.leo b/tests/compiler/integers/i64/eq.leo new file mode 100644 index 0000000000..86a234c834 --- /dev/null +++ b/tests/compiler/integers/i64/eq.leo @@ -0,0 +1,3 @@ +function main(a: i64, b: i64, c: bool) { + console.assert(a == b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/ge.leo b/tests/compiler/integers/i64/ge.leo new file mode 100644 index 0000000000..e7b453c5dc --- /dev/null +++ b/tests/compiler/integers/i64/ge.leo @@ -0,0 +1,3 @@ +function main(a: i64, b: i64, c: bool) { + console.assert(a >= b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/gt.leo b/tests/compiler/integers/i64/gt.leo new file mode 100644 index 0000000000..9709bad012 --- /dev/null +++ b/tests/compiler/integers/i64/gt.leo @@ -0,0 +1,3 @@ +function main(a: i64, b: i64, c: bool) { + console.assert(a > b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/input.leo b/tests/compiler/integers/i64/input.leo new file mode 100644 index 0000000000..ab9a5d6e91 --- /dev/null +++ b/tests/compiler/integers/i64/input.leo @@ -0,0 +1,3 @@ +function main(a: i64, b: i64) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/le.leo b/tests/compiler/integers/i64/le.leo new file mode 100644 index 0000000000..3e2cfcb711 --- /dev/null +++ b/tests/compiler/integers/i64/le.leo @@ -0,0 +1,3 @@ +function main(a: i64, b: i64, c: bool) { + console.assert(a <= b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/lt.leo b/tests/compiler/integers/i64/lt.leo new file mode 100644 index 0000000000..ef4e38eb76 --- /dev/null +++ b/tests/compiler/integers/i64/lt.leo @@ -0,0 +1,3 @@ +function main(a: i64, b: i64, c: bool) { + console.assert(a < b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/max.leo b/tests/compiler/integers/i64/max.leo new file mode 100644 index 0000000000..593f91e110 --- /dev/null +++ b/tests/compiler/integers/i64/max.leo @@ -0,0 +1,3 @@ +function main() { + const a: i64 = 9223372036854775807; +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/max_fail.leo b/tests/compiler/integers/i64/max_fail.leo new file mode 100644 index 0000000000..362b794a2c --- /dev/null +++ b/tests/compiler/integers/i64/max_fail.leo @@ -0,0 +1,3 @@ +function main() { + const a: i64 = 9223372036854775808; +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/min.leo b/tests/compiler/integers/i64/min.leo new file mode 100644 index 0000000000..794d8fbfac --- /dev/null +++ b/tests/compiler/integers/i64/min.leo @@ -0,0 +1,3 @@ +function main() { + const a: i64 = -9223372036854775808; +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/min_fail.leo b/tests/compiler/integers/i64/min_fail.leo new file mode 100644 index 0000000000..bb260ecc3f --- /dev/null +++ b/tests/compiler/integers/i64/min_fail.leo @@ -0,0 +1,3 @@ +function main() { + const a: i64 = -9223372036854775809; +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/mod.rs b/tests/compiler/integers/i64/mod.rs new file mode 100644 index 0000000000..ccfb06ce68 --- /dev/null +++ b/tests/compiler/integers/i64/mod.rs @@ -0,0 +1,142 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + integers::{expect_computation_error, IntegerTester}, + parse_program, +}; +use leo_ast::InputValue; +use leo_input::types::{I64Type, IntegerType, SignedIntegerType}; + +test_int!( + TestI64, + i64, + IntegerType::Signed(SignedIntegerType::I64Type(I64Type {})), + Int64 +); + +#[test] +fn test_i64_min() { + TestI64::test_min(); +} + +#[test] +fn test_i64_min_fail() { + TestI64::test_min_fail(); +} + +#[test] +fn test_i64_max() { + TestI64::test_max(); +} + +#[test] +fn test_i64_max_fail() { + TestI64::test_max_fail(); +} + +#[test] +fn test_i64_neg() { + TestI64::test_negate(); +} + +#[test] +fn test_i64_neg_max_fail() { + TestI64::test_negate_min_fail(); +} + +#[test] +fn test_i64_neg_zero() { + TestI64::test_negate_zero(); +} + +#[test] +fn test_i64_add() { + TestI64::test_add(); +} + +#[test] +fn test_i64_sub() { + TestI64::test_sub(); +} + +#[test] +fn test_i64_mul() { + TestI64::test_mul(); +} + +#[test] +#[ignore] // takes 2 minutes +fn test_i64_div() { + TestI64::test_div(); +} + +#[test] +fn test_i64_pow() { + TestI64::test_pow(); +} + +#[test] +fn test_i64_eq() { + TestI64::test_eq(); +} + +#[test] +fn test_i64_ne() { + TestI64::test_ne(); +} + +#[test] +fn test_i64_ge() { + TestI64::test_ge(); +} + +#[test] +fn test_i64_gt() { + TestI64::test_gt(); +} + +#[test] +fn test_i64_le() { + TestI64::test_le(); +} + +#[test] +fn test_i64_lt() { + TestI64::test_lt(); +} + +#[test] +fn test_i64_console_assert() { + TestI64::test_console_assert(); +} + +#[test] +fn test_i64_ternary() { + TestI64::test_ternary(); +} + +#[test] +fn test_no_space_between_literal() { + let program_string = include_str!("no_space_between_literal.leo"); + let program = parse_program(program_string); + + assert!(program.is_err()); +} diff --git a/tests/compiler/integers/i64/mul.leo b/tests/compiler/integers/i64/mul.leo new file mode 100644 index 0000000000..a3b8bd1da5 --- /dev/null +++ b/tests/compiler/integers/i64/mul.leo @@ -0,0 +1,3 @@ +function main(a: i64, b: i64, c: i64) { + console.assert(a * b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/ne.leo b/tests/compiler/integers/i64/ne.leo new file mode 100644 index 0000000000..a2642bb479 --- /dev/null +++ b/tests/compiler/integers/i64/ne.leo @@ -0,0 +1,3 @@ +function main(a: i64, b: i64, c: bool) { + console.assert(a != b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/negate.leo b/tests/compiler/integers/i64/negate.leo new file mode 100644 index 0000000000..fe0cdc4d97 --- /dev/null +++ b/tests/compiler/integers/i64/negate.leo @@ -0,0 +1,3 @@ +function main(a: i64, b: i64) { + console.assert(-a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/negate_min.leo b/tests/compiler/integers/i64/negate_min.leo new file mode 100644 index 0000000000..daf694491b --- /dev/null +++ b/tests/compiler/integers/i64/negate_min.leo @@ -0,0 +1,4 @@ +function main() { + const a: i64 = -9223372036854775808; + const b = -a; +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/negate_zero.leo b/tests/compiler/integers/i64/negate_zero.leo new file mode 100644 index 0000000000..81f09c19a3 --- /dev/null +++ b/tests/compiler/integers/i64/negate_zero.leo @@ -0,0 +1,5 @@ +function main() { + const a = 0i64; + + console.assert(-a == 0i64); +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/no_space_between_literal.leo b/tests/compiler/integers/i64/no_space_between_literal.leo new file mode 100644 index 0000000000..7fb6ea9e62 --- /dev/null +++ b/tests/compiler/integers/i64/no_space_between_literal.leo @@ -0,0 +1,3 @@ +function main() { + const i = 1 i64; +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/pow.leo b/tests/compiler/integers/i64/pow.leo new file mode 100644 index 0000000000..dca2dace74 --- /dev/null +++ b/tests/compiler/integers/i64/pow.leo @@ -0,0 +1,3 @@ +function main(a: i64, b: i64, c: i64) { + console.assert(a ** b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/sub.leo b/tests/compiler/integers/i64/sub.leo new file mode 100644 index 0000000000..4d335e504b --- /dev/null +++ b/tests/compiler/integers/i64/sub.leo @@ -0,0 +1,3 @@ +function main(a: i64, b: i64, c: i64) { + console.assert(a - b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i64/ternary.leo b/tests/compiler/integers/i64/ternary.leo new file mode 100644 index 0000000000..df63b3ad6a --- /dev/null +++ b/tests/compiler/integers/i64/ternary.leo @@ -0,0 +1,5 @@ +function main(s: bool, a: i64, b: i64, c: i64) { + const r = s ? a : b; + + console.assert(r == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/add.leo b/tests/compiler/integers/i8/add.leo new file mode 100644 index 0000000000..dd71bc7f53 --- /dev/null +++ b/tests/compiler/integers/i8/add.leo @@ -0,0 +1,3 @@ +function main(a: i8, b: i8, c: i8) { + console.assert(a + b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/console_assert.leo b/tests/compiler/integers/i8/console_assert.leo new file mode 100644 index 0000000000..1fc09cb57d --- /dev/null +++ b/tests/compiler/integers/i8/console_assert.leo @@ -0,0 +1,3 @@ +function main(a: i8, b: i8) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/div.leo b/tests/compiler/integers/i8/div.leo new file mode 100644 index 0000000000..a80d8e6319 --- /dev/null +++ b/tests/compiler/integers/i8/div.leo @@ -0,0 +1,3 @@ +function main(a: i8, b: i8, c: i8) { + console.assert(a / b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/eq.leo b/tests/compiler/integers/i8/eq.leo new file mode 100644 index 0000000000..130cc64b89 --- /dev/null +++ b/tests/compiler/integers/i8/eq.leo @@ -0,0 +1,3 @@ +function main(a: i8, b: i8, c: bool) { + console.assert(a == b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/ge.leo b/tests/compiler/integers/i8/ge.leo new file mode 100644 index 0000000000..3084692c0c --- /dev/null +++ b/tests/compiler/integers/i8/ge.leo @@ -0,0 +1,3 @@ +function main(a: i8, b: i8, c: bool) { + console.assert(a >= b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/gt.leo b/tests/compiler/integers/i8/gt.leo new file mode 100644 index 0000000000..d3913b8b24 --- /dev/null +++ b/tests/compiler/integers/i8/gt.leo @@ -0,0 +1,3 @@ +function main(a: i8, b: i8, c: bool) { + console.assert(a > b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/input.leo b/tests/compiler/integers/i8/input.leo new file mode 100644 index 0000000000..1fc09cb57d --- /dev/null +++ b/tests/compiler/integers/i8/input.leo @@ -0,0 +1,3 @@ +function main(a: i8, b: i8) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/le.leo b/tests/compiler/integers/i8/le.leo new file mode 100644 index 0000000000..92e011f206 --- /dev/null +++ b/tests/compiler/integers/i8/le.leo @@ -0,0 +1,3 @@ +function main(a: i8, b: i8, c: bool) { + console.assert(a <= b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/lt.leo b/tests/compiler/integers/i8/lt.leo new file mode 100644 index 0000000000..eb34b7148e --- /dev/null +++ b/tests/compiler/integers/i8/lt.leo @@ -0,0 +1,3 @@ +function main(a: i8, b: i8, c: bool) { + console.assert(a < b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/max.leo b/tests/compiler/integers/i8/max.leo new file mode 100644 index 0000000000..f20d59ddf4 --- /dev/null +++ b/tests/compiler/integers/i8/max.leo @@ -0,0 +1,3 @@ +function main() { + const a: i8 = 127; +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/max_fail.leo b/tests/compiler/integers/i8/max_fail.leo new file mode 100644 index 0000000000..9e1956024a --- /dev/null +++ b/tests/compiler/integers/i8/max_fail.leo @@ -0,0 +1,3 @@ +function main() { + const a: i8 = 128; +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/min.leo b/tests/compiler/integers/i8/min.leo new file mode 100644 index 0000000000..7b6db025ea --- /dev/null +++ b/tests/compiler/integers/i8/min.leo @@ -0,0 +1,3 @@ +function main() { + const a: i8 = -128; +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/min_fail.leo b/tests/compiler/integers/i8/min_fail.leo new file mode 100644 index 0000000000..41170e9b93 --- /dev/null +++ b/tests/compiler/integers/i8/min_fail.leo @@ -0,0 +1,3 @@ +function main() { + const a: i8 = -129; +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/mod.rs b/tests/compiler/integers/i8/mod.rs new file mode 100644 index 0000000000..5073dda460 --- /dev/null +++ b/tests/compiler/integers/i8/mod.rs @@ -0,0 +1,141 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + integers::{expect_computation_error, IntegerTester}, + parse_program, +}; +use leo_ast::InputValue; +use leo_input::types::{I8Type, IntegerType, SignedIntegerType}; + +test_int!( + TestI8, + i8, + IntegerType::Signed(SignedIntegerType::I8Type(I8Type {})), + Int8 +); + +#[test] +fn test_i8_min() { + TestI8::test_min(); +} + +#[test] +fn test_i8_min_fail() { + TestI8::test_min_fail(); +} + +#[test] +fn test_i8_max() { + TestI8::test_max(); +} + +#[test] +fn test_i8_max_fail() { + TestI8::test_max_fail(); +} + +#[test] +fn test_i8_neg() { + TestI8::test_negate(); +} + +#[test] +fn test_i8_neg_max_fail() { + TestI8::test_negate_min_fail(); +} + +#[test] +fn test_i8_neg_zero() { + TestI8::test_negate_zero(); +} + +#[test] +fn test_i8_add() { + TestI8::test_add(); +} + +#[test] +fn test_i8_sub() { + TestI8::test_sub(); +} + +#[test] +fn test_i8_mul() { + TestI8::test_mul(); +} + +#[test] +fn test_i8_div() { + TestI8::test_div(); +} + +#[test] +fn test_i8_pow() { + TestI8::test_pow(); +} + +#[test] +fn test_i8_eq() { + TestI8::test_eq(); +} + +#[test] +fn test_i8_ne() { + TestI8::test_ne(); +} + +#[test] +fn test_i8_ge() { + TestI8::test_ge(); +} + +#[test] +fn test_i8_gt() { + TestI8::test_gt(); +} + +#[test] +fn test_i8_le() { + TestI8::test_le(); +} + +#[test] +fn test_i8_lt() { + TestI8::test_lt(); +} + +#[test] +fn test_i8_console_assert() { + TestI8::test_console_assert(); +} + +#[test] +fn test_i8_ternary() { + TestI8::test_ternary(); +} + +#[test] +fn test_no_space_between_literal() { + let program_string = include_str!("no_space_between_literal.leo"); + let program = parse_program(program_string); + + assert!(program.is_err()); +} diff --git a/tests/compiler/integers/i8/mul.leo b/tests/compiler/integers/i8/mul.leo new file mode 100644 index 0000000000..34726fff92 --- /dev/null +++ b/tests/compiler/integers/i8/mul.leo @@ -0,0 +1,3 @@ +function main(a: i8, b: i8, c: i8) { + console.assert(a * b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/ne.leo b/tests/compiler/integers/i8/ne.leo new file mode 100644 index 0000000000..e5028d404a --- /dev/null +++ b/tests/compiler/integers/i8/ne.leo @@ -0,0 +1,3 @@ +function main(a: i8, b: i8, c: bool) { + console.assert(a != b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/negate.leo b/tests/compiler/integers/i8/negate.leo new file mode 100644 index 0000000000..2a2266bc56 --- /dev/null +++ b/tests/compiler/integers/i8/negate.leo @@ -0,0 +1,3 @@ +function main(a: i8, b: i8) { + console.assert(-a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/negate_min.leo b/tests/compiler/integers/i8/negate_min.leo new file mode 100644 index 0000000000..7f664a1b78 --- /dev/null +++ b/tests/compiler/integers/i8/negate_min.leo @@ -0,0 +1,4 @@ +function main() { + const a = -128i8; + const b = -a; +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/negate_zero.leo b/tests/compiler/integers/i8/negate_zero.leo new file mode 100644 index 0000000000..cc3f4a0828 --- /dev/null +++ b/tests/compiler/integers/i8/negate_zero.leo @@ -0,0 +1,5 @@ +function main() { + const a = 0i8; + + console.assert(-a == 0i8); +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/no_space_between_literal.leo b/tests/compiler/integers/i8/no_space_between_literal.leo new file mode 100644 index 0000000000..7a8eda7ef9 --- /dev/null +++ b/tests/compiler/integers/i8/no_space_between_literal.leo @@ -0,0 +1,3 @@ +function main() { + const i = 1 i8; +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/pow.leo b/tests/compiler/integers/i8/pow.leo new file mode 100644 index 0000000000..18aeb44b46 --- /dev/null +++ b/tests/compiler/integers/i8/pow.leo @@ -0,0 +1,3 @@ +function main(a: i8, b: i8, c: i8) { + console.assert(a ** b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/sub.leo b/tests/compiler/integers/i8/sub.leo new file mode 100644 index 0000000000..a795bed153 --- /dev/null +++ b/tests/compiler/integers/i8/sub.leo @@ -0,0 +1,3 @@ +function main(a: i8, b: i8, c: i8) { + console.assert(a - b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/i8/ternary.leo b/tests/compiler/integers/i8/ternary.leo new file mode 100644 index 0000000000..0956a9cd39 --- /dev/null +++ b/tests/compiler/integers/i8/ternary.leo @@ -0,0 +1,5 @@ +function main(s: bool, a: i8, b: i8, c: i8) { + const r = s ? a : b; + + console.assert(r == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/int_macro.rs b/tests/compiler/integers/int_macro.rs new file mode 100644 index 0000000000..7867961fc4 --- /dev/null +++ b/tests/compiler/integers/int_macro.rs @@ -0,0 +1,538 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +macro_rules! test_int { + ($name: ident, $type_: ty, $integer_type: expr, $gadget: ty) => { + pub struct $name {} + + impl $name { + fn test_negate() { + for _ in 0..10 { + let a: $type_ = rand::random(); + + let b = match a.checked_neg() { + Some(valid) => valid, + None => continue, + }; + + let program_string = include_str!("negate.leo"); + let mut program = parse_program(program_string).unwrap(); + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_negate_min_fail() { + let program_string = include_str!("negate_min.leo"); + let program = parse_program(program_string).unwrap(); + + expect_computation_error(program); + } + + fn test_negate_zero() { + let program_string = include_str!("negate_zero.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); + } + } + + impl IntegerTester for $name { + fn test_min() { + let program_string = include_str!("min.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); + } + + fn test_min_fail() { + let program_string = include_str!("min_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); + } + + fn test_max() { + let program_string = include_str!("max.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); + } + + fn test_max_fail() { + let program_string = include_str!("max_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); + } + + fn test_add() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + let c = match a.checked_add(b) { + Some(valid) => valid, + None => continue, + }; + + let program_string = include_str!("add.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Integer($integer_type, c.to_string()))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_sub() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + if b.checked_neg().is_none() { + continue; + } + + let c = match a.checked_sub(b) { + Some(valid) => valid, + None => continue, + }; + + let program_string = include_str!("sub.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Integer($integer_type, c.to_string()))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_mul() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + let c = match a.checked_mul(b) { + Some(valid) => valid, + None => continue, + }; + + let program_string = include_str!("mul.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Integer($integer_type, c.to_string()))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_div() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + // make sure that we can calculate the inverse of each number + // Leo signed integer division is non-wrapping. Thus attempting to calculate a + // division result that wraps should be ignored here. + if a.checked_neg().is_none() { + continue; + } + + let program_string = include_str!("div.leo"); + let mut program = parse_program(program_string).unwrap(); + + // expect an error when dividing by zero + if b == 0 { + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Integer($integer_type, b.to_string()))), + ]); + + program.set_main_input(main_input); + + expect_compiler_error(program); + } else { + let c = match a.checked_div(b) { + Some(valid) => valid, + None => continue, + }; + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Integer($integer_type, c.to_string()))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + } + + fn test_pow() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + // rust specific conversion see https://doc.rust-lang.org/std/primitive.u8.html#method.checked_pow + let c = match a.checked_pow(b as u32) { + Some(valid) => valid, + None => continue, + }; + + let program_string = include_str!("pow.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Integer($integer_type, c.to_string()))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_eq() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + // test equal + + let program_string = include_str!("eq.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, a.to_string()))), + ("c", Some(InputValue::Boolean(true))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + + // test not equal + + let c = a.eq(&b); + + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Boolean(c))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_ne() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + // test a != a == false + + let program_string = include_str!("ne.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, a.to_string()))), + ("c", Some(InputValue::Boolean(false))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + + // test not equal + + let c = a.ne(&b); + + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Boolean(c))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_ge() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + // test equal + + let program_string = include_str!("ge.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, a.to_string()))), + ("c", Some(InputValue::Boolean(true))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + + // test greater or equal + + let c = a.ge(&b); + + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Boolean(c))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_gt() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + // test equal + + let program_string = include_str!("gt.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, a.to_string()))), + ("c", Some(InputValue::Boolean(false))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + + // test greater than + + let c = a.gt(&b); + + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Boolean(c))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_le() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + // test equal + + let program_string = include_str!("le.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, a.to_string()))), + ("c", Some(InputValue::Boolean(true))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + + // test less or equal + + let c = a.le(&b); + + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Boolean(c))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_lt() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + // test equal + + let program_string = include_str!("lt.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, a.to_string()))), + ("c", Some(InputValue::Boolean(false))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + + // test less or equal + + let c = a.lt(&b); + + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Boolean(c))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_console_assert() { + for _ in 0..10 { + let a: $type_ = rand::random(); + + // test equal + let program_string = include_str!("console_assert.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, a.to_string()))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + + // test not equal + let b: $type_ = rand::random(); + + if a == b { + continue; + } + + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ]); + + program.set_main_input(main_input); + + expect_compiler_error(program); + } + } + + fn test_ternary() { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + let program_string = include_str!("ternary.leo"); + let mut program = parse_program(program_string).unwrap(); + + // true -> field 1 + let main_input = generate_main_input(vec![ + ("s", Some(InputValue::Boolean(true))), + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Integer($integer_type, a.to_string()))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + + // false -> field 2 + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("s", Some(InputValue::Boolean(false))), + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Integer($integer_type, b.to_string()))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + }; +} diff --git a/tests/compiler/integers/integer_tester.rs b/tests/compiler/integers/integer_tester.rs new file mode 100644 index 0000000000..23085d5aac --- /dev/null +++ b/tests/compiler/integers/integer_tester.rs @@ -0,0 +1,83 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{expect_compiler_error, EdwardsTestCompiler}; +use leo_compiler::errors::{CompilerError, ExpressionError, FunctionError, IntegerError, StatementError}; + +pub trait IntegerTester { + /// Tests defining the smalled value that can be represented by the integer type + fn test_min(); + + /// Tests defining the smallest value - 1 + fn test_min_fail(); + + /// Tests defining the largest value that can be represented by the integer type + fn test_max(); + + /// Tests defining the largest value + 1 + fn test_max_fail(); + + /// Tests a non-wrapping addition + fn test_add(); + + /// Tests a non-wrapping subtraction + fn test_sub(); + + /// Tests a non-wrapping multiplication + fn test_mul(); + + /// Tests a non-wrapping division + fn test_div(); + + /// Tests a non-wrapping exponentiation + fn test_pow(); + + /// Tests == evaluation + fn test_eq(); + + /// Tests != evaluation + fn test_ne(); + + /// Tests >= evaluation + fn test_ge(); + + /// Tests > evaluation + fn test_gt(); + + /// Tests <= evaluation + fn test_le(); + + /// Tests < evaluation + fn test_lt(); + + /// Test assert equals constraint keyword + fn test_console_assert(); + + /// Test ternary if bool ? num_1 : num_2; + fn test_ternary(); +} + +pub(crate) fn expect_computation_error(program: EdwardsTestCompiler) { + match expect_compiler_error(program) { + CompilerError::FunctionError(FunctionError::StatementError(StatementError::ExpressionError( + ExpressionError::IntegerError(IntegerError::Error(_)), + ))) => {} + error => panic!( + "Expected integer computation error such as `DivisionByZero`, found {:?}", + error + ), + } +} diff --git a/tests/compiler/integers/mod.rs b/tests/compiler/integers/mod.rs new file mode 100644 index 0000000000..0cfd4f643c --- /dev/null +++ b/tests/compiler/integers/mod.rs @@ -0,0 +1,37 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +#[macro_use] +pub mod int_macro; + +#[macro_use] +pub mod uint_macro; + +pub mod integer_tester; +pub use self::integer_tester::*; + +// must be below macro definitions! +pub mod u128; +pub mod u16; +pub mod u32; +pub mod u64; +pub mod u8; + +pub mod i128; +pub mod i16; +pub mod i32; +pub mod i64; +pub mod i8; diff --git a/tests/compiler/integers/u128/add.leo b/tests/compiler/integers/u128/add.leo new file mode 100644 index 0000000000..6b32042fd5 --- /dev/null +++ b/tests/compiler/integers/u128/add.leo @@ -0,0 +1,3 @@ +function main(a: u128, b: u128, c: u128) { + console.assert(a + b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u128/console_assert.leo b/tests/compiler/integers/u128/console_assert.leo new file mode 100644 index 0000000000..adab295385 --- /dev/null +++ b/tests/compiler/integers/u128/console_assert.leo @@ -0,0 +1,3 @@ +function main(a: u128, b: u128) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/u128/div.leo b/tests/compiler/integers/u128/div.leo new file mode 100644 index 0000000000..0d62054eca --- /dev/null +++ b/tests/compiler/integers/u128/div.leo @@ -0,0 +1,3 @@ +function main(a: u128, b: u128, c: u128) { + console.assert(a / b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u128/eq.leo b/tests/compiler/integers/u128/eq.leo new file mode 100644 index 0000000000..2c2acd923a --- /dev/null +++ b/tests/compiler/integers/u128/eq.leo @@ -0,0 +1,3 @@ +function main(a: u128, b: u128, c: bool) { + console.assert(a == b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u128/ge.leo b/tests/compiler/integers/u128/ge.leo new file mode 100644 index 0000000000..bff7cd321b --- /dev/null +++ b/tests/compiler/integers/u128/ge.leo @@ -0,0 +1,3 @@ +function main(a: u128, b: u128, c: bool) { + console.assert(a >= b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u128/gt.leo b/tests/compiler/integers/u128/gt.leo new file mode 100644 index 0000000000..e8aec0faf2 --- /dev/null +++ b/tests/compiler/integers/u128/gt.leo @@ -0,0 +1,3 @@ +function main(a: u128, b: u128, c: bool) { + console.assert(a > b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u128/input.leo b/tests/compiler/integers/u128/input.leo new file mode 100644 index 0000000000..adab295385 --- /dev/null +++ b/tests/compiler/integers/u128/input.leo @@ -0,0 +1,3 @@ +function main(a: u128, b: u128) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/u128/le.leo b/tests/compiler/integers/u128/le.leo new file mode 100644 index 0000000000..c9e4609136 --- /dev/null +++ b/tests/compiler/integers/u128/le.leo @@ -0,0 +1,3 @@ +function main(a: u128, b: u128, c: bool) { + console.assert(a <= b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u128/lt.leo b/tests/compiler/integers/u128/lt.leo new file mode 100644 index 0000000000..b37057c895 --- /dev/null +++ b/tests/compiler/integers/u128/lt.leo @@ -0,0 +1,3 @@ +function main(a: u128, b: u128, c: bool) { + console.assert(a < b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u128/max.leo b/tests/compiler/integers/u128/max.leo new file mode 100644 index 0000000000..b166ede06b --- /dev/null +++ b/tests/compiler/integers/u128/max.leo @@ -0,0 +1,3 @@ +function main() { + const a: u128 = 340282366920938463463374607431768211455; +} \ No newline at end of file diff --git a/tests/compiler/integers/u128/max_fail.leo b/tests/compiler/integers/u128/max_fail.leo new file mode 100644 index 0000000000..f51c967925 --- /dev/null +++ b/tests/compiler/integers/u128/max_fail.leo @@ -0,0 +1,3 @@ +function main() { + const a: u128 = 340282366920938463463374607431768211456; +} \ No newline at end of file diff --git a/tests/compiler/integers/u128/min.leo b/tests/compiler/integers/u128/min.leo new file mode 100644 index 0000000000..41fbf1a2fe --- /dev/null +++ b/tests/compiler/integers/u128/min.leo @@ -0,0 +1,3 @@ +function main() { + const a: u128 = 0; +} \ No newline at end of file diff --git a/tests/compiler/integers/u128/min_fail.leo b/tests/compiler/integers/u128/min_fail.leo new file mode 100644 index 0000000000..b0d17191ff --- /dev/null +++ b/tests/compiler/integers/u128/min_fail.leo @@ -0,0 +1,3 @@ +function main() { + const a: u128 = -1; +} \ No newline at end of file diff --git a/tests/compiler/integers/u128/mod.rs b/tests/compiler/integers/u128/mod.rs new file mode 100644 index 0000000000..38677dcb29 --- /dev/null +++ b/tests/compiler/integers/u128/mod.rs @@ -0,0 +1,126 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + integers::IntegerTester, + parse_program, +}; +use leo_ast::InputValue; +use leo_input::types::{IntegerType, U128Type, UnsignedIntegerType}; + +test_uint!( + TestU128, + u128, + IntegerType::Unsigned(UnsignedIntegerType::U128Type(U128Type {})), + UInt128 +); + +#[test] +fn test_u128_min() { + TestU128::test_min(); +} + +#[test] +fn test_u128_min_fail() { + TestU128::test_min_fail(); +} + +#[test] +fn test_u128_max() { + TestU128::test_max(); +} + +#[test] +fn test_u128_max_fail() { + TestU128::test_max_fail(); +} + +#[test] +fn test_u128_add() { + TestU128::test_add(); +} + +#[test] +fn test_u128_sub() { + TestU128::test_sub(); +} + +#[test] +fn test_u128_mul() { + TestU128::test_mul(); +} + +#[test] +fn test_u128_div() { + TestU128::test_div(); +} + +#[test] +fn test_u128_pow() { + TestU128::test_pow(); +} + +#[test] +fn test_u128_eq() { + TestU128::test_eq(); +} + +#[test] +fn test_u128_ne() { + TestU128::test_ne(); +} + +#[test] +fn test_u128_ge() { + TestU128::test_ge(); +} + +#[test] +fn test_u128_gt() { + TestU128::test_gt(); +} + +#[test] +fn test_u128_le() { + TestU128::test_le(); +} + +#[test] +fn test_u128_lt() { + TestU128::test_lt(); +} + +#[test] +fn test_u128_console_assert() { + TestU128::test_console_assert(); +} + +#[test] +fn test_u128_ternary() { + TestU128::test_ternary(); +} + +#[test] +fn test_no_space_between_literal() { + let program_string = include_str!("no_space_between_literal.leo"); + let program = parse_program(program_string); + + assert!(program.is_err()); +} diff --git a/tests/compiler/integers/u128/mul.leo b/tests/compiler/integers/u128/mul.leo new file mode 100644 index 0000000000..c7fdc1530c --- /dev/null +++ b/tests/compiler/integers/u128/mul.leo @@ -0,0 +1,3 @@ +function main(a: u128, b: u128, c: u128) { + console.assert(a * b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u128/ne.leo b/tests/compiler/integers/u128/ne.leo new file mode 100644 index 0000000000..da3467d01e --- /dev/null +++ b/tests/compiler/integers/u128/ne.leo @@ -0,0 +1,3 @@ +function main(a: u128, b: u128, c: bool) { + console.assert(a != b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u128/no_space_between_literal.leo b/tests/compiler/integers/u128/no_space_between_literal.leo new file mode 100644 index 0000000000..fc48e7f1ae --- /dev/null +++ b/tests/compiler/integers/u128/no_space_between_literal.leo @@ -0,0 +1,3 @@ +function main() { + const i = 1 u128; +} \ No newline at end of file diff --git a/tests/compiler/integers/u128/pow.leo b/tests/compiler/integers/u128/pow.leo new file mode 100644 index 0000000000..27614bfa56 --- /dev/null +++ b/tests/compiler/integers/u128/pow.leo @@ -0,0 +1,3 @@ +function main(a: u128, b: u128, c: u128) { + console.assert(a ** b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u128/sub.leo b/tests/compiler/integers/u128/sub.leo new file mode 100644 index 0000000000..2374413505 --- /dev/null +++ b/tests/compiler/integers/u128/sub.leo @@ -0,0 +1,3 @@ +function main(a: u128, b: u128, c: u128) { + console.assert(a - b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u128/ternary.leo b/tests/compiler/integers/u128/ternary.leo new file mode 100644 index 0000000000..99a6b997e0 --- /dev/null +++ b/tests/compiler/integers/u128/ternary.leo @@ -0,0 +1,5 @@ +function main(s: bool, a: u128, b: u128, c: u128) { + const r = s ? a : b; + + console.assert(r == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u16/add.leo b/tests/compiler/integers/u16/add.leo new file mode 100644 index 0000000000..f00701181b --- /dev/null +++ b/tests/compiler/integers/u16/add.leo @@ -0,0 +1,3 @@ +function main(a: u16, b: u16, c: u16) { + console.assert(a + b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u16/console_assert.leo b/tests/compiler/integers/u16/console_assert.leo new file mode 100644 index 0000000000..761f0639d0 --- /dev/null +++ b/tests/compiler/integers/u16/console_assert.leo @@ -0,0 +1,3 @@ +function main(a: u16, b: u16) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/u16/div.leo b/tests/compiler/integers/u16/div.leo new file mode 100644 index 0000000000..f1dd3fa463 --- /dev/null +++ b/tests/compiler/integers/u16/div.leo @@ -0,0 +1,3 @@ +function main(a: u16, b: u16, c: u16) { + console.assert(a / b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u16/eq.leo b/tests/compiler/integers/u16/eq.leo new file mode 100644 index 0000000000..a4b4e78b49 --- /dev/null +++ b/tests/compiler/integers/u16/eq.leo @@ -0,0 +1,3 @@ +function main(a: u16, b: u16, c: bool) { + console.assert(a == b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u16/ge.leo b/tests/compiler/integers/u16/ge.leo new file mode 100644 index 0000000000..4b1da1b27b --- /dev/null +++ b/tests/compiler/integers/u16/ge.leo @@ -0,0 +1,3 @@ +function main(a: u16, b: u16, c: bool) { + console.assert(a >= b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u16/gt.leo b/tests/compiler/integers/u16/gt.leo new file mode 100644 index 0000000000..2c5ffbe8eb --- /dev/null +++ b/tests/compiler/integers/u16/gt.leo @@ -0,0 +1,3 @@ +function main(a: u16, b: u16, c: bool) { + console.assert(a > b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u16/input.leo b/tests/compiler/integers/u16/input.leo new file mode 100644 index 0000000000..761f0639d0 --- /dev/null +++ b/tests/compiler/integers/u16/input.leo @@ -0,0 +1,3 @@ +function main(a: u16, b: u16) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/u16/le.leo b/tests/compiler/integers/u16/le.leo new file mode 100644 index 0000000000..49713482d0 --- /dev/null +++ b/tests/compiler/integers/u16/le.leo @@ -0,0 +1,3 @@ +function main(a: u16, b: u16, c: bool) { + console.assert(a <= b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u16/lt.leo b/tests/compiler/integers/u16/lt.leo new file mode 100644 index 0000000000..dae1951231 --- /dev/null +++ b/tests/compiler/integers/u16/lt.leo @@ -0,0 +1,3 @@ +function main(a: u16, b: u16, c: bool) { + console.assert(a < b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u16/max.leo b/tests/compiler/integers/u16/max.leo new file mode 100644 index 0000000000..56cb2af18d --- /dev/null +++ b/tests/compiler/integers/u16/max.leo @@ -0,0 +1,3 @@ +function main() { + const a: u16 = 65535; +} \ No newline at end of file diff --git a/tests/compiler/integers/u16/max_fail.leo b/tests/compiler/integers/u16/max_fail.leo new file mode 100644 index 0000000000..bb703210e3 --- /dev/null +++ b/tests/compiler/integers/u16/max_fail.leo @@ -0,0 +1,3 @@ +function main() { + const a: u16 = 65536; +} \ No newline at end of file diff --git a/tests/compiler/integers/u16/min.leo b/tests/compiler/integers/u16/min.leo new file mode 100644 index 0000000000..4dee94a1a4 --- /dev/null +++ b/tests/compiler/integers/u16/min.leo @@ -0,0 +1,3 @@ +function main() { + const a: u16 = 0; +} \ No newline at end of file diff --git a/tests/compiler/integers/u16/min_fail.leo b/tests/compiler/integers/u16/min_fail.leo new file mode 100644 index 0000000000..0c61dd7ddf --- /dev/null +++ b/tests/compiler/integers/u16/min_fail.leo @@ -0,0 +1,3 @@ +function main() { + const a: u16 = -1; +} \ No newline at end of file diff --git a/tests/compiler/integers/u16/mod.rs b/tests/compiler/integers/u16/mod.rs new file mode 100644 index 0000000000..33f88452c1 --- /dev/null +++ b/tests/compiler/integers/u16/mod.rs @@ -0,0 +1,126 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + integers::IntegerTester, + parse_program, +}; +use leo_ast::InputValue; +use leo_input::types::{IntegerType, U16Type, UnsignedIntegerType}; + +test_uint!( + TestU16, + u16, + IntegerType::Unsigned(UnsignedIntegerType::U16Type(U16Type {})), + UInt16 +); + +#[test] +fn test_u16_min() { + TestU16::test_min(); +} + +#[test] +fn test_u16_min_fail() { + TestU16::test_min_fail(); +} + +#[test] +fn test_u16_max() { + TestU16::test_max(); +} + +#[test] +fn test_u16_max_fail() { + TestU16::test_max_fail(); +} + +#[test] +fn test_u16_add() { + TestU16::test_add(); +} + +#[test] +fn test_u16_sub() { + TestU16::test_sub(); +} + +#[test] +fn test_u16_mul() { + TestU16::test_mul(); +} + +#[test] +fn test_u16_div() { + TestU16::test_div(); +} + +#[test] +fn test_u16_pow() { + TestU16::test_pow(); +} + +#[test] +fn test_u16_eq() { + TestU16::test_eq(); +} + +#[test] +fn test_u16_ne() { + TestU16::test_ne(); +} + +#[test] +fn test_u16_ge() { + TestU16::test_ge(); +} + +#[test] +fn test_u16_gt() { + TestU16::test_gt(); +} + +#[test] +fn test_u16_le() { + TestU16::test_le(); +} + +#[test] +fn test_u16_lt() { + TestU16::test_lt(); +} + +#[test] +fn test_u16_console_assert() { + TestU16::test_console_assert(); +} + +#[test] +fn test_u16_ternary() { + TestU16::test_ternary(); +} + +#[test] +fn test_no_space_between_literal() { + let program_string = include_str!("no_space_between_literal.leo"); + let program = parse_program(program_string); + + assert!(program.is_err()); +} diff --git a/tests/compiler/integers/u16/mul.leo b/tests/compiler/integers/u16/mul.leo new file mode 100644 index 0000000000..f2c6f0aac8 --- /dev/null +++ b/tests/compiler/integers/u16/mul.leo @@ -0,0 +1,3 @@ +function main(a: u16, b: u16, c: u16) { + console.assert(a * b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u16/ne.leo b/tests/compiler/integers/u16/ne.leo new file mode 100644 index 0000000000..e90a304cfe --- /dev/null +++ b/tests/compiler/integers/u16/ne.leo @@ -0,0 +1,3 @@ +function main(a: u16, b: u16, c: bool) { + console.assert(a != b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u16/no_space_between_literal.leo b/tests/compiler/integers/u16/no_space_between_literal.leo new file mode 100644 index 0000000000..34e125cfc6 --- /dev/null +++ b/tests/compiler/integers/u16/no_space_between_literal.leo @@ -0,0 +1,3 @@ +function main() { + const i = 1 u16; +} \ No newline at end of file diff --git a/tests/compiler/integers/u16/pow.leo b/tests/compiler/integers/u16/pow.leo new file mode 100644 index 0000000000..564c1c51fe --- /dev/null +++ b/tests/compiler/integers/u16/pow.leo @@ -0,0 +1,3 @@ +function main(a: u16, b: u16, c: u16) { + console.assert(a ** b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u16/sub.leo b/tests/compiler/integers/u16/sub.leo new file mode 100644 index 0000000000..92aae9ac2c --- /dev/null +++ b/tests/compiler/integers/u16/sub.leo @@ -0,0 +1,3 @@ +function main(a: u16, b: u16, c: u16) { + console.assert(a - b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u16/ternary.leo b/tests/compiler/integers/u16/ternary.leo new file mode 100644 index 0000000000..d6131f9f4f --- /dev/null +++ b/tests/compiler/integers/u16/ternary.leo @@ -0,0 +1,5 @@ +function main(s: bool, a: u16, b: u16, c: u16) { + const r = s ? a : b; + + console.assert(r == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u32/add.leo b/tests/compiler/integers/u32/add.leo new file mode 100644 index 0000000000..6f6a2454b4 --- /dev/null +++ b/tests/compiler/integers/u32/add.leo @@ -0,0 +1,3 @@ +function main(a: u32, b: u32, c: u32) { + console.assert(a + b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u32/console_assert.leo b/tests/compiler/integers/u32/console_assert.leo new file mode 100644 index 0000000000..32604eb3b8 --- /dev/null +++ b/tests/compiler/integers/u32/console_assert.leo @@ -0,0 +1,3 @@ +function main(a: u32, b: u32) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/u32/div.leo b/tests/compiler/integers/u32/div.leo new file mode 100644 index 0000000000..ed689bd408 --- /dev/null +++ b/tests/compiler/integers/u32/div.leo @@ -0,0 +1,3 @@ +function main(a: u32, b: u32, c: u32) { + console.assert(a / b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u32/eq.leo b/tests/compiler/integers/u32/eq.leo new file mode 100644 index 0000000000..ca427b3c42 --- /dev/null +++ b/tests/compiler/integers/u32/eq.leo @@ -0,0 +1,3 @@ +function main(a: u32, b: u32, c: bool) { + console.assert(a == b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u32/ge.leo b/tests/compiler/integers/u32/ge.leo new file mode 100644 index 0000000000..35c1c71829 --- /dev/null +++ b/tests/compiler/integers/u32/ge.leo @@ -0,0 +1,3 @@ +function main(a: u32, b: u32, c: bool) { + console.assert(a >= b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u32/gt.leo b/tests/compiler/integers/u32/gt.leo new file mode 100644 index 0000000000..f76df415c4 --- /dev/null +++ b/tests/compiler/integers/u32/gt.leo @@ -0,0 +1,3 @@ +function main(a: u32, b: u32, c: bool) { + console.assert(a > b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u32/input.leo b/tests/compiler/integers/u32/input.leo new file mode 100644 index 0000000000..32604eb3b8 --- /dev/null +++ b/tests/compiler/integers/u32/input.leo @@ -0,0 +1,3 @@ +function main(a: u32, b: u32) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/u32/le.leo b/tests/compiler/integers/u32/le.leo new file mode 100644 index 0000000000..9a802f896d --- /dev/null +++ b/tests/compiler/integers/u32/le.leo @@ -0,0 +1,3 @@ +function main(a: u32, b: u32, c: bool) { + console.assert(a <= b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u32/lt.leo b/tests/compiler/integers/u32/lt.leo new file mode 100644 index 0000000000..73e5654470 --- /dev/null +++ b/tests/compiler/integers/u32/lt.leo @@ -0,0 +1,3 @@ +function main(a: u32, b: u32, c: bool) { + console.assert(a < b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u32/max.leo b/tests/compiler/integers/u32/max.leo new file mode 100644 index 0000000000..4a07281b5d --- /dev/null +++ b/tests/compiler/integers/u32/max.leo @@ -0,0 +1,3 @@ +function main() { + const a: u32 = 4294967295; +} \ No newline at end of file diff --git a/tests/compiler/integers/u32/max_fail.leo b/tests/compiler/integers/u32/max_fail.leo new file mode 100644 index 0000000000..6b1631876e --- /dev/null +++ b/tests/compiler/integers/u32/max_fail.leo @@ -0,0 +1,3 @@ +function main() { + const a: u32 = 4294967296; +} \ No newline at end of file diff --git a/tests/compiler/integers/u32/min.leo b/tests/compiler/integers/u32/min.leo new file mode 100644 index 0000000000..8077e0ec02 --- /dev/null +++ b/tests/compiler/integers/u32/min.leo @@ -0,0 +1,3 @@ +function main() { + const a: u32 = 0; +} \ No newline at end of file diff --git a/tests/compiler/integers/u32/min_fail.leo b/tests/compiler/integers/u32/min_fail.leo new file mode 100644 index 0000000000..c3e3f33225 --- /dev/null +++ b/tests/compiler/integers/u32/min_fail.leo @@ -0,0 +1,3 @@ +function main() { + const a: u32 = -1; +} \ No newline at end of file diff --git a/tests/compiler/integers/u32/mod.rs b/tests/compiler/integers/u32/mod.rs new file mode 100644 index 0000000000..7f2d76d198 --- /dev/null +++ b/tests/compiler/integers/u32/mod.rs @@ -0,0 +1,126 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + integers::IntegerTester, + parse_program, +}; +use leo_ast::InputValue; +use leo_input::types::{IntegerType, U32Type, UnsignedIntegerType}; + +test_uint!( + TestU32, + u32, + IntegerType::Unsigned(UnsignedIntegerType::U32Type(U32Type {})), + UInt32 +); + +#[test] +fn test_u32_min() { + TestU32::test_min(); +} + +#[test] +fn test_u32_min_fail() { + TestU32::test_min_fail(); +} + +#[test] +fn test_u32_max() { + TestU32::test_max(); +} + +#[test] +fn test_u32_max_fail() { + TestU32::test_max_fail(); +} + +#[test] +fn test_u32_add() { + TestU32::test_add(); +} + +#[test] +fn test_u32_sub() { + TestU32::test_sub(); +} + +#[test] +fn test_u32_mul() { + TestU32::test_mul(); +} + +#[test] +fn test_u32_div() { + TestU32::test_div(); +} + +#[test] +fn test_u32_pow() { + TestU32::test_pow(); +} + +#[test] +fn test_u32_eq() { + TestU32::test_eq(); +} + +#[test] +fn test_u32_ne() { + TestU32::test_ne(); +} + +#[test] +fn test_u32_ge() { + TestU32::test_ge(); +} + +#[test] +fn test_u32_gt() { + TestU32::test_gt(); +} + +#[test] +fn test_u32_le() { + TestU32::test_le(); +} + +#[test] +fn test_u32_lt() { + TestU32::test_lt(); +} + +#[test] +fn test_u32_console_assert() { + TestU32::test_console_assert(); +} + +#[test] +fn test_u32_ternary() { + TestU32::test_ternary(); +} + +#[test] +fn test_no_space_between_literal() { + let program_string = include_str!("no_space_between_literal.leo"); + let program = parse_program(program_string); + + assert!(program.is_err()); +} diff --git a/tests/compiler/integers/u32/mul.leo b/tests/compiler/integers/u32/mul.leo new file mode 100644 index 0000000000..a77a85477b --- /dev/null +++ b/tests/compiler/integers/u32/mul.leo @@ -0,0 +1,3 @@ +function main(a: u32, b: u32, c: u32) { + console.assert(a * b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u32/ne.leo b/tests/compiler/integers/u32/ne.leo new file mode 100644 index 0000000000..00ee1a9989 --- /dev/null +++ b/tests/compiler/integers/u32/ne.leo @@ -0,0 +1,3 @@ +function main(a: u32, b: u32, c: bool) { + console.assert(a != b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u32/no_space_between_literal.leo b/tests/compiler/integers/u32/no_space_between_literal.leo new file mode 100644 index 0000000000..83b3caca55 --- /dev/null +++ b/tests/compiler/integers/u32/no_space_between_literal.leo @@ -0,0 +1,3 @@ +function main() { + const i = 1 u32; +} \ No newline at end of file diff --git a/tests/compiler/integers/u32/pow.leo b/tests/compiler/integers/u32/pow.leo new file mode 100644 index 0000000000..b82496ff77 --- /dev/null +++ b/tests/compiler/integers/u32/pow.leo @@ -0,0 +1,3 @@ +function main(a: u32, b: u32, c: u32) { + console.assert(a ** b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u32/sub.leo b/tests/compiler/integers/u32/sub.leo new file mode 100644 index 0000000000..54480bd4bc --- /dev/null +++ b/tests/compiler/integers/u32/sub.leo @@ -0,0 +1,3 @@ +function main(a: u32, b: u32, c: u32) { + console.assert(a - b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u32/ternary.leo b/tests/compiler/integers/u32/ternary.leo new file mode 100644 index 0000000000..f32ffc29fe --- /dev/null +++ b/tests/compiler/integers/u32/ternary.leo @@ -0,0 +1,5 @@ +function main(s: bool, a: u32, b: u32, c: u32) { + const r = s ? a : b; + + console.assert(r == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u64/add.leo b/tests/compiler/integers/u64/add.leo new file mode 100644 index 0000000000..28abe51201 --- /dev/null +++ b/tests/compiler/integers/u64/add.leo @@ -0,0 +1,3 @@ +function main(a: u64, b: u64, c: u64) { + console.assert(a + b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u64/console_assert.leo b/tests/compiler/integers/u64/console_assert.leo new file mode 100644 index 0000000000..ac1d6d40c3 --- /dev/null +++ b/tests/compiler/integers/u64/console_assert.leo @@ -0,0 +1,3 @@ +function main(a: u64, b: u64) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/u64/div.leo b/tests/compiler/integers/u64/div.leo new file mode 100644 index 0000000000..059da236bb --- /dev/null +++ b/tests/compiler/integers/u64/div.leo @@ -0,0 +1,3 @@ +function main(a: u64, b: u64, c: u64) { + console.assert(a / b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u64/eq.leo b/tests/compiler/integers/u64/eq.leo new file mode 100644 index 0000000000..990b2dad2d --- /dev/null +++ b/tests/compiler/integers/u64/eq.leo @@ -0,0 +1,3 @@ +function main(a: u64, b: u64, c: bool) { + console.assert(a == b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u64/ge.leo b/tests/compiler/integers/u64/ge.leo new file mode 100644 index 0000000000..46ba36ceff --- /dev/null +++ b/tests/compiler/integers/u64/ge.leo @@ -0,0 +1,3 @@ +function main(a: u64, b: u64, c: bool) { + console.assert(a >= b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u64/gt.leo b/tests/compiler/integers/u64/gt.leo new file mode 100644 index 0000000000..7d3032c7f5 --- /dev/null +++ b/tests/compiler/integers/u64/gt.leo @@ -0,0 +1,3 @@ +function main(a: u64, b: u64, c: bool) { + console.assert(a > b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u64/input.leo b/tests/compiler/integers/u64/input.leo new file mode 100644 index 0000000000..ac1d6d40c3 --- /dev/null +++ b/tests/compiler/integers/u64/input.leo @@ -0,0 +1,3 @@ +function main(a: u64, b: u64) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/u64/le.leo b/tests/compiler/integers/u64/le.leo new file mode 100644 index 0000000000..625b38d2d9 --- /dev/null +++ b/tests/compiler/integers/u64/le.leo @@ -0,0 +1,3 @@ +function main(a: u64, b: u64, c: bool) { + console.assert(a <= b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u64/lt.leo b/tests/compiler/integers/u64/lt.leo new file mode 100644 index 0000000000..ed379f7341 --- /dev/null +++ b/tests/compiler/integers/u64/lt.leo @@ -0,0 +1,3 @@ +function main(a: u64, b: u64, c: bool) { + console.assert(a < b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u64/max.leo b/tests/compiler/integers/u64/max.leo new file mode 100644 index 0000000000..f14ac7ce64 --- /dev/null +++ b/tests/compiler/integers/u64/max.leo @@ -0,0 +1,3 @@ +function main() { + const a: u64 = 18446744073709551615; +} \ No newline at end of file diff --git a/tests/compiler/integers/u64/max_fail.leo b/tests/compiler/integers/u64/max_fail.leo new file mode 100644 index 0000000000..d606c83585 --- /dev/null +++ b/tests/compiler/integers/u64/max_fail.leo @@ -0,0 +1,3 @@ +function main() { + const a: u64 = 18446744073709551616; +} \ No newline at end of file diff --git a/tests/compiler/integers/u64/min.leo b/tests/compiler/integers/u64/min.leo new file mode 100644 index 0000000000..b1da40b14c --- /dev/null +++ b/tests/compiler/integers/u64/min.leo @@ -0,0 +1,3 @@ +function main() { + const a: u64 = 0; +} \ No newline at end of file diff --git a/tests/compiler/integers/u64/min_fail.leo b/tests/compiler/integers/u64/min_fail.leo new file mode 100644 index 0000000000..e58f1897e6 --- /dev/null +++ b/tests/compiler/integers/u64/min_fail.leo @@ -0,0 +1,3 @@ +function main() { + const a: u64 = -1; +} \ No newline at end of file diff --git a/tests/compiler/integers/u64/mod.rs b/tests/compiler/integers/u64/mod.rs new file mode 100644 index 0000000000..1a2af24ddd --- /dev/null +++ b/tests/compiler/integers/u64/mod.rs @@ -0,0 +1,126 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + integers::IntegerTester, + parse_program, +}; +use leo_ast::InputValue; +use leo_input::types::{IntegerType, U64Type, UnsignedIntegerType}; + +test_uint!( + TestU64, + u64, + IntegerType::Unsigned(UnsignedIntegerType::U64Type(U64Type {})), + UInt64 +); + +#[test] +fn test_u64_min() { + TestU64::test_min(); +} + +#[test] +fn test_u64_min_fail() { + TestU64::test_min_fail(); +} + +#[test] +fn test_u64_max() { + TestU64::test_max(); +} + +#[test] +fn test_u64_max_fail() { + TestU64::test_max_fail(); +} + +#[test] +fn test_u64_add() { + TestU64::test_add(); +} + +#[test] +fn test_u64_sub() { + TestU64::test_sub(); +} + +#[test] +fn test_u64_mul() { + TestU64::test_mul(); +} + +#[test] +fn test_u64_div() { + TestU64::test_div(); +} + +#[test] +fn test_u64_pow() { + TestU64::test_pow(); +} + +#[test] +fn test_u64_eq() { + TestU64::test_eq(); +} + +#[test] +fn test_u64_ne() { + TestU64::test_ne(); +} + +#[test] +fn test_u64_ge() { + TestU64::test_ge(); +} + +#[test] +fn test_u64_gt() { + TestU64::test_gt(); +} + +#[test] +fn test_u64_le() { + TestU64::test_le(); +} + +#[test] +fn test_u64_lt() { + TestU64::test_lt(); +} + +#[test] +fn test_u64_console_assert() { + TestU64::test_console_assert(); +} + +#[test] +fn test_u64_ternary() { + TestU64::test_ternary(); +} + +#[test] +fn test_no_space_between_literal() { + let program_string = include_str!("no_space_between_literal.leo"); + let program = parse_program(program_string); + + assert!(program.is_err()); +} diff --git a/tests/compiler/integers/u64/mul.leo b/tests/compiler/integers/u64/mul.leo new file mode 100644 index 0000000000..2633e6780c --- /dev/null +++ b/tests/compiler/integers/u64/mul.leo @@ -0,0 +1,3 @@ +function main(a: u64, b: u64, c: u64) { + console.assert(a * b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u64/ne.leo b/tests/compiler/integers/u64/ne.leo new file mode 100644 index 0000000000..e47acbb1de --- /dev/null +++ b/tests/compiler/integers/u64/ne.leo @@ -0,0 +1,3 @@ +function main(a: u64, b: u64, c: bool) { + console.assert(a != b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u64/no_space_between_literal.leo b/tests/compiler/integers/u64/no_space_between_literal.leo new file mode 100644 index 0000000000..852fd5c2aa --- /dev/null +++ b/tests/compiler/integers/u64/no_space_between_literal.leo @@ -0,0 +1,3 @@ +function main() { + const i = 1 u64; +} \ No newline at end of file diff --git a/tests/compiler/integers/u64/pow.leo b/tests/compiler/integers/u64/pow.leo new file mode 100644 index 0000000000..64f0694ed1 --- /dev/null +++ b/tests/compiler/integers/u64/pow.leo @@ -0,0 +1,3 @@ +function main(a: u64, b: u64, c: u64) { + console.assert(a ** b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u64/sub.leo b/tests/compiler/integers/u64/sub.leo new file mode 100644 index 0000000000..9961f0f7b7 --- /dev/null +++ b/tests/compiler/integers/u64/sub.leo @@ -0,0 +1,3 @@ +function main(a: u64, b: u64, c: u64) { + console.assert(a - b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u64/ternary.leo b/tests/compiler/integers/u64/ternary.leo new file mode 100644 index 0000000000..4427cd0466 --- /dev/null +++ b/tests/compiler/integers/u64/ternary.leo @@ -0,0 +1,5 @@ +function main(s: bool, a: u64, b: u64, c: u64) { + const r = s ? a : b; + + console.assert(r == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u8/add.leo b/tests/compiler/integers/u8/add.leo new file mode 100644 index 0000000000..1b40e304d2 --- /dev/null +++ b/tests/compiler/integers/u8/add.leo @@ -0,0 +1,3 @@ +function main(a: u8, b: u8, c: u8) { + console.assert(a + b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u8/console_assert.leo b/tests/compiler/integers/u8/console_assert.leo new file mode 100644 index 0000000000..4d99dc106c --- /dev/null +++ b/tests/compiler/integers/u8/console_assert.leo @@ -0,0 +1,3 @@ +function main(a: u8, b: u8) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/u8/div.leo b/tests/compiler/integers/u8/div.leo new file mode 100644 index 0000000000..945aa94c30 --- /dev/null +++ b/tests/compiler/integers/u8/div.leo @@ -0,0 +1,3 @@ +function main(a: u8, b: u8, c: u8) { + console.assert(a / b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u8/eq.leo b/tests/compiler/integers/u8/eq.leo new file mode 100644 index 0000000000..c2a487b0e7 --- /dev/null +++ b/tests/compiler/integers/u8/eq.leo @@ -0,0 +1,3 @@ +function main(a: u8, b: u8, c: bool) { + console.assert(a == b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u8/ge.leo b/tests/compiler/integers/u8/ge.leo new file mode 100644 index 0000000000..d819422276 --- /dev/null +++ b/tests/compiler/integers/u8/ge.leo @@ -0,0 +1,3 @@ +function main(a: u8, b: u8, c: bool) { + console.assert(a >= b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u8/gt.leo b/tests/compiler/integers/u8/gt.leo new file mode 100644 index 0000000000..87843f575f --- /dev/null +++ b/tests/compiler/integers/u8/gt.leo @@ -0,0 +1,3 @@ +function main(a: u8, b: u8, c: bool) { + console.assert(a > b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u8/input.leo b/tests/compiler/integers/u8/input.leo new file mode 100644 index 0000000000..4d99dc106c --- /dev/null +++ b/tests/compiler/integers/u8/input.leo @@ -0,0 +1,3 @@ +function main(a: u8, b: u8) { + console.assert(a == b); +} \ No newline at end of file diff --git a/tests/compiler/integers/u8/le.leo b/tests/compiler/integers/u8/le.leo new file mode 100644 index 0000000000..2607b7f3d1 --- /dev/null +++ b/tests/compiler/integers/u8/le.leo @@ -0,0 +1,3 @@ +function main(a: u8, b: u8, c: bool) { + console.assert(a <= b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u8/lt.leo b/tests/compiler/integers/u8/lt.leo new file mode 100644 index 0000000000..7495d0fe37 --- /dev/null +++ b/tests/compiler/integers/u8/lt.leo @@ -0,0 +1,3 @@ +function main(a: u8, b: u8, c: bool) { + console.assert(a < b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u8/max.leo b/tests/compiler/integers/u8/max.leo new file mode 100644 index 0000000000..03e82c9a5e --- /dev/null +++ b/tests/compiler/integers/u8/max.leo @@ -0,0 +1,3 @@ +function main() { + const a: u8 = 255; +} \ No newline at end of file diff --git a/tests/compiler/integers/u8/max_fail.leo b/tests/compiler/integers/u8/max_fail.leo new file mode 100644 index 0000000000..01bb544601 --- /dev/null +++ b/tests/compiler/integers/u8/max_fail.leo @@ -0,0 +1,3 @@ +function main() { + const a: u8 = 256; +} \ No newline at end of file diff --git a/tests/compiler/integers/u8/min.leo b/tests/compiler/integers/u8/min.leo new file mode 100644 index 0000000000..1db08a07b5 --- /dev/null +++ b/tests/compiler/integers/u8/min.leo @@ -0,0 +1,3 @@ +function main() { + const a: u8 = 0; +} \ No newline at end of file diff --git a/tests/compiler/integers/u8/min_fail.leo b/tests/compiler/integers/u8/min_fail.leo new file mode 100644 index 0000000000..3cd8d46de7 --- /dev/null +++ b/tests/compiler/integers/u8/min_fail.leo @@ -0,0 +1,3 @@ +function main() { + const a: u8 = -1; +} \ No newline at end of file diff --git a/tests/compiler/integers/u8/mod.rs b/tests/compiler/integers/u8/mod.rs new file mode 100644 index 0000000000..f1fb2b0fab --- /dev/null +++ b/tests/compiler/integers/u8/mod.rs @@ -0,0 +1,126 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + integers::IntegerTester, + parse_program, +}; +use leo_ast::InputValue; +use leo_input::types::{IntegerType, U8Type, UnsignedIntegerType}; + +test_uint!( + TestU8, + u8, + IntegerType::Unsigned(UnsignedIntegerType::U8Type(U8Type {})), + UInt8 +); + +#[test] +fn test_u8_min() { + TestU8::test_min(); +} + +#[test] +fn test_u8_min_fail() { + TestU8::test_min_fail(); +} + +#[test] +fn test_u8_max() { + TestU8::test_max(); +} + +#[test] +fn test_u8_max_fail() { + TestU8::test_max_fail(); +} + +#[test] +fn test_u8_add() { + TestU8::test_add(); +} + +#[test] +fn test_u8_sub() { + TestU8::test_sub(); +} + +#[test] +fn test_u8_mul() { + TestU8::test_mul(); +} + +#[test] +fn test_u8_div() { + TestU8::test_div(); +} + +#[test] +fn test_u8_pow() { + TestU8::test_pow(); +} + +#[test] +fn test_u8_eq() { + TestU8::test_eq(); +} + +#[test] +fn test_u8_ne() { + TestU8::test_ne(); +} + +#[test] +fn test_u8_ge() { + TestU8::test_ge(); +} + +#[test] +fn test_u8_gt() { + TestU8::test_gt(); +} + +#[test] +fn test_u8_le() { + TestU8::test_le(); +} + +#[test] +fn test_u8_lt() { + TestU8::test_lt(); +} + +#[test] +fn test_u8_console_assert() { + TestU8::test_console_assert(); +} + +#[test] +fn test_u8_ternary() { + TestU8::test_ternary(); +} + +#[test] +fn test_no_space_between_literal() { + let program_string = include_str!("no_space_between_literal.leo"); + let program = parse_program(program_string); + + assert!(program.is_err()); +} diff --git a/tests/compiler/integers/u8/mul.leo b/tests/compiler/integers/u8/mul.leo new file mode 100644 index 0000000000..11acf4688b --- /dev/null +++ b/tests/compiler/integers/u8/mul.leo @@ -0,0 +1,3 @@ +function main(a: u8, b: u8, c: u8) { + console.assert(a * b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u8/ne.leo b/tests/compiler/integers/u8/ne.leo new file mode 100644 index 0000000000..e75194a2f2 --- /dev/null +++ b/tests/compiler/integers/u8/ne.leo @@ -0,0 +1,3 @@ +function main(a: u8, b: u8, c: bool) { + console.assert(a != b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u8/no_space_between_literal.leo b/tests/compiler/integers/u8/no_space_between_literal.leo new file mode 100644 index 0000000000..64eba2a083 --- /dev/null +++ b/tests/compiler/integers/u8/no_space_between_literal.leo @@ -0,0 +1,3 @@ +function main() { + const i = 1 u8; +} \ No newline at end of file diff --git a/tests/compiler/integers/u8/pow.leo b/tests/compiler/integers/u8/pow.leo new file mode 100644 index 0000000000..928ab73b0d --- /dev/null +++ b/tests/compiler/integers/u8/pow.leo @@ -0,0 +1,3 @@ +function main(a: u8, b: u8, c: u8) { + console.assert(a ** b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u8/sub.leo b/tests/compiler/integers/u8/sub.leo new file mode 100644 index 0000000000..1335409c29 --- /dev/null +++ b/tests/compiler/integers/u8/sub.leo @@ -0,0 +1,3 @@ +function main(a: u8, b: u8, c: u8) { + console.assert(a - b == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/u8/ternary.leo b/tests/compiler/integers/u8/ternary.leo new file mode 100644 index 0000000000..5123a511cd --- /dev/null +++ b/tests/compiler/integers/u8/ternary.leo @@ -0,0 +1,5 @@ +function main(s: bool, a: u8, b: u8, c: u8) { + const r = s ? a : b; + + console.assert(r == c); +} \ No newline at end of file diff --git a/tests/compiler/integers/uint_macro.rs b/tests/compiler/integers/uint_macro.rs new file mode 100644 index 0000000000..393ed1c7a6 --- /dev/null +++ b/tests/compiler/integers/uint_macro.rs @@ -0,0 +1,476 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +macro_rules! test_uint { + ($name: ident, $type_: ty, $integer_type: expr, $gadget: ty) => { + pub struct $name {} + + impl IntegerTester for $name { + fn test_min() { + let program_string = include_str!("min.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); + } + + fn test_min_fail() { + let program_string = include_str!("min_fail.leo"); + let program = parse_program(program_string).err().unwrap(); + + expect_asg_error(program); + } + + fn test_max() { + let program_string = include_str!("max.leo"); + let error = parse_program(program_string).unwrap(); + + assert_satisfied(error); + } + + fn test_max_fail() { + let program_string = include_str!("max_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); + } + + fn test_add() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + let c = match a.checked_add(b) { + Some(valid) => valid, + None => continue, + }; + + let program_string = include_str!("add.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Integer($integer_type, c.to_string()))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_sub() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + let c = match a.checked_sub(b) { + Some(valid) => valid, + None => continue, + }; + + let program_string = include_str!("sub.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Integer($integer_type, c.to_string()))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_mul() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + let c = match a.checked_mul(b) { + Some(valid) => valid, + None => continue, + }; + + let program_string = include_str!("mul.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Integer($integer_type, c.to_string()))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_div() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + let c = match a.checked_div(b) { + Some(valid) => valid, + None => continue, + }; + + let program_string = include_str!("div.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Integer($integer_type, c.to_string()))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_pow() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + // rust specific conversion see https://doc.rust-lang.org/std/primitive.u8.html#method.checked_pow + let c = match a.checked_pow(b as u32) { + Some(valid) => valid, + None => continue, + }; + + let program_string = include_str!("pow.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Integer($integer_type, c.to_string()))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_eq() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + // test equal + + let program_string = include_str!("eq.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, a.to_string()))), + ("c", Some(InputValue::Boolean(true))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + + // test not equal + + let c = a.eq(&b); + + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Boolean(c))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_ne() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + // test a != a == false + + let program_string = include_str!("ne.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, a.to_string()))), + ("c", Some(InputValue::Boolean(false))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + + // test not equal + + let c = a.ne(&b); + + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Boolean(c))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_ge() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + // test equal + + let program_string = include_str!("ge.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, a.to_string()))), + ("c", Some(InputValue::Boolean(true))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + + // test greater or equal + + let c = a.ge(&b); + + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Boolean(c))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_gt() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + // test equal + + let program_string = include_str!("gt.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, a.to_string()))), + ("c", Some(InputValue::Boolean(false))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + + // test greater than + + let c = a.gt(&b); + + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Boolean(c))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_le() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + // test equal + + let program_string = include_str!("le.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, a.to_string()))), + ("c", Some(InputValue::Boolean(true))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + + // test less or equal + + let c = a.le(&b); + + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Boolean(c))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_lt() { + for _ in 0..10 { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + // test equal + + let program_string = include_str!("lt.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, a.to_string()))), + ("c", Some(InputValue::Boolean(false))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + + // test less or equal + + let c = a.lt(&b); + + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Boolean(c))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + + fn test_console_assert() { + for _ in 0..10 { + let a: $type_ = rand::random(); + + // test equal + let program_string = include_str!("console_assert.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, a.to_string()))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + + // test not equal + let b: $type_ = rand::random(); + + if a == b { + continue; + } + + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ]); + + program.set_main_input(main_input); + + expect_compiler_error(program); + } + } + + fn test_ternary() { + let a: $type_ = rand::random(); + let b: $type_ = rand::random(); + + let program_string = include_str!("ternary.leo"); + let mut program = parse_program(program_string).unwrap(); + + // true -> field 1 + let main_input = generate_main_input(vec![ + ("s", Some(InputValue::Boolean(true))), + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Integer($integer_type, a.to_string()))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + + // false -> field 2 + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![ + ("s", Some(InputValue::Boolean(false))), + ("a", Some(InputValue::Integer($integer_type, a.to_string()))), + ("b", Some(InputValue::Integer($integer_type, b.to_string()))), + ("c", Some(InputValue::Integer($integer_type, b.to_string()))), + ]); + + program.set_main_input(main_input); + + assert_satisfied(program); + } + } + }; +} diff --git a/tests/compiler/mutability/array.leo b/tests/compiler/mutability/array.leo new file mode 100644 index 0000000000..ea63baaad2 --- /dev/null +++ b/tests/compiler/mutability/array.leo @@ -0,0 +1,5 @@ +// Arrays are immutable by default. +function main() { + const a = [1u32]; + a[0] = 0; +} \ No newline at end of file diff --git a/tests/compiler/mutability/array_mut.leo b/tests/compiler/mutability/array_mut.leo new file mode 100644 index 0000000000..5d4db3b68a --- /dev/null +++ b/tests/compiler/mutability/array_mut.leo @@ -0,0 +1,7 @@ +// Adding the `mut` keyword makes an array variable mutable. +function main() { + let a = [1u32]; + a[0] = 0; + + console.assert(a[0] == 0u32); +} \ No newline at end of file diff --git a/tests/compiler/mutability/array_splice_mut.leo b/tests/compiler/mutability/array_splice_mut.leo new file mode 100644 index 0000000000..d13216600a --- /dev/null +++ b/tests/compiler/mutability/array_splice_mut.leo @@ -0,0 +1,9 @@ +// Adding the `mut` keyword makes an array variable mutable. +function main() { + let a = [1u32, 2u32, 3u32]; + a[0u32..2u32] = [4u32, 5u32]; + + console.assert(a[0] == 4u32); + console.assert(a[1] == 5u32); + console.assert(a[2] == 3u32); +} \ No newline at end of file diff --git a/tests/compiler/mutability/array_tuple_mut.leo b/tests/compiler/mutability/array_tuple_mut.leo new file mode 100644 index 0000000000..ed323d46da --- /dev/null +++ b/tests/compiler/mutability/array_tuple_mut.leo @@ -0,0 +1,8 @@ +// Adding the `mut` keyword makes an array variable mutable. +function main() { + let a = [(1u32, 2u32)]; + a[0u32].1 = 3u32; + + console.assert(a[0u32].0 == 1u32); + console.assert(a[0u32].1 == 3u32); +} \ No newline at end of file diff --git a/tests/compiler/mutability/circuit.leo b/tests/compiler/mutability/circuit.leo new file mode 100644 index 0000000000..508595ef16 --- /dev/null +++ b/tests/compiler/mutability/circuit.leo @@ -0,0 +1,9 @@ +// Circuits are immutable by default. +circuit Foo { + x: u32 +} + +function main() { + const a = Foo { x: 1 }; + a.x = 0; +} \ No newline at end of file diff --git a/tests/compiler/mutability/circuit_function_mut.leo b/tests/compiler/mutability/circuit_function_mut.leo new file mode 100644 index 0000000000..c1bc941c94 --- /dev/null +++ b/tests/compiler/mutability/circuit_function_mut.leo @@ -0,0 +1,9 @@ +// Adding the `mut` keyword makes a circuit variable mutable. +circuit Foo { + function bar() {} +} + +function main() { + let a = Foo { x: 1 }; + a.bar = 0; +} \ No newline at end of file diff --git a/tests/compiler/mutability/circuit_mut.leo b/tests/compiler/mutability/circuit_mut.leo new file mode 100644 index 0000000000..f7067db11e --- /dev/null +++ b/tests/compiler/mutability/circuit_mut.leo @@ -0,0 +1,11 @@ +// Adding the `mut` keyword makes a circuit variable mutable. +circuit Foo { + x: u32 +} + +function main() { + let a = Foo { x: 1 }; + a.x = 0; + + console.assert(a.x == 0u32); +} \ No newline at end of file diff --git a/tests/compiler/mutability/circuit_static_function_mut.leo b/tests/compiler/mutability/circuit_static_function_mut.leo new file mode 100644 index 0000000000..c1bc941c94 --- /dev/null +++ b/tests/compiler/mutability/circuit_static_function_mut.leo @@ -0,0 +1,9 @@ +// Adding the `mut` keyword makes a circuit variable mutable. +circuit Foo { + function bar() {} +} + +function main() { + let a = Foo { x: 1 }; + a.bar = 0; +} \ No newline at end of file diff --git a/tests/compiler/mutability/circuit_variable_mut.leo b/tests/compiler/mutability/circuit_variable_mut.leo new file mode 100644 index 0000000000..f7067db11e --- /dev/null +++ b/tests/compiler/mutability/circuit_variable_mut.leo @@ -0,0 +1,11 @@ +// Adding the `mut` keyword makes a circuit variable mutable. +circuit Foo { + x: u32 +} + +function main() { + let a = Foo { x: 1 }; + a.x = 0; + + console.assert(a.x == 0u32); +} \ No newline at end of file diff --git a/tests/compiler/mutability/cond_mut.leo b/tests/compiler/mutability/cond_mut.leo new file mode 100644 index 0000000000..11e19b2645 --- /dev/null +++ b/tests/compiler/mutability/cond_mut.leo @@ -0,0 +1,7 @@ +function main () { + let x = 100i8; + if false { + x = 1i8; + x *= 100i8; + } +} \ No newline at end of file diff --git a/tests/compiler/mutability/const.leo b/tests/compiler/mutability/const.leo new file mode 100644 index 0000000000..6201e7c5af --- /dev/null +++ b/tests/compiler/mutability/const.leo @@ -0,0 +1,5 @@ +// Let variables are immutable by default. +function main() { + const a = 1u32; + a = 0; +} \ No newline at end of file diff --git a/tests/compiler/mutability/function_input.leo b/tests/compiler/mutability/function_input.leo new file mode 100644 index 0000000000..18d035574b --- /dev/null +++ b/tests/compiler/mutability/function_input.leo @@ -0,0 +1,4 @@ +// Const function input are immutable. +function main(const a: bool) { + a = false; +} \ No newline at end of file diff --git a/tests/compiler/mutability/function_input_mut.leo b/tests/compiler/mutability/function_input_mut.leo new file mode 100644 index 0000000000..98739d78c7 --- /dev/null +++ b/tests/compiler/mutability/function_input_mut.leo @@ -0,0 +1,6 @@ +// Function input are mutable by default. +function main(a: bool) { + a = true; + + console.assert(a == true); +} \ No newline at end of file diff --git a/tests/compiler/mutability/let.leo b/tests/compiler/mutability/let.leo new file mode 100644 index 0000000000..105730adb7 --- /dev/null +++ b/tests/compiler/mutability/let.leo @@ -0,0 +1,5 @@ +// Variables are immutable by default. +function main() { + const a = 1u32; + a = 0; +} \ No newline at end of file diff --git a/tests/compiler/mutability/let_mut.leo b/tests/compiler/mutability/let_mut.leo new file mode 100644 index 0000000000..cd1060d0d2 --- /dev/null +++ b/tests/compiler/mutability/let_mut.leo @@ -0,0 +1,7 @@ +// Adding the `mut` keyword makes a variable mutable. +function main() { + let a = 1u32; + a = 0; + + console.assert(a == 0u32); +} \ No newline at end of file diff --git a/tests/compiler/mutability/let_mut_nested.leo b/tests/compiler/mutability/let_mut_nested.leo new file mode 100644 index 0000000000..93236ef4c6 --- /dev/null +++ b/tests/compiler/mutability/let_mut_nested.leo @@ -0,0 +1,5 @@ +function main () { + let x = 2u8; + let y = x; + const z = y / 2u8; +} \ No newline at end of file diff --git a/tests/compiler/mutability/mod.rs b/tests/compiler/mutability/mod.rs new file mode 100644 index 0000000000..e0df21fb4e --- /dev/null +++ b/tests/compiler/mutability/mod.rs @@ -0,0 +1,157 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{assert_satisfied, expect_asg_error, generate_main_input, parse_program}; +use leo_ast::InputValue; + +#[test] +fn test_let() { + let program_string = include_str!("let.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_let_mut() { + let program_string = include_str!("let_mut.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_let_mut_nested() { + let program_string = include_str!("let_mut_nested.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_const_fail() { + let program_string = include_str!("const.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_cond_mut() { + let program_string = include_str!("cond_mut.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_array() { + let program_string = include_str!("array.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_array_mut() { + let program_string = include_str!("array_mut.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_array_tuple_mut() { + let bytes = include_str!("array_tuple_mut.leo"); + let program = parse_program(bytes).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_array_splice_mut() { + let bytes = include_str!("array_splice_mut.leo"); + let program = parse_program(bytes).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_circuit() { + let program_string = include_str!("circuit.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_circuit_mut() { + let program_string = include_str!("circuit_mut.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_circuit_variable_mut() { + let program_string = include_str!("circuit_variable_mut.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_circuit_function_mut() { + let program_string = include_str!("circuit_function_mut.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_circuit_static_function_mut() { + let program_string = include_str!("circuit_static_function_mut.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + +#[test] +fn test_function_input() { + let program_string = include_str!("function_input.leo"); + let error = parse_program(program_string).err().unwrap(); + expect_asg_error(error); +} + +#[test] +fn test_function_input_mut() { + let program_string = include_str!("function_input_mut.leo"); + let mut program = parse_program(program_string).unwrap(); + + let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]); + + program.set_main_input(main_input); + + assert_satisfied(program); +} + +#[test] +fn test_swap() { + let program_string = include_str!("swap.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} diff --git a/tests/compiler/mutability/swap.leo b/tests/compiler/mutability/swap.leo new file mode 100644 index 0000000000..d0d663ea1a --- /dev/null +++ b/tests/compiler/mutability/swap.leo @@ -0,0 +1,20 @@ +// Swap two elements of an array. +function swap(a: [u32; 2], const i: u32, const j: u32) -> [u32; 2] { + const t = a[i]; + a[i] = a[j]; + a[j] = t; + return a; +} + +function main() { + let arr: [u32; 2] = [0, 1]; + const expected: [u32; 2] = [1, 0]; + + // Do swap. + const actual = swap(arr, 0, 1); + + // Check result. + for i in 0..2 { + console.assert(expected[i] == actual[i]); + } +} \ No newline at end of file diff --git a/tests/compiler/statements/block.leo b/tests/compiler/statements/block.leo new file mode 100644 index 0000000000..4891a44827 --- /dev/null +++ b/tests/compiler/statements/block.leo @@ -0,0 +1,15 @@ +/* +namespace: Compile +expectation: Pass +input_file: u32_3.in +*/ + +function main(x: u32) -> bool { + let y = x; + + { + y += 5u32; + } + + return y == 8; +} \ No newline at end of file diff --git a/tests/compiler/statements/chain.leo b/tests/compiler/statements/chain.leo new file mode 100644 index 0000000000..ab79ae4647 --- /dev/null +++ b/tests/compiler/statements/chain.leo @@ -0,0 +1,21 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - u32_3.in + - u32_5.in + - u32_6.in +*/ + +function main(x: u32) -> bool { + let c = 0u32; + + if x == 1 { + c = 1; + } else if x == 2 { + c = 2; + } else { + c = 3; + } + return c == x; +} diff --git a/tests/compiler/statements/for_loop.leo b/tests/compiler/statements/for_loop.leo new file mode 100644 index 0000000000..5baba77b5d --- /dev/null +++ b/tests/compiler/statements/for_loop.leo @@ -0,0 +1,19 @@ +/* +namespace: Compile +expectation: Pass +input_file: u32_3.in +*/ + +function main(x: u32) -> bool { + let b = 0u32; + + if x == 3 { + for i in 0..4 { + b += i; + } + } + + const r: u32 = x == 3 ? 6 : 0; + + return r == b; +} diff --git a/tests/compiler/statements/iteration_basic.leo b/tests/compiler/statements/iteration_basic.leo new file mode 100644 index 0000000000..5de135bba2 --- /dev/null +++ b/tests/compiler/statements/iteration_basic.leo @@ -0,0 +1,15 @@ +/* +namespace: Compile +expectation: Pass +input_file: u32_3.in +*/ + +function main(x: u32) -> bool { + let y = x; + + for i in 0..3 { + y -= 1; + } + + return y == 0; +} diff --git a/tests/compiler/statements/iteration_variable.leo b/tests/compiler/statements/iteration_variable.leo new file mode 100644 index 0000000000..34aa827afc --- /dev/null +++ b/tests/compiler/statements/iteration_variable.leo @@ -0,0 +1,16 @@ +/* +namespace: Compile +expectation: Pass +input_file: u32_3.in +*/ + +function main(x: u32) -> bool { + const COUNT: u32 = 2; + let y = x; + + for i in 0..COUNT { + y -= 1; + } + + return y == 1; +} diff --git a/tests/compiler/statements/multiple_returns.leo b/tests/compiler/statements/multiple_returns.leo new file mode 100644 index 0000000000..14b70341c0 --- /dev/null +++ b/tests/compiler/statements/multiple_returns.leo @@ -0,0 +1,15 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - u32_3.in + - u32_5.in +*/ + +function main(x: u32) -> bool { + if x == 3 { + return true; + } else { + return false; + } +} diff --git a/tests/compiler/statements/mutate.leo b/tests/compiler/statements/mutate.leo new file mode 100644 index 0000000000..dc337ac723 --- /dev/null +++ b/tests/compiler/statements/mutate.leo @@ -0,0 +1,23 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - u32_3.in + - u32_5.in +*/ + +function main(x: u32) -> bool { + let b = 5u32; + + if x == 3 { + b = 1; + } else { + b = 0; + } + + if x == 3 { + return (b == 1); + } else { + return (b == 0); + } +} diff --git a/tests/compiler/statements/nested_mutate.leo b/tests/compiler/statements/nested_mutate.leo new file mode 100644 index 0000000000..2b3cac1a9e --- /dev/null +++ b/tests/compiler/statements/nested_mutate.leo @@ -0,0 +1,21 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - u32_3.in + - u32_5.in + - u32_6.in +*/ + +function main(x: u32) -> bool { + let d = x; + + if x == 3 || x == 5 { + d += 1; + if x == 3 { + d += 2; + } + } + + return d > x; +} \ No newline at end of file diff --git a/tests/compiler/statements/u32_3.in b/tests/compiler/statements/u32_3.in new file mode 100644 index 0000000000..f187dd41f7 --- /dev/null +++ b/tests/compiler/statements/u32_3.in @@ -0,0 +1,5 @@ +[main] +x: u32 = 3; + +[registers] +a: bool = false; \ No newline at end of file diff --git a/tests/compiler/statements/u32_5.in b/tests/compiler/statements/u32_5.in new file mode 100644 index 0000000000..e62a4b58db --- /dev/null +++ b/tests/compiler/statements/u32_5.in @@ -0,0 +1,5 @@ +[main] +x: u32 = 5; + +[registers] +a: bool = false; \ No newline at end of file diff --git a/tests/compiler/statements/u32_6.in b/tests/compiler/statements/u32_6.in new file mode 100644 index 0000000000..1f8c86d85a --- /dev/null +++ b/tests/compiler/statements/u32_6.in @@ -0,0 +1,5 @@ +[main] +x: u32 = 6; + +[registers] +a: bool = false; \ No newline at end of file diff --git a/tests/compiler/tuples/basic.leo b/tests/compiler/tuples/basic.leo new file mode 100644 index 0000000000..3a9b0e414c --- /dev/null +++ b/tests/compiler/tuples/basic.leo @@ -0,0 +1,11 @@ +/* +namespace: Compile +expectation: Pass +input_file: inputs/true_true.in +*/ + +function main(a: (bool, bool)) -> (bool, bool) { + const a = (true, false); + + return (a.0, a.1); +} \ No newline at end of file diff --git a/tests/compiler/tuples/dependent.leo b/tests/compiler/tuples/dependent.leo new file mode 100644 index 0000000000..37bcbb738b --- /dev/null +++ b/tests/compiler/tuples/dependent.leo @@ -0,0 +1,11 @@ +/* +namespace: Compile +expectation: Pass +input_file: inputs/true_true.in +*/ + +function main(a: (bool, bool)) -> (bool, bool) { + const a = (a.0 ? false : true, a.1 ? false : true); + + return (a.0, a.1); +} \ No newline at end of file diff --git a/tests/compiler/tuples/destructured.leo b/tests/compiler/tuples/destructured.leo new file mode 100644 index 0000000000..d3780b496e --- /dev/null +++ b/tests/compiler/tuples/destructured.leo @@ -0,0 +1,11 @@ +/* +namespace: Compile +expectation: Pass +input_file: inputs/true_true.in +*/ + +function main(a: (bool, bool)) -> (bool, bool) { + const (a, b) = (a.0 ? false : true, a.1 ? false : true); + + return (b, a); +} \ No newline at end of file diff --git a/tests/compiler/tuples/inputs/true_true.in b/tests/compiler/tuples/inputs/true_true.in new file mode 100644 index 0000000000..f8671a956f --- /dev/null +++ b/tests/compiler/tuples/inputs/true_true.in @@ -0,0 +1,6 @@ +[main] +a: (bool, bool) = (false, true); + +[registers] +b: bool = true; +c: bool = false; \ No newline at end of file diff --git a/tests/compiler/tuples/nested_access.leo b/tests/compiler/tuples/nested_access.leo new file mode 100644 index 0000000000..424ba47822 --- /dev/null +++ b/tests/compiler/tuples/nested_access.leo @@ -0,0 +1,11 @@ +/* +namespace: Compile +expectation: Pass +input_file: inputs/true_true.in +*/ + +function main(a: (bool, bool)) -> (bool, bool) { + const b = (a, false); + + return (b.1 || b.0.0, b.1 && b.0.1); +} \ No newline at end of file diff --git a/tests/expectations/compiler/compiler/address/equal.leo.out b/tests/expectations/compiler/compiler/address/equal.leo.out new file mode 100644 index 0000000000..6a14ab2a43 --- /dev/null +++ b/tests/expectations/compiler/compiler/address/equal.leo.out @@ -0,0 +1,24 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 511 + num_constraints: 511 + at: 61e8ee994e9e7edc1f84fa3cbe8c421ade231189b9ddf6a9a75eeef9915c20f7 + bt: 2194515882da93c79fa24d47c40fddc44f0284da25da7b89efb935c0ea7382f8 + ct: a0736e8c8f3bb1c39a147348754e53dfd31fd76a1df9cd9960472841bcc531df + output: + - input_file: address1.in + output: + registers: + a: + type: bool + value: "true" + - input_file: address2.in + output: + registers: + a: + type: bool + value: "false" diff --git a/tests/expectations/compiler/compiler/address/ternary.leo.out b/tests/expectations/compiler/compiler/address/ternary.leo.out new file mode 100644 index 0000000000..d257950701 --- /dev/null +++ b/tests/expectations/compiler/compiler/address/ternary.leo.out @@ -0,0 +1,24 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 1022 + num_constraints: 1022 + at: 1b42ef63a212d2ea51cab07171c8fb1438112afdbd14501470c2477b9eeb4c99 + bt: 15054154626f1ae748008fc4ed9a650c3873b608988ff31312fe4049957dfffb + ct: dbda9de51fe9897456cbbcc3b450ed7d66185fb6018c7a0c72414784f29b2ad4 + output: + - input_file: address1.in + output: + registers: + a: + type: bool + value: "false" + - input_file: address2.in + output: + registers: + a: + type: bool + value: "false" diff --git a/tests/expectations/compiler/compiler/array/equal_initializer.leo.out b/tests/expectations/compiler/compiler/array/equal_initializer.leo.out new file mode 100644 index 0000000000..6f0788716e --- /dev/null +++ b/tests/expectations/compiler/compiler/array/equal_initializer.leo.out @@ -0,0 +1,24 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 95 + num_constraints: 95 + at: 5884e806c47756fa1d12f47e5cc5249843d8de4e2fafcb373c5a0d67dfe22d69 + bt: 983c734b40e342144d6b4d52e315da9ff9f97580f019f606403924bb977a5be7 + ct: 49f0db71bd29b80dbe5f2f96573a5959b1df339c92350e16f111bade214037aa + output: + - input_file: input/six_zeros.in + output: + registers: + x: + type: bool + value: "true" + - input_file: input/count_to_6.in + output: + registers: + x: + type: bool + value: "false" diff --git a/tests/expectations/compiler/compiler/array/equal_initializer_2.leo.out b/tests/expectations/compiler/compiler/array/equal_initializer_2.leo.out new file mode 100644 index 0000000000..7807e58816 --- /dev/null +++ b/tests/expectations/compiler/compiler/array/equal_initializer_2.leo.out @@ -0,0 +1,24 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 95 + num_constraints: 95 + at: 9273b9ab94dee8605c4f1e49fe99910f674468f5026b8d2c48ecaa4d8c006f3a + bt: a3614a9ddd1ae0fde16a61336aba5a02b44816b3e43e23c7b9663976319bcb8a + ct: 49f0db71bd29b80dbe5f2f96573a5959b1df339c92350e16f111bade214037aa + output: + - input_file: input/six_zeros.in + output: + registers: + x: + type: bool + value: "false" + - input_file: input/count_to_6.in + output: + registers: + x: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/boolean/and.leo.out b/tests/expectations/compiler/compiler/boolean/and.leo.out new file mode 100644 index 0000000000..ff5f7b11f7 --- /dev/null +++ b/tests/expectations/compiler/compiler/boolean/and.leo.out @@ -0,0 +1,36 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 3 + num_constraints: 3 + at: bbd0722c65502a4b903833f9ff9e614e877f9b5c58c670593e2aa290d0457b2f + bt: 49e8fa1fd3f85b0f486c49f194e4fff3da5e8039685fca1f3327389cbe9fc180 + ct: ae5c1ab4ec8811a2ec2efb38b91ab4a8b6fb80bd914b31f9a70559531aeb6a46 + output: + - input_file: input/false_false.in + output: + registers: + x: + type: bool + value: "false" + - input_file: input/false_true.in + output: + registers: + x: + type: bool + value: "false" + - input_file: input/true_false.in + output: + registers: + x: + type: bool + value: "false" + - input_file: input/true_true.in + output: + registers: + x: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/boolean/conditional.leo.out b/tests/expectations/compiler/compiler/boolean/conditional.leo.out new file mode 100644 index 0000000000..ff5f7b11f7 --- /dev/null +++ b/tests/expectations/compiler/compiler/boolean/conditional.leo.out @@ -0,0 +1,36 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 3 + num_constraints: 3 + at: bbd0722c65502a4b903833f9ff9e614e877f9b5c58c670593e2aa290d0457b2f + bt: 49e8fa1fd3f85b0f486c49f194e4fff3da5e8039685fca1f3327389cbe9fc180 + ct: ae5c1ab4ec8811a2ec2efb38b91ab4a8b6fb80bd914b31f9a70559531aeb6a46 + output: + - input_file: input/false_false.in + output: + registers: + x: + type: bool + value: "false" + - input_file: input/false_true.in + output: + registers: + x: + type: bool + value: "false" + - input_file: input/true_false.in + output: + registers: + x: + type: bool + value: "false" + - input_file: input/true_true.in + output: + registers: + x: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/boolean/equal.leo.out b/tests/expectations/compiler/compiler/boolean/equal.leo.out new file mode 100644 index 0000000000..76953125e0 --- /dev/null +++ b/tests/expectations/compiler/compiler/boolean/equal.leo.out @@ -0,0 +1,36 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 3 + num_constraints: 3 + at: d4e77c2cd10c964fbbc4ad4f374dc36b3a6bc7d6865b87ec5234076348308c2c + bt: 49e8fa1fd3f85b0f486c49f194e4fff3da5e8039685fca1f3327389cbe9fc180 + ct: 7ca43d5c34997f3c866631161cb33186cc016972238c07771ae105ca1b05320d + output: + - input_file: input/false_false.in + output: + registers: + x: + type: bool + value: "true" + - input_file: input/false_true.in + output: + registers: + x: + type: bool + value: "false" + - input_file: input/true_false.in + output: + registers: + x: + type: bool + value: "false" + - input_file: input/true_true.in + output: + registers: + x: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/boolean/not_equal.leo.out b/tests/expectations/compiler/compiler/boolean/not_equal.leo.out new file mode 100644 index 0000000000..0192013865 --- /dev/null +++ b/tests/expectations/compiler/compiler/boolean/not_equal.leo.out @@ -0,0 +1,36 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 3 + num_constraints: 3 + at: d4e77c2cd10c964fbbc4ad4f374dc36b3a6bc7d6865b87ec5234076348308c2c + bt: 49e8fa1fd3f85b0f486c49f194e4fff3da5e8039685fca1f3327389cbe9fc180 + ct: 7ca43d5c34997f3c866631161cb33186cc016972238c07771ae105ca1b05320d + output: + - input_file: input/false_false.in + output: + registers: + x: + type: bool + value: "false" + - input_file: input/false_true.in + output: + registers: + x: + type: bool + value: "true" + - input_file: input/true_false.in + output: + registers: + x: + type: bool + value: "true" + - input_file: input/true_true.in + output: + registers: + x: + type: bool + value: "false" diff --git a/tests/expectations/compiler/compiler/boolean/or.leo.out b/tests/expectations/compiler/compiler/boolean/or.leo.out new file mode 100644 index 0000000000..06f1cbad2f --- /dev/null +++ b/tests/expectations/compiler/compiler/boolean/or.leo.out @@ -0,0 +1,36 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 3 + num_constraints: 3 + at: 1df8316bf2fa59a7a92242252ec3c26a425f07212a4c716b2fefd4ddabc2d773 + bt: b95daadce52bb9a3b59565f7078664afbebde46b9b5d6a187e4877926e7a506c + ct: fc07ea064122a2b3be5414ded4cd1e51e3aef7240ad33c8888d757909e9c2c07 + output: + - input_file: input/false_false.in + output: + registers: + x: + type: bool + value: "false" + - input_file: input/false_true.in + output: + registers: + x: + type: bool + value: "true" + - input_file: input/true_false.in + output: + registers: + x: + type: bool + value: "true" + - input_file: input/true_true.in + output: + registers: + x: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/statements/block.leo.out b/tests/expectations/compiler/compiler/statements/block.leo.out new file mode 100644 index 0000000000..8d06221d84 --- /dev/null +++ b/tests/expectations/compiler/compiler/statements/block.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 96 + num_constraints: 97 + at: 82703e2aa614d0f54a1c321e06edd2e79a9574a91d0984d6f5e98926710962f2 + bt: 54bbc6eb42c38f8bbb12360c98b483e782f47c2875d6b88b6ae2b7cd70220cf8 + ct: 52022ccbdc5119e02384f852f21e0ed0b6d729cb1cd18aea031f73037e467755 + output: + - input_file: u32_3.in + output: + registers: + a: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/statements/chain.leo.out b/tests/expectations/compiler/compiler/statements/chain.leo.out new file mode 100644 index 0000000000..20454e0595 --- /dev/null +++ b/tests/expectations/compiler/compiler/statements/chain.leo.out @@ -0,0 +1,30 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 319 + num_constraints: 415 + at: 7758de8b887d66c54fef4affc72141544bcc9762eaabe77639dcbb72d02aaa67 + bt: 3ae01a0af5534bca6ad67bd2609a5370a4982c7f6d17fb8c285054c3d08f9c4f + ct: 67836f65a02c595fcbf6d6a6d223a15e138d99a542390693ac4f582d073869e6 + output: + - input_file: u32_3.in + output: + registers: + a: + type: bool + value: "true" + - input_file: u32_5.in + output: + registers: + a: + type: bool + value: "false" + - input_file: u32_6.in + output: + registers: + a: + type: bool + value: "false" diff --git a/tests/expectations/compiler/compiler/statements/for_loop.leo.out b/tests/expectations/compiler/compiler/statements/for_loop.leo.out new file mode 100644 index 0000000000..2ebe1ba7f1 --- /dev/null +++ b/tests/expectations/compiler/compiler/statements/for_loop.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 512 + num_constraints: 675 + at: da107701a842d40fe2af68152622ca69aa3496c7952cdbeb1b5f4fe69b2661ab + bt: 192ca0dd8a20d69b443b952a7226e8c82936fedd2c9735d2b792883a01e46e3b + ct: 04609638ad65317edb75529646b34f10a846b39b3ddb783e4aeceddde17b79f9 + output: + - input_file: u32_3.in + output: + registers: + a: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/statements/iteration_basic.leo.out b/tests/expectations/compiler/compiler/statements/iteration_basic.leo.out new file mode 100644 index 0000000000..e9b75968ed --- /dev/null +++ b/tests/expectations/compiler/compiler/statements/iteration_basic.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 162 + num_constraints: 165 + at: 5b2ee97bca1c978a9cb40345a5358b6da05b06c94ef08ade726f32a8d0840c4e + bt: 9dc810c17c3ede695558cbade305db754bfc9de90c983ab114557f2cc9bb3631 + ct: 16ed7b0c9d703be9a60d4b2e0da9a52403de8b03c35a545db7c05b698eddcdfd + output: + - input_file: u32_3.in + output: + registers: + a: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/statements/iteration_variable.leo.out b/tests/expectations/compiler/compiler/statements/iteration_variable.leo.out new file mode 100644 index 0000000000..4b90bb7aee --- /dev/null +++ b/tests/expectations/compiler/compiler/statements/iteration_variable.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 129 + num_constraints: 131 + at: 3ce06ba8c0b8ed0af6941d5d0a487cfb836053b5f7098525dbc159dbbca3508a + bt: d0528d867b40b0642b9b93a6b7f6d64ceb8d7e97799848ccd6b7fecfb86e2889 + ct: 638bf6e71b08cf88ff8fc38ff7594880102164a51a452dec39b42c10f6f36c35 + output: + - input_file: u32_3.in + output: + registers: + a: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/statements/multiple_returns.leo.out b/tests/expectations/compiler/compiler/statements/multiple_returns.leo.out new file mode 100644 index 0000000000..9b967dc59e --- /dev/null +++ b/tests/expectations/compiler/compiler/statements/multiple_returns.leo.out @@ -0,0 +1,24 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 63 + num_constraints: 63 + at: 37a483a8d794b0cd2f37b20c69eb00e2d9a3d950319dd18ead861dd505d84ce9 + bt: 6c9fd7d4b3947c363bdb576b2c2c827c3ebfe4c3b56eda2abb8a37e436b69638 + ct: c0d39de2b3b1c321288b265a4f0e72c13da3b07b0f5d61d14b66215440c56a42 + output: + - input_file: u32_3.in + output: + registers: + a: + type: bool + value: "true" + - input_file: u32_5.in + output: + registers: + a: + type: bool + value: "false" diff --git a/tests/expectations/compiler/compiler/statements/mutate.leo.out b/tests/expectations/compiler/compiler/statements/mutate.leo.out new file mode 100644 index 0000000000..52a657ffd3 --- /dev/null +++ b/tests/expectations/compiler/compiler/statements/mutate.leo.out @@ -0,0 +1,24 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 253 + num_constraints: 317 + at: 30a9d7ef92bc14334cf2058df46dd513d99b7d21712c6c8bedfce9c48bc0f402 + bt: eaddc0804e3047ae886466758455accba906f9ae990696f12c17a3237a9c9688 + ct: e60851ccedd572c63dbcec5e0d84ddf45d76423dcf08fe0c9761fe17ce2bdd4e + output: + - input_file: u32_3.in + output: + registers: + a: + type: bool + value: "true" + - input_file: u32_5.in + output: + registers: + a: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/statements/nested_mutate.leo.out b/tests/expectations/compiler/compiler/statements/nested_mutate.leo.out new file mode 100644 index 0000000000..1b1071da2f --- /dev/null +++ b/tests/expectations/compiler/compiler/statements/nested_mutate.leo.out @@ -0,0 +1,30 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 481 + num_constraints: 547 + at: b23dee30e3d6dc6d95933170ea18b5680aa3f859e808328599c3de9027bdbc5f + bt: 86e567b4b178b61f7a2ae29ac78c6f60fc1b6c9cdfdbb6c896c8b059b68a90b6 + ct: eb4c6eaa123567ee0a5b12a2812f90b4f532e657b59249aaad97092bd32cdbe9 + output: + - input_file: u32_3.in + output: + registers: + a: + type: bool + value: "true" + - input_file: u32_5.in + output: + registers: + a: + type: bool + value: "true" + - input_file: u32_6.in + output: + registers: + a: + type: bool + value: "false" diff --git a/tests/expectations/compiler/compiler/tuples/basic.leo.out b/tests/expectations/compiler/compiler/tuples/basic.leo.out new file mode 100644 index 0000000000..06cacdebe4 --- /dev/null +++ b/tests/expectations/compiler/compiler/tuples/basic.leo.out @@ -0,0 +1,21 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 2 + num_constraints: 2 + at: 401937c524c61a28b4fab76d7a1f85bb628850012af62362a0922610372faf92 + bt: cdf9a9cee4f2edf55111a95ae60bde9801080f6bde638a5c79273a39a2f9f7f5 + ct: 643d5437104296e21d906ecb15b2c96ad278f20cfc4af53b12bb6069bd853726 + output: + - input_file: inputs/true_true.in + output: + registers: + b: + type: bool + value: "true" + c: + type: bool + value: "false" diff --git a/tests/expectations/compiler/compiler/tuples/dependent.leo.out b/tests/expectations/compiler/compiler/tuples/dependent.leo.out new file mode 100644 index 0000000000..06cacdebe4 --- /dev/null +++ b/tests/expectations/compiler/compiler/tuples/dependent.leo.out @@ -0,0 +1,21 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 2 + num_constraints: 2 + at: 401937c524c61a28b4fab76d7a1f85bb628850012af62362a0922610372faf92 + bt: cdf9a9cee4f2edf55111a95ae60bde9801080f6bde638a5c79273a39a2f9f7f5 + ct: 643d5437104296e21d906ecb15b2c96ad278f20cfc4af53b12bb6069bd853726 + output: + - input_file: inputs/true_true.in + output: + registers: + b: + type: bool + value: "true" + c: + type: bool + value: "false" diff --git a/tests/expectations/compiler/compiler/tuples/destructured.leo.out b/tests/expectations/compiler/compiler/tuples/destructured.leo.out new file mode 100644 index 0000000000..c7a4802ab8 --- /dev/null +++ b/tests/expectations/compiler/compiler/tuples/destructured.leo.out @@ -0,0 +1,21 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 2 + num_constraints: 2 + at: 401937c524c61a28b4fab76d7a1f85bb628850012af62362a0922610372faf92 + bt: cdf9a9cee4f2edf55111a95ae60bde9801080f6bde638a5c79273a39a2f9f7f5 + ct: 643d5437104296e21d906ecb15b2c96ad278f20cfc4af53b12bb6069bd853726 + output: + - input_file: inputs/true_true.in + output: + registers: + b: + type: bool + value: "false" + c: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/tuples/nested_access.leo.out b/tests/expectations/compiler/compiler/tuples/nested_access.leo.out new file mode 100644 index 0000000000..045f791989 --- /dev/null +++ b/tests/expectations/compiler/compiler/tuples/nested_access.leo.out @@ -0,0 +1,21 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 2 + num_constraints: 2 + at: 401937c524c61a28b4fab76d7a1f85bb628850012af62362a0922610372faf92 + bt: cdf9a9cee4f2edf55111a95ae60bde9801080f6bde638a5c79273a39a2f9f7f5 + ct: 643d5437104296e21d906ecb15b2c96ad278f20cfc4af53b12bb6069bd853726 + output: + - input_file: inputs/true_true.in + output: + registers: + b: + type: bool + value: "false" + c: + type: bool + value: "false"