remove otests folder

This commit is contained in:
damirka 2021-05-12 19:45:01 +03:00
parent 6138f8e719
commit 17b59fe96f
652 changed files with 0 additions and 13940 deletions

View File

@ -1,6 +0,0 @@
function main() {
const address_1 = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
const address_2 = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j9;
console.assert(address_1 == address_2);
}

View File

@ -1,6 +0,0 @@
function main() {
const address_1 = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
const address_2 = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
console.assert(address_1 == address_2);
}

View File

@ -1,3 +0,0 @@
function main() {
const owner = address();
}

View File

@ -1,3 +0,0 @@
function main(a: address, b: address, c: bool) {
console.assert(a == b == c);
}

View File

@ -1,3 +0,0 @@
function main() {
const public_key_string: address = zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
}

View File

@ -1,3 +0,0 @@
function main() {
const public_key_string: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
}

View File

@ -1,5 +0,0 @@
function main(owner: address) {
const sender = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
console.assert(owner == sender);
}

View File

@ -1,3 +0,0 @@
function main() {
const public_key_string = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j88;
}

View File

@ -1,3 +0,0 @@
function main() {
const public_key_string = address(zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8);
}

View File

@ -1,139 +0,0 @@
// 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 <https://www.gnu.org/licenses/>.
use crate::{assert_satisfied, expect_asg_error, expect_compiler_error, generate_main_input, parse_program};
use leo_ast::InputValue;
static TEST_ADDRESS_1: &str = "aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8";
static TEST_ADDRESS_2: &str = "aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpq3dq05r";
#[test]
fn test_valid() {
let program_string = include_str!("valid.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program)
}
#[test]
fn test_invalid_prefix() {
let program_string = include_str!("invalid_prefix.leo");
let syntax_error = parse_program(program_string).is_err();
assert!(syntax_error);
}
#[test]
fn test_invalid_length() {
let program_string = include_str!("invalid_length.leo");
let syntax_error = parse_program(program_string).is_err();
assert!(syntax_error);
}
#[test]
fn test_empty() {
let program_string = include_str!("empty.leo");
let syntax_error = parse_program(program_string).is_err();
assert!(syntax_error);
}
#[test]
fn test_implicit_valid() {
let program_string = include_str!("implicit_valid.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_implicit_invalid() {
let program_string = include_str!("implicit_invalid.leo");
let error = parse_program(program_string).err().unwrap();
expect_asg_error(error);
}
#[test]
fn test_console_assert_pass() {
let program_string = include_str!("console_assert_pass.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_console_assert_fail() {
let program_string = include_str!("console_assert_fail.leo");
let program = parse_program(program_string).unwrap();
let _output = expect_compiler_error(program);
}
#[test]
fn test_ternary() {
let program_string = include_str!("ternary.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("s", Some(InputValue::Boolean(true))),
("c", Some(InputValue::Address(TEST_ADDRESS_1.to_string()))),
]);
program.set_main_input(main_input);
assert_satisfied(program);
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("s", Some(InputValue::Boolean(false))),
("c", Some(InputValue::Address(TEST_ADDRESS_2.to_string()))),
]);
program.set_main_input(main_input);
assert_satisfied(program);
}
#[test]
fn test_equal() {
let program_string = include_str!("equal.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Address(TEST_ADDRESS_1.to_string()))),
("b", Some(InputValue::Address(TEST_ADDRESS_1.to_string()))),
("c", 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::Address(TEST_ADDRESS_1.to_string()))),
("b", Some(InputValue::Address(TEST_ADDRESS_2.to_string()))),
("c", Some(InputValue::Boolean(false))),
]);
program.set_main_input(main_input);
assert_satisfied(program);
}

View File

@ -1,8 +0,0 @@
function main(s: bool, c: address) {
const a = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
const b = aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpq3dq05r;
let r = s ? a: b;
console.assert(r == c);
}

View File

@ -1,3 +0,0 @@
function main() {
const public_key_string = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
}

View File

@ -1,3 +0,0 @@
function main(a: [u8; 3]) {
console.assert(a == [1u8; 3]);
}

View File

@ -1,3 +0,0 @@
function main(a: [u8; 3]) {
console.assert(a == [1u8; -3]);
}

View File

