mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-25 03:04:13 +03:00
add tests for input array initializer
This commit is contained in:
parent
91350a2ffe
commit
bd3b465a4f
3
compiler/tests/array/initializer_input.leo
Normal file
3
compiler/tests/array/initializer_input.leo
Normal file
@ -0,0 +1,3 @@
|
||||
function main(a: [u8; (3, 2)]) {
|
||||
console.assert(a == [0u8; (3, 2)]);
|
||||
}
|
2
compiler/tests/array/input/initializer_fail.in
Normal file
2
compiler/tests/array/input/initializer_fail.in
Normal file
@ -0,0 +1,2 @@
|
||||
[main]
|
||||
a: [u8; (3, 2)] = [0; (2, 2)];
|
@ -1,2 +1,2 @@
|
||||
[main]
|
||||
a: [u8; (3, 2)] = [[0; 3]; 2];
|
||||
a: [u8; (3, 2)] = [0; (3, 2)];
|
@ -18,6 +18,7 @@ use crate::{
|
||||
assert_satisfied,
|
||||
expect_compiler_error,
|
||||
get_output,
|
||||
integers::{expect_computation_error, expect_parsing_error},
|
||||
parse_program,
|
||||
parse_program_with_input,
|
||||
EdwardsTestCompiler,
|
||||
@ -101,6 +102,24 @@ fn test_initializer_fail() {
|
||||
assert!(syntax_error);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_initializer_input() {
|
||||
let program_bytes = include_bytes!("initializer_input.leo");
|
||||
let input_bytes = include_bytes!("input/six_zeros.in");
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_initializer_input_fail() {
|
||||
let program_bytes = include_bytes!("initializer_input.leo");
|
||||
let input_bytes = include_bytes!("input/initializer_fail.in");
|
||||
let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err();
|
||||
|
||||
assert!(syntax_error);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_spread() {
|
||||
let program_bytes = include_bytes!("spread.leo");
|
||||
|
@ -142,7 +142,7 @@ impl InputValue {
|
||||
array_type: ArrayType,
|
||||
initializer: ArrayInitializerExpression,
|
||||
) -> Result<Self, InputParserError> {
|
||||
let mut array_dimensions = TypedExpression::get_input_array_dimensions(array_type.dimensions.clone());
|
||||
let array_dimensions = TypedExpression::get_input_array_dimensions(array_type.dimensions.clone());
|
||||
let initializer_dimensions = TypedExpression::get_input_array_dimensions(initializer.dimensions.clone());
|
||||
|
||||
// Return an error if the array type does not equal the array expression
|
||||
|
Loading…
Reference in New Issue
Block a user