[breaking] delete ptr deref prefix op

start using zig-fmt-pointer-reform branch build of zig fmt
to fix code to use the new syntax

all of test/cases/* are processed, but there are more left
to be done - all the std lib used by the behavior tests
This commit is contained in:
Andrew Kelley
2018-04-30 20:35:54 -04:00
parent 76ab1d2b6c
commit a35b366eb6
49 changed files with 1694 additions and 880 deletions

View File

@@ -2,9 +2,9 @@ const assert = @import("std").debug.assert;
const mem = @import("std").mem;
test "arrays" {
var array : [5]u32 = undefined;
var array: [5]u32 = undefined;
var i : u32 = 0;
var i: u32 = 0;
while (i < 5) {
array[i] = i + 1;
i = array[i];
@@ -34,24 +34,41 @@ test "void arrays" {
}
test "array literal" {
const hex_mult = []u16{4096, 256, 16, 1};
const hex_mult = []u16 {
4096,
256,
16,
1,
};
assert(hex_mult.len == 4);
assert(hex_mult[1] == 256);
}
test "array dot len const expr" {
assert(comptime x: {break :x some_array.len == 4;});
assert(comptime x: {
break :x some_array.len == 4;
});
}
const ArrayDotLenConstExpr = struct {
y: [some_array.len]u8,
};
const some_array = []u8 {0, 1, 2, 3};
const some_array = []u8 {
0,
1,
2,
3,
};
test "nested arrays" {
const array_of_strings = [][]const u8 {"hello", "this", "is", "my", "thing"};
const array_of_strings = [][]const u8 {
"hello",
"this",
"is",
"my",
"thing",
};
for (array_of_strings) |s, i| {
if (i == 0) assert(mem.eql(u8, s, "hello"));
if (i == 1) assert(mem.eql(u8, s, "this"));
@@ -61,7 +78,6 @@ test "nested arrays" {
}
}
var s_array: [8]Sub = undefined;
const Sub = struct {
b: u8,
@@ -70,7 +86,9 @@ const Str = struct {
a: []Sub,
};
test "set global var array via slice embedded in struct" {
var s = Str { .a = s_array[0..]};
var s = Str {
.a = s_array[0..],
};
s.a[0].b = 1;
s.a[1].b = 2;
@@ -82,7 +100,10 @@ test "set global var array via slice embedded in struct" {
}
test "array literal with specified size" {
var array = [2]u8{1, 2};
var array = [2]u8 {
1,
2,
};
assert(array[0] == 1);
assert(array[1] == 2);
}