From e7091b18ed345ea8719565d3523269135d220cf3 Mon Sep 17 00:00:00 2001 From: collin Date: Wed, 2 Sep 2020 11:12:12 -0700 Subject: [PATCH] fix tests --- compiler/tests/array/initializer.leo | 2 +- compiler/tests/array/initializer_fail.leo | 2 +- compiler/tests/array/inline.leo | 2 +- compiler/tests/array/input/registers_ones.in | 2 +- compiler/tests/array/input/registers_zeros.in | 2 +- compiler/tests/array/input/six_zeros.in | 2 +- compiler/tests/array/input/three_ones.in | 2 +- compiler/tests/array/multi.leo | 2 +- compiler/tests/array/output/registers_ones.out | 2 +- compiler/tests/array/output/registers_zeros.out | 2 +- compiler/tests/array/registers.leo | 2 +- compiler/tests/array/slice.leo | 2 +- compiler/tests/array/spread.leo | 2 +- compiler/tests/array/type_fail.leo | 2 +- typed/src/types/type_.rs | 11 ++++++----- 15 files changed, 20 insertions(+), 19 deletions(-) diff --git a/compiler/tests/array/initializer.leo b/compiler/tests/array/initializer.leo index 49d5cb7e76..51ac19f68f 100644 --- a/compiler/tests/array/initializer.leo +++ b/compiler/tests/array/initializer.leo @@ -1,3 +1,3 @@ -function main(a: u8[3]) { +function main(a: [u8; 3]) { console.assert(a == [1u8; 3]); } \ No newline at end of file diff --git a/compiler/tests/array/initializer_fail.leo b/compiler/tests/array/initializer_fail.leo index 73809d3ac2..3b2e7785cc 100644 --- a/compiler/tests/array/initializer_fail.leo +++ b/compiler/tests/array/initializer_fail.leo @@ -1,3 +1,3 @@ -function main(a: u8[3]) { +function main(a: [u8; 3]) { console.assert(a == [1u8; -3]); } \ No newline at end of file diff --git a/compiler/tests/array/inline.leo b/compiler/tests/array/inline.leo index d21b59f302..8c5c98ae50 100644 --- a/compiler/tests/array/inline.leo +++ b/compiler/tests/array/inline.leo @@ -1,3 +1,3 @@ -function main(a: u8[3]) { +function main(a: [u8; 3]) { console.assert(a == [1u8, 1u8, 1u8]); } \ No newline at end of file diff --git a/compiler/tests/array/input/registers_ones.in b/compiler/tests/array/input/registers_ones.in index 47f8b756d1..fab79f69a0 100644 --- a/compiler/tests/array/input/registers_ones.in +++ b/compiler/tests/array/input/registers_ones.in @@ -1,2 +1,2 @@ [registers] -r: u8[3] = [1u8, 1u8, 1u8]; +r: [u8; 3] = [1u8, 1u8, 1u8]; diff --git a/compiler/tests/array/input/registers_zeros.in b/compiler/tests/array/input/registers_zeros.in index bda1f40229..e9aa65cf9b 100644 --- a/compiler/tests/array/input/registers_zeros.in +++ b/compiler/tests/array/input/registers_zeros.in @@ -1,2 +1,2 @@ [registers] -r: u8[3] = [0u8, 0u8, 0u8]; +r: [u8; 3] = [0u8, 0u8, 0u8]; diff --git a/compiler/tests/array/input/six_zeros.in b/compiler/tests/array/input/six_zeros.in index f91102b28f..b6f6bd4b65 100644 --- a/compiler/tests/array/input/six_zeros.in +++ b/compiler/tests/array/input/six_zeros.in @@ -1,2 +1,2 @@ [main] -a: u8[3][2] = [[0; 3]; 2]; \ No newline at end of file +a: [u8; (3, 2)] = [[0; 3]; 2]; \ No newline at end of file diff --git a/compiler/tests/array/input/three_ones.in b/compiler/tests/array/input/three_ones.in index 2f935102d9..80d095f864 100644 --- a/compiler/tests/array/input/three_ones.in +++ b/compiler/tests/array/input/three_ones.in @@ -1,2 +1,2 @@ [main] -a: u8[3] = [1, 1, 1]; \ No newline at end of file +a: [u8; 3] = [1, 1, 1]; \ No newline at end of file diff --git a/compiler/tests/array/multi.leo b/compiler/tests/array/multi.leo index 37b145fa8f..8602c39465 100644 --- a/compiler/tests/array/multi.leo +++ b/compiler/tests/array/multi.leo @@ -2,7 +2,7 @@ function main() { const a = [[0u32, 0u32, 0u32], [0u32, 0u32, 0u32]]; // inline - const b: u32[3][2] = [[0; 3]; 2]; // initializer + const b: [u32; (3, 2)] = [[0; 3]; 2]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/output/registers_ones.out b/compiler/tests/array/output/registers_ones.out index 47f8b756d1..d7aaafed88 100644 --- a/compiler/tests/array/output/registers_ones.out +++ b/compiler/tests/array/output/registers_ones.out @@ -1,2 +1,2 @@ [registers] -r: u8[3] = [1u8, 1u8, 1u8]; +r: [u8; (3)] = [1u8, 1u8, 1u8]; diff --git a/compiler/tests/array/output/registers_zeros.out b/compiler/tests/array/output/registers_zeros.out index bda1f40229..d6278e3b69 100644 --- a/compiler/tests/array/output/registers_zeros.out +++ b/compiler/tests/array/output/registers_zeros.out @@ -1,2 +1,2 @@ [registers] -r: u8[3] = [0u8, 0u8, 0u8]; +r: [u8; (3)] = [0u8, 0u8, 0u8]; diff --git a/compiler/tests/array/registers.leo b/compiler/tests/array/registers.leo index a8da187d56..fb8980868e 100644 --- a/compiler/tests/array/registers.leo +++ b/compiler/tests/array/registers.leo @@ -1,3 +1,3 @@ -function main(input) -> u8[3] { +function main(input) -> [u8; 3] { return input.registers.r } \ No newline at end of file diff --git a/compiler/tests/array/slice.leo b/compiler/tests/array/slice.leo index f238c0aca8..296f5bd050 100644 --- a/compiler/tests/array/slice.leo +++ b/compiler/tests/array/slice.leo @@ -1,5 +1,5 @@ // `{from}..{to}` copies the elements of one array into another exclusively -function main(a: u8[3]) { +function main(a: [u8; 3]) { let b = [1u8; 4]; console.assert(a == b[0..3]); diff --git a/compiler/tests/array/spread.leo b/compiler/tests/array/spread.leo index 75f2b2be77..5370960c2d 100644 --- a/compiler/tests/array/spread.leo +++ b/compiler/tests/array/spread.leo @@ -1,5 +1,5 @@ // A spread operator `...` copies the elements of one array into another -function main(a: u8[3]) { +function main(a: [u8; 3]) { let b = [1u8, 1u8]; console.assert(a == [1u8, ...b]); diff --git a/compiler/tests/array/type_fail.leo b/compiler/tests/array/type_fail.leo index c21a6d7b13..0b8e467e33 100644 --- a/compiler/tests/array/type_fail.leo +++ b/compiler/tests/array/type_fail.leo @@ -1,3 +1,3 @@ let main() { - let a: u32[-2] = [0u32; 2]; + let a: [u8; -2] = [0u32; 2]; } \ No newline at end of file diff --git a/typed/src/types/type_.rs b/typed/src/types/type_.rs index e4e6581653..911ebb6153 100644 --- a/typed/src/types/type_.rs +++ b/typed/src/types/type_.rs @@ -207,11 +207,12 @@ impl fmt::Display for Type { Type::Circuit(ref variable) => write!(f, "circuit {}", variable), Type::SelfType => write!(f, "SelfType"), Type::Array(ref array, ref dimensions) => { - write!(f, "{}", *array)?; - for row in dimensions { - write!(f, "[{}]", row)?; - } - write!(f, "") + let dimensions = dimensions + .iter() + .map(|x| format!("{}", x)) + .collect::>() + .join(", "); + write!(f, "[{}; ({})]", *array, dimensions) } Type::Tuple(ref tuple) => { let types = tuple.iter().map(|x| format!("{}", x)).collect::>().join(", ");