leo/compiler/tests/input_files/program_input/mod.rs

50 lines
1.4 KiB
Rust
Raw Normal View History

2020-08-01 05:39:30 +03:00
use crate::{assert_satisfied, expect_compiler_error, parse_program_with_input, EdwardsTestCompiler};
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),
}
}
#[test]
2020-08-01 06:59:50 +03:00
fn test_input_pass() {
let program_bytes = include_bytes!("main.leo");
2020-08-01 06:59:50 +03:00
let input_bytes = include_bytes!("input/main.in");
2020-08-01 05:39:30 +03:00
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
2020-07-31 00:38:31 +03:00
assert_satisfied(program);
}
#[test]
2020-08-01 06:59:50 +03:00
fn test_input_fail_name() {
let program_bytes = include_bytes!("main.leo");
2020-08-01 06:59:50 +03:00
let input_bytes = include_bytes!("input/main_fail_name.in");
2020-08-01 05:39:30 +03:00
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
2020-07-31 00:38:31 +03:00
expect_fail(program);
}
#[test]
2020-08-01 06:59:50 +03:00
fn test_input_fail_type() {
let program_bytes = include_bytes!("main.leo");
2020-08-01 06:59:50 +03:00
let input_bytes = include_bytes!("input/main_fail_type.in");
2020-08-01 05:39:30 +03:00
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
2020-07-31 00:38:31 +03:00
expect_fail(program);
}
#[test]
2020-08-01 06:59:50 +03:00
fn test_input_multiple() {
let program_bytes = include_bytes!("main_multiple.leo");
2020-08-01 06:59:50 +03:00
let input_bytes = include_bytes!("input/main_multiple.in");
2020-08-01 05:39:30 +03:00
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
2020-07-31 00:38:31 +03:00
assert_satisfied(program);
}