authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-05-26 19:38:28-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-05-26 21:58:19-07:00
log4751356d7f1da157665d37e29216628e61ddf079
tree4d703caff2eec93161d5f37737b24fa87073053b
parentf2e8c79763723e394f57af84af977d91652568b5

clean up some behavior tests

* improve names * properly categorize a couple of bug cases * mark one as already passing

8 files changed, 39 insertions(+), 40 deletions(-)

test/behavior.zig-2
...@@ -67,7 +67,6 @@ test {...@@ -67,7 +67,6 @@ test {
67 _ = @import("behavior/bugs/6781.zig");67 _ = @import("behavior/bugs/6781.zig");
68 _ = @import("behavior/bugs/6850.zig");68 _ = @import("behavior/bugs/6850.zig");
69 _ = @import("behavior/bugs/7003.zig");69 _ = @import("behavior/bugs/7003.zig");
70 _ = @import("behavior/bugs/7027.zig");
71 _ = @import("behavior/bugs/7047.zig");70 _ = @import("behavior/bugs/7047.zig");
72 _ = @import("behavior/bugs/7187.zig");71 _ = @import("behavior/bugs/7187.zig");
73 _ = @import("behavior/bugs/7250.zig");72 _ = @import("behavior/bugs/7250.zig");
...@@ -82,7 +81,6 @@ test {...@@ -82,7 +81,6 @@ test {
82 _ = @import("behavior/bugs/11162.zig");81 _ = @import("behavior/bugs/11162.zig");
83 _ = @import("behavior/bugs/11165.zig");82 _ = @import("behavior/bugs/11165.zig");
84 _ = @import("behavior/bugs/11181.zig");83 _ = @import("behavior/bugs/11181.zig");
85 _ = @import("behavior/bugs/11182.zig");
86 _ = @import("behavior/bugs/11213.zig");84 _ = @import("behavior/bugs/11213.zig");
87 _ = @import("behavior/byteswap.zig");85 _ = @import("behavior/byteswap.zig");
88 _ = @import("behavior/byval_arg_var.zig");86 _ = @import("behavior/byval_arg_var.zig");
test/behavior/bugs/10970.zig+2-1
...@@ -3,11 +3,12 @@ const builtin = @import("builtin");...@@ -3,11 +3,12 @@ const builtin = @import("builtin");
3fn retOpt() ?u32 {3fn retOpt() ?u32 {
4 return null;4 return null;
5}5}
6test {6test "breaking from a loop in an if statement" {
7 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;7 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
8 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;8 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
9 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;9 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
10 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;10 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
11
11 var cond = true;12 var cond = true;
12 const opt = while (cond) {13 const opt = while (cond) {
13 if (retOpt()) |opt| {14 if (retOpt()) |opt| {
test/behavior/bugs/11162.zig+1-1
...@@ -2,7 +2,7 @@ const std = @import("std");...@@ -2,7 +2,7 @@ const std = @import("std");
2const builtin = @import("builtin");2const builtin = @import("builtin");
3const expect = std.testing.expect;3const expect = std.testing.expect;
44
5test {5test "aggregate initializers should allow initializing comptime fields, verifying equality (stage2 only)" {
6 if (builtin.zig_backend == .stage1) return error.SkipZigTest; // TODO6 if (builtin.zig_backend == .stage1) return error.SkipZigTest; // TODO
7 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO7 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
88
test/behavior/bugs/11182.zig deleted-10
...@@ -1,10 +0,0 @@
1const std = @import("std");
2const builtin = @import("builtin");
3
4test {
5 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
6
7 const T = @TypeOf(.{ @as(i32, 0), @as(u32, 0) });
8 var a = T{ 0, 0 };
9 _ = a;
10}
test/behavior/bugs/7027.zig deleted-21
...@@ -1,21 +0,0 @@
1const Foobar = struct {
2 myTypes: [128]type,
3 str: [1024]u8,
4
5 fn foo() @This() {
6 comptime var foobar: Foobar = undefined;
7 foobar.str = [_]u8{'a'} ** 1024;
8 return foobar;
9 }
10};
11
12fn foo(arg: anytype) void {
13 _ = arg;
14}
15
16test {
17 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
18
19 comptime var foobar = Foobar.foo();
20 foo(foobar.str[0..10]);
21}
test/behavior/eval.zig+27
...@@ -1203,3 +1203,30 @@ test "equality of pointers to comptime const" {...@@ -1203,3 +1203,30 @@ test "equality of pointers to comptime const" {
1203 const a: i32 = undefined;1203 const a: i32 = undefined;
1204 comptime assert(&a == &a);1204 comptime assert(&a == &a);
1205}1205}
1206
1207test "storing an array of type in a field" {
1208 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
1209
1210 const S = struct {
1211 fn doTheTest() void {
1212 comptime var foobar = Foobar.foo();
1213 foo(foobar.str[0..10]);
1214 }
1215 const Foobar = struct {
1216 myTypes: [128]type,
1217 str: [1024]u8,
1218
1219 fn foo() @This() {
1220 comptime var foobar: Foobar = undefined;
1221 foobar.str = [_]u8{'a'} ** 1024;
1222 return foobar;
1223 }
1224 };
1225
1226 fn foo(arg: anytype) void {
1227 _ = arg;
1228 }
1229 };
1230
1231 S.doTheTest();
1232}
test/behavior/floatop.zig+1-5
...@@ -651,11 +651,7 @@ test "negation f128" {...@@ -651,11 +651,7 @@ test "negation f128" {
651}651}
652652
653test "eval @setFloatMode at compile-time" {653test "eval @setFloatMode at compile-time" {
654 if (builtin.zig_backend != .stage1) {654 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
655 // let's delay solving this one; I want to re-evaluate this language feature, and
656 // we don't rely on it for self-hosted.
657 return error.SkipZigTest; // TODO
658 }
659655
660 const result = comptime fnWithFloatMode();656 const result = comptime fnWithFloatMode();
661 try expect(result == 1234.0);657 try expect(result == 1234.0);
test/behavior/tuple.zig+8
...@@ -192,3 +192,11 @@ test "tuple as the result from a labeled block" {...@@ -192,3 +192,11 @@ test "tuple as the result from a labeled block" {
192 try S.doTheTest();192 try S.doTheTest();
193 comptime try S.doTheTest();193 comptime try S.doTheTest();
194}194}
195
196test "initializing tuple with explicit type" {
197 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
198
199 const T = @TypeOf(.{ @as(i32, 0), @as(u32, 0) });
200 var a = T{ 0, 0 };
201 _ = a;
202}