mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-09-19 01:37:34 +03:00
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:
parent
daa23b7311
commit
ad86b23c01
@ -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())),
|
||||
}
|
||||
|
14
examples/silly-sudoku/inputs/test-input.in
Normal file
14
examples/silly-sudoku/inputs/test-input.in
Normal 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;
|
Loading…
Reference in New Issue
Block a user