@ -1,3 +0,0 @@
function main(a: [u8; (3, 2)]) {
console.assert(a == [0u8; (3, 2)]);
}

View File

@ -1,3 +0,0 @@
function main(a: [u8; 3]) {
console.assert(a == [1u8, 1u8, 1u8]);
}

View File

@ -1,2 +0,0 @@
[main]
a: [u8; (3, 2)] = [0u8; (2, 2)];

View File

@ -1,3 +0,0 @@
function main() {
const a = [1u8, bool];
}

View File

@ -1,2 +0,0 @@
[main]
a: [u8; (3, 2)] = [[0u8; 2]; 3];

View File

@ -1,2 +0,0 @@
[main]
a: [u8; (3, 2)] = [[0u8; 3]; 2)];

View File

@ -1,2 +0,0 @@
[main]
a: [u8; (3, 2)] = [0u8; (3, 2)];

View File

@ -1,2 +0,0 @@
[main]
a: [u8; (3, 2)] = [0u8; (2, 3)];

View File

@ -1,2 +0,0 @@
[registers]
r: [u8; 3] = [1u8, 1u8, 1u8];

View File

@ -1,2 +0,0 @@
[registers]
r: [u8; 3] = [0u8, 0u8, 0u8];

View File

@ -1,2 +0,0 @@
[main]
a: [u8; (3, 2)] = [0; (3, 2)];

View File

@ -1,2 +0,0 @@
[main]
a: [u8; 3] = [1, 1, 1];

View File

@ -1,2 +0,0 @@
[main]
a: [[u8; 2]; 3] = [[0; 2]; 3];

View File

@ -1,2 +0,0 @@
[main]
a: [[u8; 2]; 3] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering)

View File

@ -1,2 +0,0 @@
[main]
a: [[[u8; 2]; 3]; 4] = [[[0; 2]; 3]; 4];

View File

@ -1,2 +0,0 @@
[main]
a: [[[u8; 2]; 3]; 4] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering)

View File

@ -1,2 +0,0 @@
[main]
a: [[u8; 2]; 3] = [0; (3, 2)];

View File

@ -1,2 +0,0 @@
[main]
a: [[u8; 2]; 3] = [0; (2, 3)]; // initializer (incorrectly reversed ordering)

View File

@ -1,2 +0,0 @@
[main]
a: [[[u8; 2]; 3]; 4] = [0; (4, 3, 2)];

View File

@ -1,2 +0,0 @@
[main]
a: [[[u8; 2]; 3]; 4] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering)

View File

@ -1,2 +0,0 @@
[main]
a: [u8; (3, 2)] = [[0; 2]; 3];

View File

@ -1,2 +0,0 @@
[main]
a: [u8; (3, 2)] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering)

View File

@ -1,2 +0,0 @@
[main]
a: [u8; (4, 3, 2)] = [[[0; 2]; 3]; 4];

View File

@ -1,2 +0,0 @@
[main]
a: [u8; (4, 3, 2)] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering)

View File

@ -1,2 +0,0 @@
[main]
a: [u8; (3, 2)] = [0; (3, 2)];

View File

@ -1,2 +0,0 @@
[main]
a: [u8; (3, 2)] = [0; (2, 3)]; // initializer (incorrectly reversed ordering)

View File

@ -1,2 +0,0 @@
[main]
a: [u8; (4, 3, 2)] = [0; (4, 3, 2)];

View File

@ -1,2 +0,0 @@
[main]
a: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering)

View File

@ -1,3 +0,0 @@
function main(a: [u8; (3, 2)]) {
console.assert(a == [[0u8; 2]; 3]);
}

View File

@ -1,3 +0,0 @@
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.
}

View File

@ -1,3 +0,0 @@
function main(a: [u8; (3, 2)]) {
console.assert(a == [0u8; (3, 2)]);
}

View File

@ -1,3 +0,0 @@
function main(a: [u8; (3, 2)]) {
console.assert(a == [0u8; (3, 2)]);
}

View File

@ -1,716 +0,0 @@
// 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 <https://www.gnu.org/licenses/>.
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);
}

View File

@ -1,3 +0,0 @@
function main() {
const arr: [u8; (2, 2)] = [[1u8; 2]; 1]; // incorrect dimensions
}

View File

