mirror of
https://github.com/ziglang/zig.git
synced 2024-11-28 08:02:32 +00:00
Merge pull request #15957 from BratishkaErik/deprecated-
std.*: remove stuff that was deprecated in older versions
This commit is contained in:
commit
38fc826a5a
@ -3306,7 +3306,7 @@ const Divided = packed struct {
|
||||
|
||||
test "@bitCast between packed structs" {
|
||||
try doTheTest();
|
||||
comptime try doTheTest();
|
||||
try comptime doTheTest();
|
||||
}
|
||||
|
||||
fn doTheTest() !void {
|
||||
@ -5815,10 +5815,10 @@ test "error union" {
|
||||
foo = error.SomeError;
|
||||
|
||||
// Use compile-time reflection to access the payload type of an error union:
|
||||
comptime try expect(@typeInfo(@TypeOf(foo)).ErrorUnion.payload == i32);
|
||||
try comptime expect(@typeInfo(@TypeOf(foo)).ErrorUnion.payload == i32);
|
||||
|
||||
// Use compile-time reflection to access the error set type of an error union:
|
||||
comptime try expect(@typeInfo(@TypeOf(foo)).ErrorUnion.error_set == anyerror);
|
||||
try comptime expect(@typeInfo(@TypeOf(foo)).ErrorUnion.error_set == anyerror);
|
||||
}
|
||||
{#code_end#}
|
||||
{#header_open|Merging Error Sets#}
|
||||
@ -6199,7 +6199,7 @@ test "optional type" {
|
||||
foo = 1234;
|
||||
|
||||
// Use compile-time reflection to access the child type of the optional:
|
||||
comptime try expect(@typeInfo(@TypeOf(foo)).Optional.child == i32);
|
||||
try comptime expect(@typeInfo(@TypeOf(foo)).Optional.child == i32);
|
||||
}
|
||||
{#code_end#}
|
||||
{#header_close#}
|
||||
@ -6632,8 +6632,8 @@ test "peer resolve int widening" {
|
||||
test "peer resolve arrays of different size to const slice" {
|
||||
try expect(mem.eql(u8, boolToStr(true), "true"));
|
||||
try expect(mem.eql(u8, boolToStr(false), "false"));
|
||||
comptime try expect(mem.eql(u8, boolToStr(true), "true"));
|
||||
comptime try expect(mem.eql(u8, boolToStr(false), "false"));
|
||||
try comptime expect(mem.eql(u8, boolToStr(true), "true"));
|
||||
try comptime expect(mem.eql(u8, boolToStr(false), "false"));
|
||||
}
|
||||
fn boolToStr(b: bool) []const u8 {
|
||||
return if (b) "true" else "false";
|
||||
@ -6641,7 +6641,7 @@ fn boolToStr(b: bool) []const u8 {
|
||||
|
||||
test "peer resolve array and const slice" {
|
||||
try testPeerResolveArrayConstSlice(true);
|
||||
comptime try testPeerResolveArrayConstSlice(true);
|
||||
try comptime testPeerResolveArrayConstSlice(true);
|
||||
}
|
||||
fn testPeerResolveArrayConstSlice(b: bool) !void {
|
||||
const value1 = if (b) "aoeu" else @as([]const u8, "zz");
|
||||
@ -9184,7 +9184,7 @@ const expect = std.testing.expect;
|
||||
test "vector @splat" {
|
||||
const scalar: u32 = 5;
|
||||
const result = @splat(4, scalar);
|
||||
comptime try expect(@TypeOf(result) == @Vector(4, u32));
|
||||
try comptime expect(@TypeOf(result) == @Vector(4, u32));
|
||||
try expect(std.mem.eql(u32, &@as([4]u32, result), &[_]u32{ 5, 5, 5, 5 }));
|
||||
}
|
||||
{#code_end#}
|
||||
@ -9228,9 +9228,9 @@ test "vector @reduce" {
|
||||
const value = @Vector(4, i32){ 1, -1, 1, -1 };
|
||||
const result = value > @splat(4, @as(i32, 0));
|
||||
// result is { true, false, true, false };
|
||||
comptime try expect(@TypeOf(result) == @Vector(4, bool));
|
||||
try comptime expect(@TypeOf(result) == @Vector(4, bool));
|
||||
const is_all_true = @reduce(.And, result);
|
||||
comptime try expect(@TypeOf(is_all_true) == bool);
|
||||
try comptime expect(@TypeOf(is_all_true) == bool);
|
||||
try expect(is_all_true == false);
|
||||
}
|
||||
{#code_end#}
|
||||
@ -9571,7 +9571,7 @@ const expect = std.testing.expect;
|
||||
test "no runtime side effects" {
|
||||
var data: i32 = 0;
|
||||
const T = @TypeOf(foo(i32, &data));
|
||||
comptime try expect(T == i32);
|
||||
try comptime expect(T == i32);
|
||||
try expect(data == 0);
|
||||
}
|
||||
|
||||
|
@ -32,17 +32,18 @@ fn test__powixf2(a: f80, b: i32, expected: f80) !void {
|
||||
}
|
||||
|
||||
test "powihf2" {
|
||||
const inf_f16 = math.inf(f16);
|
||||
try test__powisf2(0, 0, 1);
|
||||
try test__powihf2(1, 0, 1);
|
||||
try test__powihf2(1.5, 0, 1);
|
||||
try test__powihf2(2, 0, 1);
|
||||
try test__powihf2(math.inf_f16, 0, 1);
|
||||
try test__powihf2(inf_f16, 0, 1);
|
||||
|
||||
try test__powihf2(-0.0, 0, 1);
|
||||
try test__powihf2(-1, 0, 1);
|
||||
try test__powihf2(-1.5, 0, 1);
|
||||
try test__powihf2(-2, 0, 1);
|
||||
try test__powihf2(-math.inf_f16, 0, 1);
|
||||
try test__powihf2(-inf_f16, 0, 1);
|
||||
|
||||
try test__powihf2(0, 1, 0);
|
||||
try test__powihf2(0, 2, 0);
|
||||
@ -65,35 +66,35 @@ test "powihf2" {
|
||||
try test__powihf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFE)), 1);
|
||||
try test__powihf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFF)), 1);
|
||||
|
||||
try test__powihf2(math.inf_f16, 1, math.inf_f16);
|
||||
try test__powihf2(math.inf_f16, 2, math.inf_f16);
|
||||
try test__powihf2(math.inf_f16, 3, math.inf_f16);
|
||||
try test__powihf2(math.inf_f16, 4, math.inf_f16);
|
||||
try test__powihf2(math.inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f16);
|
||||
try test__powihf2(math.inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFF)), math.inf_f16);
|
||||
try test__powihf2(inf_f16, 1, inf_f16);
|
||||
try test__powihf2(inf_f16, 2, inf_f16);
|
||||
try test__powihf2(inf_f16, 3, inf_f16);
|
||||
try test__powihf2(inf_f16, 4, inf_f16);
|
||||
try test__powihf2(inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f16);
|
||||
try test__powihf2(inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFF)), inf_f16);
|
||||
|
||||
try test__powihf2(-math.inf_f16, 1, -math.inf_f16);
|
||||
try test__powihf2(-math.inf_f16, 2, math.inf_f16);
|
||||
try test__powihf2(-math.inf_f16, 3, -math.inf_f16);
|
||||
try test__powihf2(-math.inf_f16, 4, math.inf_f16);
|
||||
try test__powihf2(-math.inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f16);
|
||||
try test__powihf2(-math.inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -math.inf_f16);
|
||||
try test__powihf2(-inf_f16, 1, -inf_f16);
|
||||
try test__powihf2(-inf_f16, 2, inf_f16);
|
||||
try test__powihf2(-inf_f16, 3, -inf_f16);
|
||||
try test__powihf2(-inf_f16, 4, inf_f16);
|
||||
try test__powihf2(-inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f16);
|
||||
try test__powihf2(-inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -inf_f16);
|
||||
//
|
||||
try test__powihf2(0, -1, math.inf_f16);
|
||||
try test__powihf2(0, -2, math.inf_f16);
|
||||
try test__powihf2(0, -3, math.inf_f16);
|
||||
try test__powihf2(0, -4, math.inf_f16);
|
||||
try test__powihf2(0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f16); // 0 ^ anything = +inf
|
||||
try test__powihf2(0, @bitCast(i32, @as(u32, 0x80000001)), math.inf_f16);
|
||||
try test__powihf2(0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f16);
|
||||
try test__powihf2(0, -1, inf_f16);
|
||||
try test__powihf2(0, -2, inf_f16);
|
||||
try test__powihf2(0, -3, inf_f16);
|
||||
try test__powihf2(0, -4, inf_f16);
|
||||
try test__powihf2(0, @bitCast(i32, @as(u32, 0x80000002)), inf_f16); // 0 ^ anything = +inf
|
||||
try test__powihf2(0, @bitCast(i32, @as(u32, 0x80000001)), inf_f16);
|
||||
try test__powihf2(0, @bitCast(i32, @as(u32, 0x80000000)), inf_f16);
|
||||
|
||||
try test__powihf2(-0.0, -1, -math.inf_f16);
|
||||
try test__powihf2(-0.0, -2, math.inf_f16);
|
||||
try test__powihf2(-0.0, -3, -math.inf_f16);
|
||||
try test__powihf2(-0.0, -4, math.inf_f16);
|
||||
try test__powihf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f16); // -0 ^ anything even = +inf
|
||||
try test__powihf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -math.inf_f16); // -0 ^ anything odd = -inf
|
||||
try test__powihf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f16);
|
||||
try test__powihf2(-0.0, -1, -inf_f16);
|
||||
try test__powihf2(-0.0, -2, inf_f16);
|
||||
try test__powihf2(-0.0, -3, -inf_f16);
|
||||
try test__powihf2(-0.0, -4, inf_f16);
|
||||
try test__powihf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), inf_f16); // -0 ^ anything even = +inf
|
||||
try test__powihf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -inf_f16); // -0 ^ anything odd = -inf
|
||||
try test__powihf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), inf_f16);
|
||||
|
||||
try test__powihf2(1, -1, 1);
|
||||
try test__powihf2(1, -2, 1);
|
||||
@ -103,21 +104,21 @@ test "powihf2" {
|
||||
try test__powihf2(1, @bitCast(i32, @as(u32, 0x80000001)), 1);
|
||||
try test__powihf2(1, @bitCast(i32, @as(u32, 0x80000000)), 1);
|
||||
|
||||
try test__powihf2(math.inf_f16, -1, 0);
|
||||
try test__powihf2(math.inf_f16, -2, 0);
|
||||
try test__powihf2(math.inf_f16, -3, 0);
|
||||
try test__powihf2(math.inf_f16, -4, 0);
|
||||
try test__powihf2(math.inf_f16, @bitCast(i32, @as(u32, 0x80000002)), 0);
|
||||
try test__powihf2(math.inf_f16, @bitCast(i32, @as(u32, 0x80000001)), 0);
|
||||
try test__powihf2(math.inf_f16, @bitCast(i32, @as(u32, 0x80000000)), 0);
|
||||
try test__powihf2(inf_f16, -1, 0);
|
||||
try test__powihf2(inf_f16, -2, 0);
|
||||
try test__powihf2(inf_f16, -3, 0);
|
||||
try test__powihf2(inf_f16, -4, 0);
|
||||
try test__powihf2(inf_f16, @bitCast(i32, @as(u32, 0x80000002)), 0);
|
||||
try test__powihf2(inf_f16, @bitCast(i32, @as(u32, 0x80000001)), 0);
|
||||
try test__powihf2(inf_f16, @bitCast(i32, @as(u32, 0x80000000)), 0);
|
||||
//
|
||||
try test__powihf2(-math.inf_f16, -1, -0.0);
|
||||
try test__powihf2(-math.inf_f16, -2, 0);
|
||||
try test__powihf2(-math.inf_f16, -3, -0.0);
|
||||
try test__powihf2(-math.inf_f16, -4, 0);
|
||||
try test__powihf2(-math.inf_f16, @bitCast(i32, @as(u32, 0x80000002)), 0);
|
||||
try test__powihf2(-math.inf_f16, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
|
||||
try test__powihf2(-math.inf_f16, @bitCast(i32, @as(u32, 0x80000000)), 0);
|
||||
try test__powihf2(-inf_f16, -1, -0.0);
|
||||
try test__powihf2(-inf_f16, -2, 0);
|
||||
try test__powihf2(-inf_f16, -3, -0.0);
|
||||
try test__powihf2(-inf_f16, -4, 0);
|
||||
try test__powihf2(-inf_f16, @bitCast(i32, @as(u32, 0x80000002)), 0);
|
||||
try test__powihf2(-inf_f16, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
|
||||
try test__powihf2(-inf_f16, @bitCast(i32, @as(u32, 0x80000000)), 0);
|
||||
|
||||
try test__powihf2(2, 10, 1024.0);
|
||||
try test__powihf2(-2, 10, 1024.0);
|
||||
@ -128,8 +129,8 @@ test "powihf2" {
|
||||
try test__powihf2(-2, 14, 16384.0);
|
||||
try test__powihf2(2, 15, 32768.0);
|
||||
try test__powihf2(-2, 15, -32768.0);
|
||||
try test__powihf2(2, 16, math.inf_f16);
|
||||
try test__powihf2(-2, 16, math.inf_f16);
|
||||
try test__powihf2(2, 16, inf_f16);
|
||||
try test__powihf2(-2, 16, inf_f16);
|
||||
|
||||
try test__powihf2(2, -13, 1.0 / 8192.0);
|
||||
try test__powihf2(-2, -13, -1.0 / 8192.0);
|
||||
@ -140,17 +141,18 @@ test "powihf2" {
|
||||
}
|
||||
|
||||
test "powisf2" {
|
||||
const inf_f32 = math.inf(f32);
|
||||
try test__powisf2(0, 0, 1);
|
||||
try test__powisf2(1, 0, 1);
|
||||
try test__powisf2(1.5, 0, 1);
|
||||
try test__powisf2(2, 0, 1);
|
||||
try test__powisf2(math.inf_f32, 0, 1);
|
||||
try test__powisf2(inf_f32, 0, 1);
|
||||
|
||||
try test__powisf2(-0.0, 0, 1);
|
||||
try test__powisf2(-1, 0, 1);
|
||||
try test__powisf2(-1.5, 0, 1);
|
||||
try test__powisf2(-2, 0, 1);
|
||||
try test__powisf2(-math.inf_f32, 0, 1);
|
||||
try test__powisf2(-inf_f32, 0, 1);
|
||||
|
||||
try test__powisf2(0, 1, 0);
|
||||
try test__powisf2(0, 2, 0);
|
||||
@ -173,35 +175,35 @@ test "powisf2" {
|
||||
try test__powisf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFE)), 1);
|
||||
try test__powisf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFF)), 1);
|
||||
|
||||
try test__powisf2(math.inf_f32, 1, math.inf_f32);
|
||||
try test__powisf2(math.inf_f32, 2, math.inf_f32);
|
||||
try test__powisf2(math.inf_f32, 3, math.inf_f32);
|
||||
try test__powisf2(math.inf_f32, 4, math.inf_f32);
|
||||
try test__powisf2(math.inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f32);
|
||||
try test__powisf2(math.inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFF)), math.inf_f32);
|
||||
try test__powisf2(inf_f32, 1, inf_f32);
|
||||
try test__powisf2(inf_f32, 2, inf_f32);
|
||||
try test__powisf2(inf_f32, 3, inf_f32);
|
||||
try test__powisf2(inf_f32, 4, inf_f32);
|
||||
try test__powisf2(inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f32);
|
||||
try test__powisf2(inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFF)), inf_f32);
|
||||
|
||||
try test__powisf2(-math.inf_f32, 1, -math.inf_f32);
|
||||
try test__powisf2(-math.inf_f32, 2, math.inf_f32);
|
||||
try test__powisf2(-math.inf_f32, 3, -math.inf_f32);
|
||||
try test__powisf2(-math.inf_f32, 4, math.inf_f32);
|
||||
try test__powisf2(-math.inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f32);
|
||||
try test__powisf2(-math.inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -math.inf_f32);
|
||||
try test__powisf2(-inf_f32, 1, -inf_f32);
|
||||
try test__powisf2(-inf_f32, 2, inf_f32);
|
||||
try test__powisf2(-inf_f32, 3, -inf_f32);
|
||||
try test__powisf2(-inf_f32, 4, inf_f32);
|
||||
try test__powisf2(-inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f32);
|
||||
try test__powisf2(-inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -inf_f32);
|
||||
|
||||
try test__powisf2(0, -1, math.inf_f32);
|
||||
try test__powisf2(0, -2, math.inf_f32);
|
||||
try test__powisf2(0, -3, math.inf_f32);
|
||||
try test__powisf2(0, -4, math.inf_f32);
|
||||
try test__powisf2(0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f32);
|
||||
try test__powisf2(0, @bitCast(i32, @as(u32, 0x80000001)), math.inf_f32);
|
||||
try test__powisf2(0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f32);
|
||||
try test__powisf2(0, -1, inf_f32);
|
||||
try test__powisf2(0, -2, inf_f32);
|
||||
try test__powisf2(0, -3, inf_f32);
|
||||
try test__powisf2(0, -4, inf_f32);
|
||||
try test__powisf2(0, @bitCast(i32, @as(u32, 0x80000002)), inf_f32);
|
||||
try test__powisf2(0, @bitCast(i32, @as(u32, 0x80000001)), inf_f32);
|
||||
try test__powisf2(0, @bitCast(i32, @as(u32, 0x80000000)), inf_f32);
|
||||
|
||||
try test__powisf2(-0.0, -1, -math.inf_f32);
|
||||
try test__powisf2(-0.0, -2, math.inf_f32);
|
||||
try test__powisf2(-0.0, -3, -math.inf_f32);
|
||||
try test__powisf2(-0.0, -4, math.inf_f32);
|
||||
try test__powisf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f32);
|
||||
try test__powisf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -math.inf_f32);
|
||||
try test__powisf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f32);
|
||||
try test__powisf2(-0.0, -1, -inf_f32);
|
||||
try test__powisf2(-0.0, -2, inf_f32);
|
||||
try test__powisf2(-0.0, -3, -inf_f32);
|
||||
try test__powisf2(-0.0, -4, inf_f32);
|
||||
try test__powisf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), inf_f32);
|
||||
try test__powisf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -inf_f32);
|
||||
try test__powisf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), inf_f32);
|
||||
|
||||
try test__powisf2(1, -1, 1);
|
||||
try test__powisf2(1, -2, 1);
|
||||
@ -211,21 +213,21 @@ test "powisf2" {
|
||||
try test__powisf2(1, @bitCast(i32, @as(u32, 0x80000001)), 1);
|
||||
try test__powisf2(1, @bitCast(i32, @as(u32, 0x80000000)), 1);
|
||||
|
||||
try test__powisf2(math.inf_f32, -1, 0);
|
||||
try test__powisf2(math.inf_f32, -2, 0);
|
||||
try test__powisf2(math.inf_f32, -3, 0);
|
||||
try test__powisf2(math.inf_f32, -4, 0);
|
||||
try test__powisf2(math.inf_f32, @bitCast(i32, @as(u32, 0x80000002)), 0);
|
||||
try test__powisf2(math.inf_f32, @bitCast(i32, @as(u32, 0x80000001)), 0);
|
||||
try test__powisf2(math.inf_f32, @bitCast(i32, @as(u32, 0x80000000)), 0);
|
||||
try test__powisf2(inf_f32, -1, 0);
|
||||
try test__powisf2(inf_f32, -2, 0);
|
||||
try test__powisf2(inf_f32, -3, 0);
|
||||
try test__powisf2(inf_f32, -4, 0);
|
||||
try test__powisf2(inf_f32, @bitCast(i32, @as(u32, 0x80000002)), 0);
|
||||
try test__powisf2(inf_f32, @bitCast(i32, @as(u32, 0x80000001)), 0);
|
||||
try test__powisf2(inf_f32, @bitCast(i32, @as(u32, 0x80000000)), 0);
|
||||
|
||||
try test__powisf2(-math.inf_f32, -1, -0.0);
|
||||
try test__powisf2(-math.inf_f32, -2, 0);
|
||||
try test__powisf2(-math.inf_f32, -3, -0.0);
|
||||
try test__powisf2(-math.inf_f32, -4, 0);
|
||||
try test__powisf2(-math.inf_f32, @bitCast(i32, @as(u32, 0x80000002)), 0);
|
||||
try test__powisf2(-math.inf_f32, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
|
||||
try test__powisf2(-math.inf_f32, @bitCast(i32, @as(u32, 0x80000000)), 0);
|
||||
try test__powisf2(-inf_f32, -1, -0.0);
|
||||
try test__powisf2(-inf_f32, -2, 0);
|
||||
try test__powisf2(-inf_f32, -3, -0.0);
|
||||
try test__powisf2(-inf_f32, -4, 0);
|
||||
try test__powisf2(-inf_f32, @bitCast(i32, @as(u32, 0x80000002)), 0);
|
||||
try test__powisf2(-inf_f32, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
|
||||
try test__powisf2(-inf_f32, @bitCast(i32, @as(u32, 0x80000000)), 0);
|
||||
|
||||
try test__powisf2(2.0, 10, 1024.0);
|
||||
try test__powisf2(-2, 10, 1024.0);
|
||||
@ -244,17 +246,18 @@ test "powisf2" {
|
||||
}
|
||||
|
||||
test "powidf2" {
|
||||
const inf_f64 = math.inf(f64);
|
||||
try test__powidf2(0, 0, 1);
|
||||
try test__powidf2(1, 0, 1);
|
||||
try test__powidf2(1.5, 0, 1);
|
||||
try test__powidf2(2, 0, 1);
|
||||
try test__powidf2(math.inf_f64, 0, 1);
|
||||
try test__powidf2(inf_f64, 0, 1);
|
||||
|
||||
try test__powidf2(-0.0, 0, 1);
|
||||
try test__powidf2(-1, 0, 1);
|
||||
try test__powidf2(-1.5, 0, 1);
|
||||
try test__powidf2(-2, 0, 1);
|
||||
try test__powidf2(-math.inf_f64, 0, 1);
|
||||
try test__powidf2(-inf_f64, 0, 1);
|
||||
|
||||
try test__powidf2(0, 1, 0);
|
||||
try test__powidf2(0, 2, 0);
|
||||
@ -277,35 +280,35 @@ test "powidf2" {
|
||||
try test__powidf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFE)), 1);
|
||||
try test__powidf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFF)), 1);
|
||||
|
||||
try test__powidf2(math.inf_f64, 1, math.inf_f64);
|
||||
try test__powidf2(math.inf_f64, 2, math.inf_f64);
|
||||
try test__powidf2(math.inf_f64, 3, math.inf_f64);
|
||||
try test__powidf2(math.inf_f64, 4, math.inf_f64);
|
||||
try test__powidf2(math.inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f64);
|
||||
try test__powidf2(math.inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFF)), math.inf_f64);
|
||||
try test__powidf2(inf_f64, 1, inf_f64);
|
||||
try test__powidf2(inf_f64, 2, inf_f64);
|
||||
try test__powidf2(inf_f64, 3, inf_f64);
|
||||
try test__powidf2(inf_f64, 4, inf_f64);
|
||||
try test__powidf2(inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f64);
|
||||
try test__powidf2(inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFF)), inf_f64);
|
||||
|
||||
try test__powidf2(-math.inf_f64, 1, -math.inf_f64);
|
||||
try test__powidf2(-math.inf_f64, 2, math.inf_f64);
|
||||
try test__powidf2(-math.inf_f64, 3, -math.inf_f64);
|
||||
try test__powidf2(-math.inf_f64, 4, math.inf_f64);
|
||||
try test__powidf2(-math.inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f64);
|
||||
try test__powidf2(-math.inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -math.inf_f64);
|
||||
try test__powidf2(-inf_f64, 1, -inf_f64);
|
||||
try test__powidf2(-inf_f64, 2, inf_f64);
|
||||
try test__powidf2(-inf_f64, 3, -inf_f64);
|
||||
try test__powidf2(-inf_f64, 4, inf_f64);
|
||||
try test__powidf2(-inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f64);
|
||||
try test__powidf2(-inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -inf_f64);
|
||||
|
||||
try test__powidf2(0, -1, math.inf_f64);
|
||||
try test__powidf2(0, -2, math.inf_f64);
|
||||
try test__powidf2(0, -3, math.inf_f64);
|
||||
try test__powidf2(0, -4, math.inf_f64);
|
||||
try test__powidf2(0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f64);
|
||||
try test__powidf2(0, @bitCast(i32, @as(u32, 0x80000001)), math.inf_f64);
|
||||
try test__powidf2(0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f64);
|
||||
try test__powidf2(0, -1, inf_f64);
|
||||
try test__powidf2(0, -2, inf_f64);
|
||||
try test__powidf2(0, -3, inf_f64);
|
||||
try test__powidf2(0, -4, inf_f64);
|
||||
try test__powidf2(0, @bitCast(i32, @as(u32, 0x80000002)), inf_f64);
|
||||
try test__powidf2(0, @bitCast(i32, @as(u32, 0x80000001)), inf_f64);
|
||||
try test__powidf2(0, @bitCast(i32, @as(u32, 0x80000000)), inf_f64);
|
||||
|
||||
try test__powidf2(-0.0, -1, -math.inf_f64);
|
||||
try test__powidf2(-0.0, -2, math.inf_f64);
|
||||
try test__powidf2(-0.0, -3, -math.inf_f64);
|
||||
try test__powidf2(-0.0, -4, math.inf_f64);
|
||||
try test__powidf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f64);
|
||||
try test__powidf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -math.inf_f64);
|
||||
try test__powidf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f64);
|
||||
try test__powidf2(-0.0, -1, -inf_f64);
|
||||
try test__powidf2(-0.0, -2, inf_f64);
|
||||
try test__powidf2(-0.0, -3, -inf_f64);
|
||||
try test__powidf2(-0.0, -4, inf_f64);
|
||||
try test__powidf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), inf_f64);
|
||||
try test__powidf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -inf_f64);
|
||||
try test__powidf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), inf_f64);
|
||||
|
||||
try test__powidf2(1, -1, 1);
|
||||
try test__powidf2(1, -2, 1);
|
||||
@ -315,21 +318,21 @@ test "powidf2" {
|
||||
try test__powidf2(1, @bitCast(i32, @as(u32, 0x80000001)), 1);
|
||||
try test__powidf2(1, @bitCast(i32, @as(u32, 0x80000000)), 1);
|
||||
|
||||
try test__powidf2(math.inf_f64, -1, 0);
|
||||
try test__powidf2(math.inf_f64, -2, 0);
|
||||
try test__powidf2(math.inf_f64, -3, 0);
|
||||
try test__powidf2(math.inf_f64, -4, 0);
|
||||
try test__powidf2(math.inf_f64, @bitCast(i32, @as(u32, 0x80000002)), 0);
|
||||
try test__powidf2(math.inf_f64, @bitCast(i32, @as(u32, 0x80000001)), 0);
|
||||
try test__powidf2(math.inf_f64, @bitCast(i32, @as(u32, 0x80000000)), 0);
|
||||
try test__powidf2(inf_f64, -1, 0);
|
||||
try test__powidf2(inf_f64, -2, 0);
|
||||
try test__powidf2(inf_f64, -3, 0);
|
||||
try test__powidf2(inf_f64, -4, 0);
|
||||
try test__powidf2(inf_f64, @bitCast(i32, @as(u32, 0x80000002)), 0);
|
||||
try test__powidf2(inf_f64, @bitCast(i32, @as(u32, 0x80000001)), 0);
|
||||
try test__powidf2(inf_f64, @bitCast(i32, @as(u32, 0x80000000)), 0);
|
||||
|
||||
try test__powidf2(-math.inf_f64, -1, -0.0);
|
||||
try test__powidf2(-math.inf_f64, -2, 0);
|
||||
try test__powidf2(-math.inf_f64, -3, -0.0);
|
||||
try test__powidf2(-math.inf_f64, -4, 0);
|
||||
try test__powidf2(-math.inf_f64, @bitCast(i32, @as(u32, 0x80000002)), 0);
|
||||
try test__powidf2(-math.inf_f64, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
|
||||
try test__powidf2(-math.inf_f64, @bitCast(i32, @as(u32, 0x80000000)), 0);
|
||||
try test__powidf2(-inf_f64, -1, -0.0);
|
||||
try test__powidf2(-inf_f64, -2, 0);
|
||||
try test__powidf2(-inf_f64, -3, -0.0);
|
||||
try test__powidf2(-inf_f64, -4, 0);
|
||||
try test__powidf2(-inf_f64, @bitCast(i32, @as(u32, 0x80000002)), 0);
|
||||
try test__powidf2(-inf_f64, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
|
||||
try test__powidf2(-inf_f64, @bitCast(i32, @as(u32, 0x80000000)), 0);
|
||||
|
||||
try test__powidf2(2, 10, 1024.0);
|
||||
try test__powidf2(-2, 10, 1024.0);
|
||||
@ -348,17 +351,18 @@ test "powidf2" {
|
||||
}
|
||||
|
||||
test "powitf2" {
|
||||
const inf_f128 = math.inf(f128);
|
||||
try test__powitf2(0, 0, 1);
|
||||
try test__powitf2(1, 0, 1);
|
||||
try test__powitf2(1.5, 0, 1);
|
||||
try test__powitf2(2, 0, 1);
|
||||
try test__powitf2(math.inf_f128, 0, 1);
|
||||
try test__powitf2(inf_f128, 0, 1);
|
||||
|
||||
try test__powitf2(-0.0, 0, 1);
|
||||
try test__powitf2(-1, 0, 1);
|
||||
try test__powitf2(-1.5, 0, 1);
|
||||
try test__powitf2(-2, 0, 1);
|
||||
try test__powitf2(-math.inf_f128, 0, 1);
|
||||
try test__powitf2(-inf_f128, 0, 1);
|
||||
|
||||
try test__powitf2(0, 1, 0);
|
||||
try test__powitf2(0, 2, 0);
|
||||
@ -381,35 +385,35 @@ test "powitf2" {
|
||||
try test__powitf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFE)), 1);
|
||||
try test__powitf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFF)), 1);
|
||||
|
||||
try test__powitf2(math.inf_f128, 1, math.inf_f128);
|
||||
try test__powitf2(math.inf_f128, 2, math.inf_f128);
|
||||
try test__powitf2(math.inf_f128, 3, math.inf_f128);
|
||||
try test__powitf2(math.inf_f128, 4, math.inf_f128);
|
||||
try test__powitf2(math.inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f128);
|
||||
try test__powitf2(math.inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFF)), math.inf_f128);
|
||||
try test__powitf2(inf_f128, 1, inf_f128);
|
||||
try test__powitf2(inf_f128, 2, inf_f128);
|
||||
try test__powitf2(inf_f128, 3, inf_f128);
|
||||
try test__powitf2(inf_f128, 4, inf_f128);
|
||||
try test__powitf2(inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f128);
|
||||
try test__powitf2(inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFF)), inf_f128);
|
||||
|
||||
try test__powitf2(-math.inf_f128, 1, -math.inf_f128);
|
||||
try test__powitf2(-math.inf_f128, 2, math.inf_f128);
|
||||
try test__powitf2(-math.inf_f128, 3, -math.inf_f128);
|
||||
try test__powitf2(-math.inf_f128, 4, math.inf_f128);
|
||||
try test__powitf2(-math.inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f128);
|
||||
try test__powitf2(-math.inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -math.inf_f128);
|
||||
try test__powitf2(-inf_f128, 1, -inf_f128);
|
||||
try test__powitf2(-inf_f128, 2, inf_f128);
|
||||
try test__powitf2(-inf_f128, 3, -inf_f128);
|
||||
try test__powitf2(-inf_f128, 4, inf_f128);
|
||||
try test__powitf2(-inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f128);
|
||||
try test__powitf2(-inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -inf_f128);
|
||||
|
||||
try test__powitf2(0, -1, math.inf_f128);
|
||||
try test__powitf2(0, -2, math.inf_f128);
|
||||
try test__powitf2(0, -3, math.inf_f128);
|
||||
try test__powitf2(0, -4, math.inf_f128);
|
||||
try test__powitf2(0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f128);
|
||||
try test__powitf2(0, @bitCast(i32, @as(u32, 0x80000001)), math.inf_f128);
|
||||
try test__powitf2(0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f128);
|
||||
try test__powitf2(0, -1, inf_f128);
|
||||
try test__powitf2(0, -2, inf_f128);
|
||||
try test__powitf2(0, -3, inf_f128);
|
||||
try test__powitf2(0, -4, inf_f128);
|
||||
try test__powitf2(0, @bitCast(i32, @as(u32, 0x80000002)), inf_f128);
|
||||
try test__powitf2(0, @bitCast(i32, @as(u32, 0x80000001)), inf_f128);
|
||||
try test__powitf2(0, @bitCast(i32, @as(u32, 0x80000000)), inf_f128);
|
||||
|
||||
try test__powitf2(-0.0, -1, -math.inf_f128);
|
||||
try test__powitf2(-0.0, -2, math.inf_f128);
|
||||
try test__powitf2(-0.0, -3, -math.inf_f128);
|
||||
try test__powitf2(-0.0, -4, math.inf_f128);
|
||||
try test__powitf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f128);
|
||||
try test__powitf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -math.inf_f128);
|
||||
try test__powitf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f128);
|
||||
try test__powitf2(-0.0, -1, -inf_f128);
|
||||
try test__powitf2(-0.0, -2, inf_f128);
|
||||
try test__powitf2(-0.0, -3, -inf_f128);
|
||||
try test__powitf2(-0.0, -4, inf_f128);
|
||||
try test__powitf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), inf_f128);
|
||||
try test__powitf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -inf_f128);
|
||||
try test__powitf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), inf_f128);
|
||||
|
||||
try test__powitf2(1, -1, 1);
|
||||
try test__powitf2(1, -2, 1);
|
||||
@ -419,21 +423,21 @@ test "powitf2" {
|
||||
try test__powitf2(1, @bitCast(i32, @as(u32, 0x80000001)), 1);
|
||||
try test__powitf2(1, @bitCast(i32, @as(u32, 0x80000000)), 1);
|
||||
|
||||
try test__powitf2(math.inf_f128, -1, 0);
|
||||
try test__powitf2(math.inf_f128, -2, 0);
|
||||
try test__powitf2(math.inf_f128, -3, 0);
|
||||
try test__powitf2(math.inf_f128, -4, 0);
|
||||
try test__powitf2(math.inf_f128, @bitCast(i32, @as(u32, 0x80000002)), 0);
|
||||
try test__powitf2(math.inf_f128, @bitCast(i32, @as(u32, 0x80000001)), 0);
|
||||
try test__powitf2(math.inf_f128, @bitCast(i32, @as(u32, 0x80000000)), 0);
|
||||
try test__powitf2(inf_f128, -1, 0);
|
||||
try test__powitf2(inf_f128, -2, 0);
|
||||
try test__powitf2(inf_f128, -3, 0);
|
||||
try test__powitf2(inf_f128, -4, 0);
|
||||
try test__powitf2(inf_f128, @bitCast(i32, @as(u32, 0x80000002)), 0);
|
||||
try test__powitf2(inf_f128, @bitCast(i32, @as(u32, 0x80000001)), 0);
|
||||
try test__powitf2(inf_f128, @bitCast(i32, @as(u32, 0x80000000)), 0);
|
||||
|
||||
try test__powitf2(-math.inf_f128, -1, -0.0);
|
||||
try test__powitf2(-math.inf_f128, -2, 0);
|
||||
try test__powitf2(-math.inf_f128, -3, -0.0);
|
||||
try test__powitf2(-math.inf_f128, -4, 0);
|
||||
try test__powitf2(-math.inf_f128, @bitCast(i32, @as(u32, 0x80000002)), 0);
|
||||
try test__powitf2(-math.inf_f128, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
|
||||
try test__powitf2(-math.inf_f128, @bitCast(i32, @as(u32, 0x80000000)), 0);
|
||||
try test__powitf2(-inf_f128, -1, -0.0);
|
||||
try test__powitf2(-inf_f128, -2, 0);
|
||||
try test__powitf2(-inf_f128, -3, -0.0);
|
||||
try test__powitf2(-inf_f128, -4, 0);
|
||||
try test__powitf2(-inf_f128, @bitCast(i32, @as(u32, 0x80000002)), 0);
|
||||
try test__powitf2(-inf_f128, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
|
||||
try test__powitf2(-inf_f128, @bitCast(i32, @as(u32, 0x80000000)), 0);
|
||||
|
||||
try test__powitf2(2, 10, 1024.0);
|
||||
try test__powitf2(-2, 10, 1024.0);
|
||||
@ -452,17 +456,18 @@ test "powitf2" {
|
||||
}
|
||||
|
||||
test "powixf2" {
|
||||
const inf_f80 = math.inf(f80);
|
||||
try test__powixf2(0, 0, 1);
|
||||
try test__powixf2(1, 0, 1);
|
||||
try test__powixf2(1.5, 0, 1);
|
||||
try test__powixf2(2, 0, 1);
|
||||
try test__powixf2(math.inf_f80, 0, 1);
|
||||
try test__powixf2(inf_f80, 0, 1);
|
||||
|
||||
try test__powixf2(-0.0, 0, 1);
|
||||
try test__powixf2(-1, 0, 1);
|
||||
try test__powixf2(-1.5, 0, 1);
|
||||
try test__powixf2(-2, 0, 1);
|
||||
try test__powixf2(-math.inf_f80, 0, 1);
|
||||
try test__powixf2(-inf_f80, 0, 1);
|
||||
|
||||
try test__powixf2(0, 1, 0);
|
||||
try test__powixf2(0, 2, 0);
|
||||
@ -485,35 +490,35 @@ test "powixf2" {
|
||||
try test__powixf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFE)), 1);
|
||||
try test__powixf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFF)), 1);
|
||||
|
||||
try test__powixf2(math.inf_f80, 1, math.inf_f80);
|
||||
try test__powixf2(math.inf_f80, 2, math.inf_f80);
|
||||
try test__powixf2(math.inf_f80, 3, math.inf_f80);
|
||||
try test__powixf2(math.inf_f80, 4, math.inf_f80);
|
||||
try test__powixf2(math.inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f80);
|
||||
try test__powixf2(math.inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFF)), math.inf_f80);
|
||||
try test__powixf2(inf_f80, 1, inf_f80);
|
||||
try test__powixf2(inf_f80, 2, inf_f80);
|
||||
try test__powixf2(inf_f80, 3, inf_f80);
|
||||
try test__powixf2(inf_f80, 4, inf_f80);
|
||||
try test__powixf2(inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f80);
|
||||
try test__powixf2(inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFF)), inf_f80);
|
||||
|
||||
try test__powixf2(-math.inf_f80, 1, -math.inf_f80);
|
||||
try test__powixf2(-math.inf_f80, 2, math.inf_f80);
|
||||
try test__powixf2(-math.inf_f80, 3, -math.inf_f80);
|
||||
try test__powixf2(-math.inf_f80, 4, math.inf_f80);
|
||||
try test__powixf2(-math.inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f80);
|
||||
try test__powixf2(-math.inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -math.inf_f80);
|
||||
try test__powixf2(-inf_f80, 1, -inf_f80);
|
||||
try test__powixf2(-inf_f80, 2, inf_f80);
|
||||
try test__powixf2(-inf_f80, 3, -inf_f80);
|
||||
try test__powixf2(-inf_f80, 4, inf_f80);
|
||||
try test__powixf2(-inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f80);
|
||||
try test__powixf2(-inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -inf_f80);
|
||||
|
||||
try test__powixf2(0, -1, math.inf_f80);
|
||||
try test__powixf2(0, -2, math.inf_f80);
|
||||
try test__powixf2(0, -3, math.inf_f80);
|
||||
try test__powixf2(0, -4, math.inf_f80);
|
||||
try test__powixf2(0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f80);
|
||||
try test__powixf2(0, @bitCast(i32, @as(u32, 0x80000001)), math.inf_f80);
|
||||
try test__powixf2(0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f80);
|
||||
try test__powixf2(0, -1, inf_f80);
|
||||
try test__powixf2(0, -2, inf_f80);
|
||||
try test__powixf2(0, -3, inf_f80);
|
||||
try test__powixf2(0, -4, inf_f80);
|
||||
try test__powixf2(0, @bitCast(i32, @as(u32, 0x80000002)), inf_f80);
|
||||
try test__powixf2(0, @bitCast(i32, @as(u32, 0x80000001)), inf_f80);
|
||||
try test__powixf2(0, @bitCast(i32, @as(u32, 0x80000000)), inf_f80);
|
||||
|
||||
try test__powixf2(-0.0, -1, -math.inf_f80);
|
||||
try test__powixf2(-0.0, -2, math.inf_f80);
|
||||
try test__powixf2(-0.0, -3, -math.inf_f80);
|
||||
try test__powixf2(-0.0, -4, math.inf_f80);
|
||||
try test__powixf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f80);
|
||||
try test__powixf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -math.inf_f80);
|
||||
try test__powixf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f80);
|
||||
try test__powixf2(-0.0, -1, -inf_f80);
|
||||
try test__powixf2(-0.0, -2, inf_f80);
|
||||
try test__powixf2(-0.0, -3, -inf_f80);
|
||||
try test__powixf2(-0.0, -4, inf_f80);
|
||||
try test__powixf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), inf_f80);
|
||||
try test__powixf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -inf_f80);
|
||||
try test__powixf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), inf_f80);
|
||||
|
||||
try test__powixf2(1, -1, 1);
|
||||
try test__powixf2(1, -2, 1);
|
||||
@ -523,21 +528,21 @@ test "powixf2" {
|
||||
try test__powixf2(1, @bitCast(i32, @as(u32, 0x80000001)), 1);
|
||||
try test__powixf2(1, @bitCast(i32, @as(u32, 0x80000000)), 1);
|
||||
|
||||
try test__powixf2(math.inf_f80, -1, 0);
|
||||
try test__powixf2(math.inf_f80, -2, 0);
|
||||
try test__powixf2(math.inf_f80, -3, 0);
|
||||
try test__powixf2(math.inf_f80, -4, 0);
|
||||
try test__powixf2(math.inf_f80, @bitCast(i32, @as(u32, 0x80000002)), 0);
|
||||
try test__powixf2(math.inf_f80, @bitCast(i32, @as(u32, 0x80000001)), 0);
|
||||
try test__powixf2(math.inf_f80, @bitCast(i32, @as(u32, 0x80000000)), 0);
|
||||
try test__powixf2(inf_f80, -1, 0);
|
||||
try test__powixf2(inf_f80, -2, 0);
|
||||
try test__powixf2(inf_f80, -3, 0);
|
||||
try test__powixf2(inf_f80, -4, 0);
|
||||
try test__powixf2(inf_f80, @bitCast(i32, @as(u32, 0x80000002)), 0);
|
||||
try test__powixf2(inf_f80, @bitCast(i32, @as(u32, 0x80000001)), 0);
|
||||
try test__powixf2(inf_f80, @bitCast(i32, @as(u32, 0x80000000)), 0);
|
||||
|
||||
try test__powixf2(-math.inf_f80, -1, -0.0);
|
||||
try test__powixf2(-math.inf_f80, -2, 0);
|
||||
try test__powixf2(-math.inf_f80, -3, -0.0);
|
||||
try test__powixf2(-math.inf_f80, -4, 0);
|
||||
try test__powixf2(-math.inf_f80, @bitCast(i32, @as(u32, 0x80000002)), 0);
|
||||
try test__powixf2(-math.inf_f80, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
|
||||
try test__powixf2(-math.inf_f80, @bitCast(i32, @as(u32, 0x80000000)), 0);
|
||||
try test__powixf2(-inf_f80, -1, -0.0);
|
||||
try test__powixf2(-inf_f80, -2, 0);
|
||||
try test__powixf2(-inf_f80, -3, -0.0);
|
||||
try test__powixf2(-inf_f80, -4, 0);
|
||||
try test__powixf2(-inf_f80, @bitCast(i32, @as(u32, 0x80000002)), 0);
|
||||
try test__powixf2(-inf_f80, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
|
||||
try test__powixf2(-inf_f80, @bitCast(i32, @as(u32, 0x80000000)), 0);
|
||||
|
||||
try test__powixf2(2, 10, 1024.0);
|
||||
try test__powixf2(-2, 10, 1024.0);
|
||||
|
@ -1032,11 +1032,6 @@ pub fn addObject(self: *Compile, obj: *Compile) void {
|
||||
self.linkLibraryOrObject(obj);
|
||||
}
|
||||
|
||||
pub const addSystemIncludeDir = @compileError("deprecated; use addSystemIncludePath");
|
||||
pub const addIncludeDir = @compileError("deprecated; use addIncludePath");
|
||||
pub const addLibPath = @compileError("deprecated, use addLibraryPath");
|
||||
pub const addFrameworkDir = @compileError("deprecated, use addFrameworkPath");
|
||||
|
||||
pub fn addSystemIncludePath(self: *Compile, path: []const u8) void {
|
||||
const b = self.step.owner;
|
||||
self.include_dirs.append(IncludeDir{ .raw_path_system = b.dupe(path) }) catch @panic("OOM");
|
||||
|
@ -302,7 +302,7 @@ pub const Base64DecoderWithIgnore = struct {
|
||||
test "base64" {
|
||||
@setEvalBranchQuota(8000);
|
||||
try testBase64();
|
||||
comptime try testAllApis(standard, "comptime", "Y29tcHRpbWU=");
|
||||
try comptime testAllApis(standard, "comptime", "Y29tcHRpbWU=");
|
||||
}
|
||||
|
||||
test "base64 padding dest overflow" {
|
||||
@ -322,7 +322,7 @@ test "base64 padding dest overflow" {
|
||||
test "base64 url_safe_no_pad" {
|
||||
@setEvalBranchQuota(8000);
|
||||
try testBase64UrlSafeNoPad();
|
||||
comptime try testAllApis(url_safe_no_pad, "comptime", "Y29tcHRpbWU");
|
||||
try comptime testAllApis(url_safe_no_pad, "comptime", "Y29tcHRpbWU");
|
||||
}
|
||||
|
||||
fn testBase64() !void {
|
||||
|
@ -221,7 +221,6 @@ pub const SourceLocation = struct {
|
||||
};
|
||||
|
||||
pub const TypeId = std.meta.Tag(Type);
|
||||
pub const TypeInfo = @compileError("deprecated; use Type");
|
||||
|
||||
/// This data structure is used by the Zig language code generation and
|
||||
/// therefore must be kept in sync with the compiler implementation.
|
||||
@ -388,8 +387,6 @@ pub const Type = union(enum) {
|
||||
decls: []const Declaration,
|
||||
};
|
||||
|
||||
pub const FnArg = @compileError("deprecated; use Fn.Param");
|
||||
|
||||
/// This data structure is used by the Zig language code generation and
|
||||
/// therefore must be kept in sync with the compiler implementation.
|
||||
pub const Fn = struct {
|
||||
|
@ -480,13 +480,7 @@ pub const Ed25519 = struct {
|
||||
hx.final(&blind_h);
|
||||
return blind_h;
|
||||
}
|
||||
|
||||
pub const sign = @compileError("deprecated; use BlindKeyPair.sign instead");
|
||||
pub const unblindPublicKey = @compileError("deprecated; use BlindPublicKey.unblind instead");
|
||||
};
|
||||
|
||||
pub const sign = @compileError("deprecated; use KeyPair.sign instead");
|
||||
pub const verify = @compileError("deprecated; use PublicKey.verify instead");
|
||||
};
|
||||
|
||||
test "ed25519 key pair creation" {
|
||||
|
@ -22,7 +22,7 @@ pub fn cmp(a: [*:0]const u8, b: [*:0]const u8) i8 {
|
||||
}
|
||||
|
||||
test "cstr fns" {
|
||||
comptime try testCStrFnsImpl();
|
||||
try comptime testCStrFnsImpl();
|
||||
try testCStrFnsImpl();
|
||||
}
|
||||
|
||||
|
@ -81,8 +81,6 @@ const PdbOrDwarf = union(enum) {
|
||||
|
||||
var stderr_mutex = std.Thread.Mutex{};
|
||||
|
||||
pub const warn = @compileError("deprecated; use `std.log` functions for logging or `std.debug.print` for 'printf debugging'");
|
||||
|
||||
/// Print to stderr, unbuffered, and silently returning on failure. Intended
|
||||
/// for use in "printf debugging." Use `std.log` functions for proper logging.
|
||||
pub fn print(comptime fmt: []const u8, args: anytype) void {
|
||||
|
@ -117,8 +117,6 @@ pub fn LinearFifo(
|
||||
}
|
||||
}
|
||||
|
||||
pub const ensureCapacity = @compileError("deprecated; call `ensureUnusedCapacity` or `ensureTotalCapacity`");
|
||||
|
||||
/// Ensure that the buffer can fit at least `size` items
|
||||
pub fn ensureTotalCapacity(self: *Self, size: usize) !void {
|
||||
if (self.buf.len >= size) return;
|
||||
|
@ -727,12 +727,6 @@ fn formatValue(
|
||||
options: FormatOptions,
|
||||
writer: anytype,
|
||||
) !void {
|
||||
if (comptime std.mem.eql(u8, fmt, "B")) {
|
||||
@compileError("specifier 'B' has been deprecated, wrap your argument in std.fmt.fmtIntSizeDec instead");
|
||||
} else if (comptime std.mem.eql(u8, fmt, "Bi")) {
|
||||
@compileError("specifier 'Bi' has been deprecated, wrap your argument in std.fmt.fmtIntSizeBin instead");
|
||||
}
|
||||
|
||||
const T = @TypeOf(value);
|
||||
switch (@typeInfo(T)) {
|
||||
.Float, .ComptimeFloat => return formatFloatValue(value, fmt, options, writer),
|
||||
@ -977,12 +971,10 @@ fn checkTextFmt(comptime fmt: []const u8) void {
|
||||
if (fmt.len != 1)
|
||||
@compileError("unsupported format string '" ++ fmt ++ "' when formatting text");
|
||||
switch (fmt[0]) {
|
||||
// Example of deprecation:
|
||||
// '[deprecated_specifier]' => @compileError("specifier '[deprecated_specifier]' has been deprecated, wrap your argument in `std.some_function` instead"),
|
||||
'x' => @compileError("specifier 'x' has been deprecated, wrap your argument in std.fmt.fmtSliceHexLower instead"),
|
||||
'X' => @compileError("specifier 'X' has been deprecated, wrap your argument in std.fmt.fmtSliceHexUpper instead"),
|
||||
'e' => @compileError("specifier 'e' has been deprecated, wrap your argument in std.fmt.fmtSliceEscapeLower instead"),
|
||||
'E' => @compileError("specifier 'E' has been deprecated, wrap your argument in std.fmt.fmtSliceEscapeUpper instead"),
|
||||
'z' => @compileError("specifier 'z' has been deprecated, wrap your argument in std.zig.fmtId instead"),
|
||||
'Z' => @compileError("specifier 'Z' has been deprecated, wrap your argument in std.zig.fmtEscapes instead"),
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
|
@ -408,13 +408,13 @@ test "testHash union" {
|
||||
}
|
||||
|
||||
test "testHash vector" {
|
||||
const a: meta.Vector(4, u32) = [_]u32{ 1, 2, 3, 4 };
|
||||
const b: meta.Vector(4, u32) = [_]u32{ 1, 2, 3, 5 };
|
||||
const a: @Vector(4, u32) = [_]u32{ 1, 2, 3, 4 };
|
||||
const b: @Vector(4, u32) = [_]u32{ 1, 2, 3, 5 };
|
||||
try testing.expect(testHash(a) == testHash(a));
|
||||
try testing.expect(testHash(a) != testHash(b));
|
||||
|
||||
const c: meta.Vector(4, u31) = [_]u31{ 1, 2, 3, 4 };
|
||||
const d: meta.Vector(4, u31) = [_]u31{ 1, 2, 3, 5 };
|
||||
const c: @Vector(4, u31) = [_]u31{ 1, 2, 3, 4 };
|
||||
const d: @Vector(4, u31) = [_]u31{ 1, 2, 3, 5 };
|
||||
try testing.expect(testHash(c) == testHash(c));
|
||||
try testing.expect(testHash(c) != testHash(d));
|
||||
}
|
||||
|
@ -148,9 +148,6 @@ pub const changeDetectionStream = @import("io/change_detection_stream.zig").chan
|
||||
pub const FindByteWriter = @import("io/find_byte_writer.zig").FindByteWriter;
|
||||
pub const findByteWriter = @import("io/find_byte_writer.zig").findByteWriter;
|
||||
|
||||
pub const FindByteOutStream = @compileError("deprecated; use `FindByteWriter`");
|
||||
pub const findByteOutStream = @compileError("deprecated; use `findByteWriter`");
|
||||
|
||||
pub const BufferedAtomicFile = @import("io/buffered_atomic_file.zig").BufferedAtomicFile;
|
||||
|
||||
pub const StreamSource = @import("io/stream_source.zig").StreamSource;
|
||||
|
185
lib/std/math.zig
185
lib/std/math.zig
@ -48,43 +48,41 @@ pub const floatMax = @import("math/float.zig").floatMax;
|
||||
pub const floatEps = @import("math/float.zig").floatEps;
|
||||
pub const inf = @import("math/float.zig").inf;
|
||||
|
||||
// TODO Replace with @compileError("deprecated for foobar") after 0.10.0 is released.
|
||||
pub const f16_true_min: comptime_float = floatTrueMin(f16); // prev: 0.000000059604644775390625
|
||||
pub const f32_true_min: comptime_float = floatTrueMin(f32); // prev: 1.40129846432481707092e-45
|
||||
pub const f64_true_min: comptime_float = floatTrueMin(f64); // prev: 4.94065645841246544177e-324
|
||||
pub const f80_true_min = floatTrueMin(f80); // prev: make_f80(.{ .fraction = 1, .exp = 0 })
|
||||
pub const f128_true_min = floatTrueMin(f128); // prev: @bitCast(f128, @as(u128, 0x00000000000000000000000000000001))
|
||||
pub const f16_min: comptime_float = floatMin(f16); // prev: 0.00006103515625
|
||||
pub const f32_min: comptime_float = floatMin(f32); // prev: 1.17549435082228750797e-38
|
||||
pub const f64_min: comptime_float = floatMin(f64); // prev: 2.2250738585072014e-308
|
||||
pub const f80_min = floatMin(f80); // prev: make_f80(.{ .fraction = 0x8000000000000000, .exp = 1 })
|
||||
pub const f128_min = floatMin(f128); // prev: @bitCast(f128, @as(u128, 0x00010000000000000000000000000000))
|
||||
pub const f16_max: comptime_float = floatMax(f16); // prev: 65504
|
||||
pub const f32_max: comptime_float = floatMax(f32); // prev: 3.40282346638528859812e+38
|
||||
pub const f64_max: comptime_float = floatMax(f64); // prev: 1.79769313486231570815e+308
|
||||
pub const f80_max = floatMax(f80); // prev: make_f80(.{ .fraction = 0xFFFFFFFFFFFFFFFF, .exp = 0x7FFE })
|
||||
pub const f128_max = floatMax(f128); // prev: @bitCast(f128, @as(u128, 0x7FFEFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
|
||||
pub const f16_epsilon: comptime_float = floatEps(f16); // prev: 0.0009765625
|
||||
pub const f32_epsilon: comptime_float = floatEps(f32); // prev: 1.1920928955078125e-07
|
||||
pub const f64_epsilon: comptime_float = floatEps(f64); // prev: 2.22044604925031308085e-16
|
||||
pub const f80_epsilon = floatEps(f80); // prev: make_f80(.{ .fraction = 0x8000000000000000, .exp = 0x3FC0 })
|
||||
pub const f128_epsilon = floatEps(f128); // prev: @bitCast(f128, @as(u128, 0x3F8F0000000000000000000000000000))
|
||||
pub const f16_toint: comptime_float = 1.0 / f16_epsilon; // same as before
|
||||
pub const f32_toint: comptime_float = 1.0 / f32_epsilon; // same as before
|
||||
pub const f64_toint: comptime_float = 1.0 / f64_epsilon; // same as before
|
||||
pub const f80_toint = 1.0 / f80_epsilon; // same as before
|
||||
pub const f128_toint = 1.0 / f128_epsilon; // same as before
|
||||
pub const inf_u16 = @bitCast(u16, inf_f16); // prev: @as(u16, 0x7C00)
|
||||
pub const inf_f16 = inf(f16); // prev: @bitCast(f16, inf_u16)
|
||||
pub const inf_u32 = @bitCast(u32, inf_f32); // prev: @as(u32, 0x7F800000)
|
||||
pub const inf_f32 = inf(f32); // prev: @bitCast(f32, inf_u32)
|
||||
pub const inf_u64 = @bitCast(u64, inf_f64); // prev: @as(u64, 0x7FF << 52)
|
||||
pub const inf_f64 = inf(f64); // prev: @bitCast(f64, inf_u64)
|
||||
pub const inf_f80 = inf(f80); // prev: make_f80(F80{ .fraction = 0x8000000000000000, .exp = 0x7fff })
|
||||
pub const inf_u128 = @bitCast(u128, inf_f128); // prev: @as(u128, 0x7fff0000000000000000000000000000)
|
||||
pub const inf_f128 = inf(f128); // prev: @bitCast(f128, inf_u128)
|
||||
pub const epsilon = floatEps;
|
||||
// End of "soft deprecated" section
|
||||
pub const f16_true_min = @compileError("Deprecated: use `floatTrueMin(f16)` instead");
|
||||
pub const f32_true_min = @compileError("Deprecated: use `floatTrueMin(f32)` instead");
|
||||
pub const f64_true_min = @compileError("Deprecated: use `floatTrueMin(f64)` instead");
|
||||
pub const f80_true_min = @compileError("Deprecated: use `floatTrueMin(f80)` instead");
|
||||
pub const f128_true_min = @compileError("Deprecated: use `floatTrueMin(f128)` instead");
|
||||
pub const f16_min = @compileError("Deprecated: use `floatMin(f16)` instead");
|
||||
pub const f32_min = @compileError("Deprecated: use `floatMin(f32)` instead");
|
||||
pub const f64_min = @compileError("Deprecated: use `floatMin(f64)` instead");
|
||||
pub const f80_min = @compileError("Deprecated: use `floatMin(f80)` instead");
|
||||
pub const f128_min = @compileError("Deprecated: use `floatMin(f128)` instead");
|
||||
pub const f16_max = @compileError("Deprecated: use `floatMax(f16)` instead");
|
||||
pub const f32_max = @compileError("Deprecated: use `floatMax(f32)` instead");
|
||||
pub const f64_max = @compileError("Deprecated: use `floatMax(f64)` instead");
|
||||
pub const f80_max = @compileError("Deprecated: use `floatMax(f80)` instead");
|
||||
pub const f128_max = @compileError("Deprecated: use `floatMax(f128)` instead");
|
||||
pub const f16_epsilon = @compileError("Deprecated: use `floatEps(f16)` instead");
|
||||
pub const f32_epsilon = @compileError("Deprecated: use `floatEps(f32)` instead");
|
||||
pub const f64_epsilon = @compileError("Deprecated: use `floatEps(f64)` instead");
|
||||
pub const f80_epsilon = @compileError("Deprecated: use `floatEps(f80)` instead");
|
||||
pub const f128_epsilon = @compileError("Deprecated: use `floatEps(f128)` instead");
|
||||
pub const f16_toint = @compileError("Deprecated: use `1.0 / floatEps(f16)` instead");
|
||||
pub const f32_toint = @compileError("Deprecated: use `1.0 / floatEps(f32)` instead");
|
||||
pub const f64_toint = @compileError("Deprecated: use `1.0 / floatEps(f64)` instead");
|
||||
pub const f80_toint = @compileError("Deprecated: use `1.0 / floatEps(f80)` instead");
|
||||
pub const f128_toint = @compileError("Deprecated: use `1.0 / floatEps(f128)` instead");
|
||||
pub const inf_u16 = @compileError("Deprecated: use `@bitCast(u16, inf(f16))` instead");
|
||||
pub const inf_f16 = @compileError("Deprecated: use `inf(f16)` instead");
|
||||
pub const inf_u32 = @compileError("Deprecated: use `@bitCast(u32, inf(f32))` instead");
|
||||
pub const inf_f32 = @compileError("Deprecated: use `inf(f32)` instead");
|
||||
pub const inf_u64 = @compileError("Deprecated: use `@bitCast(u64, inf(f64))` instead");
|
||||
pub const inf_f64 = @compileError("Deprecated: use `inf(f64)` instead");
|
||||
pub const inf_f80 = @compileError("Deprecated: use `inf(f80)` instead");
|
||||
pub const inf_u128 = @compileError("Deprecated: use `@bitCast(u128, inf(f128))` instead");
|
||||
pub const inf_f128 = @compileError("Deprecated: use `inf(f128)` instead");
|
||||
pub const epsilon = @compileError("Deprecated: use `floatEps` instead");
|
||||
|
||||
pub const nan_u16 = @as(u16, 0x7C01);
|
||||
pub const nan_f16 = @bitCast(f16, nan_u16);
|
||||
@ -329,7 +327,92 @@ pub const Complex = complex.Complex;
|
||||
pub const big = @import("math/big.zig");
|
||||
|
||||
test {
|
||||
std.testing.refAllDecls(@This());
|
||||
_ = floatExponentBits;
|
||||
_ = floatMantissaBits;
|
||||
_ = floatFractionalBits;
|
||||
_ = floatExponentMin;
|
||||
_ = floatExponentMax;
|
||||
_ = floatTrueMin;
|
||||
_ = floatMin;
|
||||
_ = floatMax;
|
||||
_ = floatEps;
|
||||
_ = inf;
|
||||
|
||||
_ = nan_u16;
|
||||
_ = nan_f16;
|
||||
|
||||
_ = qnan_u16;
|
||||
_ = qnan_f16;
|
||||
|
||||
_ = nan_u32;
|
||||
_ = nan_f32;
|
||||
|
||||
_ = qnan_u32;
|
||||
_ = qnan_f32;
|
||||
|
||||
_ = nan_u64;
|
||||
_ = nan_f64;
|
||||
|
||||
_ = qnan_u64;
|
||||
_ = qnan_f64;
|
||||
|
||||
_ = nan_f80;
|
||||
_ = qnan_f80;
|
||||
|
||||
_ = nan_u128;
|
||||
_ = nan_f128;
|
||||
|
||||
_ = qnan_u128;
|
||||
_ = qnan_f128;
|
||||
|
||||
_ = nan;
|
||||
_ = snan;
|
||||
|
||||
_ = isNan;
|
||||
_ = isSignalNan;
|
||||
_ = frexp;
|
||||
_ = Frexp;
|
||||
_ = modf;
|
||||
_ = modf32_result;
|
||||
_ = modf64_result;
|
||||
_ = copysign;
|
||||
_ = isFinite;
|
||||
_ = isInf;
|
||||
_ = isPositiveInf;
|
||||
_ = isNegativeInf;
|
||||
_ = isNormal;
|
||||
_ = signbit;
|
||||
_ = scalbn;
|
||||
_ = ldexp;
|
||||
_ = pow;
|
||||
_ = powi;
|
||||
_ = sqrt;
|
||||
_ = cbrt;
|
||||
_ = acos;
|
||||
_ = asin;
|
||||
_ = atan;
|
||||
_ = atan2;
|
||||
_ = hypot;
|
||||
_ = expm1;
|
||||
_ = ilogb;
|
||||
_ = ln;
|
||||
_ = log;
|
||||
_ = log2;
|
||||
_ = log10;
|
||||
_ = log10_int;
|
||||
_ = log1p;
|
||||
_ = asinh;
|
||||
_ = acosh;
|
||||
_ = atanh;
|
||||
_ = sinh;
|
||||
_ = cosh;
|
||||
_ = tanh;
|
||||
_ = gcd;
|
||||
|
||||
_ = complex;
|
||||
_ = Complex;
|
||||
|
||||
_ = big;
|
||||
}
|
||||
|
||||
/// Given two types, returns the smallest one which is capable of holding the
|
||||
@ -771,7 +854,7 @@ test "IntFittingRange" {
|
||||
|
||||
test "overflow functions" {
|
||||
try testOverflow();
|
||||
comptime try testOverflow();
|
||||
try comptime testOverflow();
|
||||
}
|
||||
|
||||
fn testOverflow() !void {
|
||||
@ -815,7 +898,7 @@ pub fn absInt(x: anytype) !@TypeOf(x) {
|
||||
|
||||
test "absInt" {
|
||||
try testAbsInt();
|
||||
comptime try testAbsInt();
|
||||
try comptime testAbsInt();
|
||||
}
|
||||
fn testAbsInt() !void {
|
||||
try testing.expect((absInt(@as(i32, -10)) catch unreachable) == 10);
|
||||
@ -837,7 +920,7 @@ pub fn divTrunc(comptime T: type, numerator: T, denominator: T) !T {
|
||||
|
||||
test "divTrunc" {
|
||||
try testDivTrunc();
|
||||
comptime try testDivTrunc();
|
||||
try comptime testDivTrunc();
|
||||
}
|
||||
fn testDivTrunc() !void {
|
||||
try testing.expect((divTrunc(i32, 5, 3) catch unreachable) == 1);
|
||||
@ -861,7 +944,7 @@ pub fn divFloor(comptime T: type, numerator: T, denominator: T) !T {
|
||||
|
||||
test "divFloor" {
|
||||
try testDivFloor();
|
||||
comptime try testDivFloor();
|
||||
try comptime testDivFloor();
|
||||
}
|
||||
fn testDivFloor() !void {
|
||||
try testing.expect((divFloor(i32, 5, 3) catch unreachable) == 1);
|
||||
@ -898,7 +981,7 @@ pub fn divCeil(comptime T: type, numerator: T, denominator: T) !T {
|
||||
|
||||
test "divCeil" {
|
||||
try testDivCeil();
|
||||
comptime try testDivCeil();
|
||||
try comptime testDivCeil();
|
||||
}
|
||||
fn testDivCeil() !void {
|
||||
try testing.expectEqual(@as(i32, 2), divCeil(i32, 5, 3) catch unreachable);
|
||||
@ -942,7 +1025,7 @@ pub fn divExact(comptime T: type, numerator: T, denominator: T) !T {
|
||||
|
||||
test "divExact" {
|
||||
try testDivExact();
|
||||
comptime try testDivExact();
|
||||
try comptime testDivExact();
|
||||
}
|
||||
fn testDivExact() !void {
|
||||
try testing.expect((divExact(i32, 10, 5) catch unreachable) == 2);
|
||||
@ -968,7 +1051,7 @@ pub fn mod(comptime T: type, numerator: T, denominator: T) !T {
|
||||
|
||||
test "mod" {
|
||||
try testMod();
|
||||
comptime try testMod();
|
||||
try comptime testMod();
|
||||
}
|
||||
fn testMod() !void {
|
||||
try testing.expect((mod(i32, -5, 3) catch unreachable) == 1);
|
||||
@ -994,7 +1077,7 @@ pub fn rem(comptime T: type, numerator: T, denominator: T) !T {
|
||||
|
||||
test "rem" {
|
||||
try testRem();
|
||||
comptime try testRem();
|
||||
try comptime testRem();
|
||||
}
|
||||
fn testRem() !void {
|
||||
try testing.expect((rem(i32, -5, 3) catch unreachable) == -2);
|
||||
@ -1170,7 +1253,7 @@ pub fn floorPowerOfTwo(comptime T: type, value: T) T {
|
||||
|
||||
test "floorPowerOfTwo" {
|
||||
try testFloorPowerOfTwo();
|
||||
comptime try testFloorPowerOfTwo();
|
||||
try comptime testFloorPowerOfTwo();
|
||||
}
|
||||
|
||||
fn testFloorPowerOfTwo() !void {
|
||||
@ -1232,7 +1315,7 @@ pub fn ceilPowerOfTwoAssert(comptime T: type, value: T) T {
|
||||
|
||||
test "ceilPowerOfTwoPromote" {
|
||||
try testCeilPowerOfTwoPromote();
|
||||
comptime try testCeilPowerOfTwoPromote();
|
||||
try comptime testCeilPowerOfTwoPromote();
|
||||
}
|
||||
|
||||
fn testCeilPowerOfTwoPromote() !void {
|
||||
@ -1249,7 +1332,7 @@ fn testCeilPowerOfTwoPromote() !void {
|
||||
|
||||
test "ceilPowerOfTwo" {
|
||||
try testCeilPowerOfTwo();
|
||||
comptime try testCeilPowerOfTwo();
|
||||
try comptime testCeilPowerOfTwo();
|
||||
}
|
||||
|
||||
fn testCeilPowerOfTwo() !void {
|
||||
@ -1668,7 +1751,7 @@ test "boolMask" {
|
||||
}
|
||||
}.runTest;
|
||||
try runTest();
|
||||
comptime try runTest();
|
||||
try comptime runTest();
|
||||
}
|
||||
|
||||
/// Return the mod of `num` with the smallest integer type
|
||||
@ -1799,5 +1882,5 @@ test "sign" {
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
try testSign();
|
||||
comptime try testSign();
|
||||
try comptime testSign();
|
||||
}
|
||||
|
@ -3101,7 +3101,7 @@ test "testStringEquality" {
|
||||
|
||||
test "testReadInt" {
|
||||
try testReadIntImpl();
|
||||
comptime try testReadIntImpl();
|
||||
try comptime testReadIntImpl();
|
||||
}
|
||||
fn testReadIntImpl() !void {
|
||||
{
|
||||
@ -3152,7 +3152,7 @@ fn testReadIntImpl() !void {
|
||||
|
||||
test writeIntSlice {
|
||||
try testWriteIntImpl();
|
||||
comptime try testWriteIntImpl();
|
||||
try comptime testWriteIntImpl();
|
||||
}
|
||||
fn testWriteIntImpl() !void {
|
||||
var bytes: [8]u8 = undefined;
|
||||
@ -4069,13 +4069,13 @@ test "bytesAsSlice keeps pointer alignment" {
|
||||
{
|
||||
var bytes = [_]u8{ 0x01, 0x02, 0x03, 0x04 };
|
||||
const numbers = bytesAsSlice(u32, bytes[0..]);
|
||||
comptime try testing.expect(@TypeOf(numbers) == []align(@alignOf(@TypeOf(bytes))) u32);
|
||||
try comptime testing.expect(@TypeOf(numbers) == []align(@alignOf(@TypeOf(bytes))) u32);
|
||||
}
|
||||
{
|
||||
var bytes = [_]u8{ 0x01, 0x02, 0x03, 0x04 };
|
||||
var runtime_zero: usize = 0;
|
||||
const numbers = bytesAsSlice(u32, bytes[runtime_zero..]);
|
||||
comptime try testing.expect(@TypeOf(numbers) == []align(@alignOf(@TypeOf(bytes))) u32);
|
||||
try comptime testing.expect(@TypeOf(numbers) == []align(@alignOf(@TypeOf(bytes))) u32);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4168,7 +4168,7 @@ test "sliceAsBytes packed struct at runtime and comptime" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "sliceAsBytes and bytesAsSlice back" {
|
||||
@ -4557,7 +4557,7 @@ test "read/write(Var)PackedInt" {
|
||||
}
|
||||
|
||||
const signedness = @typeInfo(PackedType).Int.signedness;
|
||||
const NextPowerOfTwoInt = std.meta.Int(signedness, comptime try std.math.ceilPowerOfTwo(u16, @bitSizeOf(PackedType)));
|
||||
const NextPowerOfTwoInt = std.meta.Int(signedness, try comptime std.math.ceilPowerOfTwo(u16, @bitSizeOf(PackedType)));
|
||||
const ui64 = std.meta.Int(signedness, 64);
|
||||
inline for ([_]type{ PackedType, NextPowerOfTwoInt, ui64 }) |U| {
|
||||
{ // Variable-size Read/Write (Native-endian)
|
||||
|
@ -146,7 +146,7 @@ test "std.meta.Child" {
|
||||
try testing.expect(Child(*u8) == u8);
|
||||
try testing.expect(Child([]u8) == u8);
|
||||
try testing.expect(Child(?u8) == u8);
|
||||
try testing.expect(Child(Vector(2, u8)) == u8);
|
||||
try testing.expect(Child(@Vector(2, u8)) == u8);
|
||||
}
|
||||
|
||||
/// Given a "memory span" type (array, slice, vector, or pointer to such), returns the "element type".
|
||||
@ -173,8 +173,8 @@ test "std.meta.Elem" {
|
||||
try testing.expect(Elem([*]u8) == u8);
|
||||
try testing.expect(Elem([]u8) == u8);
|
||||
try testing.expect(Elem(*[10]u8) == u8);
|
||||
try testing.expect(Elem(Vector(2, u8)) == u8);
|
||||
try testing.expect(Elem(*Vector(2, u8)) == u8);
|
||||
try testing.expect(Elem(@Vector(2, u8)) == u8);
|
||||
try testing.expect(Elem(*@Vector(2, u8)) == u8);
|
||||
try testing.expect(Elem(?[*]u8) == u8);
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ pub fn sentinel(comptime T: type) ?Elem(T) {
|
||||
|
||||
test "std.meta.sentinel" {
|
||||
try testSentinel();
|
||||
comptime try testSentinel();
|
||||
try comptime testSentinel();
|
||||
}
|
||||
|
||||
fn testSentinel() !void {
|
||||
@ -711,8 +711,6 @@ test "std.meta.DeclEnum" {
|
||||
try expectEqualEnum(enum { a, b, c }, DeclEnum(C));
|
||||
}
|
||||
|
||||
pub const TagType = @compileError("deprecated; use Tag");
|
||||
|
||||
pub fn Tag(comptime T: type) type {
|
||||
return switch (@typeInfo(T)) {
|
||||
.Enum => |info| info.tag_type,
|
||||
@ -1014,16 +1012,6 @@ test "std.meta.Float" {
|
||||
try testing.expectEqual(f128, Float(128));
|
||||
}
|
||||
|
||||
/// Deprecated. Use `@Vector`.
|
||||
pub fn Vector(comptime len: u32, comptime child: type) type {
|
||||
return @Type(.{
|
||||
.Vector = .{
|
||||
.len = len,
|
||||
.child = child,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/// For a given function type, returns a tuple type which fields will
|
||||
/// correspond to the argument types.
|
||||
///
|
||||
|
@ -222,8 +222,8 @@ pub fn isSingleItemPtr(comptime T: type) bool {
|
||||
|
||||
test "isSingleItemPtr" {
|
||||
const array = [_]u8{0} ** 10;
|
||||
comptime try testing.expect(isSingleItemPtr(@TypeOf(&array[0])));
|
||||
comptime try testing.expect(!isSingleItemPtr(@TypeOf(array)));
|
||||
try comptime testing.expect(isSingleItemPtr(@TypeOf(&array[0])));
|
||||
try comptime testing.expect(!isSingleItemPtr(@TypeOf(array)));
|
||||
var runtime_zero: usize = 0;
|
||||
try testing.expect(!isSingleItemPtr(@TypeOf(array[runtime_zero..1])));
|
||||
}
|
||||
@ -271,7 +271,7 @@ pub fn isIndexable(comptime T: type) bool {
|
||||
test "isIndexable" {
|
||||
const array = [_]u8{0} ** 10;
|
||||
const slice = @as([]const u8, &array);
|
||||
const vector: meta.Vector(2, u32) = [_]u32{0} ** 2;
|
||||
const vector: @Vector(2, u32) = [_]u32{0} ** 2;
|
||||
const tuple = .{ 1, 2, 3 };
|
||||
|
||||
try testing.expect(isIndexable(@TypeOf(array)));
|
||||
|
@ -410,7 +410,7 @@ pub const Random = struct {
|
||||
r.uintLessThan(T, sum)
|
||||
else if (comptime std.meta.trait.isFloat(T))
|
||||
// take care that imprecision doesn't lead to a value slightly greater than sum
|
||||
std.math.min(r.float(T) * sum, sum - std.math.epsilon(T))
|
||||
std.math.min(r.float(T) * sum, sum - std.math.floatEps(T))
|
||||
else
|
||||
@compileError("weightedIndex does not support proportions of type " ++ @typeName(T));
|
||||
|
||||
|
@ -79,7 +79,7 @@ const Dilbert = struct {
|
||||
|
||||
test "Random int" {
|
||||
try testRandomInt();
|
||||
comptime try testRandomInt();
|
||||
try comptime testRandomInt();
|
||||
}
|
||||
fn testRandomInt() !void {
|
||||
var rng = SequentialPrng.init();
|
||||
@ -126,7 +126,7 @@ fn testRandomInt() !void {
|
||||
|
||||
test "Random boolean" {
|
||||
try testRandomBoolean();
|
||||
comptime try testRandomBoolean();
|
||||
try comptime testRandomBoolean();
|
||||
}
|
||||
fn testRandomBoolean() !void {
|
||||
var rng = SequentialPrng.init();
|
||||
@ -140,7 +140,7 @@ fn testRandomBoolean() !void {
|
||||
|
||||
test "Random enum" {
|
||||
try testRandomEnumValue();
|
||||
comptime try testRandomEnumValue();
|
||||
try comptime testRandomEnumValue();
|
||||
}
|
||||
fn testRandomEnumValue() !void {
|
||||
const TestEnum = enum {
|
||||
@ -159,7 +159,7 @@ fn testRandomEnumValue() !void {
|
||||
test "Random intLessThan" {
|
||||
@setEvalBranchQuota(10000);
|
||||
try testRandomIntLessThan();
|
||||
comptime try testRandomIntLessThan();
|
||||
try comptime testRandomIntLessThan();
|
||||
}
|
||||
fn testRandomIntLessThan() !void {
|
||||
var rng = SequentialPrng.init();
|
||||
@ -201,7 +201,7 @@ fn testRandomIntLessThan() !void {
|
||||
test "Random intAtMost" {
|
||||
@setEvalBranchQuota(10000);
|
||||
try testRandomIntAtMost();
|
||||
comptime try testRandomIntAtMost();
|
||||
try comptime testRandomIntAtMost();
|
||||
}
|
||||
fn testRandomIntAtMost() !void {
|
||||
var rng = SequentialPrng.init();
|
||||
|
@ -263,7 +263,7 @@ pub fn expectApproxEqRel(expected: anytype, actual: @TypeOf(expected), tolerance
|
||||
|
||||
test "expectApproxEqRel" {
|
||||
inline for ([_]type{ f16, f32, f64, f128 }) |T| {
|
||||
const eps_value = comptime math.epsilon(T);
|
||||
const eps_value = comptime math.floatEps(T);
|
||||
const sqrt_eps_value = comptime @sqrt(eps_value);
|
||||
|
||||
const pos_x: T = 12.0;
|
||||
|
@ -354,11 +354,11 @@ fn testUtf16CountCodepoints() !void {
|
||||
|
||||
test "utf16 count codepoints" {
|
||||
try testUtf16CountCodepoints();
|
||||
comptime try testUtf16CountCodepoints();
|
||||
try comptime testUtf16CountCodepoints();
|
||||
}
|
||||
|
||||
test "utf8 encode" {
|
||||
comptime try testUtf8Encode();
|
||||
try comptime testUtf8Encode();
|
||||
try testUtf8Encode();
|
||||
}
|
||||
fn testUtf8Encode() !void {
|
||||
@ -384,7 +384,7 @@ fn testUtf8Encode() !void {
|
||||
}
|
||||
|
||||
test "utf8 encode error" {
|
||||
comptime try testUtf8EncodeError();
|
||||
try comptime testUtf8EncodeError();
|
||||
try testUtf8EncodeError();
|
||||
}
|
||||
fn testUtf8EncodeError() !void {
|
||||
@ -400,7 +400,7 @@ fn testErrorEncode(codePoint: u21, array: []u8, expectedErr: anyerror) !void {
|
||||
}
|
||||
|
||||
test "utf8 iterator on ascii" {
|
||||
comptime try testUtf8IteratorOnAscii();
|
||||
try comptime testUtf8IteratorOnAscii();
|
||||
try testUtf8IteratorOnAscii();
|
||||
}
|
||||
fn testUtf8IteratorOnAscii() !void {
|
||||
@ -420,7 +420,7 @@ fn testUtf8IteratorOnAscii() !void {
|
||||
}
|
||||
|
||||
test "utf8 view bad" {
|
||||
comptime try testUtf8ViewBad();
|
||||
try comptime testUtf8ViewBad();
|
||||
try testUtf8ViewBad();
|
||||
}
|
||||
fn testUtf8ViewBad() !void {
|
||||
@ -430,7 +430,7 @@ fn testUtf8ViewBad() !void {
|
||||
}
|
||||
|
||||
test "utf8 view ok" {
|
||||
comptime try testUtf8ViewOk();
|
||||
try comptime testUtf8ViewOk();
|
||||
try testUtf8ViewOk();
|
||||
}
|
||||
fn testUtf8ViewOk() !void {
|
||||
@ -450,7 +450,7 @@ fn testUtf8ViewOk() !void {
|
||||
}
|
||||
|
||||
test "bad utf8 slice" {
|
||||
comptime try testBadUtf8Slice();
|
||||
try comptime testBadUtf8Slice();
|
||||
try testBadUtf8Slice();
|
||||
}
|
||||
fn testBadUtf8Slice() !void {
|
||||
@ -461,7 +461,7 @@ fn testBadUtf8Slice() !void {
|
||||
}
|
||||
|
||||
test "valid utf8" {
|
||||
comptime try testValidUtf8();
|
||||
try comptime testValidUtf8();
|
||||
try testValidUtf8();
|
||||
}
|
||||
fn testValidUtf8() !void {
|
||||
@ -480,7 +480,7 @@ fn testValidUtf8() !void {
|
||||
}
|
||||
|
||||
test "invalid utf8 continuation bytes" {
|
||||
comptime try testInvalidUtf8ContinuationBytes();
|
||||
try comptime testInvalidUtf8ContinuationBytes();
|
||||
try testInvalidUtf8ContinuationBytes();
|
||||
}
|
||||
fn testInvalidUtf8ContinuationBytes() !void {
|
||||
@ -512,7 +512,7 @@ fn testInvalidUtf8ContinuationBytes() !void {
|
||||
}
|
||||
|
||||
test "overlong utf8 codepoint" {
|
||||
comptime try testOverlongUtf8Codepoint();
|
||||
try comptime testOverlongUtf8Codepoint();
|
||||
try testOverlongUtf8Codepoint();
|
||||
}
|
||||
fn testOverlongUtf8Codepoint() !void {
|
||||
@ -525,7 +525,7 @@ fn testOverlongUtf8Codepoint() !void {
|
||||
}
|
||||
|
||||
test "misc invalid utf8" {
|
||||
comptime try testMiscInvalidUtf8();
|
||||
try comptime testMiscInvalidUtf8();
|
||||
try testMiscInvalidUtf8();
|
||||
}
|
||||
fn testMiscInvalidUtf8() !void {
|
||||
@ -540,7 +540,7 @@ fn testMiscInvalidUtf8() !void {
|
||||
}
|
||||
|
||||
test "utf8 iterator peeking" {
|
||||
comptime try testUtf8Peeking();
|
||||
try comptime testUtf8Peeking();
|
||||
try testUtf8Peeking();
|
||||
}
|
||||
|
||||
@ -813,7 +813,7 @@ fn testCalcUtf16LeLen() !void {
|
||||
|
||||
test "calculate utf16 string length of given utf8 string in u16" {
|
||||
try testCalcUtf16LeLen();
|
||||
comptime try testCalcUtf16LeLen();
|
||||
try comptime testCalcUtf16LeLen();
|
||||
}
|
||||
|
||||
/// Print the given `utf16le` string
|
||||
@ -919,7 +919,7 @@ fn testUtf8CountCodepoints() !void {
|
||||
|
||||
test "utf8 count codepoints" {
|
||||
try testUtf8CountCodepoints();
|
||||
comptime try testUtf8CountCodepoints();
|
||||
try comptime testUtf8CountCodepoints();
|
||||
}
|
||||
|
||||
fn testUtf8ValidCodepoint() !void {
|
||||
@ -935,5 +935,5 @@ fn testUtf8ValidCodepoint() !void {
|
||||
|
||||
test "utf8 valid codepoint" {
|
||||
try testUtf8ValidCodepoint();
|
||||
comptime try testUtf8ValidCodepoint();
|
||||
try comptime testUtf8ValidCodepoint();
|
||||
}
|
||||
|
@ -7,11 +7,11 @@ const assert = std.debug.assert;
|
||||
var foo: u8 align(4) = 100;
|
||||
|
||||
test "global variable alignment" {
|
||||
comptime try expect(@typeInfo(@TypeOf(&foo)).Pointer.alignment == 4);
|
||||
comptime try expect(@TypeOf(&foo) == *align(4) u8);
|
||||
try comptime expect(@typeInfo(@TypeOf(&foo)).Pointer.alignment == 4);
|
||||
try comptime expect(@TypeOf(&foo) == *align(4) u8);
|
||||
{
|
||||
const slice = @as(*align(4) [1]u8, &foo)[0..];
|
||||
comptime try expect(@TypeOf(slice) == *align(4) [1]u8);
|
||||
try comptime expect(@TypeOf(slice) == *align(4) [1]u8);
|
||||
}
|
||||
}
|
||||
|
||||
@ -396,7 +396,7 @@ test "function align expression depends on generic parameter" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "function callconv expression depends on generic parameter" {
|
||||
@ -414,7 +414,7 @@ test "function callconv expression depends on generic parameter" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "runtime-known array index has best alignment possible" {
|
||||
@ -452,10 +452,10 @@ test "runtime-known array index has best alignment possible" {
|
||||
try testIndex2(&array, 3, *u8);
|
||||
}
|
||||
fn testIndex(smaller: [*]align(2) u32, index: usize, comptime T: type) !void {
|
||||
comptime try expect(@TypeOf(&smaller[index]) == T);
|
||||
try comptime expect(@TypeOf(&smaller[index]) == T);
|
||||
}
|
||||
fn testIndex2(ptr: [*]align(4) u8, index: usize, comptime T: type) !void {
|
||||
comptime try expect(@TypeOf(&ptr[index]) == T);
|
||||
try comptime expect(@TypeOf(&ptr[index]) == T);
|
||||
}
|
||||
|
||||
test "alignment of function with c calling convention" {
|
||||
@ -517,7 +517,7 @@ test "struct field explicit alignment" {
|
||||
var node: S.Node = undefined;
|
||||
node.massive_byte = 100;
|
||||
try expect(node.massive_byte == 100);
|
||||
comptime try expect(@TypeOf(&node.massive_byte) == *align(64) u8);
|
||||
try comptime expect(@TypeOf(&node.massive_byte) == *align(64) u8);
|
||||
try expect(@ptrToInt(&node.massive_byte) % 64 == 0);
|
||||
}
|
||||
|
||||
|
@ -11,9 +11,9 @@ const Foo = struct {
|
||||
};
|
||||
|
||||
test "@alignOf(T) before referencing T" {
|
||||
comptime try expect(@alignOf(Foo) != maxInt(usize));
|
||||
try comptime expect(@alignOf(Foo) != maxInt(usize));
|
||||
if (native_arch == .x86_64) {
|
||||
comptime try expect(@alignOf(Foo) == 4);
|
||||
try comptime expect(@alignOf(Foo) == 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ test "array concat with undefined" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "array concat with tuple" {
|
||||
@ -154,9 +154,9 @@ test "array len field" {
|
||||
var arr = [4]u8{ 0, 0, 0, 0 };
|
||||
var ptr = &arr;
|
||||
try expect(arr.len == 4);
|
||||
comptime try expect(arr.len == 4);
|
||||
try comptime expect(arr.len == 4);
|
||||
try expect(ptr.len == 4);
|
||||
comptime try expect(ptr.len == 4);
|
||||
try comptime expect(ptr.len == 4);
|
||||
try expect(@TypeOf(arr.len) == usize);
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ test "array with sentinels" {
|
||||
};
|
||||
|
||||
try S.doTheTest(false);
|
||||
comptime try S.doTheTest(true);
|
||||
try comptime S.doTheTest(true);
|
||||
}
|
||||
|
||||
test "void arrays" {
|
||||
@ -247,7 +247,7 @@ test "single-item pointer to array indexing and slicing" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testSingleItemPtrArrayIndexSlice();
|
||||
comptime try testSingleItemPtrArrayIndexSlice();
|
||||
try comptime testSingleItemPtrArrayIndexSlice();
|
||||
}
|
||||
|
||||
fn testSingleItemPtrArrayIndexSlice() !void {
|
||||
@ -300,7 +300,7 @@ test "anonymous list literal syntax" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
var s_array: [8]Sub = undefined;
|
||||
@ -349,7 +349,7 @@ test "implicit cast single-item pointer" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try testImplicitCastSingleItemPtr();
|
||||
comptime try testImplicitCastSingleItemPtr();
|
||||
try comptime testImplicitCastSingleItemPtr();
|
||||
}
|
||||
|
||||
fn testImplicitCastSingleItemPtr() !void {
|
||||
@ -410,7 +410,7 @@ test "array literal as argument to function" {
|
||||
}
|
||||
};
|
||||
try S.entry(2);
|
||||
comptime try S.entry(2);
|
||||
try comptime S.entry(2);
|
||||
}
|
||||
|
||||
test "double nested array to const slice cast in array literal" {
|
||||
@ -472,7 +472,7 @@ test "double nested array to const slice cast in array literal" {
|
||||
}
|
||||
};
|
||||
try S.entry(2);
|
||||
comptime try S.entry(2);
|
||||
try comptime S.entry(2);
|
||||
}
|
||||
|
||||
test "anonymous literal in array" {
|
||||
@ -498,7 +498,7 @@ test "anonymous literal in array" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "access the null element of a null terminated array" {
|
||||
@ -515,7 +515,7 @@ test "access the null element of a null terminated array" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "type deduction for array subscript expression" {
|
||||
@ -534,7 +534,7 @@ test "type deduction for array subscript expression" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "sentinel element count towards the ABI size calculation" {
|
||||
@ -558,7 +558,7 @@ test "sentinel element count towards the ABI size calculation" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "zero-sized array with recursive type definition" {
|
||||
@ -613,7 +613,7 @@ test "type coercion of anon struct literal to array" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "type coercion of pointer to anon struct literal to pointer to array" {
|
||||
@ -646,7 +646,7 @@ test "type coercion of pointer to anon struct literal to pointer to array" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "array with comptime-only element type" {
|
||||
|
@ -331,7 +331,7 @@ test "async fn pointer in a struct field" {
|
||||
var foo = Foo{ .bar = simpleAsyncFn2 };
|
||||
var bytes: [64]u8 align(16) = undefined;
|
||||
const f = @asyncCall(&bytes, {}, foo.bar, .{&data});
|
||||
comptime try expect(@TypeOf(f) == anyframe->void);
|
||||
try comptime expect(@TypeOf(f) == anyframe->void);
|
||||
try expect(data == 2);
|
||||
resume f;
|
||||
try expect(data == 4);
|
||||
@ -1143,7 +1143,7 @@ test "@asyncCall using the result location inside the frame" {
|
||||
var foo = Foo{ .bar = S.simple2 };
|
||||
var bytes: [64]u8 align(16) = undefined;
|
||||
const f = @asyncCall(&bytes, {}, foo.bar, .{&data});
|
||||
comptime try expect(@TypeOf(f) == anyframe->i32);
|
||||
try comptime expect(@TypeOf(f) == anyframe->i32);
|
||||
try expect(data == 2);
|
||||
resume f;
|
||||
try expect(data == 4);
|
||||
@ -1158,7 +1158,7 @@ test "@TypeOf an async function call of generic fn with error union type" {
|
||||
const S = struct {
|
||||
fn func(comptime x: anytype) anyerror!i32 {
|
||||
const T = @TypeOf(async func(x));
|
||||
comptime try expect(T == @typeInfo(@TypeOf(@frame())).Pointer.child);
|
||||
try comptime expect(T == @typeInfo(@TypeOf(@frame())).Pointer.child);
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
@ -17,7 +17,7 @@ test "cmpxchg" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testCmpxchg();
|
||||
comptime try testCmpxchg();
|
||||
try comptime testCmpxchg();
|
||||
}
|
||||
|
||||
fn testCmpxchg() !void {
|
||||
@ -122,7 +122,7 @@ test "128-bit cmpxchg" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
|
||||
try test_u128_cmpxchg();
|
||||
comptime try test_u128_cmpxchg();
|
||||
try comptime test_u128_cmpxchg();
|
||||
}
|
||||
|
||||
fn test_u128_cmpxchg() !void {
|
||||
@ -195,7 +195,7 @@ test "atomic store comptime" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testAtomicStore();
|
||||
try comptime testAtomicStore();
|
||||
try testAtomicStore();
|
||||
}
|
||||
|
||||
@ -219,7 +219,7 @@ test "atomicrmw with floats" {
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
try testAtomicRmwFloat();
|
||||
comptime try testAtomicRmwFloat();
|
||||
try comptime testAtomicRmwFloat();
|
||||
}
|
||||
|
||||
fn testAtomicRmwFloat() !void {
|
||||
@ -244,7 +244,7 @@ test "atomicrmw with ints" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testAtomicRmwInts();
|
||||
comptime try testAtomicRmwInts();
|
||||
try comptime testAtomicRmwInts();
|
||||
}
|
||||
|
||||
fn testAtomicRmwInts() !void {
|
||||
@ -318,8 +318,8 @@ test "atomicrmw with 128-bit ints" {
|
||||
|
||||
try testAtomicRmwInt128(.signed);
|
||||
try testAtomicRmwInt128(.unsigned);
|
||||
comptime try testAtomicRmwInt128(.signed);
|
||||
comptime try testAtomicRmwInt128(.unsigned);
|
||||
try comptime testAtomicRmwInt128(.signed);
|
||||
try comptime testAtomicRmwInt128(.unsigned);
|
||||
}
|
||||
|
||||
fn testAtomicRmwInt128(comptime signedness: std.builtin.Signedness) !void {
|
||||
@ -441,5 +441,5 @@ test "return @atomicStore, using it as a void value" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ test "empty function with comments" {
|
||||
|
||||
test "truncate" {
|
||||
try expect(testTruncate(0x10fd) == 0xfd);
|
||||
comptime try expect(testTruncate(0x10fd) == 0xfd);
|
||||
try comptime expect(testTruncate(0x10fd) == 0xfd);
|
||||
}
|
||||
fn testTruncate(x: u32) u8 {
|
||||
return @truncate(u8, x);
|
||||
@ -462,7 +462,7 @@ test "struct inside function" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try testStructInFn();
|
||||
comptime try testStructInFn();
|
||||
try comptime testStructInFn();
|
||||
}
|
||||
|
||||
fn testStructInFn() !void {
|
||||
@ -577,7 +577,7 @@ fn emptyFn() void {}
|
||||
const addr1 = @ptrCast(*const u8, &emptyFn);
|
||||
test "comptime cast fn to ptr" {
|
||||
const addr2 = @ptrCast(*const u8, &emptyFn);
|
||||
comptime try expect(addr1 == addr2);
|
||||
try comptime expect(addr1 == addr2);
|
||||
}
|
||||
|
||||
test "equality compare fn ptrs" {
|
||||
@ -688,8 +688,8 @@ test "string concatenation" {
|
||||
const a = "OK" ++ " IT " ++ "WORKED";
|
||||
const b = "OK IT WORKED";
|
||||
|
||||
comptime try expect(@TypeOf(a) == *const [12:0]u8);
|
||||
comptime try expect(@TypeOf(b) == *const [12:0]u8);
|
||||
try comptime expect(@TypeOf(a) == *const [12:0]u8);
|
||||
try comptime expect(@TypeOf(b) == *const [12:0]u8);
|
||||
|
||||
const len = b.len;
|
||||
const len_with_null = len + 1;
|
||||
@ -759,7 +759,7 @@ test "auto created variables have correct alignment" {
|
||||
}
|
||||
};
|
||||
try expect(S.foo("\x7a\x7a\x7a\x7a") == 0x7a7a7a7a);
|
||||
comptime try expect(S.foo("\x7a\x7a\x7a\x7a") == 0x7a7a7a7a);
|
||||
try comptime expect(S.foo("\x7a\x7a\x7a\x7a") == 0x7a7a7a7a);
|
||||
}
|
||||
|
||||
test "extern variable with non-pointer opaque type" {
|
||||
|
@ -14,7 +14,7 @@ test "@bitCast iX -> uX (32, 64)" {
|
||||
|
||||
inline for (bit_values) |bits| {
|
||||
try testBitCast(bits);
|
||||
comptime try testBitCast(bits);
|
||||
try comptime testBitCast(bits);
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ test "@bitCast iX -> uX (8, 16, 128)" {
|
||||
|
||||
inline for (bit_values) |bits| {
|
||||
try testBitCast(bits);
|
||||
comptime try testBitCast(bits);
|
||||
try comptime testBitCast(bits);
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ test "@bitCast iX -> uX exotic integers" {
|
||||
|
||||
inline for (bit_values) |bits| {
|
||||
try testBitCast(bits);
|
||||
comptime try testBitCast(bits);
|
||||
try comptime testBitCast(bits);
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ test "bitcast uX to bytes" {
|
||||
const bit_values = [_]usize{ 1, 48, 27, 512, 493, 293, 125, 204, 112 };
|
||||
inline for (bit_values) |bits| {
|
||||
try testBitCast(bits);
|
||||
comptime try testBitCast(bits);
|
||||
try comptime testBitCast(bits);
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ test "nested bitcast" {
|
||||
};
|
||||
|
||||
try S.foo(42);
|
||||
comptime try S.foo(42);
|
||||
try comptime S.foo(42);
|
||||
}
|
||||
|
||||
// issue #3010: compiler segfault
|
||||
@ -182,7 +182,7 @@ test "@bitCast packed structs at runtime and comptime" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "@bitCast extern structs at runtime and comptime" {
|
||||
@ -214,7 +214,7 @@ test "@bitCast extern structs at runtime and comptime" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "bitcast packed struct to integer and back" {
|
||||
@ -237,7 +237,7 @@ test "bitcast packed struct to integer and back" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "implicit cast to error union by returning" {
|
||||
@ -254,7 +254,7 @@ test "implicit cast to error union by returning" {
|
||||
}
|
||||
};
|
||||
try S.entry();
|
||||
comptime try S.entry();
|
||||
try comptime S.entry();
|
||||
}
|
||||
|
||||
test "bitcast packed struct literal to byte" {
|
||||
@ -275,7 +275,7 @@ test "comptime bitcast used in expression has the correct type" {
|
||||
test "bitcast passed as tuple element" {
|
||||
const S = struct {
|
||||
fn foo(args: anytype) !void {
|
||||
comptime try expect(@TypeOf(args[0]) == f32);
|
||||
try comptime expect(@TypeOf(args[0]) == f32);
|
||||
try expect(args[0] == 12.34);
|
||||
}
|
||||
};
|
||||
@ -285,7 +285,7 @@ test "bitcast passed as tuple element" {
|
||||
test "triple level result location with bitcast sandwich passed as tuple element" {
|
||||
const S = struct {
|
||||
fn foo(args: anytype) !void {
|
||||
comptime try expect(@TypeOf(args[0]) == f64);
|
||||
try comptime expect(@TypeOf(args[0]) == f64);
|
||||
try expect(args[0] > 12.33 and args[0] < 12.35);
|
||||
}
|
||||
};
|
||||
@ -326,7 +326,7 @@ test "@bitCast packed struct of floats" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "comptime @bitCast packed struct to int and back" {
|
||||
|
@ -17,7 +17,7 @@ test "@bitReverse" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testBitReverse();
|
||||
try comptime testBitReverse();
|
||||
try testBitReverse();
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ test "bitReverse vectors u8" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try vector8();
|
||||
try comptime vector8();
|
||||
try vector8();
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ test "bitReverse vectors u16" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try vector16();
|
||||
try comptime vector16();
|
||||
try vector16();
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ test "bitReverse vectors u24" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try vector24();
|
||||
try comptime vector24();
|
||||
try vector24();
|
||||
}
|
||||
|
||||
@ -155,6 +155,6 @@ fn vector0() !void {
|
||||
test "bitReverse vectors u0" {
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
|
||||
|
||||
comptime try vector0();
|
||||
try comptime vector0();
|
||||
try vector0();
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ test "compile time bool not" {
|
||||
|
||||
test "short circuit" {
|
||||
try testShortCircuit(false, true);
|
||||
comptime try testShortCircuit(false, true);
|
||||
try comptime testShortCircuit(false, true);
|
||||
}
|
||||
|
||||
fn testShortCircuit(f: bool, t: bool) !void {
|
||||
|
@ -9,7 +9,7 @@ test "comptime code should not modify constant data" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testCastPtrOfArrayToSliceAndPtr();
|
||||
comptime try testCastPtrOfArrayToSliceAndPtr();
|
||||
try comptime testCastPtrOfArrayToSliceAndPtr();
|
||||
}
|
||||
|
||||
fn testCastPtrOfArrayToSliceAndPtr() !void {
|
||||
|
@ -9,7 +9,7 @@ test "store array of array of structs at comptime" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try expect(storeArrayOfArrayOfStructs() == 15);
|
||||
comptime try expect(storeArrayOfArrayOfStructs() == 15);
|
||||
try comptime expect(storeArrayOfArrayOfStructs() == 15);
|
||||
}
|
||||
|
||||
fn storeArrayOfArrayOfStructs() u8 {
|
||||
|
@ -17,5 +17,5 @@ test "slices pointing at the same address as global array." {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try checkAddress(&a);
|
||||
comptime try checkAddress(&a);
|
||||
try comptime checkAddress(&a);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ test "fixed" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testCtz();
|
||||
comptime try testCtz();
|
||||
try comptime testCtz();
|
||||
}
|
||||
|
||||
fn testCtz() !void {
|
||||
|
@ -7,7 +7,7 @@ test "bitCast to array" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testBitCastArray();
|
||||
try comptime testBitCastArray();
|
||||
try testBitCastArray();
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ test "Extern function calls in @TypeOf" {
|
||||
};
|
||||
|
||||
try Test.doTheTest();
|
||||
comptime try Test.doTheTest();
|
||||
try comptime Test.doTheTest();
|
||||
}
|
||||
|
||||
test "Peer resolution of extern function calls in @TypeOf" {
|
||||
@ -52,7 +52,7 @@ test "Peer resolution of extern function calls in @TypeOf" {
|
||||
};
|
||||
|
||||
try Test.doTheTest();
|
||||
comptime try Test.doTheTest();
|
||||
try comptime Test.doTheTest();
|
||||
}
|
||||
|
||||
test "Extern function calls, dereferences and field access in @TypeOf" {
|
||||
@ -78,5 +78,5 @@ test "Extern function calls, dereferences and field access in @TypeOf" {
|
||||
};
|
||||
|
||||
try Test.doTheTest();
|
||||
comptime try Test.doTheTest();
|
||||
try comptime Test.doTheTest();
|
||||
}
|
||||
|
@ -52,12 +52,12 @@ test "pointer-to-array constness for zero-size elements, var" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try mutable();
|
||||
comptime try mutable();
|
||||
try comptime mutable();
|
||||
}
|
||||
|
||||
test "pointer-to-array constness for zero-size elements, const" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try constant();
|
||||
comptime try constant();
|
||||
try comptime constant();
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ const other_file = @import("655_other_file.zig");
|
||||
|
||||
test "function with *const parameter with type dereferenced by namespace" {
|
||||
const x: other_file.Integer = 1234;
|
||||
comptime try std.testing.expect(@TypeOf(&x) == *const other_file.Integer);
|
||||
try comptime std.testing.expect(@TypeOf(&x) == *const other_file.Integer);
|
||||
try foo(&x);
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ test "@byteSwap integers" {
|
||||
try std.testing.expect(expected_output == @byteSwap(input));
|
||||
}
|
||||
};
|
||||
comptime try ByteSwapIntTest.run();
|
||||
try comptime ByteSwapIntTest.run();
|
||||
try ByteSwapIntTest.run();
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ test "@byteSwap vectors u8" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try vector8();
|
||||
try comptime vector8();
|
||||
try vector8();
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ test "@byteSwap vectors u16" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try vector16();
|
||||
try comptime vector16();
|
||||
try vector16();
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ test "@byteSwap vectors u24" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try vector24();
|
||||
try comptime vector24();
|
||||
try vector24();
|
||||
}
|
||||
|
||||
@ -121,6 +121,6 @@ fn vector0() !void {
|
||||
test "@byteSwap vectors u0" {
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
|
||||
|
||||
comptime try vector0();
|
||||
try comptime vector0();
|
||||
try vector0();
|
||||
}
|
||||
|
@ -10,11 +10,11 @@ test "super basic invocations" {
|
||||
}
|
||||
}.foo;
|
||||
try expect(@call(.auto, foo, .{}) == 1234);
|
||||
comptime try expect(@call(.always_inline, foo, .{}) == 1234);
|
||||
try comptime expect(@call(.always_inline, foo, .{}) == 1234);
|
||||
{
|
||||
// comptime call without comptime keyword
|
||||
const result = @call(.compile_time, foo, .{}) == 1234;
|
||||
comptime try expect(result);
|
||||
try comptime expect(result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ test "basic invocations" {
|
||||
{
|
||||
// comptime call without comptime keyword
|
||||
const result = @call(.compile_time, foo, .{}) == 1234;
|
||||
comptime try expect(result);
|
||||
try comptime expect(result);
|
||||
}
|
||||
{
|
||||
// call of non comptime-known function
|
||||
@ -71,7 +71,7 @@ test "tuple parameters" {
|
||||
try expect(@call(.auto, add, .{ a, b }) == 46);
|
||||
try expect(@call(.auto, add, .{ 12, 34 }) == 46);
|
||||
if (false) {
|
||||
comptime try expect(@call(.auto, add, .{ 12, 34 }) == 46); // TODO
|
||||
try comptime expect(@call(.auto, add, .{ 12, 34 }) == 46); // TODO
|
||||
}
|
||||
try expect(comptime @call(.auto, add, .{ 12, 34 }) == 46);
|
||||
{
|
||||
@ -344,7 +344,7 @@ test "inline call doesn't re-evaluate non generic struct" {
|
||||
};
|
||||
const ArgTuple = std.meta.ArgsTuple(@TypeOf(S.foo));
|
||||
try @call(.always_inline, S.foo, ArgTuple{.{ .a = 123, .b = 45 }});
|
||||
comptime try @call(.always_inline, S.foo, ArgTuple{.{ .a = 123, .b = 45 }});
|
||||
try comptime @call(.always_inline, S.foo, ArgTuple{.{ .a = 123, .b = 45 }});
|
||||
}
|
||||
|
||||
test "Enum constructed by @Type passed as generic argument" {
|
||||
|
@ -39,7 +39,7 @@ fn peerTypeTAndOptionalT(c: bool, b: bool) ?usize {
|
||||
|
||||
test "resolve undefined with integer" {
|
||||
try testResolveUndefWithInt(true, 1234);
|
||||
comptime try testResolveUndefWithInt(true, 1234);
|
||||
try comptime testResolveUndefWithInt(true, 1234);
|
||||
}
|
||||
fn testResolveUndefWithInt(b: bool, x: i32) !void {
|
||||
const value = if (b) x else undefined;
|
||||
@ -59,7 +59,7 @@ test "implicit cast comptime numbers to any type when the value fits" {
|
||||
}
|
||||
|
||||
test "implicit cast comptime_int to comptime_float" {
|
||||
comptime try expect(@as(comptime_float, 10) == @as(f32, 10));
|
||||
try comptime expect(@as(comptime_float, 10) == @as(f32, 10));
|
||||
try expect(2 == 2.0);
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ test "@intToFloat" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "@intToFloat(f80)" {
|
||||
@ -140,13 +140,13 @@ test "@intToFloat(f80)" {
|
||||
try S.doTheTest(i80);
|
||||
try S.doTheTest(i128);
|
||||
// try S.doTheTest(i256); // TODO missing compiler_rt symbols
|
||||
comptime try S.doTheTest(i31);
|
||||
comptime try S.doTheTest(i32);
|
||||
comptime try S.doTheTest(i45);
|
||||
comptime try S.doTheTest(i64);
|
||||
comptime try S.doTheTest(i80);
|
||||
comptime try S.doTheTest(i128);
|
||||
comptime try S.doTheTest(i256);
|
||||
try comptime S.doTheTest(i31);
|
||||
try comptime S.doTheTest(i32);
|
||||
try comptime S.doTheTest(i45);
|
||||
try comptime S.doTheTest(i64);
|
||||
try comptime S.doTheTest(i80);
|
||||
try comptime S.doTheTest(i128);
|
||||
try comptime S.doTheTest(i256);
|
||||
}
|
||||
|
||||
test "@floatToInt" {
|
||||
@ -156,7 +156,7 @@ test "@floatToInt" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try testFloatToInts();
|
||||
comptime try testFloatToInts();
|
||||
try comptime testFloatToInts();
|
||||
}
|
||||
|
||||
fn testFloatToInts() !void {
|
||||
@ -291,7 +291,7 @@ test "@intCast to u0 and use the result" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest(0, 1, 0);
|
||||
comptime try S.doTheTest(0, 1, 0);
|
||||
try comptime S.doTheTest(0, 1, 0);
|
||||
}
|
||||
|
||||
test "peer result null and comptime_int" {
|
||||
@ -312,11 +312,11 @@ test "peer result null and comptime_int" {
|
||||
};
|
||||
|
||||
try expect(S.blah(0) == null);
|
||||
comptime try expect(S.blah(0) == null);
|
||||
try comptime expect(S.blah(0) == null);
|
||||
try expect(S.blah(10).? == 1);
|
||||
comptime try expect(S.blah(10).? == 1);
|
||||
try comptime expect(S.blah(10).? == 1);
|
||||
try expect(S.blah(-10).? == -1);
|
||||
comptime try expect(S.blah(-10).? == -1);
|
||||
try comptime expect(S.blah(-10).? == -1);
|
||||
}
|
||||
|
||||
test "*const ?[*]const T to [*c]const [*c]const T" {
|
||||
@ -375,7 +375,7 @@ test "return u8 coercing into ?u32 return type" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "cast from ?[*]T to ??[*]T" {
|
||||
@ -392,7 +392,7 @@ test "peer type unsigned int to signed" {
|
||||
var x: u8 = 7;
|
||||
var y: i32 = -5;
|
||||
var a = w + y + x;
|
||||
comptime try expect(@TypeOf(a) == i32);
|
||||
try comptime expect(@TypeOf(a) == i32);
|
||||
try expect(a == 7);
|
||||
}
|
||||
|
||||
@ -414,7 +414,7 @@ test "explicit cast from integer to error type" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testCastIntToErr(error.ItBroke);
|
||||
comptime try testCastIntToErr(error.ItBroke);
|
||||
try comptime testCastIntToErr(error.ItBroke);
|
||||
}
|
||||
fn testCastIntToErr(err: anyerror) !void {
|
||||
const x = @errorToInt(err);
|
||||
@ -428,7 +428,7 @@ test "peer resolve array and const slice" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try testPeerResolveArrayConstSlice(true);
|
||||
comptime try testPeerResolveArrayConstSlice(true);
|
||||
try comptime testPeerResolveArrayConstSlice(true);
|
||||
}
|
||||
fn testPeerResolveArrayConstSlice(b: bool) !void {
|
||||
const value1 = if (b) "aoeu" else @as([]const u8, "zz");
|
||||
@ -444,7 +444,7 @@ test "implicitly cast from T to anyerror!?T" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try castToOptionalTypeError(1);
|
||||
comptime try castToOptionalTypeError(1);
|
||||
try comptime castToOptionalTypeError(1);
|
||||
}
|
||||
|
||||
const A = struct {
|
||||
@ -470,7 +470,7 @@ test "implicitly cast from [0]T to anyerror![]T" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testCastZeroArrayToErrSliceMut();
|
||||
comptime try testCastZeroArrayToErrSliceMut();
|
||||
try comptime testCastZeroArrayToErrSliceMut();
|
||||
}
|
||||
|
||||
fn testCastZeroArrayToErrSliceMut() !void {
|
||||
@ -504,7 +504,7 @@ test "peer type resolution: [0]u8, []const u8, and anyerror![]u8" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
fn peerTypeEmptyArrayAndSliceAndError(a: bool, slice: []u8) anyerror![]u8 {
|
||||
if (a) {
|
||||
@ -520,7 +520,7 @@ test "implicit cast from *const [N]T to []const T" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testCastConstArrayRefToConstSlice();
|
||||
comptime try testCastConstArrayRefToConstSlice();
|
||||
try comptime testCastConstArrayRefToConstSlice();
|
||||
}
|
||||
|
||||
fn testCastConstArrayRefToConstSlice() !void {
|
||||
@ -546,9 +546,9 @@ test "peer type resolution: error and [N]T" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try expect(mem.eql(u8, try testPeerErrorAndArray(0), "OK"));
|
||||
comptime try expect(mem.eql(u8, try testPeerErrorAndArray(0), "OK"));
|
||||
try comptime expect(mem.eql(u8, try testPeerErrorAndArray(0), "OK"));
|
||||
try expect(mem.eql(u8, try testPeerErrorAndArray2(1), "OKK"));
|
||||
comptime try expect(mem.eql(u8, try testPeerErrorAndArray2(1), "OKK"));
|
||||
try comptime expect(mem.eql(u8, try testPeerErrorAndArray2(1), "OKK"));
|
||||
}
|
||||
|
||||
fn testPeerErrorAndArray(x: u8) anyerror![]const u8 {
|
||||
@ -571,7 +571,7 @@ test "single-item pointer of array to slice to unknown length pointer" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testCastPtrOfArrayToSliceAndPtr();
|
||||
comptime try testCastPtrOfArrayToSliceAndPtr();
|
||||
try comptime testCastPtrOfArrayToSliceAndPtr();
|
||||
}
|
||||
|
||||
fn testCastPtrOfArrayToSliceAndPtr() !void {
|
||||
@ -644,9 +644,9 @@ test "vector casts" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
try S.doTheTestFloat();
|
||||
comptime try S.doTheTestFloat();
|
||||
try comptime S.doTheTestFloat();
|
||||
}
|
||||
|
||||
test "@floatCast cast down" {
|
||||
@ -887,7 +887,7 @@ test "peer resolution of string literals" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest(.b);
|
||||
comptime try S.doTheTest(.b);
|
||||
try comptime S.doTheTest(.b);
|
||||
}
|
||||
|
||||
test "peer cast [:x]T to []T" {
|
||||
@ -904,7 +904,7 @@ test "peer cast [:x]T to []T" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "peer cast [N:x]T to [N]T" {
|
||||
@ -920,7 +920,7 @@ test "peer cast [N:x]T to [N]T" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "peer cast *[N:x]T to *[N]T" {
|
||||
@ -936,7 +936,7 @@ test "peer cast *[N:x]T to *[N]T" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "peer cast [*:x]T to [*]T" {
|
||||
@ -956,7 +956,7 @@ test "peer cast [*:x]T to [*]T" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "peer cast [:x]T to [*:x]T" {
|
||||
@ -978,7 +978,7 @@ test "peer cast [:x]T to [*:x]T" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "peer type resolution implicit cast to return type" {
|
||||
@ -999,7 +999,7 @@ test "peer type resolution implicit cast to return type" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "peer type resolution implicit cast to variable type" {
|
||||
@ -1018,7 +1018,7 @@ test "peer type resolution implicit cast to variable type" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "variable initialization uses result locations properly with regards to the type" {
|
||||
@ -1042,7 +1042,7 @@ test "cast between C pointer with different but compatible types" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "peer type resolve string lit with sentinel-terminated mutable slice" {
|
||||
@ -1053,8 +1053,8 @@ test "peer type resolve string lit with sentinel-terminated mutable slice" {
|
||||
var array: [4:0]u8 = undefined;
|
||||
array[4] = 0; // TODO remove this when #4372 is solved
|
||||
var slice: [:0]u8 = array[0..4 :0];
|
||||
comptime try expect(@TypeOf(slice, "hi") == [:0]const u8);
|
||||
comptime try expect(@TypeOf("hi", slice) == [:0]const u8);
|
||||
try comptime expect(@TypeOf(slice, "hi") == [:0]const u8);
|
||||
try comptime expect(@TypeOf("hi", slice) == [:0]const u8);
|
||||
}
|
||||
|
||||
test "peer type resolve array pointers, one of them const" {
|
||||
@ -1062,8 +1062,8 @@ test "peer type resolve array pointers, one of them const" {
|
||||
|
||||
var array1: [4]u8 = undefined;
|
||||
const array2: [5]u8 = undefined;
|
||||
comptime try expect(@TypeOf(&array1, &array2) == []const u8);
|
||||
comptime try expect(@TypeOf(&array2, &array1) == []const u8);
|
||||
try comptime expect(@TypeOf(&array1, &array2) == []const u8);
|
||||
try comptime expect(@TypeOf(&array2, &array1) == []const u8);
|
||||
}
|
||||
|
||||
test "peer type resolve array pointer and unknown pointer" {
|
||||
@ -1074,17 +1074,17 @@ test "peer type resolve array pointer and unknown pointer" {
|
||||
var const_ptr: [*]const u8 = undefined;
|
||||
var ptr: [*]u8 = undefined;
|
||||
|
||||
comptime try expect(@TypeOf(&array, ptr) == [*]u8);
|
||||
comptime try expect(@TypeOf(ptr, &array) == [*]u8);
|
||||
try comptime expect(@TypeOf(&array, ptr) == [*]u8);
|
||||
try comptime expect(@TypeOf(ptr, &array) == [*]u8);
|
||||
|
||||
comptime try expect(@TypeOf(&const_array, ptr) == [*]const u8);
|
||||
comptime try expect(@TypeOf(ptr, &const_array) == [*]const u8);
|
||||
try comptime expect(@TypeOf(&const_array, ptr) == [*]const u8);
|
||||
try comptime expect(@TypeOf(ptr, &const_array) == [*]const u8);
|
||||
|
||||
comptime try expect(@TypeOf(&array, const_ptr) == [*]const u8);
|
||||
comptime try expect(@TypeOf(const_ptr, &array) == [*]const u8);
|
||||
try comptime expect(@TypeOf(&array, const_ptr) == [*]const u8);
|
||||
try comptime expect(@TypeOf(const_ptr, &array) == [*]const u8);
|
||||
|
||||
comptime try expect(@TypeOf(&const_array, const_ptr) == [*]const u8);
|
||||
comptime try expect(@TypeOf(const_ptr, &const_array) == [*]const u8);
|
||||
try comptime expect(@TypeOf(&const_array, const_ptr) == [*]const u8);
|
||||
try comptime expect(@TypeOf(const_ptr, &const_array) == [*]const u8);
|
||||
}
|
||||
|
||||
test "comptime float casts" {
|
||||
@ -1209,7 +1209,7 @@ test "implicitly cast from [N]T to ?[]const T" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try expect(mem.eql(u8, castToOptionalSlice().?, "hi"));
|
||||
comptime try expect(mem.eql(u8, castToOptionalSlice().?, "hi"));
|
||||
try comptime expect(mem.eql(u8, castToOptionalSlice().?, "hi"));
|
||||
}
|
||||
|
||||
fn castToOptionalSlice() ?[]const u8 {
|
||||
@ -1223,7 +1223,7 @@ test "cast u128 to f128 and back" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testCast128();
|
||||
try comptime testCast128();
|
||||
try testCast128();
|
||||
}
|
||||
|
||||
@ -1303,7 +1303,7 @@ test "*const [N]null u8 to ?[]const u8" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "cast between [*c]T and ?[*:0]T on fn parameter" {
|
||||
@ -1352,8 +1352,8 @@ test "peer resolve arrays of different size to const slice" {
|
||||
|
||||
try expect(mem.eql(u8, boolToStr(true), "true"));
|
||||
try expect(mem.eql(u8, boolToStr(false), "false"));
|
||||
comptime try expect(mem.eql(u8, boolToStr(true), "true"));
|
||||
comptime try expect(mem.eql(u8, boolToStr(false), "false"));
|
||||
try comptime expect(mem.eql(u8, boolToStr(true), "true"));
|
||||
try comptime expect(mem.eql(u8, boolToStr(false), "false"));
|
||||
}
|
||||
fn boolToStr(b: bool) []const u8 {
|
||||
return if (b) "true" else "false";
|
||||
@ -1376,7 +1376,7 @@ test "cast f16 to wider types" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "cast f128 to narrower types" {
|
||||
@ -1396,7 +1396,7 @@ test "cast f128 to narrower types" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "peer type resolution: unreachable, null, slice" {
|
||||
@ -1436,7 +1436,7 @@ test "cast i8 fn call peers to i32 result" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "cast compatible optional types" {
|
||||
@ -1509,7 +1509,7 @@ test "floatToInt to zero-bit int" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
const a: f32 = 0.0;
|
||||
comptime try std.testing.expect(@floatToInt(u0, a) == 0);
|
||||
try comptime std.testing.expect(@floatToInt(u0, a) == 0);
|
||||
}
|
||||
|
||||
test "peer type resolution of function pointer and function body" {
|
||||
|
@ -257,9 +257,9 @@ test "shuffle chunks of linker value" {
|
||||
try testing.expectEqual(lazy_address, unshuffled1_rt);
|
||||
const shuffled1_ct = comptime shuffle(lazy_address, Bits, ShuffledBits);
|
||||
const shuffled1_ct_2 = comptime shuffle(lazy_address, Bits, ShuffledBits);
|
||||
comptime try testing.expectEqual(shuffled1_ct, shuffled1_ct_2);
|
||||
try comptime testing.expectEqual(shuffled1_ct, shuffled1_ct_2);
|
||||
const unshuffled1_ct = comptime shuffle(shuffled1_ct, ShuffledBits, Bits);
|
||||
comptime try testing.expectEqual(lazy_address, unshuffled1_ct);
|
||||
try comptime testing.expectEqual(lazy_address, unshuffled1_ct);
|
||||
try testing.expectEqual(shuffled1_ct, shuffled1_rt);
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ test "return variable while defer expression in scope to modify it" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
var result: [3]u8 = undefined;
|
||||
@ -131,7 +131,7 @@ test "errdefer with payload" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "reference to errdefer payload" {
|
||||
@ -157,7 +157,7 @@ test "reference to errdefer payload" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "simple else prong doesn't emit an error for unreachable else prong" {
|
||||
|
@ -611,7 +611,7 @@ test "enum with specified tag values" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try testEnumWithSpecifiedTagValues(MultipleChoice.C);
|
||||
comptime try testEnumWithSpecifiedTagValues(MultipleChoice.C);
|
||||
try comptime testEnumWithSpecifiedTagValues(MultipleChoice.C);
|
||||
}
|
||||
|
||||
test "non-exhaustive enum" {
|
||||
@ -656,7 +656,7 @@ test "non-exhaustive enum" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest(52);
|
||||
comptime try S.doTheTest(52);
|
||||
try comptime S.doTheTest(52);
|
||||
}
|
||||
|
||||
test "empty non-exhaustive enum" {
|
||||
@ -677,7 +677,7 @@ test "empty non-exhaustive enum" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest(42);
|
||||
comptime try S.doTheTest(42);
|
||||
try comptime S.doTheTest(42);
|
||||
}
|
||||
|
||||
test "single field non-exhaustive enum" {
|
||||
@ -715,7 +715,7 @@ test "single field non-exhaustive enum" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest(23);
|
||||
comptime try S.doTheTest(23);
|
||||
try comptime S.doTheTest(23);
|
||||
}
|
||||
|
||||
const EnumWithTagValues = enum(u4) {
|
||||
@ -750,7 +750,7 @@ test "enum with specified and unspecified tag values" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try testEnumWithSpecifiedAndUnspecifiedTagValues(MultipleChoice2.D);
|
||||
comptime try testEnumWithSpecifiedAndUnspecifiedTagValues(MultipleChoice2.D);
|
||||
try comptime testEnumWithSpecifiedAndUnspecifiedTagValues(MultipleChoice2.D);
|
||||
}
|
||||
|
||||
fn testEnumWithSpecifiedAndUnspecifiedTagValues(x: MultipleChoice2) !void {
|
||||
@ -775,18 +775,18 @@ test "set enum tag type" {
|
||||
{
|
||||
var x = Small.One;
|
||||
x = Small.Two;
|
||||
comptime try expect(Tag(Small) == u2);
|
||||
try comptime expect(Tag(Small) == u2);
|
||||
}
|
||||
{
|
||||
var x = Small2.One;
|
||||
x = Small2.Two;
|
||||
comptime try expect(Tag(Small2) == u2);
|
||||
try comptime expect(Tag(Small2) == u2);
|
||||
}
|
||||
}
|
||||
|
||||
test "casting enum to its tag type" {
|
||||
try testCastEnumTag(Small2.Two);
|
||||
comptime try testCastEnumTag(Small2.Two);
|
||||
try comptime testCastEnumTag(Small2.Two);
|
||||
}
|
||||
|
||||
fn testCastEnumTag(value: Small2) !void {
|
||||
@ -797,7 +797,7 @@ test "enum with 1 field but explicit tag type should still have the tag type" {
|
||||
const Enum = enum(u8) {
|
||||
B = 2,
|
||||
};
|
||||
comptime try expect(@sizeOf(Enum) == @sizeOf(u8));
|
||||
try comptime expect(@sizeOf(Enum) == @sizeOf(u8));
|
||||
}
|
||||
|
||||
test "signed integer as enum tag" {
|
||||
@ -836,12 +836,12 @@ test "enum with comptime_int tag type" {
|
||||
Two = 2,
|
||||
Three = 1,
|
||||
};
|
||||
comptime try expect(Tag(Enum) == comptime_int);
|
||||
try comptime expect(Tag(Enum) == comptime_int);
|
||||
}
|
||||
|
||||
test "enum with one member default to u0 tag type" {
|
||||
const E0 = enum { X };
|
||||
comptime try expect(Tag(E0) == u0);
|
||||
try comptime expect(Tag(E0) == u0);
|
||||
}
|
||||
|
||||
const EnumWithOneMember = enum { Eof };
|
||||
@ -891,7 +891,7 @@ test "method call on an enum" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "enum value allocation" {
|
||||
@ -993,7 +993,7 @@ test "@tagName" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try expect(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three"));
|
||||
comptime try expect(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three"));
|
||||
try comptime expect(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three"));
|
||||
}
|
||||
|
||||
fn testEnumTagNameBare(n: anytype) []const u8 {
|
||||
@ -1009,7 +1009,7 @@ test "@tagName non-exhaustive enum" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try expect(mem.eql(u8, testEnumTagNameBare(NonExhaustive.B), "B"));
|
||||
comptime try expect(mem.eql(u8, testEnumTagNameBare(NonExhaustive.B), "B"));
|
||||
try comptime expect(mem.eql(u8, testEnumTagNameBare(NonExhaustive.B), "B"));
|
||||
}
|
||||
const NonExhaustive = enum(u8) { A, B, _ };
|
||||
|
||||
@ -1047,7 +1047,7 @@ test "@tagName on enum literals" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try expect(mem.eql(u8, @tagName(.FooBar), "FooBar"));
|
||||
comptime try expect(mem.eql(u8, @tagName(.FooBar), "FooBar"));
|
||||
try comptime expect(mem.eql(u8, @tagName(.FooBar), "FooBar"));
|
||||
}
|
||||
|
||||
test "enum literal casting to optional" {
|
||||
@ -1088,7 +1088,7 @@ test "bit field access with enum fields" {
|
||||
try expect(getA(&data) == A.Two);
|
||||
try expect(getB(&data) == B.Three3);
|
||||
try expect(getC(&data) == C.Four4);
|
||||
comptime try expect(@sizeOf(BitFieldOfEnums) == 1);
|
||||
try comptime expect(@sizeOf(BitFieldOfEnums) == 1);
|
||||
|
||||
data.b = B.Four3;
|
||||
try expect(data.b == B.Four3);
|
||||
|
@ -188,7 +188,7 @@ fn bar2() (error{}!void) {}
|
||||
|
||||
test "error union type " {
|
||||
try testErrorUnionType();
|
||||
comptime try testErrorUnionType();
|
||||
try comptime testErrorUnionType();
|
||||
}
|
||||
|
||||
fn testErrorUnionType() !void {
|
||||
@ -201,7 +201,7 @@ fn testErrorUnionType() !void {
|
||||
|
||||
test "error set type" {
|
||||
try testErrorSetType();
|
||||
comptime try testErrorSetType();
|
||||
try comptime testErrorSetType();
|
||||
}
|
||||
|
||||
const MyErrSet = error{
|
||||
@ -227,7 +227,7 @@ test "explicit error set cast" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testExplicitErrorSetCast(Set1.A);
|
||||
comptime try testExplicitErrorSetCast(Set1.A);
|
||||
try comptime testExplicitErrorSetCast(Set1.A);
|
||||
}
|
||||
|
||||
const Set1 = error{ A, B };
|
||||
@ -246,7 +246,7 @@ test "comptime test error for empty error set" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testComptimeTestErrorEmptySet(1234);
|
||||
comptime try testComptimeTestErrorEmptySet(1234);
|
||||
try comptime testComptimeTestErrorEmptySet(1234);
|
||||
}
|
||||
|
||||
const EmptyErrorSet = error{};
|
||||
@ -337,7 +337,7 @@ test "error: Zero sized error set returned with value payload crash" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
_ = try foo3(0);
|
||||
_ = comptime try foo3(0);
|
||||
_ = try comptime foo3(0);
|
||||
}
|
||||
|
||||
const Error = error{};
|
||||
@ -446,7 +446,7 @@ test "return function call to error set from error union function" {
|
||||
}
|
||||
};
|
||||
try expectError(error.Failure, S.errorable());
|
||||
comptime try expectError(error.Failure, S.errorable());
|
||||
try comptime expectError(error.Failure, S.errorable());
|
||||
}
|
||||
|
||||
test "optional error set is the same size as error set" {
|
||||
@ -455,15 +455,15 @@ test "optional error set is the same size as error set" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try expect(@sizeOf(?anyerror) == @sizeOf(anyerror));
|
||||
comptime try expect(@alignOf(?anyerror) == @alignOf(anyerror));
|
||||
try comptime expect(@sizeOf(?anyerror) == @sizeOf(anyerror));
|
||||
try comptime expect(@alignOf(?anyerror) == @alignOf(anyerror));
|
||||
const S = struct {
|
||||
fn returnsOptErrSet() ?anyerror {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
try expect(S.returnsOptErrSet() == null);
|
||||
comptime try expect(S.returnsOptErrSet() == null);
|
||||
try comptime expect(S.returnsOptErrSet() == null);
|
||||
}
|
||||
|
||||
test "nested catch" {
|
||||
@ -489,7 +489,7 @@ test "nested catch" {
|
||||
};
|
||||
};
|
||||
try S.entry();
|
||||
comptime try S.entry();
|
||||
try comptime S.entry();
|
||||
}
|
||||
|
||||
test "function pointer with return type that is error union with payload which is pointer of parent struct" {
|
||||
@ -545,7 +545,7 @@ test "return result loc as peer result loc in inferred error set function" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "error payload type is correctly resolved" {
|
||||
|
@ -56,7 +56,7 @@ fn staticAdd(a: i32, b: i32) i32 {
|
||||
|
||||
test "const expr eval on single expr blocks" {
|
||||
try expect(constExprEvalOnSingleExprBlocksFn(1, true) == 3);
|
||||
comptime try expect(constExprEvalOnSingleExprBlocksFn(1, true) == 3);
|
||||
try comptime expect(constExprEvalOnSingleExprBlocksFn(1, true) == 3);
|
||||
}
|
||||
|
||||
fn constExprEvalOnSingleExprBlocksFn(x: i32, b: bool) i32 {
|
||||
@ -436,7 +436,7 @@ test "f64 at compile time is lossy" {
|
||||
}
|
||||
|
||||
test {
|
||||
comptime try expect(@as(f128, 1 << 113) == 10384593717069655257060992658440192);
|
||||
try comptime expect(@as(f128, 1 << 113) == 10384593717069655257060992658440192);
|
||||
}
|
||||
|
||||
fn copyWithPartialInline(s: []u32, b: []u8) void {
|
||||
@ -625,7 +625,7 @@ test "const global shares pointer with other same one" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try assertEqualPtrs(&hi1[0], &hi2[0]);
|
||||
comptime try expect(&hi1[0] == &hi2[0]);
|
||||
try comptime expect(&hi1[0] == &hi2[0]);
|
||||
}
|
||||
fn assertEqualPtrs(ptr1: *const u8, ptr2: *const u8) !void {
|
||||
try expect(ptr1 == ptr2);
|
||||
@ -646,8 +646,8 @@ fn assertEqualPtrs(ptr1: *const u8, ptr2: *const u8) !void {
|
||||
test "string literal used as comptime slice is memoized" {
|
||||
const a = "link";
|
||||
const b = "link";
|
||||
comptime try expect(TypeWithCompTimeSlice(a).Node == TypeWithCompTimeSlice(b).Node);
|
||||
comptime try expect(TypeWithCompTimeSlice("link").Node == TypeWithCompTimeSlice("link").Node);
|
||||
try comptime expect(TypeWithCompTimeSlice(a).Node == TypeWithCompTimeSlice(b).Node);
|
||||
try comptime expect(TypeWithCompTimeSlice("link").Node == TypeWithCompTimeSlice("link").Node);
|
||||
}
|
||||
|
||||
pub fn TypeWithCompTimeSlice(comptime field_name: []const u8) type {
|
||||
@ -1072,7 +1072,7 @@ test "comptime break operand passing through runtime condition converted to runt
|
||||
};
|
||||
|
||||
try S.doTheTest('b');
|
||||
comptime try S.doTheTest('b');
|
||||
try comptime S.doTheTest('b');
|
||||
}
|
||||
|
||||
test "comptime break operand passing through runtime switch converted to runtime break" {
|
||||
@ -1092,7 +1092,7 @@ test "comptime break operand passing through runtime switch converted to runtime
|
||||
};
|
||||
|
||||
try S.doTheTest('b');
|
||||
comptime try S.doTheTest('b');
|
||||
try comptime S.doTheTest('b');
|
||||
}
|
||||
|
||||
test "no dependency loop for alignment of self struct" {
|
||||
@ -1349,7 +1349,7 @@ test "value in if block is comptime-known" {
|
||||
const s = if (false) S{ .str = "a" } else S{ .str = "b" };
|
||||
break :blk "foo" ++ s.str;
|
||||
};
|
||||
comptime try expect(std.mem.eql(u8, first, second));
|
||||
try comptime expect(std.mem.eql(u8, first, second));
|
||||
}
|
||||
|
||||
test "lazy sizeof is resolved in division" {
|
||||
@ -1448,7 +1448,7 @@ test "length of global array is determinable at comptime" {
|
||||
try std.testing.expect(bytes.len == 1024);
|
||||
}
|
||||
};
|
||||
comptime try S.foo();
|
||||
try comptime S.foo();
|
||||
}
|
||||
|
||||
test "continue nested inline for loop" {
|
||||
@ -1574,7 +1574,7 @@ test "comptime function turns function value to function pointer" {
|
||||
fnPtr(Nil),
|
||||
};
|
||||
};
|
||||
comptime try expect(S.foo[0] == &S.Nil);
|
||||
try comptime expect(S.foo[0] == &S.Nil);
|
||||
}
|
||||
|
||||
test "container level const and var have unique addresses" {
|
||||
|
@ -7,7 +7,7 @@ test "@fieldParentPtr non-first field" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testParentFieldPtr(&foo.c);
|
||||
comptime try testParentFieldPtr(&foo.c);
|
||||
try comptime testParentFieldPtr(&foo.c);
|
||||
}
|
||||
|
||||
test "@fieldParentPtr first field" {
|
||||
@ -16,7 +16,7 @@ test "@fieldParentPtr first field" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testParentFieldPtrFirst(&foo.a);
|
||||
comptime try testParentFieldPtrFirst(&foo.a);
|
||||
try comptime testParentFieldPtrFirst(&foo.a);
|
||||
}
|
||||
|
||||
const Foo = struct {
|
||||
@ -56,7 +56,7 @@ test "@fieldParentPtr untagged union" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testFieldParentPtrUnion(&bar.c);
|
||||
comptime try testFieldParentPtrUnion(&bar.c);
|
||||
try comptime testFieldParentPtrUnion(&bar.c);
|
||||
}
|
||||
|
||||
const Bar = union(enum) {
|
||||
@ -83,7 +83,7 @@ test "@fieldParentPtr tagged union" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testFieldParentPtrTaggedUnion(&bar_tagged.c);
|
||||
comptime try testFieldParentPtrTaggedUnion(&bar_tagged.c);
|
||||
try comptime testFieldParentPtrTaggedUnion(&bar_tagged.c);
|
||||
}
|
||||
|
||||
const BarTagged = union(enum) {
|
||||
@ -110,7 +110,7 @@ test "@fieldParentPtr extern union" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testFieldParentPtrExternUnion(&bar_extern.c);
|
||||
comptime try testFieldParentPtrExternUnion(&bar_extern.c);
|
||||
try comptime testFieldParentPtrExternUnion(&bar_extern.c);
|
||||
}
|
||||
|
||||
const BarExtern = extern union {
|
||||
|
@ -25,7 +25,7 @@ test "floating point comparisons" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try testFloatComparisons();
|
||||
comptime try testFloatComparisons();
|
||||
try comptime testFloatComparisons();
|
||||
}
|
||||
|
||||
fn testFloatComparisons() !void {
|
||||
@ -61,7 +61,7 @@ test "different sized float comparisons" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testDifferentSizedFloatComparisons();
|
||||
comptime try testDifferentSizedFloatComparisons();
|
||||
try comptime testDifferentSizedFloatComparisons();
|
||||
}
|
||||
|
||||
fn testDifferentSizedFloatComparisons() !void {
|
||||
@ -104,7 +104,7 @@ test "@sqrt" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testSqrt();
|
||||
try comptime testSqrt();
|
||||
try testSqrt();
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ test "@sqrt with vectors" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testSqrtWithVectors();
|
||||
try comptime testSqrtWithVectors();
|
||||
try testSqrtWithVectors();
|
||||
}
|
||||
|
||||
@ -188,18 +188,18 @@ test "another, possibly redundant @sqrt test" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testSqrtLegacy(f64, 12.0);
|
||||
comptime try testSqrtLegacy(f64, 12.0);
|
||||
try comptime testSqrtLegacy(f64, 12.0);
|
||||
try testSqrtLegacy(f32, 13.0);
|
||||
comptime try testSqrtLegacy(f32, 13.0);
|
||||
try comptime testSqrtLegacy(f32, 13.0);
|
||||
try testSqrtLegacy(f16, 13.0);
|
||||
comptime try testSqrtLegacy(f16, 13.0);
|
||||
try comptime testSqrtLegacy(f16, 13.0);
|
||||
|
||||
// TODO: make this pass
|
||||
if (false) {
|
||||
const x = 14.0;
|
||||
const y = x * x;
|
||||
const z = @sqrt(y);
|
||||
comptime try expect(z == x);
|
||||
try comptime expect(z == x);
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ test "@sin" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testSin();
|
||||
try comptime testSin();
|
||||
try testSin();
|
||||
}
|
||||
|
||||
@ -235,7 +235,7 @@ test "@sin with vectors" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testSinWithVectors();
|
||||
try comptime testSinWithVectors();
|
||||
try testSinWithVectors();
|
||||
}
|
||||
|
||||
@ -255,7 +255,7 @@ test "@cos" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testCos();
|
||||
try comptime testCos();
|
||||
try testCos();
|
||||
}
|
||||
|
||||
@ -276,7 +276,7 @@ test "@cos with vectors" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testCosWithVectors();
|
||||
try comptime testCosWithVectors();
|
||||
try testCosWithVectors();
|
||||
}
|
||||
|
||||
@ -296,7 +296,7 @@ test "@exp" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testExp();
|
||||
try comptime testExp();
|
||||
try testExp();
|
||||
}
|
||||
|
||||
@ -316,7 +316,7 @@ test "@exp with vectors" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testExpWithVectors();
|
||||
try comptime testExpWithVectors();
|
||||
try testExpWithVectors();
|
||||
}
|
||||
|
||||
@ -336,7 +336,7 @@ test "@exp2" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testExp2();
|
||||
try comptime testExp2();
|
||||
try testExp2();
|
||||
}
|
||||
|
||||
@ -356,7 +356,7 @@ test "@exp2 with @vectors" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testExp2WithVectors();
|
||||
try comptime testExp2WithVectors();
|
||||
try testExp2WithVectors();
|
||||
}
|
||||
|
||||
@ -376,7 +376,7 @@ test "@log" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testLog();
|
||||
try comptime testLog();
|
||||
try testLog();
|
||||
}
|
||||
|
||||
@ -425,7 +425,7 @@ test "@log2" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testLog2();
|
||||
try comptime testLog2();
|
||||
try testLog2();
|
||||
}
|
||||
|
||||
@ -449,7 +449,7 @@ test "@log2 with vectors" {
|
||||
builtin.cpu.arch == .aarch64 and
|
||||
builtin.os.tag == .windows) return error.SkipZigTest;
|
||||
|
||||
comptime try testLog2WithVectors();
|
||||
try comptime testLog2WithVectors();
|
||||
try testLog2WithVectors();
|
||||
}
|
||||
|
||||
@ -469,7 +469,7 @@ test "@log10" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testLog10();
|
||||
try comptime testLog10();
|
||||
try testLog10();
|
||||
}
|
||||
|
||||
@ -489,7 +489,7 @@ test "@log10 with vectors" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testLog10WithVectors();
|
||||
try comptime testLog10WithVectors();
|
||||
try testLog10WithVectors();
|
||||
}
|
||||
|
||||
@ -507,7 +507,7 @@ test "@fabs" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
comptime try testFabs();
|
||||
try comptime testFabs();
|
||||
try testFabs();
|
||||
}
|
||||
|
||||
@ -535,7 +535,7 @@ test "@fabs with vectors" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testFabsWithVectors();
|
||||
try comptime testFabsWithVectors();
|
||||
try testFabsWithVectors();
|
||||
}
|
||||
|
||||
@ -556,18 +556,18 @@ test "another, possibly redundant, @fabs test" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testFabsLegacy(f128, 12.0);
|
||||
comptime try testFabsLegacy(f128, 12.0);
|
||||
try comptime testFabsLegacy(f128, 12.0);
|
||||
try testFabsLegacy(f64, 12.0);
|
||||
comptime try testFabsLegacy(f64, 12.0);
|
||||
try comptime testFabsLegacy(f64, 12.0);
|
||||
try testFabsLegacy(f32, 12.0);
|
||||
comptime try testFabsLegacy(f32, 12.0);
|
||||
try comptime testFabsLegacy(f32, 12.0);
|
||||
try testFabsLegacy(f16, 12.0);
|
||||
comptime try testFabsLegacy(f16, 12.0);
|
||||
try comptime testFabsLegacy(f16, 12.0);
|
||||
|
||||
const x = 14.0;
|
||||
const y = -x;
|
||||
const z = @fabs(y);
|
||||
comptime try std.testing.expectEqual(x, z);
|
||||
try comptime std.testing.expectEqual(x, z);
|
||||
}
|
||||
|
||||
test "@fabs f80" {
|
||||
@ -578,7 +578,7 @@ test "@fabs f80" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testFabsLegacy(f80, 12.0);
|
||||
comptime try testFabsLegacy(f80, 12.0);
|
||||
try comptime testFabsLegacy(f80, 12.0);
|
||||
}
|
||||
|
||||
fn testFabsLegacy(comptime T: type, x: T) !void {
|
||||
@ -621,7 +621,7 @@ test "@floor" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
comptime try testFloor();
|
||||
try comptime testFloor();
|
||||
try testFloor();
|
||||
}
|
||||
|
||||
@ -646,7 +646,7 @@ test "@floor with vectors" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testFloorWithVectors();
|
||||
try comptime testFloorWithVectors();
|
||||
try testFloorWithVectors();
|
||||
}
|
||||
|
||||
@ -666,16 +666,16 @@ test "another, possibly redundant, @floor test" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testFloorLegacy(f64, 12.0);
|
||||
comptime try testFloorLegacy(f64, 12.0);
|
||||
try comptime testFloorLegacy(f64, 12.0);
|
||||
try testFloorLegacy(f32, 12.0);
|
||||
comptime try testFloorLegacy(f32, 12.0);
|
||||
try comptime testFloorLegacy(f32, 12.0);
|
||||
try testFloorLegacy(f16, 12.0);
|
||||
comptime try testFloorLegacy(f16, 12.0);
|
||||
try comptime testFloorLegacy(f16, 12.0);
|
||||
|
||||
const x = 14.0;
|
||||
const y = x + 0.7;
|
||||
const z = @floor(y);
|
||||
comptime try expect(x == z);
|
||||
try comptime expect(x == z);
|
||||
}
|
||||
|
||||
test "@floor f80" {
|
||||
@ -691,7 +691,7 @@ test "@floor f80" {
|
||||
}
|
||||
|
||||
try testFloorLegacy(f80, 12.0);
|
||||
comptime try testFloorLegacy(f80, 12.0);
|
||||
try comptime testFloorLegacy(f80, 12.0);
|
||||
}
|
||||
|
||||
test "@floor f128" {
|
||||
@ -702,7 +702,7 @@ test "@floor f128" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testFloorLegacy(f128, 12.0);
|
||||
comptime try testFloorLegacy(f128, 12.0);
|
||||
try comptime testFloorLegacy(f128, 12.0);
|
||||
}
|
||||
|
||||
fn testFloorLegacy(comptime T: type, x: T) !void {
|
||||
@ -717,7 +717,7 @@ test "@ceil" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testCeil();
|
||||
try comptime testCeil();
|
||||
try testCeil();
|
||||
}
|
||||
|
||||
@ -742,7 +742,7 @@ test "@ceil with vectors" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testCeilWithVectors();
|
||||
try comptime testCeilWithVectors();
|
||||
try testCeilWithVectors();
|
||||
}
|
||||
|
||||
@ -762,16 +762,16 @@ test "another, possibly redundant, @ceil test" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testCeilLegacy(f64, 12.0);
|
||||
comptime try testCeilLegacy(f64, 12.0);
|
||||
try comptime testCeilLegacy(f64, 12.0);
|
||||
try testCeilLegacy(f32, 12.0);
|
||||
comptime try testCeilLegacy(f32, 12.0);
|
||||
try comptime testCeilLegacy(f32, 12.0);
|
||||
try testCeilLegacy(f16, 12.0);
|
||||
comptime try testCeilLegacy(f16, 12.0);
|
||||
try comptime testCeilLegacy(f16, 12.0);
|
||||
|
||||
const x = 14.0;
|
||||
const y = x - 0.7;
|
||||
const z = @ceil(y);
|
||||
comptime try expect(x == z);
|
||||
try comptime expect(x == z);
|
||||
}
|
||||
|
||||
test "@ceil f80" {
|
||||
@ -787,7 +787,7 @@ test "@ceil f80" {
|
||||
}
|
||||
|
||||
try testCeilLegacy(f80, 12.0);
|
||||
comptime try testCeilLegacy(f80, 12.0);
|
||||
try comptime testCeilLegacy(f80, 12.0);
|
||||
}
|
||||
|
||||
test "@ceil f128" {
|
||||
@ -798,7 +798,7 @@ test "@ceil f128" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testCeilLegacy(f128, 12.0);
|
||||
comptime try testCeilLegacy(f128, 12.0);
|
||||
try comptime testCeilLegacy(f128, 12.0);
|
||||
}
|
||||
|
||||
fn testCeilLegacy(comptime T: type, x: T) !void {
|
||||
@ -812,7 +812,7 @@ test "@trunc" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
comptime try testTrunc();
|
||||
try comptime testTrunc();
|
||||
try testTrunc();
|
||||
}
|
||||
|
||||
@ -837,7 +837,7 @@ test "@trunc with vectors" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testTruncWithVectors();
|
||||
try comptime testTruncWithVectors();
|
||||
try testTruncWithVectors();
|
||||
}
|
||||
|
||||
@ -857,16 +857,16 @@ test "another, possibly redundant, @trunc test" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testTruncLegacy(f64, 12.0);
|
||||
comptime try testTruncLegacy(f64, 12.0);
|
||||
try comptime testTruncLegacy(f64, 12.0);
|
||||
try testTruncLegacy(f32, 12.0);
|
||||
comptime try testTruncLegacy(f32, 12.0);
|
||||
try comptime testTruncLegacy(f32, 12.0);
|
||||
try testTruncLegacy(f16, 12.0);
|
||||
comptime try testTruncLegacy(f16, 12.0);
|
||||
try comptime testTruncLegacy(f16, 12.0);
|
||||
|
||||
const x = 14.0;
|
||||
const y = x + 0.7;
|
||||
const z = @trunc(y);
|
||||
comptime try expect(x == z);
|
||||
try comptime expect(x == z);
|
||||
}
|
||||
|
||||
test "@trunc f80" {
|
||||
@ -882,7 +882,7 @@ test "@trunc f80" {
|
||||
}
|
||||
|
||||
try testTruncLegacy(f80, 12.0);
|
||||
comptime try testTruncLegacy(f80, 12.0);
|
||||
try comptime testTruncLegacy(f80, 12.0);
|
||||
comptime {
|
||||
const x: f80 = 12.0;
|
||||
const y = x + 0.8;
|
||||
@ -899,7 +899,7 @@ test "@trunc f128" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testTruncLegacy(f128, 12.0);
|
||||
comptime try testTruncLegacy(f128, 12.0);
|
||||
try comptime testTruncLegacy(f128, 12.0);
|
||||
}
|
||||
|
||||
fn testTruncLegacy(comptime T: type, x: T) !void {
|
||||
@ -939,7 +939,7 @@ test "negation f16" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "negation f32" {
|
||||
@ -959,7 +959,7 @@ test "negation f32" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "negation f64" {
|
||||
@ -979,7 +979,7 @@ test "negation f64" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "negation f80" {
|
||||
@ -1001,7 +1001,7 @@ test "negation f80" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "negation f128" {
|
||||
@ -1023,7 +1023,7 @@ test "negation f128" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "eval @setFloatMode at compile-time" {
|
||||
|
@ -211,7 +211,7 @@ test "pass by non-copying value through var arg" {
|
||||
}
|
||||
|
||||
fn addPointCoordsVar(pt: anytype) !i32 {
|
||||
comptime try expect(@TypeOf(pt) == Point);
|
||||
try comptime expect(@TypeOf(pt) == Point);
|
||||
return pt.x + pt.y;
|
||||
}
|
||||
|
||||
@ -285,7 +285,7 @@ test "implicit cast fn call result to optional in field result" {
|
||||
};
|
||||
};
|
||||
try S.entry();
|
||||
comptime try S.entry();
|
||||
try comptime S.entry();
|
||||
}
|
||||
|
||||
test "void parameters" {
|
||||
@ -344,7 +344,7 @@ fn fn4() u32 {
|
||||
|
||||
test "number literal as an argument" {
|
||||
try numberLiteralArg(3);
|
||||
comptime try numberLiteralArg(3);
|
||||
try comptime numberLiteralArg(3);
|
||||
}
|
||||
|
||||
fn numberLiteralArg(a: anytype) !void {
|
||||
@ -369,7 +369,7 @@ test "function call with anon list literal" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "function call with anon list literal - 2D" {
|
||||
@ -391,7 +391,7 @@ test "function call with anon list literal - 2D" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "ability to give comptime types and non comptime types to same parameter" {
|
||||
@ -410,7 +410,7 @@ test "ability to give comptime types and non comptime types to same parameter" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "function with inferred error set but returning no error" {
|
||||
|
@ -23,7 +23,7 @@ test "continue in for loop" {
|
||||
|
||||
test "break from outer for loop" {
|
||||
try testBreakOuter();
|
||||
comptime try testBreakOuter();
|
||||
try comptime testBreakOuter();
|
||||
}
|
||||
|
||||
fn testBreakOuter() !void {
|
||||
@ -40,7 +40,7 @@ fn testBreakOuter() !void {
|
||||
|
||||
test "continue outer for loop" {
|
||||
try testContinueOuter();
|
||||
comptime try testContinueOuter();
|
||||
try comptime testContinueOuter();
|
||||
}
|
||||
|
||||
fn testContinueOuter() !void {
|
||||
@ -129,7 +129,7 @@ test "for with null and T peer types and inferred result location type" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest(&[_]u8{ 1, 2 });
|
||||
comptime try S.doTheTest(&[_]u8{ 1, 2 });
|
||||
try comptime S.doTheTest(&[_]u8{ 1, 2 });
|
||||
}
|
||||
|
||||
test "2 break statements and an else" {
|
||||
@ -150,7 +150,7 @@ test "2 break statements and an else" {
|
||||
}
|
||||
};
|
||||
try S.entry(true, false);
|
||||
comptime try S.entry(true, false);
|
||||
try comptime S.entry(true, false);
|
||||
}
|
||||
|
||||
test "for loop with pointer elem var" {
|
||||
@ -197,7 +197,7 @@ test "for copies its payload" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "for on slice with allowzero ptr" {
|
||||
@ -214,7 +214,7 @@ test "for on slice with allowzero ptr" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest(&[_]u8{ 1, 2, 3, 4 });
|
||||
comptime try S.doTheTest(&[_]u8{ 1, 2, 3, 4 });
|
||||
try comptime S.doTheTest(&[_]u8{ 1, 2, 3, 4 });
|
||||
}
|
||||
|
||||
test "else continue outer for" {
|
||||
|
@ -93,7 +93,7 @@ test "if copies its payload" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "if prongs cast to expected type instead of peer type resolution" {
|
||||
@ -109,7 +109,7 @@ test "if prongs cast to expected type instead of peer type resolution" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest(false);
|
||||
comptime try S.doTheTest(false);
|
||||
try comptime S.doTheTest(false);
|
||||
}
|
||||
|
||||
test "if peer expressions inferred optional type" {
|
||||
|
@ -95,16 +95,16 @@ test "shift int128" {
|
||||
const types = .{ u128, i128 };
|
||||
inline for (types) |t| {
|
||||
try testShlTrunc(t, 0x8, 123);
|
||||
comptime try testShlTrunc(t, 0x8, 123);
|
||||
try comptime testShlTrunc(t, 0x8, 123);
|
||||
|
||||
try testShlTrunc(t, 0x40000000_00000000, 64);
|
||||
comptime try testShlTrunc(t, 0x40000000_00000000, 64);
|
||||
try comptime testShlTrunc(t, 0x40000000_00000000, 64);
|
||||
|
||||
try testShlTrunc(t, 0x01000000_00000000_00000000, 38);
|
||||
comptime try testShlTrunc(t, 0x01000000_00000000_00000000, 38);
|
||||
try comptime testShlTrunc(t, 0x01000000_00000000_00000000, 38);
|
||||
|
||||
try testShlTrunc(t, 0x00000008_00000000_00000000_00000000, 27);
|
||||
comptime try testShlTrunc(t, 0x00000008_00000000_00000000_00000000, 27);
|
||||
try comptime testShlTrunc(t, 0x00000008_00000000_00000000_00000000, 27);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ test "integer division" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try testDivision();
|
||||
comptime try testDivision();
|
||||
try comptime testDivision();
|
||||
}
|
||||
fn testDivision() !void {
|
||||
try expect(div(u32, 13, 3) == 4);
|
||||
|
@ -40,7 +40,7 @@ test "assignment operators" {
|
||||
|
||||
test "three expr in a row" {
|
||||
try testThreeExprInARow(false, true);
|
||||
comptime try testThreeExprInARow(false, true);
|
||||
try comptime testThreeExprInARow(false, true);
|
||||
}
|
||||
fn testThreeExprInARow(f: bool, t: bool) !void {
|
||||
try assertFalse(f or f or f);
|
||||
@ -67,7 +67,7 @@ test "@clz" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testClz();
|
||||
comptime try testClz();
|
||||
try comptime testClz();
|
||||
}
|
||||
|
||||
fn testClz() !void {
|
||||
@ -86,7 +86,7 @@ test "@clz big ints" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testClzBigInts();
|
||||
comptime try testClzBigInts();
|
||||
try comptime testClzBigInts();
|
||||
}
|
||||
|
||||
fn testClzBigInts() !void {
|
||||
@ -107,7 +107,7 @@ test "@clz vectors" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testClzVectors();
|
||||
comptime try testClzVectors();
|
||||
try comptime testClzVectors();
|
||||
}
|
||||
|
||||
fn testClzVectors() !void {
|
||||
@ -147,7 +147,7 @@ test "@ctz" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testCtz();
|
||||
comptime try testCtz();
|
||||
try comptime testCtz();
|
||||
}
|
||||
|
||||
fn testCtz() !void {
|
||||
@ -176,7 +176,7 @@ test "@ctz vectors" {
|
||||
}
|
||||
|
||||
try testCtzVectors();
|
||||
comptime try testCtzVectors();
|
||||
try comptime testCtzVectors();
|
||||
}
|
||||
|
||||
fn testCtzVectors() !void {
|
||||
@ -213,7 +213,7 @@ test "float equality" {
|
||||
const y: f64 = x + 1.0;
|
||||
|
||||
try testFloatEqualityImpl(x, y);
|
||||
comptime try testFloatEqualityImpl(x, y);
|
||||
try comptime testFloatEqualityImpl(x, y);
|
||||
}
|
||||
|
||||
fn testFloatEqualityImpl(x: f64, y: f64) !void {
|
||||
@ -222,7 +222,7 @@ fn testFloatEqualityImpl(x: f64, y: f64) !void {
|
||||
}
|
||||
|
||||
test "hex float literal parsing" {
|
||||
comptime try expect(0x1.0 == 1.0);
|
||||
try comptime expect(0x1.0 == 1.0);
|
||||
}
|
||||
|
||||
test "hex float literal within range" {
|
||||
@ -323,7 +323,7 @@ test "comptime_int multi-limb partial shift right" {
|
||||
|
||||
test "xor" {
|
||||
try test_xor();
|
||||
comptime try test_xor();
|
||||
try comptime test_xor();
|
||||
}
|
||||
|
||||
fn test_xor() !void {
|
||||
@ -412,7 +412,7 @@ test "division" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testDivision();
|
||||
comptime try testDivision();
|
||||
try comptime testDivision();
|
||||
}
|
||||
|
||||
fn testDivision() !void {
|
||||
@ -492,7 +492,7 @@ test "division half-precision floats" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testDivisionFP16();
|
||||
comptime try testDivisionFP16();
|
||||
try comptime testDivisionFP16();
|
||||
}
|
||||
|
||||
fn testDivisionFP16() !void {
|
||||
@ -527,7 +527,7 @@ fn mod(comptime T: type, a: T, b: T) T {
|
||||
|
||||
test "unsigned wrapping" {
|
||||
try testUnsignedWrappingEval(maxInt(u32));
|
||||
comptime try testUnsignedWrappingEval(maxInt(u32));
|
||||
try comptime testUnsignedWrappingEval(maxInt(u32));
|
||||
}
|
||||
fn testUnsignedWrappingEval(x: u32) !void {
|
||||
const zero = x +% 1;
|
||||
@ -538,7 +538,7 @@ fn testUnsignedWrappingEval(x: u32) !void {
|
||||
|
||||
test "signed wrapping" {
|
||||
try testSignedWrappingEval(maxInt(i32));
|
||||
comptime try testSignedWrappingEval(maxInt(i32));
|
||||
try comptime testSignedWrappingEval(maxInt(i32));
|
||||
}
|
||||
fn testSignedWrappingEval(x: i32) !void {
|
||||
const min_val = x +% 1;
|
||||
@ -549,7 +549,7 @@ fn testSignedWrappingEval(x: i32) !void {
|
||||
|
||||
test "signed negation wrapping" {
|
||||
try testSignedNegationWrappingEval(minInt(i16));
|
||||
comptime try testSignedNegationWrappingEval(minInt(i16));
|
||||
try comptime testSignedNegationWrappingEval(minInt(i16));
|
||||
}
|
||||
fn testSignedNegationWrappingEval(x: i16) !void {
|
||||
try expect(x == -32768);
|
||||
@ -559,7 +559,7 @@ fn testSignedNegationWrappingEval(x: i16) !void {
|
||||
|
||||
test "unsigned negation wrapping" {
|
||||
try testUnsignedNegationWrappingEval(1);
|
||||
comptime try testUnsignedNegationWrappingEval(1);
|
||||
try comptime testUnsignedNegationWrappingEval(1);
|
||||
}
|
||||
fn testUnsignedNegationWrappingEval(x: u16) !void {
|
||||
try expect(x == 1);
|
||||
@ -586,7 +586,7 @@ test "unsigned 64-bit division" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try test_u64_div();
|
||||
comptime try test_u64_div();
|
||||
try comptime test_u64_div();
|
||||
}
|
||||
fn test_u64_div() !void {
|
||||
const result = divWithResult(1152921504606846976, 34359738365);
|
||||
@ -614,7 +614,7 @@ test "truncating shift right" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testShrTrunc(maxInt(u16));
|
||||
comptime try testShrTrunc(maxInt(u16));
|
||||
try comptime testShrTrunc(maxInt(u16));
|
||||
}
|
||||
fn testShrTrunc(x: u16) !void {
|
||||
const shifted = x >> 1;
|
||||
@ -630,7 +630,7 @@ test "f128" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try test_f128();
|
||||
comptime try test_f128();
|
||||
try comptime test_f128();
|
||||
}
|
||||
|
||||
fn make_f128(x: f128) f128 {
|
||||
@ -1238,12 +1238,12 @@ test "quad hex float literal parsing accurate" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "truncating shift left" {
|
||||
try testShlTrunc(maxInt(u16));
|
||||
comptime try testShlTrunc(maxInt(u16));
|
||||
try comptime testShlTrunc(maxInt(u16));
|
||||
}
|
||||
fn testShlTrunc(x: u16) !void {
|
||||
const shifted = x << 1;
|
||||
@ -1254,7 +1254,7 @@ test "exact shift left" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testShlExact(0b00110101);
|
||||
comptime try testShlExact(0b00110101);
|
||||
try comptime testShlExact(0b00110101);
|
||||
}
|
||||
fn testShlExact(x: u8) !void {
|
||||
const shifted = @shlExact(x, 2);
|
||||
@ -1265,7 +1265,7 @@ test "exact shift right" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testShrExact(0b10110100);
|
||||
comptime try testShrExact(0b10110100);
|
||||
try comptime testShrExact(0b10110100);
|
||||
}
|
||||
fn testShrExact(x: u8) !void {
|
||||
const shifted = @shrExact(x, 2);
|
||||
@ -1288,7 +1288,7 @@ test "shift left/right on u0 operand" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "comptime float rem int" {
|
||||
@ -1311,11 +1311,11 @@ test "remainder division" {
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
comptime try remdiv(f16);
|
||||
comptime try remdiv(f32);
|
||||
comptime try remdiv(f64);
|
||||
comptime try remdiv(f80);
|
||||
comptime try remdiv(f128);
|
||||
try comptime remdiv(f16);
|
||||
try comptime remdiv(f32);
|
||||
try comptime remdiv(f64);
|
||||
try comptime remdiv(f80);
|
||||
try comptime remdiv(f128);
|
||||
try remdiv(f16);
|
||||
try remdiv(f64);
|
||||
try remdiv(f80);
|
||||
@ -1343,11 +1343,11 @@ test "float remainder division using @rem" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
|
||||
|
||||
comptime try frem(f16);
|
||||
comptime try frem(f32);
|
||||
comptime try frem(f64);
|
||||
comptime try frem(f80);
|
||||
comptime try frem(f128);
|
||||
try comptime frem(f16);
|
||||
try comptime frem(f32);
|
||||
try comptime frem(f64);
|
||||
try comptime frem(f80);
|
||||
try comptime frem(f128);
|
||||
try frem(f16);
|
||||
try frem(f32);
|
||||
try frem(f64);
|
||||
@ -1386,11 +1386,11 @@ test "float modulo division using @mod" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try fmod(f16);
|
||||
comptime try fmod(f32);
|
||||
comptime try fmod(f64);
|
||||
comptime try fmod(f80);
|
||||
comptime try fmod(f128);
|
||||
try comptime fmod(f16);
|
||||
try comptime fmod(f32);
|
||||
try comptime fmod(f64);
|
||||
try comptime fmod(f80);
|
||||
try comptime fmod(f128);
|
||||
try fmod(f16);
|
||||
try fmod(f32);
|
||||
try fmod(f64);
|
||||
@ -1430,16 +1430,16 @@ test "@round" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testRound(f64, 12.0);
|
||||
comptime try testRound(f64, 12.0);
|
||||
try comptime testRound(f64, 12.0);
|
||||
try testRound(f32, 12.0);
|
||||
comptime try testRound(f32, 12.0);
|
||||
try comptime testRound(f32, 12.0);
|
||||
try testRound(f16, 12.0);
|
||||
comptime try testRound(f16, 12.0);
|
||||
try comptime testRound(f16, 12.0);
|
||||
|
||||
const x = 14.0;
|
||||
const y = x + 0.4;
|
||||
const z = @round(y);
|
||||
comptime try expect(x == z);
|
||||
try comptime expect(x == z);
|
||||
}
|
||||
|
||||
test "@round f80" {
|
||||
@ -1451,7 +1451,7 @@ test "@round f80" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testRound(f80, 12.0);
|
||||
comptime try testRound(f80, 12.0);
|
||||
try comptime testRound(f80, 12.0);
|
||||
}
|
||||
|
||||
test "@round f128" {
|
||||
@ -1463,7 +1463,7 @@ test "@round f128" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testRound(f128, 12.0);
|
||||
comptime try testRound(f128, 12.0);
|
||||
try comptime testRound(f128, 12.0);
|
||||
}
|
||||
|
||||
fn testRound(comptime T: type, x: T) !void {
|
||||
@ -1491,7 +1491,7 @@ test "vector integer addition" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "NaN comparison" {
|
||||
@ -1506,10 +1506,10 @@ test "NaN comparison" {
|
||||
try testNanEqNan(f32);
|
||||
try testNanEqNan(f64);
|
||||
try testNanEqNan(f128);
|
||||
comptime try testNanEqNan(f16);
|
||||
comptime try testNanEqNan(f32);
|
||||
comptime try testNanEqNan(f64);
|
||||
comptime try testNanEqNan(f128);
|
||||
try comptime testNanEqNan(f16);
|
||||
try comptime testNanEqNan(f32);
|
||||
try comptime testNanEqNan(f64);
|
||||
try comptime testNanEqNan(f128);
|
||||
}
|
||||
|
||||
test "NaN comparison f80" {
|
||||
@ -1521,7 +1521,7 @@ test "NaN comparison f80" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testNanEqNan(f80);
|
||||
comptime try testNanEqNan(f80);
|
||||
try comptime testNanEqNan(f80);
|
||||
}
|
||||
|
||||
fn testNanEqNan(comptime F: type) !void {
|
||||
@ -1556,7 +1556,7 @@ test "vector comparison" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "compare undefined literal with comptime_int" {
|
||||
@ -1593,7 +1593,7 @@ test "signed zeros are represented properly" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "comptime sin and ln" {
|
||||
@ -1609,7 +1609,7 @@ test "absFloat" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testAbsFloat();
|
||||
comptime try testAbsFloat();
|
||||
try comptime testAbsFloat();
|
||||
}
|
||||
fn testAbsFloat() !void {
|
||||
try testAbsFloatOne(-10.05, 10.05);
|
||||
|
@ -19,7 +19,7 @@ test "@max" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "@max on vectors" {
|
||||
@ -50,7 +50,7 @@ test "@max on vectors" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "@min" {
|
||||
@ -68,7 +68,7 @@ test "@min" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "@min for vectors" {
|
||||
@ -99,7 +99,7 @@ test "@min for vectors" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "@min/max for floats" {
|
||||
@ -123,9 +123,9 @@ test "@min/max for floats" {
|
||||
|
||||
inline for (.{ f16, f32, f64, f80, f128, c_longdouble }) |T| {
|
||||
try S.doTheTest(T);
|
||||
comptime try S.doTheTest(T);
|
||||
try comptime S.doTheTest(T);
|
||||
}
|
||||
comptime try S.doTheTest(comptime_float);
|
||||
try comptime S.doTheTest(comptime_float);
|
||||
}
|
||||
|
||||
test "@min/@max on lazy values" {
|
||||
|
@ -12,7 +12,7 @@ test "@mulAdd" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testMulAdd();
|
||||
try comptime testMulAdd();
|
||||
try testMulAdd();
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ test "@mulAdd f16" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testMulAdd16();
|
||||
try comptime testMulAdd16();
|
||||
try testMulAdd16();
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ test "@mulAdd f80" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testMulAdd80();
|
||||
try comptime testMulAdd80();
|
||||
try testMulAdd80();
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ test "@mulAdd f128" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testMulAdd128();
|
||||
try comptime testMulAdd128();
|
||||
try testMulAdd128();
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ test "vector f16" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try vector16();
|
||||
try comptime vector16();
|
||||
try vector16();
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ test "vector f32" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try vector32();
|
||||
try comptime vector32();
|
||||
try vector32();
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ test "vector f64" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try vector64();
|
||||
try comptime vector64();
|
||||
try vector64();
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ test "vector f80" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try vector80();
|
||||
try comptime vector80();
|
||||
try vector80();
|
||||
}
|
||||
|
||||
@ -202,6 +202,6 @@ test "vector f128" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try vector128();
|
||||
try comptime vector128();
|
||||
try vector128();
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ test "maybe return" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try maybeReturnImpl();
|
||||
comptime try maybeReturnImpl();
|
||||
try comptime maybeReturnImpl();
|
||||
}
|
||||
|
||||
fn maybeReturnImpl() !void {
|
||||
@ -87,7 +87,7 @@ test "optional void" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try optionalVoidImpl();
|
||||
comptime try optionalVoidImpl();
|
||||
try comptime optionalVoidImpl();
|
||||
}
|
||||
|
||||
fn optionalVoidImpl() !void {
|
||||
@ -111,7 +111,7 @@ test "optional struct{}" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
_ = try optionalEmptyStructImpl();
|
||||
_ = comptime try optionalEmptyStructImpl();
|
||||
_ = try comptime optionalEmptyStructImpl();
|
||||
}
|
||||
|
||||
fn optionalEmptyStructImpl() !void {
|
||||
|
@ -20,7 +20,7 @@ test "passing an optional integer as a parameter" {
|
||||
}
|
||||
};
|
||||
try expect(S.entry());
|
||||
comptime try expect(S.entry());
|
||||
try comptime expect(S.entry());
|
||||
}
|
||||
|
||||
pub const EmptyStruct = struct {};
|
||||
@ -38,7 +38,7 @@ test "equality compare optional pointers" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testNullPtrsEql();
|
||||
comptime try testNullPtrsEql();
|
||||
try comptime testNullPtrsEql();
|
||||
}
|
||||
|
||||
fn testNullPtrsEql() !void {
|
||||
@ -117,7 +117,7 @@ test "equality compare optional with non-optional" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try test_cmp_optional_non_optional();
|
||||
comptime try test_cmp_optional_non_optional();
|
||||
try comptime test_cmp_optional_non_optional();
|
||||
}
|
||||
|
||||
fn test_cmp_optional_non_optional() !void {
|
||||
@ -168,7 +168,7 @@ test "unwrap function call with optional pointer return value" {
|
||||
}
|
||||
};
|
||||
try S.entry();
|
||||
comptime try S.entry();
|
||||
try comptime S.entry();
|
||||
}
|
||||
|
||||
test "nested orelse" {
|
||||
@ -195,7 +195,7 @@ test "nested orelse" {
|
||||
};
|
||||
};
|
||||
try S.entry();
|
||||
comptime try S.entry();
|
||||
try comptime S.entry();
|
||||
}
|
||||
|
||||
test "self-referential struct through a slice of optional" {
|
||||
@ -250,7 +250,7 @@ test "coerce an anon struct literal to optional struct" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "0-bit child type coerced to optional return ptr result location" {
|
||||
@ -277,7 +277,7 @@ test "0-bit child type coerced to optional return ptr result location" {
|
||||
};
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "0-bit child type coerced to optional" {
|
||||
@ -303,7 +303,7 @@ test "0-bit child type coerced to optional" {
|
||||
};
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "array of optional unaligned types" {
|
||||
|
@ -351,7 +351,7 @@ test "byte-aligned field pointer offsets" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "load pointer from packed struct" {
|
||||
|
@ -5,7 +5,7 @@ const expect = testing.expect;
|
||||
const expectError = testing.expectError;
|
||||
|
||||
test "dereference pointer" {
|
||||
comptime try testDerefPtr();
|
||||
try comptime testDerefPtr();
|
||||
try testDerefPtr();
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ test "pointer arithmetic" {
|
||||
}
|
||||
|
||||
test "double pointer parsing" {
|
||||
comptime try expect(PtrOf(PtrOf(i32)) == **i32);
|
||||
try comptime expect(PtrOf(PtrOf(i32)) == **i32);
|
||||
}
|
||||
|
||||
fn PtrOf(comptime T: type) type {
|
||||
@ -62,7 +62,7 @@ test "implicit cast single item pointer to C pointer and back" {
|
||||
test "initialize const optional C pointer to null" {
|
||||
const a: ?[*c]i32 = null;
|
||||
try expect(a == null);
|
||||
comptime try expect(a == null);
|
||||
try comptime expect(a == null);
|
||||
}
|
||||
|
||||
test "assigning integer to C pointer" {
|
||||
@ -105,12 +105,12 @@ test "C pointer comparison and arithmetic" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "dereference pointer again" {
|
||||
try testDerefPtrOneVal();
|
||||
comptime try testDerefPtrOneVal();
|
||||
try comptime testDerefPtrOneVal();
|
||||
}
|
||||
|
||||
const Foo1 = struct {
|
||||
@ -180,7 +180,7 @@ test "implicit cast error unions with non-optional to optional pointer" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "compare equality of optional and non-optional pointer" {
|
||||
@ -203,11 +203,11 @@ test "allowzero pointer and slice" {
|
||||
try expect(@ptrToInt(ptr) == 0);
|
||||
var runtime_zero: usize = 0;
|
||||
var slice = ptr[runtime_zero..10];
|
||||
comptime try expect(@TypeOf(slice) == []allowzero i32);
|
||||
try comptime expect(@TypeOf(slice) == []allowzero i32);
|
||||
try expect(@ptrToInt(&slice[5]) == 20);
|
||||
|
||||
comptime try expect(@typeInfo(@TypeOf(ptr)).Pointer.is_allowzero);
|
||||
comptime try expect(@typeInfo(@TypeOf(slice)).Pointer.is_allowzero);
|
||||
try comptime expect(@typeInfo(@TypeOf(ptr)).Pointer.is_allowzero);
|
||||
try comptime expect(@typeInfo(@TypeOf(slice)).Pointer.is_allowzero);
|
||||
}
|
||||
|
||||
test "assign null directly to C pointer and test null equality" {
|
||||
@ -229,17 +229,17 @@ test "assign null directly to C pointer and test null equality" {
|
||||
try expect((x orelse &otherx) == &otherx);
|
||||
|
||||
const y: [*c]i32 = null;
|
||||
comptime try expect(y == null);
|
||||
comptime try expect(null == y);
|
||||
comptime try expect(!(y != null));
|
||||
comptime try expect(!(null != y));
|
||||
try comptime expect(y == null);
|
||||
try comptime expect(null == y);
|
||||
try comptime expect(!(y != null));
|
||||
try comptime expect(!(null != y));
|
||||
if (y) |same_y| {
|
||||
_ = same_y;
|
||||
@panic("fail");
|
||||
}
|
||||
const othery: i32 = undefined;
|
||||
const ptr_othery = &othery;
|
||||
comptime try expect((y orelse ptr_othery) == ptr_othery);
|
||||
try comptime expect((y orelse ptr_othery) == ptr_othery);
|
||||
|
||||
var n: i32 = 1234;
|
||||
var x1: [*c]i32 = &n;
|
||||
@ -257,17 +257,17 @@ test "assign null directly to C pointer and test null equality" {
|
||||
|
||||
const nc: i32 = 1234;
|
||||
const y1: [*c]const i32 = &nc;
|
||||
comptime try expect(!(y1 == null));
|
||||
comptime try expect(!(null == y1));
|
||||
comptime try expect(y1 != null);
|
||||
comptime try expect(null != y1);
|
||||
comptime try expect(y1.?.* == 1234);
|
||||
try comptime expect(!(y1 == null));
|
||||
try comptime expect(!(null == y1));
|
||||
try comptime expect(y1 != null);
|
||||
try comptime expect(null != y1);
|
||||
try comptime expect(y1.?.* == 1234);
|
||||
if (y1) |same_y1| {
|
||||
try expect(same_y1.* == 1234);
|
||||
} else {
|
||||
@compileError("fail");
|
||||
}
|
||||
comptime try expect((y1 orelse &othery) == y1);
|
||||
try comptime expect((y1 orelse &othery) == y1);
|
||||
}
|
||||
|
||||
test "array initialization types" {
|
||||
@ -293,7 +293,7 @@ test "null terminated pointer" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "allow any sentinel" {
|
||||
@ -308,7 +308,7 @@ test "allow any sentinel" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "pointer sentinel with enums" {
|
||||
@ -325,11 +325,11 @@ test "pointer sentinel with enums" {
|
||||
|
||||
fn doTheTest() !void {
|
||||
var ptr: [*:.sentinel]const Number = &[_:.sentinel]Number{ .one, .two, .two, .one };
|
||||
try expect(ptr[4] == .sentinel); // TODO this should be comptime try expect, see #3731
|
||||
try expect(ptr[4] == .sentinel); // TODO this should be try comptime expect, see #3731
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "pointer sentinel with optional element" {
|
||||
@ -341,11 +341,11 @@ test "pointer sentinel with optional element" {
|
||||
const S = struct {
|
||||
fn doTheTest() !void {
|
||||
var ptr: [*:null]const ?i32 = &[_:null]?i32{ 1, 2, 3, 4 };
|
||||
try expect(ptr[4] == null); // TODO this should be comptime try expect, see #3731
|
||||
try expect(ptr[4] == null); // TODO this should be try comptime expect, see #3731
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "pointer sentinel with +inf" {
|
||||
@ -357,13 +357,13 @@ test "pointer sentinel with +inf" {
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest() !void {
|
||||
const inf = std.math.inf_f32;
|
||||
var ptr: [*:inf]const f32 = &[_:inf]f32{ 1.1, 2.2, 3.3, 4.4 };
|
||||
try expect(ptr[4] == inf); // TODO this should be comptime try expect, see #3731
|
||||
const inf_f32 = comptime std.math.inf(f32);
|
||||
var ptr: [*:inf_f32]const f32 = &[_:inf_f32]f32{ 1.1, 2.2, 3.3, 4.4 };
|
||||
try expect(ptr[4] == inf_f32); // TODO this should be try comptime expect, see #3731
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "pointer to array at fixed address" {
|
||||
@ -409,11 +409,11 @@ test "@ptrToInt on null optional at comptime" {
|
||||
const pointer = @intToPtr(?*u8, 0x000);
|
||||
const x = @ptrToInt(pointer);
|
||||
_ = x;
|
||||
comptime try expect(0 == @ptrToInt(pointer));
|
||||
try comptime expect(0 == @ptrToInt(pointer));
|
||||
}
|
||||
{
|
||||
const pointer = @intToPtr(?*u8, 0xf00);
|
||||
comptime try expect(0xf00 == @ptrToInt(pointer));
|
||||
try comptime expect(0xf00 == @ptrToInt(pointer));
|
||||
}
|
||||
}
|
||||
|
||||
@ -447,7 +447,7 @@ test "element pointer to slice" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "element pointer arithmetic to slice" {
|
||||
@ -473,7 +473,7 @@ test "element pointer arithmetic to slice" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "array slicing to slice" {
|
||||
@ -491,7 +491,7 @@ test "array slicing to slice" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "pointer to constant decl preserves alignment" {
|
||||
|
@ -9,7 +9,7 @@ test "@popCount integers" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testPopCountIntegers();
|
||||
try comptime testPopCountIntegers();
|
||||
try testPopCountIntegers();
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ test "@popCount vectors" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try testPopCountVectors();
|
||||
try comptime testPopCountVectors();
|
||||
try testPopCountVectors();
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ test "reinterpret bytes as integer with nonzero offset" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try testReinterpretBytesAsInteger();
|
||||
comptime try testReinterpretBytesAsInteger();
|
||||
try comptime testReinterpretBytesAsInteger();
|
||||
}
|
||||
|
||||
fn testReinterpretBytesAsInteger() !void {
|
||||
@ -26,7 +26,7 @@ test "reinterpret an array over multiple elements, with no well-defined layout"
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testReinterpretWithOffsetAndNoWellDefinedLayout();
|
||||
comptime try testReinterpretWithOffsetAndNoWellDefinedLayout();
|
||||
try comptime testReinterpretWithOffsetAndNoWellDefinedLayout();
|
||||
}
|
||||
|
||||
fn testReinterpretWithOffsetAndNoWellDefinedLayout() !void {
|
||||
@ -41,7 +41,7 @@ test "reinterpret bytes inside auto-layout struct as integer with nonzero offset
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try testReinterpretStructWrappedBytesAsInteger();
|
||||
comptime try testReinterpretStructWrappedBytesAsInteger();
|
||||
try comptime testReinterpretStructWrappedBytesAsInteger();
|
||||
}
|
||||
|
||||
fn testReinterpretStructWrappedBytesAsInteger() !void {
|
||||
@ -59,7 +59,7 @@ test "reinterpret bytes of an array into an extern struct" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try testReinterpretBytesAsExternStruct();
|
||||
comptime try testReinterpretBytesAsExternStruct();
|
||||
try comptime testReinterpretBytesAsExternStruct();
|
||||
}
|
||||
|
||||
fn testReinterpretBytesAsExternStruct() !void {
|
||||
@ -80,7 +80,7 @@ test "reinterpret bytes of an extern struct (with under-aligned fields) into ano
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try testReinterpretExternStructAsExternStruct();
|
||||
comptime try testReinterpretExternStructAsExternStruct();
|
||||
try comptime testReinterpretExternStructAsExternStruct();
|
||||
}
|
||||
|
||||
fn testReinterpretExternStructAsExternStruct() !void {
|
||||
@ -104,7 +104,7 @@ test "reinterpret bytes of an extern struct into another" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try testReinterpretOverAlignedExternStructAsExternStruct();
|
||||
comptime try testReinterpretOverAlignedExternStructAsExternStruct();
|
||||
try comptime testReinterpretOverAlignedExternStructAsExternStruct();
|
||||
}
|
||||
|
||||
fn testReinterpretOverAlignedExternStructAsExternStruct() !void {
|
||||
|
@ -38,16 +38,16 @@ test "saturating add" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
|
||||
comptime try S.testSatAdd(comptime_int, 0, 0, 0);
|
||||
comptime try S.testSatAdd(comptime_int, -1, 1, 0);
|
||||
comptime try S.testSatAdd(comptime_int, 3, 2, 5);
|
||||
comptime try S.testSatAdd(comptime_int, -3, -2, -5);
|
||||
comptime try S.testSatAdd(comptime_int, 3, -2, 1);
|
||||
comptime try S.testSatAdd(comptime_int, -3, 2, -1);
|
||||
comptime try S.testSatAdd(comptime_int, 651075816498665588400716961808225370057, 468229432685078038144554201546849378455, 1119305249183743626545271163355074748512);
|
||||
comptime try S.testSatAdd(comptime_int, 7, -593423721213448152027139550640105366508, -593423721213448152027139550640105366501);
|
||||
try comptime S.testSatAdd(comptime_int, 0, 0, 0);
|
||||
try comptime S.testSatAdd(comptime_int, -1, 1, 0);
|
||||
try comptime S.testSatAdd(comptime_int, 3, 2, 5);
|
||||
try comptime S.testSatAdd(comptime_int, -3, -2, -5);
|
||||
try comptime S.testSatAdd(comptime_int, 3, -2, 1);
|
||||
try comptime S.testSatAdd(comptime_int, -3, 2, -1);
|
||||
try comptime S.testSatAdd(comptime_int, 651075816498665588400716961808225370057, 468229432685078038144554201546849378455, 1119305249183743626545271163355074748512);
|
||||
try comptime S.testSatAdd(comptime_int, 7, -593423721213448152027139550640105366508, -593423721213448152027139550640105366501);
|
||||
}
|
||||
|
||||
test "saturating add 128bit" {
|
||||
@ -74,7 +74,7 @@ test "saturating add 128bit" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "saturating subtraction" {
|
||||
@ -110,16 +110,16 @@ test "saturating subtraction" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
|
||||
comptime try S.testSatSub(comptime_int, 0, 0, 0);
|
||||
comptime try S.testSatSub(comptime_int, 1, 1, 0);
|
||||
comptime try S.testSatSub(comptime_int, 3, 2, 1);
|
||||
comptime try S.testSatSub(comptime_int, -3, -2, -1);
|
||||
comptime try S.testSatSub(comptime_int, 3, -2, 5);
|
||||
comptime try S.testSatSub(comptime_int, -3, 2, -5);
|
||||
comptime try S.testSatSub(comptime_int, 651075816498665588400716961808225370057, 468229432685078038144554201546849378455, 182846383813587550256162760261375991602);
|
||||
comptime try S.testSatSub(comptime_int, 7, -593423721213448152027139550640105366508, 593423721213448152027139550640105366515);
|
||||
try comptime S.testSatSub(comptime_int, 0, 0, 0);
|
||||
try comptime S.testSatSub(comptime_int, 1, 1, 0);
|
||||
try comptime S.testSatSub(comptime_int, 3, 2, 1);
|
||||
try comptime S.testSatSub(comptime_int, -3, -2, -1);
|
||||
try comptime S.testSatSub(comptime_int, 3, -2, 5);
|
||||
try comptime S.testSatSub(comptime_int, -3, 2, -5);
|
||||
try comptime S.testSatSub(comptime_int, 651075816498665588400716961808225370057, 468229432685078038144554201546849378455, 182846383813587550256162760261375991602);
|
||||
try comptime S.testSatSub(comptime_int, 7, -593423721213448152027139550640105366508, 593423721213448152027139550640105366515);
|
||||
}
|
||||
|
||||
test "saturating subtraction 128bit" {
|
||||
@ -147,7 +147,7 @@ test "saturating subtraction 128bit" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "saturating multiplication" {
|
||||
@ -188,12 +188,12 @@ test "saturating multiplication" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
|
||||
comptime try S.testSatMul(comptime_int, 0, 0, 0);
|
||||
comptime try S.testSatMul(comptime_int, 3, 2, 6);
|
||||
comptime try S.testSatMul(comptime_int, 651075816498665588400716961808225370057, 468229432685078038144554201546849378455, 304852860194144160265083087140337419215516305999637969803722975979232817921935);
|
||||
comptime try S.testSatMul(comptime_int, 7, -593423721213448152027139550640105366508, -4153966048494137064189976854480737565556);
|
||||
try comptime S.testSatMul(comptime_int, 0, 0, 0);
|
||||
try comptime S.testSatMul(comptime_int, 3, 2, 6);
|
||||
try comptime S.testSatMul(comptime_int, 651075816498665588400716961808225370057, 468229432685078038144554201546849378455, 304852860194144160265083087140337419215516305999637969803722975979232817921935);
|
||||
try comptime S.testSatMul(comptime_int, 7, -593423721213448152027139550640105366508, -4153966048494137064189976854480737565556);
|
||||
}
|
||||
|
||||
test "saturating shift-left" {
|
||||
@ -228,12 +228,12 @@ test "saturating shift-left" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
|
||||
comptime try S.testSatShl(comptime_int, 0, 0, 0);
|
||||
comptime try S.testSatShl(comptime_int, 1, 2, 4);
|
||||
comptime try S.testSatShl(comptime_int, 13, 150, 18554220005177478453757717602843436772975706112);
|
||||
comptime try S.testSatShl(comptime_int, -582769, 180, -893090893854873184096635538665358532628308979495815656505344);
|
||||
try comptime S.testSatShl(comptime_int, 0, 0, 0);
|
||||
try comptime S.testSatShl(comptime_int, 1, 2, 4);
|
||||
try comptime S.testSatShl(comptime_int, 13, 150, 18554220005177478453757717602843436772975706112);
|
||||
try comptime S.testSatShl(comptime_int, -582769, 180, -893090893854873184096635538665358532628308979495815656505344);
|
||||
}
|
||||
|
||||
test "saturating shl uses the LHS type" {
|
||||
|
@ -11,7 +11,7 @@ test "@select vectors" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try selectVectors();
|
||||
try comptime selectVectors();
|
||||
try selectVectors();
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ test "@select arrays" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try selectArrays();
|
||||
try comptime selectArrays();
|
||||
try selectArrays();
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ test "@shuffle int" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "@shuffle bool 1" {
|
||||
@ -62,7 +62,7 @@ test "@shuffle bool 1" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "@shuffle bool 2" {
|
||||
@ -88,5 +88,5 @@ test "@shuffle bool 2" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
@ -24,21 +24,21 @@ test "@TypeOf() with multiple arguments" {
|
||||
var var_1: u32 = undefined;
|
||||
var var_2: u8 = undefined;
|
||||
var var_3: u64 = undefined;
|
||||
comptime try expect(@TypeOf(var_1, var_2, var_3) == u64);
|
||||
try comptime expect(@TypeOf(var_1, var_2, var_3) == u64);
|
||||
}
|
||||
{
|
||||
var var_1: f16 = undefined;
|
||||
var var_2: f32 = undefined;
|
||||
var var_3: f64 = undefined;
|
||||
comptime try expect(@TypeOf(var_1, var_2, var_3) == f64);
|
||||
try comptime expect(@TypeOf(var_1, var_2, var_3) == f64);
|
||||
}
|
||||
{
|
||||
var var_1: u16 = undefined;
|
||||
comptime try expect(@TypeOf(var_1, 0xffff) == u16);
|
||||
try comptime expect(@TypeOf(var_1, 0xffff) == u16);
|
||||
}
|
||||
{
|
||||
var var_1: f32 = undefined;
|
||||
comptime try expect(@TypeOf(var_1, 3.1415) == f32);
|
||||
try comptime expect(@TypeOf(var_1, 3.1415) == f32);
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ test "@TypeOf() has no runtime side effects" {
|
||||
};
|
||||
var data: i32 = 0;
|
||||
const T = @TypeOf(S.foo(i32, &data));
|
||||
comptime try expect(T == i32);
|
||||
try comptime expect(T == i32);
|
||||
try expect(data == 0);
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ test "branching logic inside @TypeOf" {
|
||||
}
|
||||
};
|
||||
const T = @TypeOf(S.foo() catch undefined);
|
||||
comptime try expect(T == i32);
|
||||
try comptime expect(T == i32);
|
||||
try expect(S.data == 0);
|
||||
}
|
||||
|
||||
@ -236,7 +236,7 @@ test "hardcoded address in typeof expression" {
|
||||
}
|
||||
};
|
||||
try expect(S.func() == 0);
|
||||
comptime try expect(S.func() == 0);
|
||||
try comptime expect(S.func() == 0);
|
||||
}
|
||||
|
||||
test "array access of generic param in typeof expression" {
|
||||
@ -246,7 +246,7 @@ test "array access of generic param in typeof expression" {
|
||||
}
|
||||
};
|
||||
try expect(S.first("a") == 'a');
|
||||
comptime try expect(S.first("a") == 'a');
|
||||
try comptime expect(S.first("a") == 'a');
|
||||
}
|
||||
|
||||
test "lazy size cast to float" {
|
||||
|
@ -87,7 +87,7 @@ test "access len index of sentinel-terminated slice" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "comptime slice of slice preserves comptime var" {
|
||||
@ -139,7 +139,7 @@ test "slice of hardcoded address to pointer" {
|
||||
const S = struct {
|
||||
fn doTheTest() !void {
|
||||
const pointer = @intToPtr([*]u8, 0x04)[0..2];
|
||||
comptime try expect(@TypeOf(pointer) == *[2]u8);
|
||||
try comptime expect(@TypeOf(pointer) == *[2]u8);
|
||||
const slice: []const u8 = pointer;
|
||||
try expect(@ptrToInt(slice.ptr) == 4);
|
||||
try expect(slice.len == 2);
|
||||
@ -214,9 +214,9 @@ test "slice string literal has correct type" {
|
||||
try expect(@TypeOf(array[0..]) == *const [4]i32);
|
||||
}
|
||||
var runtime_zero: usize = 0;
|
||||
comptime try expect(@TypeOf("aoeu"[runtime_zero..]) == [:0]const u8);
|
||||
try comptime expect(@TypeOf("aoeu"[runtime_zero..]) == [:0]const u8);
|
||||
const array = [_]i32{ 1, 2, 3, 4 };
|
||||
comptime try expect(@TypeOf(array[runtime_zero..]) == []const i32);
|
||||
try comptime expect(@TypeOf(array[runtime_zero..]) == []const i32);
|
||||
}
|
||||
|
||||
test "result location zero sized array inside struct field implicit cast to slice" {
|
||||
@ -265,8 +265,8 @@ test "C pointer slice access" {
|
||||
const c_ptr = @ptrCast([*c]const u32, &buf);
|
||||
|
||||
var runtime_zero: usize = 0;
|
||||
comptime try expectEqual([]const u32, @TypeOf(c_ptr[runtime_zero..1]));
|
||||
comptime try expectEqual(*const [1]u32, @TypeOf(c_ptr[0..1]));
|
||||
try comptime expectEqual([]const u32, @TypeOf(c_ptr[runtime_zero..1]));
|
||||
try comptime expectEqual(*const [1]u32, @TypeOf(c_ptr[0..1]));
|
||||
|
||||
for (c_ptr[0..5]) |*cl| {
|
||||
try expect(@as(u32, 42) == cl.*);
|
||||
@ -320,10 +320,10 @@ test "obtaining a null terminated slice" {
|
||||
var runtime_len: usize = 3;
|
||||
const ptr2 = buf[0..runtime_len :0];
|
||||
// ptr2 is a null-terminated slice
|
||||
comptime try expect(@TypeOf(ptr2) == [:0]u8);
|
||||
comptime try expect(@TypeOf(ptr2[0..2]) == *[2]u8);
|
||||
try comptime expect(@TypeOf(ptr2) == [:0]u8);
|
||||
try comptime expect(@TypeOf(ptr2[0..2]) == *[2]u8);
|
||||
var runtime_zero: usize = 0;
|
||||
comptime try expect(@TypeOf(ptr2[runtime_zero..2]) == []u8);
|
||||
try comptime expect(@TypeOf(ptr2[runtime_zero..2]) == []u8);
|
||||
}
|
||||
|
||||
test "empty array to slice" {
|
||||
@ -340,7 +340,7 @@ test "empty array to slice" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "@ptrCast slice to pointer" {
|
||||
@ -358,7 +358,7 @@ test "@ptrCast slice to pointer" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "slice syntax resulting in pointer-to-array" {
|
||||
@ -389,29 +389,29 @@ test "slice syntax resulting in pointer-to-array" {
|
||||
fn testArray() !void {
|
||||
var array = [5]u8{ 1, 2, 3, 4, 5 };
|
||||
var slice = array[1..3];
|
||||
comptime try expect(@TypeOf(slice) == *[2]u8);
|
||||
try comptime expect(@TypeOf(slice) == *[2]u8);
|
||||
try expect(slice[0] == 2);
|
||||
try expect(slice[1] == 3);
|
||||
}
|
||||
|
||||
fn testArrayZ() !void {
|
||||
var array = [5:0]u8{ 1, 2, 3, 4, 5 };
|
||||
comptime try expect(@TypeOf(array[1..3]) == *[2]u8);
|
||||
comptime try expect(@TypeOf(array[1..5]) == *[4:0]u8);
|
||||
comptime try expect(@TypeOf(array[1..]) == *[4:0]u8);
|
||||
comptime try expect(@TypeOf(array[1..3 :4]) == *[2:4]u8);
|
||||
try comptime expect(@TypeOf(array[1..3]) == *[2]u8);
|
||||
try comptime expect(@TypeOf(array[1..5]) == *[4:0]u8);
|
||||
try comptime expect(@TypeOf(array[1..]) == *[4:0]u8);
|
||||
try comptime expect(@TypeOf(array[1..3 :4]) == *[2:4]u8);
|
||||
}
|
||||
|
||||
fn testArray0() !void {
|
||||
{
|
||||
var array = [0]u8{};
|
||||
var slice = array[0..0];
|
||||
comptime try expect(@TypeOf(slice) == *[0]u8);
|
||||
try comptime expect(@TypeOf(slice) == *[0]u8);
|
||||
}
|
||||
{
|
||||
var array = [0:0]u8{};
|
||||
var slice = array[0..0];
|
||||
comptime try expect(@TypeOf(slice) == *[0:0]u8);
|
||||
try comptime expect(@TypeOf(slice) == *[0:0]u8);
|
||||
try expect(slice[0] == 0);
|
||||
}
|
||||
}
|
||||
@ -419,16 +419,16 @@ test "slice syntax resulting in pointer-to-array" {
|
||||
fn testArrayAlign() !void {
|
||||
var array align(4) = [5]u8{ 1, 2, 3, 4, 5 };
|
||||
var slice = array[4..5];
|
||||
comptime try expect(@TypeOf(slice) == *align(4) [1]u8);
|
||||
try comptime expect(@TypeOf(slice) == *align(4) [1]u8);
|
||||
try expect(slice[0] == 5);
|
||||
comptime try expect(@TypeOf(array[0..2]) == *align(4) [2]u8);
|
||||
try comptime expect(@TypeOf(array[0..2]) == *align(4) [2]u8);
|
||||
}
|
||||
|
||||
fn testPointer() !void {
|
||||
var array = [5]u8{ 1, 2, 3, 4, 5 };
|
||||
var pointer: [*]u8 = &array;
|
||||
var slice = pointer[1..3];
|
||||
comptime try expect(@TypeOf(slice) == *[2]u8);
|
||||
try comptime expect(@TypeOf(slice) == *[2]u8);
|
||||
try expect(slice[0] == 2);
|
||||
try expect(slice[1] == 3);
|
||||
}
|
||||
@ -436,14 +436,14 @@ test "slice syntax resulting in pointer-to-array" {
|
||||
fn testPointerZ() !void {
|
||||
var array = [5:0]u8{ 1, 2, 3, 4, 5 };
|
||||
var pointer: [*:0]u8 = &array;
|
||||
comptime try expect(@TypeOf(pointer[1..3]) == *[2]u8);
|
||||
comptime try expect(@TypeOf(pointer[1..3 :4]) == *[2:4]u8);
|
||||
try comptime expect(@TypeOf(pointer[1..3]) == *[2]u8);
|
||||
try comptime expect(@TypeOf(pointer[1..3 :4]) == *[2:4]u8);
|
||||
}
|
||||
|
||||
fn testPointer0() !void {
|
||||
var pointer: [*]const u0 = &[1]u0{0};
|
||||
var slice = pointer[0..1];
|
||||
comptime try expect(@TypeOf(slice) == *const [1]u0);
|
||||
try comptime expect(@TypeOf(slice) == *const [1]u0);
|
||||
try expect(slice[0] == 0);
|
||||
}
|
||||
|
||||
@ -451,16 +451,16 @@ test "slice syntax resulting in pointer-to-array" {
|
||||
var array align(4) = [5]u8{ 1, 2, 3, 4, 5 };
|
||||
var pointer: [*]align(4) u8 = &array;
|
||||
var slice = pointer[4..5];
|
||||
comptime try expect(@TypeOf(slice) == *align(4) [1]u8);
|
||||
try comptime expect(@TypeOf(slice) == *align(4) [1]u8);
|
||||
try expect(slice[0] == 5);
|
||||
comptime try expect(@TypeOf(pointer[0..2]) == *align(4) [2]u8);
|
||||
try comptime expect(@TypeOf(pointer[0..2]) == *align(4) [2]u8);
|
||||
}
|
||||
|
||||
fn testSlice() !void {
|
||||
var array = [5]u8{ 1, 2, 3, 4, 5 };
|
||||
var src_slice: []u8 = &array;
|
||||
var slice = src_slice[1..3];
|
||||
comptime try expect(@TypeOf(slice) == *[2]u8);
|
||||
try comptime expect(@TypeOf(slice) == *[2]u8);
|
||||
try expect(slice[0] == 2);
|
||||
try expect(slice[1] == 3);
|
||||
}
|
||||
@ -468,26 +468,26 @@ test "slice syntax resulting in pointer-to-array" {
|
||||
fn testSliceZ() !void {
|
||||
var array = [5:0]u8{ 1, 2, 3, 4, 5 };
|
||||
var slice: [:0]u8 = &array;
|
||||
comptime try expect(@TypeOf(slice[1..3]) == *[2]u8);
|
||||
comptime try expect(@TypeOf(slice[1..]) == [:0]u8);
|
||||
comptime try expect(@TypeOf(slice[1..3 :4]) == *[2:4]u8);
|
||||
try comptime expect(@TypeOf(slice[1..3]) == *[2]u8);
|
||||
try comptime expect(@TypeOf(slice[1..]) == [:0]u8);
|
||||
try comptime expect(@TypeOf(slice[1..3 :4]) == *[2:4]u8);
|
||||
}
|
||||
|
||||
fn testSliceOpt() !void {
|
||||
var array: [2]u8 = [2]u8{ 1, 2 };
|
||||
var slice: ?[]u8 = &array;
|
||||
comptime try expect(@TypeOf(&array, slice) == ?[]u8);
|
||||
comptime try expect(@TypeOf(slice, &array) == ?[]u8);
|
||||
comptime try expect(@TypeOf(slice.?[0..2]) == *[2]u8);
|
||||
try comptime expect(@TypeOf(&array, slice) == ?[]u8);
|
||||
try comptime expect(@TypeOf(slice, &array) == ?[]u8);
|
||||
try comptime expect(@TypeOf(slice.?[0..2]) == *[2]u8);
|
||||
}
|
||||
|
||||
fn testSliceAlign() !void {
|
||||
var array align(4) = [5]u8{ 1, 2, 3, 4, 5 };
|
||||
var src_slice: []align(4) u8 = &array;
|
||||
var slice = src_slice[4..5];
|
||||
comptime try expect(@TypeOf(slice) == *align(4) [1]u8);
|
||||
try comptime expect(@TypeOf(slice) == *align(4) [1]u8);
|
||||
try expect(slice[0] == 5);
|
||||
comptime try expect(@TypeOf(src_slice[0..2]) == *align(4) [2]u8);
|
||||
try comptime expect(@TypeOf(src_slice[0..2]) == *align(4) [2]u8);
|
||||
}
|
||||
|
||||
fn testConcatStrLiterals() !void {
|
||||
@ -498,67 +498,67 @@ test "slice syntax resulting in pointer-to-array" {
|
||||
fn testSliceLength() !void {
|
||||
var array = [5]u8{ 1, 2, 3, 4, 5 };
|
||||
var slice: []u8 = &array;
|
||||
comptime try expect(@TypeOf(slice[1..][0..2]) == *[2]u8);
|
||||
comptime try expect(@TypeOf(slice[1..][0..4]) == *[4]u8);
|
||||
comptime try expect(@TypeOf(slice[1..][0..2 :4]) == *[2:4]u8);
|
||||
try comptime expect(@TypeOf(slice[1..][0..2]) == *[2]u8);
|
||||
try comptime expect(@TypeOf(slice[1..][0..4]) == *[4]u8);
|
||||
try comptime expect(@TypeOf(slice[1..][0..2 :4]) == *[2:4]u8);
|
||||
}
|
||||
|
||||
fn testSliceLengthZ() !void {
|
||||
var array = [5:0]u8{ 1, 2, 3, 4, 5 };
|
||||
var slice: [:0]u8 = &array;
|
||||
comptime try expect(@TypeOf(slice[1..][0..2]) == *[2]u8);
|
||||
comptime try expect(@TypeOf(slice[1..][0..2 :4]) == *[2:4]u8);
|
||||
comptime try expect(@TypeOf(slice[1.. :0][0..2]) == *[2]u8);
|
||||
comptime try expect(@TypeOf(slice[1.. :0][0..2 :4]) == *[2:4]u8);
|
||||
try comptime expect(@TypeOf(slice[1..][0..2]) == *[2]u8);
|
||||
try comptime expect(@TypeOf(slice[1..][0..2 :4]) == *[2:4]u8);
|
||||
try comptime expect(@TypeOf(slice[1.. :0][0..2]) == *[2]u8);
|
||||
try comptime expect(@TypeOf(slice[1.. :0][0..2 :4]) == *[2:4]u8);
|
||||
}
|
||||
|
||||
fn testArrayLength() !void {
|
||||
var array = [5]u8{ 1, 2, 3, 4, 5 };
|
||||
comptime try expect(@TypeOf(array[1..][0..2]) == *[2]u8);
|
||||
comptime try expect(@TypeOf(array[1..][0..4]) == *[4]u8);
|
||||
comptime try expect(@TypeOf(array[1..][0..2 :4]) == *[2:4]u8);
|
||||
try comptime expect(@TypeOf(array[1..][0..2]) == *[2]u8);
|
||||
try comptime expect(@TypeOf(array[1..][0..4]) == *[4]u8);
|
||||
try comptime expect(@TypeOf(array[1..][0..2 :4]) == *[2:4]u8);
|
||||
}
|
||||
|
||||
fn testArrayLengthZ() !void {
|
||||
var array = [5:0]u8{ 1, 2, 3, 4, 5 };
|
||||
comptime try expect(@TypeOf(array[1..][0..2]) == *[2]u8);
|
||||
comptime try expect(@TypeOf(array[1..][0..4]) == *[4:0]u8);
|
||||
comptime try expect(@TypeOf(array[1..][0..2 :4]) == *[2:4]u8);
|
||||
comptime try expect(@TypeOf(array[1.. :0][0..2]) == *[2]u8);
|
||||
comptime try expect(@TypeOf(array[1.. :0][0..4]) == *[4:0]u8);
|
||||
comptime try expect(@TypeOf(array[1.. :0][0..2 :4]) == *[2:4]u8);
|
||||
try comptime expect(@TypeOf(array[1..][0..2]) == *[2]u8);
|
||||
try comptime expect(@TypeOf(array[1..][0..4]) == *[4:0]u8);
|
||||
try comptime expect(@TypeOf(array[1..][0..2 :4]) == *[2:4]u8);
|
||||
try comptime expect(@TypeOf(array[1.. :0][0..2]) == *[2]u8);
|
||||
try comptime expect(@TypeOf(array[1.. :0][0..4]) == *[4:0]u8);
|
||||
try comptime expect(@TypeOf(array[1.. :0][0..2 :4]) == *[2:4]u8);
|
||||
}
|
||||
|
||||
fn testMultiPointer() !void {
|
||||
var array = [5]u8{ 1, 2, 3, 4, 5 };
|
||||
var ptr: [*]u8 = &array;
|
||||
comptime try expect(@TypeOf(ptr[1..][0..2]) == *[2]u8);
|
||||
comptime try expect(@TypeOf(ptr[1..][0..4]) == *[4]u8);
|
||||
comptime try expect(@TypeOf(ptr[1..][0..2 :4]) == *[2:4]u8);
|
||||
try comptime expect(@TypeOf(ptr[1..][0..2]) == *[2]u8);
|
||||
try comptime expect(@TypeOf(ptr[1..][0..4]) == *[4]u8);
|
||||
try comptime expect(@TypeOf(ptr[1..][0..2 :4]) == *[2:4]u8);
|
||||
}
|
||||
|
||||
fn testMultiPointerLengthZ() !void {
|
||||
var array = [5:0]u8{ 1, 2, 3, 4, 5 };
|
||||
var ptr: [*]u8 = &array;
|
||||
comptime try expect(@TypeOf(ptr[1..][0..2]) == *[2]u8);
|
||||
comptime try expect(@TypeOf(ptr[1..][0..4]) == *[4:0]u8);
|
||||
comptime try expect(@TypeOf(ptr[1..][0..2 :4]) == *[2:4]u8);
|
||||
comptime try expect(@TypeOf(ptr[1.. :0][0..2]) == *[2]u8);
|
||||
comptime try expect(@TypeOf(ptr[1.. :0][0..4]) == *[4:0]u8);
|
||||
comptime try expect(@TypeOf(ptr[1.. :0][0..2 :4]) == *[2:4]u8);
|
||||
try comptime expect(@TypeOf(ptr[1..][0..2]) == *[2]u8);
|
||||
try comptime expect(@TypeOf(ptr[1..][0..4]) == *[4:0]u8);
|
||||
try comptime expect(@TypeOf(ptr[1..][0..2 :4]) == *[2:4]u8);
|
||||
try comptime expect(@TypeOf(ptr[1.. :0][0..2]) == *[2]u8);
|
||||
try comptime expect(@TypeOf(ptr[1.. :0][0..4]) == *[4:0]u8);
|
||||
try comptime expect(@TypeOf(ptr[1.. :0][0..2 :4]) == *[2:4]u8);
|
||||
|
||||
var ptr_z: [*:0]u8 = &array;
|
||||
comptime try expect(@TypeOf(ptr_z[1..][0..2]) == *[2]u8);
|
||||
comptime try expect(@TypeOf(ptr_z[1..][0..4]) == *[4:0]u8);
|
||||
comptime try expect(@TypeOf(ptr_z[1..][0..2 :4]) == *[2:4]u8);
|
||||
comptime try expect(@TypeOf(ptr_z[1.. :0][0..2]) == *[2]u8);
|
||||
comptime try expect(@TypeOf(ptr_z[1.. :0][0..4]) == *[4:0]u8);
|
||||
comptime try expect(@TypeOf(ptr_z[1.. :0][0..2 :4]) == *[2:4]u8);
|
||||
try comptime expect(@TypeOf(ptr_z[1..][0..2]) == *[2]u8);
|
||||
try comptime expect(@TypeOf(ptr_z[1..][0..4]) == *[4:0]u8);
|
||||
try comptime expect(@TypeOf(ptr_z[1..][0..2 :4]) == *[2:4]u8);
|
||||
try comptime expect(@TypeOf(ptr_z[1.. :0][0..2]) == *[2]u8);
|
||||
try comptime expect(@TypeOf(ptr_z[1.. :0][0..4]) == *[4:0]u8);
|
||||
try comptime expect(@TypeOf(ptr_z[1.. :0][0..2 :4]) == *[2:4]u8);
|
||||
}
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "slice pointer-to-array null terminated" {
|
||||
@ -576,9 +576,9 @@ test "slice pointer-to-array null terminated" {
|
||||
|
||||
var array = [5:0]u8{ 1, 2, 3, 4, 5 };
|
||||
var slice: [:0]u8 = &array;
|
||||
comptime try expect(@TypeOf(slice[1..3]) == *[2]u8);
|
||||
comptime try expect(@TypeOf(slice[1..3 :4]) == *[2:4]u8);
|
||||
comptime try expect(@TypeOf(slice[1..]) == [:0]u8);
|
||||
try comptime expect(@TypeOf(slice[1..3]) == *[2]u8);
|
||||
try comptime expect(@TypeOf(slice[1..3 :4]) == *[2:4]u8);
|
||||
try comptime expect(@TypeOf(slice[1..]) == [:0]u8);
|
||||
}
|
||||
|
||||
test "slice pointer-to-array zero length" {
|
||||
@ -604,13 +604,13 @@ test "slice pointer-to-array zero length" {
|
||||
var array = [0]u8{};
|
||||
var src_slice: []u8 = &array;
|
||||
var slice = src_slice[0..0];
|
||||
comptime try expect(@TypeOf(slice) == *[0]u8);
|
||||
try comptime expect(@TypeOf(slice) == *[0]u8);
|
||||
}
|
||||
{
|
||||
var array = [0:0]u8{};
|
||||
var src_slice: [:0]u8 = &array;
|
||||
var slice = src_slice[0..0];
|
||||
comptime try expect(@TypeOf(slice) == *[0]u8);
|
||||
try comptime expect(@TypeOf(slice) == *[0]u8);
|
||||
}
|
||||
}
|
||||
|
||||
@ -647,7 +647,7 @@ test "type coercion of pointer to anon struct literal to pointer to slice" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "array concat of slices gives ptr to array" {
|
||||
@ -719,7 +719,7 @@ test "slicing array with sentinel as end index" {
|
||||
};
|
||||
|
||||
try S.do();
|
||||
comptime try S.do();
|
||||
try comptime S.do();
|
||||
}
|
||||
|
||||
test "slicing slice with sentinel as end index" {
|
||||
@ -739,7 +739,7 @@ test "slicing slice with sentinel as end index" {
|
||||
};
|
||||
|
||||
try S.do();
|
||||
comptime try S.do();
|
||||
try comptime S.do();
|
||||
}
|
||||
|
||||
test "slice len modification at comptime" {
|
||||
|
@ -268,7 +268,7 @@ test "struct field init with catch" {
|
||||
};
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
const blah: packed struct {
|
||||
@ -603,7 +603,7 @@ test "bit field access" {
|
||||
try expect(getA(&data) == 1);
|
||||
try expect(getB(&data) == 2);
|
||||
try expect(getC(&data) == 3);
|
||||
comptime try expect(@sizeOf(BitField1) == 1);
|
||||
try comptime expect(@sizeOf(BitField1) == 1);
|
||||
|
||||
data.b += 1;
|
||||
try expect(data.b == 3);
|
||||
@ -740,7 +740,7 @@ test "packed struct with u0 field access" {
|
||||
f0: u0,
|
||||
};
|
||||
var s = S{ .f0 = 0 };
|
||||
comptime try expect(s.f0 == 0);
|
||||
try comptime expect(s.f0 == 0);
|
||||
}
|
||||
|
||||
test "access to global struct fields" {
|
||||
@ -817,7 +817,7 @@ test "fn with C calling convention returns struct by value" {
|
||||
}
|
||||
};
|
||||
try S.entry();
|
||||
comptime try S.entry();
|
||||
try comptime S.entry();
|
||||
}
|
||||
|
||||
test "non-packed struct with u128 entry in union" {
|
||||
@ -889,7 +889,7 @@ test "anonymous struct literal syntax" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "fully anonymous struct" {
|
||||
@ -911,7 +911,7 @@ test "fully anonymous struct" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "fully anonymous list literal" {
|
||||
@ -928,7 +928,7 @@ test "fully anonymous list literal" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "tuple assigned to variable" {
|
||||
@ -955,7 +955,7 @@ test "comptime struct field" {
|
||||
comptime std.debug.assert(@sizeOf(T) == 4);
|
||||
|
||||
var foo: T = undefined;
|
||||
comptime try expect(foo.b == 1234);
|
||||
try comptime expect(foo.b == 1234);
|
||||
}
|
||||
|
||||
test "tuple element initialized with fn call" {
|
||||
@ -974,7 +974,7 @@ test "tuple element initialized with fn call" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "struct with union field" {
|
||||
@ -1033,7 +1033,7 @@ test "type coercion of anon struct literal to struct" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "type coercion of pointer to anon struct literal to pointer to struct" {
|
||||
@ -1071,7 +1071,7 @@ test "type coercion of pointer to anon struct literal to pointer to struct" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "packed struct with undefined initializers" {
|
||||
@ -1104,7 +1104,7 @@ test "packed struct with undefined initializers" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "for loop over pointers to struct, getting field from struct pointer" {
|
||||
@ -1169,7 +1169,7 @@ test "anon init through error unions and optionals" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "anon init through optional" {
|
||||
@ -1189,7 +1189,7 @@ test "anon init through optional" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "anon init through error union" {
|
||||
@ -1209,7 +1209,7 @@ test "anon init through error union" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "typed init through error unions and optionals" {
|
||||
@ -1236,7 +1236,7 @@ test "typed init through error unions and optionals" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "initialize struct with empty literal" {
|
||||
@ -1311,7 +1311,7 @@ test "packed struct field access via pointer" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "store to comptime field" {
|
||||
@ -1416,7 +1416,7 @@ test "fieldParentPtr of a zero-bit field" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "struct field has a pointer to an aligned version of itself" {
|
||||
|
@ -121,7 +121,7 @@ test "switching on booleans" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testSwitchOnBools();
|
||||
comptime try testSwitchOnBools();
|
||||
try comptime testSwitchOnBools();
|
||||
}
|
||||
|
||||
fn testSwitchOnBools() !void {
|
||||
@ -186,10 +186,10 @@ test "switch variable for range and multiple prongs" {
|
||||
fn doTheTest() !void {
|
||||
var u: u8 = 16;
|
||||
try doTheSwitch(u);
|
||||
comptime try doTheSwitch(u);
|
||||
try comptime doTheSwitch(u);
|
||||
var v: u8 = 42;
|
||||
try doTheSwitch(v);
|
||||
comptime try doTheSwitch(v);
|
||||
try comptime doTheSwitch(v);
|
||||
}
|
||||
fn doTheSwitch(q: u8) !void {
|
||||
switch (q) {
|
||||
@ -260,7 +260,7 @@ test "switch on enum using pointer capture" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testSwitchEnumPtrCapture();
|
||||
comptime try testSwitchEnumPtrCapture();
|
||||
try comptime testSwitchEnumPtrCapture();
|
||||
}
|
||||
|
||||
fn testSwitchEnumPtrCapture() !void {
|
||||
@ -279,7 +279,7 @@ test "switch handles all cases of number" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try testSwitchHandleAllCases();
|
||||
comptime try testSwitchHandleAllCases();
|
||||
try comptime testSwitchHandleAllCases();
|
||||
}
|
||||
|
||||
fn testSwitchHandleAllCases() !void {
|
||||
@ -373,7 +373,7 @@ test "switch all prongs unreachable" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try testAllProngsUnreachable();
|
||||
comptime try testAllProngsUnreachable();
|
||||
try comptime testAllProngsUnreachable();
|
||||
}
|
||||
|
||||
fn testAllProngsUnreachable() !void {
|
||||
@ -421,7 +421,7 @@ test "switch on integer with else capturing expr" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "else prong of switch on error set excludes other cases" {
|
||||
@ -456,7 +456,7 @@ test "else prong of switch on error set excludes other cases" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "switch prongs with error set cases make a new error set type for capture value" {
|
||||
@ -493,7 +493,7 @@ test "switch prongs with error set cases make a new error set type for capture v
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "return result loc and then switch with range implicit casted to error union" {
|
||||
@ -512,7 +512,7 @@ test "return result loc and then switch with range implicit casted to error unio
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "switch with null and T peer types and inferred result location type" {
|
||||
@ -532,7 +532,7 @@ test "switch with null and T peer types and inferred result location type" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest(1);
|
||||
comptime try S.doTheTest(1);
|
||||
try comptime S.doTheTest(1);
|
||||
}
|
||||
|
||||
test "switch prongs with cases with identical payload types" {
|
||||
@ -577,7 +577,7 @@ test "switch prongs with cases with identical payload types" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "switch on pointer type" {
|
||||
@ -606,9 +606,9 @@ test "switch on pointer type" {
|
||||
try expect(1 == S.doTheTest(S.P1));
|
||||
try expect(2 == S.doTheTest(S.P2));
|
||||
try expect(3 == S.doTheTest(S.P3));
|
||||
comptime try expect(1 == S.doTheTest(S.P1));
|
||||
comptime try expect(2 == S.doTheTest(S.P2));
|
||||
comptime try expect(3 == S.doTheTest(S.P3));
|
||||
try comptime expect(1 == S.doTheTest(S.P1));
|
||||
try comptime expect(2 == S.doTheTest(S.P2));
|
||||
try comptime expect(3 == S.doTheTest(S.P3));
|
||||
}
|
||||
|
||||
test "switch on error set with single else" {
|
||||
@ -624,7 +624,7 @@ test "switch on error set with single else" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "switch capture copies its payload" {
|
||||
@ -650,7 +650,7 @@ test "switch capture copies its payload" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "capture of integer forwards the switch condition directly" {
|
||||
@ -670,8 +670,8 @@ test "capture of integer forwards the switch condition directly" {
|
||||
};
|
||||
try S.foo(42);
|
||||
try S.foo(100);
|
||||
comptime try S.foo(42);
|
||||
comptime try S.foo(100);
|
||||
try comptime S.foo(42);
|
||||
try comptime S.foo(100);
|
||||
}
|
||||
|
||||
test "enum value without tag name used as switch item" {
|
||||
@ -702,7 +702,7 @@ test "switch item sizeof" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "comptime inline switch" {
|
||||
|
@ -5,7 +5,7 @@ const expect = std.testing.expect;
|
||||
test "truncate u0 to larger integer allowed and has comptime-known result" {
|
||||
var x: u0 = 0;
|
||||
const y = @truncate(u8, x);
|
||||
comptime try expect(y == 0);
|
||||
try comptime expect(y == 0);
|
||||
}
|
||||
|
||||
test "truncate.u0.literal" {
|
||||
@ -28,7 +28,7 @@ test "truncate.u0.var" {
|
||||
test "truncate i0 to larger integer allowed and has comptime-known result" {
|
||||
var x: i0 = 0;
|
||||
const y = @truncate(i8, x);
|
||||
comptime try expect(y == 0);
|
||||
try comptime expect(y == 0);
|
||||
}
|
||||
|
||||
test "truncate.i0.literal" {
|
||||
@ -73,6 +73,6 @@ test "truncate on vectors" {
|
||||
try expect(std.mem.eql(u8, &@as([4]u8, v2), &[4]u8{ 0xbb, 0xdd, 0xff, 0x22 }));
|
||||
}
|
||||
};
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
try S.doTheTest();
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ test "try on error union" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try tryOnErrorUnionImpl();
|
||||
comptime try tryOnErrorUnionImpl();
|
||||
try comptime tryOnErrorUnionImpl();
|
||||
}
|
||||
|
||||
fn tryOnErrorUnionImpl() !void {
|
||||
|
@ -23,7 +23,7 @@ test "tuple concatenation" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "tuple multiplication" {
|
||||
@ -46,7 +46,7 @@ test "tuple multiplication" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "more tuple concatenation" {
|
||||
@ -91,7 +91,7 @@ test "more tuple concatenation" {
|
||||
};
|
||||
|
||||
try T.doTheTest();
|
||||
comptime try T.doTheTest();
|
||||
try comptime T.doTheTest();
|
||||
}
|
||||
|
||||
test "pass tuple to comptime var parameter" {
|
||||
@ -105,7 +105,7 @@ test "pass tuple to comptime var parameter" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "tuple initializer for var" {
|
||||
@ -163,7 +163,7 @@ test "array-like initializer for tuple types" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "anon struct as the result from a labeled block" {
|
||||
@ -180,7 +180,7 @@ test "anon struct as the result from a labeled block" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "tuple as the result from a labeled block" {
|
||||
@ -195,7 +195,7 @@ test "tuple as the result from a labeled block" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "initializing tuple with explicit type" {
|
||||
|
@ -10,7 +10,7 @@ const expectEqualStrings = std.testing.expectEqualStrings;
|
||||
|
||||
test "type info: integer, floating point type info" {
|
||||
try testIntFloat();
|
||||
comptime try testIntFloat();
|
||||
try comptime testIntFloat();
|
||||
}
|
||||
|
||||
fn testIntFloat() !void {
|
||||
@ -26,7 +26,7 @@ fn testIntFloat() !void {
|
||||
|
||||
test "type info: optional type info" {
|
||||
try testOptional();
|
||||
comptime try testOptional();
|
||||
try comptime testOptional();
|
||||
}
|
||||
|
||||
fn testOptional() !void {
|
||||
@ -37,7 +37,7 @@ fn testOptional() !void {
|
||||
|
||||
test "type info: C pointer type info" {
|
||||
try testCPtr();
|
||||
comptime try testCPtr();
|
||||
try comptime testCPtr();
|
||||
}
|
||||
|
||||
fn testCPtr() !void {
|
||||
@ -60,7 +60,7 @@ test "type info: value is correctly copied" {
|
||||
|
||||
test "type info: tag type, void info" {
|
||||
try testBasic();
|
||||
comptime try testBasic();
|
||||
try comptime testBasic();
|
||||
}
|
||||
|
||||
fn testBasic() !void {
|
||||
@ -72,7 +72,7 @@ fn testBasic() !void {
|
||||
|
||||
test "type info: pointer type info" {
|
||||
try testPointer();
|
||||
comptime try testPointer();
|
||||
try comptime testPointer();
|
||||
}
|
||||
|
||||
fn testPointer() !void {
|
||||
@ -88,7 +88,7 @@ fn testPointer() !void {
|
||||
|
||||
test "type info: unknown length pointer type info" {
|
||||
try testUnknownLenPtr();
|
||||
comptime try testUnknownLenPtr();
|
||||
try comptime testUnknownLenPtr();
|
||||
}
|
||||
|
||||
fn testUnknownLenPtr() !void {
|
||||
@ -104,7 +104,7 @@ fn testUnknownLenPtr() !void {
|
||||
|
||||
test "type info: null terminated pointer type info" {
|
||||
try testNullTerminatedPtr();
|
||||
comptime try testNullTerminatedPtr();
|
||||
try comptime testNullTerminatedPtr();
|
||||
}
|
||||
|
||||
fn testNullTerminatedPtr() !void {
|
||||
@ -120,7 +120,7 @@ fn testNullTerminatedPtr() !void {
|
||||
|
||||
test "type info: slice type info" {
|
||||
try testSlice();
|
||||
comptime try testSlice();
|
||||
try comptime testSlice();
|
||||
}
|
||||
|
||||
fn testSlice() !void {
|
||||
@ -135,7 +135,7 @@ fn testSlice() !void {
|
||||
|
||||
test "type info: array type info" {
|
||||
try testArray();
|
||||
comptime try testArray();
|
||||
try comptime testArray();
|
||||
}
|
||||
|
||||
fn testArray() !void {
|
||||
@ -163,7 +163,7 @@ test "type info: error set, error union info, anyerror" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testErrorSet();
|
||||
comptime try testErrorSet();
|
||||
try comptime testErrorSet();
|
||||
}
|
||||
|
||||
fn testErrorSet() !void {
|
||||
@ -225,7 +225,7 @@ test "type info: enum info" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testEnum();
|
||||
comptime try testEnum();
|
||||
try comptime testEnum();
|
||||
}
|
||||
|
||||
fn testEnum() !void {
|
||||
@ -247,7 +247,7 @@ fn testEnum() !void {
|
||||
|
||||
test "type info: union info" {
|
||||
try testUnion();
|
||||
comptime try testUnion();
|
||||
try comptime testUnion();
|
||||
}
|
||||
|
||||
fn testUnion() !void {
|
||||
@ -257,7 +257,7 @@ fn testUnion() !void {
|
||||
try expect(typeinfo_info.Union.tag_type.? == TypeId);
|
||||
try expect(typeinfo_info.Union.fields.len == 24);
|
||||
try expect(typeinfo_info.Union.fields[4].type == @TypeOf(@typeInfo(u8).Int));
|
||||
try expect(typeinfo_info.Union.decls.len == 22);
|
||||
try expect(typeinfo_info.Union.decls.len == 21);
|
||||
|
||||
const TestNoTagUnion = union {
|
||||
Foo: void,
|
||||
@ -287,7 +287,7 @@ test "type info: struct info" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try testStruct();
|
||||
comptime try testStruct();
|
||||
try comptime testStruct();
|
||||
}
|
||||
|
||||
fn testStruct() !void {
|
||||
@ -306,7 +306,7 @@ const TestStruct = struct {
|
||||
|
||||
test "type info: packed struct info" {
|
||||
try testPackedStruct();
|
||||
comptime try testPackedStruct();
|
||||
try comptime testPackedStruct();
|
||||
}
|
||||
|
||||
fn testPackedStruct() !void {
|
||||
@ -339,7 +339,7 @@ const TestPackedStruct = packed struct {
|
||||
|
||||
test "type info: opaque info" {
|
||||
try testOpaque();
|
||||
comptime try testOpaque();
|
||||
try comptime testOpaque();
|
||||
}
|
||||
|
||||
fn testOpaque() !void {
|
||||
@ -356,7 +356,7 @@ test "type info: function type info" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try testFunction();
|
||||
comptime try testFunction();
|
||||
try comptime testFunction();
|
||||
}
|
||||
|
||||
fn testFunction() !void {
|
||||
@ -427,7 +427,7 @@ test "typeInfo with comptime parameter in struct fn def" {
|
||||
|
||||
test "type info: vectors" {
|
||||
try testVector();
|
||||
comptime try testVector();
|
||||
try comptime testVector();
|
||||
}
|
||||
|
||||
fn testVector() !void {
|
||||
@ -444,7 +444,7 @@ test "type info: anyframe and anyframe->T" {
|
||||
}
|
||||
|
||||
try testAnyFrame();
|
||||
comptime try testAnyFrame();
|
||||
try comptime testAnyFrame();
|
||||
}
|
||||
|
||||
fn testAnyFrame() !void {
|
||||
@ -489,7 +489,7 @@ test "@typeInfo does not force declarations into existence" {
|
||||
@compileError("test failed");
|
||||
}
|
||||
};
|
||||
comptime try expect(@typeInfo(S).Struct.fields.len == 1);
|
||||
try comptime expect(@typeInfo(S).Struct.fields.len == 1);
|
||||
}
|
||||
|
||||
fn add(a: i32, b: i32) i32 {
|
||||
|
@ -113,7 +113,7 @@ const ExternPtrOrInt = extern union {
|
||||
int: u64,
|
||||
};
|
||||
test "extern union size" {
|
||||
comptime try expect(@sizeOf(ExternPtrOrInt) == 8);
|
||||
try comptime expect(@sizeOf(ExternPtrOrInt) == 8);
|
||||
}
|
||||
|
||||
test "0-sized extern union definition" {
|
||||
@ -165,7 +165,7 @@ test "access a member of tagged union with conflicting enum tag name" {
|
||||
const B = void;
|
||||
};
|
||||
|
||||
comptime try expect(Bar.A == u8);
|
||||
try comptime expect(Bar.A == u8);
|
||||
}
|
||||
|
||||
test "constant tagged union with payload" {
|
||||
@ -225,7 +225,7 @@ test "union with specified enum tag" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
try doTest();
|
||||
comptime try doTest();
|
||||
try comptime doTest();
|
||||
}
|
||||
|
||||
test "packed union generates correctly aligned type" {
|
||||
@ -274,7 +274,7 @@ test "comparison between union and enum literal" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try testComparison();
|
||||
comptime try testComparison();
|
||||
try comptime testComparison();
|
||||
}
|
||||
|
||||
const TheTag = enum { A, B, C };
|
||||
@ -289,7 +289,7 @@ test "cast union to tag type of union" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try testCastUnionToTag();
|
||||
comptime try testCastUnionToTag();
|
||||
try comptime testCastUnionToTag();
|
||||
}
|
||||
|
||||
fn testCastUnionToTag() !void {
|
||||
@ -372,14 +372,14 @@ const PackedPtrOrInt = packed union {
|
||||
int: u64,
|
||||
};
|
||||
test "packed union size" {
|
||||
comptime try expect(@sizeOf(PackedPtrOrInt) == 8);
|
||||
try comptime expect(@sizeOf(PackedPtrOrInt) == 8);
|
||||
}
|
||||
|
||||
const ZeroBits = union {
|
||||
OnlyField: void,
|
||||
};
|
||||
test "union with only 1 field which is void should be zero bits" {
|
||||
comptime try expect(@sizeOf(ZeroBits) == 0);
|
||||
try comptime expect(@sizeOf(ZeroBits) == 0);
|
||||
}
|
||||
|
||||
test "tagged union initialization with runtime void" {
|
||||
@ -430,7 +430,7 @@ test "union with only 1 field casted to its enum type" {
|
||||
|
||||
var e = Expr{ .Literal = Literal{ .Bool = true } };
|
||||
const ExprTag = Tag(Expr);
|
||||
comptime try expect(Tag(ExprTag) == u0);
|
||||
try comptime expect(Tag(ExprTag) == u0);
|
||||
var t = @as(ExprTag, e);
|
||||
try expect(t == Expr.Literal);
|
||||
}
|
||||
@ -439,7 +439,7 @@ test "union with one member defaults to u0 tag type" {
|
||||
const U0 = union(enum) {
|
||||
X: u32,
|
||||
};
|
||||
comptime try expect(Tag(Tag(U0)) == u0);
|
||||
try comptime expect(Tag(Tag(U0)) == u0);
|
||||
}
|
||||
|
||||
const Foo1 = union(enum) {
|
||||
@ -547,7 +547,7 @@ test "method call on an empty union" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
const Point = struct {
|
||||
@ -628,7 +628,7 @@ test "tagged union with all void fields but a meaningful tag" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "union(enum(u32)) with specified and unspecified tag values" {
|
||||
@ -637,9 +637,9 @@ test "union(enum(u32)) with specified and unspecified tag values" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
comptime try expect(Tag(Tag(MultipleChoice2)) == u32);
|
||||
try comptime expect(Tag(Tag(MultipleChoice2)) == u32);
|
||||
try testEnumWithSpecifiedAndUnspecifiedTagValues(MultipleChoice2{ .C = 123 });
|
||||
comptime try testEnumWithSpecifiedAndUnspecifiedTagValues(MultipleChoice2{ .C = 123 });
|
||||
try comptime testEnumWithSpecifiedAndUnspecifiedTagValues(MultipleChoice2{ .C = 123 });
|
||||
}
|
||||
|
||||
const MultipleChoice2 = union(enum(u32)) {
|
||||
@ -718,11 +718,11 @@ test "union with only 1 field casted to its enum type which has enum value speci
|
||||
};
|
||||
|
||||
var e = Expr{ .Literal = Literal{ .Bool = true } };
|
||||
comptime try expect(Tag(ExprTag) == comptime_int);
|
||||
try comptime expect(Tag(ExprTag) == comptime_int);
|
||||
comptime var t = @as(ExprTag, e);
|
||||
try expect(t == Expr.Literal);
|
||||
try expect(@enumToInt(t) == 33);
|
||||
comptime try expect(@enumToInt(t) == 33);
|
||||
try comptime expect(@enumToInt(t) == 33);
|
||||
}
|
||||
|
||||
test "@enumToInt works on unions" {
|
||||
@ -805,7 +805,7 @@ test "return union init with void payload" {
|
||||
}
|
||||
};
|
||||
try S.entry();
|
||||
comptime try S.entry();
|
||||
try comptime S.entry();
|
||||
}
|
||||
|
||||
test "@unionInit stored to a const" {
|
||||
@ -833,7 +833,7 @@ test "@unionInit stored to a const" {
|
||||
}
|
||||
};
|
||||
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
try S.doTheTest();
|
||||
}
|
||||
|
||||
@ -905,7 +905,7 @@ test "union with comptime_int tag" {
|
||||
Y: u16,
|
||||
Z: u8,
|
||||
};
|
||||
comptime try expect(Tag(Tag(Union)) == comptime_int);
|
||||
try comptime expect(Tag(Tag(Union)) == comptime_int);
|
||||
}
|
||||
|
||||
test "extern union doesn't trigger field check at comptime" {
|
||||
@ -915,7 +915,7 @@ test "extern union doesn't trigger field check at comptime" {
|
||||
};
|
||||
|
||||
const x = U{ .x = 0x55AAAA55 };
|
||||
comptime try expect(x.y == 0x55);
|
||||
try comptime expect(x.y == 0x55);
|
||||
}
|
||||
|
||||
test "anonymous union literal syntax" {
|
||||
@ -942,7 +942,7 @@ test "anonymous union literal syntax" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "function call result coerces from tagged union to the tag" {
|
||||
@ -975,7 +975,7 @@ test "function call result coerces from tagged union to the tag" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "cast from anonymous struct to union" {
|
||||
@ -1007,7 +1007,7 @@ test "cast from anonymous struct to union" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "cast from pointer to anonymous struct to pointer to union" {
|
||||
@ -1039,7 +1039,7 @@ test "cast from pointer to anonymous struct to pointer to union" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "switching on non exhaustive union" {
|
||||
@ -1067,7 +1067,7 @@ test "switching on non exhaustive union" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "containers with single-field enums" {
|
||||
@ -1096,7 +1096,7 @@ test "containers with single-field enums" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "@unionInit on union with tag but no fields" {
|
||||
@ -1130,7 +1130,7 @@ test "@unionInit on union with tag but no fields" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "union enum type gets a separate scope" {
|
||||
@ -1552,7 +1552,7 @@ test "reinterpreting enum value inside packed union" {
|
||||
}
|
||||
};
|
||||
try U.doTest();
|
||||
comptime try U.doTest();
|
||||
try comptime U.doTest();
|
||||
}
|
||||
|
||||
test "access the tag of a global tagged union" {
|
||||
@ -1581,5 +1581,5 @@ test "coerce enum literal to union in result loc" {
|
||||
}
|
||||
};
|
||||
try U.doTest(true);
|
||||
comptime try U.doTest(true);
|
||||
try comptime U.doTest(true);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ usingnamespace struct {
|
||||
};
|
||||
|
||||
test "usingnamespace does not redeclare an imported variable" {
|
||||
comptime try std.testing.expect(@This().foo == 42);
|
||||
try comptime std.testing.expect(@This().foo == 42);
|
||||
}
|
||||
|
||||
usingnamespace @import("usingnamespace/foo.zig");
|
||||
|
@ -21,7 +21,7 @@ test "implicit cast vector to array - bool" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "vector wrap operators" {
|
||||
@ -45,7 +45,7 @@ test "vector wrap operators" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "vector bin compares with mem.eql" {
|
||||
@ -69,7 +69,7 @@ test "vector bin compares with mem.eql" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "vector int operators" {
|
||||
@ -91,7 +91,7 @@ test "vector int operators" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "vector float operators" {
|
||||
@ -114,7 +114,7 @@ test "vector float operators" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ test "vector bit operators" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "implicit cast vector to array" {
|
||||
@ -153,7 +153,7 @@ test "implicit cast vector to array" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "array to vector" {
|
||||
@ -171,7 +171,7 @@ test "array to vector" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "array to vector with element type coercion" {
|
||||
@ -192,7 +192,7 @@ test "array to vector with element type coercion" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "peer type resolution with coercible element types" {
|
||||
@ -212,7 +212,7 @@ test "peer type resolution with coercible element types" {
|
||||
try std.testing.expect(@TypeOf(c) == @Vector(2, u16));
|
||||
}
|
||||
};
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "tuple to vector" {
|
||||
@ -242,7 +242,7 @@ test "tuple to vector" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "vector casts of sizes not divisible by 8" {
|
||||
@ -278,7 +278,7 @@ test "vector casts of sizes not divisible by 8" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "vector @splat" {
|
||||
@ -326,7 +326,7 @@ test "vector @splat" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "load vector elements via comptime index" {
|
||||
@ -348,7 +348,7 @@ test "load vector elements via comptime index" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "store vector elements via comptime index" {
|
||||
@ -376,7 +376,7 @@ test "store vector elements via comptime index" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "load vector elements via runtime index" {
|
||||
@ -398,7 +398,7 @@ test "load vector elements via runtime index" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "store vector elements via runtime index" {
|
||||
@ -421,7 +421,7 @@ test "store vector elements via runtime index" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "initialize vector which is a struct field" {
|
||||
@ -443,7 +443,7 @@ test "initialize vector which is a struct field" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "vector comparison operators" {
|
||||
@ -484,7 +484,7 @@ test "vector comparison operators" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "vector division operators" {
|
||||
@ -567,7 +567,7 @@ test "vector division operators" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "vector bitwise not operator" {
|
||||
@ -599,7 +599,7 @@ test "vector bitwise not operator" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "vector shift operators" {
|
||||
@ -693,7 +693,7 @@ test "vector shift operators" {
|
||||
}
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "vector reduce operation" {
|
||||
@ -837,7 +837,7 @@ test "vector reduce operation" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "vector @reduce comptime" {
|
||||
@ -849,9 +849,9 @@ test "vector @reduce comptime" {
|
||||
const value = @Vector(4, i32){ 1, -1, 1, -1 };
|
||||
const result = value > @splat(4, @as(i32, 0));
|
||||
// result is { true, false, true, false };
|
||||
comptime try expect(@TypeOf(result) == @Vector(4, bool));
|
||||
try comptime expect(@TypeOf(result) == @Vector(4, bool));
|
||||
const is_all_true = @reduce(.And, result);
|
||||
comptime try expect(@TypeOf(is_all_true) == bool);
|
||||
try comptime expect(@TypeOf(is_all_true) == bool);
|
||||
try expect(is_all_true == false);
|
||||
}
|
||||
|
||||
@ -903,7 +903,7 @@ test "saturating add" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "saturating subtraction" {
|
||||
@ -926,7 +926,7 @@ test "saturating subtraction" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "saturating multiplication" {
|
||||
@ -953,7 +953,7 @@ test "saturating multiplication" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "saturating shift-left" {
|
||||
@ -976,7 +976,7 @@ test "saturating shift-left" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "multiplication-assignment operator with an array operand" {
|
||||
@ -997,7 +997,7 @@ test "multiplication-assignment operator with an array operand" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "@addWithOverflow" {
|
||||
@ -1041,7 +1041,7 @@ test "@addWithOverflow" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "@subWithOverflow" {
|
||||
@ -1071,7 +1071,7 @@ test "@subWithOverflow" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "@mulWithOverflow" {
|
||||
@ -1092,7 +1092,7 @@ test "@mulWithOverflow" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "@shlWithOverflow" {
|
||||
@ -1113,7 +1113,7 @@ test "@shlWithOverflow" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "alignment of vectors" {
|
||||
|
@ -122,7 +122,7 @@ test "while copies its payload" {
|
||||
}
|
||||
};
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "continue and break" {
|
||||
@ -293,7 +293,7 @@ test "while bool 2 break statements and an else" {
|
||||
}
|
||||
};
|
||||
try S.entry(true, false);
|
||||
comptime try S.entry(true, false);
|
||||
try comptime S.entry(true, false);
|
||||
}
|
||||
|
||||
test "while optional 2 break statements and an else" {
|
||||
@ -312,7 +312,7 @@ test "while optional 2 break statements and an else" {
|
||||
}
|
||||
};
|
||||
try S.entry(true, false);
|
||||
comptime try S.entry(true, false);
|
||||
try comptime S.entry(true, false);
|
||||
}
|
||||
|
||||
test "while error 2 break statements and an else" {
|
||||
@ -332,7 +332,7 @@ test "while error 2 break statements and an else" {
|
||||
}
|
||||
};
|
||||
try S.entry(true, false);
|
||||
comptime try S.entry(true, false);
|
||||
try comptime S.entry(true, false);
|
||||
}
|
||||
|
||||
test "continue inline while loop" {
|
||||
|
@ -31,12 +31,12 @@ test "wrapping add" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
|
||||
comptime try S.testWrapAdd(comptime_int, 0, 0, 0);
|
||||
comptime try S.testWrapAdd(comptime_int, 3, 2, 5);
|
||||
comptime try S.testWrapAdd(comptime_int, 651075816498665588400716961808225370057, 468229432685078038144554201546849378455, 1119305249183743626545271163355074748512);
|
||||
comptime try S.testWrapAdd(comptime_int, 7, -593423721213448152027139550640105366508, -593423721213448152027139550640105366501);
|
||||
try comptime S.testWrapAdd(comptime_int, 0, 0, 0);
|
||||
try comptime S.testWrapAdd(comptime_int, 3, 2, 5);
|
||||
try comptime S.testWrapAdd(comptime_int, 651075816498665588400716961808225370057, 468229432685078038144554201546849378455, 1119305249183743626545271163355074748512);
|
||||
try comptime S.testWrapAdd(comptime_int, 7, -593423721213448152027139550640105366508, -593423721213448152027139550640105366501);
|
||||
}
|
||||
|
||||
test "wrapping subtraction" {
|
||||
@ -64,12 +64,12 @@ test "wrapping subtraction" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
|
||||
comptime try S.testWrapSub(comptime_int, 0, 0, 0);
|
||||
comptime try S.testWrapSub(comptime_int, 3, 2, 1);
|
||||
comptime try S.testWrapSub(comptime_int, 651075816498665588400716961808225370057, 468229432685078038144554201546849378455, 182846383813587550256162760261375991602);
|
||||
comptime try S.testWrapSub(comptime_int, 7, -593423721213448152027139550640105366508, 593423721213448152027139550640105366515);
|
||||
try comptime S.testWrapSub(comptime_int, 0, 0, 0);
|
||||
try comptime S.testWrapSub(comptime_int, 3, 2, 1);
|
||||
try comptime S.testWrapSub(comptime_int, 651075816498665588400716961808225370057, 468229432685078038144554201546849378455, 182846383813587550256162760261375991602);
|
||||
try comptime S.testWrapSub(comptime_int, 7, -593423721213448152027139550640105366508, 593423721213448152027139550640105366515);
|
||||
}
|
||||
|
||||
test "wrapping multiplication" {
|
||||
@ -101,10 +101,10 @@ test "wrapping multiplication" {
|
||||
};
|
||||
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
|
||||
comptime try S.testWrapMul(comptime_int, 0, 0, 0);
|
||||
comptime try S.testWrapMul(comptime_int, 3, 2, 6);
|
||||
comptime try S.testWrapMul(comptime_int, 651075816498665588400716961808225370057, 468229432685078038144554201546849378455, 304852860194144160265083087140337419215516305999637969803722975979232817921935);
|
||||
comptime try S.testWrapMul(comptime_int, 7, -593423721213448152027139550640105366508, -4153966048494137064189976854480737565556);
|
||||
try comptime S.testWrapMul(comptime_int, 0, 0, 0);
|
||||
try comptime S.testWrapMul(comptime_int, 3, 2, 6);
|
||||
try comptime S.testWrapMul(comptime_int, 651075816498665588400716961808225370057, 468229432685078038144554201546849378455, 304852860194144160265083087140337419215516305999637969803722975979232817921935);
|
||||
try comptime S.testWrapMul(comptime_int, 7, -593423721213448152027139550640105366508, -4153966048494137064189976854480737565556);
|
||||
}
|
||||
|
@ -2,8 +2,7 @@ export fn f1(x: u32) u32 {
|
||||
const y = -%x;
|
||||
return -y;
|
||||
}
|
||||
const V = @import("std").meta.Vector;
|
||||
export fn f2(x: V(4, u32)) V(4, u32) {
|
||||
export fn f2(x: @Vector(4, u32)) @Vector(4, u32) {
|
||||
const y = -%x;
|
||||
return -y;
|
||||
}
|
||||
@ -13,4 +12,4 @@ export fn f2(x: V(4, u32)) V(4, u32) {
|
||||
// target=native
|
||||
//
|
||||
// :3:12: error: negation of type 'u32'
|
||||
// :8:12: error: negation of type '@Vector(4, u32)'
|
||||
// :7:12: error: negation of type '@Vector(4, u32)'
|
||||
|
@ -1,6 +1,6 @@
|
||||
comptime {
|
||||
var a: @import("std").meta.Vector(4, u8) = [_]u8{ 1, 2, 255, 4 };
|
||||
var b: @import("std").meta.Vector(4, u8) = [_]u8{ 5, 6, 1, 8 };
|
||||
var a: @Vector(4, u8) = [_]u8{ 1, 2, 255, 4 };
|
||||
var b: @Vector(4, u8) = [_]u8{ 5, 6, 1, 8 };
|
||||
var x = a + b;
|
||||
_ = x;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
export fn entry() void {
|
||||
const V1 = @import("std").meta.Vector(4, u8);
|
||||
const V1 = @Vector(4, u8);
|
||||
const V2 = @Type(.{ .Vector = .{ .len = 4, .child = V1 } });
|
||||
var v: V2 = undefined;
|
||||
_ = v;
|
||||
|
@ -1,6 +1,6 @@
|
||||
export fn entry() void {
|
||||
const v: @import("std").meta.Vector(4, u32) = [4]u32{ 10, 11, 12, 13 };
|
||||
const x: @import("std").meta.Vector(4, u32) = [4]u32{ 14, 15, 16, 17 };
|
||||
const v: @Vector(4, u32) = [4]u32{ 10, 11, 12, 13 };
|
||||
const x: @Vector(4, u32) = [4]u32{ 14, 15, 16, 17 };
|
||||
var z = @shuffle(u32, v, x, [8]i32{ 0, 1, 2, 3, 7, 6, 5, 4 });
|
||||
_ = z;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
export fn entry() void {
|
||||
const x = @import("std").meta.Vector(3, f32){ 25, 75, 5, 0 };
|
||||
const x = @Vector(3, f32){ 25, 75, 5, 0 };
|
||||
_ = x;
|
||||
}
|
||||
|
||||
@ -7,4 +7,4 @@ export fn entry() void {
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :2:49: error: expected 3 vector elements; found 4
|
||||
// :2:30: error: expected 3 vector elements; found 4
|
||||
|
@ -3,5 +3,5 @@ const std = @import("std");
|
||||
const testing = std.testing;
|
||||
|
||||
test "c import" {
|
||||
comptime try testing.expect(c.NUMBER == 1234);
|
||||
try comptime testing.expect(c.NUMBER == 1234);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user