rename all bytes variables to string

This commit is contained in:
collin 2020-12-04 15:48:43 -05:00
parent 674caf5902
commit 2352ebaf2c
20 changed files with 441 additions and 441 deletions

View File

@ -79,32 +79,32 @@ fn test_registers() {
#[test]
fn test_not_true() {
let bytes = include_str!("not_true.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("not_true.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_not_false() {
let bytes = include_str!("not_false.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("not_false.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_not_mutable() {
let bytes = include_str!("not_mutable.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("not_mutable.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_not_u32() {
let bytes = include_str!("not_u32.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("not_u32.leo");
let program = parse_program(program_string).unwrap();
expect_compiler_error(program);
}
@ -113,32 +113,32 @@ fn test_not_u32() {
#[test]
fn test_true_or_true() {
let bytes = include_str!("true_or_true.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("true_or_true.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_true_or_false() {
let bytes = include_str!("true_or_false.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("true_or_false.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_false_or_false() {
let bytes = include_str!("false_or_false.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("false_or_false.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_true_or_u32() {
let bytes = include_str!("true_or_u32.leo");
let error = parse_program(bytes).err().unwrap();
let program_string = include_str!("true_or_u32.leo");
let error = parse_program(program_string).err().unwrap();
expect_type_inference_error(error);
}
@ -147,32 +147,32 @@ fn test_true_or_u32() {
#[test]
fn test_true_and_true() {
let bytes = include_str!("true_and_true.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("true_and_true.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_true_and_false() {
let bytes = include_str!("true_and_false.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("true_and_false.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_false_and_false() {
let bytes = include_str!("false_and_false.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("false_and_false.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_true_and_u32() {
let bytes = include_str!("true_and_u32.leo");
let error = parse_program(bytes).err().unwrap();
let program_string = include_str!("true_and_u32.leo");
let error = parse_program(program_string).err().unwrap();
expect_type_inference_error(error);
}
@ -181,8 +181,8 @@ fn test_true_and_u32() {
#[test]
fn test_all() {
let bytes = include_str!("all.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("all.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}

View File

@ -20,24 +20,24 @@ use crate::{assert_satisfied, expect_compiler_error, expect_type_inference_error
#[test]
fn test_inline() {
let bytes = include_str!("inline.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("inline.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_inline_fail() {
let bytes = include_str!("inline_fail.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("inline_fail.leo");
let program = parse_program(program_string).unwrap();
expect_compiler_error(program);
}
#[test]
fn test_inline_undefined() {
let bytes = include_str!("inline_undefined.leo");
let error = parse_program(bytes).err().unwrap();
let program_string = include_str!("inline_undefined.leo");
let error = parse_program(program_string).err().unwrap();
expect_type_inference_error(error);
}
@ -46,88 +46,88 @@ fn test_inline_undefined() {
#[test]
fn test_member_variable() {
let bytes = include_str!("member_variable.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("member_variable.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_member_variable_fail() {
let bytes = include_str!("member_variable_fail.leo");
let error = parse_program(bytes).err().unwrap();
let program_string = include_str!("member_variable_fail.leo");
let error = parse_program(program_string).err().unwrap();
expect_type_inference_error(error);
}
#[test]
fn test_member_variable_and_function() {
let bytes = include_str!("member_variable_and_function.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("member_variable_and_function.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_member_function() {
let bytes = include_str!("member_function.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("member_function.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_member_function_fail() {
let bytes = include_str!("member_function_fail.leo");
let error = parse_program(bytes).err().unwrap();
let program_string = include_str!("member_function_fail.leo");
let error = parse_program(program_string).err().unwrap();
expect_type_inference_error(error);
}
#[test]
fn test_member_function_invalid() {
let bytes = include_str!("member_function_invalid.leo");
let error = parse_program(bytes).err().unwrap();
let program_string = include_str!("member_function_invalid.leo");
let error = parse_program(program_string).err().unwrap();
expect_type_inference_error(error);
}
#[test]
fn test_member_function_nested() {
let bytes = include_str!("member_function_nested.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("member_function_nested.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_member_static_function() {
let bytes = include_str!("member_static_function.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("member_static_function.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_member_static_function_nested() {
let bytes = include_str!("member_static_function_nested.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("member_static_function_nested.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_member_static_function_invalid() {
let bytes = include_str!("member_static_function_invalid.leo");
let error = parse_program(bytes).err().unwrap();
let program_string = include_str!("member_static_function_invalid.leo");
let error = parse_program(program_string).err().unwrap();
expect_type_inference_error(error)
}
#[test]
fn test_member_static_function_undefined() {
let bytes = include_str!("member_static_function_undefined.leo");
let error = parse_program(bytes).err().unwrap();
let program_string = include_str!("member_static_function_undefined.leo");
let error = parse_program(program_string).err().unwrap();
expect_type_inference_error(error)
}
@ -136,64 +136,64 @@ fn test_member_static_function_undefined() {
#[test]
fn test_mutate_function_fail() {
let bytes = include_str!("mut_function_fail.leo");
let error = parse_program(bytes).err().unwrap();
let program_string = include_str!("mut_function_fail.leo");
let error = parse_program(program_string).err().unwrap();
expect_type_inference_error(error);
}
#[test]
fn test_mutate_self_variable() {
let bytes = include_str!("mut_self_variable.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("mut_self_variable.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_mutate_self_variable_fail() {
let bytes = include_str!("mut_self_variable_fail.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("mut_self_variable_fail.leo");
let program = parse_program(program_string).unwrap();
expect_compiler_error(program);
}
#[test]
fn test_mutate_self_function_fail() {
let bytes = include_str!("mut_self_function_fail.leo");
let error = parse_program(bytes).err().unwrap();
let program_string = include_str!("mut_self_function_fail.leo");
let error = parse_program(program_string).err().unwrap();
expect_type_inference_error(error);
}
#[test]
fn test_mutate_self_static_function_fail() {
let bytes = include_str!("mut_self_static_function_fail.leo");
let error = parse_program(bytes).err().unwrap();
let program_string = include_str!("mut_self_static_function_fail.leo");
let error = parse_program(program_string).err().unwrap();
expect_type_inference_error(error);
}
#[test]
fn test_mutate_static_function_fail() {
let bytes = include_str!("mut_static_function_fail.leo");
let error = parse_program(bytes).err().unwrap();
let program_string = include_str!("mut_static_function_fail.leo");
let error = parse_program(program_string).err().unwrap();
expect_type_inference_error(error);
}
#[test]
fn test_mutate_variable() {
let bytes = include_str!("mut_variable.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("mut_variable.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_mutate_variable_fail() {
let bytes = include_str!("mut_variable_fail.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("mut_variable_fail.leo");
let program = parse_program(program_string).unwrap();
expect_compiler_error(program);
}
@ -202,32 +202,32 @@ fn test_mutate_variable_fail() {
#[test]
fn test_self_fail() {
let bytes = include_str!("self_fail.leo");
let error = parse_program(bytes).err().unwrap();
let program_string = include_str!("self_fail.leo");
let error = parse_program(program_string).err().unwrap();
expect_type_inference_error(error);
}
#[test]
fn test_self_member_pass() {
let bytes = include_str!("self_member.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("self_member.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_self_member_invalid() {
let bytes = include_str!("self_member_invalid.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("self_member_invalid.leo");
let program = parse_program(program_string).unwrap();
let _err = expect_compiler_error(program);
}
#[test]
fn test_self_member_undefined() {
let bytes = include_str!("self_member_undefined.leo");
let error = parse_program(bytes).err().unwrap();
let program_string = include_str!("self_member_undefined.leo");
let error = parse_program(program_string).err().unwrap();
expect_type_inference_error(error);
}
@ -236,16 +236,16 @@ fn test_self_member_undefined() {
#[test]
fn test_pedersen_mock() {
let bytes = include_str!("pedersen_mock.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("pedersen_mock.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_define_circuit_inside_circuit_function() {
let bytes = include_str!("define_circuit_inside_circuit_function.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("define_circuit_inside_circuit_function.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}

View File

@ -19,63 +19,63 @@ use leo_ast::InputValue;
#[test]
fn test_log() {
let bytes = include_str!("log.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("log.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_log_fail() {
let bytes = include_str!("log_fail.leo");
let program_string = include_str!("log_fail.leo");
assert!(parse_program(bytes).is_err());
assert!(parse_program(program_string).is_err());
}
#[test]
fn test_log_parameter() {
let bytes = include_str!("log_parameter.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("log_parameter.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_log_parameter_many() {
let bytes = include_str!("log_parameter_many.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("log_parameter_many.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_log_parameter_fail_unknown() {
let bytes = include_str!("log_parameter_fail_unknown.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("log_parameter_fail_unknown.leo");
let program = parse_program(program_string).unwrap();
expect_compiler_error(program);
}
#[test]
fn test_log_parameter_fail_empty() {
let bytes = include_str!("log_parameter_fail_empty.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("log_parameter_fail_empty.leo");
let program = parse_program(program_string).unwrap();
expect_compiler_error(program);
}
#[test]
fn test_log_parameter_fail_none() {
let bytes = include_str!("log_parameter_fail_empty.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("log_parameter_fail_empty.leo");
let program = parse_program(program_string).unwrap();
expect_compiler_error(program);
}
#[test]
fn test_log_input() {
let bytes = include_str!("log_input.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("log_input.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]);
@ -88,8 +88,8 @@ fn test_log_input() {
#[test]
fn test_debug() {
let bytes = include_str!("debug.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("debug.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
@ -98,8 +98,8 @@ fn test_debug() {
#[test]
fn test_error() {
let bytes = include_str!("error.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("error.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
@ -108,8 +108,8 @@ fn test_error() {
#[test]
fn test_assert() {
let bytes = include_str!("assert.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("assert.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]);
@ -117,7 +117,7 @@ fn test_assert() {
assert_satisfied(program);
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(false)))]);
@ -128,15 +128,15 @@ fn test_assert() {
#[test]
fn test_conditional_assert() {
let bytes = include_str!("conditional_assert.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("conditional_assert.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]);
program.set_main_input(main_input);
assert_satisfied(program);
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(false)))]);

View File

@ -20,40 +20,40 @@ use crate::{assert_satisfied, expect_symbol_table_error, parse_program};
#[test]
fn test_core_circuit_invalid() {
let program_bytes = include_str!("core_package_invalid.leo");
let program = parse_program(program_bytes).err().unwrap();
let program_string = include_str!("core_package_invalid.leo");
let error = parse_program(program_string).err().unwrap();
expect_symbol_table_error(program);
expect_symbol_table_error(error);
}
#[test]
fn test_core_circuit_star_fail() {
let program_bytes = include_str!("core_circuit_star_fail.leo");
let error = parse_program(program_bytes).err().unwrap();
let program_string = include_str!("core_circuit_star_fail.leo");
let error = parse_program(program_string).err().unwrap();
expect_symbol_table_error(error);
}
#[test]
fn test_core_package_invalid() {
let program_bytes = include_str!("core_package_invalid.leo");
let error = parse_program(program_bytes).err().unwrap();
let program_string = include_str!("core_package_invalid.leo");
let error = parse_program(program_string).err().unwrap();
expect_symbol_table_error(error);
}
#[test]
fn test_core_unstable_package_invalid() {
let program_bytes = include_str!("core_unstable_package_invalid.leo");
let error = parse_program(program_bytes).err().unwrap();
let program_string = include_str!("core_unstable_package_invalid.leo");
let error = parse_program(program_string).err().unwrap();
expect_symbol_table_error(error);
}
#[test]
fn test_unstable_blake2s_sanity() {
let program_bytes = include_str!("unstable_blake2s.leo");
let program = parse_program(program_bytes).unwrap();
let program_string = include_str!("unstable_blake2s.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}

View File

@ -32,16 +32,16 @@ use snarkos_models::algorithms::PRF;
#[test]
fn test_arguments_length_fail() {
let program_bytes = include_str!("arguments_length_fail.leo");
let error = parse_program(program_bytes).err().unwrap();
let program_string = include_str!("arguments_length_fail.leo");
let error = parse_program(program_string).err().unwrap();
expect_type_inference_error(error);
}
#[test]
fn test_arguments_type_fail() {
let program_bytes = include_str!("arguments_type_fail.leo");
let error = parse_program(program_bytes).err().unwrap();
let program_string = include_str!("arguments_type_fail.leo");
let error = parse_program(program_string).err().unwrap();
expect_type_inference_error(error);
}

View File

@ -18,9 +18,9 @@ use crate::{assert_satisfied, import::set_local_dir, parse_program};
#[test]
fn test_out_of_order() {
let program_bytes = include_str!("out_of_order.leo");
let program_string = include_str!("out_of_order.leo");
let program = parse_program(program_bytes).unwrap();
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
@ -30,9 +30,9 @@ fn test_out_of_order() {
fn test_out_of_order_with_import() {
set_local_dir();
let program_bytes = include_str!("out_of_order_with_import.leo");
let program_string = include_str!("out_of_order_with_import.leo");
let program = parse_program(program_bytes).unwrap();
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}

View File

@ -52,8 +52,8 @@ fn test_negate() {
let a_string = field_to_decimal_string(a);
let b_string = field_to_decimal_string(b);
let bytes = include_str!("negate.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("negate.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Field(a_string))),
@ -81,8 +81,8 @@ fn test_add() {
let b_string = field_to_decimal_string(b);
let c_string = field_to_decimal_string(c);
let bytes = include_str!("add.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("add.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Field(a_string))),
@ -111,8 +111,8 @@ fn test_sub() {
let b_string = field_to_decimal_string(b);
let c_string = field_to_decimal_string(c);
let bytes = include_str!("sub.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("sub.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Field(a_string))),
@ -140,8 +140,8 @@ fn test_div() {
let b_string = field_to_decimal_string(b);
let c_string = field_to_decimal_string(c);
let bytes = include_str!("div.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("div.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Field(a_string))),
@ -169,8 +169,8 @@ fn test_mul() {
let b_string = field_to_decimal_string(b);
let c_string = field_to_decimal_string(c);
let bytes = include_str!("mul.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("mul.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Field(a_string))),
@ -197,8 +197,8 @@ fn test_eq() {
// test equal
let bytes = include_str!("eq.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("eq.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Field(a_string.clone()))),
@ -214,7 +214,7 @@ fn test_eq() {
let c = a.eq(&b);
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Field(a_string))),
@ -237,8 +237,8 @@ fn test_console_assert_pass() {
let a_string = field_to_decimal_string(a);
let bytes = include_str!("console_assert.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("console_assert.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Field(a_string.clone()))),
@ -266,8 +266,8 @@ fn test_console_assert_fail() {
let a_string = field_to_decimal_string(a);
let b_string = field_to_decimal_string(b);
let bytes = include_str!("console_assert.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("console_assert.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Field(a_string))),
@ -290,8 +290,8 @@ fn test_ternary() {
let a_string = field_to_decimal_string(a);
let b_string = field_to_decimal_string(b);
let bytes = include_str!("ternary.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("ternary.leo");
let mut program = parse_program(program_string).unwrap();
// true -> field a
let main_input = generate_main_input(vec![
@ -305,7 +305,7 @@ fn test_ternary() {
assert_satisfied(program);
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
// false -> field b
let main_input = generate_main_input(vec![
@ -325,14 +325,14 @@ fn test_ternary() {
// let expected = include_str!("output_/register_one.out");
// let actual = get_output(program);
//
// assert_eq!(expected, actual.bytes().as_slice());
// assert_eq!(expected, actual.program_string().as_slice());
// }
//
// pub fn output_zero(program: EdwardsTestCompiler) {
// let expected = include_str!("output_/register_zero.out");
// let actual = get_output(program);
//
// assert_eq!(expected, actual.bytes().as_slice());
// assert_eq!(expected, actual.program_string().as_slice());
// }
//
// #[test]

View File

@ -26,24 +26,24 @@ use leo_compiler::errors::{CompilerError, ExpressionError, FunctionError, Statem
#[test]
fn test_empty() {
let bytes = include_str!("empty.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("empty.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_iteration() {
let bytes = include_str!("iteration.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("iteration.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_iteration_repeated() {
let bytes = include_str!("iteration_repeated.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("iteration_repeated.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
@ -63,8 +63,8 @@ fn test_newlines() {
#[test]
fn test_multiple_returns() {
let bytes = include_str!("multiple.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("multiple.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
@ -85,24 +85,24 @@ fn test_multiple_returns_main() {
#[test]
fn test_repeated_function_call() {
let bytes = include_str!("repeated.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("repeated.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_return() {
let bytes = include_str!("return.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("return.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_scope_fail() {
let bytes = include_str!("scope_fail.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("scope_fail.leo");
let program = parse_program(program_string).unwrap();
match expect_compiler_error(program) {
CompilerError::FunctionError(FunctionError::StatementError(StatementError::ExpressionError(
@ -117,24 +117,24 @@ fn test_scope_fail() {
#[test]
fn test_undefined() {
let bytes = include_str!("undefined.leo");
let error = parse_program(bytes).err().unwrap();
let program_string = include_str!("undefined.leo");
let error = parse_program(program_string).err().unwrap();
expect_type_inference_error(error);
}
#[test]
fn test_value_unchanged() {
let bytes = include_str!("value_unchanged.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("value_unchanged.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_array_input() {
let bytes = include_str!("array_input.leo");
let error = parse_program(bytes).err().unwrap();
let program_string = include_str!("array_input.leo");
let error = parse_program(program_string).err().unwrap();
expect_type_inference_error(error)
}
@ -143,32 +143,32 @@ fn test_array_input() {
#[test]
fn test_return_array_nested_fail() {
let bytes = include_str!("return_array_nested_fail.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("return_array_nested_fail.leo");
let program = parse_program(program_string).unwrap();
let _err = expect_compiler_error(program);
}
#[test]
fn test_return_array_nested_pass() {
let bytes = include_str!("return_array_nested_pass.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("return_array_nested_pass.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_return_array_tuple_fail() {
let bytes = include_str!("return_array_tuple_fail.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("return_array_tuple_fail.leo");
let program = parse_program(program_string).unwrap();
let _err = expect_compiler_error(program);
}
#[test]
fn test_return_array_tuple_pass() {
let bytes = include_str!("return_array_tuple_pass.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("return_array_tuple_pass.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
@ -177,16 +177,16 @@ fn test_return_array_tuple_pass() {
#[test]
fn test_return_tuple() {
let bytes = include_str!("return_tuple.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("return_tuple.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_return_tuple_conditional() {
let bytes = include_str!("return_tuple_conditional.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("return_tuple_conditional.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}

View File

@ -52,124 +52,124 @@ pub fn group_element_to_input_value(g: EdwardsAffine) -> GroupValue {
#[test]
fn test_one() {
let bytes = include_str!("one.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("one.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_zero() {
let bytes = include_str!("zero.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("zero.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_point() {
let bytes = include_str!("point.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("point.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_x_sign_high() {
let bytes = include_str!("x_sign_high.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("x_sign_high.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_x_sign_low() {
let bytes = include_str!("x_sign_low.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("x_sign_low.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_x_sign_inferred() {
let bytes = include_str!("x_sign_inferred.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("x_sign_inferred.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_y_sign_high() {
let bytes = include_str!("y_sign_high.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("y_sign_high.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_y_sign_low() {
let bytes = include_str!("y_sign_low.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("y_sign_low.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_y_sign_inferred() {
let bytes = include_str!("y_sign_inferred.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("y_sign_inferred.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_both_sign_high() {
let bytes = include_str!("both_sign_high.leo");
let program_string = include_str!("both_sign_high.leo");
let program = parse_program(bytes).unwrap();
let program = parse_program(program_string).unwrap();
expect_compiler_error(program);
}
#[test]
fn test_both_sign_low() {
let bytes = include_str!("both_sign_low.leo");
let program_string = include_str!("both_sign_low.leo");
let program = parse_program(bytes).unwrap();
let program = parse_program(program_string).unwrap();
expect_compiler_error(program);
}
#[test]
fn test_both_sign_inferred() {
let bytes = include_str!("both_sign_inferred.leo");
let program_string = include_str!("both_sign_inferred.leo");
let program = parse_program(bytes).unwrap();
let program = parse_program(program_string).unwrap();
expect_compiler_error(program);
}
#[test]
fn test_point_input() {
let program_bytes = include_str!("point_input.leo");
let program_string = include_str!("point_input.leo");
let input_bytes = include_str!("input/point.in");
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
let program = parse_program_with_input(program_string, input_bytes).unwrap();
assert_satisfied(program);
}
#[test]
fn test_input() {
let program_bytes = include_str!("input.leo");
let input_bytes_pass = include_str!("input/valid.in");
let input_bytes_fail = include_str!("input/invalid.in");
let program_string = include_str!("input.leo");
let input_string_pass = include_str!("input/valid.in");
let input_string_fail = include_str!("input/invalid.in");
let program = parse_program_with_input(program_bytes, input_bytes_pass).unwrap();
let program = parse_program_with_input(program_string, input_string_pass).unwrap();
assert_satisfied(program);
let program = parse_program_with_input(program_bytes, input_bytes_fail).unwrap();
let program = parse_program_with_input(program_string, input_string_fail).unwrap();
expect_compiler_error(program);
}
@ -187,8 +187,8 @@ fn test_negate() {
let a_element = group_element_to_input_value(a);
let b_element = group_element_to_input_value(b);
let bytes = include_str!("negate.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("negate.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Group(a_element))),
@ -215,8 +215,8 @@ fn test_add() {
let b_element = group_element_to_input_value(b);
let c_element = group_element_to_input_value(c);
let bytes = include_str!("add.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("add.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Group(a_element))),
@ -244,8 +244,8 @@ fn test_sub() {
let b_element = group_element_to_input_value(b);
let c_element = group_element_to_input_value(c);
let bytes = include_str!("sub.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("sub.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Group(a_element))),
@ -267,8 +267,8 @@ fn test_console_assert_pass() {
let a_element = group_element_to_input_value(a);
let bytes = include_str!("assert_eq.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("assert_eq.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Group(a_element.clone()))),
@ -296,8 +296,8 @@ fn test_console_assert_fail() {
let a_element = group_element_to_input_value(a);
let b_element = group_element_to_input_value(b);
let bytes = include_str!("assert_eq.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("assert_eq.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Group(a_element))),
@ -323,8 +323,8 @@ fn test_eq() {
// test equal
let bytes = include_str!("eq.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("eq.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Group(a_element.clone()))),
@ -340,7 +340,7 @@ fn test_eq() {
let c = a.eq(&b);
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Group(a_element))),
@ -364,8 +364,8 @@ fn test_ternary() {
let a_element = group_element_to_input_value(a);
let b_element = group_element_to_input_value(b);
let bytes = include_str!("ternary.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("ternary.leo");
let mut program = parse_program(program_string).unwrap();
// true -> field a
let main_input = generate_main_input(vec![
@ -379,7 +379,7 @@ fn test_ternary() {
assert_satisfied(program);
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
// false -> field b
let main_input = generate_main_input(vec![

View File

@ -34,8 +34,8 @@ pub fn set_local_dir() {
fn test_basic() {
set_local_dir();
let bytes = include_str!("basic.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("basic.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
@ -45,8 +45,8 @@ fn test_basic() {
fn test_multiple() {
set_local_dir();
let bytes = include_str!("multiple.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("multiple.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
@ -56,8 +56,8 @@ fn test_multiple() {
fn test_star() {
set_local_dir();
let bytes = include_str!("star.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("star.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
@ -67,8 +67,8 @@ fn test_star() {
fn test_star_fail() {
set_local_dir();
let bytes = include_str!("star_fail.leo");
assert!(parse_program(bytes).is_err());
let program_string = include_str!("star_fail.leo");
assert!(parse_program(program_string).is_err());
}
#[test]
@ -76,8 +76,8 @@ fn test_star_fail() {
fn test_alias() {
set_local_dir();
let bytes = include_str!("alias.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("alias.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
@ -88,8 +88,8 @@ fn test_alias() {
fn test_names_pass() {
set_local_dir();
let bytes = include_str!("names.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("names.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
@ -99,8 +99,8 @@ fn test_names_pass() {
fn test_names_fail_1() {
set_local_dir();
let bytes = include_str!("names_dash_a.leo");
assert!(parse_program(bytes).is_err());
let program_string = include_str!("names_dash_a.leo");
assert!(parse_program(program_string).is_err());
}
#[test]
@ -108,8 +108,8 @@ fn test_names_fail_1() {
fn test_names_fail_2() {
set_local_dir();
let bytes = include_str!("names_a_dash.leo");
assert!(parse_program(bytes).is_err());
let program_string = include_str!("names_a_dash.leo");
assert!(parse_program(program_string).is_err());
}
#[test]
@ -117,8 +117,8 @@ fn test_names_fail_2() {
fn test_names_fail_3() {
set_local_dir();
let bytes = include_str!("names_underscore.leo");
assert!(parse_program(bytes).is_err());
let program_string = include_str!("names_underscore.leo");
assert!(parse_program(program_string).is_err());
}
#[test]
@ -126,8 +126,8 @@ fn test_names_fail_3() {
fn test_names_fail_4() {
set_local_dir();
let bytes = include_str!("names_dollar.leo");
assert!(parse_program(bytes).is_err());
let program_string = include_str!("names_dollar.leo");
assert!(parse_program(program_string).is_err());
}
// more complex tests
@ -136,8 +136,8 @@ fn test_names_fail_4() {
fn test_many_import() {
set_local_dir();
let bytes = include_str!("many_import.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("many_import.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
@ -147,8 +147,8 @@ fn test_many_import() {
fn test_many_import_star() {
set_local_dir();
let bytes = include_str!("many_import_star.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("many_import_star.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}

View File

@ -26,10 +26,10 @@ fn expect_fail(program: EdwardsTestCompiler) {
#[test]
fn test_input_pass() {
let program_bytes = include_str!("main.leo");
let input_bytes = include_str!("input/main.in");
let program_string = include_str!("main.leo");
let input_string = include_str!("input/main.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);
}

View File

@ -42,10 +42,10 @@ fn test_access_state() {
#[test]
fn test_access_all() {
let program_bytes = include_str!("access_all.leo");
let state_bytes = include_str!("input/token_withdraw.state");
let program_string = include_str!("access_all.leo");
let state_string = include_str!("input/token_withdraw.state");
let program = parse_program_with_state(program_bytes, state_bytes).unwrap();
let program = parse_program_with_state(program_string, state_string).unwrap();
assert_satisfied(program);
}

View File

@ -28,8 +28,8 @@ macro_rules! test_int {
None => continue,
};
let bytes = include_str!("negate.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("negate.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
("b", Some(InputValue::Integer($integer_type, b.to_string()))),
@ -42,15 +42,15 @@ macro_rules! test_int {
}
fn test_negate_min_fail() {
let bytes = include_str!("negate_min.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("negate_min.leo");
let program = parse_program(program_string).unwrap();
expect_computation_error(program);
}
fn test_negate_zero() {
let bytes = include_str!("negate_zero.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("negate_zero.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
@ -58,29 +58,29 @@ macro_rules! test_int {
impl IntegerTester for $name {
fn test_min() {
let bytes = include_str!("min.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("min.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
fn test_min_fail() {
let bytes = include_str!("min_fail.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("min_fail.leo");
let program = parse_program(program_string).unwrap();
expect_parsing_error(program);
}
fn test_max() {
let bytes = include_str!("max.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("max.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
fn test_max_fail() {
let bytes = include_str!("max_fail.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("max_fail.leo");
let program = parse_program(program_string).unwrap();
expect_parsing_error(program);
}
@ -95,8 +95,8 @@ macro_rules! test_int {
None => continue,
};
let bytes = include_str!("add.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("add.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -124,8 +124,8 @@ macro_rules! test_int {
None => continue,
};
let bytes = include_str!("sub.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("sub.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -149,8 +149,8 @@ macro_rules! test_int {
None => continue,
};
let bytes = include_str!("mul.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("mul.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -176,8 +176,8 @@ macro_rules! test_int {
continue;
}
let bytes = include_str!("div.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("div.leo");
let mut program = parse_program(program_string).unwrap();
// expect an error when dividing by zero
if b == 0 {
@ -220,8 +220,8 @@ macro_rules! test_int {
None => continue,
};
let bytes = include_str!("pow.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("pow.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -242,8 +242,8 @@ macro_rules! test_int {
// test equal
let bytes = include_str!("eq.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("eq.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -259,7 +259,7 @@ macro_rules! test_int {
let c = a.eq(&b);
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -280,8 +280,8 @@ macro_rules! test_int {
// test a != a == false
let bytes = include_str!("ne.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("ne.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -297,7 +297,7 @@ macro_rules! test_int {
let c = a.ne(&b);
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -318,8 +318,8 @@ macro_rules! test_int {
// test equal
let bytes = include_str!("ge.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("ge.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -335,7 +335,7 @@ macro_rules! test_int {
let c = a.ge(&b);
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -356,8 +356,8 @@ macro_rules! test_int {
// test equal
let bytes = include_str!("gt.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("gt.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -373,7 +373,7 @@ macro_rules! test_int {
let c = a.gt(&b);
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -394,8 +394,8 @@ macro_rules! test_int {
// test equal
let bytes = include_str!("le.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("le.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -411,7 +411,7 @@ macro_rules! test_int {
let c = a.le(&b);
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -432,8 +432,8 @@ macro_rules! test_int {
// test equal
let bytes = include_str!("lt.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("lt.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -449,7 +449,7 @@ macro_rules! test_int {
let c = a.lt(&b);
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -468,8 +468,8 @@ macro_rules! test_int {
let a: $type_ = rand::random();
// test equal
let bytes = include_str!("console_assert.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("console_assert.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -487,7 +487,7 @@ macro_rules! test_int {
continue;
}
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -504,8 +504,8 @@ macro_rules! test_int {
let a: $type_ = rand::random();
let b: $type_ = rand::random();
let bytes = include_str!("ternary.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("ternary.leo");
let mut program = parse_program(program_string).unwrap();
// true -> field 1
let main_input = generate_main_input(vec![
@ -520,7 +520,7 @@ macro_rules! test_int {
assert_satisfied(program);
// false -> field 2
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("s", Some(InputValue::Boolean(false))),

View File

@ -20,29 +20,29 @@ macro_rules! test_uint {
impl IntegerTester for $name {
fn test_min() {
let bytes = include_str!("min.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("min.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
fn test_min_fail() {
let bytes = include_str!("min_fail.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("min_fail.leo");
let program = parse_program(program_string).unwrap();
expect_parsing_error(program);
}
fn test_max() {
let bytes = include_str!("max.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("max.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
fn test_max_fail() {
let bytes = include_str!("max_fail.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("max_fail.leo");
let program = parse_program(program_string).unwrap();
expect_parsing_error(program);
}
@ -57,8 +57,8 @@ macro_rules! test_uint {
None => continue,
};
let bytes = include_str!("add.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("add.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -82,8 +82,8 @@ macro_rules! test_uint {
None => continue,
};
let bytes = include_str!("sub.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("sub.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -107,8 +107,8 @@ macro_rules! test_uint {
None => continue,
};
let bytes = include_str!("mul.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("mul.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -132,8 +132,8 @@ macro_rules! test_uint {
None => continue,
};
let bytes = include_str!("div.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("div.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -158,8 +158,8 @@ macro_rules! test_uint {
None => continue,
};
let bytes = include_str!("pow.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("pow.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -180,8 +180,8 @@ macro_rules! test_uint {
// test equal
let bytes = include_str!("eq.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("eq.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -197,7 +197,7 @@ macro_rules! test_uint {
let c = a.eq(&b);
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -218,8 +218,8 @@ macro_rules! test_uint {
// test a != a == false
let bytes = include_str!("ne.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("ne.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -235,7 +235,7 @@ macro_rules! test_uint {
let c = a.ne(&b);
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -256,8 +256,8 @@ macro_rules! test_uint {
// test equal
let bytes = include_str!("ge.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("ge.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -273,7 +273,7 @@ macro_rules! test_uint {
let c = a.ge(&b);
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -294,8 +294,8 @@ macro_rules! test_uint {
// test equal
let bytes = include_str!("gt.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("gt.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -311,7 +311,7 @@ macro_rules! test_uint {
let c = a.gt(&b);
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -332,8 +332,8 @@ macro_rules! test_uint {
// test equal
let bytes = include_str!("le.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("le.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -349,7 +349,7 @@ macro_rules! test_uint {
let c = a.le(&b);
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -370,8 +370,8 @@ macro_rules! test_uint {
// test equal
let bytes = include_str!("lt.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("lt.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -387,7 +387,7 @@ macro_rules! test_uint {
let c = a.lt(&b);
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -406,8 +406,8 @@ macro_rules! test_uint {
let a: $type_ = rand::random();
// test equal
let bytes = include_str!("console_assert.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("console_assert.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -425,7 +425,7 @@ macro_rules! test_uint {
continue;
}
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
@ -442,8 +442,8 @@ macro_rules! test_uint {
let a: $type_ = rand::random();
let b: $type_ = rand::random();
let bytes = include_str!("ternary.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("ternary.leo");
let mut program = parse_program(program_string).unwrap();
// true -> field 1
let main_input = generate_main_input(vec![
@ -458,7 +458,7 @@ macro_rules! test_uint {
assert_satisfied(program);
// false -> field 2
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("s", Some(InputValue::Boolean(false))),

View File

@ -19,96 +19,96 @@ use leo_ast::InputValue;
#[test]
fn test_let() {
let bytes = include_str!("let.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("let.leo");
let program = parse_program(program_string).unwrap();
expect_compiler_error(program);
}
#[test]
fn test_let_mut() {
let bytes = include_str!("let_mut.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("let_mut.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_const_fail() {
let bytes = include_str!("const.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("const.leo");
let program = parse_program(program_string).unwrap();
expect_compiler_error(program);
}
#[test]
fn test_const_mut_fail() {
let bytes = include_str!("const_mut.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("const_mut.leo");
let program = parse_program(program_string).unwrap();
expect_compiler_error(program);
}
#[test]
fn test_array() {
let bytes = include_str!("array.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("array.leo");
let program = parse_program(program_string).unwrap();
expect_compiler_error(program);
}
#[test]
fn test_array_mut() {
let bytes = include_str!("array_mut.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("array_mut.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_circuit() {
let bytes = include_str!("circuit.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("circuit.leo");
let program = parse_program(program_string).unwrap();
expect_compiler_error(program);
}
#[test]
fn test_circuit_mut() {
let bytes = include_str!("circuit_mut.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("circuit_mut.leo");
let program = parse_program(program_string).unwrap();
expect_compiler_error(program);
}
#[test]
fn test_circuit_variable_mut() {
let bytes = include_str!("circuit_variable_mut.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("circuit_variable_mut.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_circuit_function_mut() {
let bytes = include_str!("circuit_function_mut.leo");
let error = parse_program(bytes).err().unwrap();
let program_string = include_str!("circuit_function_mut.leo");
let error = parse_program(program_string).err().unwrap();
expect_type_inference_error(error);
}
#[test]
fn test_circuit_static_function_mut() {
let bytes = include_str!("circuit_static_function_mut.leo");
let error = parse_program(bytes).err().unwrap();
let program_string = include_str!("circuit_static_function_mut.leo");
let error = parse_program(program_string).err().unwrap();
expect_type_inference_error(error);
}
#[test]
fn test_function_input() {
let bytes = include_str!("function_input.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("function_input.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]);
@ -119,8 +119,8 @@ fn test_function_input() {
#[test]
fn test_function_input_mut() {
let bytes = include_str!("function_input_mut.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("function_input_mut.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]);

View File

@ -28,8 +28,8 @@ use leo_ast::InputValue;
#[test]
fn test_assert() {
let bytes = include_str!("assert.leo");
let mut program_1_pass = parse_program(bytes).unwrap();
let program_string = include_str!("assert.leo");
let mut program_1_pass = parse_program(program_string).unwrap();
let mut program_0_pass = program_1_pass.clone();
let mut program_2_fail = program_1_pass.clone();
@ -60,8 +60,8 @@ fn test_assert() {
#[test]
fn test_mutate() {
let bytes = include_str!("mutate.leo");
let mut program_1_pass = parse_program(bytes).unwrap();
let program_string = include_str!("mutate.leo");
let mut program_1_pass = parse_program(program_string).unwrap();
let mut program_0_pass = program_1_pass.clone();
// Check that an input value of 1 satisfies the constraint system
@ -83,8 +83,8 @@ fn test_mutate() {
#[test]
fn test_for_loop() {
let bytes = include_str!("for_loop.leo");
let mut program_true_6 = parse_program(bytes).unwrap();
let program_string = include_str!("for_loop.leo");
let mut program_true_6 = parse_program(program_string).unwrap();
let mut program_false_0 = program_true_6.clone();
// Check that an input value of true satisfies the constraint system
@ -106,8 +106,8 @@ fn test_for_loop() {
#[test]
fn test_chain() {
let bytes = include_str!("chain.leo");
let mut program_1_1 = parse_program(bytes).unwrap();
let program_string = include_str!("chain.leo");
let mut program_1_1 = parse_program(program_string).unwrap();
let mut program_2_2 = program_1_1.clone();
let mut program_4_3 = program_1_1.clone();
@ -147,8 +147,8 @@ fn test_chain() {
#[test]
fn test_nested() {
let bytes = include_str!("nested.leo");
let mut program_true_true_3 = parse_program(bytes).unwrap();
let program_string = include_str!("nested.leo");
let mut program_true_true_3 = parse_program(program_string).unwrap();
let mut program_true_false_1 = program_true_true_3.clone();
let mut program_false_false_0 = program_true_true_3.clone();

View File

@ -23,8 +23,8 @@ pub mod conditional;
#[test]
fn test_ternary_basic() {
let bytes = include_str!("ternary_basic.leo");
let mut program = parse_program(bytes).unwrap();
let program_string = include_str!("ternary_basic.leo");
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Boolean(true))),
@ -35,7 +35,7 @@ fn test_ternary_basic() {
assert_satisfied(program);
let mut program = parse_program(bytes).unwrap();
let mut program = parse_program(program_string).unwrap();
let main_input = generate_main_input(vec![
("a", Some(InputValue::Boolean(false))),
@ -51,16 +51,16 @@ fn test_ternary_basic() {
#[test]
fn test_iteration_basic() {
let bytes = include_str!("iteration_basic.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("iteration_basic.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_num_returns_fail() {
let bytes = include_str!("num_returns_fail.leo");
let error = parse_program(bytes).err().unwrap();
let program_string = include_str!("num_returns_fail.leo");
let error = parse_program(program_string).err().unwrap();
expect_type_inference_error(error);
}

View File

@ -18,80 +18,80 @@ use crate::parse_program;
#[test]
fn test_address_name_fail() {
let bytes = include_str!("address_fail.leo");
let syntax_error = parse_program(bytes).is_err();
let program_string = include_str!("address_fail.leo");
let syntax_error = parse_program(program_string).is_err();
assert!(syntax_error);
}
#[test]
fn test_console_name_fail() {
let bytes = include_str!("console_fail.leo");
let syntax_error = parse_program(bytes).is_err();
let program_string = include_str!("console_fail.leo");
let syntax_error = parse_program(program_string).is_err();
assert!(syntax_error);
}
#[test]
fn test_field_name_fail() {
let bytes = include_str!("field_fail.leo");
let syntax_error = parse_program(bytes).is_err();
let program_string = include_str!("field_fail.leo");
let syntax_error = parse_program(program_string).is_err();
assert!(syntax_error);
}
#[test]
fn test_group_name_fail() {
let bytes = include_str!("group_fail.leo");
let syntax_error = parse_program(bytes).is_err();
let program_string = include_str!("group_fail.leo");
let syntax_error = parse_program(program_string).is_err();
assert!(syntax_error);
}
#[test]
fn test_i8_name_fail() {
let bytes = include_str!("i8_fail.leo");
let syntax_error = parse_program(bytes).is_err();
let program_string = include_str!("i8_fail.leo");
let syntax_error = parse_program(program_string).is_err();
assert!(syntax_error);
}
#[test]
fn test_input_name_fail() {
let bytes = include_str!("input_fail.leo");
let syntax_error = parse_program(bytes).is_err();
let program_string = include_str!("input_fail.leo");
let syntax_error = parse_program(program_string).is_err();
assert!(syntax_error);
}
#[test]
fn test_self_type_name_fail() {
let bytes = include_str!("self_type_fail.leo");
let syntax_error = parse_program(bytes).is_err();
let program_string = include_str!("self_type_fail.leo");
let syntax_error = parse_program(program_string).is_err();
assert!(syntax_error);
}
#[test]
fn test_self_keyword_name_fail() {
let bytes = include_str!("self_keyword_fail.leo");
let syntax_error = parse_program(bytes).is_err();
let program_string = include_str!("self_keyword_fail.leo");
let syntax_error = parse_program(program_string).is_err();
assert!(syntax_error);
}
#[test]
fn test_true_name_fail() {
let bytes = include_str!("true_fail.leo");
let syntax_error = parse_program(bytes).is_err();
let program_string = include_str!("true_fail.leo");
let syntax_error = parse_program(program_string).is_err();
assert!(syntax_error);
}
#[test]
fn test_u8_name_fail() {
let bytes = include_str!("u8_fail.leo");
let syntax_error = parse_program(bytes).is_err();
let program_string = include_str!("u8_fail.leo");
let syntax_error = parse_program(program_string).is_err();
assert!(syntax_error);
}

View File

@ -25,8 +25,8 @@ pub mod identifiers;
#[test]
#[ignore]
fn test_semicolon() {
let bytes = include_str!("semicolon.leo");
let error = parse_program(bytes).err().unwrap();
let program_string = include_str!("semicolon.leo");
let error = parse_program(program_string).err().unwrap();
match error {
CompilerError::ParserError(ParserError::SyntaxError(_)) => {}
@ -36,8 +36,8 @@ fn test_semicolon() {
#[test]
fn test_undefined() {
let bytes = include_str!("undefined.leo");
let program = parse_program(bytes).unwrap();
let program_string = include_str!("undefined.leo");
let program = parse_program(program_string).unwrap();
let error = expect_compiler_error(program);
@ -76,8 +76,8 @@ fn input_syntax_error() {
#[test]
fn test_compare_mismatched_types() {
let bytes = include_str!("compare_mismatched_types.leo");
let error = parse_program(bytes).err().unwrap();
let program_string = include_str!("compare_mismatched_types.leo");
let error = parse_program(program_string).err().unwrap();
// Expect a type inference error.
match error {

View File

@ -18,105 +18,105 @@ use crate::{assert_satisfied, parse_program};
#[test]
fn test_tuple_basic() {
let program_bytes = include_str!("basic.leo");
let program_string = include_str!("basic.leo");
let program = parse_program(program_bytes).unwrap();
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_tuple_access() {
let program_bytes = include_str!("access.leo");
let program_string = include_str!("access.leo");
let program = parse_program(program_bytes).unwrap();
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_tuple_typed() {
let program_bytes = include_str!("typed.leo");
let program_string = include_str!("typed.leo");
let program = parse_program(program_bytes).unwrap();
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_multiple() {
let program_bytes = include_str!("multiple.leo");
let program_string = include_str!("multiple.leo");
let program = parse_program(program_bytes).unwrap();
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_multiple_typed() {
let program_bytes = include_str!("multiple_typed.leo");
let program_string = include_str!("multiple_typed.leo");
let program = parse_program(program_bytes).unwrap();
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_function() {
let program_bytes = include_str!("function.leo");
let program_string = include_str!("function.leo");
let program = parse_program(program_bytes).unwrap();
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_function_typed() {
let program_bytes = include_str!("function_typed.leo");
let program_string = include_str!("function_typed.leo");
let program = parse_program(program_bytes).unwrap();
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_function_multiple() {
let progam_bytes = include_str!("function_multiple.leo");
let progam_string = include_str!("function_multiple.leo");
let program = parse_program(progam_bytes).unwrap();
let program = parse_program(progam_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_nested() {
let program_bytes = include_str!("nested.leo");
let program_string = include_str!("nested.leo");
let program = parse_program(program_bytes).unwrap();
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_nested_access() {
let program_bytes = include_str!("nested_access.leo");
let program_string = include_str!("nested_access.leo");
let program = parse_program(program_bytes).unwrap();
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
#[test]
fn test_nested_typed() {
let program_bytes = include_str!("nested_typed.leo");
let program_string = include_str!("nested_typed.leo");
let program = parse_program(program_bytes).unwrap();
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
}
// #[test]
// fn test_input() {
// let input_bytes = include_str!("inputs/input.in");
// let program_bytes = include_str!("")
// let input_string = include_str!("inputs/input.in");
// let program_string = include_str!("")
// }