@ -1,4 +0,0 @@
function main() {
const arr: [u8; (2, 2)] = [[1u8, 1u8],
[1u8]]; // incorrect dimensions
}

View File

@ -1,7 +0,0 @@
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);
}

View File

@ -1,3 +0,0 @@
function main() {
const arr: [u8; (2, 2)] = [1u8; (2, 1)]; // incorrect dimensions
}

View File

@ -1,4 +0,0 @@
function main () {
const x = [false; (2, 2)];
const y: bool = x[0][0];
}

View File

@ -1,8 +0,0 @@
// 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);
}

View File

@ -1,4 +0,0 @@
// Multidimensional array syntax in leo
function main() {
const a: [u32; (3, 2)] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering)
}

View File

@ -1,2 +0,0 @@
[registers]
r: [u8; 3] = [1, 1, 1];

View File

@ -1,2 +0,0 @@
[registers]
r: [u8; 3] = [0, 0, 0];

View File

@ -1,3 +0,0 @@
function main() -> [u8; 3] {
return input.registers.r;
}

View File

@ -1,6 +0,0 @@
// `{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]);
}

View File

@ -1,8 +0,0 @@
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);
}

View File

@ -1,7 +0,0 @@
// 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);
}

View File

@ -1,8 +0,0 @@
// 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);
}

View File

@ -1,4 +0,0 @@
// Multidimensional array syntax in leo
function main() {
const a: [u32; (3, 2)] = [0; (2, 3)]; // initializer (incorrectly reversed ordering)
}

View File

@ -1,3 +0,0 @@
function main() {
const a: [u8; -2] = [0u32; 2];
}

View File

@ -1,5 +0,0 @@
function main(a: [[u8; 2]; 3]) {
const b = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline
console.assert(a == b);
}

View File

@ -1,8 +0,0 @@
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);
}

View File

@ -1,7 +0,0 @@
function main() {
const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline
const b: [[u8; 2]; 3] = [[0; 2]; 3]; // initializer
console.assert(a == b);
}

View File

@ -1,3 +0,0 @@
function main() {
const b: [[u8; 2]; 3] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering)
}

View File

@ -1,10 +0,0 @@
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);
}

View File

@ -1,3 +0,0 @@
function main() {
const b: [[[u8; 2]; 3]; 4] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering)
}

View File

@ -1,7 +0,0 @@
function main() {
const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline
const b: [[u8; 2]; 3] = [0; (3, 2)]; // initializer
console.assert(a == b);
}

View File

@ -1,3 +0,0 @@
function main() {
const b: [[u8; 2]; 3] = [0; (2, 3)]; // initializer (incorrectly reversed ordering)
}

View File

@ -1,10 +0,0 @@
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);
}

View File

@ -1,3 +0,0 @@
function main() {
const b: [[[u8; 2]; 3]; 4] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering)
}

View File

@ -1,7 +0,0 @@
function main() {
const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline
const b: [u8; (3, 2)] = [[0; 2]; 3]; // initializer
console.assert(a == b);
}

View File

@ -1,3 +0,0 @@
function main() {
const b: [u8; (2, 3)] = [[0; 2]; 3]; // initializer (incorrectly reversed ordering)
}

View File

@ -1,10 +0,0 @@
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);
}

View File

@ -1,3 +0,0 @@
function main() {
const b: [u8; (4, 3, 2)] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering)
}

View File

@ -1,7 +0,0 @@
function main() {
const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline
const b: [u8; (3, 2)] = [0; (3, 2)]; // initializer
console.assert(a == b);
}

View File

@ -1,3 +0,0 @@
function main() {
const b: [u8; (2, 3)] = [0; (3, 2)]; // initializer (incorrectly reversed ordering)
}

View File

@ -1,10 +0,0 @@
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);
}

View File

@ -1,3 +0,0 @@
function main() {
const b: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed order)
}

View File

@ -1,7 +0,0 @@
function main() {
const a = [1u8; 10];
for i in 0..10 {
const x = a[i..10];
console.debug("{}", x);
}
}

View File

@ -1,8 +0,0 @@
// !(true && (false || true))
function main() {
const a = true;
const b = false || a;
const c = !(true && b);
console.assert(c == false);
}

View File

@ -1,3 +0,0 @@
function main(a: bool, b: bool) {
console.assert(a == b);
}

View File

