adds search for @test(custom) inputs path in kebab case

- in Leo test envs can only be snake_cased
- while we suggest naming inputs and folders in kebab-case
- this patch searches for both test_input and test-input options in inputs
This commit is contained in:
damirka 2021-04-21 15:27:10 +03:00
parent daa23b7311
commit ad86b23c01
2 changed files with 22 additions and 1 deletions

View File

@ -85,10 +85,17 @@ pub fn generate_test_constraints<'a, F: PrimeField, G: GroupType<F>>(
let input_pair = match input_file {
Some(file_id) => {
let file_name = file_id.clone();
let file_name_kebab = file_name.to_string().replace("_", "-");
// transform "test_name" into "test-name"
output_file_name = file_name.to_string();
match input.pairs.get(file_name.as_ref()) {
// searches for test_input (snake case) or for test-input (kebab case)
match input
.pairs
.get(&file_name_kebab)
.or_else(|| input.pairs.get(&file_name_kebab))
{
Some(pair) => pair.to_owned(),
None => return Err(CompilerError::InvalidTestContext(file_name.to_string())),
}

View File

@ -0,0 +1,14 @@
// The program input for tmp-test/src/main.leo
[main]
puzzle: [u8; (3, 3)] = [[1, 0, 5],
[0, 2, 0],
[7, 0, 0]];
answer: [u8; (3, 3)] = [[1, 4, 5],
[3, 2, 6],
[7, 8, 9]];
expected: bool = true;
[registers]
r: bool = false;