aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/basic.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/behavior/basic.zig')
-rw-r--r--test/behavior/basic.zig35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/behavior/basic.zig b/test/behavior/basic.zig
index ac9e776c76..e887a1d4b6 100644
--- a/test/behavior/basic.zig
+++ b/test/behavior/basic.zig
@@ -942,3 +942,38 @@ test "comptime int in switch in catch is casted to correct inferred type" {
};
_ = b;
}
+
+test "vector initialized with array init syntax has proper type" {
+ comptime {
+ const actual = -@Vector(4, i32){ 1, 2, 3, 4 };
+ try std.testing.expectEqual(@Vector(4, i32){ -1, -2, -3, -4 }, actual);
+ }
+}
+
+test "weird array and tuple initializations" {
+ if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
+
+ const E = enum { a, b };
+ const S = struct { e: E };
+ var a = false;
+ const b = S{ .e = .a };
+
+ _ = &[_]S{
+ if (a) .{ .e = .a } else .{ .e = .b },
+ };
+
+ if (true) return error.SkipZigTest;
+
+ const S2 = @TypeOf(.{ false, b });
+ _ = &S2{
+ true,
+ if (a) .{ .e = .a } else .{ .e = .b },
+ };
+ const S3 = @TypeOf(.{ .a = false, .b = b });
+ _ = &S3{
+ .a = true,
+ .b = if (a) .{ .e = .a } else .{ .e = .b },
+ };
+}