aboutsummaryrefslogtreecommitdiff
path: root/test/cases/array.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-04-30 20:35:54 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-04-30 20:35:54 -0400
commita35b366eb64272c6d4646aedc035a837ed0c3cb0 (patch)
treedcde18b655e59df2b24f6804eb069f3f43393b28 /test/cases/array.zig
parent76ab1d2b6c9eedd861920ae6b6f8ee06aa482159 (diff)
downloadzig-a35b366eb64272c6d4646aedc035a837ed0c3cb0.tar.gz
zig-a35b366eb64272c6d4646aedc035a837ed0c3cb0.zip
[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
Diffstat (limited to 'test/cases/array.zig')
-rw-r--r--test/cases/array.zig41
1 files changed, 31 insertions, 10 deletions
diff --git a/test/cases/array.zig b/test/cases/array.zig
index 577161dd16..0fb61b2a9f 100644
--- a/test/cases/array.zig
+++ b/test/cases/array.zig
@@ -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);
}