fix tests

This commit is contained in:
collin 2020-09-02 11:12:12 -07:00
parent 77e2d55765
commit e7091b18ed
15 changed files with 20 additions and 19 deletions

View File

@ -1,3 +1,3 @@
function main(a: u8[3]) {
function main(a: [u8; 3]) {
console.assert(a == [1u8; 3]);
}

View File

@ -1,3 +1,3 @@
function main(a: u8[3]) {
function main(a: [u8; 3]) {
console.assert(a == [1u8; -3]);
}

View File

@ -1,3 +1,3 @@
function main(a: u8[3]) {
function main(a: [u8; 3]) {
console.assert(a == [1u8, 1u8, 1u8]);
}

View File

@ -1,2 +1,2 @@
[registers]
r: u8[3] = [1u8, 1u8, 1u8];
r: [u8; 3] = [1u8, 1u8, 1u8];

View File

@ -1,2 +1,2 @@
[registers]
r: u8[3] = [0u8, 0u8, 0u8];
r: [u8; 3] = [0u8, 0u8, 0u8];

View File

@ -1,2 +1,2 @@
[main]
a: u8[3][2] = [[0; 3]; 2];
a: [u8; (3, 2)] = [[0; 3]; 2];

View File

@ -1,2 +1,2 @@
[main]
a: u8[3] = [1, 1, 1];
a: [u8; 3] = [1, 1, 1];

View File

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

View File

@ -1,2 +1,2 @@
[registers]
r: u8[3] = [1u8, 1u8, 1u8];
r: [u8; (3)] = [1u8, 1u8, 1u8];

View File

@ -1,2 +1,2 @@
[registers]
r: u8[3] = [0u8, 0u8, 0u8];
r: [u8; (3)] = [0u8, 0u8, 0u8];

View File

@ -1,3 +1,3 @@
function main(input) -> u8[3] {
function main(input) -> [u8; 3] {
return input.registers.r
}

View File

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

View File

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

View File

@ -1,3 +1,3 @@
let main() {
let a: u32[-2] = [0u32; 2];
let a: [u8; -2] = [0u32; 2];
}

View File

@ -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::<Vec<_>>()
.join(", ");
write!(f, "[{}; ({})]", *array, dimensions)
}
Type::Tuple(ref tuple) => {
let types = tuple.iter().map(|x| format!("{}", x)).collect::<Vec<_>>().join(", ");