mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-24 07:48:04 +03:00
reverse iter for building array, add test case for it
This commit is contained in:
parent
1898cc6840
commit
e48b971789
@ -177,7 +177,7 @@ impl InputValue {
|
||||
let mut elements = vec![];
|
||||
|
||||
// Build the elements of the array using the `vec!` macro
|
||||
for (i, dimension) in initializer_dimensions.into_iter().enumerate() {
|
||||
for (i, dimension) in initializer_dimensions.into_iter().rev().enumerate() {
|
||||
if i == 0 {
|
||||
elements = vec![value.clone(); dimension];
|
||||
} else {
|
||||
|
@ -0,0 +1,2 @@
|
||||
[main]
|
||||
x: [i16; (2, 2, 3)] = [0i16; (2, 2, 3)];
|
@ -0,0 +1,6 @@
|
||||
function main(x: [i16; (2, 2, 3)]){
|
||||
console.log("x: {}", x);
|
||||
|
||||
let y: [i16; (2, 2, 3)] = [0i16; (2, 2, 3)];
|
||||
console.log("y: {}", y);
|
||||
}
|
@ -44,6 +44,16 @@ fn test_input_array_fail() {
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_multi_dimension_array() {
|
||||
let program_string = include_str!("main_multi_dimension_array.leo");
|
||||
let input_string = include_str!("input/main_multi_dimension_array.in");
|
||||
|
||||
let program = parse_program_with_input(program_string, input_string).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input_fail_name() {
|
||||
let program_string = include_str!("main.leo");
|
||||
|
Loading…
Reference in New Issue
Block a user