fix all tests

This commit is contained in:
collin 2020-07-31 20:59:50 -07:00
parent fb45ac7498
commit 070fa0edea
66 changed files with 270 additions and 276 deletions

View File

@ -67,7 +67,7 @@ impl FunctionError {
}
pub fn arguments_length(expected: usize, actual: usize, span: Span) -> Self {
let message = format!("function expected {} inputs, found {} inputs", expected, actual);
let message = format!("function expected {} input variables, found {}", expected, actual);
Self::new_from_span(message, span)
}

View File

@ -57,23 +57,23 @@ fn test_ternary() {
let bytes = include_bytes!("ternary.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("s", Some(InputValue::Boolean(true))),
("c", Some(InputValue::Address(TEST_ADDRESS_1.to_string()))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("s", Some(InputValue::Boolean(false))),
("c", Some(InputValue::Address(TEST_ADDRESS_2.to_string()))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -83,25 +83,25 @@ fn test_equal() {
let bytes = include_bytes!("equal.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Address(TEST_ADDRESS_1.to_string()))),
("b", Some(InputValue::Address(TEST_ADDRESS_1.to_string()))),
("c", Some(InputValue::Boolean(true))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Address(TEST_ADDRESS_1.to_string()))),
("b", Some(InputValue::Address(TEST_ADDRESS_2.to_string()))),
("c", Some(InputValue::Boolean(false))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}

View File

@ -26,8 +26,8 @@ pub fn output_zeros(program: EdwardsTestCompiler) {
#[test]
fn test_registers() {
let program_bytes = include_bytes!("registers.leo");
let ones_input_bytes = include_bytes!("inputs/registers_ones.in");
let zeros_input_bytes = include_bytes!("inputs/registers_zeros.in");
let ones_input_bytes = include_bytes!("input/registers_ones.in");
let zeros_input_bytes = include_bytes!("input/registers_zeros.in");
// test ones input register => ones output register
let program = parse_program_with_input(program_bytes, ones_input_bytes).unwrap();
@ -45,7 +45,7 @@ fn test_registers() {
#[test]
fn test_inline() {
let program_bytes = include_bytes!("inline.leo");
let input_bytes = include_bytes!("inputs/three_ones.in");
let input_bytes = include_bytes!("input/three_ones.in");
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
assert_satisfied(program);
@ -62,7 +62,7 @@ fn test_inline_fail() {
#[test]
fn test_initializer() {
let program_bytes = include_bytes!("initializer.leo");
let input_bytes = include_bytes!("inputs/three_ones.in");
let input_bytes = include_bytes!("input/three_ones.in");
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
assert_satisfied(program);
@ -71,7 +71,7 @@ fn test_initializer() {
#[test]
fn test_spread() {
let program_bytes = include_bytes!("spread.leo");
let input_bytes = include_bytes!("inputs/three_ones.in");
let input_bytes = include_bytes!("input/three_ones.in");
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
assert_satisfied(program);
@ -80,7 +80,7 @@ fn test_spread() {
#[test]
fn test_slice() {
let program_bytes = include_bytes!("slice.leo");
let input_bytes = include_bytes!("inputs/three_ones.in");
let input_bytes = include_bytes!("input/three_ones.in");
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
assert_satisfied(program);

View File

@ -1,3 +1,3 @@
function main(registers) -> u8[3] {
return registers.r
function main(input) -> u8[3] {
return input.registers.r
}

View File

@ -35,7 +35,7 @@ fn fail_boolean_statement(program: EdwardsTestCompiler) {
#[test]
fn test_input_pass() {
let program_bytes = include_bytes!("assert_eq_input.leo");
let input_bytes = include_bytes!("inputs/true_true.in");
let input_bytes = include_bytes!("input/true_true.in");
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
@ -45,7 +45,7 @@ fn test_input_pass() {
#[test]
fn test_input_fail() {
let program_bytes = include_bytes!("assert_eq_input.leo");
let input_bytes = include_bytes!("inputs/true_false.in");
let input_bytes = include_bytes!("input/true_false.in");
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
@ -55,8 +55,8 @@ fn test_input_fail() {
#[test]
fn test_registers() {
let program_bytes = include_bytes!("output_register.leo");
let true_input_bytes = include_bytes!("inputs/registers_true.in");
let false_input_bytes = include_bytes!("inputs/registers_false.in");
let true_input_bytes = include_bytes!("input/registers_true.in");
let false_input_bytes = include_bytes!("input/registers_false.in");
// test true input register => true output register
let program = parse_program_with_input(program_bytes, true_input_bytes).unwrap();

View File

@ -1,3 +1,3 @@
function main(registers) -> bool {
return registers.r
function main(input) -> bool {
return input.registers.r
}

View File

@ -41,13 +41,13 @@ fn test_add() {
let bytes = include_bytes!("add.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Field(a_string))),
("b", Some(InputValue::Field(b_string))),
("c", Some(InputValue::Field(c_string))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program)
}
@ -71,12 +71,12 @@ fn test_sub() {
let bytes = include_bytes!("sub.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Field(a_string))),
("b", Some(InputValue::Field(b_string))),
("c", Some(InputValue::Field(c_string))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program)
}
@ -100,12 +100,12 @@ fn test_div() {
let bytes = include_bytes!("div.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Field(a_string))),
("b", Some(InputValue::Field(b_string))),
("c", Some(InputValue::Field(c_string))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program)
}
@ -129,13 +129,13 @@ fn test_mul() {
let bytes = include_bytes!("mul.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Field(a_string))),
("b", Some(InputValue::Field(b_string))),
("c", Some(InputValue::Field(c_string))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program)
}
@ -157,13 +157,13 @@ fn test_eq() {
let bytes = include_bytes!("eq.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Field(a_string.clone()))),
("b", Some(InputValue::Field(a_string.clone()))),
("c", Some(InputValue::Boolean(true))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
@ -173,13 +173,13 @@ fn test_eq() {
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Field(a_string))),
("b", Some(InputValue::Field(b_string))),
("c", Some(InputValue::Boolean(c))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -197,12 +197,12 @@ fn test_assert_eq_pass() {
let bytes = include_bytes!("assert_eq.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Field(a_string.clone()))),
("b", Some(InputValue::Field(a_string))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -226,12 +226,12 @@ fn test_assert_eq_fail() {
let bytes = include_bytes!("assert_eq.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Field(a_string))),
("b", Some(InputValue::Field(b_string))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
expect_synthesis_error(program);
}
@ -251,28 +251,28 @@ fn test_ternary() {
let mut program = parse_program(bytes).unwrap();
// true -> field a
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("s", Some(InputValue::Boolean(true))),
("a", Some(InputValue::Field(a_string.clone()))),
("b", Some(InputValue::Field(b_string.clone()))),
("c", Some(InputValue::Field(a_string.clone()))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
let mut program = parse_program(bytes).unwrap();
// false -> field b
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("s", Some(InputValue::Boolean(false))),
("a", Some(InputValue::Field(a_string))),
("b", Some(InputValue::Field(b_string.clone()))),
("c", Some(InputValue::Field(b_string))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -295,16 +295,16 @@ fn test_ternary() {
// #[test]
// fn test_registers() {
// let program_bytes = include_bytes!("output_register.leo");
// let one_input_bytes = include_bytes!("inputs/register_one.in");
// let zero_input_bytes = include_bytes!("inputs/register_zero.in");
// let one_input_bytes = include_bytes!("input/register_one.in");
// let zero_input_bytes = include_bytes!("input/register_zero.in");
//
// // test 1field input register => 1field output register
// let program = parse_program_with_inputs(program_bytes, one_input_bytes).unwrap();
// let program = parse_program_with_input(program_bytes, one_input_bytes).unwrap();
//
// output_one(program);
//
// // test 0field input register => 0field output register
// let program = parse_program_with_inputs(program_bytes, zero_input_bytes).unwrap();
// let program = parse_program_with_input(program_bytes, zero_input_bytes).unwrap();
//
// output_zero(program);
// }

View File

@ -52,9 +52,9 @@ fn test_multiple_returns() {
#[test]
fn test_multiple_returns_main() {
let program_bytes = include_bytes!("multiple_main.leo");
let inputs_bytes = include_bytes!("inputs/registers.in");
let input_bytes = include_bytes!("input/registers.in");
let program = parse_program_with_input(program_bytes, inputs_bytes).unwrap();
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
let expected_bytes = include_bytes!("outputs_/registers.out");
let expected = std::str::from_utf8(expected_bytes).unwrap();

View File

@ -1,3 +1,3 @@
function main(registers) -> (bool, bool) {
return (registers.a, registers.b)
function main(input) -> (bool, bool) {
return (input.registers.a, input.registers.b)
}

View File

@ -1,4 +1,4 @@
// Functions inputs in leo are pass-by-value.
// Functions input in leo are pass-by-value.
//
// Program execution:
// line 15: variable `a` is defined with value `1`.

View File

@ -45,10 +45,10 @@ fn test_point() {
}
#[test]
fn test_inputs() {
fn test_input() {
let program_bytes = include_bytes!("input.leo");
let input_bytes_pass = include_bytes!("inputs/one_one.in");
let input_bytes_fail = include_bytes!("inputs/one_zero.in");
let input_bytes_pass = include_bytes!("input/one_one.in");
let input_bytes_fail = include_bytes!("input/one_zero.in");
let program = parse_program_with_input(program_bytes, input_bytes_pass).unwrap();
@ -77,12 +77,12 @@ fn test_add() {
let bytes = include_bytes!("add.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Group(a_string))),
("b", Some(InputValue::Group(b_string))),
("c", Some(InputValue::Group(c_string))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program)
}
@ -106,12 +106,12 @@ fn test_sub() {
let bytes = include_bytes!("sub.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Group(a_string))),
("b", Some(InputValue::Group(b_string))),
("c", Some(InputValue::Group(c_string))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program)
}
@ -129,12 +129,12 @@ fn test_assert_eq_pass() {
let bytes = include_bytes!("assert_eq.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Group(a_string.clone()))),
("b", Some(InputValue::Group(a_string))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -158,12 +158,12 @@ fn test_assert_eq_fail() {
let bytes = include_bytes!("assert_eq.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Group(a_string))),
("b", Some(InputValue::Group(b_string))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
expect_synthesis_error(program);
}
@ -185,13 +185,13 @@ fn test_eq() {
let bytes = include_bytes!("eq.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Group(a_string.clone()))),
("b", Some(InputValue::Group(a_string.clone()))),
("c", Some(InputValue::Boolean(true))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
@ -201,13 +201,13 @@ fn test_eq() {
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Group(a_string))),
("b", Some(InputValue::Group(b_string))),
("c", Some(InputValue::Boolean(c))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -227,28 +227,28 @@ fn test_ternary() {
let mut program = parse_program(bytes).unwrap();
// true -> field a
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("s", Some(InputValue::Boolean(true))),
("a", Some(InputValue::Group(a_string.clone()))),
("b", Some(InputValue::Group(b_string.clone()))),
("c", Some(InputValue::Group(a_string.clone()))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
let mut program = parse_program(bytes).unwrap();
// false -> field b
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("s", Some(InputValue::Boolean(false))),
("a", Some(InputValue::Group(a_string))),
("b", Some(InputValue::Group(b_string.clone()))),
("c", Some(InputValue::Group(b_string))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}

View File

@ -1,3 +1,3 @@
mod program_inputs;
mod program_inputs_and_state;
mod state;
mod program_input;
mod program_input_and_program_state;
mod program_state;

View File

@ -9,9 +9,9 @@ fn expect_fail(program: EdwardsTestCompiler) {
}
#[test]
fn test_inputs_pass() {
fn test_input_pass() {
let program_bytes = include_bytes!("main.leo");
let input_bytes = include_bytes!("inputs/main.in");
let input_bytes = include_bytes!("input/main.in");
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
@ -19,9 +19,9 @@ fn test_inputs_pass() {
}
#[test]
fn test_inputs_fail_name() {
fn test_input_fail_name() {
let program_bytes = include_bytes!("main.leo");
let input_bytes = include_bytes!("inputs/main_fail_name.in");
let input_bytes = include_bytes!("input/main_fail_name.in");
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
@ -29,9 +29,9 @@ fn test_inputs_fail_name() {
}
#[test]
fn test_inputs_fail_type() {
fn test_input_fail_type() {
let program_bytes = include_bytes!("main.leo");
let input_bytes = include_bytes!("inputs/main_fail_type.in");
let input_bytes = include_bytes!("input/main_fail_type.in");
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
@ -39,9 +39,9 @@ fn test_inputs_fail_type() {
}
#[test]
fn test_inputs_multiple() {
fn test_input_multiple() {
let program_bytes = include_bytes!("main_multiple.leo");
let input_bytes = include_bytes!("inputs/main_multiple.in");
let input_bytes = include_bytes!("input/main_multiple.in");
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();

View File

@ -0,0 +1,11 @@
function main(input, data: u8[32]) {
assert_eq!(input.registers.value_balance, 0u64);
assert_eq!(input.state.leaf_index, 0u32);
assert_eq!(input.record.value, 5u64);
assert_eq!(input.state_leaf.network_id, 0u8);
assert_eq!(data, [0u8; 32]);
}

View File

@ -0,0 +1,28 @@
use crate::{assert_satisfied, parse_input_and_state, parse_program_with_input_and_state};
#[test]
fn test_basic() {
let input_bytes = include_bytes!("input/basic.in");
let state_bytes = include_bytes!("input/basic.state");
parse_input_and_state(input_bytes, state_bytes).unwrap();
}
#[test]
fn test_full() {
let input_bytes = include_bytes!("input/token_withdraw.in");
let state_bytes = include_bytes!("input/token_withdraw.state");
parse_input_and_state(input_bytes, state_bytes).unwrap();
}
#[test]
fn test_access() {
let program_bytes = include_bytes!("access.leo");
let input_bytes = include_bytes!("input/token_withdraw.in");
let state_bytes = include_bytes!("input/token_withdraw.state");
let program = parse_program_with_input_and_state(program_bytes, input_bytes, state_bytes).unwrap();
assert_satisfied(program);
}

View File

@ -1,17 +0,0 @@
function main(
registers,
state,
record,
state_leaf,
data: u8[32]
) {
assert_eq!(registers.value_balance, 0u64);
assert_eq!(state.leaf_index, 0u32);
assert_eq!(record.value, 5u64);
assert_eq!(state_leaf.network_id, 0u8);
assert_eq!(data, [0u8; 32]);
}

View File

@ -1,28 +0,0 @@
use crate::{assert_satisfied, parse_input_and_state, parse_program_with_input_and_state};
#[test]
fn test_basic() {
let inputs_bytes = include_bytes!("inputs/basic.in");
let state_bytes = include_bytes!("inputs/basic.state");
parse_input_and_state(inputs_bytes, state_bytes).unwrap();
}
#[test]
fn test_full() {
let inputs_bytes = include_bytes!("inputs/token_withdraw.in");
let state_bytes = include_bytes!("inputs/token_withdraw.state");
parse_input_and_state(inputs_bytes, state_bytes).unwrap();
}
#[test]
fn test_access() {
let program_bytes = include_bytes!("access.leo");
let inputs_bytes = include_bytes!("inputs/token_withdraw.in");
let state_bytes = include_bytes!("inputs/token_withdraw.state");
let program = parse_program_with_input_and_state(program_bytes, inputs_bytes, state_bytes).unwrap();
assert_satisfied(program);
}

View File

@ -0,0 +1,8 @@
function main(input) {
assert_eq!(input.state.root, [0u8; 32]);
let expected: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
assert_eq!(input.record.owner, expected);
assert_eq!(input.state_leaf.network_id, 0u8);
}

View File

@ -0,0 +1,3 @@
function main(input) {
assert_eq!(input.state.root, [0u8; 32]);
}

View File

@ -2,14 +2,14 @@ use crate::{assert_satisfied, parse_program_with_state, parse_state};
#[test]
fn test_basic() {
let bytes = include_bytes!("inputs/basic.state");
let bytes = include_bytes!("input/basic.state");
parse_state(bytes).unwrap();
}
#[test]
fn test_token_withdraw() {
let bytes = include_bytes!("inputs/token_withdraw.state");
let bytes = include_bytes!("input/token_withdraw.state");
parse_state(bytes).unwrap();
}
@ -17,7 +17,7 @@ fn test_token_withdraw() {
#[test]
fn test_access_state() {
let program_bytes = include_bytes!("access_state.leo");
let state_bytes = include_bytes!("inputs/token_withdraw.state");
let state_bytes = include_bytes!("input/token_withdraw.state");
let program = parse_program_with_state(program_bytes, state_bytes).unwrap();
@ -27,7 +27,7 @@ fn test_access_state() {
#[test]
fn test_access_all() {
let program_bytes = include_bytes!("access_all.leo");
let state_bytes = include_bytes!("inputs/token_withdraw.state");
let state_bytes = include_bytes!("input/token_withdraw.state");
let program = parse_program_with_state(program_bytes, state_bytes).unwrap();
@ -36,7 +36,7 @@ fn test_access_all() {
#[test]
fn test_visibility_fail() {
let state_bytes = include_bytes!("inputs/visibility_fail.state");
let state_bytes = include_bytes!("input/visibility_fail.state");
let is_err = parse_state(state_bytes).is_err();
@ -45,7 +45,7 @@ fn test_visibility_fail() {
#[test]
fn test_section_undefined() {
let state_bytes = include_bytes!("inputs/section_undefined.state");
let state_bytes = include_bytes!("input/section_undefined.state");
let is_err = parse_state(state_bytes).is_err();
@ -54,7 +54,7 @@ fn test_section_undefined() {
#[test]
fn test_section_invalid() {
let state_bytes = include_bytes!("inputs/section_invalid.state");
let state_bytes = include_bytes!("input/section_invalid.state");
let is_err = parse_state(state_bytes).is_err();

View File

@ -1,8 +0,0 @@
function main(state, record, state_leaf) {
assert_eq!(state.root, [0u8; 32]);
let expected: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
assert_eq!(record.owner, expected);
assert_eq!(state_leaf.network_id, 0u8);
}

View File

@ -1,3 +0,0 @@
function main(state) {
assert_eq!(state.root, [0u8; 32]);
}

View File

@ -44,13 +44,13 @@ macro_rules! test_int {
let bytes = include_bytes!("add.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
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()))),
("c", Some(InputValue::Integer($integer_type, c.to_string()))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -73,13 +73,13 @@ macro_rules! test_int {
let bytes = include_bytes!("sub.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
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()))),
("c", Some(InputValue::Integer($integer_type, c.to_string()))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -98,13 +98,13 @@ macro_rules! test_int {
let bytes = include_bytes!("mul.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
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()))),
("c", Some(InputValue::Integer($integer_type, c.to_string()))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -120,13 +120,13 @@ macro_rules! test_int {
// expect an error when dividing by zero
if b == 0 {
let main_inputs = generate_main_inputs(vec![
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()))),
("c", Some(InputValue::Integer($integer_type, b.to_string()))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
expect_computation_error(program);
} else {
@ -135,13 +135,13 @@ macro_rules! test_int {
None => continue,
};
let main_inputs = generate_main_inputs(vec![
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()))),
("c", Some(InputValue::Integer($integer_type, c.to_string()))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -162,13 +162,13 @@ macro_rules! test_int {
let bytes = include_bytes!("pow.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
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()))),
("c", Some(InputValue::Integer($integer_type, c.to_string()))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -184,13 +184,13 @@ macro_rules! test_int {
let bytes = include_bytes!("eq.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
("b", Some(InputValue::Integer($integer_type, a.to_string()))),
("c", Some(InputValue::Boolean(true))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
@ -200,13 +200,13 @@ macro_rules! test_int {
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
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()))),
("c", Some(InputValue::Boolean(c))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -222,13 +222,13 @@ macro_rules! test_int {
let bytes = include_bytes!("ge.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
("b", Some(InputValue::Integer($integer_type, a.to_string()))),
("c", Some(InputValue::Boolean(true))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
@ -238,13 +238,13 @@ macro_rules! test_int {
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
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()))),
("c", Some(InputValue::Boolean(c))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -260,13 +260,13 @@ macro_rules! test_int {
let bytes = include_bytes!("gt.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
("b", Some(InputValue::Integer($integer_type, a.to_string()))),
("c", Some(InputValue::Boolean(false))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
@ -276,13 +276,13 @@ macro_rules! test_int {
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
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()))),
("c", Some(InputValue::Boolean(c))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -298,13 +298,13 @@ macro_rules! test_int {
let bytes = include_bytes!("le.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
("b", Some(InputValue::Integer($integer_type, a.to_string()))),
("c", Some(InputValue::Boolean(true))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
@ -314,13 +314,13 @@ macro_rules! test_int {
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
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()))),
("c", Some(InputValue::Boolean(c))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -336,13 +336,13 @@ macro_rules! test_int {
let bytes = include_bytes!("lt.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
("b", Some(InputValue::Integer($integer_type, a.to_string()))),
("c", Some(InputValue::Boolean(false))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
@ -352,13 +352,13 @@ macro_rules! test_int {
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
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()))),
("c", Some(InputValue::Boolean(c))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -372,12 +372,12 @@ macro_rules! test_int {
let bytes = include_bytes!("assert_eq.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
("b", Some(InputValue::Integer($integer_type, a.to_string()))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
@ -390,12 +390,12 @@ macro_rules! test_int {
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
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()))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
expect_synthesis_error(program);
}
@ -409,28 +409,28 @@ macro_rules! test_int {
let mut program = parse_program(bytes).unwrap();
// true -> field 1
let main_inputs = generate_main_inputs(vec![
let main_input = generate_main_input(vec![
("s", Some(InputValue::Boolean(true))),
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
("b", Some(InputValue::Integer($integer_type, b.to_string()))),
("c", Some(InputValue::Integer($integer_type, a.to_string()))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
// false -> field 2
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
let main_input = generate_main_input(vec![
("s", Some(InputValue::Boolean(false))),
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
("b", Some(InputValue::Integer($integer_type, b.to_string()))),
("c", Some(InputValue::Integer($integer_type, b.to_string()))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}

View File

@ -44,13 +44,13 @@ macro_rules! test_uint {
let bytes = include_bytes!("add.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
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()))),
("c", Some(InputValue::Integer($integer_type, c.to_string()))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -69,13 +69,13 @@ macro_rules! test_uint {
let bytes = include_bytes!("sub.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
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()))),
("c", Some(InputValue::Integer($integer_type, c.to_string()))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -94,13 +94,13 @@ macro_rules! test_uint {
let bytes = include_bytes!("mul.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
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()))),
("c", Some(InputValue::Integer($integer_type, c.to_string()))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -119,13 +119,13 @@ macro_rules! test_uint {
let bytes = include_bytes!("div.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
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()))),
("c", Some(InputValue::Integer($integer_type, c.to_string()))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -145,13 +145,13 @@ macro_rules! test_uint {
let bytes = include_bytes!("pow.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
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()))),
("c", Some(InputValue::Integer($integer_type, c.to_string()))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -167,13 +167,13 @@ macro_rules! test_uint {
let bytes = include_bytes!("eq.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
("b", Some(InputValue::Integer($integer_type, a.to_string()))),
("c", Some(InputValue::Boolean(true))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
@ -183,13 +183,13 @@ macro_rules! test_uint {
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
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()))),
("c", Some(InputValue::Boolean(c))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -205,13 +205,13 @@ macro_rules! test_uint {
let bytes = include_bytes!("ge.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
("b", Some(InputValue::Integer($integer_type, a.to_string()))),
("c", Some(InputValue::Boolean(true))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
@ -221,13 +221,13 @@ macro_rules! test_uint {
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
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()))),
("c", Some(InputValue::Boolean(c))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -243,13 +243,13 @@ macro_rules! test_uint {
let bytes = include_bytes!("gt.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
("b", Some(InputValue::Integer($integer_type, a.to_string()))),
("c", Some(InputValue::Boolean(false))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
@ -259,13 +259,13 @@ macro_rules! test_uint {
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
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()))),
("c", Some(InputValue::Boolean(c))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -281,13 +281,13 @@ macro_rules! test_uint {
let bytes = include_bytes!("le.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
("b", Some(InputValue::Integer($integer_type, a.to_string()))),
("c", Some(InputValue::Boolean(true))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
@ -297,13 +297,13 @@ macro_rules! test_uint {
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
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()))),
("c", Some(InputValue::Boolean(c))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -319,13 +319,13 @@ macro_rules! test_uint {
let bytes = include_bytes!("lt.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
("b", Some(InputValue::Integer($integer_type, a.to_string()))),
("c", Some(InputValue::Boolean(false))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
@ -335,13 +335,13 @@ macro_rules! test_uint {
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
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()))),
("c", Some(InputValue::Boolean(c))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -355,12 +355,12 @@ macro_rules! test_uint {
let bytes = include_bytes!("assert_eq.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
("b", Some(InputValue::Integer($integer_type, a.to_string()))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
@ -373,12 +373,12 @@ macro_rules! test_uint {
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
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()))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
expect_synthesis_error(program);
}
@ -392,28 +392,28 @@ macro_rules! test_uint {
let mut program = parse_program(bytes).unwrap();
// true -> field 1
let main_inputs = generate_main_inputs(vec![
let main_input = generate_main_input(vec![
("s", Some(InputValue::Boolean(true))),
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
("b", Some(InputValue::Integer($integer_type, b.to_string()))),
("c", Some(InputValue::Integer($integer_type, a.to_string()))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
// false -> field 2
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_inputs(vec![
let main_input = generate_main_input(vec![
("s", Some(InputValue::Boolean(false))),
("a", Some(InputValue::Integer($integer_type, a.to_string()))),
("b", Some(InputValue::Integer($integer_type, b.to_string()))),
("c", Some(InputValue::Integer($integer_type, b.to_string()))),
]);
program.set_main_inputs(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}

View File

@ -61,9 +61,9 @@ fn test_print_input() {
let bytes = include_bytes!("print_input.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]);
let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}

View File

@ -53,9 +53,9 @@ pub(crate) fn parse_program(bytes: &[u8]) -> Result<EdwardsTestCompiler, Compile
pub(crate) fn parse_input(bytes: &[u8]) -> Result<EdwardsTestCompiler, CompilerError> {
let mut compiler = new_compiler();
let inputs_string = String::from_utf8_lossy(bytes);
let input_string = String::from_utf8_lossy(bytes);
compiler.parse_input(&inputs_string, EMPTY_FILE)?;
compiler.parse_input(&input_string, EMPTY_FILE)?;
Ok(compiler)
}
@ -89,9 +89,9 @@ pub fn parse_program_with_input(
let mut compiler = new_compiler();
let program_string = String::from_utf8_lossy(program_bytes);
let inputs_string = String::from_utf8_lossy(input_bytes);
let input_string = String::from_utf8_lossy(input_bytes);
compiler.parse_input(&inputs_string, EMPTY_FILE)?;
compiler.parse_input(&input_string, EMPTY_FILE)?;
compiler.parse_program(&program_string)?;
Ok(compiler)

View File

@ -1,4 +1,4 @@
// Function inputs are immutable by default.
// Function input are immutable by default.
function main(a: bool) {
a = false;
}

View File

@ -70,9 +70,9 @@ fn test_function_input() {
let bytes = include_bytes!("function_input.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]);
let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
expect_compiler_error(program);
}
@ -82,9 +82,9 @@ fn test_function_input_mut() {
let bytes = include_bytes!("function_input_mut.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]);
let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}

View File

@ -19,34 +19,34 @@ fn test_assert() {
// Check that an input value of 1 satisfies the constraint system
let main_inputs = generate_main_input(vec![(
let main_input = generate_main_input(vec![(
"a",
Some(InputValue::Integer(IntegerType::U32Type(U32Type {}), 1.to_string())),
)]);
program_1_pass.set_main_input(main_inputs);
program_1_pass.set_main_input(main_input);
assert_satisfied(program_1_pass);
// Check that an input value of 0 satisfies the constraint system
let main_inputs = generate_main_input(vec![(
let main_input = generate_main_input(vec![(
"a",
Some(InputValue::Integer(IntegerType::U32Type(U32Type {}), 0.to_string())),
)]);
program_0_pass.set_main_input(main_inputs);
program_0_pass.set_main_input(main_input);
assert_satisfied(program_0_pass);
// Check that an input value of 2 does not satisfy the constraint system
let main_inputs = generate_main_input(vec![(
let main_input = generate_main_input(vec![(
"a",
Some(InputValue::Integer(IntegerType::U32Type(U32Type {}), 2.to_string())),
)]);
program_2_fail.set_main_input(main_inputs);
program_2_fail.set_main_input(main_input);
expect_synthesis_error(program_2_fail);
}
@ -59,23 +59,23 @@ fn test_mutate() {
// Check that an input value of 1 satisfies the constraint system
let main_inputs = generate_main_input(vec![(
let main_input = generate_main_input(vec![(
"a",
Some(InputValue::Integer(IntegerType::U32Type(U32Type {}), 1.to_string())),
)]);
program_1_pass.set_main_input(main_inputs);
program_1_pass.set_main_input(main_input);
assert_satisfied(program_1_pass);
// Check that an input value of 0 satisfies the constraint system
let main_inputs = generate_main_input(vec![(
let main_input = generate_main_input(vec![(
"a",
Some(InputValue::Integer(IntegerType::U32Type(U32Type {}), 0.to_string())),
)]);
program_0_pass.set_main_input(main_inputs);
program_0_pass.set_main_input(main_input);
assert_satisfied(program_0_pass);
}
@ -88,17 +88,17 @@ fn test_for_loop() {
// Check that an input value of true satisfies the constraint system
let main_inputs = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]);
let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]);
program_true_6.set_main_input(main_inputs);
program_true_6.set_main_input(main_input);
assert_satisfied(program_true_6);
// Check that an input value of false satisfies the constraint system
let main_inputs = generate_main_input(vec![("a", Some(InputValue::Boolean(false)))]);
let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(false)))]);
program_false_0.set_main_input(main_inputs);
program_false_0.set_main_input(main_input);
assert_satisfied(program_false_0);
}
@ -112,7 +112,7 @@ fn test_chain() {
// Check that an input of 1 outputs 1
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
(
"a",
Some(InputValue::Integer(IntegerType::U32Type(U32Type {}), 1.to_string())),
@ -123,13 +123,13 @@ fn test_chain() {
),
]);
program_1_1.set_main_input(main_inputs);
program_1_1.set_main_input(main_input);
assert_satisfied(program_1_1);
// Check that an input of 2 outputs 2
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
(
"a",
Some(InputValue::Integer(IntegerType::U32Type(U32Type {}), 2.to_string())),
@ -140,13 +140,13 @@ fn test_chain() {
),
]);
program_2_2.set_main_input(main_inputs);
program_2_2.set_main_input(main_input);
assert_satisfied(program_2_2);
// Check that an input of 4 outputs 3
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
(
"a",
Some(InputValue::Integer(IntegerType::U32Type(U32Type {}), 4.to_string())),
@ -157,7 +157,7 @@ fn test_chain() {
),
]);
program_4_3.set_main_input(main_inputs);
program_4_3.set_main_input(main_input);
assert_satisfied(program_4_3);
}
@ -171,7 +171,7 @@ fn test_nested() {
// Check that an input value of true true outputs 3
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Boolean(true))),
("b", Some(InputValue::Boolean(true))),
(
@ -180,13 +180,13 @@ fn test_nested() {
),
]);
program_true_true_3.set_main_input(main_inputs);
program_true_true_3.set_main_input(main_input);
assert_satisfied(program_true_true_3);
// Check that an input value of true false outputs 1
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Boolean(true))),
("b", Some(InputValue::Boolean(false))),
(
@ -195,13 +195,13 @@ fn test_nested() {
),
]);
program_true_false_1.set_main_input(main_inputs);
program_true_false_1.set_main_input(main_input);
assert_satisfied(program_true_false_1);
// Check that an input value of false false outputs 0
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Boolean(false))),
("b", Some(InputValue::Boolean(false))),
(
@ -210,7 +210,7 @@ fn test_nested() {
),
]);
program_false_false_0.set_main_input(main_inputs);
program_false_false_0.set_main_input(main_input);
assert_satisfied(program_false_false_0);
}
@ -235,14 +235,14 @@ fn test_multiple_returns() {
// Check that an input value of 1 writes 1 to the output registers
let registers_one_bytes = include_bytes!("inputs/registers_one.in");
let registers_one_bytes = include_bytes!("input/registers_one.in");
let program = parse_program_with_input(program_bytes, registers_one_bytes).unwrap();
output_one(program);
// Check that an input value of 0 writes 0 to the output registers
let registers_zero_bytes = include_bytes!("inputs/registers_zero.in");
let registers_zero_bytes = include_bytes!("input/registers_zero.in");
let program = parse_program_with_input(program_bytes, registers_zero_bytes).unwrap();
output_zero(program);

View File

@ -1,5 +1,5 @@
function main(registers) -> u32 {
if registers.a == 0 {
function main(input) -> u32 {
if input.registers.a == 0 {
return 0u32
} else {
return 1u32

View File

@ -10,23 +10,23 @@ fn test_ternary_basic() {
let bytes = include_bytes!("ternary_basic.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Boolean(true))),
("b", Some(InputValue::Boolean(true))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![
let main_input = generate_main_input(vec![
("a", Some(InputValue::Boolean(false))),
("b", Some(InputValue::Boolean(false))),
]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
}
@ -48,17 +48,17 @@ fn test_assertion_basic() {
let bytes = include_bytes!("assertion_basic.leo");
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]);
let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
assert_satisfied(program);
let mut program = parse_program(bytes).unwrap();
let main_inputs = generate_main_input(vec![("a", Some(InputValue::Boolean(false)))]);
let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(false)))]);
program.set_main_input(main_inputs);
program.set_main_input(main_input);
expect_synthesis_error(program);
}

View File

@ -44,11 +44,11 @@ fn test_undefined() {
#[test]
fn input_syntax_error() {
let bytes = include_bytes!("inputs_semicolon.leo");
let bytes = include_bytes!("input_semicolon.leo");
let error = parse_input(bytes).err().unwrap();
match error {
CompilerError::InputParserError(InputParserError::SyntaxError(_)) => {}
_ => panic!("inputs syntax error should be a ParserError"),
_ => panic!("input syntax error should be a ParserError"),
}
}

View File

@ -1,4 +1,4 @@
// The program inputs for square_root/src/main.leo
// The program input for square_root/src/main.leo
[main]
a: field = 337;
b: field = 113569;

View File

@ -15,7 +15,7 @@ impl CLI for RunCommand {
type Options = ();
type Output = ();
const ABOUT: AboutType = "Run a program with inputs";
const ABOUT: AboutType = "Run a program with input variables";
const ARGUMENTS: &'static [ArgumentType] = &[];
const FLAGS: &'static [FlagType] = &[];
const NAME: NameType = "run";