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-08-01 05:39:30 +03:00
|
|
|
use crate::{assert_satisfied, expect_compiler_error, parse_program_with_input, EdwardsTestCompiler};
|
2020-06-12 00:40:27 +03:00
|
|
|
use leo_compiler::errors::CompilerError;
|
|
|
|
|
2020-07-31 00:38:31 +03:00
|
|
|
fn expect_fail(program: EdwardsTestCompiler) {
|
|
|
|
match expect_compiler_error(program) {
|
|
|
|
CompilerError::FunctionError(_) => {}
|
|
|
|
err => panic!("expected input parser error, got {:?}", err),
|
2020-06-12 00:40:27 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2020-08-01 06:59:50 +03:00
|
|
|
fn test_input_pass() {
|
2020-12-04 23:20:59 +03:00
|
|
|
let program_bytes = include_str!("main.leo");
|
|
|
|
let input_bytes = include_str!("input/main.in");
|
2020-06-12 00:40:27 +03:00
|
|
|
|
2020-08-01 05:39:30 +03:00
|
|
|
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
2020-06-12 00:40:27 +03:00
|
|
|
|
2020-07-31 00:38:31 +03:00
|
|
|
assert_satisfied(program);
|
2020-06-12 00:40:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2020-08-01 06:59:50 +03:00
|
|
|
fn test_input_fail_name() {
|
2020-12-04 23:20:59 +03:00
|
|
|
let program_string = include_str!("main.leo");
|
|
|
|
let input_string = include_str!("input/main_fail_name.in");
|
2020-06-12 00:40:27 +03:00
|
|
|
|
2020-12-04 23:20:59 +03:00
|
|
|
let program = parse_program_with_input(program_string, input_string).unwrap();
|
2020-06-12 00:40:27 +03:00
|
|
|
|
2020-07-31 00:38:31 +03:00
|
|
|
expect_fail(program);
|
2020-06-12 00:40:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2020-08-01 06:59:50 +03:00
|
|
|
fn test_input_fail_type() {
|
2020-12-04 23:20:59 +03:00
|
|
|
let program_string = include_str!("main.leo");
|
|
|
|
let input_string = include_str!("input/main_fail_type.in");
|
2020-06-12 00:40:27 +03:00
|
|
|
|
2020-12-04 23:20:59 +03:00
|
|
|
let program = parse_program_with_input(program_string, input_string).unwrap();
|
2020-06-12 00:40:27 +03:00
|
|
|
|
2020-07-31 00:38:31 +03:00
|
|
|
expect_fail(program);
|
2020-06-12 00:40:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2020-08-01 06:59:50 +03:00
|
|
|
fn test_input_multiple() {
|
2020-12-04 23:20:59 +03:00
|
|
|
let program_string = include_str!("main_multiple.leo");
|
|
|
|
let input_string = include_str!("input/main_multiple.in");
|
2020-06-12 00:40:27 +03:00
|
|
|
|
2020-12-04 23:20:59 +03:00
|
|
|
let program = parse_program_with_input(program_string, input_string).unwrap();
|
2020-06-12 00:40:27 +03:00
|
|
|
|
2020-07-31 00:38:31 +03:00
|
|
|
assert_satisfied(program);
|
2020-06-12 00:40:27 +03:00
|
|
|
}
|