fix core package tests

This commit is contained in:
collin 2020-10-26 12:55:00 -07:00
parent 9933b8e336
commit 9bae1037f7
3 changed files with 21 additions and 11 deletions

View File

@ -16,38 +16,38 @@
pub mod packages;
use crate::{assert_satisfied, expect_compiler_error, parse_program};
use crate::{assert_satisfied, expect_static_check_error, parse_program};
#[test]
fn test_core_circuit_invalid() {
let program_bytes = include_bytes!("core_package_invalid.leo");
let program = parse_program(program_bytes).unwrap();
let program = parse_program(program_bytes).err().unwrap();
expect_compiler_error(program);
expect_static_check_error(program);
}
#[test]
fn test_core_circuit_star_fail() {
let program_bytes = include_bytes!("core_circuit_star_fail.leo");
let program = parse_program(program_bytes).unwrap();
let error = parse_program(program_bytes).err().unwrap();
expect_compiler_error(program);
expect_static_check_error(error);
}
#[test]
fn test_core_package_invalid() {
let program_bytes = include_bytes!("core_package_invalid.leo");
let program = parse_program(program_bytes).unwrap();
let error = parse_program(program_bytes).err().unwrap();
expect_compiler_error(program);
expect_static_check_error(error);
}
#[test]
fn test_core_unstable_package_invalid() {
let program_bytes = include_bytes!("core_unstable_package_invalid.leo");
let program = parse_program(program_bytes).unwrap();
let error = parse_program(program_bytes).err().unwrap();
expect_compiler_error(program);
expect_static_check_error(error);
}
#[test]

View File

@ -17,6 +17,7 @@
use crate::{
assert_satisfied,
expect_compiler_error,
expect_dynamic_check_error,
generate_main_input,
get_output,
parse_program,
@ -33,9 +34,9 @@ use snarkos_models::algorithms::PRF;
#[test]
fn test_arguments_length_fail() {
let program_bytes = include_bytes!("arguments_length_fail.leo");
let program = parse_program(program_bytes).unwrap();
let error = parse_program(program_bytes).err().unwrap();
expect_compiler_error(program);
expect_dynamic_check_error(error);
}
#[test]

View File

@ -187,6 +187,15 @@ pub(crate) fn expect_dynamic_check_error(error: CompilerError) {
assert!(is_dynamic_check)
}
pub(crate) fn expect_static_check_error(error: CompilerError) {
let is_static_check = match error {
CompilerError::StaticCheckError(_) => true,
_ => false,
};
assert!(is_static_check)
}
// pub(crate) fn expect_synthesis_error(program: EdwardsTestCompiler) {
// let mut cs = TestConstraintSystem::<Fq>::new();
// let _output = program.generate_constraints_helper(&mut cs).unwrap();