mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-28 01:01:53 +03:00
impl tests for nested and tuple array combinations in Leo programs
This commit is contained in:
parent
4932eb688e
commit
3ef023b87a
@ -240,21 +240,133 @@ fn test_type_fail() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_type_tuple() {
|
||||
let program_bytes = include_bytes!("type_tuple.leo");
|
||||
fn test_type_nested_value_nested_3x2() {
|
||||
let program_bytes = include_bytes!("type_nested_value_nested_3x2.leo");
|
||||
let program = parse_program(program_bytes).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_type_nested() {
|
||||
let program_bytes = include_bytes!("type_nested.leo");
|
||||
fn test_type_nested_value_nested_3x2_fail() {
|
||||
let program_bytes = include_bytes!("type_nested_value_nested_3x2_fail.leo");
|
||||
let program = parse_program(program_bytes).unwrap();
|
||||
|
||||
expect_compiler_error(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_type_nested_value_nested_4x3x2() {
|
||||
let program_bytes = include_bytes!("type_nested_value_nested_4x3x2.leo");
|
||||
let program = parse_program(program_bytes).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_type_nested_value_nested_4x3x2_fail() {
|
||||
let program_bytes = include_bytes!("type_nested_value_nested_4x3x2_fail.leo");
|
||||
let program = parse_program(program_bytes).unwrap();
|
||||
|
||||
expect_compiler_error(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_type_nested_value_tuple_3x2() {
|
||||
let program_bytes = include_bytes!("type_nested_value_tuple_3x2.leo");
|
||||
let program = parse_program(program_bytes).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_type_nested_value_tuple_3x2_fail() {
|
||||
let program_bytes = include_bytes!("type_nested_value_tuple_3x2_fail.leo");
|
||||
let program = parse_program(program_bytes).unwrap();
|
||||
|
||||
expect_compiler_error(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_type_nested_value_tuple_4x3x2() {
|
||||
let program_bytes = include_bytes!("type_nested_value_tuple_4x3x2.leo");
|
||||
let program = parse_program(program_bytes).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_type_nested_value_tuple_4x3x2_fail() {
|
||||
let program_bytes = include_bytes!("type_nested_value_tuple_4x3x2_fail.leo");
|
||||
let program = parse_program(program_bytes).unwrap();
|
||||
|
||||
expect_compiler_error(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_type_tuple_value_nested_3x2() {
|
||||
let program_bytes = include_bytes!("type_tuple_value_nested_3x2.leo");
|
||||
let program = parse_program(program_bytes).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_type_tuple_value_nested_3x2_fail() {
|
||||
let program_bytes = include_bytes!("type_tuple_value_nested_3x2_fail.leo");
|
||||
let program = parse_program(program_bytes).unwrap();
|
||||
|
||||
expect_compiler_error(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_type_tuple_value_nested_4x3x2() {
|
||||
let program_bytes = include_bytes!("type_tuple_value_nested_4x3x2.leo");
|
||||
let program = parse_program(program_bytes).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_type_tuple_value_nested_4x3x2_fail() {
|
||||
let program_bytes = include_bytes!("type_tuple_value_nested_4x3x2_fail.leo");
|
||||
let program = parse_program(program_bytes).unwrap();
|
||||
|
||||
expect_compiler_error(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_type_tuple_value_tuple_3x2() {
|
||||
let program_bytes = include_bytes!("type_tuple_value_tuple_3x2.leo");
|
||||
let program = parse_program(program_bytes).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_type_tuple_value_tuple_3x2_fail() {
|
||||
let program_bytes = include_bytes!("type_tuple_value_tuple_3x2_fail.leo");
|
||||
let program = parse_program(program_bytes).unwrap();
|
||||
|
||||
expect_compiler_error(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_type_tuple_value_tuple_4x3x2() {
|
||||
let program_bytes = include_bytes!("type_tuple_value_tuple_4x3x2.leo");
|
||||
let program = parse_program(program_bytes).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_type_tuple_value_tuple_4x3x2_fail() {
|
||||
let program_bytes = include_bytes!("type_tuple_value_tuple_4x3x2_fail.leo");
|
||||
let program = parse_program(program_bytes).unwrap();
|
||||
|
||||
expect_compiler_error(program);
|
||||
}
|
||||
|
||||
// Tests for nested multi-dimensional arrays as input to the program
|
||||
|
||||
#[test]
|
||||
|
@ -1,7 +0,0 @@
|
||||
function main() {
|
||||
let a: [[u8; 3]; 2] = [[0; 3]; 2];
|
||||
|
||||
let b: [[u8; 3]; 2] = [0; (2, 3)];
|
||||
|
||||
console.assert(a == b);
|
||||
}
|
7
compiler/tests/array/type_nested_value_nested_3x2.leo
Normal file
7
compiler/tests/array/type_nested_value_nested_3x2.leo
Normal file
@ -0,0 +1,7 @@
|
||||
function main() {
|
||||
const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline
|
||||
|
||||
const b: [[u8; 2]; 3] = [[0; 2]; 3]; // initializer
|
||||
|
||||
console.assert(a == b);
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
function main() {
|
||||
const b: [[u8; 2]; 3] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering)
|
||||
}
|
10
compiler/tests/array/type_nested_value_nested_4x3x2.leo
Normal file
10
compiler/tests/array/type_nested_value_nested_4x3x2.leo
Normal file
@ -0,0 +1,10 @@
|
||||
function main() {
|
||||
const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]],
|
||||
[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]],
|
||||
[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]],
|
||||
[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline
|
||||
|
||||
const b: [[[u8; 2]; 3]; 4] = [[[0; 2]; 3]; 4]; // initializer
|
||||
|
||||
console.assert(a == b);
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
function main() {
|
||||
const b: [[[u8; 2]; 3]; 4] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering)
|
||||
}
|
7
compiler/tests/array/type_nested_value_tuple_3x2.leo
Normal file
7
compiler/tests/array/type_nested_value_tuple_3x2.leo
Normal file
@ -0,0 +1,7 @@
|
||||
function main() {
|
||||
const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline
|
||||
|
||||
const b: [[u8; 2]; 3] = [0; (3, 2)]; // initializer
|
||||
|
||||
console.assert(a == b);
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
function main() {
|
||||
const b: [[u8; 2]; 3] = [0; (2, 3)]; // initializer (incorrectly reversed ordering)
|
||||
}
|
10
compiler/tests/array/type_nested_value_tuple_4x3x2.leo
Normal file
10
compiler/tests/array/type_nested_value_tuple_4x3x2.leo
Normal file
@ -0,0 +1,10 @@
|
||||
function main() {
|
||||
const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]],
|
||||
[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]],
|
||||
[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]],
|
||||
[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline
|
||||
|
||||
const b: [[[u8; 2]; 3]; 4] = [0; (4, 3, 2)]; // initializer
|
||||
|
||||
console.assert(a == b);
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
function main() {
|
||||
const b: [[[u8; 2]; 3]; 4] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering)
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
function main() {
|
||||
let a: [u8; (2, 3)] = [[0; 3]; 2];
|
||||
|
||||
let b: [u8; (2, 3)] = [0; (2, 3)];
|
||||
|
||||
console.assert(a == b);
|
||||
}
|
7
compiler/tests/array/type_tuple_value_nested_3x2.leo
Normal file
7
compiler/tests/array/type_tuple_value_nested_3x2.leo
Normal file
@ -0,0 +1,7 @@
|
||||
function main() {
|
||||
const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline
|
||||
|
||||
const b: [u8; (2, 3)] = [[0; 3]; 2]; // initializer
|
||||
|
||||
console.assert(a == b);
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
function main() {
|
||||
const b: [u8; (2, 3)] = [[0; 2]; 3]; // initializer (incorrectly reversed ordering)
|
||||
}
|
10
compiler/tests/array/type_tuple_value_nested_4x3x2.leo
Normal file
10
compiler/tests/array/type_tuple_value_nested_4x3x2.leo
Normal file
@ -0,0 +1,10 @@
|
||||
function main() {
|
||||
const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]],
|
||||
[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]],
|
||||
[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]],
|
||||
[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline
|
||||
|
||||
const b: [u8; (4, 3, 2)] = [[[0; 2]; 3]; 4]; // initializer
|
||||
|
||||
console.assert(a == b);
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
function main() {
|
||||
const b: [u8; (4, 3, 2)] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering)
|
||||
}
|
7
compiler/tests/array/type_tuple_value_tuple_3x2.leo
Normal file
7
compiler/tests/array/type_tuple_value_tuple_3x2.leo
Normal file
@ -0,0 +1,7 @@
|
||||
function main() {
|
||||
const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline
|
||||
|
||||
const b: [u8; (2, 3)] = [0; (2, 3)]; // initializer
|
||||
|
||||
console.assert(a == b);
|
||||
}
|
3
compiler/tests/array/type_tuple_value_tuple_3x2_fail.leo
Normal file
3
compiler/tests/array/type_tuple_value_tuple_3x2_fail.leo
Normal file
@ -0,0 +1,3 @@
|
||||
function main() {
|
||||
const b: [u8; (2, 3)] = [0; (3, 2)]; // initializer (incorrectly reversed ordering)
|
||||
}
|
10
compiler/tests/array/type_tuple_value_tuple_4x3x2.leo
Normal file
10
compiler/tests/array/type_tuple_value_tuple_4x3x2.leo
Normal file
@ -0,0 +1,10 @@
|
||||
function main() {
|
||||
const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]],
|
||||
[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]],
|
||||
[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]],
|
||||
[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline
|
||||
|
||||
const b: [u8; (4, 3, 2)] = [0; (4, 3, 2)]; // initializer
|
||||
|
||||
console.assert(a == b);
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
function main() {
|
||||
const b: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed order)
|
||||
}
|
Loading…
Reference in New Issue
Block a user