impl tests for nested and tuple array combinations in Leo programs

This commit is contained in:
collin 2020-09-03 13:56:45 -07:00
parent 4932eb688e
commit 3ef023b87a
19 changed files with 208 additions and 18 deletions

View File

@ -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]

View File

@ -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);
}

View 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);
}

View File

@ -0,0 +1,3 @@
function main() {
const b: [[u8; 2]; 3] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering)
}

View 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);
}

View File

@ -0,0 +1,3 @@
function main() {
const b: [[[u8; 2]; 3]; 4] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering)
}

View 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);
}

View File

@ -0,0 +1,3 @@
function main() {
const b: [[u8; 2]; 3] = [0; (2, 3)]; // initializer (incorrectly reversed ordering)
}

View 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);
}

View File

@ -0,0 +1,3 @@
function main() {
const b: [[[u8; 2]; 3]; 4] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering)
}

View File

@ -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);
}

View 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);
}

View File

@ -0,0 +1,3 @@
function main() {
const b: [u8; (2, 3)] = [[0; 2]; 3]; // initializer (incorrectly reversed ordering)
}

View 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);
}

View File

@ -0,0 +1,3 @@
function main() {
const b: [u8; (4, 3, 2)] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering)
}

View 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);
}

View File

@ -0,0 +1,3 @@
function main() {
const b: [u8; (2, 3)] = [0; (3, 2)]; // initializer (incorrectly reversed ordering)
}

View 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);
}

View File

@ -0,0 +1,3 @@
function main() {
const b: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed order)
}