@ -1,6 +0,0 @@
function main () {
let x = true;
if x {
const y = 0u8;
}
}

View File

@ -1,5 +0,0 @@
function main() {
const a = false && false;
console.assert(a == false);
}

View File

@ -1,5 +0,0 @@
function main() {
const a = false || false;
console.assert(a == false);
}

View File

@ -1,2 +0,0 @@
[registers]
r: bool = false;

View File

@ -1,2 +0,0 @@
[registers]
r: bool = true;

View File

@ -1,3 +0,0 @@
[main]
a: bool = true;
b: bool = false;

View File

@ -1,3 +0,0 @@
[main]
a: bool = true;
b: bool = true;

View File

@ -1,196 +0,0 @@
// 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 <https://www.gnu.org/licenses/>.
use crate::{
assert_satisfied,
expect_asg_error,
expect_compiler_error,
get_output,
parse_program,
parse_program_with_input,
EdwardsTestCompiler,
};
pub fn output_true(program: EdwardsTestCompiler) {
let expected = include_bytes!("output/registers_true.out");
let actual = get_output(program);
assert_eq!(expected, actual.bytes().as_slice());
}
pub fn output_false(program: EdwardsTestCompiler) {
let expected = include_bytes!("output/registers_false.out");
let actual = get_output(program);
assert_eq!(expected, actual.bytes().as_slice());
}
#[test]
fn test_input_pass() {
let program_string = include_str!("assert_eq_input.leo");
let input_string = include_str!("input/true_true.in");
let program = parse_program_with_input(program_string, input_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_input_fail() {
let program_string = include_str!("assert_eq_input.leo");
let input_string = include_str!("input/true_false.in");
let program = parse_program_with_input(program_string, input_string).unwrap();
expect_compiler_error(program);
}
#[test]
fn test_registers() {
let program_string = include_str!("output_register.leo");
let true_input_string = include_str!("input/registers_true.in");
let false_input_string = include_str!("input/registers_false.in");
// test true input register => true output register
let program = parse_program_with_input(program_string, true_input_string).unwrap();
output_true(program);
// test false input register => false output register
let program = parse_program_with_input(program_string, false_input_string).unwrap();
output_false(program);
}
// Boolean not !
#[test]
fn test_not_true() {
let program_string = include_str!("not_true.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_not_false() {
let program_string = include_str!("not_false.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_not_mutable() {
let program_string = include_str!("not_mutable.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_conditional_mut() {
let program_string = include_str!("conditional_mut.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_not_u32() {
let program_string = include_str!("not_u32.leo");
let error = parse_program(program_string).err().unwrap();
expect_asg_error(error);
}
// Boolean or ||
#[test]
fn test_true_or_true() {
let program_string = include_str!("true_or_true.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_true_or_false() {
let program_string = include_str!("true_or_false.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_false_or_false() {
let program_string = include_str!("false_or_false.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_true_or_u32() {
let program_string = include_str!("true_or_u32.leo");
let error = parse_program(program_string).err().unwrap();
expect_asg_error(error);
}
// Boolean and &&
#[test]
fn test_true_and_true() {
let program_string = include_str!("true_and_true.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_true_and_false() {
let program_string = include_str!("true_and_false.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_false_and_false() {
let program_string = include_str!("false_and_false.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_true_and_u32() {
let program_string = include_str!("true_and_u32.leo");
let error = parse_program(program_string).err().unwrap();
expect_asg_error(error);
}
// All
#[test]
fn test_all() {
let program_string = include_str!("all.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}

View File

@ -1,3 +0,0 @@
function main() {
console.assert(!false == true);
}

View File

@ -1,4 +0,0 @@
function main () {
const b = false;
const a = !b;
}

View File

@ -1,3 +0,0 @@
function main() {
console.assert(!true == false);
}

View File

@ -1,3 +0,0 @@
function main() -> bool {
console.assert(!1u32 == 0u32);
}

View File

@ -1,2 +0,0 @@
[registers]
r: bool = false;

View File

@ -1,2 +0,0 @@
[registers]
r: bool = true;

View File

@ -1,3 +0,0 @@
function main() -> bool {
return input.registers.r;
}

View File

@ -1,5 +0,0 @@
function main() {
const a = true && false;
console.assert(a == false);
}

Some files were not shown because too many files have changed in this diff Show More