mirror of
https://github.com/AleoHQ/leo.git
synced 2024-11-29 11:43:28 +03:00
adds check for integer parsing error vs integer computation error in tests
This commit is contained in:
parent
ae8fb1f714
commit
7137c98745
@ -2,7 +2,7 @@ use crate::{
|
||||
assert_satisfied,
|
||||
expect_synthesis_error,
|
||||
generate_main_inputs,
|
||||
integers::{expect_fail, IntegerTester},
|
||||
integers::{expect_computation_error, expect_parsing_error, IntegerTester},
|
||||
parse_program,
|
||||
};
|
||||
use leo_inputs::types::{I128Type, IntegerType};
|
||||
|
@ -2,7 +2,7 @@ use crate::{
|
||||
assert_satisfied,
|
||||
expect_synthesis_error,
|
||||
generate_main_inputs,
|
||||
integers::{expect_fail, IntegerTester},
|
||||
integers::{expect_computation_error, expect_parsing_error, IntegerTester},
|
||||
parse_program,
|
||||
};
|
||||
use leo_inputs::types::{I16Type, IntegerType};
|
||||
|
@ -2,7 +2,7 @@ use crate::{
|
||||
assert_satisfied,
|
||||
expect_synthesis_error,
|
||||
generate_main_inputs,
|
||||
integers::{expect_fail, IntegerTester},
|
||||
integers::{expect_computation_error, expect_parsing_error, IntegerTester},
|
||||
parse_program,
|
||||
};
|
||||
use leo_inputs::types::{I32Type, IntegerType};
|
||||
|
@ -2,7 +2,7 @@ use crate::{
|
||||
assert_satisfied,
|
||||
expect_synthesis_error,
|
||||
generate_main_inputs,
|
||||
integers::{expect_fail, IntegerTester},
|
||||
integers::{expect_computation_error, expect_parsing_error, IntegerTester},
|
||||
parse_program,
|
||||
};
|
||||
use leo_inputs::types::{I64Type, IntegerType};
|
||||
|
@ -2,7 +2,7 @@ use crate::{
|
||||
assert_satisfied,
|
||||
expect_synthesis_error,
|
||||
generate_main_inputs,
|
||||
integers::{expect_fail, IntegerTester},
|
||||
integers::{expect_computation_error, expect_parsing_error, IntegerTester},
|
||||
parse_program,
|
||||
};
|
||||
use leo_inputs::types::{I8Type, IntegerType};
|
||||
|
@ -14,7 +14,7 @@ macro_rules! test_int {
|
||||
let bytes = include_bytes!("min_fail.leo");
|
||||
let program = parse_program(bytes).unwrap();
|
||||
|
||||
expect_fail(program);
|
||||
expect_parsing_error(program);
|
||||
}
|
||||
|
||||
fn test_max() {
|
||||
@ -28,7 +28,7 @@ macro_rules! test_int {
|
||||
let bytes = include_bytes!("max_fail.leo");
|
||||
let program = parse_program(bytes).unwrap();
|
||||
|
||||
expect_fail(program);
|
||||
expect_parsing_error(program);
|
||||
}
|
||||
|
||||
fn test_add() {
|
||||
@ -128,11 +128,11 @@ macro_rules! test_int {
|
||||
|
||||
program.set_main_inputs(main_inputs);
|
||||
|
||||
expect_fail(program);
|
||||
expect_computation_error(program);
|
||||
} else {
|
||||
let c = match a.checked_div(b) {
|
||||
Some(valid) => valid,
|
||||
None => return,
|
||||
None => continue,
|
||||
};
|
||||
|
||||
let main_inputs = generate_main_inputs(vec![
|
||||
|
@ -51,11 +51,23 @@ pub trait IntegerTester {
|
||||
fn test_ternary();
|
||||
}
|
||||
|
||||
pub(crate) fn expect_fail(program: EdwardsTestCompiler) {
|
||||
pub(crate) fn expect_parsing_error(program: EdwardsTestCompiler) {
|
||||
match expect_compiler_error(program) {
|
||||
CompilerError::FunctionError(FunctionError::StatementError(StatementError::ExpressionError(
|
||||
ExpressionError::ValueError(ValueError::IntegerError(IntegerError::Error(_))),
|
||||
))) => {}
|
||||
error => panic!("Expected invalid integer error, got {:?}", error),
|
||||
error => panic!("Expected integer parsing error, found {:?}", error),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn expect_computation_error(program: EdwardsTestCompiler) {
|
||||
match expect_compiler_error(program) {
|
||||
CompilerError::FunctionError(FunctionError::StatementError(StatementError::ExpressionError(
|
||||
ExpressionError::IntegerError(IntegerError::Error(_)),
|
||||
))) => {}
|
||||
error => panic!(
|
||||
"Expected integer computation error such as `DivisionByZero`, found {:?}",
|
||||
error
|
||||
),
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use crate::{
|
||||
assert_satisfied,
|
||||
expect_synthesis_error,
|
||||
generate_main_inputs,
|
||||
integers::{expect_fail, IntegerTester},
|
||||
integers::{expect_parsing_error, IntegerTester},
|
||||
parse_program,
|
||||
};
|
||||
use leo_inputs::types::{IntegerType, U128Type};
|
||||
|
@ -2,7 +2,7 @@ use crate::{
|
||||
assert_satisfied,
|
||||
expect_synthesis_error,
|
||||
generate_main_inputs,
|
||||
integers::{expect_fail, IntegerTester},
|
||||
integers::{expect_parsing_error, IntegerTester},
|
||||
parse_program,
|
||||
};
|
||||
use leo_inputs::types::{IntegerType, U16Type};
|
||||
|
@ -2,7 +2,7 @@ use crate::{
|
||||
assert_satisfied,
|
||||
expect_synthesis_error,
|
||||
generate_main_inputs,
|
||||
integers::{expect_fail, IntegerTester},
|
||||
integers::{expect_parsing_error, IntegerTester},
|
||||
parse_program,
|
||||
};
|
||||
use leo_inputs::types::{IntegerType, U32Type};
|
||||
|
@ -2,7 +2,7 @@ use crate::{
|
||||
assert_satisfied,
|
||||
expect_synthesis_error,
|
||||
generate_main_inputs,
|
||||
integers::{expect_fail, IntegerTester},
|
||||
integers::{expect_parsing_error, IntegerTester},
|
||||
parse_program,
|
||||
};
|
||||
use leo_inputs::types::{IntegerType, U64Type};
|
||||
|
@ -2,7 +2,7 @@ use crate::{
|
||||
assert_satisfied,
|
||||
expect_synthesis_error,
|
||||
generate_main_inputs,
|
||||
integers::{expect_fail, IntegerTester},
|
||||
integers::{expect_parsing_error, IntegerTester},
|
||||
parse_program,
|
||||
};
|
||||
use leo_inputs::types::{IntegerType, U8Type};
|
||||
|
@ -14,7 +14,7 @@ macro_rules! test_uint {
|
||||
let bytes = include_bytes!("min_fail.leo");
|
||||
let program = parse_program(bytes).unwrap();
|
||||
|
||||
expect_fail(program);
|
||||
expect_parsing_error(program);
|
||||
}
|
||||
|
||||
fn test_max() {
|
||||
@ -28,7 +28,7 @@ macro_rules! test_uint {
|
||||
let bytes = include_bytes!("max_fail.leo");
|
||||
let program = parse_program(bytes).unwrap();
|
||||
|
||||
expect_fail(program);
|
||||
expect_parsing_error(program);
|
||||
}
|
||||
|
||||
fn test_add() {
|
||||
|
Loading…
Reference in New Issue
Block a user