mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-18 07:11:53 +03:00
fix inputs tests
This commit is contained in:
parent
4566ac8e03
commit
1b6a2b55d4
2
compiler/tests/inputs/inputs/main.in
Normal file
2
compiler/tests/inputs/inputs/main.in
Normal file
@ -0,0 +1,2 @@
|
||||
[main]
|
||||
a: bool = true;
|
2
compiler/tests/inputs/inputs/main_fail_type.in
Normal file
2
compiler/tests/inputs/inputs/main_fail_type.in
Normal file
@ -0,0 +1,2 @@
|
||||
[main]
|
||||
a: u8 = 1;
|
3
compiler/tests/inputs/inputs/main_multiple.in
Normal file
3
compiler/tests/inputs/inputs/main_multiple.in
Normal file
@ -0,0 +1,3 @@
|
||||
[main]
|
||||
a: bool = true;
|
||||
b: bool = false;
|
@ -1,2 +0,0 @@
|
||||
[main]
|
||||
b: bool = true;
|
@ -1,3 +1,3 @@
|
||||
function main(b: bool) -> bool {
|
||||
return b
|
||||
function main(a: bool) {
|
||||
assert_eq!(a, true);
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
[main]
|
||||
b: u8 = 1;
|
@ -1,3 +0,0 @@
|
||||
[main]
|
||||
b: bool = true;
|
||||
a: bool = false;
|
@ -1,3 +1,4 @@
|
||||
function main(a: bool, b: bool) -> bool {
|
||||
return a || b
|
||||
function main(a: bool, b: bool) {
|
||||
assert_eq!(a, true);
|
||||
assert_eq!(b, false);
|
||||
}
|
@ -1,58 +1,49 @@
|
||||
use crate::{boolean::output_true, parse_program};
|
||||
use crate::{assert_satisfied, expect_compiler_error, parse_program_with_inputs, EdwardsTestCompiler};
|
||||
use leo_compiler::errors::CompilerError;
|
||||
use leo_inputs::InputParserError;
|
||||
|
||||
fn fail_input_parser(error: CompilerError) {
|
||||
match error {
|
||||
CompilerError::InputParserError(InputParserError::InputNotFound(_)) => {}
|
||||
err => panic!("expected input parser error, got {}", err),
|
||||
fn expect_fail(program: EdwardsTestCompiler) {
|
||||
match expect_compiler_error(program) {
|
||||
CompilerError::FunctionError(_) => {}
|
||||
err => panic!("expected input parser error, got {:?}", err),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_inputs_pass() {
|
||||
let program_bytes = include_bytes!("main.leo");
|
||||
let input_bytes = include_bytes!("main.in");
|
||||
let input_string = String::from_utf8_lossy(input_bytes);
|
||||
let input_bytes = include_bytes!("inputs/main.in");
|
||||
|
||||
let mut program = parse_program(program_bytes).unwrap();
|
||||
program.parse_inputs(&input_string).unwrap();
|
||||
let program = parse_program_with_inputs(program_bytes, input_bytes).unwrap();
|
||||
|
||||
output_true(program);
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_inputs_fail_name() {
|
||||
let program_bytes = include_bytes!("main.leo");
|
||||
let input_bytes = include_bytes!("main_fail_name.in");
|
||||
let input_string = String::from_utf8_lossy(input_bytes);
|
||||
let input_bytes = include_bytes!("inputs/main_fail_name.in");
|
||||
|
||||
let mut program = parse_program(program_bytes).unwrap();
|
||||
let error = program.parse_inputs(&input_string).unwrap_err();
|
||||
let program = parse_program_with_inputs(program_bytes, input_bytes).unwrap();
|
||||
|
||||
fail_input_parser(error);
|
||||
expect_fail(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_inputs_fail_type() {
|
||||
let program_bytes = include_bytes!("main.leo");
|
||||
let input_bytes = include_bytes!("main_fail_type.in");
|
||||
let input_string = String::from_utf8_lossy(input_bytes);
|
||||
let input_bytes = include_bytes!("inputs/main_fail_type.in");
|
||||
|
||||
let mut program = parse_program(program_bytes).unwrap();
|
||||
let error = program.parse_inputs(&input_string).unwrap_err();
|
||||
let program = parse_program_with_inputs(program_bytes, input_bytes).unwrap();
|
||||
|
||||
fail_input_parser(error);
|
||||
expect_fail(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_inputs_multiple() {
|
||||
let program_bytes = include_bytes!("main_multiple.leo");
|
||||
let input_bytes = include_bytes!("main_multiple.in");
|
||||
let input_string = String::from_utf8_lossy(input_bytes);
|
||||
let input_bytes = include_bytes!("inputs/main_multiple.in");
|
||||
|
||||
let mut program = parse_program(program_bytes).unwrap();
|
||||
program.parse_inputs(&input_string).unwrap();
|
||||
let program = parse_program_with_inputs(program_bytes, input_bytes).unwrap();
|
||||
|
||||
output_true(program);
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ pub mod field;
|
||||
pub mod function;
|
||||
pub mod group;
|
||||
pub mod import;
|
||||
// pub mod inputs;
|
||||
pub mod inputs;
|
||||
// pub mod integers;
|
||||
// pub mod macros;
|
||||
// pub mod mutability;
|
||||
|
Loading…
Reference in New Issue
Block a user