From 92cac97a848c314330b833220536b7cd117d3ead Mon Sep 17 00:00:00 2001 From: 0rphon <59403052+0rphon@users.noreply.github.com> Date: Sat, 14 May 2022 20:27:08 -0700 Subject: [PATCH] added scalar tests --- .gitignore | 3 +++ tests/compiler/scalar/add.leo | 10 ++++++++++ tests/compiler/scalar/cmp.leo | 16 ++++++++++++++++ tests/compiler/scalar/div.leo | 10 ++++++++++ tests/compiler/scalar/group_mul.leo | 15 +++++++++++++++ tests/compiler/scalar/inputs/scalar_group.in | 7 +++++++ tests/compiler/scalar/inputs/scalars.in | 7 +++++++ tests/compiler/scalar/mul.leo | 10 ++++++++++ tests/compiler/scalar/negate.leo | 10 ++++++++++ .../compiler/scalar/no_space_between_literal.leo | 8 ++++++++ tests/compiler/scalar/scalar.leo | 11 +++++++++++ tests/compiler/scalar/ternary.leo | 10 ++++++++++ 12 files changed, 117 insertions(+) create mode 100644 tests/compiler/scalar/add.leo create mode 100644 tests/compiler/scalar/cmp.leo create mode 100644 tests/compiler/scalar/div.leo create mode 100644 tests/compiler/scalar/group_mul.leo create mode 100644 tests/compiler/scalar/inputs/scalar_group.in create mode 100644 tests/compiler/scalar/inputs/scalars.in create mode 100644 tests/compiler/scalar/mul.leo create mode 100644 tests/compiler/scalar/negate.leo create mode 100644 tests/compiler/scalar/no_space_between_literal.leo create mode 100644 tests/compiler/scalar/scalar.leo create mode 100644 tests/compiler/scalar/ternary.leo diff --git a/.gitignore b/.gitignore index d29c5a8cce..a1484c9626 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,6 @@ sccache*/ *~ \#*\# .\#* + +# code coverage scripts +*.bat \ No newline at end of file diff --git a/tests/compiler/scalar/add.leo b/tests/compiler/scalar/add.leo new file mode 100644 index 0000000000..2fca0c0f53 --- /dev/null +++ b/tests/compiler/scalar/add.leo @@ -0,0 +1,10 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/scalars.in +*/ + +function main(a: scalar, b: scalar, c: scalar) -> bool { + return a + b == c; +} \ No newline at end of file diff --git a/tests/compiler/scalar/cmp.leo b/tests/compiler/scalar/cmp.leo new file mode 100644 index 0000000000..0eae370af0 --- /dev/null +++ b/tests/compiler/scalar/cmp.leo @@ -0,0 +1,16 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/scalars.in +*/ + +function main(a: scalar, b: scalar) -> bool { + let c: bool = a == b; + let d: bool = a != b; + let e: bool = a > b; + let f: bool = a < b; + let g: bool = a >= b; + let h: bool = a <= b; + return h; +} \ No newline at end of file diff --git a/tests/compiler/scalar/div.leo b/tests/compiler/scalar/div.leo new file mode 100644 index 0000000000..679abbe3da --- /dev/null +++ b/tests/compiler/scalar/div.leo @@ -0,0 +1,10 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/scalars.in +*/ + +function main(a: scalar, b: scalar, c: scalar) -> bool { + return a / b != c; +} \ No newline at end of file diff --git a/tests/compiler/scalar/group_mul.leo b/tests/compiler/scalar/group_mul.leo new file mode 100644 index 0000000000..1b170e53f6 --- /dev/null +++ b/tests/compiler/scalar/group_mul.leo @@ -0,0 +1,15 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/scalar_group.in +*/ + +function main(a: scalar, b: group, c: scalar) -> bool { + let d: group = 1group * a; + let e: group = a * 1group; + let f: group = b * a; + let g: group = a * b; + + return a * g == d; +} \ No newline at end of file diff --git a/tests/compiler/scalar/inputs/scalar_group.in b/tests/compiler/scalar/inputs/scalar_group.in new file mode 100644 index 0000000000..29402e1539 --- /dev/null +++ b/tests/compiler/scalar/inputs/scalar_group.in @@ -0,0 +1,7 @@ +[main] +a: scalar = 1scalar; +b: group = 1group; +c: scalar = 2scalar; + +[registers] +r: bool = false; \ No newline at end of file diff --git a/tests/compiler/scalar/inputs/scalars.in b/tests/compiler/scalar/inputs/scalars.in new file mode 100644 index 0000000000..6aa25f85f8 --- /dev/null +++ b/tests/compiler/scalar/inputs/scalars.in @@ -0,0 +1,7 @@ +[main] +a: scalar = 1scalar; +b: scalar = 1scalar; +c: scalar = 2scalar; + +[registers] +r: bool = false; \ No newline at end of file diff --git a/tests/compiler/scalar/mul.leo b/tests/compiler/scalar/mul.leo new file mode 100644 index 0000000000..4ce11e0345 --- /dev/null +++ b/tests/compiler/scalar/mul.leo @@ -0,0 +1,10 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/scalars.in +*/ + +function main(a: scalar, b: scalar, c: scalar) -> bool { + return a * b == c; +} \ No newline at end of file diff --git a/tests/compiler/scalar/negate.leo b/tests/compiler/scalar/negate.leo new file mode 100644 index 0000000000..b9d04811c6 --- /dev/null +++ b/tests/compiler/scalar/negate.leo @@ -0,0 +1,10 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/scalars.in +*/ + +function main(a: scalar, b: scalar) -> bool { + return -a == -b; +} \ No newline at end of file diff --git a/tests/compiler/scalar/no_space_between_literal.leo b/tests/compiler/scalar/no_space_between_literal.leo new file mode 100644 index 0000000000..26e45dd33f --- /dev/null +++ b/tests/compiler/scalar/no_space_between_literal.leo @@ -0,0 +1,8 @@ +/* +namespace: Compile +expectation: Fail +*/ + +function main() { + const f = 1 scalar; +} \ No newline at end of file diff --git a/tests/compiler/scalar/scalar.leo b/tests/compiler/scalar/scalar.leo new file mode 100644 index 0000000000..0c4bd5d386 --- /dev/null +++ b/tests/compiler/scalar/scalar.leo @@ -0,0 +1,11 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/scalars.in +*/ + +function main(a: scalar) -> bool { + const s: scalar = 1scalar; + return s + a == 0scalar; +} \ No newline at end of file diff --git a/tests/compiler/scalar/ternary.leo b/tests/compiler/scalar/ternary.leo new file mode 100644 index 0000000000..91f3c2cf89 --- /dev/null +++ b/tests/compiler/scalar/ternary.leo @@ -0,0 +1,10 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/scalars.in +*/ + +function main(a: scalar, b: scalar, c: scalar) -> bool { + return b == 1scalar ? a == 1scalar : c == 2scalar; +} \ No newline at end of file