Commit 4751356d7f

Andrew Kelley <andrew@ziglang.org>
2022-05-27 04:38:28
clean up some behavior tests
* improve names * properly categorize a couple of bug cases * mark one as already passing
1 parent f2e8c79
test/behavior/bugs/10970.zig
@@ -3,11 +3,12 @@ const builtin = @import("builtin");
 fn retOpt() ?u32 {
     return null;
 }
-test {
+test "breaking from a loop in an if statement" {
     if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
     if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
     if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
     if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
+
     var cond = true;
     const opt = while (cond) {
         if (retOpt()) |opt| {
test/behavior/bugs/11162.zig
@@ -2,7 +2,7 @@ const std = @import("std");
 const builtin = @import("builtin");
 const expect = std.testing.expect;
 
-test {
+test "aggregate initializers should allow initializing comptime fields, verifying equality (stage2 only)" {
     if (builtin.zig_backend == .stage1) return error.SkipZigTest; // TODO
     if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
 
test/behavior/bugs/11182.zig
@@ -1,10 +0,0 @@
-const std = @import("std");
-const builtin = @import("builtin");
-
-test {
-    if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
-
-    const T = @TypeOf(.{ @as(i32, 0), @as(u32, 0) });
-    var a = T{ 0, 0 };
-    _ = a;
-}
test/behavior/bugs/7027.zig
@@ -1,21 +0,0 @@
-const Foobar = struct {
-    myTypes: [128]type,
-    str: [1024]u8,
-
-    fn foo() @This() {
-        comptime var foobar: Foobar = undefined;
-        foobar.str = [_]u8{'a'} ** 1024;
-        return foobar;
-    }
-};
-
-fn foo(arg: anytype) void {
-    _ = arg;
-}
-
-test {
-    if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
-
-    comptime var foobar = Foobar.foo();
-    foo(foobar.str[0..10]);
-}
test/behavior/eval.zig
@@ -1203,3 +1203,30 @@ test "equality of pointers to comptime const" {
     const a: i32 = undefined;
     comptime assert(&a == &a);
 }
+
+test "storing an array of type in a field" {
+    if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
+
+    const S = struct {
+        fn doTheTest() void {
+            comptime var foobar = Foobar.foo();
+            foo(foobar.str[0..10]);
+        }
+        const Foobar = struct {
+            myTypes: [128]type,
+            str: [1024]u8,
+
+            fn foo() @This() {
+                comptime var foobar: Foobar = undefined;
+                foobar.str = [_]u8{'a'} ** 1024;
+                return foobar;
+            }
+        };
+
+        fn foo(arg: anytype) void {
+            _ = arg;
+        }
+    };
+
+    S.doTheTest();
+}
test/behavior/floatop.zig
@@ -651,11 +651,7 @@ test "negation f128" {
 }
 
 test "eval @setFloatMode at compile-time" {
-    if (builtin.zig_backend != .stage1) {
-        // let's delay solving this one; I want to re-evaluate this language feature, and
-        // we don't rely on it for self-hosted.
-        return error.SkipZigTest; // TODO
-    }
+    if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
 
     const result = comptime fnWithFloatMode();
     try expect(result == 1234.0);
test/behavior/tuple.zig
@@ -192,3 +192,11 @@ test "tuple as the result from a labeled block" {
     try S.doTheTest();
     comptime try S.doTheTest();
 }
+
+test "initializing tuple with explicit type" {
+    if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
+
+    const T = @TypeOf(.{ @as(i32, 0), @as(u32, 0) });
+    var a = T{ 0, 0 };
+    _ = a;
+}
test/behavior.zig
@@ -67,7 +67,6 @@ test {
     _ = @import("behavior/bugs/6781.zig");
     _ = @import("behavior/bugs/6850.zig");
     _ = @import("behavior/bugs/7003.zig");
-    _ = @import("behavior/bugs/7027.zig");
     _ = @import("behavior/bugs/7047.zig");
     _ = @import("behavior/bugs/7187.zig");
     _ = @import("behavior/bugs/7250.zig");
@@ -82,7 +81,6 @@ test {
     _ = @import("behavior/bugs/11162.zig");
     _ = @import("behavior/bugs/11165.zig");
     _ = @import("behavior/bugs/11181.zig");
-    _ = @import("behavior/bugs/11182.zig");
     _ = @import("behavior/bugs/11213.zig");
     _ = @import("behavior/byteswap.zig");
     _ = @import("behavior/byval_arg_var.zig");