diff --git a/compiler/tests/array/mod.rs b/compiler/tests/array/mod.rs index 1ba20c9676..62a18bd541 100644 --- a/compiler/tests/array/mod.rs +++ b/compiler/tests/array/mod.rs @@ -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] diff --git a/compiler/tests/array/type_nested.leo b/compiler/tests/array/type_nested.leo deleted file mode 100644 index e8ee3785b7..0000000000 --- a/compiler/tests/array/type_nested.leo +++ /dev/null @@ -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); -} \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_nested_3x2.leo b/compiler/tests/array/type_nested_value_nested_3x2.leo new file mode 100644 index 0000000000..bcf5bae674 --- /dev/null +++ b/compiler/tests/array/type_nested_value_nested_3x2.leo @@ -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); +} \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_nested_3x2_fail.leo b/compiler/tests/array/type_nested_value_nested_3x2_fail.leo new file mode 100644 index 0000000000..56c8916fb0 --- /dev/null +++ b/compiler/tests/array/type_nested_value_nested_3x2_fail.leo @@ -0,0 +1,3 @@ +function main() { + const b: [[u8; 2]; 3] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) +} \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_nested_4x3x2.leo b/compiler/tests/array/type_nested_value_nested_4x3x2.leo new file mode 100644 index 0000000000..1691fa26c7 --- /dev/null +++ b/compiler/tests/array/type_nested_value_nested_4x3x2.leo @@ -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); +} \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_nested_4x3x2_fail.leo b/compiler/tests/array/type_nested_value_nested_4x3x2_fail.leo new file mode 100644 index 0000000000..480327a91d --- /dev/null +++ b/compiler/tests/array/type_nested_value_nested_4x3x2_fail.leo @@ -0,0 +1,3 @@ +function main() { + const b: [[[u8; 2]; 3]; 4] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) +} \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_tuple_3x2.leo b/compiler/tests/array/type_nested_value_tuple_3x2.leo new file mode 100644 index 0000000000..5f14084d55 --- /dev/null +++ b/compiler/tests/array/type_nested_value_tuple_3x2.leo @@ -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); +} \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_tuple_3x2_fail.leo b/compiler/tests/array/type_nested_value_tuple_3x2_fail.leo new file mode 100644 index 0000000000..3bfb559615 --- /dev/null +++ b/compiler/tests/array/type_nested_value_tuple_3x2_fail.leo @@ -0,0 +1,3 @@ +function main() { + const b: [[u8; 2]; 3] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) +} \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_tuple_4x3x2.leo b/compiler/tests/array/type_nested_value_tuple_4x3x2.leo new file mode 100644 index 0000000000..88a5143bd2 --- /dev/null +++ b/compiler/tests/array/type_nested_value_tuple_4x3x2.leo @@ -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); +} \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_tuple_4x3x2_fail.leo b/compiler/tests/array/type_nested_value_tuple_4x3x2_fail.leo new file mode 100644 index 0000000000..ce1219a37b --- /dev/null +++ b/compiler/tests/array/type_nested_value_tuple_4x3x2_fail.leo @@ -0,0 +1,3 @@ +function main() { + const b: [[[u8; 2]; 3]; 4] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering) +} \ No newline at end of file diff --git a/compiler/tests/array/type_tuple.leo b/compiler/tests/array/type_tuple.leo deleted file mode 100644 index 0e2daa201f..0000000000 --- a/compiler/tests/array/type_tuple.leo +++ /dev/null @@ -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); -} \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_nested_3x2.leo b/compiler/tests/array/type_tuple_value_nested_3x2.leo new file mode 100644 index 0000000000..0b960c6b44 --- /dev/null +++ b/compiler/tests/array/type_tuple_value_nested_3x2.leo @@ -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); +} \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_nested_3x2_fail.leo b/compiler/tests/array/type_tuple_value_nested_3x2_fail.leo new file mode 100644 index 0000000000..e84f025a9f --- /dev/null +++ b/compiler/tests/array/type_tuple_value_nested_3x2_fail.leo @@ -0,0 +1,3 @@ +function main() { + const b: [u8; (2, 3)] = [[0; 2]; 3]; // initializer (incorrectly reversed ordering) +} \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_nested_4x3x2.leo b/compiler/tests/array/type_tuple_value_nested_4x3x2.leo new file mode 100644 index 0000000000..322a6f7601 --- /dev/null +++ b/compiler/tests/array/type_tuple_value_nested_4x3x2.leo @@ -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); +} \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_nested_4x3x2_fail.leo b/compiler/tests/array/type_tuple_value_nested_4x3x2_fail.leo new file mode 100644 index 0000000000..cbb7ccbf76 --- /dev/null +++ b/compiler/tests/array/type_tuple_value_nested_4x3x2_fail.leo @@ -0,0 +1,3 @@ +function main() { + const b: [u8; (4, 3, 2)] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) +} \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_tuple_3x2.leo b/compiler/tests/array/type_tuple_value_tuple_3x2.leo new file mode 100644 index 0000000000..d742a544a7 --- /dev/null +++ b/compiler/tests/array/type_tuple_value_tuple_3x2.leo @@ -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); +} \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_tuple_3x2_fail.leo b/compiler/tests/array/type_tuple_value_tuple_3x2_fail.leo new file mode 100644 index 0000000000..884a75db9d --- /dev/null +++ b/compiler/tests/array/type_tuple_value_tuple_3x2_fail.leo @@ -0,0 +1,3 @@ +function main() { + const b: [u8; (2, 3)] = [0; (3, 2)]; // initializer (incorrectly reversed ordering) +} \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_tuple_4x3x2.leo b/compiler/tests/array/type_tuple_value_tuple_4x3x2.leo new file mode 100644 index 0000000000..1205b1dc9c --- /dev/null +++ b/compiler/tests/array/type_tuple_value_tuple_4x3x2.leo @@ -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); +} \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_tuple_4x3x2_fail.leo b/compiler/tests/array/type_tuple_value_tuple_4x3x2_fail.leo new file mode 100644 index 0000000000..31e2a5e552 --- /dev/null +++ b/compiler/tests/array/type_tuple_value_tuple_4x3x2_fail.leo @@ -0,0 +1,3 @@ +function main() { + const b: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed order) +} \ No newline at end of file