diff --git a/lib/std/Random/Isaac64.zig b/lib/std/Random/Isaac64.zig index cbf9df8803..624fad7f88 100644 --- a/lib/std/Random/Isaac64.zig +++ b/lib/std/Random/Isaac64.zig @@ -201,7 +201,7 @@ test "sequence" { } } -test "fill" { +test fill { var r = Isaac64.init(0); // from reference implementation diff --git a/lib/std/Random/Pcg.zig b/lib/std/Random/Pcg.zig index a5f4ef7e41..18d1ddcfec 100644 --- a/lib/std/Random/Pcg.zig +++ b/lib/std/Random/Pcg.zig @@ -92,7 +92,7 @@ test "sequence" { } } -test "fill" { +test fill { var r = Pcg.init(0); const s0: u64 = 0x9394bf54ce5d79de; const s1: u64 = 0x84e9c579ef59bbf7; diff --git a/lib/std/Random/RomuTrio.zig b/lib/std/Random/RomuTrio.zig index 202361ae66..5b7664d7f2 100644 --- a/lib/std/Random/RomuTrio.zig +++ b/lib/std/Random/RomuTrio.zig @@ -94,7 +94,7 @@ test "sequence" { } } -test "fill" { +test fill { // Unfortunately there does not seem to be an official test sequence. var r = RomuTrio.init(0); diff --git a/lib/std/Random/Sfc64.zig b/lib/std/Random/Sfc64.zig index 7a68446096..ebe618ddcf 100644 --- a/lib/std/Random/Sfc64.zig +++ b/lib/std/Random/Sfc64.zig @@ -98,7 +98,7 @@ test "sequence" { } } -test "fill" { +test fill { // Unfortunately there does not seem to be an official test sequence. var r = Sfc64.init(0); diff --git a/lib/std/Random/Xoroshiro128.zig b/lib/std/Random/Xoroshiro128.zig index 44eb594e37..37679069a9 100644 --- a/lib/std/Random/Xoroshiro128.zig +++ b/lib/std/Random/Xoroshiro128.zig @@ -122,7 +122,7 @@ test "sequence" { } } -test "fill" { +test fill { var r = Xoroshiro128.init(0); r.s[0] = 0xaeecf86f7878dd75; r.s[1] = 0x01cd153642e72622; diff --git a/lib/std/Random/Xoshiro256.zig b/lib/std/Random/Xoshiro256.zig index 94e62b1480..fb65c2ba58 100644 --- a/lib/std/Random/Xoshiro256.zig +++ b/lib/std/Random/Xoshiro256.zig @@ -122,7 +122,7 @@ test "sequence" { } } -test "fill" { +test fill { var r = Xoshiro256.init(0); const seq = [_]u64{ diff --git a/lib/std/SemanticVersion.zig b/lib/std/SemanticVersion.zig index 71529045e5..bde3e906d8 100644 --- a/lib/std/SemanticVersion.zig +++ b/lib/std/SemanticVersion.zig @@ -166,7 +166,7 @@ pub fn format( const expect = std.testing.expect; const expectError = std.testing.expectError; -test "format" { +test format { // Many of these test strings are from https://github.com/semver/semver.org/issues/59#issuecomment-390854010. // Valid version strings should be accepted. diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index bf538c1b4f..a043f267bf 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -1437,7 +1437,7 @@ fn testIncrementNotify(value: *usize, event: *ResetEvent) void { event.set(); } -test "join" { +test join { if (builtin.single_threaded) return error.SkipZigTest; var value: usize = 0; @@ -1449,7 +1449,7 @@ test "join" { try std.testing.expectEqual(value, 1); } -test "detach" { +test detach { if (builtin.single_threaded) return error.SkipZigTest; var value: usize = 0; diff --git a/lib/std/Thread/Condition.zig b/lib/std/Thread/Condition.zig index 5c436261a8..b1154f8bd0 100644 --- a/lib/std/Thread/Condition.zig +++ b/lib/std/Thread/Condition.zig @@ -362,7 +362,7 @@ test "wait and signal" { } } -test "signal" { +test signal { // This test requires spawning threads if (builtin.single_threaded) { return error.SkipZigTest; @@ -491,7 +491,7 @@ test "multi signal" { } } -test "broadcasting" { +test broadcast { // This test requires spawning threads if (builtin.single_threaded) { return error.SkipZigTest; diff --git a/lib/std/Thread/Semaphore.zig b/lib/std/Thread/Semaphore.zig index 47dccea6df..a82ae3d002 100644 --- a/lib/std/Thread/Semaphore.zig +++ b/lib/std/Thread/Semaphore.zig @@ -71,7 +71,7 @@ pub fn post(sem: *Semaphore) void { sem.cond.signal(); } -test "Semaphore" { +test Semaphore { if (builtin.single_threaded) { return error.SkipZigTest; } @@ -97,7 +97,7 @@ test "Semaphore" { try testing.expect(n == num_threads); } -test "timedWait" { +test timedWait { var sem = Semaphore{}; try testing.expectEqual(0, sem.permits); diff --git a/lib/std/buf_set.zig b/lib/std/buf_set.zig index 6ff8ee23af..f027d57699 100644 --- a/lib/std/buf_set.zig +++ b/lib/std/buf_set.zig @@ -90,6 +90,23 @@ pub const BufSet = struct { return self.cloneWithAllocator(self.allocator()); } + test clone { + var original = BufSet.init(testing.allocator); + defer original.deinit(); + try original.insert("x"); + + var cloned = try original.clone(); + defer cloned.deinit(); + cloned.remove("x"); + try testing.expect(original.count() == 1); + try testing.expect(cloned.count() == 0); + + try testing.expectError( + error.OutOfMemory, + original.cloneWithAllocator(testing.failing_allocator), + ); + } + fn free(self: *const BufSet, value: []const u8) void { self.hash_map.allocator.free(value); } @@ -115,23 +132,6 @@ test BufSet { try bufset.insert("z"); } -test "clone" { - var original = BufSet.init(testing.allocator); - defer original.deinit(); - try original.insert("x"); - - var cloned = try original.clone(); - defer cloned.deinit(); - cloned.remove("x"); - try testing.expect(original.count() == 1); - try testing.expect(cloned.count() == 0); - - try testing.expectError( - error.OutOfMemory, - original.cloneWithAllocator(testing.failing_allocator), - ); -} - test "clone with arena" { const allocator = std.testing.allocator; var arena = std.heap.ArenaAllocator.init(allocator); diff --git a/lib/std/compress/flate/CircularBuffer.zig b/lib/std/compress/flate/CircularBuffer.zig index bb98173aad..066e0b4f39 100644 --- a/lib/std/compress/flate/CircularBuffer.zig +++ b/lib/std/compress/flate/CircularBuffer.zig @@ -130,7 +130,7 @@ pub fn full(self: *Self) bool { } // example from: https://youtu.be/SJPvNi4HrWQ?t=3558 -test "writeMatch" { +test writeMatch { var cb: Self = .{}; cb.writeAll("a salad; "); @@ -150,7 +150,7 @@ test "writeMatch overlap" { try testing.expectEqualStrings("a b c b c b c d", cb.read()); } -test "readAtMost" { +test readAtMost { var cb: Self = .{}; cb.writeAll("0123456789"); @@ -165,7 +165,7 @@ test "readAtMost" { try testing.expectEqualStrings("", cb.read()); } -test "CircularBuffer" { +test Self { var cb: Self = .{}; const data = "0123456789abcdef" ** (1024 / 16); diff --git a/lib/std/compress/flate/Lookup.zig b/lib/std/compress/flate/Lookup.zig index 34ac38f5e8..31f59550b0 100644 --- a/lib/std/compress/flate/Lookup.zig +++ b/lib/std/compress/flate/Lookup.zig @@ -83,7 +83,7 @@ fn hashu(v: u32) u32 { return @intCast((v *% prime4) >> consts.lookup.shift); } -test "add/prev" { +test add { const data = [_]u8{ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, @@ -107,7 +107,7 @@ test "add/prev" { try expect(h.chain[2 + 8] == 2); } -test "bulkAdd" { +test bulkAdd { const data = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."; // one by one diff --git a/lib/std/compress/flate/SlidingWindow.zig b/lib/std/compress/flate/SlidingWindow.zig index 684b91bacc..4a10383820 100644 --- a/lib/std/compress/flate/SlidingWindow.zig +++ b/lib/std/compress/flate/SlidingWindow.zig @@ -122,7 +122,7 @@ pub fn tokensBuffer(self: *Self) ?[]const u8 { return self.buffer[@intCast(self.fp)..self.rp]; } -test "match" { +test match { const data = "Blah blah blah blah blah!"; var win: Self = .{}; try expect(win.write(data) == data.len); @@ -142,7 +142,7 @@ test "match" { try expect(win.match(15, 20, 4) == 0); } -test "slide" { +test slide { var win: Self = .{}; win.wp = Self.buffer_len - 11; win.rp = Self.buffer_len - 111; diff --git a/lib/std/compress/flate/huffman_encoder.zig b/lib/std/compress/flate/huffman_encoder.zig index 067b5197d3..c1c5148c97 100644 --- a/lib/std/compress/flate/huffman_encoder.zig +++ b/lib/std/compress/flate/huffman_encoder.zig @@ -458,7 +458,7 @@ fn bitReverse(comptime T: type, value: T, n: usize) T { return r >> @as(math.Log2Int(T), @intCast(@typeInfo(T).Int.bits - n)); } -test "bitReverse" { +test bitReverse { const ReverseBitsTest = struct { in: u16, bit_count: u5, diff --git a/lib/std/enums.zig b/lib/std/enums.zig index f992276431..7247b5dc88 100644 --- a/lib/std/enums.zig +++ b/lib/std/enums.zig @@ -120,7 +120,7 @@ pub fn directEnumArray( return directEnumArrayDefault(E, Data, null, max_unused_slots, init_values); } -test "directEnumArray" { +test directEnumArray { const E = enum(i4) { a = 4, b = 6, c = 2 }; var runtime_false: bool = false; _ = &runtime_false; @@ -163,7 +163,7 @@ pub fn directEnumArrayDefault( return result; } -test "directEnumArrayDefault" { +test directEnumArrayDefault { const E = enum(i4) { a = 4, b = 6, c = 2 }; var runtime_false: bool = false; _ = &runtime_false; @@ -214,7 +214,7 @@ pub fn nameCast(comptime E: type, comptime value: anytype) E { }; } -test "nameCast" { +test nameCast { const A = enum(u1) { a = 0, b = 1 }; const B = enum(u1) { a = 1, b = 0 }; try testing.expectEqual(A.a, nameCast(A, .a)); @@ -515,7 +515,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { }; } -test "EnumMultiset" { +test EnumMultiset { const Ball = enum { red, green, blue }; const empty = EnumMultiset(Ball).initEmpty(); @@ -1298,7 +1298,7 @@ pub fn ensureIndexer(comptime T: type) void { } } -test "ensureIndexer" { +test ensureIndexer { ensureIndexer(struct { pub const Key = u32; pub const count: comptime_int = 8; @@ -1535,7 +1535,7 @@ test "EnumIndexer empty" { try testing.expectEqual(0, Indexer.count); } -test "enumValues" { +test values { const E = enum { X, Y, diff --git a/lib/std/math/acos.zig b/lib/std/math/acos.zig index 6adc00b4f7..dfb3caf4d9 100644 --- a/lib/std/math/acos.zig +++ b/lib/std/math/acos.zig @@ -148,12 +148,12 @@ fn acos64(x: f64) f64 { return 2 * (df + w); } -test "acos" { +test acos { try expect(acos(@as(f32, 0.0)) == acos32(0.0)); try expect(acos(@as(f64, 0.0)) == acos64(0.0)); } -test "acos32" { +test acos32 { const epsilon = 0.000001; try expect(math.approxEqAbs(f32, acos32(0.0), 1.570796, epsilon)); @@ -164,7 +164,7 @@ test "acos32" { try expect(math.approxEqAbs(f32, acos32(-0.2), 1.772154, epsilon)); } -test "acos64" { +test acos64 { const epsilon = 0.000001; try expect(math.approxEqAbs(f64, acos64(0.0), 1.570796, epsilon)); diff --git a/lib/std/math/acosh.zig b/lib/std/math/acosh.zig index 7bc9c06fc2..8c86dbba4c 100644 --- a/lib/std/math/acosh.zig +++ b/lib/std/math/acosh.zig @@ -59,12 +59,12 @@ fn acosh64(x: f64) f64 { } } -test "acosh" { +test acosh { try expect(acosh(@as(f32, 1.5)) == acosh32(1.5)); try expect(acosh(@as(f64, 1.5)) == acosh64(1.5)); } -test "acosh32" { +test acosh32 { const epsilon = 0.000001; try expect(math.approxEqAbs(f32, acosh32(1.5), 0.962424, epsilon)); @@ -73,7 +73,7 @@ test "acosh32" { try expect(math.approxEqAbs(f32, acosh32(123123.234375), 12.414088, epsilon)); } -test "acosh64" { +test acosh64 { const epsilon = 0.000001; try expect(math.approxEqAbs(f64, acosh64(1.5), 0.962424, epsilon)); diff --git a/lib/std/math/asin.zig b/lib/std/math/asin.zig index 885ab35b9b..cb4571c24e 100644 --- a/lib/std/math/asin.zig +++ b/lib/std/math/asin.zig @@ -141,12 +141,12 @@ fn asin64(x: f64) f64 { } } -test "asin" { +test asin { try expect(asin(@as(f32, 0.0)) == asin32(0.0)); try expect(asin(@as(f64, 0.0)) == asin64(0.0)); } -test "asin32" { +test asin32 { const epsilon = 0.000001; try expect(math.approxEqAbs(f32, asin32(0.0), 0.0, epsilon)); @@ -157,7 +157,7 @@ test "asin32" { try expect(math.approxEqAbs(f32, asin32(0.8923), 1.102415, epsilon)); } -test "asin64" { +test asin64 { const epsilon = 0.000001; try expect(math.approxEqAbs(f64, asin64(0.0), 0.0, epsilon)); diff --git a/lib/std/math/asinh.zig b/lib/std/math/asinh.zig index 81e1abc7b8..b2fd1b13a2 100644 --- a/lib/std/math/asinh.zig +++ b/lib/std/math/asinh.zig @@ -80,12 +80,12 @@ fn asinh64(x: f64) f64 { return if (s != 0) -rx else rx; } -test "asinh" { +test asinh { try expect(asinh(@as(f32, 0.0)) == asinh32(0.0)); try expect(asinh(@as(f64, 0.0)) == asinh64(0.0)); } -test "asinh32" { +test asinh32 { const epsilon = 0.000001; try expect(math.approxEqAbs(f32, asinh32(0.0), 0.0, epsilon)); @@ -98,7 +98,7 @@ test "asinh32" { try expect(math.approxEqAbs(f32, asinh32(123123.234375), 12.414088, epsilon)); } -test "asinh64" { +test asinh64 { const epsilon = 0.000001; try expect(math.approxEqAbs(f64, asinh64(0.0), 0.0, epsilon)); diff --git a/lib/std/math/atan.zig b/lib/std/math/atan.zig index b6cf2310c4..377d96897f 100644 --- a/lib/std/math/atan.zig +++ b/lib/std/math/atan.zig @@ -212,12 +212,12 @@ fn atan64(x_: f64) f64 { } } -test "atan" { +test atan { try expect(@as(u32, @bitCast(atan(@as(f32, 0.2)))) == @as(u32, @bitCast(atan32(0.2)))); try expect(atan(@as(f64, 0.2)) == atan64(0.2)); } -test "atan32" { +test atan32 { const epsilon = 0.000001; try expect(math.approxEqAbs(f32, atan32(0.2), 0.197396, epsilon)); @@ -227,7 +227,7 @@ test "atan32" { try expect(math.approxEqAbs(f32, atan32(1.5), 0.982794, epsilon)); } -test "atan64" { +test atan64 { const epsilon = 0.000001; try expect(math.approxEqAbs(f64, atan64(0.2), 0.197396, epsilon)); diff --git a/lib/std/math/atan2.zig b/lib/std/math/atan2.zig index 77ceff37d2..f0c8aa0792 100644 --- a/lib/std/math/atan2.zig +++ b/lib/std/math/atan2.zig @@ -214,7 +214,7 @@ fn atan2_64(y: f64, x: f64) f64 { } } -test "atan2" { +test atan2 { const y32: f32 = 0.2; const x32: f32 = 0.21; const y64: f64 = 0.2; @@ -223,7 +223,7 @@ test "atan2" { try expect(atan2(y64, x64) == atan2_64(0.2, 0.21)); } -test "atan2_32" { +test atan2_32 { const epsilon = 0.000001; try expect(math.approxEqAbs(f32, atan2_32(0.0, 0.0), 0.0, epsilon)); @@ -235,7 +235,7 @@ test "atan2_32" { try expect(math.approxEqAbs(f32, atan2_32(0.34, 1.243), 0.267001, epsilon)); } -test "atan2_64" { +test atan2_64 { const epsilon = 0.000001; try expect(math.approxEqAbs(f64, atan2_64(0.0, 0.0), 0.0, epsilon)); diff --git a/lib/std/math/atanh.zig b/lib/std/math/atanh.zig index 51051c5902..4cca62a8e7 100644 --- a/lib/std/math/atanh.zig +++ b/lib/std/math/atanh.zig @@ -84,12 +84,12 @@ fn atanh_64(x: f64) f64 { return if (s != 0) -y else y; } -test "atanh" { +test atanh { try expect(atanh(@as(f32, 0.0)) == atanh_32(0.0)); try expect(atanh(@as(f64, 0.0)) == atanh_64(0.0)); } -test "atanh_32" { +test atanh_32 { const epsilon = 0.000001; try expect(math.approxEqAbs(f32, atanh_32(0.0), 0.0, epsilon)); @@ -97,7 +97,7 @@ test "atanh_32" { try expect(math.approxEqAbs(f32, atanh_32(0.8923), 1.433099, epsilon)); } -test "atanh_64" { +test atanh_64 { const epsilon = 0.000001; try expect(math.approxEqAbs(f64, atanh_64(0.0), 0.0, epsilon)); diff --git a/lib/std/math/big/rational.zig b/lib/std/math/big/rational.zig index 35df8f9018..774e0c1314 100644 --- a/lib/std/math/big/rational.zig +++ b/lib/std/math/big/rational.zig @@ -493,7 +493,7 @@ fn extractLowBits(a: Int, comptime T: type) T { } } -test "extractLowBits" { +test extractLowBits { var a = try Int.initSet(testing.allocator, 0x11112222333344441234567887654321); defer a.deinit(); diff --git a/lib/std/math/cbrt.zig b/lib/std/math/cbrt.zig index 140b06f4e5..e1290fdd2b 100644 --- a/lib/std/math/cbrt.zig +++ b/lib/std/math/cbrt.zig @@ -119,12 +119,12 @@ fn cbrt64(x: f64) f64 { return t + t * q; } -test "cbrt" { +test cbrt { try expect(cbrt(@as(f32, 0.0)) == cbrt32(0.0)); try expect(cbrt(@as(f64, 0.0)) == cbrt64(0.0)); } -test "cbrt32" { +test cbrt32 { const epsilon = 0.000001; try expect(math.isPositiveZero(cbrt32(0.0))); @@ -135,7 +135,7 @@ test "cbrt32" { try expect(math.approxEqAbs(f32, cbrt32(123123.234375), 49.748501, epsilon)); } -test "cbrt64" { +test cbrt64 { const epsilon = 0.000001; try expect(math.isPositiveZero(cbrt64(0.0))); diff --git a/lib/std/math/complex/atan.zig b/lib/std/math/complex/atan.zig index 77a1e5b839..33109178f8 100644 --- a/lib/std/math/complex/atan.zig +++ b/lib/std/math/complex/atan.zig @@ -120,7 +120,7 @@ fn atan64(z: Complex(f64)) Complex(f64) { const epsilon = 0.0001; -test "atan32" { +test atan32 { const a = Complex(f32).init(5, 3); const c = atan(a); @@ -128,7 +128,7 @@ test "atan32" { try testing.expect(math.approxEqAbs(f32, c.im, 0.086569, epsilon)); } -test "atan64" { +test atan64 { const a = Complex(f64).init(5, 3); const c = atan(a); diff --git a/lib/std/math/complex/atanh.zig b/lib/std/math/complex/atanh.zig index 4a246daa85..54d21fc433 100644 --- a/lib/std/math/complex/atanh.zig +++ b/lib/std/math/complex/atanh.zig @@ -14,7 +14,7 @@ pub fn atanh(z: anytype) Complex(@TypeOf(z.re, z.im)) { const epsilon = 0.0001; -test "atanh" { +test atanh { const a = Complex(f32).init(5, 3); const c = atanh(a); diff --git a/lib/std/math/complex/conj.zig b/lib/std/math/complex/conj.zig index 596bf2a296..b5a4d063d3 100644 --- a/lib/std/math/complex/conj.zig +++ b/lib/std/math/complex/conj.zig @@ -10,7 +10,7 @@ pub fn conj(z: anytype) Complex(@TypeOf(z.re, z.im)) { return Complex(T).init(z.re, -z.im); } -test "onj" { +test conj { const a = Complex(f32).init(5, 3); const c = a.conjugate(); diff --git a/lib/std/math/complex/cos.zig b/lib/std/math/complex/cos.zig index 85ab07bf4b..389dd013e3 100644 --- a/lib/std/math/complex/cos.zig +++ b/lib/std/math/complex/cos.zig @@ -13,7 +13,7 @@ pub fn cos(z: anytype) Complex(@TypeOf(z.re, z.im)) { const epsilon = 0.0001; -test "cos" { +test cos { const a = Complex(f32).init(5, 3); const c = cos(a); diff --git a/lib/std/math/complex/cosh.zig b/lib/std/math/complex/cosh.zig index ffaff9932a..42f5b432ec 100644 --- a/lib/std/math/complex/cosh.zig +++ b/lib/std/math/complex/cosh.zig @@ -155,7 +155,7 @@ fn cosh64(z: Complex(f64)) Complex(f64) { const epsilon = 0.0001; -test "cosh32" { +test cosh32 { const a = Complex(f32).init(5, 3); const c = cosh(a); @@ -163,7 +163,7 @@ test "cosh32" { try testing.expect(math.approxEqAbs(f32, c.im, 10.471557, epsilon)); } -test "cosh64" { +test cosh64 { const a = Complex(f64).init(5, 3); const c = cosh(a); diff --git a/lib/std/math/complex/exp.zig b/lib/std/math/complex/exp.zig index 457bddc1e2..a3916300c4 100644 --- a/lib/std/math/complex/exp.zig +++ b/lib/std/math/complex/exp.zig @@ -119,7 +119,7 @@ fn exp64(z: Complex(f64)) Complex(f64) { } } -test "exp32" { +test exp32 { const tolerance_f32 = @sqrt(math.floatEps(f32)); { @@ -139,7 +139,7 @@ test "exp32" { } } -test "exp64" { +test exp64 { const tolerance_f64 = @sqrt(math.floatEps(f64)); { diff --git a/lib/std/math/complex/log.zig b/lib/std/math/complex/log.zig index 12329380bd..65859c2dce 100644 --- a/lib/std/math/complex/log.zig +++ b/lib/std/math/complex/log.zig @@ -15,7 +15,7 @@ pub fn log(z: anytype) Complex(@TypeOf(z.re, z.im)) { const epsilon = 0.0001; -test "log" { +test log { const a = Complex(f32).init(5, 3); const c = log(a); diff --git a/lib/std/math/complex/pow.zig b/lib/std/math/complex/pow.zig index d675f56739..874e4037dc 100644 --- a/lib/std/math/complex/pow.zig +++ b/lib/std/math/complex/pow.zig @@ -11,7 +11,7 @@ pub fn pow(z: anytype, s: anytype) Complex(@TypeOf(z.re, z.im, s.re, s.im)) { const epsilon = 0.0001; -test "pow" { +test pow { const a = Complex(f32).init(5, 3); const b = Complex(f32).init(2.3, -1.3); const c = pow(a, b); diff --git a/lib/std/math/complex/proj.zig b/lib/std/math/complex/proj.zig index 7026977b36..b7d3d58b12 100644 --- a/lib/std/math/complex/proj.zig +++ b/lib/std/math/complex/proj.zig @@ -15,9 +15,7 @@ pub fn proj(z: anytype) Complex(@TypeOf(z.re, z.im)) { return Complex(T).init(z.re, z.im); } -const epsilon = 0.0001; - -test "proj" { +test proj { const a = Complex(f32).init(5, 3); const c = proj(a); diff --git a/lib/std/math/complex/sin.zig b/lib/std/math/complex/sin.zig index 4ea4ca5be1..3ca2419e43 100644 --- a/lib/std/math/complex/sin.zig +++ b/lib/std/math/complex/sin.zig @@ -14,7 +14,7 @@ pub fn sin(z: anytype) Complex(@TypeOf(z.re, z.im)) { const epsilon = 0.0001; -test "sin" { +test sin { const a = Complex(f32).init(5, 3); const c = sin(a); diff --git a/lib/std/math/complex/sinh.zig b/lib/std/math/complex/sinh.zig index c8fce46947..911587a9c5 100644 --- a/lib/std/math/complex/sinh.zig +++ b/lib/std/math/complex/sinh.zig @@ -154,7 +154,7 @@ fn sinh64(z: Complex(f64)) Complex(f64) { const epsilon = 0.0001; -test "sinh32" { +test sinh32 { const a = Complex(f32).init(5, 3); const c = sinh(a); @@ -162,7 +162,7 @@ test "sinh32" { try testing.expect(math.approxEqAbs(f32, c.im, 10.472508, epsilon)); } -test "sinh64" { +test sinh64 { const a = Complex(f64).init(5, 3); const c = sinh(a); diff --git a/lib/std/math/complex/sqrt.zig b/lib/std/math/complex/sqrt.zig index 6a1f9d21c7..0edf18fb23 100644 --- a/lib/std/math/complex/sqrt.zig +++ b/lib/std/math/complex/sqrt.zig @@ -129,7 +129,7 @@ fn sqrt64(z: Complex(f64)) Complex(f64) { const epsilon = 0.0001; -test "sqrt32" { +test sqrt32 { const a = Complex(f32).init(5, 3); const c = sqrt(a); @@ -137,7 +137,7 @@ test "sqrt32" { try testing.expect(math.approxEqAbs(f32, c.im, 0.644574, epsilon)); } -test "sqrt64" { +test sqrt64 { const a = Complex(f64).init(5, 3); const c = sqrt(a); diff --git a/lib/std/math/complex/tan.zig b/lib/std/math/complex/tan.zig index de7f340450..ad5b1b47b6 100644 --- a/lib/std/math/complex/tan.zig +++ b/lib/std/math/complex/tan.zig @@ -14,7 +14,7 @@ pub fn tan(z: anytype) Complex(@TypeOf(z.re, z.im)) { const epsilon = 0.0001; -test "tan" { +test tan { const a = Complex(f32).init(5, 3); const c = tan(a); diff --git a/lib/std/math/complex/tanh.zig b/lib/std/math/complex/tanh.zig index 554b83f46f..8a1d46eca7 100644 --- a/lib/std/math/complex/tanh.zig +++ b/lib/std/math/complex/tanh.zig @@ -103,7 +103,7 @@ fn tanh64(z: Complex(f64)) Complex(f64) { const epsilon = 0.0001; -test "tanh32" { +test tanh32 { const a = Complex(f32).init(5, 3); const c = tanh(a); @@ -111,7 +111,7 @@ test "tanh32" { try testing.expect(math.approxEqAbs(f32, c.im, -0.000025, epsilon)); } -test "tanh64" { +test tanh64 { const a = Complex(f64).init(5, 3); const c = tanh(a); diff --git a/lib/std/math/cosh.zig b/lib/std/math/cosh.zig index 8b46081de1..950448bb74 100644 --- a/lib/std/math/cosh.zig +++ b/lib/std/math/cosh.zig @@ -86,12 +86,12 @@ fn cosh64(x: f64) f64 { return expo2(ax); } -test "cosh" { +test cosh { try expect(cosh(@as(f32, 1.5)) == cosh32(1.5)); try expect(cosh(@as(f64, 1.5)) == cosh64(1.5)); } -test "cosh32" { +test cosh32 { const epsilon = 0.000001; try expect(math.approxEqAbs(f32, cosh32(0.0), 1.0, epsilon)); @@ -104,7 +104,7 @@ test "cosh32" { try expect(math.approxEqAbs(f32, cosh32(-1.5), 2.352410, epsilon)); } -test "cosh64" { +test cosh64 { const epsilon = 0.000001; try expect(math.approxEqAbs(f64, cosh64(0.0), 1.0, epsilon)); diff --git a/lib/std/math/expm1.zig b/lib/std/math/expm1.zig index 81ffe16bd7..c64a123631 100644 --- a/lib/std/math/expm1.zig +++ b/lib/std/math/expm1.zig @@ -286,12 +286,12 @@ fn expm1_64(x_: f64) f64 { } } -test "exp1m" { +test expm1 { try expect(expm1(@as(f32, 0.0)) == expm1_32(0.0)); try expect(expm1(@as(f64, 0.0)) == expm1_64(0.0)); } -test "expm1_32" { +test expm1_32 { const epsilon = 0.000001; try expect(math.isPositiveZero(expm1_32(0.0))); @@ -301,7 +301,7 @@ test "expm1_32" { try expect(math.approxEqAbs(f32, expm1_32(1.5), 3.481689, epsilon)); } -test "expm1_64" { +test expm1_64 { const epsilon = 0.000001; try expect(math.isPositiveZero(expm1_64(0.0))); diff --git a/lib/std/math/float.zig b/lib/std/math/float.zig index bd510baefa..f8f04e217c 100644 --- a/lib/std/math/float.zig +++ b/lib/std/math/float.zig @@ -132,7 +132,7 @@ test "float bits" { } } -test "inf" { +test inf { const inf_u16: u16 = 0x7C00; const inf_u32: u32 = 0x7F800000; const inf_u64: u64 = 0x7FF0000000000000; @@ -145,7 +145,7 @@ test "inf" { try expectEqual(inf_u128, @as(u128, @bitCast(inf(f128)))); } -test "nan" { +test nan { const qnan_u16: u16 = 0x7E00; const qnan_u32: u32 = 0x7FC00000; const qnan_u64: u64 = 0x7FF8000000000000; @@ -158,7 +158,7 @@ test "nan" { try expectEqual(qnan_u128, @as(u128, @bitCast(nan(f128)))); } -test "snan" { +test snan { // TODO: https://github.com/ziglang/zig/issues/14366 if (builtin.zig_backend == .stage2_llvm and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest; diff --git a/lib/std/math/gamma.zig b/lib/std/math/gamma.zig index 15967f1afa..ce37db4962 100644 --- a/lib/std/math/gamma.zig +++ b/lib/std/math/gamma.zig @@ -240,7 +240,7 @@ const expect = std.testing.expect; const expectEqual = std.testing.expectEqual; const expectApproxEqRel = std.testing.expectApproxEqRel; -test "gamma" { +test gamma { inline for (&.{ f32, f64 }) |T| { const eps = @sqrt(std.math.floatEps(T)); try expectApproxEqRel(@as(T, 120), gamma(T, 6), eps); @@ -286,7 +286,7 @@ test "gamma.special" { } } -test "lgamma" { +test lgamma { inline for (&.{ f32, f64 }) |T| { const eps = @sqrt(std.math.floatEps(T)); try expectApproxEqRel(@as(T, @log(24.0)), lgamma(T, 5), eps); diff --git a/lib/std/math/hypot.zig b/lib/std/math/hypot.zig index 92e0c1eb13..c0bfabca1c 100644 --- a/lib/std/math/hypot.zig +++ b/lib/std/math/hypot.zig @@ -124,7 +124,7 @@ fn hypot64(x: f64, y: f64) f64 { return z * @sqrt(ly + lx + hy + hx); } -test "hypot" { +test hypot { const x32: f32 = 0.0; const y32: f32 = -1.2; const x64: f64 = 0.0; @@ -133,7 +133,7 @@ test "hypot" { try expect(hypot(x64, y64) == hypot64(0.0, -1.2)); } -test "hypot32" { +test hypot32 { const epsilon = 0.000001; try expect(math.approxEqAbs(f32, hypot32(0.0, -1.2), 1.2, epsilon)); @@ -145,7 +145,7 @@ test "hypot32" { try expect(math.approxEqAbs(f32, hypot32(123123.234375, 529428.707813), 543556.875, epsilon)); } -test "hypot64" { +test hypot64 { const epsilon = 0.000001; try expect(math.approxEqAbs(f64, hypot64(0.0, -1.2), 1.2, epsilon)); diff --git a/lib/std/math/log1p.zig b/lib/std/math/log1p.zig index 48a57366b7..2d7507bc88 100644 --- a/lib/std/math/log1p.zig +++ b/lib/std/math/log1p.zig @@ -182,12 +182,12 @@ fn log1p_64(x: f64) f64 { return s * (hfsq + R) + (dk * ln2_lo + c) - hfsq + f + dk * ln2_hi; } -test "log1p" { +test log1p { try expect(log1p(@as(f32, 0.0)) == log1p_32(0.0)); try expect(log1p(@as(f64, 0.0)) == log1p_64(0.0)); } -test "log1p_32" { +test log1p_32 { const epsilon = 0.000001; try expect(math.approxEqAbs(f32, log1p_32(0.0), 0.0, epsilon)); @@ -199,7 +199,7 @@ test "log1p_32" { try expect(math.approxEqAbs(f32, log1p_32(123123.234375), 11.720949, epsilon)); } -test "log1p_64" { +test log1p_64 { const epsilon = 0.000001; try expect(math.approxEqAbs(f64, log1p_64(0.0), 0.0, epsilon)); diff --git a/lib/std/math/log2.zig b/lib/std/math/log2.zig index 65fd9c296b..0902f3e10c 100644 --- a/lib/std/math/log2.zig +++ b/lib/std/math/log2.zig @@ -42,7 +42,7 @@ pub fn log2(x: anytype) @TypeOf(x) { } } -test "log2" { +test log2 { // https://github.com/ziglang/zig/issues/13703 if (builtin.cpu.arch == .aarch64 and builtin.os.tag == .windows) return error.SkipZigTest; diff --git a/lib/std/math/modf.zig b/lib/std/math/modf.zig index cb539136e4..03b8111873 100644 --- a/lib/std/math/modf.zig +++ b/lib/std/math/modf.zig @@ -123,14 +123,14 @@ fn modf64(x: f64) modf64_result { return result; } -test "modf" { +test modf { const a = modf(@as(f32, 1.0)); const b = modf32(1.0); // NOTE: No struct comparison on generic return type function? non-named, makes sense, but still. try expectEqual(a, b); } -test "modf32" { +test modf32 { const epsilon = 0.000001; var r: modf32_result = undefined; @@ -155,7 +155,7 @@ test "modf32" { try expect(math.approxEqAbs(f32, r.fpart, 0.340820, epsilon)); } -test "modf64" { +test modf64 { const epsilon = 0.000001; var r: modf64_result = undefined; diff --git a/lib/std/math/powi.zig b/lib/std/math/powi.zig index 85ed538d34..271d24352a 100644 --- a/lib/std/math/powi.zig +++ b/lib/std/math/powi.zig @@ -91,7 +91,7 @@ pub fn powi(comptime T: type, x: T, y: T) (error{ return acc; } -test "powi" { +test powi { try testing.expectError(error.Overflow, powi(i8, -66, 6)); try testing.expectError(error.Overflow, powi(i16, -13, 13)); try testing.expectError(error.Overflow, powi(i32, -32, 21)); diff --git a/lib/std/math/sinh.zig b/lib/std/math/sinh.zig index a5cb8bc2da..5652603d1a 100644 --- a/lib/std/math/sinh.zig +++ b/lib/std/math/sinh.zig @@ -91,12 +91,12 @@ fn sinh64(x: f64) f64 { return 2 * h * expo2(ax); } -test "sinh" { +test sinh { try expect(sinh(@as(f32, 1.5)) == sinh32(1.5)); try expect(sinh(@as(f64, 1.5)) == sinh64(1.5)); } -test "sinh32" { +test sinh32 { const epsilon = 0.000001; try expect(math.approxEqAbs(f32, sinh32(0.0), 0.0, epsilon)); @@ -109,7 +109,7 @@ test "sinh32" { try expect(math.approxEqAbs(f32, sinh32(-1.5), -2.129279, epsilon)); } -test "sinh64" { +test sinh64 { const epsilon = 0.000001; try expect(math.approxEqAbs(f64, sinh64(0.0), 0.0, epsilon)); diff --git a/lib/std/math/tanh.zig b/lib/std/math/tanh.zig index c32a60957b..dfe70f4b7a 100644 --- a/lib/std/math/tanh.zig +++ b/lib/std/math/tanh.zig @@ -104,12 +104,12 @@ fn tanh64(x: f64) f64 { return if (sign) -t else t; } -test "tanh" { +test tanh { try expect(tanh(@as(f32, 1.5)) == tanh32(1.5)); try expect(tanh(@as(f64, 1.5)) == tanh64(1.5)); } -test "tanh32" { +test tanh32 { const epsilon = 0.000001; try expect(math.approxEqAbs(f32, tanh32(0.0), 0.0, epsilon)); @@ -122,7 +122,7 @@ test "tanh32" { try expect(math.approxEqAbs(f32, tanh32(-37.45), -1.0, epsilon)); } -test "tanh64" { +test tanh64 { const epsilon = 0.000001; try expect(math.approxEqAbs(f64, tanh64(0.0), 0.0, epsilon)); diff --git a/lib/std/meta.zig b/lib/std/meta.zig index 80e9874782..66388aebf6 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -46,7 +46,7 @@ pub fn stringToEnum(comptime T: type, str: []const u8) ?T { } } -test "stringToEnum" { +test stringToEnum { const E1 = enum { A, B, @@ -73,7 +73,7 @@ pub fn alignment(comptime T: type) comptime_int { }; } -test "alignment" { +test alignment { try testing.expect(alignment(u8) == 1); try testing.expect(alignment(*align(1) u8) == 1); try testing.expect(alignment(*align(2) u8) == 2); @@ -94,7 +94,7 @@ pub fn Child(comptime T: type) type { }; } -test "Child" { +test Child { try testing.expect(Child([1]u8) == u8); try testing.expect(Child(*u8) == u8); try testing.expect(Child([]u8) == u8); @@ -121,7 +121,7 @@ pub fn Elem(comptime T: type) type { @compileError("Expected pointer, slice, array or vector type, found '" ++ @typeName(T) ++ "'"); } -test "Elem" { +test Elem { try testing.expect(Elem([1]u8) == u8); try testing.expect(Elem([*]u8) == u8); try testing.expect(Elem([]u8) == u8); @@ -255,7 +255,7 @@ pub fn containerLayout(comptime T: type) Type.ContainerLayout { }; } -test "containerLayout" { +test containerLayout { const S1 = struct {}; const S2 = packed struct {}; const S3 = extern struct {}; @@ -289,7 +289,7 @@ pub fn declarations(comptime T: type) []const Type.Declaration { }; } -test "declarations" { +test declarations { const E1 = enum { A, @@ -329,7 +329,7 @@ pub fn declarationInfo(comptime T: type, comptime decl_name: []const u8) Type.De @compileError("'" ++ @typeName(T) ++ "' has no declaration '" ++ decl_name ++ "'"); } -test "declarationInfo" { +test declarationInfo { const E1 = enum { A, @@ -370,7 +370,7 @@ pub fn fields(comptime T: type) switch (@typeInfo(T)) { }; } -test "fields" { +test fields { const E1 = enum { A, }; @@ -409,7 +409,7 @@ pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeIn return fields(T)[@intFromEnum(field)]; } -test "fieldInfo" { +test fieldInfo { const E1 = enum { A, }; @@ -442,7 +442,7 @@ pub fn FieldType(comptime T: type, comptime field: FieldEnum(T)) type { return fieldInfo(T, field).type; } -test "FieldType" { +test FieldType { const S = struct { a: u8, b: u16, @@ -470,7 +470,7 @@ pub fn fieldNames(comptime T: type) *const [fields(T).len][:0]const u8 { }; } -test "fieldNames" { +test fieldNames { const E1 = enum { A, B }; const E2 = error{A}; const S1 = struct { @@ -511,7 +511,7 @@ pub fn tags(comptime T: type) *const [fields(T).len]T { }; } -test "tags" { +test tags { const E1 = enum { A, B }; const E2 = error{A}; @@ -604,7 +604,7 @@ fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void { ); } -test "FieldEnum" { +test FieldEnum { try expectEqualEnum(enum {}, FieldEnum(struct {})); try expectEqualEnum(enum { a }, FieldEnum(struct { a: u8 })); try expectEqualEnum(enum { a, b, c }, FieldEnum(struct { a: u8, b: void, c: f32 })); @@ -639,7 +639,7 @@ pub fn DeclEnum(comptime T: type) type { }); } -test "DeclEnum" { +test DeclEnum { const A = struct { pub const a: u8 = 0; }; @@ -670,7 +670,7 @@ pub fn Tag(comptime T: type) type { }; } -test "Tag" { +test Tag { const E = enum(u8) { C = 33, D, @@ -690,7 +690,7 @@ pub fn activeTag(u: anytype) Tag(@TypeOf(u)) { return @as(Tag(T), u); } -test "activeTag" { +test activeTag { const UE = enum { Int, Float, @@ -727,7 +727,7 @@ pub fn TagPayload(comptime U: type, comptime tag: Tag(U)) type { return TagPayloadByName(U, @tagName(tag)); } -test "TagPayload" { +test TagPayload { const Event = union(enum) { Moved: struct { from: i32, @@ -802,7 +802,7 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool { } } -test "eql" { +test eql { const S = struct { a: u32, b: f64, @@ -863,7 +863,7 @@ test "eql" { try testing.expect(!eql(v1, v3)); } -test "intToEnum with error return" { +test intToEnum { const E1 = enum { A, }; @@ -965,7 +965,7 @@ pub fn Float(comptime bit_count: u8) type { }); } -test "Float" { +test Float { try testing.expectEqual(f16, Float(16)); try testing.expectEqual(f32, Float(32)); try testing.expectEqual(f64, Float(64)); @@ -1057,7 +1057,7 @@ const TupleTester = struct { } }; -test "ArgsTuple" { +test ArgsTuple { TupleTester.assertTuple(.{}, ArgsTuple(fn () void)); TupleTester.assertTuple(.{u32}, ArgsTuple(fn (a: u32) []const u8)); TupleTester.assertTuple(.{ u32, f16 }, ArgsTuple(fn (a: u32, b: f16) noreturn)); @@ -1065,7 +1065,7 @@ test "ArgsTuple" { TupleTester.assertTuple(.{u32}, ArgsTuple(fn (comptime a: u32) []const u8)); } -test "Tuple" { +test Tuple { TupleTester.assertTuple(.{}, Tuple(&[_]type{})); TupleTester.assertTuple(.{u32}, Tuple(&[_]type{u32})); TupleTester.assertTuple(.{ u32, f16 }, Tuple(&[_]type{ u32, f16 })); @@ -1103,7 +1103,7 @@ pub fn isError(error_union: anytype) bool { return if (error_union) |_| false else |_| true; } -test "isError" { +test isError { try std.testing.expect(isError(math.divTrunc(u8, 5, 0))); try std.testing.expect(!isError(math.divTrunc(u8, 5, 5))); } @@ -1121,7 +1121,7 @@ pub inline fn hasFn(comptime T: type, comptime name: []const u8) bool { return @typeInfo(@TypeOf(@field(T, name))) == .Fn; } -test "hasFn" { +test hasFn { const S1 = struct { pub fn foo() void {} }; @@ -1149,7 +1149,7 @@ pub inline fn hasMethod(comptime T: type, comptime name: []const u8) bool { }; } -test "hasMethod" { +test hasMethod { try std.testing.expect(!hasMethod(u32, "foo")); try std.testing.expect(!hasMethod([]u32, "len")); try std.testing.expect(!hasMethod(struct { u32, u64 }, "len")); @@ -1218,7 +1218,7 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool { }; } -test "hasUniqueRepresentation" { +test hasUniqueRepresentation { const TestStruct1 = struct { a: u32, b: u32,