authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-05-23 21:38:31-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-05-23 21:38:31-04:00
log68add5d8286e5c517143b16a457a86a6c23dbc64
tree1058b55e8f0b86ad523012c89975ded539fffac5
parent0065eb7c80c2bb68585e42b87131f374e1d3fcbc

clean up behavior test names


21 files changed, 89 insertions(+), 89 deletions(-)

test/cases/array.zig+5-5
...@@ -25,7 +25,7 @@ fn getArrayLen(a: []const u32) -> usize {...@@ -25,7 +25,7 @@ fn getArrayLen(a: []const u32) -> usize {
25 a.len25 a.len
26}26}
2727
28test "voidArrays" {28test "void arrays" {
29 var array: [4]void = undefined;29 var array: [4]void = undefined;
30 array[0] = void{};30 array[0] = void{};
31 array[1] = array[2];31 array[1] = array[2];
...@@ -33,14 +33,14 @@ test "voidArrays" {...@@ -33,14 +33,14 @@ test "voidArrays" {
33 assert(array.len == 4);33 assert(array.len == 4);
34}34}
3535
36test "arrayLiteral" {36test "array literal" {
37 const hex_mult = []u16{4096, 256, 16, 1};37 const hex_mult = []u16{4096, 256, 16, 1};
3838
39 assert(hex_mult.len == 4);39 assert(hex_mult.len == 4);
40 assert(hex_mult[1] == 256);40 assert(hex_mult[1] == 256);
41}41}
4242
43test "arrayDotLenConstExpr" {43test "array dot len const expr" {
44 assert(comptime {some_array.len == 4});44 assert(comptime {some_array.len == 4});
45}45}
4646
...@@ -50,7 +50,7 @@ const ArrayDotLenConstExpr = struct {...@@ -50,7 +50,7 @@ const ArrayDotLenConstExpr = struct {
50const some_array = []u8 {0, 1, 2, 3};50const some_array = []u8 {0, 1, 2, 3};
5151
5252
53test "nestedArrays" {53test "nested arrays" {
54 const array_of_strings = [][]const u8 {"hello", "this", "is", "my", "thing"};54 const array_of_strings = [][]const u8 {"hello", "this", "is", "my", "thing"};
55 for (array_of_strings) |s, i| {55 for (array_of_strings) |s, i| {
56 if (i == 0) assert(mem.eql(u8, s, "hello"));56 if (i == 0) assert(mem.eql(u8, s, "hello"));
...@@ -69,7 +69,7 @@ const Sub = struct {...@@ -69,7 +69,7 @@ const Sub = struct {
69const Str = struct {69const Str = struct {
70 a: []Sub,70 a: []Sub,
71};71};
72test "setGlobalVarArrayViaSliceEmbeddedInStruct" {72test "set global var array via slice embedded in struct" {
73 var s = Str { .a = s_array[0..]};73 var s = Str { .a = s_array[0..]};
7474
75 s.a[0].b = 1;75 s.a[0].b = 1;
test/cases/bool.zig+4-4
...@@ -1,11 +1,11 @@...@@ -1,11 +1,11 @@
1const assert = @import("std").debug.assert;1const assert = @import("std").debug.assert;
22
3test "boolLiterals" {3test "bool literals" {
4 assert(true);4 assert(true);
5 assert(!false);5 assert(!false);
6}6}
77
8test "castBoolToInt" {8test "cast bool to int" {
9 const t = true;9 const t = true;
10 const f = false;10 const f = false;
11 assert(i32(t) == i32(1));11 assert(i32(t) == i32(1));
...@@ -18,7 +18,7 @@ fn nonConstCastBoolToInt(t: bool, f: bool) {...@@ -18,7 +18,7 @@ fn nonConstCastBoolToInt(t: bool, f: bool) {
18 assert(i32(f) == i32(0));18 assert(i32(f) == i32(0));
19}19}
2020
21test "boolCmp" {21test "bool cmp" {
22 assert(testBoolCmp(true, false) == false);22 assert(testBoolCmp(true, false) == false);
23}23}
24fn testBoolCmp(a: bool, b: bool) -> bool {24fn testBoolCmp(a: bool, b: bool) -> bool {
...@@ -29,7 +29,7 @@ const global_f = false;...@@ -29,7 +29,7 @@ const global_f = false;
29const global_t = true;29const global_t = true;
30const not_global_f = !global_f;30const not_global_f = !global_f;
31const not_global_t = !global_t;31const not_global_t = !global_t;
32test "compileTimeBoolnot" {32test "compile time bool not" {
33 assert(not_global_f);33 assert(not_global_f);
34 assert(!not_global_t);34 assert(!not_global_t);
35}35}
test/cases/cast.zig+2-2
...@@ -8,12 +8,12 @@ test "int to ptr cast" {...@@ -8,12 +8,12 @@ test "int to ptr cast" {
8 assert(z == 13);8 assert(z == 13);
9}9}
1010
11test "numLitIntToPtrCast" {11test "integer literal to pointer cast" {
12 const vga_mem = @intToPtr(&u16, 0xB8000);12 const vga_mem = @intToPtr(&u16, 0xB8000);
13 assert(usize(vga_mem) == 0xB8000);13 assert(usize(vga_mem) == 0xB8000);
14}14}
1515
16test "pointerReinterpretConstFloatToInt" {16test "pointer reinterpret const float to int" {
17 const float: f64 = 5.99999999999994648725e-01;17 const float: f64 = 5.99999999999994648725e-01;
18 const float_ptr = &float;18 const float_ptr = &float;
19 const int_ptr = @ptrCast(&i32, float_ptr);19 const int_ptr = @ptrCast(&i32, float_ptr);
test/cases/const_slice_child.zig+1-1
...@@ -3,7 +3,7 @@ const assert = debug.assert;...@@ -3,7 +3,7 @@ const assert = debug.assert;
33
4var argv: &const &const u8 = undefined;4var argv: &const &const u8 = undefined;
55
6test "constSliceChild" {6test "const slice child" {
7 const strs = ([]&const u8) {7 const strs = ([]&const u8) {
8 c"one",8 c"one",
9 c"two",9 c"two",
test/cases/enum.zig+6-6
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1const assert = @import("std").debug.assert;1const assert = @import("std").debug.assert;
2const mem = @import("std").mem;2const mem = @import("std").mem;
33
4test "enumType" {4test "enum type" {
5 const foo1 = Foo.One {13};5 const foo1 = Foo.One {13};
6 const foo2 = Foo.Two { Point { .x = 1234, .y = 5678, }};6 const foo2 = Foo.Two { Point { .x = 1234, .y = 5678, }};
7 const bar = Bar.B;7 const bar = Bar.B;
...@@ -14,7 +14,7 @@ test "enumType" {...@@ -14,7 +14,7 @@ test "enumType" {
14 assert(@sizeOf(Bar) == 1);14 assert(@sizeOf(Bar) == 1);
15}15}
1616
17test "enumAsReturnValue" {17test "enum as return value" {
18 switch (returnAnInt(13)) {18 switch (returnAnInt(13)) {
19 Foo.One => |value| assert(value == 13),19 Foo.One => |value| assert(value == 13),
20 else => unreachable,20 else => unreachable,
...@@ -42,7 +42,7 @@ fn returnAnInt(x: i32) -> Foo {...@@ -42,7 +42,7 @@ fn returnAnInt(x: i32) -> Foo {
42}42}
4343
4444
45test "constantEnumWithPayload" {45test "constant enum with payload" {
46 var empty = AnEnumWithPayload.Empty;46 var empty = AnEnumWithPayload.Empty;
47 var full = AnEnumWithPayload.Full {13};47 var full = AnEnumWithPayload.Full {13};
48 shouldBeEmpty(empty);48 shouldBeEmpty(empty);
...@@ -78,7 +78,7 @@ const Number = enum {...@@ -78,7 +78,7 @@ const Number = enum {
78 Four,78 Four,
79};79};
8080
81test "enumToInt" {81test "enum to int" {
82 shouldEqual(Number.Zero, 0);82 shouldEqual(Number.Zero, 0);
83 shouldEqual(Number.One, 1);83 shouldEqual(Number.One, 1);
84 shouldEqual(Number.Two, 2);84 shouldEqual(Number.Two, 2);
...@@ -91,7 +91,7 @@ fn shouldEqual(n: Number, expected: usize) {...@@ -91,7 +91,7 @@ fn shouldEqual(n: Number, expected: usize) {
91}91}
9292
9393
94test "intToEnum" {94test "int to enum" {
95 testIntToEnumEval(3);95 testIntToEnumEval(3);
96}96}
97fn testIntToEnumEval(x: i32) {97fn testIntToEnumEval(x: i32) {
...@@ -106,7 +106,7 @@ const IntToEnumNumber = enum {...@@ -106,7 +106,7 @@ const IntToEnumNumber = enum {
106};106};
107107
108108
109test "enumTagName builtin function" {109test "@enumTagName" {
110 assert(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three"));110 assert(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three"));
111 comptime assert(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three"));111 comptime assert(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three"));
112}112}
test/cases/enum_with_members.zig+1-1
...@@ -14,7 +14,7 @@ const ET = enum {...@@ -14,7 +14,7 @@ const ET = enum {
14 }14 }
15};15};
1616
17test "enumWithMembers" {17test "enum with members" {
18 const a = ET.SINT { -42 };18 const a = ET.SINT { -42 };
19 const b = ET.UINT { 42 };19 const b = ET.UINT { 42 };
20 var buf: [20]u8 = undefined;20 var buf: [20]u8 = undefined;
test/cases/error.zig+7-7
...@@ -15,7 +15,7 @@ pub fn baz() -> %i32 {...@@ -15,7 +15,7 @@ pub fn baz() -> %i32 {
15 return y + 1;15 return y + 1;
16}16}
1717
18test "errorWrapping" {18test "error wrapping" {
19 assert(%%baz() == 15);19 assert(%%baz() == 15);
20}20}
2121
...@@ -24,7 +24,7 @@ fn gimmeItBroke() -> []const u8 {...@@ -24,7 +24,7 @@ fn gimmeItBroke() -> []const u8 {
24 @errorName(error.ItBroke)24 @errorName(error.ItBroke)
25}25}
2626
27test "errorName" {27test "@errorName" {
28 assert(mem.eql(u8, @errorName(error.AnError), "AnError"));28 assert(mem.eql(u8, @errorName(error.AnError), "AnError"));
29 assert(mem.eql(u8, @errorName(error.ALongerErrorName), "ALongerErrorName"));29 assert(mem.eql(u8, @errorName(error.ALongerErrorName), "ALongerErrorName"));
30}30}
...@@ -32,7 +32,7 @@ error AnError;...@@ -32,7 +32,7 @@ error AnError;
32error ALongerErrorName;32error ALongerErrorName;
3333
3434
35test "errorValues" {35test "error values" {
36 const a = i32(error.err1);36 const a = i32(error.err1);
37 const b = i32(error.err2);37 const b = i32(error.err2);
38 assert(a != b);38 assert(a != b);
...@@ -41,7 +41,7 @@ error err1;...@@ -41,7 +41,7 @@ error err1;
41error err2;41error err2;
4242
4343
44test "redefinitionOfErrorValuesAllowed" {44test "redefinition of error values allowed" {
45 shouldBeNotEqual(error.AnError, error.SecondError);45 shouldBeNotEqual(error.AnError, error.SecondError);
46}46}
47error AnError;47error AnError;
...@@ -52,7 +52,7 @@ fn shouldBeNotEqual(a: error, b: error) {...@@ -52,7 +52,7 @@ fn shouldBeNotEqual(a: error, b: error) {
52}52}
5353
5454
55test "errBinaryOperator" {55test "error binary operator" {
56 const a = errBinaryOperatorG(true) %% 3;56 const a = errBinaryOperatorG(true) %% 3;
57 const b = errBinaryOperatorG(false) %% 3;57 const b = errBinaryOperatorG(false) %% 3;
58 assert(a == 3);58 assert(a == 3);
...@@ -68,14 +68,14 @@ fn errBinaryOperatorG(x: bool) -> %isize {...@@ -68,14 +68,14 @@ fn errBinaryOperatorG(x: bool) -> %isize {
68}68}
6969
7070
71test "unwrapSimpleValueFromError" {71test "unwrap simple value from error" {
72 const i = %%unwrapSimpleValueFromErrorDo();72 const i = %%unwrapSimpleValueFromErrorDo();
73 assert(i == 13);73 assert(i == 13);
74}74}
75fn unwrapSimpleValueFromErrorDo() -> %isize { 13 }75fn unwrapSimpleValueFromErrorDo() -> %isize { 13 }
7676
7777
78test "errReturnInAssignment" {78test "error return in assignment" {
79 %%doErrReturnInAssignment();79 %%doErrReturnInAssignment();
80}80}
8181
test/cases/eval.zig+18-18
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1const assert = @import("std").debug.assert;1const assert = @import("std").debug.assert;
2const builtin = @import("builtin");2const builtin = @import("builtin");
33
4test "compileTimeRecursion" {4test "compile time recursion" {
5 assert(some_data.len == 21);5 assert(some_data.len == 21);
6}6}
7var some_data: [usize(fibonacci(7))]u8 = undefined;7var some_data: [usize(fibonacci(7))]u8 = undefined;
...@@ -16,11 +16,11 @@ fn unwrapAndAddOne(blah: ?i32) -> i32 {...@@ -16,11 +16,11 @@ fn unwrapAndAddOne(blah: ?i32) -> i32 {
16 return ??blah + 1;16 return ??blah + 1;
17}17}
18const should_be_1235 = unwrapAndAddOne(1234);18const should_be_1235 = unwrapAndAddOne(1234);
19test "testStaticAddOne" {19test "static add one" {
20 assert(should_be_1235 == 1235);20 assert(should_be_1235 == 1235);
21}21}
2222
23test "inlinedLoop" {23test "inlined loop" {
24 comptime var i = 0;24 comptime var i = 0;
25 comptime var sum = 0;25 comptime var sum = 0;
26 inline while (i <= 5) : (i += 1)26 inline while (i <= 5) : (i += 1)
...@@ -34,20 +34,20 @@ fn gimme1or2(comptime a: bool) -> i32 {...@@ -34,20 +34,20 @@ fn gimme1or2(comptime a: bool) -> i32 {
34 comptime var z: i32 = if (a) x else y;34 comptime var z: i32 = if (a) x else y;
35 return z;35 return z;
36}36}
37test "inlineVariableGetsResultOfConstIf" {37test "inline variable gets result of const if" {
38 assert(gimme1or2(true) == 1);38 assert(gimme1or2(true) == 1);
39 assert(gimme1or2(false) == 2);39 assert(gimme1or2(false) == 2);
40}40}
4141
4242
43test "staticFunctionEvaluation" {43test "static function evaluation" {
44 assert(statically_added_number == 3);44 assert(statically_added_number == 3);
45}45}
46const statically_added_number = staticAdd(1, 2);46const statically_added_number = staticAdd(1, 2);
47fn staticAdd(a: i32, b: i32) -> i32 { a + b }47fn staticAdd(a: i32, b: i32) -> i32 { a + b }
4848
4949
50test "constExprEvalOnSingleExprBlocks" {50test "const expr eval on single expr blocks" {
51 assert(constExprEvalOnSingleExprBlocksFn(1, true) == 3);51 assert(constExprEvalOnSingleExprBlocksFn(1, true) == 3);
52}52}
5353
...@@ -66,7 +66,7 @@ fn constExprEvalOnSingleExprBlocksFn(x: i32, b: bool) -> i32 {...@@ -66,7 +66,7 @@ fn constExprEvalOnSingleExprBlocksFn(x: i32, b: bool) -> i32 {
6666
6767
6868
69test "staticallyInitalizedList" {69test "statically initialized list" {
70 assert(static_point_list[0].x == 1);70 assert(static_point_list[0].x == 1);
71 assert(static_point_list[0].y == 2);71 assert(static_point_list[0].y == 2);
72 assert(static_point_list[1].x == 3);72 assert(static_point_list[1].x == 3);
...@@ -85,7 +85,7 @@ fn makePoint(x: i32, y: i32) -> Point {...@@ -85,7 +85,7 @@ fn makePoint(x: i32, y: i32) -> Point {
85}85}
8686
8787
88test "staticEvalListInit" {88test "static eval list init" {
89 assert(static_vec3.data[2] == 1.0);89 assert(static_vec3.data[2] == 1.0);
90 assert(vec3(0.0, 0.0, 3.0).data[2] == 3.0);90 assert(vec3(0.0, 0.0, 3.0).data[2] == 3.0);
91}91}
...@@ -100,14 +100,14 @@ pub fn vec3(x: f32, y: f32, z: f32) -> Vec3 {...@@ -100,14 +100,14 @@ pub fn vec3(x: f32, y: f32, z: f32) -> Vec3 {
100}100}
101101
102102
103test "constantExpressions" {103test "constant expressions" {
104 var array : [array_size]u8 = undefined;104 var array : [array_size]u8 = undefined;
105 assert(@sizeOf(@typeOf(array)) == 20);105 assert(@sizeOf(@typeOf(array)) == 20);
106}106}
107const array_size : u8 = 20;107const array_size : u8 = 20;
108108
109109
110test "constantStructWithNegation" {110test "constant struct with negation" {
111 assert(vertices[0].x == -0.6);111 assert(vertices[0].x == -0.6);
112}112}
113const Vertex = struct {113const Vertex = struct {
...@@ -124,7 +124,7 @@ const vertices = []Vertex {...@@ -124,7 +124,7 @@ const vertices = []Vertex {
124};124};
125125
126126
127test "staticallyInitalizedStruct" {127test "statically initialized struct" {
128 st_init_str_foo.x += 1;128 st_init_str_foo.x += 1;
129 assert(st_init_str_foo.x == 14);129 assert(st_init_str_foo.x == 14);
130}130}
...@@ -135,14 +135,14 @@ const StInitStrFoo = struct {...@@ -135,14 +135,14 @@ const StInitStrFoo = struct {
135var st_init_str_foo = StInitStrFoo { .x = 13, .y = true, };135var st_init_str_foo = StInitStrFoo { .x = 13, .y = true, };
136136
137137
138test "staticallyInitializedArrayLiteral" {138test "statically initalized array literal" {
139 const y : [4]u8 = st_init_arr_lit_x;139 const y : [4]u8 = st_init_arr_lit_x;
140 assert(y[3] == 4);140 assert(y[3] == 4);
141}141}
142const st_init_arr_lit_x = []u8{1,2,3,4};142const st_init_arr_lit_x = []u8{1,2,3,4};
143143
144144
145test "constSlice" {145test "const slice" {
146 comptime {146 comptime {
147 const a = "1234567890";147 const a = "1234567890";
148 assert(a.len == 10);148 assert(a.len == 10);
...@@ -152,7 +152,7 @@ test "constSlice" {...@@ -152,7 +152,7 @@ test "constSlice" {
152 }152 }
153}153}
154154
155test "tryToTrickEvalWithRuntimeIf" {155test "try to trick eval with runtime if" {
156 assert(testTryToTrickEvalWithRuntimeIf(true) == 10);156 assert(testTryToTrickEvalWithRuntimeIf(true) == 10);
157}157}
158158
...@@ -178,7 +178,7 @@ fn max(comptime T: type, a: T, b: T) -> T {...@@ -178,7 +178,7 @@ fn max(comptime T: type, a: T, b: T) -> T {
178fn letsTryToCompareBools(a: bool, b: bool) -> bool {178fn letsTryToCompareBools(a: bool, b: bool) -> bool {
179 max(bool, a, b)179 max(bool, a, b)
180}180}
181test "inlinedBlockAndRuntimeBlockPhi" {181test "inlined block and runtime block phi" {
182 assert(letsTryToCompareBools(true, true));182 assert(letsTryToCompareBools(true, true));
183 assert(letsTryToCompareBools(true, false));183 assert(letsTryToCompareBools(true, false));
184 assert(letsTryToCompareBools(false, true));184 assert(letsTryToCompareBools(false, true));
...@@ -217,7 +217,7 @@ fn performFn(comptime prefix_char: u8, start_value: i32) -> i32 {...@@ -217,7 +217,7 @@ fn performFn(comptime prefix_char: u8, start_value: i32) -> i32 {
217 return result;217 return result;
218}218}
219219
220test "comptimeIterateOverFnPtrList" {220test "comptime iterate over fn ptr list" {
221 assert(performFn('t', 1) == 6);221 assert(performFn('t', 1) == 6);
222 assert(performFn('o', 0) == 1);222 assert(performFn('o', 0) == 1);
223 assert(performFn('w', 99) == 99);223 assert(performFn('w', 99) == 99);
...@@ -256,13 +256,13 @@ var simple_struct = SimpleStruct{ .field = 1234, };...@@ -256,13 +256,13 @@ var simple_struct = SimpleStruct{ .field = 1234, };
256256
257const bound_fn = simple_struct.method;257const bound_fn = simple_struct.method;
258258
259test "callMethodOnBoundFnReferringToVarInstance" {259test "call method on bound fn referring to var instance" {
260 assert(bound_fn() == 1237);260 assert(bound_fn() == 1237);
261}261}
262262
263263
264264
265test "ptrToLocalArrayArgumentAtComptime" {265test "ptr to local array argument at comptime" {
266 comptime {266 comptime {
267 var bytes: [10]u8 = undefined;267 var bytes: [10]u8 = undefined;
268 modifySomeBytes(bytes[0..]);268 modifySomeBytes(bytes[0..]);
test/cases/ir_block_deps.zig+1-1
...@@ -15,7 +15,7 @@ fn getErrInt() -> %i32 { 0 }...@@ -15,7 +15,7 @@ fn getErrInt() -> %i32 { 0 }
1515
16error ItBroke;16error ItBroke;
1717
18test "irBlockDeps" {18test "ir block deps" {
19 assert(%%foo(1) == 0);19 assert(%%foo(1) == 0);
20 assert(%%foo(2) == 0);20 assert(%%foo(2) == 0);
21}21}
test/cases/math.zig+1-1
...@@ -85,7 +85,7 @@ test "assignment operators" {...@@ -85,7 +85,7 @@ test "assignment operators" {
85 i |= 3; assert(i == 7);85 i |= 3; assert(i == 7);
86}86}
8787
88test "threeExprInARow" {88test "three expr in a row" {
89 testThreeExprInARow(false, true);89 testThreeExprInARow(false, true);
90 comptime testThreeExprInARow(false, true);90 comptime testThreeExprInARow(false, true);
91}91}
test/cases/namespace_depends_on_compile_var/index.zig+1-1
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1const builtin = @import("builtin");1const builtin = @import("builtin");
2const assert = @import("std").debug.assert;2const assert = @import("std").debug.assert;
33
4test "namespaceDependsOnCompileVar" {4test "namespace depends on compile var" {
5 if (some_namespace.a_bool) {5 if (some_namespace.a_bool) {
6 assert(some_namespace.a_bool);6 assert(some_namespace.a_bool);
7 } else {7 } else {
test/cases/null.zig+6-6
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const assert = @import("std").debug.assert;1const assert = @import("std").debug.assert;
22
3test "nullableType" {3test "nullable type" {
4 const x : ?bool = true;4 const x : ?bool = true;
55
6 if (x) |y| {6 if (x) |y| {
...@@ -37,7 +37,7 @@ test "test maybe object and get a pointer to the inner value" {...@@ -37,7 +37,7 @@ test "test maybe object and get a pointer to the inner value" {
37}37}
3838
3939
40test "rhsMaybeUnwrapReturn" {40test "rhs maybe unwrap return" {
41 const x: ?bool = true;41 const x: ?bool = true;
42 const y = x ?? return;42 const y = x ?? return;
43}43}
...@@ -61,7 +61,7 @@ fn foo(x: ?i32) -> ?bool {...@@ -61,7 +61,7 @@ fn foo(x: ?i32) -> ?bool {
61}61}
6262
6363
64test "ifVarMaybePointer" {64test "if var maybe pointer" {
65 assert(shouldBeAPlus1(Particle {.a = 14, .b = 1, .c = 1, .d = 1}) == 15);65 assert(shouldBeAPlus1(Particle {.a = 14, .b = 1, .c = 1, .d = 1}) == 15);
66}66}
67fn shouldBeAPlus1(p: &const Particle) -> u64 {67fn shouldBeAPlus1(p: &const Particle) -> u64 {
...@@ -82,7 +82,7 @@ const Particle = struct {...@@ -82,7 +82,7 @@ const Particle = struct {
82};82};
8383
8484
85test "nullLiteralOutsideFunction" {85test "null literal outside function" {
86 const is_null = here_is_a_null_literal.context == null;86 const is_null = here_is_a_null_literal.context == null;
87 assert(is_null);87 assert(is_null);
8888
...@@ -97,7 +97,7 @@ const here_is_a_null_literal = SillyStruct {...@@ -97,7 +97,7 @@ const here_is_a_null_literal = SillyStruct {
97};97};
9898
9999
100test "testNullRuntime" {100test "test null runtime" {
101 testTestNullRuntime(null);101 testTestNullRuntime(null);
102}102}
103fn testTestNullRuntime(x: ?i32) {103fn testTestNullRuntime(x: ?i32) {
...@@ -105,7 +105,7 @@ fn testTestNullRuntime(x: ?i32) {...@@ -105,7 +105,7 @@ fn testTestNullRuntime(x: ?i32) {
105 assert(!(x != null));105 assert(!(x != null));
106}106}
107107
108test "nullableVoid" {108test "nullable void" {
109 nullableVoidImpl();109 nullableVoidImpl();
110 comptime nullableVoidImpl();110 comptime nullableVoidImpl();
111}111}
test/cases/pub_enum/index.zig+2-2
...@@ -1,13 +1,13 @@...@@ -1,13 +1,13 @@
1const other = @import("other.zig");1const other = @import("other.zig");
2const assert = @import("std").debug.assert;2const assert = @import("std").debug.assert;
33
4test "pubEnum" {4test "pub enum" {
5 pubEnumTest(other.APubEnum.Two);5 pubEnumTest(other.APubEnum.Two);
6}6}
7fn pubEnumTest(foo: other.APubEnum) {7fn pubEnumTest(foo: other.APubEnum) {
8 assert(foo == other.APubEnum.Two);8 assert(foo == other.APubEnum.Two);
9}9}
1010
11test "castWithImportedSymbol" {11test "cast with imported symbol" {
12 assert(other.size_t(42) == 42);12 assert(other.size_t(42) == 42);
13}13}
test/cases/struct.zig+20-20
...@@ -5,12 +5,12 @@ const StructWithNoFields = struct {...@@ -5,12 +5,12 @@ const StructWithNoFields = struct {
5};5};
6const empty_global_instance = StructWithNoFields {};6const empty_global_instance = StructWithNoFields {};
77
8test "callStructStaticMethod" {8test "call struct static method" {
9 const result = StructWithNoFields.add(3, 4);9 const result = StructWithNoFields.add(3, 4);
10 assert(result == 7);10 assert(result == 7);
11}11}
1212
13test "returnEmptyStructInstance" {13test "return empty struct instance" {
14 _ = returnEmptyStructInstance();14 _ = returnEmptyStructInstance();
15}15}
16fn returnEmptyStructInstance() -> StructWithNoFields {16fn returnEmptyStructInstance() -> StructWithNoFields {
...@@ -19,11 +19,11 @@ fn returnEmptyStructInstance() -> StructWithNoFields {...@@ -19,11 +19,11 @@ fn returnEmptyStructInstance() -> StructWithNoFields {
1919
20const should_be_11 = StructWithNoFields.add(5, 6);20const should_be_11 = StructWithNoFields.add(5, 6);
2121
22test "invokeStaticMethodInGlobalScope" {22test "invake static method in global scope" {
23 assert(should_be_11 == 11);23 assert(should_be_11 == 11);
24}24}
2525
26test "voidStructFields" {26test "void struct fields" {
27 const foo = VoidStructFieldsFoo {27 const foo = VoidStructFieldsFoo {
28 .a = void{},28 .a = void{},
29 .b = 1,29 .b = 1,
...@@ -39,7 +39,7 @@ const VoidStructFieldsFoo = struct {...@@ -39,7 +39,7 @@ const VoidStructFieldsFoo = struct {
39};39};
4040
4141
42test "fn" {42test "structs" {
43 var foo: StructFoo = undefined;43 var foo: StructFoo = undefined;
44 @memset(@ptrCast(&u8, &foo), 0, @sizeOf(StructFoo));44 @memset(@ptrCast(&u8, &foo), 0, @sizeOf(StructFoo));
45 foo.a += 1;45 foo.a += 1;
...@@ -70,7 +70,7 @@ const Val = struct {...@@ -70,7 +70,7 @@ const Val = struct {
70 x: i32,70 x: i32,
71};71};
7272
73test "structPointToSelf" {73test "struct point to self" {
74 var root : Node = undefined;74 var root : Node = undefined;
75 root.val.x = 1;75 root.val.x = 1;
7676
...@@ -83,7 +83,7 @@ test "structPointToSelf" {...@@ -83,7 +83,7 @@ test "structPointToSelf" {
83 assert(node.next.next.next.val.x == 1);83 assert(node.next.next.next.val.x == 1);
84}84}
8585
86test "structByvalAssign" {86test "struct byval assign" {
87 var foo1 : StructFoo = undefined;87 var foo1 : StructFoo = undefined;
88 var foo2 : StructFoo = undefined;88 var foo2 : StructFoo = undefined;
8989
...@@ -100,7 +100,7 @@ fn structInitializer() {...@@ -100,7 +100,7 @@ fn structInitializer() {
100}100}
101101
102102
103test "fnCallOfStructField" {103test "fn call of struct field" {
104 assert(callStructField(Foo {.ptr = aFunc,}) == 13);104 assert(callStructField(Foo {.ptr = aFunc,}) == 13);
105}105}
106106
...@@ -115,7 +115,7 @@ fn callStructField(foo: &const Foo) -> i32 {...@@ -115,7 +115,7 @@ fn callStructField(foo: &const Foo) -> i32 {
115}115}
116116
117117
118test "storeMemberFunctionInVariable" {118test "store member function in variable" {
119 const instance = MemberFnTestFoo { .x = 1234, };119 const instance = MemberFnTestFoo { .x = 1234, };
120 const memberFn = MemberFnTestFoo.member;120 const memberFn = MemberFnTestFoo.member;
121 const result = memberFn(instance);121 const result = memberFn(instance);
...@@ -127,13 +127,13 @@ const MemberFnTestFoo = struct {...@@ -127,13 +127,13 @@ const MemberFnTestFoo = struct {
127};127};
128128
129129
130test "callMemberFunctionDirectly" {130test "call member function directly" {
131 const instance = MemberFnTestFoo { .x = 1234, };131 const instance = MemberFnTestFoo { .x = 1234, };
132 const result = MemberFnTestFoo.member(instance);132 const result = MemberFnTestFoo.member(instance);
133 assert(result == 1234);133 assert(result == 1234);
134}134}
135135
136test "memberFunctions" {136test "member functions" {
137 const r = MemberFnRand {.seed = 1234};137 const r = MemberFnRand {.seed = 1234};
138 assert(r.getSeed() == 1234);138 assert(r.getSeed() == 1234);
139}139}
...@@ -144,7 +144,7 @@ const MemberFnRand = struct {...@@ -144,7 +144,7 @@ const MemberFnRand = struct {
144 }144 }
145};145};
146146
147test "returnStructByvalFromFunction" {147test "return struct byval from function" {
148 const bar = makeBar(1234, 5678);148 const bar = makeBar(1234, 5678);
149 assert(bar.y == 5678);149 assert(bar.y == 5678);
150}150}
...@@ -159,7 +159,7 @@ fn makeBar(x: i32, y: i32) -> Bar {...@@ -159,7 +159,7 @@ fn makeBar(x: i32, y: i32) -> Bar {
159 }159 }
160}160}
161161
162test "emptyStructMethodCall" {162test "empty struct method call" {
163 const es = EmptyStruct{};163 const es = EmptyStruct{};
164 assert(es.method() == 1234);164 assert(es.method() == 1234);
165}165}
...@@ -170,7 +170,7 @@ const EmptyStruct = struct {...@@ -170,7 +170,7 @@ const EmptyStruct = struct {
170};170};
171171
172172
173test "returnEmptyStructFromFn" {173test "return empty struct from fn" {
174 _ = testReturnEmptyStructFromFn();174 _ = testReturnEmptyStructFromFn();
175}175}
176const EmptyStruct2 = struct {};176const EmptyStruct2 = struct {};
...@@ -178,7 +178,7 @@ fn testReturnEmptyStructFromFn() -> EmptyStruct2 {...@@ -178,7 +178,7 @@ fn testReturnEmptyStructFromFn() -> EmptyStruct2 {
178 EmptyStruct2 {}178 EmptyStruct2 {}
179}179}
180180
181test "passSliceOfEmptyStructToFn" {181test "pass slice of empty struct to fn" {
182 assert(testPassSliceOfEmptyStructToFn([]EmptyStruct2{ EmptyStruct2{} }) == 1);182 assert(testPassSliceOfEmptyStructToFn([]EmptyStruct2{ EmptyStruct2{} }) == 1);
183}183}
184fn testPassSliceOfEmptyStructToFn(slice: []const EmptyStruct2) -> usize {184fn testPassSliceOfEmptyStructToFn(slice: []const EmptyStruct2) -> usize {
...@@ -190,7 +190,7 @@ const APackedStruct = packed struct {...@@ -190,7 +190,7 @@ const APackedStruct = packed struct {
190 y: u8,190 y: u8,
191};191};
192192
193test "packedStruct" {193test "packed struct" {
194 var foo = APackedStruct {194 var foo = APackedStruct {
195 .x = 1,195 .x = 1,
196 .y = 2,196 .y = 2,
...@@ -216,7 +216,7 @@ const bit_field_1 = BitField1 {...@@ -216,7 +216,7 @@ const bit_field_1 = BitField1 {
216 .c = 3,216 .c = 3,
217};217};
218218
219test "bitFieldAccess" {219test "bit field access" {
220 var data = bit_field_1;220 var data = bit_field_1;
221 assert(getA(&data) == 1);221 assert(getA(&data) == 1);
222 assert(getB(&data) == 2);222 assert(getB(&data) == 2);
...@@ -254,7 +254,7 @@ const Foo96Bits = packed struct {...@@ -254,7 +254,7 @@ const Foo96Bits = packed struct {
254 d: u24,254 d: u24,
255};255};
256256
257test "packedStruct24Bits" {257test "packed struct 24bits" {
258 comptime {258 comptime {
259 assert(@sizeOf(Foo24Bits) == 3);259 assert(@sizeOf(Foo24Bits) == 3);
260 assert(@sizeOf(Foo96Bits) == 12);260 assert(@sizeOf(Foo96Bits) == 12);
...@@ -297,7 +297,7 @@ const FooArray24Bits = packed struct {...@@ -297,7 +297,7 @@ const FooArray24Bits = packed struct {
297 c: u16,297 c: u16,
298};298};
299299
300test "packedArray24Bits" {300test "packed array 24bits" {
301 comptime {301 comptime {
302 assert(@sizeOf([9]Foo24Bits) == 9 * 3);302 assert(@sizeOf([9]Foo24Bits) == 9 * 3);
303 assert(@sizeOf(FooArray24Bits) == 2 + 2 * 3 + 2);303 assert(@sizeOf(FooArray24Bits) == 2 + 2 * 3 + 2);
...@@ -347,7 +347,7 @@ const FooArrayOfAligned = packed struct {...@@ -347,7 +347,7 @@ const FooArrayOfAligned = packed struct {
347 a: [2]FooStructAligned,347 a: [2]FooStructAligned,
348};348};
349349
350test "alignedArrayOfPackedStruct" {350test "aligned array of packed struct" {
351 comptime {351 comptime {
352 assert(@sizeOf(FooStructAligned) == 2);352 assert(@sizeOf(FooStructAligned) == 2);
353 assert(@sizeOf(FooArrayOfAligned) == 2 * 2);353 assert(@sizeOf(FooArrayOfAligned) == 2 * 2);
test/cases/switch_prong_err_enum.zig+1-1
...@@ -21,7 +21,7 @@ fn doThing(form_id: u64) -> %FormValue {...@@ -21,7 +21,7 @@ fn doThing(form_id: u64) -> %FormValue {
21 }21 }
22}22}
2323
24test "switchProngReturnsErrorEnum" {24test "switch prong returns error enum" {
25 switch (%%doThing(17)) {25 switch (%%doThing(17)) {
26 FormValue.Address => |payload| { assert(payload == 1); },26 FormValue.Address => |payload| { assert(payload == 1); },
27 else => unreachable,27 else => unreachable,
test/cases/switch_prong_implicit_cast.zig+1-1
...@@ -15,7 +15,7 @@ fn foo(id: u64) -> %FormValue {...@@ -15,7 +15,7 @@ fn foo(id: u64) -> %FormValue {
15 }15 }
16}16}
1717
18test "switchProngImplicitCast" {18test "switch prong implicit cast" {
19 const result = switch (%%foo(2)) {19 const result = switch (%%foo(2)) {
20 FormValue.One => false,20 FormValue.One => false,
21 FormValue.Two => |x| x,21 FormValue.Two => |x| x,
test/cases/this.zig+3-3
...@@ -28,11 +28,11 @@ fn factorial(x: i32) -> i32 {...@@ -28,11 +28,11 @@ fn factorial(x: i32) -> i32 {
28 }28 }
29}29}
3030
31test "thisReferToModuleCallPrivateFn" {31test "this refer to module call private fn" {
32 assert(module.add(1, 2) == 3);32 assert(module.add(1, 2) == 3);
33}33}
3434
35test "thisReferToContainer" {35test "this refer to container" {
36 var pt = Point(i32) {36 var pt = Point(i32) {
37 .x = 12,37 .x = 12,
38 .y = 34,38 .y = 34,
...@@ -42,6 +42,6 @@ test "thisReferToContainer" {...@@ -42,6 +42,6 @@ test "thisReferToContainer" {
42 assert(pt.y == 35);42 assert(pt.y == 35);
43}43}
4444
45test "thisReferToFn" {45test "this refer to fn" {
46 assert(factorial(5) == 120);46 assert(factorial(5) == 120);
47}47}
test/cases/try.zig+2-2
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const assert = @import("std").debug.assert;1const assert = @import("std").debug.assert;
22
3test "tryOnErrorUnion" {3test "try on error union" {
4 tryOnErrorUnionImpl();4 tryOnErrorUnionImpl();
5 comptime tryOnErrorUnionImpl();5 comptime tryOnErrorUnionImpl();
66
...@@ -24,7 +24,7 @@ fn returnsTen() -> %i32 {...@@ -24,7 +24,7 @@ fn returnsTen() -> %i32 {
24 1024 10
25}25}
2626
27test "tryWithoutVars" {27test "try without vars" {
28 const result1 = if (failIfTrue(true)) {28 const result1 = if (failIfTrue(true)) {
29 129 1
30 } else |_| {30 } else |_| {
test/cases/undefined.zig+3-3
...@@ -9,7 +9,7 @@ fn initStaticArray() -> [10]i32 {...@@ -9,7 +9,7 @@ fn initStaticArray() -> [10]i32 {
9 return array;9 return array;
10}10}
11const static_array = initStaticArray();11const static_array = initStaticArray();
12test "initStaticArrayToUndefined" {12test "init static array to undefined" {
13 assert(static_array[0] == 1);13 assert(static_array[0] == 1);
14 assert(static_array[4] == 2);14 assert(static_array[4] == 2);
15 assert(static_array[7] == 3);15 assert(static_array[7] == 3);
...@@ -35,7 +35,7 @@ fn setFooX(foo: &Foo) {...@@ -35,7 +35,7 @@ fn setFooX(foo: &Foo) {
35 foo.x = 2;35 foo.x = 2;
36}36}
3737
38test "assignUndefinedToStruct" {38test "assign undefined to struct" {
39 comptime {39 comptime {
40 var foo: Foo = undefined;40 var foo: Foo = undefined;
41 setFooX(&foo);41 setFooX(&foo);
...@@ -48,7 +48,7 @@ test "assignUndefinedToStruct" {...@@ -48,7 +48,7 @@ test "assignUndefinedToStruct" {
48 }48 }
49}49}
5050
51test "assignUndefinedToStructWithMethod" {51test "assign undefined to struct with method" {
52 comptime {52 comptime {
53 var foo: Foo = undefined;53 var foo: Foo = undefined;
54 foo.setFooXMethod();54 foo.setFooXMethod();
test/cases/var_args.zig+3-3
...@@ -8,7 +8,7 @@ fn add(args: ...) -> i32 {...@@ -8,7 +8,7 @@ fn add(args: ...) -> i32 {
8 return sum;8 return sum;
9}9}
1010
11test "testAddArbitraryArgs" {11test "add arbitrary args" {
12 assert(add(i32(1), i32(2), i32(3), i32(4)) == 10);12 assert(add(i32(1), i32(2), i32(3), i32(4)) == 10);
13 assert(add(i32(1234)) == 1234);13 assert(add(i32(1234)) == 1234);
14 assert(add() == 0);14 assert(add() == 0);
...@@ -18,11 +18,11 @@ fn readFirstVarArg(args: ...) {...@@ -18,11 +18,11 @@ fn readFirstVarArg(args: ...) {
18 const value = args[0];18 const value = args[0];
19}19}
2020
21test "sendVoidArgToVarArgs" {21test "send void arg to var args" {
22 readFirstVarArg({});22 readFirstVarArg({});
23}23}
2424
25test "testPassArgsDirectly" {25test "pass args directly" {
26 assert(addSomeStuff(i32(1), i32(2), i32(3), i32(4)) == 10);26 assert(addSomeStuff(i32(1), i32(2), i32(3), i32(4)) == 10);
27 assert(addSomeStuff(i32(1234)) == 1234);27 assert(addSomeStuff(i32(1234)) == 1234);
28 assert(addSomeStuff() == 0);28 assert(addSomeStuff() == 0);
test/cases/void.zig+1-1
...@@ -6,7 +6,7 @@ const Foo = struct {...@@ -6,7 +6,7 @@ const Foo = struct {
6 c: void,6 c: void,
7};7};
88
9test "compareVoidWithVoidCompileTimeKnown" {9test "compare void with void compile time known" {
10 comptime {10 comptime {
11 const foo = Foo {11 const foo = Foo {
12 .a = {},12 .a = {},