2020-08-18 13:50:26 +03:00
|
|
|
// Copyright (C) 2019-2020 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/>.
|
|
|
|
|
2020-06-21 01:24:46 +03:00
|
|
|
use crate::{
|
2020-07-30 10:56:17 +03:00
|
|
|
assert_satisfied,
|
2020-07-30 21:11:54 +03:00
|
|
|
expect_compiler_error,
|
2020-08-01 07:15:33 +03:00
|
|
|
get_output,
|
2020-06-21 01:24:46 +03:00
|
|
|
parse_program,
|
2020-08-01 05:39:30 +03:00
|
|
|
parse_program_with_input,
|
2020-06-21 01:24:46 +03:00
|
|
|
EdwardsTestCompiler,
|
|
|
|
};
|
2020-05-20 03:08:38 +03:00
|
|
|
|
2020-07-30 10:56:17 +03:00
|
|
|
pub fn output_ones(program: EdwardsTestCompiler) {
|
2020-08-17 05:14:26 +03:00
|
|
|
let expected = include_bytes!("output/registers_ones.out");
|
2020-08-01 07:15:33 +03:00
|
|
|
let actual = get_output(program);
|
2020-05-20 03:08:38 +03:00
|
|
|
|
2020-07-30 10:56:17 +03:00
|
|
|
assert!(expected.eq(actual.bytes().as_slice()));
|
2020-05-20 03:08:38 +03:00
|
|
|
}
|
|
|
|
|
2020-07-30 10:56:17 +03:00
|
|
|
pub fn output_zeros(program: EdwardsTestCompiler) {
|
2020-08-17 05:14:26 +03:00
|
|
|
let expected = include_bytes!("output/registers_zeros.out");
|
2020-08-01 07:15:33 +03:00
|
|
|
let actual = get_output(program);
|
2020-07-30 10:56:17 +03:00
|
|
|
|
|
|
|
assert!(expected.eq(actual.bytes().as_slice()));
|
2020-06-11 02:14:55 +03:00
|
|
|
}
|
|
|
|
|
2020-07-30 10:56:17 +03:00
|
|
|
// Registers
|
2020-05-20 03:08:38 +03:00
|
|
|
|
|
|
|
#[test]
|
2020-07-30 10:56:17 +03:00
|
|
|
fn test_registers() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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");
|
2020-07-30 10:56:17 +03:00
|
|
|
|
|
|
|
// test ones input register => ones output register
|
2020-12-04 23:20:59 +03:00
|
|
|
let program = parse_program_with_input(program_string, ones_input_string).unwrap();
|
2020-06-09 03:51:06 +03:00
|
|
|
|
2020-05-20 03:08:38 +03:00
|
|
|
output_ones(program);
|
|
|
|
|
2020-07-30 10:56:17 +03:00
|
|
|
// test zeros input register => zeros output register
|
2020-12-04 23:20:59 +03:00
|
|
|
let program = parse_program_with_input(program_string, zeros_input_string).unwrap();
|
2020-06-09 03:51:06 +03:00
|
|
|
|
2020-07-30 10:56:17 +03:00
|
|
|
output_zeros(program);
|
2020-05-20 03:08:38 +03:00
|
|
|
}
|
|
|
|
|
2020-07-30 10:56:17 +03:00
|
|
|
// Expressions
|
|
|
|
|
2020-05-20 03:08:38 +03:00
|
|
|
#[test]
|
2020-07-30 10:56:17 +03:00
|
|
|
fn test_inline() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-06-09 03:51:06 +03:00
|
|
|
|
2020-07-30 10:56:17 +03:00
|
|
|
assert_satisfied(program);
|
2020-05-20 03:08:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2020-07-30 10:56:17 +03:00
|
|
|
fn test_inline_fail() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("inline.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-06-09 03:51:06 +03:00
|
|
|
|
2020-07-30 21:11:54 +03:00
|
|
|
let _err = expect_compiler_error(program);
|
2020-05-20 03:08:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2020-07-30 10:56:17 +03:00
|
|
|
fn test_initializer() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-06-09 03:51:06 +03:00
|
|
|
|
2020-07-30 10:56:17 +03:00
|
|
|
assert_satisfied(program);
|
2020-05-20 03:08:38 +03:00
|
|
|
}
|
|
|
|
|
2020-08-04 00:56:45 +03:00
|
|
|
#[test]
|
|
|
|
fn test_initializer_fail() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-08-04 00:56:45 +03:00
|
|
|
|
|
|
|
assert!(syntax_error);
|
|
|
|
}
|
|
|
|
|
2020-09-03 02:04:41 +03:00
|
|
|
#[test]
|
|
|
|
fn test_initializer_input() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-09-03 02:04:41 +03:00
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_initializer_input_fail() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-09-03 02:04:41 +03:00
|
|
|
|
|
|
|
assert!(syntax_error);
|
|
|
|
}
|
|
|
|
|
2020-05-20 03:08:38 +03:00
|
|
|
#[test]
|
2020-09-03 12:40:50 +03:00
|
|
|
fn test_input_nested_3x2() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-06-09 03:51:06 +03:00
|
|
|
|
2020-07-30 10:56:17 +03:00
|
|
|
assert_satisfied(program);
|
2020-05-20 03:08:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2020-09-03 12:40:50 +03:00
|
|
|
fn test_input_nested_3x2_fail() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-06-09 03:51:06 +03:00
|
|
|
|
2020-09-03 12:40:50 +03:00
|
|
|
assert!(syntax_error);
|
2020-05-20 03:08:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2020-09-03 12:40:50 +03:00
|
|
|
fn test_input_tuple_3x2() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-06-09 03:51:06 +03:00
|
|
|
|
2020-07-30 10:56:17 +03:00
|
|
|
assert_satisfied(program);
|
2020-05-20 03:08:38 +03:00
|
|
|
}
|
2020-09-02 21:40:58 +03:00
|
|
|
|
|
|
|
#[test]
|
2020-09-03 12:40:50 +03:00
|
|
|
fn test_input_tuple_3x2_fail() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-09-03 10:30:57 +03:00
|
|
|
|
2020-09-03 12:40:50 +03:00
|
|
|
assert!(syntax_error);
|
2020-09-03 10:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_multi_fail_initializer() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("multi_fail_initializer.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-02 21:40:58 +03:00
|
|
|
|
2020-11-10 01:27:59 +03:00
|
|
|
let _err = expect_compiler_error(program);
|
2020-09-02 21:40:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_multi_inline_fail() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("multi_fail_inline.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-02 21:40:58 +03:00
|
|
|
|
2020-11-10 01:27:59 +03:00
|
|
|
let _err = expect_compiler_error(program);
|
2020-09-02 21:40:58 +03:00
|
|
|
}
|
2020-09-03 02:49:06 +03:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_multi_initializer() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("multi_initializer.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 02:49:06 +03:00
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_multi_initializer_fail() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("multi_initializer_fail.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 02:49:06 +03:00
|
|
|
|
2020-11-10 01:27:59 +03:00
|
|
|
let _err = expect_compiler_error(program);
|
2020-09-03 02:49:06 +03:00
|
|
|
}
|
2020-09-03 12:40:50 +03:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_nested_3x2_value() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("nested_3x2_value.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 12:40:50 +03:00
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_nested_3x2_value_fail() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("nested_3x2_value_fail.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 12:40:50 +03:00
|
|
|
|
2020-11-10 02:03:12 +03:00
|
|
|
let _err = expect_compiler_error(program);
|
2020-09-03 12:40:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_tuple_3x2_value() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("tuple_3x2_value.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 12:40:50 +03:00
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_tuple_3x2_value_fail() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("tuple_3x2_value_fail.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 12:40:50 +03:00
|
|
|
|
2020-11-10 02:03:12 +03:00
|
|
|
let _err = expect_compiler_error(program);
|
2020-09-03 12:40:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_spread() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-09-03 12:40:50 +03:00
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_slice() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-09-03 12:40:50 +03:00
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
2020-09-03 23:22:05 +03:00
|
|
|
|
2020-12-10 01:42:15 +03:00
|
|
|
#[test]
|
|
|
|
fn test_slice_lower() {
|
|
|
|
let program_string = include_str!("slice_lower.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
|
|
|
|
2020-09-03 23:22:05 +03:00
|
|
|
// Array type tests
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_type_fail() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("type_fail.leo");
|
|
|
|
let syntax_error = parse_program(program_string).is_err();
|
2020-09-03 23:22:05 +03:00
|
|
|
|
|
|
|
assert!(syntax_error);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2020-09-03 23:56:45 +03:00
|
|
|
fn test_type_nested_value_nested_3x2() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("type_nested_value_nested_3x2.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 23:22:05 +03:00
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2020-09-03 23:56:45 +03:00
|
|
|
fn test_type_nested_value_nested_3x2_fail() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("type_nested_value_nested_3x2_fail.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 23:56:45 +03:00
|
|
|
|
2020-11-10 02:03:12 +03:00
|
|
|
let _err = expect_compiler_error(program);
|
2020-09-03 23:56:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_type_nested_value_nested_4x3x2() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("type_nested_value_nested_4x3x2.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 23:56:45 +03:00
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_type_nested_value_nested_4x3x2_fail() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("type_nested_value_nested_4x3x2_fail.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 23:56:45 +03:00
|
|
|
|
2020-11-10 02:03:12 +03:00
|
|
|
let _err = expect_compiler_error(program);
|
2020-09-03 23:56:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_type_nested_value_tuple_3x2() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("type_nested_value_tuple_3x2.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 23:56:45 +03:00
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_type_nested_value_tuple_3x2_fail() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("type_nested_value_tuple_3x2_fail.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 23:56:45 +03:00
|
|
|
|
2020-11-10 02:03:12 +03:00
|
|
|
let _err = expect_compiler_error(program);
|
2020-09-03 23:56:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_type_nested_value_tuple_4x3x2() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("type_nested_value_tuple_4x3x2.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 23:56:45 +03:00
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_type_nested_value_tuple_4x3x2_fail() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("type_nested_value_tuple_4x3x2_fail.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 23:56:45 +03:00
|
|
|
|
2020-11-10 02:03:12 +03:00
|
|
|
let _err = expect_compiler_error(program);
|
2020-09-03 23:56:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_type_tuple_value_nested_3x2() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("type_tuple_value_nested_3x2.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 23:22:05 +03:00
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
|
|
|
|
2020-09-03 23:56:45 +03:00
|
|
|
#[test]
|
|
|
|
fn test_type_tuple_value_nested_3x2_fail() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("type_tuple_value_nested_3x2_fail.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 23:56:45 +03:00
|
|
|
|
2020-11-10 02:03:12 +03:00
|
|
|
let _err = expect_compiler_error(program);
|
2020-09-03 23:56:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_type_tuple_value_nested_4x3x2() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("type_tuple_value_nested_4x3x2.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 23:56:45 +03:00
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_type_tuple_value_nested_4x3x2_fail() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("type_tuple_value_nested_4x3x2_fail.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 23:56:45 +03:00
|
|
|
|
2020-11-10 02:03:12 +03:00
|
|
|
let _err = expect_compiler_error(program);
|
2020-09-03 23:56:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_type_tuple_value_tuple_3x2() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("type_tuple_value_tuple_3x2.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 23:56:45 +03:00
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_type_tuple_value_tuple_3x2_fail() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("type_tuple_value_tuple_3x2_fail.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 23:56:45 +03:00
|
|
|
|
2020-11-10 02:03:12 +03:00
|
|
|
let _err = expect_compiler_error(program);
|
2020-09-03 23:56:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_type_tuple_value_tuple_4x3x2() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("type_tuple_value_tuple_4x3x2.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 23:56:45 +03:00
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_type_tuple_value_tuple_4x3x2_fail() {
|
2020-12-04 23:34:51 +03:00
|
|
|
let program_string = include_str!("type_tuple_value_tuple_4x3x2_fail.leo");
|
|
|
|
let program = parse_program(program_string).unwrap();
|
2020-09-03 23:56:45 +03:00
|
|
|
|
2020-11-10 02:03:12 +03:00
|
|
|
let _err = expect_compiler_error(program);
|
2020-09-03 23:56:45 +03:00
|
|
|
}
|
|
|
|
|
2020-09-03 23:22:05 +03:00
|
|
|
// Tests for nested multi-dimensional arrays as input to the program
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_input_type_nested_value_nested_3x2() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-09-03 23:22:05 +03:00
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_input_type_nested_value_nested_3x2_fail() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-09-03 23:22:05 +03:00
|
|
|
|
|
|
|
assert!(syntax_error);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_input_type_nested_value_nested_4x3x2() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-09-03 23:22:05 +03:00
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_input_type_nested_value_nested_4x3x2_fail() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-09-03 23:22:05 +03:00
|
|
|
|
|
|
|
assert!(syntax_error);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_input_type_nested_value_tuple_3x2() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-09-03 23:22:05 +03:00
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_input_type_nested_value_tuple_3x2_fail() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-09-03 23:22:05 +03:00
|
|
|
|
|
|
|
assert!(syntax_error);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_input_type_nested_value_tuple_4x3x2() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-09-03 23:22:05 +03:00
|
|
|
|
|
|
|
assert_satisfied(program)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_input_type_nested_value_tuple_4x3x2_fail() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-09-03 23:22:05 +03:00
|
|
|
|
|
|
|
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() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-09-03 23:22:05 +03:00
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_input_type_tuple_value_nested_3x2_fail() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-09-03 23:22:05 +03:00
|
|
|
|
|
|
|
assert!(syntax_error);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_input_type_tuple_value_nested_4x3x2() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-09-03 23:22:05 +03:00
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_input_type_tuple_value_nested_4x3x2_fail() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-09-03 23:22:05 +03:00
|
|
|
|
|
|
|
assert!(syntax_error);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_input_type_tuple_value_tuple_3x2() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-09-03 23:22:05 +03:00
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_input_type_tuple_value_tuple_3x2_fail() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-09-03 23:22:05 +03:00
|
|
|
|
|
|
|
assert!(syntax_error);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_input_type_tuple_value_tuple_4x3x2() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-09-03 23:22:05 +03:00
|
|
|
|
|
|
|
assert_satisfied(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_input_type_tuple_value_tuple_4x3x2_fail() {
|
2020-12-04 23:20:59 +03:00
|
|
|
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();
|
2020-09-03 23:22:05 +03:00
|
|
|
|
|
|
|
assert!(syntax_error);
|
|
|
|
}
|