From 37bedc8662de0158c3e6c125ddf67f8bf6e050ee Mon Sep 17 00:00:00 2001 From: collin Date: Sat, 15 Aug 2020 16:31:07 -0700 Subject: [PATCH] impl tests for group notation --- compiler/tests/group/double_high.leo | 3 + compiler/tests/group/double_inferred.leo | 3 + compiler/tests/group/double_low.leo | 3 + compiler/tests/group/mod.rs | 92 +++++++++++++++++++----- compiler/tests/group/one.leo | 3 - compiler/tests/group/x_sign_high.leo | 3 + compiler/tests/group/x_sign_inferred.leo | 3 + compiler/tests/group/x_sign_low.leo | 3 + compiler/tests/group/y_sign_high.leo | 3 + compiler/tests/group/y_sign_inferred.leo | 3 + compiler/tests/group/y_sign_low.leo | 3 + compiler/tests/group/zero.leo | 3 - 12 files changed, 103 insertions(+), 22 deletions(-) create mode 100644 compiler/tests/group/double_high.leo create mode 100644 compiler/tests/group/double_inferred.leo create mode 100644 compiler/tests/group/double_low.leo delete mode 100644 compiler/tests/group/one.leo create mode 100644 compiler/tests/group/x_sign_high.leo create mode 100644 compiler/tests/group/x_sign_inferred.leo create mode 100644 compiler/tests/group/x_sign_low.leo create mode 100644 compiler/tests/group/y_sign_high.leo create mode 100644 compiler/tests/group/y_sign_inferred.leo create mode 100644 compiler/tests/group/y_sign_low.leo delete mode 100644 compiler/tests/group/zero.leo diff --git a/compiler/tests/group/double_high.leo b/compiler/tests/group/double_high.leo new file mode 100644 index 0000000000..a8217d6d40 --- /dev/null +++ b/compiler/tests/group/double_high.leo @@ -0,0 +1,3 @@ +function main() { + let element = (+, +)group; +} \ No newline at end of file diff --git a/compiler/tests/group/double_inferred.leo b/compiler/tests/group/double_inferred.leo new file mode 100644 index 0000000000..b3b8b512c3 --- /dev/null +++ b/compiler/tests/group/double_inferred.leo @@ -0,0 +1,3 @@ +function main() { + let element = (_, _)group; +} \ No newline at end of file diff --git a/compiler/tests/group/double_low.leo b/compiler/tests/group/double_low.leo new file mode 100644 index 0000000000..0519c6d17d --- /dev/null +++ b/compiler/tests/group/double_low.leo @@ -0,0 +1,3 @@ +function main() { + let element = (-, -)group; +} \ No newline at end of file diff --git a/compiler/tests/group/mod.rs b/compiler/tests/group/mod.rs index b10e6b0842..70b986c701 100644 --- a/compiler/tests/group/mod.rs +++ b/compiler/tests/group/mod.rs @@ -1,5 +1,6 @@ use crate::{ assert_satisfied, + expect_compiler_error, expect_synthesis_error, field::field_to_decimal_string, generate_main_input, @@ -20,22 +21,6 @@ pub fn group_to_decimal_string(g: EdwardsAffine) -> String { format!("({}, {})", x, y) } -#[test] -fn test_zero() { - let bytes = include_bytes!("zero.leo"); - let program = parse_program(bytes).unwrap(); - - assert_satisfied(program); -} - -#[test] -fn test_one() { - let bytes = include_bytes!("one.leo"); - let program = parse_program(bytes).unwrap(); - - assert_satisfied(program) -} - #[test] fn test_point() { let bytes = include_bytes!("point.leo"); @@ -44,6 +29,81 @@ fn test_point() { assert_satisfied(program); } +#[test] +fn test_x_sign_high() { + let bytes = include_bytes!("x_sign_high.leo"); + let program = parse_program(bytes).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_x_sign_low() { + let bytes = include_bytes!("x_sign_low.leo"); + let program = parse_program(bytes).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_x_sign_inferred() { + let bytes = include_bytes!("x_sign_inferred.leo"); + let program = parse_program(bytes).unwrap(); + + assert_satisfied(program); +} + +// #[test] +// fn test_y_sign_high() { +// let bytes = include_bytes!("y_sign_high.leo"); +// let program = parse_program(bytes).unwrap(); +// +// assert_satisfied(program); +// } +// +// #[test] +// fn test_y_sign_low() { +// let bytes = include_bytes!("y_sign_low.leo"); +// let program = parse_program(bytes).unwrap(); +// +// assert_satisfied(program); +// } +// +// #[test] +// fn test_y_sign_inferred() { +// let bytes = include_bytes!("y_sign_inferred.leo"); +// let program = parse_program(bytes).unwrap(); +// +// assert_satisfied(program); +// } + +#[test] +fn test_double_high() { + let bytes = include_bytes!("double_high.leo"); + + let program = parse_program(bytes).unwrap(); + + expect_compiler_error(program); +} + +#[test] +fn test_double_low() { + let bytes = include_bytes!("double_low.leo"); + + let program = parse_program(bytes).unwrap(); + + expect_compiler_error(program); +} + +#[test] +fn test_double_inferred() { + let bytes = include_bytes!("double_inferred.leo"); + + let program = parse_program(bytes).unwrap(); + + expect_compiler_error(program); +} + #[test] fn test_point_input() { let program_bytes = include_bytes!("point_input.leo"); diff --git a/compiler/tests/group/one.leo b/compiler/tests/group/one.leo deleted file mode 100644 index 78188d4893..0000000000 --- a/compiler/tests/group/one.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main() { - let a = 1group; -} \ No newline at end of file diff --git a/compiler/tests/group/x_sign_high.leo b/compiler/tests/group/x_sign_high.leo new file mode 100644 index 0000000000..1b8d397d02 --- /dev/null +++ b/compiler/tests/group/x_sign_high.leo @@ -0,0 +1,3 @@ +function main() { + let element = (0, +)group; +} \ No newline at end of file diff --git a/compiler/tests/group/x_sign_inferred.leo b/compiler/tests/group/x_sign_inferred.leo new file mode 100644 index 0000000000..9e9622a4a4 --- /dev/null +++ b/compiler/tests/group/x_sign_inferred.leo @@ -0,0 +1,3 @@ +function main() { + let element = (0, _)group; +} \ No newline at end of file diff --git a/compiler/tests/group/x_sign_low.leo b/compiler/tests/group/x_sign_low.leo new file mode 100644 index 0000000000..a5058bda52 --- /dev/null +++ b/compiler/tests/group/x_sign_low.leo @@ -0,0 +1,3 @@ +function main() { + let element = (0, -)group; +} \ No newline at end of file diff --git a/compiler/tests/group/y_sign_high.leo b/compiler/tests/group/y_sign_high.leo new file mode 100644 index 0000000000..fe16883b39 --- /dev/null +++ b/compiler/tests/group/y_sign_high.leo @@ -0,0 +1,3 @@ +function main() { + let element = (+, 1)group; +} \ No newline at end of file diff --git a/compiler/tests/group/y_sign_inferred.leo b/compiler/tests/group/y_sign_inferred.leo new file mode 100644 index 0000000000..003c373cf2 --- /dev/null +++ b/compiler/tests/group/y_sign_inferred.leo @@ -0,0 +1,3 @@ +function main() { + let element = (_, 1)group; +} \ No newline at end of file diff --git a/compiler/tests/group/y_sign_low.leo b/compiler/tests/group/y_sign_low.leo new file mode 100644 index 0000000000..9e61bfd2bb --- /dev/null +++ b/compiler/tests/group/y_sign_low.leo @@ -0,0 +1,3 @@ +function main() { + let element = (-, 1)group; +} \ No newline at end of file diff --git a/compiler/tests/group/zero.leo b/compiler/tests/group/zero.leo deleted file mode 100644 index 199a8498a7..0000000000 --- a/compiler/tests/group/zero.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main() { - let a = 0group; -} \ No newline at end of file