aboutsummaryrefslogtreecommitdiff
path: root/test/behavior
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-06-13 20:39:40 -0400
committerGitHub <noreply@github.com>2021-06-13 20:39:40 -0400
commit86ebd4b975d2f1e01f468e06daab6e28c06f9719 (patch)
tree250bfe03e0768bdf7619fa8bb588b6815e1d3f0d /test/behavior
parentdf4f11f42f44b4ee2a06e43095bc160277ceed42 (diff)
parente63ff4f1c110165c4b92025cb5b9d5531e861643 (diff)
downloadzig-86ebd4b975d2f1e01f468e06daab6e28c06f9719.tar.gz
zig-86ebd4b975d2f1e01f468e06daab6e28c06f9719.zip
Merge pull request #9106 from Vexu/fmt
Add formatting check to CI pipeline
Diffstat (limited to 'test/behavior')
-rw-r--r--test/behavior/bitcast.zig4
-rw-r--r--test/behavior/bugs/1111.zig2
-rw-r--r--test/behavior/bugs/3046.zig2
-rw-r--r--test/behavior/cast.zig13
-rw-r--r--test/behavior/enum.zig41
-rw-r--r--test/behavior/error.zig2
-rw-r--r--test/behavior/eval.zig4
-rw-r--r--test/behavior/generics.zig6
-rw-r--r--test/behavior/misc.zig8
-rw-r--r--test/behavior/syntax.zig3
-rw-r--r--test/behavior/type.zig2
-rw-r--r--test/behavior/union.zig2
12 files changed, 17 insertions, 72 deletions
diff --git a/test/behavior/bitcast.zig b/test/behavior/bitcast.zig
index d8fc3e64df..9d2484d26e 100644
--- a/test/behavior/bitcast.zig
+++ b/test/behavior/bitcast.zig
@@ -22,8 +22,8 @@ fn conv2(x: u32) i32 {
return @bitCast(i32, x);
}
-test "@bitCast extern enum to its integer type" {
- const SOCK = extern enum {
+test "@bitCast enum to its integer type" {
+ const SOCK = enum(c_int) {
A,
B,
diff --git a/test/behavior/bugs/1111.zig b/test/behavior/bugs/1111.zig
index 607bc33666..d274befaf3 100644
--- a/test/behavior/bugs/1111.zig
+++ b/test/behavior/bugs/1111.zig
@@ -1,4 +1,4 @@
-const Foo = extern enum {
+const Foo = enum(c_int) {
Bar = -1,
};
diff --git a/test/behavior/bugs/3046.zig b/test/behavior/bugs/3046.zig
index 8ff95f3b96..60425373b8 100644
--- a/test/behavior/bugs/3046.zig
+++ b/test/behavior/bugs/3046.zig
@@ -13,7 +13,7 @@ var some_struct: SomeStruct = undefined;
test "fixed" {
some_struct = SomeStruct{
- .field = couldFail() catch |_| @as(i32, 0),
+ .field = couldFail() catch @as(i32, 0),
};
try expect(some_struct.field == 1);
}
diff --git a/test/behavior/cast.zig b/test/behavior/cast.zig
index bcd407d259..864579c8f0 100644
--- a/test/behavior/cast.zig
+++ b/test/behavior/cast.zig
@@ -560,17 +560,6 @@ test "@intToEnum passed a comptime_int to an enum with one item" {
try expect(x == E.A);
}
-test "@intToEnum runtime to an extern enum with duplicate values" {
- const E = extern enum(u8) {
- A = 1,
- B = 1,
- };
- var a: u8 = 1;
- var x = @intToEnum(E, a);
- try expect(x == E.A);
- try expect(x == E.B);
-}
-
test "@intCast to u0 and use the result" {
const S = struct {
fn doTheTest(zero: u1, one: u1, bigzero: i32) !void {
@@ -665,7 +654,7 @@ test "*const [N]null u8 to ?[]const u8" {
test "peer resolution of string literals" {
const S = struct {
- const E = extern enum {
+ const E = enum {
a,
b,
c,
diff --git a/test/behavior/enum.zig b/test/behavior/enum.zig
index 0ab4e50b24..a1a4bbdca8 100644
--- a/test/behavior/enum.zig
+++ b/test/behavior/enum.zig
@@ -2,26 +2,6 @@ const expect = @import("std").testing.expect;
const mem = @import("std").mem;
const Tag = @import("std").meta.Tag;
-test "extern enum" {
- const S = struct {
- const i = extern enum {
- n = 0,
- o = 2,
- p = 4,
- q = 4,
- };
- fn doTheTest(y: c_int) void {
- var x = i.o;
- switch (x) {
- .n, .p => unreachable,
- .o => {},
- }
- }
- };
- S.doTheTest(52);
- comptime S.doTheTest(52);
-}
-
test "non-exhaustive enum" {
const S = struct {
const E = enum(u8) {
@@ -236,11 +216,6 @@ test "@tagName" {
comptime try expect(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three"));
}
-test "@tagName extern enum with duplicates" {
- try expect(mem.eql(u8, testEnumTagNameBare(ExternDuplicates.B), "A"));
- comptime try expect(mem.eql(u8, testEnumTagNameBare(ExternDuplicates.B), "A"));
-}
-
test "@tagName non-exhaustive enum" {
try expect(mem.eql(u8, testEnumTagNameBare(NonExhaustive.B), "B"));
comptime try expect(mem.eql(u8, testEnumTagNameBare(NonExhaustive.B), "B"));
@@ -256,11 +231,6 @@ const BareNumber = enum {
Three,
};
-const ExternDuplicates = extern enum(u8) {
- A = 1,
- B = 1,
-};
-
const NonExhaustive = enum(u8) {
A,
B,
@@ -1018,17 +988,8 @@ test "enum with 1 field but explicit tag type should still have the tag type" {
comptime try expect(@sizeOf(Enum) == @sizeOf(u8));
}
-test "empty extern enum with members" {
- const E = extern enum {
- A,
- B,
- C,
- };
- try expect(@sizeOf(E) == @sizeOf(c_int));
-}
-
test "tag name with assigned enum values" {
- const LocalFoo = enum {
+ const LocalFoo = enum(u8) {
A = 1,
B = 0,
};
diff --git a/test/behavior/error.zig b/test/behavior/error.zig
index e5129f180d..c0b4dc0231 100644
--- a/test/behavior/error.zig
+++ b/test/behavior/error.zig
@@ -394,7 +394,7 @@ test "function pointer with return type that is error union with payload which i
}
fn doTheTest() !void {
- var x = Foo{ .fun = bar };
+ var x = Foo{ .fun = @This().bar };
try expectError(error.UnspecifiedErr, x.fun(1));
}
};
diff --git a/test/behavior/eval.zig b/test/behavior/eval.zig
index 68537000cb..f86ee79761 100644
--- a/test/behavior/eval.zig
+++ b/test/behavior/eval.zig
@@ -415,8 +415,8 @@ test "f128 at compile time is lossy" {
try expect(@as(f128, 10384593717069655257060992658440192.0) + 1 == 10384593717069655257060992658440192.0);
}
-comptime {
- try expect(@as(f128, 1 << 113) == 10384593717069655257060992658440192);
+test {
+ comptime try expect(@as(f128, 1 << 113) == 10384593717069655257060992658440192);
}
pub fn TypeWithCompTimeSlice(comptime field_name: []const u8) type {
diff --git a/test/behavior/generics.zig b/test/behavior/generics.zig
index 2a4fabde45..104752607a 100644
--- a/test/behavior/generics.zig
+++ b/test/behavior/generics.zig
@@ -45,9 +45,9 @@ test "var params" {
try expect(max_f64(1.2, 3.4) == 3.4);
}
-comptime {
- try expect(max_i32(12, 34) == 34);
- try expect(max_f64(1.2, 3.4) == 3.4);
+test {
+ comptime try expect(max_i32(12, 34) == 34);
+ comptime try expect(max_f64(1.2, 3.4) == 3.4);
}
fn max_var(a: anytype, b: anytype) @TypeOf(a + b) {
diff --git a/test/behavior/misc.zig b/test/behavior/misc.zig
index e010644756..35f088eb4d 100644
--- a/test/behavior/misc.zig
+++ b/test/behavior/misc.zig
@@ -546,19 +546,15 @@ const PackedUnion = packed union {
a: u8,
b: u32,
};
-const PackedEnum = packed enum {
- A,
- B,
-};
test "packed struct, enum, union parameters in extern function" {
testPackedStuff(&(PackedStruct{
.a = 1,
.b = 2,
- }), &(PackedUnion{ .a = 1 }), PackedEnum.A);
+ }), &(PackedUnion{ .a = 1 }));
}
-export fn testPackedStuff(a: *const PackedStruct, b: *const PackedUnion, c: PackedEnum) void {}
+export fn testPackedStuff(a: *const PackedStruct, b: *const PackedUnion) void {}
test "slicing zero length array" {
const s1 = ""[0..];
diff --git a/test/behavior/syntax.zig b/test/behavior/syntax.zig
index 12df8a4315..6f75810f38 100644
--- a/test/behavior/syntax.zig
+++ b/test/behavior/syntax.zig
@@ -4,7 +4,7 @@
extern var a: c_int;
extern "c" var b: c_int;
export var c: c_int = 0;
-threadlocal var d: c_int;
+threadlocal var d: c_int = 0;
extern threadlocal var e: c_int;
extern "c" threadlocal var f: c_int;
export threadlocal var g: c_int = 0;
@@ -24,7 +24,6 @@ fn container_init() void {
fn type_expr_return1() if (true) A {}
fn type_expr_return2() for (true) |_| A {}
fn type_expr_return3() while (true) A {}
-fn type_expr_return4() comptime A {}
fn switch_cases(x: i32) void {
switch (x) {
diff --git a/test/behavior/type.zig b/test/behavior/type.zig
index 5fd89ab43c..5d12ea494f 100644
--- a/test/behavior/type.zig
+++ b/test/behavior/type.zig
@@ -410,7 +410,7 @@ test "Type.Union from Type.Enum" {
}
test "Type.Union from regular enum" {
- const E = enum { working_as_expected = 0 };
+ const E = enum { working_as_expected };
const T = @Type(.{
.Union = .{
.layout = .Auto,
diff --git a/test/behavior/union.zig b/test/behavior/union.zig
index cbc9a1212b..bcdd3fa247 100644
--- a/test/behavior/union.zig
+++ b/test/behavior/union.zig
@@ -776,7 +776,7 @@ test "@unionInit on union w/ tag but no fields" {
};
comptime {
- try expect(@sizeOf(Data) != 0);
+ std.debug.assert(@sizeOf(Data) != 0);
}
fn doTheTest() !void {