mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-19 15:41:36 +03:00
use include_str in program input + state tests
This commit is contained in:
parent
675937ba13
commit
7976c739e9
@ -41,17 +41,17 @@ pub fn output_zeros(program: EdwardsTestCompiler) {
|
||||
|
||||
#[test]
|
||||
fn test_registers() {
|
||||
let program_bytes = include_bytes!("registers.leo");
|
||||
let ones_input_bytes = include_bytes!("input/registers_ones.in");
|
||||
let zeros_input_bytes = include_bytes!("input/registers_zeros.in");
|
||||
let program_string = include_str!("registers.leo");
|
||||
let ones_input_string = include_str!("input/registers_ones.in");
|
||||
let zeros_input_string = include_str!("input/registers_zeros.in");
|
||||
|
||||
// test ones input register => ones output register
|
||||
let program = parse_program_with_input(program_bytes, ones_input_bytes).unwrap();
|
||||
let program = parse_program_with_input(program_string, ones_input_string).unwrap();
|
||||
|
||||
output_ones(program);
|
||||
|
||||
// test zeros input register => zeros output register
|
||||
let program = parse_program_with_input(program_bytes, zeros_input_bytes).unwrap();
|
||||
let program = parse_program_with_input(program_string, zeros_input_string).unwrap();
|
||||
|
||||
output_zeros(program);
|
||||
}
|
||||
@ -60,9 +60,9 @@ fn test_registers() {
|
||||
|
||||
#[test]
|
||||
fn test_inline() {
|
||||
let program_bytes = include_bytes!("inline.leo");
|
||||
let input_bytes = include_bytes!("input/three_ones.in");
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program_string = include_str!("inline.leo");
|
||||
let input_string = include_str!("input/three_ones.in");
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
@ -77,72 +77,72 @@ fn test_inline_fail() {
|
||||
|
||||
#[test]
|
||||
fn test_initializer() {
|
||||
let program_bytes = include_bytes!("initializer.leo");
|
||||
let input_bytes = include_bytes!("input/three_ones.in");
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program_string = include_str!("initializer.leo");
|
||||
let input_string = include_str!("input/three_ones.in");
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_initializer_fail() {
|
||||
let program_bytes = include_bytes!("initializer_fail.leo");
|
||||
let input_bytes = include_bytes!("input/three_ones.in");
|
||||
let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err();
|
||||
let program_string = include_str!("initializer_fail.leo");
|
||||
let input_string = include_str!("input/three_ones.in");
|
||||
let syntax_error = parse_program_with_input(program_string, input_string).is_err();
|
||||
|
||||
assert!(syntax_error);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_initializer_input() {
|
||||
let program_bytes = include_bytes!("initializer_input.leo");
|
||||
let input_bytes = include_bytes!("input/six_zeros.in");
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program_string = include_str!("initializer_input.leo");
|
||||
let input_string = include_str!("input/six_zeros.in");
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_initializer_input_fail() {
|
||||
let program_bytes = include_bytes!("initializer_input.leo");
|
||||
let input_bytes = include_bytes!("input/initializer_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err();
|
||||
let program_string = include_str!("initializer_input.leo");
|
||||
let input_string = include_str!("input/initializer_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_string, input_string).is_err();
|
||||
|
||||
assert!(syntax_error);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_nested_3x2() {
|
||||
let program_bytes = include_bytes!("input_nested_3x2.leo");
|
||||
let input_bytes = include_bytes!("input/input_nested_3x2.in");
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program_string = include_str!("input_nested_3x2.leo");
|
||||
let input_string = include_str!("input/input_nested_3x2.in");
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_nested_3x2_fail() {
|
||||
let program_bytes = include_bytes!("input_nested_3x2_fail.leo");
|
||||
let input_bytes = include_bytes!("input/input_nested_3x2_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err();
|
||||
let program_string = include_str!("input_nested_3x2_fail.leo");
|
||||
let input_string = include_str!("input/input_nested_3x2_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_string, input_string).is_err();
|
||||
|
||||
assert!(syntax_error);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_tuple_3x2() {
|
||||
let program_bytes = include_bytes!("input_tuple_3x2.leo");
|
||||
let input_bytes = include_bytes!("input/input_tuple_3x2.in");
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program_string = include_str!("input_tuple_3x2.leo");
|
||||
let input_string = include_str!("input/input_tuple_3x2.in");
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_tuple_3x2_fail() {
|
||||
let program_bytes = include_bytes!("input_tuple_3x2_fail.leo");
|
||||
let input_bytes = include_bytes!("input/input_tuple_3x2_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err();
|
||||
let program_string = include_str!("input_tuple_3x2_fail.leo");
|
||||
let input_string = include_str!("input/input_tuple_3x2_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_string, input_string).is_err();
|
||||
|
||||
assert!(syntax_error);
|
||||
}
|
||||
@ -213,18 +213,18 @@ fn test_tuple_3x2_value_fail() {
|
||||
|
||||
#[test]
|
||||
fn test_spread() {
|
||||
let program_bytes = include_bytes!("spread.leo");
|
||||
let input_bytes = include_bytes!("input/three_ones.in");
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program_string = include_str!("spread.leo");
|
||||
let input_string = include_str!("input/three_ones.in");
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_slice() {
|
||||
let program_bytes = include_bytes!("slice.leo");
|
||||
let input_bytes = include_bytes!("input/three_ones.in");
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program_string = include_str!("slice.leo");
|
||||
let input_string = include_str!("input/three_ones.in");
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
@ -371,72 +371,72 @@ fn test_type_tuple_value_tuple_4x3x2_fail() {
|
||||
|
||||
#[test]
|
||||
fn test_input_type_nested_value_nested_3x2() {
|
||||
let program_bytes = include_bytes!("type_input_3x2.leo");
|
||||
let input_bytes = include_bytes!("input/type_nested_value_nested_3x2.in");
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program_string = include_str!("type_input_3x2.leo");
|
||||
let input_string = include_str!("input/type_nested_value_nested_3x2.in");
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_type_nested_value_nested_3x2_fail() {
|
||||
let program_bytes = include_bytes!("type_input_3x2.leo");
|
||||
let input_bytes = include_bytes!("input/type_nested_value_nested_3x2_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err();
|
||||
let program_string = include_str!("type_input_3x2.leo");
|
||||
let input_string = include_str!("input/type_nested_value_nested_3x2_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_string, input_string).is_err();
|
||||
|
||||
assert!(syntax_error);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_type_nested_value_nested_4x3x2() {
|
||||
let program_bytes = include_bytes!("type_input_4x3x2.leo");
|
||||
let input_bytes = include_bytes!("input/type_nested_value_nested_4x3x2.in");
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program_string = include_str!("type_input_4x3x2.leo");
|
||||
let input_string = include_str!("input/type_nested_value_nested_4x3x2.in");
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_type_nested_value_nested_4x3x2_fail() {
|
||||
let program_bytes = include_bytes!("type_input_4x3x2.leo");
|
||||
let input_bytes = include_bytes!("input/type_nested_value_nested_4x3x2_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err();
|
||||
let program_string = include_str!("type_input_4x3x2.leo");
|
||||
let input_string = include_str!("input/type_nested_value_nested_4x3x2_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_string, input_string).is_err();
|
||||
|
||||
assert!(syntax_error);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_type_nested_value_tuple_3x2() {
|
||||
let program_bytes = include_bytes!("type_input_3x2.leo");
|
||||
let input_bytes = include_bytes!("input/type_nested_value_tuple_3x2.in");
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program_string = include_str!("type_input_3x2.leo");
|
||||
let input_string = include_str!("input/type_nested_value_tuple_3x2.in");
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_type_nested_value_tuple_3x2_fail() {
|
||||
let program_bytes = include_bytes!("type_input_3x2.leo");
|
||||
let input_bytes = include_bytes!("input/type_nested_value_tuple_3x2_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err();
|
||||
let program_string = include_str!("type_input_3x2.leo");
|
||||
let input_string = include_str!("input/type_nested_value_tuple_3x2_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_string, input_string).is_err();
|
||||
|
||||
assert!(syntax_error);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_type_nested_value_tuple_4x3x2() {
|
||||
let program_bytes = include_bytes!("type_input_4x3x2.leo");
|
||||
let input_bytes = include_bytes!("input/type_nested_value_tuple_4x3x2.in");
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program_string = include_str!("type_input_4x3x2.leo");
|
||||
let input_string = include_str!("input/type_nested_value_tuple_4x3x2.in");
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
assert_satisfied(program)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_type_nested_value_tuple_4x3x2_fail() {
|
||||
let program_bytes = include_bytes!("type_input_4x3x2.leo");
|
||||
let input_bytes = include_bytes!("input/type_nested_value_tuple_4x3x2_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err();
|
||||
let program_string = include_str!("type_input_4x3x2.leo");
|
||||
let input_string = include_str!("input/type_nested_value_tuple_4x3x2_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_string, input_string).is_err();
|
||||
|
||||
assert!(syntax_error);
|
||||
}
|
||||
@ -445,72 +445,72 @@ fn test_input_type_nested_value_tuple_4x3x2_fail() {
|
||||
|
||||
#[test]
|
||||
fn test_input_type_tuple_value_nested_3x2() {
|
||||
let program_bytes = include_bytes!("type_input_3x2.leo");
|
||||
let input_bytes = include_bytes!("input/type_tuple_value_nested_3x2.in");
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program_string = include_str!("type_input_3x2.leo");
|
||||
let input_string = include_str!("input/type_tuple_value_nested_3x2.in");
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_type_tuple_value_nested_3x2_fail() {
|
||||
let program_bytes = include_bytes!("type_input_3x2.leo");
|
||||
let input_bytes = include_bytes!("input/type_tuple_value_nested_3x2_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err();
|
||||
let program_string = include_str!("type_input_3x2.leo");
|
||||
let input_string = include_str!("input/type_tuple_value_nested_3x2_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_string, input_string).is_err();
|
||||
|
||||
assert!(syntax_error);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_type_tuple_value_nested_4x3x2() {
|
||||
let program_bytes = include_bytes!("type_input_4x3x2.leo");
|
||||
let input_bytes = include_bytes!("input/type_tuple_value_nested_4x3x2.in");
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program_string = include_str!("type_input_4x3x2.leo");
|
||||
let input_string = include_str!("input/type_tuple_value_nested_4x3x2.in");
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_type_tuple_value_nested_4x3x2_fail() {
|
||||
let program_bytes = include_bytes!("type_input_4x3x2.leo");
|
||||
let input_bytes = include_bytes!("input/type_tuple_value_nested_4x3x2_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err();
|
||||
let program_string = include_str!("type_input_4x3x2.leo");
|
||||
let input_string = include_str!("input/type_tuple_value_nested_4x3x2_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_string, input_string).is_err();
|
||||
|
||||
assert!(syntax_error);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_type_tuple_value_tuple_3x2() {
|
||||
let program_bytes = include_bytes!("type_input_3x2.leo");
|
||||
let input_bytes = include_bytes!("input/type_tuple_value_tuple_3x2.in");
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program_string = include_str!("type_input_3x2.leo");
|
||||
let input_string = include_str!("input/type_tuple_value_tuple_3x2.in");
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_type_tuple_value_tuple_3x2_fail() {
|
||||
let program_bytes = include_bytes!("type_input_3x2.leo");
|
||||
let input_bytes = include_bytes!("input/type_tuple_value_tuple_3x2_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err();
|
||||
let program_string = include_str!("type_input_3x2.leo");
|
||||
let input_string = include_str!("input/type_tuple_value_tuple_3x2_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_string, input_string).is_err();
|
||||
|
||||
assert!(syntax_error);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_type_tuple_value_tuple_4x3x2() {
|
||||
let program_bytes = include_bytes!("type_input_4x3x2.leo");
|
||||
let input_bytes = include_bytes!("input/type_tuple_value_tuple_4x3x2.in");
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program_string = include_str!("type_input_4x3x2.leo");
|
||||
let input_string = include_str!("input/type_tuple_value_tuple_4x3x2.in");
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_type_tuple_value_tuple_4x3x2_fail() {
|
||||
let program_bytes = include_bytes!("type_input_4x3x2.leo");
|
||||
let input_bytes = include_bytes!("input/type_tuple_value_tuple_4x3x2_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err();
|
||||
let program_string = include_str!("type_input_4x3x2.leo");
|
||||
let input_string = include_str!("input/type_tuple_value_tuple_4x3x2_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_string, input_string).is_err();
|
||||
|
||||
assert!(syntax_error);
|
||||
}
|
||||
|
@ -40,37 +40,37 @@ pub fn output_false(program: EdwardsTestCompiler) {
|
||||
|
||||
#[test]
|
||||
fn test_input_pass() {
|
||||
let program_bytes = include_bytes!("assert_eq_input.leo");
|
||||
let input_bytes = include_bytes!("input/true_true.in");
|
||||
let program_string = include_str!("assert_eq_input.leo");
|
||||
let input_string = include_str!("input/true_true.in");
|
||||
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_fail() {
|
||||
let program_bytes = include_bytes!("assert_eq_input.leo");
|
||||
let input_bytes = include_bytes!("input/true_false.in");
|
||||
let program_string = include_str!("assert_eq_input.leo");
|
||||
let input_string = include_str!("input/true_false.in");
|
||||
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
expect_compiler_error(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_registers() {
|
||||
let program_bytes = include_bytes!("output_register.leo");
|
||||
let true_input_bytes = include_bytes!("input/registers_true.in");
|
||||
let false_input_bytes = include_bytes!("input/registers_false.in");
|
||||
let program_string = include_str!("output_register.leo");
|
||||
let true_input_string = include_str!("input/registers_true.in");
|
||||
let false_input_string = include_str!("input/registers_false.in");
|
||||
|
||||
// test true input register => true output register
|
||||
let program = parse_program_with_input(program_bytes, true_input_bytes).unwrap();
|
||||
let program = parse_program_with_input(program_string, true_input_string).unwrap();
|
||||
|
||||
output_true(program);
|
||||
|
||||
// test false input register => false output register
|
||||
let program = parse_program_with_input(program_bytes, false_input_bytes).unwrap();
|
||||
let program = parse_program_with_input(program_string, false_input_string).unwrap();
|
||||
|
||||
output_false(program);
|
||||
}
|
||||
|
@ -48,17 +48,16 @@ fn test_arguments_type_fail() {
|
||||
|
||||
#[test]
|
||||
fn test_blake2s_input() {
|
||||
let input_bytes = include_bytes!("inputs/valid_input.in");
|
||||
let program_bytes = include_bytes!("blake2s_input.leo");
|
||||
let expected_bytes = include_bytes!("outputs/valid_output.out");
|
||||
let input_string = include_str!("inputs/valid_input.in");
|
||||
let program_string = include_str!("blake2s_input.leo");
|
||||
let expected_string = include_str!("outputs/valid_output.out");
|
||||
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
let expected = std::str::from_utf8(expected_bytes).unwrap();
|
||||
let actual_bytes = get_output(program);
|
||||
let actual = std::str::from_utf8(actual_bytes.bytes().as_slice()).unwrap();
|
||||
let actual_string = std::str::from_utf8(actual_bytes.bytes().as_slice()).unwrap();
|
||||
|
||||
assert_eq!(expected, actual)
|
||||
assert_eq!(expected_string, actual_string)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -50,16 +50,15 @@ fn test_iteration_repeated() {
|
||||
|
||||
#[test]
|
||||
fn test_newlines() {
|
||||
let input_bytes = include_bytes!("input/newlines.in");
|
||||
let program_bytes = include_bytes!("newlines.leo");
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let input_string = include_str!("input/newlines.in");
|
||||
let program_string = include_str!("newlines.leo");
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
let expected_bytes = include_bytes!("output/newlines.out");
|
||||
let expected = std::str::from_utf8(expected_bytes).unwrap();
|
||||
let expected_string = include_str!("output/newlines.out");
|
||||
let actual_bytes = get_output(program);
|
||||
let actual = std::str::from_utf8(actual_bytes.bytes().as_slice()).unwrap();
|
||||
let actual_string = std::str::from_utf8(actual_bytes.bytes().as_slice()).unwrap();
|
||||
|
||||
assert_eq!(expected, actual);
|
||||
assert_eq!(expected_string, actual_string);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -72,17 +71,16 @@ fn test_multiple_returns() {
|
||||
|
||||
#[test]
|
||||
fn test_multiple_returns_main() {
|
||||
let program_bytes = include_bytes!("multiple_main.leo");
|
||||
let input_bytes = include_bytes!("input/registers.in");
|
||||
let program_string = include_str!("multiple_main.leo");
|
||||
let input_string = include_str!("input/registers.in");
|
||||
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
let expected_bytes = include_bytes!("output/registers.out");
|
||||
let expected = std::str::from_utf8(expected_bytes).unwrap();
|
||||
let expected_string = include_str!("output/registers.out");
|
||||
let actual_bytes = get_output(program);
|
||||
let actual = std::str::from_utf8(actual_bytes.bytes().as_slice()).unwrap();
|
||||
let actual_string = std::str::from_utf8(actual_bytes.bytes().as_slice()).unwrap();
|
||||
|
||||
assert_eq!(expected, actual);
|
||||
assert_eq!(expected_string, actual_string);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -26,8 +26,8 @@ fn expect_fail(program: EdwardsTestCompiler) {
|
||||
|
||||
#[test]
|
||||
fn test_input_pass() {
|
||||
let program_bytes = include_bytes!("main.leo");
|
||||
let input_bytes = include_bytes!("input/main.in");
|
||||
let program_bytes = include_str!("main.leo");
|
||||
let input_bytes = include_str!("input/main.in");
|
||||
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
|
||||
@ -36,30 +36,30 @@ fn test_input_pass() {
|
||||
|
||||
#[test]
|
||||
fn test_input_fail_name() {
|
||||
let program_bytes = include_bytes!("main.leo");
|
||||
let input_bytes = include_bytes!("input/main_fail_name.in");
|
||||
let program_string = include_str!("main.leo");
|
||||
let input_string = include_str!("input/main_fail_name.in");
|
||||
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
expect_fail(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_fail_type() {
|
||||
let program_bytes = include_bytes!("main.leo");
|
||||
let input_bytes = include_bytes!("input/main_fail_type.in");
|
||||
let program_string = include_str!("main.leo");
|
||||
let input_string = include_str!("input/main_fail_type.in");
|
||||
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
expect_fail(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_multiple() {
|
||||
let program_bytes = include_bytes!("main_multiple.leo");
|
||||
let input_bytes = include_bytes!("input/main_multiple.in");
|
||||
let program_string = include_str!("main_multiple.leo");
|
||||
let input_string = include_str!("input/main_multiple.in");
|
||||
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ fn test_access() {
|
||||
let input_string = include_str!("input/token_withdraw.in");
|
||||
let state_string = include_str!("input/token_withdraw.state");
|
||||
|
||||
let program = parse_program_with_input_and_state(program_strin, input_string, state_string).unwrap();
|
||||
let program = parse_program_with_input_and_state(program_string, input_string, state_string).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
@ -104,17 +104,14 @@ pub(crate) fn parse_input_and_state(
|
||||
}
|
||||
|
||||
pub fn parse_program_with_input(
|
||||
program_bytes: &[u8],
|
||||
input_bytes: &[u8],
|
||||
program_string: &str,
|
||||
input_string: &str,
|
||||
) -> Result<EdwardsTestCompiler, CompilerError> {
|
||||
let mut compiler = new_compiler();
|
||||
|
||||
let program_string = String::from_utf8_lossy(program_bytes);
|
||||
let input_string = String::from_utf8_lossy(input_bytes);
|
||||
let path = PathBuf::new();
|
||||
|
||||
compiler.parse_input(&input_string, &path, EMPTY_FILE, &path)?;
|
||||
compiler.parse_program_from_string(&program_string)?;
|
||||
compiler.parse_input(input_string, &path, EMPTY_FILE, &path)?;
|
||||
compiler.parse_program_from_string(program_string)?;
|
||||
|
||||
Ok(compiler)
|
||||
}
|
||||
|
@ -205,19 +205,19 @@ fn output_zero(program: EdwardsTestCompiler) {
|
||||
|
||||
#[test]
|
||||
fn test_multiple_returns() {
|
||||
let program_bytes = include_bytes!("multiple_returns.leo");
|
||||
let program_string = include_str!("multiple_returns.leo");
|
||||
|
||||
// Check that an input value of 1 writes 1 to the output registers
|
||||
|
||||
let registers_one_bytes = include_bytes!("input/registers_one.in");
|
||||
let program = parse_program_with_input(program_bytes, registers_one_bytes).unwrap();
|
||||
let registers_one_string = include_str!("input/registers_one.in");
|
||||
let program = parse_program_with_input(program_string, registers_one_string).unwrap();
|
||||
|
||||
output_one(program);
|
||||
|
||||
// Check that an input value of 0 writes 0 to the output registers
|
||||
|
||||
let registers_zero_bytes = include_bytes!("input/registers_zero.in");
|
||||
let program = parse_program_with_input(program_bytes, registers_zero_bytes).unwrap();
|
||||
let registers_zero_string = include_str!("input/registers_zero.in");
|
||||
let program = parse_program_with_input(program_string, registers_zero_string).unwrap();
|
||||
|
||||
output_zero(program);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user