2020-06-06 00:09:12 +03:00
|
|
|
#[macro_use]
|
|
|
|
pub mod macros;
|
2020-06-06 02:35:50 +03:00
|
|
|
|
|
|
|
use crate::{get_error, EdwardsTestCompiler};
|
|
|
|
use leo_compiler::errors::{CompilerError, FunctionError, IntegerError};
|
2020-06-06 00:09:12 +03:00
|
|
|
|
|
|
|
pub trait IntegerTester {
|
|
|
|
/// Tests use of the integer in a function input
|
|
|
|
fn test_input();
|
|
|
|
|
|
|
|
/// Tests a wrapping addition
|
|
|
|
fn test_add();
|
|
|
|
|
|
|
|
/// Tests a wrapping subtraction
|
|
|
|
fn test_sub();
|
|
|
|
|
|
|
|
/// Tests a wrapping multiplication
|
|
|
|
fn test_mul();
|
|
|
|
|
|
|
|
/// Tests a non-wrapping division
|
|
|
|
fn test_div();
|
|
|
|
|
|
|
|
/// Tests a wrapping exponentiation
|
|
|
|
fn test_pow();
|
2020-06-06 01:34:06 +03:00
|
|
|
|
|
|
|
/// Tests == evaluation
|
|
|
|
fn test_eq();
|
|
|
|
|
|
|
|
/// Tests >= evaluation
|
|
|
|
fn test_ge();
|
|
|
|
|
|
|
|
/// Tests > evaluation
|
|
|
|
fn test_gt();
|
|
|
|
|
|
|
|
/// Tests <= evaluation
|
|
|
|
fn test_le();
|
|
|
|
|
|
|
|
/// Tests < evaluation
|
|
|
|
fn test_lt();
|
|
|
|
|
|
|
|
/// Test assert equals constraint keyword
|
|
|
|
fn test_assert_eq();
|
|
|
|
|
|
|
|
/// Test ternary if bool ? num_1 : num_2;
|
|
|
|
fn test_ternary();
|
2020-06-06 00:09:12 +03:00
|
|
|
}
|
|
|
|
|
2020-06-06 02:35:50 +03:00
|
|
|
pub(crate) fn fail_integer(program: EdwardsTestCompiler) {
|
|
|
|
match get_error(program) {
|
|
|
|
CompilerError::FunctionError(FunctionError::IntegerError(
|
|
|
|
IntegerError::InvalidInteger(_string),
|
|
|
|
)) => {}
|
|
|
|
error => panic!("Expected invalid boolean error, got {}", error),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn fail_synthesis(program: EdwardsTestCompiler) {
|
|
|
|
match get_error(program) {
|
|
|
|
CompilerError::FunctionError(FunctionError::IntegerError(
|
|
|
|
IntegerError::SynthesisError(_string),
|
|
|
|
)) => {}
|
|
|
|
error => panic!("Expected synthesis error, got {}", error),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-06 00:09:12 +03:00
|
|
|
// must be below macro definitions!
|
2020-06-06 02:51:26 +03:00
|
|
|
pub mod u128;
|
2020-06-06 02:35:50 +03:00
|
|
|
pub mod u16;
|
2020-05-20 03:08:38 +03:00
|
|
|
pub mod u32;
|
2020-06-06 02:35:50 +03:00
|
|
|
pub mod u64;
|
|
|
|
pub mod u8;
|