| author | |
| committer | |
| log | 726a1149e05669e5cc05a16ce877bbb2be787e39 |
| tree | 0f5ae1dd819410e2b88def157161141fd79c8b6a |
| parent | 16b3d1004ee520341839305826fe065eb5d8c818 |
51 files changed, 143 insertions(+), 145 deletions(-)
lib/std/Random/Isaac64.zig+1-1| ... | @@ -201,7 +201,7 @@ test "sequence" { | ... | @@ -201,7 +201,7 @@ test "sequence" { |
| 201 | } | 201 | } |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | test "fill" { | 204 | test fill { |
| 205 | var r = Isaac64.init(0); | 205 | var r = Isaac64.init(0); |
| 206 | 206 | ||
| 207 | // from reference implementation | 207 | // from reference implementation |
lib/std/Random/Pcg.zig+1-1| ... | @@ -92,7 +92,7 @@ test "sequence" { | ... | @@ -92,7 +92,7 @@ test "sequence" { |
| 92 | } | 92 | } |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | test "fill" { | 95 | test fill { |
| 96 | var r = Pcg.init(0); | 96 | var r = Pcg.init(0); |
| 97 | const s0: u64 = 0x9394bf54ce5d79de; | 97 | const s0: u64 = 0x9394bf54ce5d79de; |
| 98 | const s1: u64 = 0x84e9c579ef59bbf7; | 98 | const s1: u64 = 0x84e9c579ef59bbf7; |
lib/std/Random/RomuTrio.zig+1-1| ... | @@ -94,7 +94,7 @@ test "sequence" { | ... | @@ -94,7 +94,7 @@ test "sequence" { |
| 94 | } | 94 | } |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | test "fill" { | 97 | test fill { |
| 98 | // Unfortunately there does not seem to be an official test sequence. | 98 | // Unfortunately there does not seem to be an official test sequence. |
| 99 | var r = RomuTrio.init(0); | 99 | var r = RomuTrio.init(0); |
| 100 | 100 |
lib/std/Random/Sfc64.zig+1-1| ... | @@ -98,7 +98,7 @@ test "sequence" { | ... | @@ -98,7 +98,7 @@ test "sequence" { |
| 98 | } | 98 | } |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | test "fill" { | 101 | test fill { |
| 102 | // Unfortunately there does not seem to be an official test sequence. | 102 | // Unfortunately there does not seem to be an official test sequence. |
| 103 | var r = Sfc64.init(0); | 103 | var r = Sfc64.init(0); |
| 104 | 104 |
lib/std/Random/Xoroshiro128.zig+1-1| ... | @@ -122,7 +122,7 @@ test "sequence" { | ... | @@ -122,7 +122,7 @@ test "sequence" { |
| 122 | } | 122 | } |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | test "fill" { | 125 | test fill { |
| 126 | var r = Xoroshiro128.init(0); | 126 | var r = Xoroshiro128.init(0); |
| 127 | r.s[0] = 0xaeecf86f7878dd75; | 127 | r.s[0] = 0xaeecf86f7878dd75; |
| 128 | r.s[1] = 0x01cd153642e72622; | 128 | r.s[1] = 0x01cd153642e72622; |
lib/std/Random/Xoshiro256.zig+1-1| ... | @@ -122,7 +122,7 @@ test "sequence" { | ... | @@ -122,7 +122,7 @@ test "sequence" { |
| 122 | } | 122 | } |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | test "fill" { | 125 | test fill { |
| 126 | var r = Xoshiro256.init(0); | 126 | var r = Xoshiro256.init(0); |
| 127 | 127 | ||
| 128 | const seq = [_]u64{ | 128 | const seq = [_]u64{ |
lib/std/SemanticVersion.zig+1-1| ... | @@ -166,7 +166,7 @@ pub fn format( | ... | @@ -166,7 +166,7 @@ pub fn format( |
| 166 | const expect = std.testing.expect; | 166 | const expect = std.testing.expect; |
| 167 | const expectError = std.testing.expectError; | 167 | const expectError = std.testing.expectError; |
| 168 | 168 | ||
| 169 | test "format" { | 169 | test format { |
| 170 | // Many of these test strings are from https://github.com/semver/semver.org/issues/59#issuecomment-390854010. | 170 | // Many of these test strings are from https://github.com/semver/semver.org/issues/59#issuecomment-390854010. |
| 171 | 171 | ||
| 172 | // Valid version strings should be accepted. | 172 | // Valid version strings should be accepted. |
lib/std/Thread.zig+2-2| ... | @@ -1437,7 +1437,7 @@ fn testIncrementNotify(value: *usize, event: *ResetEvent) void { | ... | @@ -1437,7 +1437,7 @@ fn testIncrementNotify(value: *usize, event: *ResetEvent) void { |
| 1437 | event.set(); | 1437 | event.set(); |
| 1438 | } | 1438 | } |
| 1439 | 1439 | ||
| 1440 | test "join" { | 1440 | test join { |
| 1441 | if (builtin.single_threaded) return error.SkipZigTest; | 1441 | if (builtin.single_threaded) return error.SkipZigTest; |
| 1442 | 1442 | ||
| 1443 | var value: usize = 0; | 1443 | var value: usize = 0; |
| ... | @@ -1449,7 +1449,7 @@ test "join" { | ... | @@ -1449,7 +1449,7 @@ test "join" { |
| 1449 | try std.testing.expectEqual(value, 1); | 1449 | try std.testing.expectEqual(value, 1); |
| 1450 | } | 1450 | } |
| 1451 | 1451 | ||
| 1452 | test "detach" { | 1452 | test detach { |
| 1453 | if (builtin.single_threaded) return error.SkipZigTest; | 1453 | if (builtin.single_threaded) return error.SkipZigTest; |
| 1454 | 1454 | ||
| 1455 | var value: usize = 0; | 1455 | var value: usize = 0; |
lib/std/Thread/Condition.zig+2-2| ... | @@ -362,7 +362,7 @@ test "wait and signal" { | ... | @@ -362,7 +362,7 @@ test "wait and signal" { |
| 362 | } | 362 | } |
| 363 | } | 363 | } |
| 364 | 364 | ||
| 365 | test "signal" { | 365 | test signal { |
| 366 | // This test requires spawning threads | 366 | // This test requires spawning threads |
| 367 | if (builtin.single_threaded) { | 367 | if (builtin.single_threaded) { |
| 368 | return error.SkipZigTest; | 368 | return error.SkipZigTest; |
| ... | @@ -491,7 +491,7 @@ test "multi signal" { | ... | @@ -491,7 +491,7 @@ test "multi signal" { |
| 491 | } | 491 | } |
| 492 | } | 492 | } |
| 493 | 493 | ||
| 494 | test "broadcasting" { | 494 | test broadcast { |
| 495 | // This test requires spawning threads | 495 | // This test requires spawning threads |
| 496 | if (builtin.single_threaded) { | 496 | if (builtin.single_threaded) { |
| 497 | return error.SkipZigTest; | 497 | return error.SkipZigTest; |
lib/std/Thread/Semaphore.zig+2-2| ... | @@ -71,7 +71,7 @@ pub fn post(sem: *Semaphore) void { | ... | @@ -71,7 +71,7 @@ pub fn post(sem: *Semaphore) void { |
| 71 | sem.cond.signal(); | 71 | sem.cond.signal(); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | test "Semaphore" { | 74 | test Semaphore { |
| 75 | if (builtin.single_threaded) { | 75 | if (builtin.single_threaded) { |
| 76 | return error.SkipZigTest; | 76 | return error.SkipZigTest; |
| 77 | } | 77 | } |
| ... | @@ -97,7 +97,7 @@ test "Semaphore" { | ... | @@ -97,7 +97,7 @@ test "Semaphore" { |
| 97 | try testing.expect(n == num_threads); | 97 | try testing.expect(n == num_threads); |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | test "timedWait" { | 100 | test timedWait { |
| 101 | var sem = Semaphore{}; | 101 | var sem = Semaphore{}; |
| 102 | try testing.expectEqual(0, sem.permits); | 102 | try testing.expectEqual(0, sem.permits); |
| 103 | 103 |
lib/std/buf_set.zig+17-17| ... | @@ -90,6 +90,23 @@ pub const BufSet = struct { | ... | @@ -90,6 +90,23 @@ pub const BufSet = struct { |
| 90 | return self.cloneWithAllocator(self.allocator()); | 90 | return self.cloneWithAllocator(self.allocator()); |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | test clone { | ||
| 94 | var original = BufSet.init(testing.allocator); | ||
| 95 | defer original.deinit(); | ||
| 96 | try original.insert("x"); | ||
| 97 | |||
| 98 | var cloned = try original.clone(); | ||
| 99 | defer cloned.deinit(); | ||
| 100 | cloned.remove("x"); | ||
| 101 | try testing.expect(original.count() == 1); | ||
| 102 | try testing.expect(cloned.count() == 0); | ||
| 103 | |||
| 104 | try testing.expectError( | ||
| 105 | error.OutOfMemory, | ||
| 106 | original.cloneWithAllocator(testing.failing_allocator), | ||
| 107 | ); | ||
| 108 | } | ||
| 109 | |||
| 93 | fn free(self: *const BufSet, value: []const u8) void { | 110 | fn free(self: *const BufSet, value: []const u8) void { |
| 94 | self.hash_map.allocator.free(value); | 111 | self.hash_map.allocator.free(value); |
| 95 | } | 112 | } |
| ... | @@ -115,23 +132,6 @@ test BufSet { | ... | @@ -115,23 +132,6 @@ test BufSet { |
| 115 | try bufset.insert("z"); | 132 | try bufset.insert("z"); |
| 116 | } | 133 | } |
| 117 | 134 | ||
| 118 | test "clone" { | ||
| 119 | var original = BufSet.init(testing.allocator); | ||
| 120 | defer original.deinit(); | ||
| 121 | try original.insert("x"); | ||
| 122 | |||
| 123 | var cloned = try original.clone(); | ||
| 124 | defer cloned.deinit(); | ||
| 125 | cloned.remove("x"); | ||
| 126 | try testing.expect(original.count() == 1); | ||
| 127 | try testing.expect(cloned.count() == 0); | ||
| 128 | |||
| 129 | try testing.expectError( | ||
| 130 | error.OutOfMemory, | ||
| 131 | original.cloneWithAllocator(testing.failing_allocator), | ||
| 132 | ); | ||
| 133 | } | ||
| 134 | |||
| 135 | test "clone with arena" { | 135 | test "clone with arena" { |
| 136 | const allocator = std.testing.allocator; | 136 | const allocator = std.testing.allocator; |
| 137 | var arena = std.heap.ArenaAllocator.init(allocator); | 137 | var arena = std.heap.ArenaAllocator.init(allocator); |
lib/std/compress/flate/CircularBuffer.zig+3-3| ... | @@ -130,7 +130,7 @@ pub fn full(self: *Self) bool { | ... | @@ -130,7 +130,7 @@ pub fn full(self: *Self) bool { |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | // example from: https://youtu.be/SJPvNi4HrWQ?t=3558 | 132 | // example from: https://youtu.be/SJPvNi4HrWQ?t=3558 |
| 133 | test "writeMatch" { | 133 | test writeMatch { |
| 134 | var cb: Self = .{}; | 134 | var cb: Self = .{}; |
| 135 | 135 | ||
| 136 | cb.writeAll("a salad; "); | 136 | cb.writeAll("a salad; "); |
| ... | @@ -150,7 +150,7 @@ test "writeMatch overlap" { | ... | @@ -150,7 +150,7 @@ test "writeMatch overlap" { |
| 150 | try testing.expectEqualStrings("a b c b c b c d", cb.read()); | 150 | try testing.expectEqualStrings("a b c b c b c d", cb.read()); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | test "readAtMost" { | 153 | test readAtMost { |
| 154 | var cb: Self = .{}; | 154 | var cb: Self = .{}; |
| 155 | 155 | ||
| 156 | cb.writeAll("0123456789"); | 156 | cb.writeAll("0123456789"); |
| ... | @@ -165,7 +165,7 @@ test "readAtMost" { | ... | @@ -165,7 +165,7 @@ test "readAtMost" { |
| 165 | try testing.expectEqualStrings("", cb.read()); | 165 | try testing.expectEqualStrings("", cb.read()); |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | test "CircularBuffer" { | 168 | test Self { |
| 169 | var cb: Self = .{}; | 169 | var cb: Self = .{}; |
| 170 | 170 | ||
| 171 | const data = "0123456789abcdef" ** (1024 / 16); | 171 | const data = "0123456789abcdef" ** (1024 / 16); |
lib/std/compress/flate/Lookup.zig+2-2| ... | @@ -83,7 +83,7 @@ fn hashu(v: u32) u32 { | ... | @@ -83,7 +83,7 @@ fn hashu(v: u32) u32 { |
| 83 | return @intCast((v *% prime4) >> consts.lookup.shift); | 83 | return @intCast((v *% prime4) >> consts.lookup.shift); |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | test "add/prev" { | 86 | test add { |
| 87 | const data = [_]u8{ | 87 | const data = [_]u8{ |
| 88 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, | 88 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
| 89 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, | 89 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
| ... | @@ -107,7 +107,7 @@ test "add/prev" { | ... | @@ -107,7 +107,7 @@ test "add/prev" { |
| 107 | try expect(h.chain[2 + 8] == 2); | 107 | try expect(h.chain[2 + 8] == 2); |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | test "bulkAdd" { | 110 | test bulkAdd { |
| 111 | const data = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."; | 111 | const data = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."; |
| 112 | 112 | ||
| 113 | // one by one | 113 | // one by one |
lib/std/compress/flate/SlidingWindow.zig+2-2| ... | @@ -122,7 +122,7 @@ pub fn tokensBuffer(self: *Self) ?[]const u8 { | ... | @@ -122,7 +122,7 @@ pub fn tokensBuffer(self: *Self) ?[]const u8 { |
| 122 | return self.buffer[@intCast(self.fp)..self.rp]; | 122 | return self.buffer[@intCast(self.fp)..self.rp]; |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | test "match" { | 125 | test match { |
| 126 | const data = "Blah blah blah blah blah!"; | 126 | const data = "Blah blah blah blah blah!"; |
| 127 | var win: Self = .{}; | 127 | var win: Self = .{}; |
| 128 | try expect(win.write(data) == data.len); | 128 | try expect(win.write(data) == data.len); |
| ... | @@ -142,7 +142,7 @@ test "match" { | ... | @@ -142,7 +142,7 @@ test "match" { |
| 142 | try expect(win.match(15, 20, 4) == 0); | 142 | try expect(win.match(15, 20, 4) == 0); |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | test "slide" { | 145 | test slide { |
| 146 | var win: Self = .{}; | 146 | var win: Self = .{}; |
| 147 | win.wp = Self.buffer_len - 11; | 147 | win.wp = Self.buffer_len - 11; |
| 148 | win.rp = Self.buffer_len - 111; | 148 | win.rp = Self.buffer_len - 111; |
lib/std/compress/flate/huffman_encoder.zig+1-1| ... | @@ -458,7 +458,7 @@ fn bitReverse(comptime T: type, value: T, n: usize) T { | ... | @@ -458,7 +458,7 @@ fn bitReverse(comptime T: type, value: T, n: usize) T { |
| 458 | return r >> @as(math.Log2Int(T), @intCast(@typeInfo(T).Int.bits - n)); | 458 | return r >> @as(math.Log2Int(T), @intCast(@typeInfo(T).Int.bits - n)); |
| 459 | } | 459 | } |
| 460 | 460 | ||
| 461 | test "bitReverse" { | 461 | test bitReverse { |
| 462 | const ReverseBitsTest = struct { | 462 | const ReverseBitsTest = struct { |
| 463 | in: u16, | 463 | in: u16, |
| 464 | bit_count: u5, | 464 | bit_count: u5, |
lib/std/enums.zig+6-6| ... | @@ -120,7 +120,7 @@ pub fn directEnumArray( | ... | @@ -120,7 +120,7 @@ pub fn directEnumArray( |
| 120 | return directEnumArrayDefault(E, Data, null, max_unused_slots, init_values); | 120 | return directEnumArrayDefault(E, Data, null, max_unused_slots, init_values); |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | test "directEnumArray" { | 123 | test directEnumArray { |
| 124 | const E = enum(i4) { a = 4, b = 6, c = 2 }; | 124 | const E = enum(i4) { a = 4, b = 6, c = 2 }; |
| 125 | var runtime_false: bool = false; | 125 | var runtime_false: bool = false; |
| 126 | _ = &runtime_false; | 126 | _ = &runtime_false; |
| ... | @@ -163,7 +163,7 @@ pub fn directEnumArrayDefault( | ... | @@ -163,7 +163,7 @@ pub fn directEnumArrayDefault( |
| 163 | return result; | 163 | return result; |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | test "directEnumArrayDefault" { | 166 | test directEnumArrayDefault { |
| 167 | const E = enum(i4) { a = 4, b = 6, c = 2 }; | 167 | const E = enum(i4) { a = 4, b = 6, c = 2 }; |
| 168 | var runtime_false: bool = false; | 168 | var runtime_false: bool = false; |
| 169 | _ = &runtime_false; | 169 | _ = &runtime_false; |
| ... | @@ -214,7 +214,7 @@ pub fn nameCast(comptime E: type, comptime value: anytype) E { | ... | @@ -214,7 +214,7 @@ pub fn nameCast(comptime E: type, comptime value: anytype) E { |
| 214 | }; | 214 | }; |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | test "nameCast" { | 217 | test nameCast { |
| 218 | const A = enum(u1) { a = 0, b = 1 }; | 218 | const A = enum(u1) { a = 0, b = 1 }; |
| 219 | const B = enum(u1) { a = 1, b = 0 }; | 219 | const B = enum(u1) { a = 1, b = 0 }; |
| 220 | try testing.expectEqual(A.a, nameCast(A, .a)); | 220 | try testing.expectEqual(A.a, nameCast(A, .a)); |
| ... | @@ -515,7 +515,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { | ... | @@ -515,7 +515,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { |
| 515 | }; | 515 | }; |
| 516 | } | 516 | } |
| 517 | 517 | ||
| 518 | test "EnumMultiset" { | 518 | test EnumMultiset { |
| 519 | const Ball = enum { red, green, blue }; | 519 | const Ball = enum { red, green, blue }; |
| 520 | 520 | ||
| 521 | const empty = EnumMultiset(Ball).initEmpty(); | 521 | const empty = EnumMultiset(Ball).initEmpty(); |
| ... | @@ -1298,7 +1298,7 @@ pub fn ensureIndexer(comptime T: type) void { | ... | @@ -1298,7 +1298,7 @@ pub fn ensureIndexer(comptime T: type) void { |
| 1298 | } | 1298 | } |
| 1299 | } | 1299 | } |
| 1300 | 1300 | ||
| 1301 | test "ensureIndexer" { | 1301 | test ensureIndexer { |
| 1302 | ensureIndexer(struct { | 1302 | ensureIndexer(struct { |
| 1303 | pub const Key = u32; | 1303 | pub const Key = u32; |
| 1304 | pub const count: comptime_int = 8; | 1304 | pub const count: comptime_int = 8; |
| ... | @@ -1535,7 +1535,7 @@ test "EnumIndexer empty" { | ... | @@ -1535,7 +1535,7 @@ test "EnumIndexer empty" { |
| 1535 | try testing.expectEqual(0, Indexer.count); | 1535 | try testing.expectEqual(0, Indexer.count); |
| 1536 | } | 1536 | } |
| 1537 | 1537 | ||
| 1538 | test "enumValues" { | 1538 | test values { |
| 1539 | const E = enum { | 1539 | const E = enum { |
| 1540 | X, | 1540 | X, |
| 1541 | Y, | 1541 | Y, |
lib/std/math/acos.zig+3-3| ... | @@ -148,12 +148,12 @@ fn acos64(x: f64) f64 { | ... | @@ -148,12 +148,12 @@ fn acos64(x: f64) f64 { |
| 148 | return 2 * (df + w); | 148 | return 2 * (df + w); |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | test "acos" { | 151 | test acos { |
| 152 | try expect(acos(@as(f32, 0.0)) == acos32(0.0)); | 152 | try expect(acos(@as(f32, 0.0)) == acos32(0.0)); |
| 153 | try expect(acos(@as(f64, 0.0)) == acos64(0.0)); | 153 | try expect(acos(@as(f64, 0.0)) == acos64(0.0)); |
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | test "acos32" { | 156 | test acos32 { |
| 157 | const epsilon = 0.000001; | 157 | const epsilon = 0.000001; |
| 158 | 158 | ||
| 159 | try expect(math.approxEqAbs(f32, acos32(0.0), 1.570796, epsilon)); | 159 | try expect(math.approxEqAbs(f32, acos32(0.0), 1.570796, epsilon)); |
| ... | @@ -164,7 +164,7 @@ test "acos32" { | ... | @@ -164,7 +164,7 @@ test "acos32" { |
| 164 | try expect(math.approxEqAbs(f32, acos32(-0.2), 1.772154, epsilon)); | 164 | try expect(math.approxEqAbs(f32, acos32(-0.2), 1.772154, epsilon)); |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | test "acos64" { | 167 | test acos64 { |
| 168 | const epsilon = 0.000001; | 168 | const epsilon = 0.000001; |
| 169 | 169 | ||
| 170 | try expect(math.approxEqAbs(f64, acos64(0.0), 1.570796, epsilon)); | 170 | try expect(math.approxEqAbs(f64, acos64(0.0), 1.570796, epsilon)); |
lib/std/math/acosh.zig+3-3| ... | @@ -59,12 +59,12 @@ fn acosh64(x: f64) f64 { | ... | @@ -59,12 +59,12 @@ fn acosh64(x: f64) f64 { |
| 59 | } | 59 | } |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | test "acosh" { | 62 | test acosh { |
| 63 | try expect(acosh(@as(f32, 1.5)) == acosh32(1.5)); | 63 | try expect(acosh(@as(f32, 1.5)) == acosh32(1.5)); |
| 64 | try expect(acosh(@as(f64, 1.5)) == acosh64(1.5)); | 64 | try expect(acosh(@as(f64, 1.5)) == acosh64(1.5)); |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | test "acosh32" { | 67 | test acosh32 { |
| 68 | const epsilon = 0.000001; | 68 | const epsilon = 0.000001; |
| 69 | 69 | ||
| 70 | try expect(math.approxEqAbs(f32, acosh32(1.5), 0.962424, epsilon)); | 70 | try expect(math.approxEqAbs(f32, acosh32(1.5), 0.962424, epsilon)); |
| ... | @@ -73,7 +73,7 @@ test "acosh32" { | ... | @@ -73,7 +73,7 @@ test "acosh32" { |
| 73 | try expect(math.approxEqAbs(f32, acosh32(123123.234375), 12.414088, epsilon)); | 73 | try expect(math.approxEqAbs(f32, acosh32(123123.234375), 12.414088, epsilon)); |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | test "acosh64" { | 76 | test acosh64 { |
| 77 | const epsilon = 0.000001; | 77 | const epsilon = 0.000001; |
| 78 | 78 | ||
| 79 | try expect(math.approxEqAbs(f64, acosh64(1.5), 0.962424, epsilon)); | 79 | try expect(math.approxEqAbs(f64, acosh64(1.5), 0.962424, epsilon)); |
lib/std/math/asin.zig+3-3| ... | @@ -141,12 +141,12 @@ fn asin64(x: f64) f64 { | ... | @@ -141,12 +141,12 @@ fn asin64(x: f64) f64 { |
| 141 | } | 141 | } |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | test "asin" { | 144 | test asin { |
| 145 | try expect(asin(@as(f32, 0.0)) == asin32(0.0)); | 145 | try expect(asin(@as(f32, 0.0)) == asin32(0.0)); |
| 146 | try expect(asin(@as(f64, 0.0)) == asin64(0.0)); | 146 | try expect(asin(@as(f64, 0.0)) == asin64(0.0)); |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | test "asin32" { | 149 | test asin32 { |
| 150 | const epsilon = 0.000001; | 150 | const epsilon = 0.000001; |
| 151 | 151 | ||
| 152 | try expect(math.approxEqAbs(f32, asin32(0.0), 0.0, epsilon)); | 152 | try expect(math.approxEqAbs(f32, asin32(0.0), 0.0, epsilon)); |
| ... | @@ -157,7 +157,7 @@ test "asin32" { | ... | @@ -157,7 +157,7 @@ test "asin32" { |
| 157 | try expect(math.approxEqAbs(f32, asin32(0.8923), 1.102415, epsilon)); | 157 | try expect(math.approxEqAbs(f32, asin32(0.8923), 1.102415, epsilon)); |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | test "asin64" { | 160 | test asin64 { |
| 161 | const epsilon = 0.000001; | 161 | const epsilon = 0.000001; |
| 162 | 162 | ||
| 163 | try expect(math.approxEqAbs(f64, asin64(0.0), 0.0, epsilon)); | 163 | try expect(math.approxEqAbs(f64, asin64(0.0), 0.0, epsilon)); |
lib/std/math/asinh.zig+3-3| ... | @@ -80,12 +80,12 @@ fn asinh64(x: f64) f64 { | ... | @@ -80,12 +80,12 @@ fn asinh64(x: f64) f64 { |
| 80 | return if (s != 0) -rx else rx; | 80 | return if (s != 0) -rx else rx; |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | test "asinh" { | 83 | test asinh { |
| 84 | try expect(asinh(@as(f32, 0.0)) == asinh32(0.0)); | 84 | try expect(asinh(@as(f32, 0.0)) == asinh32(0.0)); |
| 85 | try expect(asinh(@as(f64, 0.0)) == asinh64(0.0)); | 85 | try expect(asinh(@as(f64, 0.0)) == asinh64(0.0)); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | test "asinh32" { | 88 | test asinh32 { |
| 89 | const epsilon = 0.000001; | 89 | const epsilon = 0.000001; |
| 90 | 90 | ||
| 91 | try expect(math.approxEqAbs(f32, asinh32(0.0), 0.0, epsilon)); | 91 | try expect(math.approxEqAbs(f32, asinh32(0.0), 0.0, epsilon)); |
| ... | @@ -98,7 +98,7 @@ test "asinh32" { | ... | @@ -98,7 +98,7 @@ test "asinh32" { |
| 98 | try expect(math.approxEqAbs(f32, asinh32(123123.234375), 12.414088, epsilon)); | 98 | try expect(math.approxEqAbs(f32, asinh32(123123.234375), 12.414088, epsilon)); |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | test "asinh64" { | 101 | test asinh64 { |
| 102 | const epsilon = 0.000001; | 102 | const epsilon = 0.000001; |
| 103 | 103 | ||
| 104 | try expect(math.approxEqAbs(f64, asinh64(0.0), 0.0, epsilon)); | 104 | try expect(math.approxEqAbs(f64, asinh64(0.0), 0.0, epsilon)); |
lib/std/math/atan.zig+3-3| ... | @@ -212,12 +212,12 @@ fn atan64(x_: f64) f64 { | ... | @@ -212,12 +212,12 @@ fn atan64(x_: f64) f64 { |
| 212 | } | 212 | } |
| 213 | } | 213 | } |
| 214 | 214 | ||
| 215 | test "atan" { | 215 | test atan { |
| 216 | try expect(@as(u32, @bitCast(atan(@as(f32, 0.2)))) == @as(u32, @bitCast(atan32(0.2)))); | 216 | try expect(@as(u32, @bitCast(atan(@as(f32, 0.2)))) == @as(u32, @bitCast(atan32(0.2)))); |
| 217 | try expect(atan(@as(f64, 0.2)) == atan64(0.2)); | 217 | try expect(atan(@as(f64, 0.2)) == atan64(0.2)); |
| 218 | } | 218 | } |
| 219 | 219 | ||
| 220 | test "atan32" { | 220 | test atan32 { |
| 221 | const epsilon = 0.000001; | 221 | const epsilon = 0.000001; |
| 222 | 222 | ||
| 223 | try expect(math.approxEqAbs(f32, atan32(0.2), 0.197396, epsilon)); | 223 | try expect(math.approxEqAbs(f32, atan32(0.2), 0.197396, epsilon)); |
| ... | @@ -227,7 +227,7 @@ test "atan32" { | ... | @@ -227,7 +227,7 @@ test "atan32" { |
| 227 | try expect(math.approxEqAbs(f32, atan32(1.5), 0.982794, epsilon)); | 227 | try expect(math.approxEqAbs(f32, atan32(1.5), 0.982794, epsilon)); |
| 228 | } | 228 | } |
| 229 | 229 | ||
| 230 | test "atan64" { | 230 | test atan64 { |
| 231 | const epsilon = 0.000001; | 231 | const epsilon = 0.000001; |
| 232 | 232 | ||
| 233 | try expect(math.approxEqAbs(f64, atan64(0.2), 0.197396, epsilon)); | 233 | try expect(math.approxEqAbs(f64, atan64(0.2), 0.197396, epsilon)); |
lib/std/math/atan2.zig+3-3| ... | @@ -214,7 +214,7 @@ fn atan2_64(y: f64, x: f64) f64 { | ... | @@ -214,7 +214,7 @@ fn atan2_64(y: f64, x: f64) f64 { |
| 214 | } | 214 | } |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | test "atan2" { | 217 | test atan2 { |
| 218 | const y32: f32 = 0.2; | 218 | const y32: f32 = 0.2; |
| 219 | const x32: f32 = 0.21; | 219 | const x32: f32 = 0.21; |
| 220 | const y64: f64 = 0.2; | 220 | const y64: f64 = 0.2; |
| ... | @@ -223,7 +223,7 @@ test "atan2" { | ... | @@ -223,7 +223,7 @@ test "atan2" { |
| 223 | try expect(atan2(y64, x64) == atan2_64(0.2, 0.21)); | 223 | try expect(atan2(y64, x64) == atan2_64(0.2, 0.21)); |
| 224 | } | 224 | } |
| 225 | 225 | ||
| 226 | test "atan2_32" { | 226 | test atan2_32 { |
| 227 | const epsilon = 0.000001; | 227 | const epsilon = 0.000001; |
| 228 | 228 | ||
| 229 | try expect(math.approxEqAbs(f32, atan2_32(0.0, 0.0), 0.0, epsilon)); | 229 | try expect(math.approxEqAbs(f32, atan2_32(0.0, 0.0), 0.0, epsilon)); |
| ... | @@ -235,7 +235,7 @@ test "atan2_32" { | ... | @@ -235,7 +235,7 @@ test "atan2_32" { |
| 235 | try expect(math.approxEqAbs(f32, atan2_32(0.34, 1.243), 0.267001, epsilon)); | 235 | try expect(math.approxEqAbs(f32, atan2_32(0.34, 1.243), 0.267001, epsilon)); |
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | test "atan2_64" { | 238 | test atan2_64 { |
| 239 | const epsilon = 0.000001; | 239 | const epsilon = 0.000001; |
| 240 | 240 | ||
| 241 | try expect(math.approxEqAbs(f64, atan2_64(0.0, 0.0), 0.0, epsilon)); | 241 | try expect(math.approxEqAbs(f64, atan2_64(0.0, 0.0), 0.0, epsilon)); |
lib/std/math/atanh.zig+3-3| ... | @@ -84,12 +84,12 @@ fn atanh_64(x: f64) f64 { | ... | @@ -84,12 +84,12 @@ fn atanh_64(x: f64) f64 { |
| 84 | return if (s != 0) -y else y; | 84 | return if (s != 0) -y else y; |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | test "atanh" { | 87 | test atanh { |
| 88 | try expect(atanh(@as(f32, 0.0)) == atanh_32(0.0)); | 88 | try expect(atanh(@as(f32, 0.0)) == atanh_32(0.0)); |
| 89 | try expect(atanh(@as(f64, 0.0)) == atanh_64(0.0)); | 89 | try expect(atanh(@as(f64, 0.0)) == atanh_64(0.0)); |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | test "atanh_32" { | 92 | test atanh_32 { |
| 93 | const epsilon = 0.000001; | 93 | const epsilon = 0.000001; |
| 94 | 94 | ||
| 95 | try expect(math.approxEqAbs(f32, atanh_32(0.0), 0.0, epsilon)); | 95 | try expect(math.approxEqAbs(f32, atanh_32(0.0), 0.0, epsilon)); |
| ... | @@ -97,7 +97,7 @@ test "atanh_32" { | ... | @@ -97,7 +97,7 @@ test "atanh_32" { |
| 97 | try expect(math.approxEqAbs(f32, atanh_32(0.8923), 1.433099, epsilon)); | 97 | try expect(math.approxEqAbs(f32, atanh_32(0.8923), 1.433099, epsilon)); |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | test "atanh_64" { | 100 | test atanh_64 { |
| 101 | const epsilon = 0.000001; | 101 | const epsilon = 0.000001; |
| 102 | 102 | ||
| 103 | try expect(math.approxEqAbs(f64, atanh_64(0.0), 0.0, epsilon)); | 103 | try expect(math.approxEqAbs(f64, atanh_64(0.0), 0.0, epsilon)); |
lib/std/math/big/rational.zig+1-1| ... | @@ -493,7 +493,7 @@ fn extractLowBits(a: Int, comptime T: type) T { | ... | @@ -493,7 +493,7 @@ fn extractLowBits(a: Int, comptime T: type) T { |
| 493 | } | 493 | } |
| 494 | } | 494 | } |
| 495 | 495 | ||
| 496 | test "extractLowBits" { | 496 | test extractLowBits { |
| 497 | var a = try Int.initSet(testing.allocator, 0x11112222333344441234567887654321); | 497 | var a = try Int.initSet(testing.allocator, 0x11112222333344441234567887654321); |
| 498 | defer a.deinit(); | 498 | defer a.deinit(); |
| 499 | 499 |
lib/std/math/cbrt.zig+3-3| ... | @@ -119,12 +119,12 @@ fn cbrt64(x: f64) f64 { | ... | @@ -119,12 +119,12 @@ fn cbrt64(x: f64) f64 { |
| 119 | return t + t * q; | 119 | return t + t * q; |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | test "cbrt" { | 122 | test cbrt { |
| 123 | try expect(cbrt(@as(f32, 0.0)) == cbrt32(0.0)); | 123 | try expect(cbrt(@as(f32, 0.0)) == cbrt32(0.0)); |
| 124 | try expect(cbrt(@as(f64, 0.0)) == cbrt64(0.0)); | 124 | try expect(cbrt(@as(f64, 0.0)) == cbrt64(0.0)); |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | test "cbrt32" { | 127 | test cbrt32 { |
| 128 | const epsilon = 0.000001; | 128 | const epsilon = 0.000001; |
| 129 | 129 | ||
| 130 | try expect(math.isPositiveZero(cbrt32(0.0))); | 130 | try expect(math.isPositiveZero(cbrt32(0.0))); |
| ... | @@ -135,7 +135,7 @@ test "cbrt32" { | ... | @@ -135,7 +135,7 @@ test "cbrt32" { |
| 135 | try expect(math.approxEqAbs(f32, cbrt32(123123.234375), 49.748501, epsilon)); | 135 | try expect(math.approxEqAbs(f32, cbrt32(123123.234375), 49.748501, epsilon)); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | test "cbrt64" { | 138 | test cbrt64 { |
| 139 | const epsilon = 0.000001; | 139 | const epsilon = 0.000001; |
| 140 | 140 | ||
| 141 | try expect(math.isPositiveZero(cbrt64(0.0))); | 141 | try expect(math.isPositiveZero(cbrt64(0.0))); |
lib/std/math/complex/atan.zig+2-2| ... | @@ -120,7 +120,7 @@ fn atan64(z: Complex(f64)) Complex(f64) { | ... | @@ -120,7 +120,7 @@ fn atan64(z: Complex(f64)) Complex(f64) { |
| 120 | 120 | ||
| 121 | const epsilon = 0.0001; | 121 | const epsilon = 0.0001; |
| 122 | 122 | ||
| 123 | test "atan32" { | 123 | test atan32 { |
| 124 | const a = Complex(f32).init(5, 3); | 124 | const a = Complex(f32).init(5, 3); |
| 125 | const c = atan(a); | 125 | const c = atan(a); |
| 126 | 126 | ||
| ... | @@ -128,7 +128,7 @@ test "atan32" { | ... | @@ -128,7 +128,7 @@ test "atan32" { |
| 128 | try testing.expect(math.approxEqAbs(f32, c.im, 0.086569, epsilon)); | 128 | try testing.expect(math.approxEqAbs(f32, c.im, 0.086569, epsilon)); |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | test "atan64" { | 131 | test atan64 { |
| 132 | const a = Complex(f64).init(5, 3); | 132 | const a = Complex(f64).init(5, 3); |
| 133 | const c = atan(a); | 133 | const c = atan(a); |
| 134 | 134 |
lib/std/math/complex/atanh.zig+1-1| ... | @@ -14,7 +14,7 @@ pub fn atanh(z: anytype) Complex(@TypeOf(z.re, z.im)) { | ... | @@ -14,7 +14,7 @@ pub fn atanh(z: anytype) Complex(@TypeOf(z.re, z.im)) { |
| 14 | 14 | ||
| 15 | const epsilon = 0.0001; | 15 | const epsilon = 0.0001; |
| 16 | 16 | ||
| 17 | test "atanh" { | 17 | test atanh { |
| 18 | const a = Complex(f32).init(5, 3); | 18 | const a = Complex(f32).init(5, 3); |
| 19 | const c = atanh(a); | 19 | const c = atanh(a); |
| 20 | 20 |
lib/std/math/complex/conj.zig+1-1| ... | @@ -10,7 +10,7 @@ pub fn conj(z: anytype) Complex(@TypeOf(z.re, z.im)) { | ... | @@ -10,7 +10,7 @@ pub fn conj(z: anytype) Complex(@TypeOf(z.re, z.im)) { |
| 10 | return Complex(T).init(z.re, -z.im); | 10 | return Complex(T).init(z.re, -z.im); |
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | test "onj" { | 13 | test conj { |
| 14 | const a = Complex(f32).init(5, 3); | 14 | const a = Complex(f32).init(5, 3); |
| 15 | const c = a.conjugate(); | 15 | const c = a.conjugate(); |
| 16 | 16 |
lib/std/math/complex/cos.zig+1-1| ... | @@ -13,7 +13,7 @@ pub fn cos(z: anytype) Complex(@TypeOf(z.re, z.im)) { | ... | @@ -13,7 +13,7 @@ pub fn cos(z: anytype) Complex(@TypeOf(z.re, z.im)) { |
| 13 | 13 | ||
| 14 | const epsilon = 0.0001; | 14 | const epsilon = 0.0001; |
| 15 | 15 | ||
| 16 | test "cos" { | 16 | test cos { |
| 17 | const a = Complex(f32).init(5, 3); | 17 | const a = Complex(f32).init(5, 3); |
| 18 | const c = cos(a); | 18 | const c = cos(a); |
| 19 | 19 |
lib/std/math/complex/cosh.zig+2-2| ... | @@ -155,7 +155,7 @@ fn cosh64(z: Complex(f64)) Complex(f64) { | ... | @@ -155,7 +155,7 @@ fn cosh64(z: Complex(f64)) Complex(f64) { |
| 155 | 155 | ||
| 156 | const epsilon = 0.0001; | 156 | const epsilon = 0.0001; |
| 157 | 157 | ||
| 158 | test "cosh32" { | 158 | test cosh32 { |
| 159 | const a = Complex(f32).init(5, 3); | 159 | const a = Complex(f32).init(5, 3); |
| 160 | const c = cosh(a); | 160 | const c = cosh(a); |
| 161 | 161 | ||
| ... | @@ -163,7 +163,7 @@ test "cosh32" { | ... | @@ -163,7 +163,7 @@ test "cosh32" { |
| 163 | try testing.expect(math.approxEqAbs(f32, c.im, 10.471557, epsilon)); | 163 | try testing.expect(math.approxEqAbs(f32, c.im, 10.471557, epsilon)); |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | test "cosh64" { | 166 | test cosh64 { |
| 167 | const a = Complex(f64).init(5, 3); | 167 | const a = Complex(f64).init(5, 3); |
| 168 | const c = cosh(a); | 168 | const c = cosh(a); |
| 169 | 169 |
lib/std/math/complex/exp.zig+2-2| ... | @@ -119,7 +119,7 @@ fn exp64(z: Complex(f64)) Complex(f64) { | ... | @@ -119,7 +119,7 @@ fn exp64(z: Complex(f64)) Complex(f64) { |
| 119 | } | 119 | } |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | test "exp32" { | 122 | test exp32 { |
| 123 | const tolerance_f32 = @sqrt(math.floatEps(f32)); | 123 | const tolerance_f32 = @sqrt(math.floatEps(f32)); |
| 124 | 124 | ||
| 125 | { | 125 | { |
| ... | @@ -139,7 +139,7 @@ test "exp32" { | ... | @@ -139,7 +139,7 @@ test "exp32" { |
| 139 | } | 139 | } |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | test "exp64" { | 142 | test exp64 { |
| 143 | const tolerance_f64 = @sqrt(math.floatEps(f64)); | 143 | const tolerance_f64 = @sqrt(math.floatEps(f64)); |
| 144 | 144 | ||
| 145 | { | 145 | { |
lib/std/math/complex/log.zig+1-1| ... | @@ -15,7 +15,7 @@ pub fn log(z: anytype) Complex(@TypeOf(z.re, z.im)) { | ... | @@ -15,7 +15,7 @@ pub fn log(z: anytype) Complex(@TypeOf(z.re, z.im)) { |
| 15 | 15 | ||
| 16 | const epsilon = 0.0001; | 16 | const epsilon = 0.0001; |
| 17 | 17 | ||
| 18 | test "log" { | 18 | test log { |
| 19 | const a = Complex(f32).init(5, 3); | 19 | const a = Complex(f32).init(5, 3); |
| 20 | const c = log(a); | 20 | const c = log(a); |
| 21 | 21 |
lib/std/math/complex/pow.zig+1-1| ... | @@ -11,7 +11,7 @@ pub fn pow(z: anytype, s: anytype) Complex(@TypeOf(z.re, z.im, s.re, s.im)) { | ... | @@ -11,7 +11,7 @@ pub fn pow(z: anytype, s: anytype) Complex(@TypeOf(z.re, z.im, s.re, s.im)) { |
| 11 | 11 | ||
| 12 | const epsilon = 0.0001; | 12 | const epsilon = 0.0001; |
| 13 | 13 | ||
| 14 | test "pow" { | 14 | test pow { |
| 15 | const a = Complex(f32).init(5, 3); | 15 | const a = Complex(f32).init(5, 3); |
| 16 | const b = Complex(f32).init(2.3, -1.3); | 16 | const b = Complex(f32).init(2.3, -1.3); |
| 17 | const c = pow(a, b); | 17 | const c = pow(a, b); |
lib/std/math/complex/proj.zig+1-3| ... | @@ -15,9 +15,7 @@ pub fn proj(z: anytype) Complex(@TypeOf(z.re, z.im)) { | ... | @@ -15,9 +15,7 @@ pub fn proj(z: anytype) Complex(@TypeOf(z.re, z.im)) { |
| 15 | return Complex(T).init(z.re, z.im); | 15 | return Complex(T).init(z.re, z.im); |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | const epsilon = 0.0001; | 18 | test proj { |
| 19 | |||
| 20 | test "proj" { | ||
| 21 | const a = Complex(f32).init(5, 3); | 19 | const a = Complex(f32).init(5, 3); |
| 22 | const c = proj(a); | 20 | const c = proj(a); |
| 23 | 21 |
lib/std/math/complex/sin.zig+1-1| ... | @@ -14,7 +14,7 @@ pub fn sin(z: anytype) Complex(@TypeOf(z.re, z.im)) { | ... | @@ -14,7 +14,7 @@ pub fn sin(z: anytype) Complex(@TypeOf(z.re, z.im)) { |
| 14 | 14 | ||
| 15 | const epsilon = 0.0001; | 15 | const epsilon = 0.0001; |
| 16 | 16 | ||
| 17 | test "sin" { | 17 | test sin { |
| 18 | const a = Complex(f32).init(5, 3); | 18 | const a = Complex(f32).init(5, 3); |
| 19 | const c = sin(a); | 19 | const c = sin(a); |
| 20 | 20 |
lib/std/math/complex/sinh.zig+2-2| ... | @@ -154,7 +154,7 @@ fn sinh64(z: Complex(f64)) Complex(f64) { | ... | @@ -154,7 +154,7 @@ fn sinh64(z: Complex(f64)) Complex(f64) { |
| 154 | 154 | ||
| 155 | const epsilon = 0.0001; | 155 | const epsilon = 0.0001; |
| 156 | 156 | ||
| 157 | test "sinh32" { | 157 | test sinh32 { |
| 158 | const a = Complex(f32).init(5, 3); | 158 | const a = Complex(f32).init(5, 3); |
| 159 | const c = sinh(a); | 159 | const c = sinh(a); |
| 160 | 160 | ||
| ... | @@ -162,7 +162,7 @@ test "sinh32" { | ... | @@ -162,7 +162,7 @@ test "sinh32" { |
| 162 | try testing.expect(math.approxEqAbs(f32, c.im, 10.472508, epsilon)); | 162 | try testing.expect(math.approxEqAbs(f32, c.im, 10.472508, epsilon)); |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | test "sinh64" { | 165 | test sinh64 { |
| 166 | const a = Complex(f64).init(5, 3); | 166 | const a = Complex(f64).init(5, 3); |
| 167 | const c = sinh(a); | 167 | const c = sinh(a); |
| 168 | 168 |
lib/std/math/complex/sqrt.zig+2-2| ... | @@ -129,7 +129,7 @@ fn sqrt64(z: Complex(f64)) Complex(f64) { | ... | @@ -129,7 +129,7 @@ fn sqrt64(z: Complex(f64)) Complex(f64) { |
| 129 | 129 | ||
| 130 | const epsilon = 0.0001; | 130 | const epsilon = 0.0001; |
| 131 | 131 | ||
| 132 | test "sqrt32" { | 132 | test sqrt32 { |
| 133 | const a = Complex(f32).init(5, 3); | 133 | const a = Complex(f32).init(5, 3); |
| 134 | const c = sqrt(a); | 134 | const c = sqrt(a); |
| 135 | 135 | ||
| ... | @@ -137,7 +137,7 @@ test "sqrt32" { | ... | @@ -137,7 +137,7 @@ test "sqrt32" { |
| 137 | try testing.expect(math.approxEqAbs(f32, c.im, 0.644574, epsilon)); | 137 | try testing.expect(math.approxEqAbs(f32, c.im, 0.644574, epsilon)); |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | test "sqrt64" { | 140 | test sqrt64 { |
| 141 | const a = Complex(f64).init(5, 3); | 141 | const a = Complex(f64).init(5, 3); |
| 142 | const c = sqrt(a); | 142 | const c = sqrt(a); |
| 143 | 143 |
lib/std/math/complex/tan.zig+1-1| ... | @@ -14,7 +14,7 @@ pub fn tan(z: anytype) Complex(@TypeOf(z.re, z.im)) { | ... | @@ -14,7 +14,7 @@ pub fn tan(z: anytype) Complex(@TypeOf(z.re, z.im)) { |
| 14 | 14 | ||
| 15 | const epsilon = 0.0001; | 15 | const epsilon = 0.0001; |
| 16 | 16 | ||
| 17 | test "tan" { | 17 | test tan { |
| 18 | const a = Complex(f32).init(5, 3); | 18 | const a = Complex(f32).init(5, 3); |
| 19 | const c = tan(a); | 19 | const c = tan(a); |
| 20 | 20 |
lib/std/math/complex/tanh.zig+2-2| ... | @@ -103,7 +103,7 @@ fn tanh64(z: Complex(f64)) Complex(f64) { | ... | @@ -103,7 +103,7 @@ fn tanh64(z: Complex(f64)) Complex(f64) { |
| 103 | 103 | ||
| 104 | const epsilon = 0.0001; | 104 | const epsilon = 0.0001; |
| 105 | 105 | ||
| 106 | test "tanh32" { | 106 | test tanh32 { |
| 107 | const a = Complex(f32).init(5, 3); | 107 | const a = Complex(f32).init(5, 3); |
| 108 | const c = tanh(a); | 108 | const c = tanh(a); |
| 109 | 109 | ||
| ... | @@ -111,7 +111,7 @@ test "tanh32" { | ... | @@ -111,7 +111,7 @@ test "tanh32" { |
| 111 | try testing.expect(math.approxEqAbs(f32, c.im, -0.000025, epsilon)); | 111 | try testing.expect(math.approxEqAbs(f32, c.im, -0.000025, epsilon)); |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | test "tanh64" { | 114 | test tanh64 { |
| 115 | const a = Complex(f64).init(5, 3); | 115 | const a = Complex(f64).init(5, 3); |
| 116 | const c = tanh(a); | 116 | const c = tanh(a); |
| 117 | 117 |
lib/std/math/cosh.zig+3-3| ... | @@ -86,12 +86,12 @@ fn cosh64(x: f64) f64 { | ... | @@ -86,12 +86,12 @@ fn cosh64(x: f64) f64 { |
| 86 | return expo2(ax); | 86 | return expo2(ax); |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | test "cosh" { | 89 | test cosh { |
| 90 | try expect(cosh(@as(f32, 1.5)) == cosh32(1.5)); | 90 | try expect(cosh(@as(f32, 1.5)) == cosh32(1.5)); |
| 91 | try expect(cosh(@as(f64, 1.5)) == cosh64(1.5)); | 91 | try expect(cosh(@as(f64, 1.5)) == cosh64(1.5)); |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | test "cosh32" { | 94 | test cosh32 { |
| 95 | const epsilon = 0.000001; | 95 | const epsilon = 0.000001; |
| 96 | 96 | ||
| 97 | try expect(math.approxEqAbs(f32, cosh32(0.0), 1.0, epsilon)); | 97 | try expect(math.approxEqAbs(f32, cosh32(0.0), 1.0, epsilon)); |
| ... | @@ -104,7 +104,7 @@ test "cosh32" { | ... | @@ -104,7 +104,7 @@ test "cosh32" { |
| 104 | try expect(math.approxEqAbs(f32, cosh32(-1.5), 2.352410, epsilon)); | 104 | try expect(math.approxEqAbs(f32, cosh32(-1.5), 2.352410, epsilon)); |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | test "cosh64" { | 107 | test cosh64 { |
| 108 | const epsilon = 0.000001; | 108 | const epsilon = 0.000001; |
| 109 | 109 | ||
| 110 | try expect(math.approxEqAbs(f64, cosh64(0.0), 1.0, epsilon)); | 110 | try expect(math.approxEqAbs(f64, cosh64(0.0), 1.0, epsilon)); |
lib/std/math/expm1.zig+3-3| ... | @@ -286,12 +286,12 @@ fn expm1_64(x_: f64) f64 { | ... | @@ -286,12 +286,12 @@ fn expm1_64(x_: f64) f64 { |
| 286 | } | 286 | } |
| 287 | } | 287 | } |
| 288 | 288 | ||
| 289 | test "exp1m" { | 289 | test expm1 { |
| 290 | try expect(expm1(@as(f32, 0.0)) == expm1_32(0.0)); | 290 | try expect(expm1(@as(f32, 0.0)) == expm1_32(0.0)); |
| 291 | try expect(expm1(@as(f64, 0.0)) == expm1_64(0.0)); | 291 | try expect(expm1(@as(f64, 0.0)) == expm1_64(0.0)); |
| 292 | } | 292 | } |
| 293 | 293 | ||
| 294 | test "expm1_32" { | 294 | test expm1_32 { |
| 295 | const epsilon = 0.000001; | 295 | const epsilon = 0.000001; |
| 296 | 296 | ||
| 297 | try expect(math.isPositiveZero(expm1_32(0.0))); | 297 | try expect(math.isPositiveZero(expm1_32(0.0))); |
| ... | @@ -301,7 +301,7 @@ test "expm1_32" { | ... | @@ -301,7 +301,7 @@ test "expm1_32" { |
| 301 | try expect(math.approxEqAbs(f32, expm1_32(1.5), 3.481689, epsilon)); | 301 | try expect(math.approxEqAbs(f32, expm1_32(1.5), 3.481689, epsilon)); |
| 302 | } | 302 | } |
| 303 | 303 | ||
| 304 | test "expm1_64" { | 304 | test expm1_64 { |
| 305 | const epsilon = 0.000001; | 305 | const epsilon = 0.000001; |
| 306 | 306 | ||
| 307 | try expect(math.isPositiveZero(expm1_64(0.0))); | 307 | try expect(math.isPositiveZero(expm1_64(0.0))); |
lib/std/math/float.zig+3-3| ... | @@ -132,7 +132,7 @@ test "float bits" { | ... | @@ -132,7 +132,7 @@ test "float bits" { |
| 132 | } | 132 | } |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | test "inf" { | 135 | test inf { |
| 136 | const inf_u16: u16 = 0x7C00; | 136 | const inf_u16: u16 = 0x7C00; |
| 137 | const inf_u32: u32 = 0x7F800000; | 137 | const inf_u32: u32 = 0x7F800000; |
| 138 | const inf_u64: u64 = 0x7FF0000000000000; | 138 | const inf_u64: u64 = 0x7FF0000000000000; |
| ... | @@ -145,7 +145,7 @@ test "inf" { | ... | @@ -145,7 +145,7 @@ test "inf" { |
| 145 | try expectEqual(inf_u128, @as(u128, @bitCast(inf(f128)))); | 145 | try expectEqual(inf_u128, @as(u128, @bitCast(inf(f128)))); |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | test "nan" { | 148 | test nan { |
| 149 | const qnan_u16: u16 = 0x7E00; | 149 | const qnan_u16: u16 = 0x7E00; |
| 150 | const qnan_u32: u32 = 0x7FC00000; | 150 | const qnan_u32: u32 = 0x7FC00000; |
| 151 | const qnan_u64: u64 = 0x7FF8000000000000; | 151 | const qnan_u64: u64 = 0x7FF8000000000000; |
| ... | @@ -158,7 +158,7 @@ test "nan" { | ... | @@ -158,7 +158,7 @@ test "nan" { |
| 158 | try expectEqual(qnan_u128, @as(u128, @bitCast(nan(f128)))); | 158 | try expectEqual(qnan_u128, @as(u128, @bitCast(nan(f128)))); |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | test "snan" { | 161 | test snan { |
| 162 | // TODO: https://github.com/ziglang/zig/issues/14366 | 162 | // TODO: https://github.com/ziglang/zig/issues/14366 |
| 163 | if (builtin.zig_backend == .stage2_llvm and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest; | 163 | if (builtin.zig_backend == .stage2_llvm and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest; |
| 164 | 164 |
lib/std/math/gamma.zig+2-2| ... | @@ -240,7 +240,7 @@ const expect = std.testing.expect; | ... | @@ -240,7 +240,7 @@ const expect = std.testing.expect; |
| 240 | const expectEqual = std.testing.expectEqual; | 240 | const expectEqual = std.testing.expectEqual; |
| 241 | const expectApproxEqRel = std.testing.expectApproxEqRel; | 241 | const expectApproxEqRel = std.testing.expectApproxEqRel; |
| 242 | 242 | ||
| 243 | test "gamma" { | 243 | test gamma { |
| 244 | inline for (&.{ f32, f64 }) |T| { | 244 | inline for (&.{ f32, f64 }) |T| { |
| 245 | const eps = @sqrt(std.math.floatEps(T)); | 245 | const eps = @sqrt(std.math.floatEps(T)); |
| 246 | try expectApproxEqRel(@as(T, 120), gamma(T, 6), eps); | 246 | try expectApproxEqRel(@as(T, 120), gamma(T, 6), eps); |
| ... | @@ -286,7 +286,7 @@ test "gamma.special" { | ... | @@ -286,7 +286,7 @@ test "gamma.special" { |
| 286 | } | 286 | } |
| 287 | } | 287 | } |
| 288 | 288 | ||
| 289 | test "lgamma" { | 289 | test lgamma { |
| 290 | inline for (&.{ f32, f64 }) |T| { | 290 | inline for (&.{ f32, f64 }) |T| { |
| 291 | const eps = @sqrt(std.math.floatEps(T)); | 291 | const eps = @sqrt(std.math.floatEps(T)); |
| 292 | try expectApproxEqRel(@as(T, @log(24.0)), lgamma(T, 5), eps); | 292 | try expectApproxEqRel(@as(T, @log(24.0)), lgamma(T, 5), eps); |
lib/std/math/hypot.zig+3-3| ... | @@ -124,7 +124,7 @@ fn hypot64(x: f64, y: f64) f64 { | ... | @@ -124,7 +124,7 @@ fn hypot64(x: f64, y: f64) f64 { |
| 124 | return z * @sqrt(ly + lx + hy + hx); | 124 | return z * @sqrt(ly + lx + hy + hx); |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | test "hypot" { | 127 | test hypot { |
| 128 | const x32: f32 = 0.0; | 128 | const x32: f32 = 0.0; |
| 129 | const y32: f32 = -1.2; | 129 | const y32: f32 = -1.2; |
| 130 | const x64: f64 = 0.0; | 130 | const x64: f64 = 0.0; |
| ... | @@ -133,7 +133,7 @@ test "hypot" { | ... | @@ -133,7 +133,7 @@ test "hypot" { |
| 133 | try expect(hypot(x64, y64) == hypot64(0.0, -1.2)); | 133 | try expect(hypot(x64, y64) == hypot64(0.0, -1.2)); |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | test "hypot32" { | 136 | test hypot32 { |
| 137 | const epsilon = 0.000001; | 137 | const epsilon = 0.000001; |
| 138 | 138 | ||
| 139 | try expect(math.approxEqAbs(f32, hypot32(0.0, -1.2), 1.2, epsilon)); | 139 | try expect(math.approxEqAbs(f32, hypot32(0.0, -1.2), 1.2, epsilon)); |
| ... | @@ -145,7 +145,7 @@ test "hypot32" { | ... | @@ -145,7 +145,7 @@ test "hypot32" { |
| 145 | try expect(math.approxEqAbs(f32, hypot32(123123.234375, 529428.707813), 543556.875, epsilon)); | 145 | try expect(math.approxEqAbs(f32, hypot32(123123.234375, 529428.707813), 543556.875, epsilon)); |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | test "hypot64" { | 148 | test hypot64 { |
| 149 | const epsilon = 0.000001; | 149 | const epsilon = 0.000001; |
| 150 | 150 | ||
| 151 | try expect(math.approxEqAbs(f64, hypot64(0.0, -1.2), 1.2, epsilon)); | 151 | try expect(math.approxEqAbs(f64, hypot64(0.0, -1.2), 1.2, epsilon)); |
lib/std/math/log1p.zig+3-3| ... | @@ -182,12 +182,12 @@ fn log1p_64(x: f64) f64 { | ... | @@ -182,12 +182,12 @@ fn log1p_64(x: f64) f64 { |
| 182 | return s * (hfsq + R) + (dk * ln2_lo + c) - hfsq + f + dk * ln2_hi; | 182 | return s * (hfsq + R) + (dk * ln2_lo + c) - hfsq + f + dk * ln2_hi; |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | test "log1p" { | 185 | test log1p { |
| 186 | try expect(log1p(@as(f32, 0.0)) == log1p_32(0.0)); | 186 | try expect(log1p(@as(f32, 0.0)) == log1p_32(0.0)); |
| 187 | try expect(log1p(@as(f64, 0.0)) == log1p_64(0.0)); | 187 | try expect(log1p(@as(f64, 0.0)) == log1p_64(0.0)); |
| 188 | } | 188 | } |
| 189 | 189 | ||
| 190 | test "log1p_32" { | 190 | test log1p_32 { |
| 191 | const epsilon = 0.000001; | 191 | const epsilon = 0.000001; |
| 192 | 192 | ||
| 193 | try expect(math.approxEqAbs(f32, log1p_32(0.0), 0.0, epsilon)); | 193 | try expect(math.approxEqAbs(f32, log1p_32(0.0), 0.0, epsilon)); |
| ... | @@ -199,7 +199,7 @@ test "log1p_32" { | ... | @@ -199,7 +199,7 @@ test "log1p_32" { |
| 199 | try expect(math.approxEqAbs(f32, log1p_32(123123.234375), 11.720949, epsilon)); | 199 | try expect(math.approxEqAbs(f32, log1p_32(123123.234375), 11.720949, epsilon)); |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | test "log1p_64" { | 202 | test log1p_64 { |
| 203 | const epsilon = 0.000001; | 203 | const epsilon = 0.000001; |
| 204 | 204 | ||
| 205 | try expect(math.approxEqAbs(f64, log1p_64(0.0), 0.0, epsilon)); | 205 | try expect(math.approxEqAbs(f64, log1p_64(0.0), 0.0, epsilon)); |
lib/std/math/log2.zig+1-1| ... | @@ -42,7 +42,7 @@ pub fn log2(x: anytype) @TypeOf(x) { | ... | @@ -42,7 +42,7 @@ pub fn log2(x: anytype) @TypeOf(x) { |
| 42 | } | 42 | } |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | test "log2" { | 45 | test log2 { |
| 46 | // https://github.com/ziglang/zig/issues/13703 | 46 | // https://github.com/ziglang/zig/issues/13703 |
| 47 | if (builtin.cpu.arch == .aarch64 and builtin.os.tag == .windows) return error.SkipZigTest; | 47 | if (builtin.cpu.arch == .aarch64 and builtin.os.tag == .windows) return error.SkipZigTest; |
| 48 | 48 |
lib/std/math/modf.zig+3-3| ... | @@ -123,14 +123,14 @@ fn modf64(x: f64) modf64_result { | ... | @@ -123,14 +123,14 @@ fn modf64(x: f64) modf64_result { |
| 123 | return result; | 123 | return result; |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | test "modf" { | 126 | test modf { |
| 127 | const a = modf(@as(f32, 1.0)); | 127 | const a = modf(@as(f32, 1.0)); |
| 128 | const b = modf32(1.0); | 128 | const b = modf32(1.0); |
| 129 | // NOTE: No struct comparison on generic return type function? non-named, makes sense, but still. | 129 | // NOTE: No struct comparison on generic return type function? non-named, makes sense, but still. |
| 130 | try expectEqual(a, b); | 130 | try expectEqual(a, b); |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | test "modf32" { | 133 | test modf32 { |
| 134 | const epsilon = 0.000001; | 134 | const epsilon = 0.000001; |
| 135 | var r: modf32_result = undefined; | 135 | var r: modf32_result = undefined; |
| 136 | 136 | ||
| ... | @@ -155,7 +155,7 @@ test "modf32" { | ... | @@ -155,7 +155,7 @@ test "modf32" { |
| 155 | try expect(math.approxEqAbs(f32, r.fpart, 0.340820, epsilon)); | 155 | try expect(math.approxEqAbs(f32, r.fpart, 0.340820, epsilon)); |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | test "modf64" { | 158 | test modf64 { |
| 159 | const epsilon = 0.000001; | 159 | const epsilon = 0.000001; |
| 160 | var r: modf64_result = undefined; | 160 | var r: modf64_result = undefined; |
| 161 | 161 |
lib/std/math/powi.zig+1-1| ... | @@ -91,7 +91,7 @@ pub fn powi(comptime T: type, x: T, y: T) (error{ | ... | @@ -91,7 +91,7 @@ pub fn powi(comptime T: type, x: T, y: T) (error{ |
| 91 | return acc; | 91 | return acc; |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | test "powi" { | 94 | test powi { |
| 95 | try testing.expectError(error.Overflow, powi(i8, -66, 6)); | 95 | try testing.expectError(error.Overflow, powi(i8, -66, 6)); |
| 96 | try testing.expectError(error.Overflow, powi(i16, -13, 13)); | 96 | try testing.expectError(error.Overflow, powi(i16, -13, 13)); |
| 97 | try testing.expectError(error.Overflow, powi(i32, -32, 21)); | 97 | try testing.expectError(error.Overflow, powi(i32, -32, 21)); |
lib/std/math/sinh.zig+3-3| ... | @@ -91,12 +91,12 @@ fn sinh64(x: f64) f64 { | ... | @@ -91,12 +91,12 @@ fn sinh64(x: f64) f64 { |
| 91 | return 2 * h * expo2(ax); | 91 | return 2 * h * expo2(ax); |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | test "sinh" { | 94 | test sinh { |
| 95 | try expect(sinh(@as(f32, 1.5)) == sinh32(1.5)); | 95 | try expect(sinh(@as(f32, 1.5)) == sinh32(1.5)); |
| 96 | try expect(sinh(@as(f64, 1.5)) == sinh64(1.5)); | 96 | try expect(sinh(@as(f64, 1.5)) == sinh64(1.5)); |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | test "sinh32" { | 99 | test sinh32 { |
| 100 | const epsilon = 0.000001; | 100 | const epsilon = 0.000001; |
| 101 | 101 | ||
| 102 | try expect(math.approxEqAbs(f32, sinh32(0.0), 0.0, epsilon)); | 102 | try expect(math.approxEqAbs(f32, sinh32(0.0), 0.0, epsilon)); |
| ... | @@ -109,7 +109,7 @@ test "sinh32" { | ... | @@ -109,7 +109,7 @@ test "sinh32" { |
| 109 | try expect(math.approxEqAbs(f32, sinh32(-1.5), -2.129279, epsilon)); | 109 | try expect(math.approxEqAbs(f32, sinh32(-1.5), -2.129279, epsilon)); |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | test "sinh64" { | 112 | test sinh64 { |
| 113 | const epsilon = 0.000001; | 113 | const epsilon = 0.000001; |
| 114 | 114 | ||
| 115 | try expect(math.approxEqAbs(f64, sinh64(0.0), 0.0, epsilon)); | 115 | try expect(math.approxEqAbs(f64, sinh64(0.0), 0.0, epsilon)); |
lib/std/math/tanh.zig+3-3| ... | @@ -104,12 +104,12 @@ fn tanh64(x: f64) f64 { | ... | @@ -104,12 +104,12 @@ fn tanh64(x: f64) f64 { |
| 104 | return if (sign) -t else t; | 104 | return if (sign) -t else t; |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | test "tanh" { | 107 | test tanh { |
| 108 | try expect(tanh(@as(f32, 1.5)) == tanh32(1.5)); | 108 | try expect(tanh(@as(f32, 1.5)) == tanh32(1.5)); |
| 109 | try expect(tanh(@as(f64, 1.5)) == tanh64(1.5)); | 109 | try expect(tanh(@as(f64, 1.5)) == tanh64(1.5)); |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | test "tanh32" { | 112 | test tanh32 { |
| 113 | const epsilon = 0.000001; | 113 | const epsilon = 0.000001; |
| 114 | 114 | ||
| 115 | try expect(math.approxEqAbs(f32, tanh32(0.0), 0.0, epsilon)); | 115 | try expect(math.approxEqAbs(f32, tanh32(0.0), 0.0, epsilon)); |
| ... | @@ -122,7 +122,7 @@ test "tanh32" { | ... | @@ -122,7 +122,7 @@ test "tanh32" { |
| 122 | try expect(math.approxEqAbs(f32, tanh32(-37.45), -1.0, epsilon)); | 122 | try expect(math.approxEqAbs(f32, tanh32(-37.45), -1.0, epsilon)); |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | test "tanh64" { | 125 | test tanh64 { |
| 126 | const epsilon = 0.000001; | 126 | const epsilon = 0.000001; |
| 127 | 127 | ||
| 128 | try expect(math.approxEqAbs(f64, tanh64(0.0), 0.0, epsilon)); | 128 | try expect(math.approxEqAbs(f64, tanh64(0.0), 0.0, epsilon)); |
lib/std/meta.zig+26-26| ... | @@ -46,7 +46,7 @@ pub fn stringToEnum(comptime T: type, str: []const u8) ?T { | ... | @@ -46,7 +46,7 @@ pub fn stringToEnum(comptime T: type, str: []const u8) ?T { |
| 46 | } | 46 | } |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | test "stringToEnum" { | 49 | test stringToEnum { |
| 50 | const E1 = enum { | 50 | const E1 = enum { |
| 51 | A, | 51 | A, |
| 52 | B, | 52 | B, |
| ... | @@ -73,7 +73,7 @@ pub fn alignment(comptime T: type) comptime_int { | ... | @@ -73,7 +73,7 @@ pub fn alignment(comptime T: type) comptime_int { |
| 73 | }; | 73 | }; |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | test "alignment" { | 76 | test alignment { |
| 77 | try testing.expect(alignment(u8) == 1); | 77 | try testing.expect(alignment(u8) == 1); |
| 78 | try testing.expect(alignment(*align(1) u8) == 1); | 78 | try testing.expect(alignment(*align(1) u8) == 1); |
| 79 | try testing.expect(alignment(*align(2) u8) == 2); | 79 | try testing.expect(alignment(*align(2) u8) == 2); |
| ... | @@ -94,7 +94,7 @@ pub fn Child(comptime T: type) type { | ... | @@ -94,7 +94,7 @@ pub fn Child(comptime T: type) type { |
| 94 | }; | 94 | }; |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | test "Child" { | 97 | test Child { |
| 98 | try testing.expect(Child([1]u8) == u8); | 98 | try testing.expect(Child([1]u8) == u8); |
| 99 | try testing.expect(Child(*u8) == u8); | 99 | try testing.expect(Child(*u8) == u8); |
| 100 | try testing.expect(Child([]u8) == u8); | 100 | try testing.expect(Child([]u8) == u8); |
| ... | @@ -121,7 +121,7 @@ pub fn Elem(comptime T: type) type { | ... | @@ -121,7 +121,7 @@ pub fn Elem(comptime T: type) type { |
| 121 | @compileError("Expected pointer, slice, array or vector type, found '" ++ @typeName(T) ++ "'"); | 121 | @compileError("Expected pointer, slice, array or vector type, found '" ++ @typeName(T) ++ "'"); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | test "Elem" { | 124 | test Elem { |
| 125 | try testing.expect(Elem([1]u8) == u8); | 125 | try testing.expect(Elem([1]u8) == u8); |
| 126 | try testing.expect(Elem([*]u8) == u8); | 126 | try testing.expect(Elem([*]u8) == u8); |
| 127 | try testing.expect(Elem([]u8) == u8); | 127 | try testing.expect(Elem([]u8) == u8); |
| ... | @@ -255,7 +255,7 @@ pub fn containerLayout(comptime T: type) Type.ContainerLayout { | ... | @@ -255,7 +255,7 @@ pub fn containerLayout(comptime T: type) Type.ContainerLayout { |
| 255 | }; | 255 | }; |
| 256 | } | 256 | } |
| 257 | 257 | ||
| 258 | test "containerLayout" { | 258 | test containerLayout { |
| 259 | const S1 = struct {}; | 259 | const S1 = struct {}; |
| 260 | const S2 = packed struct {}; | 260 | const S2 = packed struct {}; |
| 261 | const S3 = extern struct {}; | 261 | const S3 = extern struct {}; |
| ... | @@ -289,7 +289,7 @@ pub fn declarations(comptime T: type) []const Type.Declaration { | ... | @@ -289,7 +289,7 @@ pub fn declarations(comptime T: type) []const Type.Declaration { |
| 289 | }; | 289 | }; |
| 290 | } | 290 | } |
| 291 | 291 | ||
| 292 | test "declarations" { | 292 | test declarations { |
| 293 | const E1 = enum { | 293 | const E1 = enum { |
| 294 | A, | 294 | A, |
| 295 | 295 | ||
| ... | @@ -329,7 +329,7 @@ pub fn declarationInfo(comptime T: type, comptime decl_name: []const u8) Type.De | ... | @@ -329,7 +329,7 @@ pub fn declarationInfo(comptime T: type, comptime decl_name: []const u8) Type.De |
| 329 | @compileError("'" ++ @typeName(T) ++ "' has no declaration '" ++ decl_name ++ "'"); | 329 | @compileError("'" ++ @typeName(T) ++ "' has no declaration '" ++ decl_name ++ "'"); |
| 330 | } | 330 | } |
| 331 | 331 | ||
| 332 | test "declarationInfo" { | 332 | test declarationInfo { |
| 333 | const E1 = enum { | 333 | const E1 = enum { |
| 334 | A, | 334 | A, |
| 335 | 335 | ||
| ... | @@ -370,7 +370,7 @@ pub fn fields(comptime T: type) switch (@typeInfo(T)) { | ... | @@ -370,7 +370,7 @@ pub fn fields(comptime T: type) switch (@typeInfo(T)) { |
| 370 | }; | 370 | }; |
| 371 | } | 371 | } |
| 372 | 372 | ||
| 373 | test "fields" { | 373 | test fields { |
| 374 | const E1 = enum { | 374 | const E1 = enum { |
| 375 | A, | 375 | A, |
| 376 | }; | 376 | }; |
| ... | @@ -409,7 +409,7 @@ pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeIn | ... | @@ -409,7 +409,7 @@ pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeIn |
| 409 | return fields(T)[@intFromEnum(field)]; | 409 | return fields(T)[@intFromEnum(field)]; |
| 410 | } | 410 | } |
| 411 | 411 | ||
| 412 | test "fieldInfo" { | 412 | test fieldInfo { |
| 413 | const E1 = enum { | 413 | const E1 = enum { |
| 414 | A, | 414 | A, |
| 415 | }; | 415 | }; |
| ... | @@ -442,7 +442,7 @@ pub fn FieldType(comptime T: type, comptime field: FieldEnum(T)) type { | ... | @@ -442,7 +442,7 @@ pub fn FieldType(comptime T: type, comptime field: FieldEnum(T)) type { |
| 442 | return fieldInfo(T, field).type; | 442 | return fieldInfo(T, field).type; |
| 443 | } | 443 | } |
| 444 | 444 | ||
| 445 | test "FieldType" { | 445 | test FieldType { |
| 446 | const S = struct { | 446 | const S = struct { |
| 447 | a: u8, | 447 | a: u8, |
| 448 | b: u16, | 448 | b: u16, |
| ... | @@ -470,7 +470,7 @@ pub fn fieldNames(comptime T: type) *const [fields(T).len][:0]const u8 { | ... | @@ -470,7 +470,7 @@ pub fn fieldNames(comptime T: type) *const [fields(T).len][:0]const u8 { |
| 470 | }; | 470 | }; |
| 471 | } | 471 | } |
| 472 | 472 | ||
| 473 | test "fieldNames" { | 473 | test fieldNames { |
| 474 | const E1 = enum { A, B }; | 474 | const E1 = enum { A, B }; |
| 475 | const E2 = error{A}; | 475 | const E2 = error{A}; |
| 476 | const S1 = struct { | 476 | const S1 = struct { |
| ... | @@ -511,7 +511,7 @@ pub fn tags(comptime T: type) *const [fields(T).len]T { | ... | @@ -511,7 +511,7 @@ pub fn tags(comptime T: type) *const [fields(T).len]T { |
| 511 | }; | 511 | }; |
| 512 | } | 512 | } |
| 513 | 513 | ||
| 514 | test "tags" { | 514 | test tags { |
| 515 | const E1 = enum { A, B }; | 515 | const E1 = enum { A, B }; |
| 516 | const E2 = error{A}; | 516 | const E2 = error{A}; |
| 517 | 517 | ||
| ... | @@ -604,7 +604,7 @@ fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void { | ... | @@ -604,7 +604,7 @@ fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void { |
| 604 | ); | 604 | ); |
| 605 | } | 605 | } |
| 606 | 606 | ||
| 607 | test "FieldEnum" { | 607 | test FieldEnum { |
| 608 | try expectEqualEnum(enum {}, FieldEnum(struct {})); | 608 | try expectEqualEnum(enum {}, FieldEnum(struct {})); |
| 609 | try expectEqualEnum(enum { a }, FieldEnum(struct { a: u8 })); | 609 | try expectEqualEnum(enum { a }, FieldEnum(struct { a: u8 })); |
| 610 | try expectEqualEnum(enum { a, b, c }, FieldEnum(struct { a: u8, b: void, c: f32 })); | 610 | 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 { | ... | @@ -639,7 +639,7 @@ pub fn DeclEnum(comptime T: type) type { |
| 639 | }); | 639 | }); |
| 640 | } | 640 | } |
| 641 | 641 | ||
| 642 | test "DeclEnum" { | 642 | test DeclEnum { |
| 643 | const A = struct { | 643 | const A = struct { |
| 644 | pub const a: u8 = 0; | 644 | pub const a: u8 = 0; |
| 645 | }; | 645 | }; |
| ... | @@ -670,7 +670,7 @@ pub fn Tag(comptime T: type) type { | ... | @@ -670,7 +670,7 @@ pub fn Tag(comptime T: type) type { |
| 670 | }; | 670 | }; |
| 671 | } | 671 | } |
| 672 | 672 | ||
| 673 | test "Tag" { | 673 | test Tag { |
| 674 | const E = enum(u8) { | 674 | const E = enum(u8) { |
| 675 | C = 33, | 675 | C = 33, |
| 676 | D, | 676 | D, |
| ... | @@ -690,7 +690,7 @@ pub fn activeTag(u: anytype) Tag(@TypeOf(u)) { | ... | @@ -690,7 +690,7 @@ pub fn activeTag(u: anytype) Tag(@TypeOf(u)) { |
| 690 | return @as(Tag(T), u); | 690 | return @as(Tag(T), u); |
| 691 | } | 691 | } |
| 692 | 692 | ||
| 693 | test "activeTag" { | 693 | test activeTag { |
| 694 | const UE = enum { | 694 | const UE = enum { |
| 695 | Int, | 695 | Int, |
| 696 | Float, | 696 | Float, |
| ... | @@ -727,7 +727,7 @@ pub fn TagPayload(comptime U: type, comptime tag: Tag(U)) type { | ... | @@ -727,7 +727,7 @@ pub fn TagPayload(comptime U: type, comptime tag: Tag(U)) type { |
| 727 | return TagPayloadByName(U, @tagName(tag)); | 727 | return TagPayloadByName(U, @tagName(tag)); |
| 728 | } | 728 | } |
| 729 | 729 | ||
| 730 | test "TagPayload" { | 730 | test TagPayload { |
| 731 | const Event = union(enum) { | 731 | const Event = union(enum) { |
| 732 | Moved: struct { | 732 | Moved: struct { |
| 733 | from: i32, | 733 | from: i32, |
| ... | @@ -802,7 +802,7 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool { | ... | @@ -802,7 +802,7 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool { |
| 802 | } | 802 | } |
| 803 | } | 803 | } |
| 804 | 804 | ||
| 805 | test "eql" { | 805 | test eql { |
| 806 | const S = struct { | 806 | const S = struct { |
| 807 | a: u32, | 807 | a: u32, |
| 808 | b: f64, | 808 | b: f64, |
| ... | @@ -863,7 +863,7 @@ test "eql" { | ... | @@ -863,7 +863,7 @@ test "eql" { |
| 863 | try testing.expect(!eql(v1, v3)); | 863 | try testing.expect(!eql(v1, v3)); |
| 864 | } | 864 | } |
| 865 | 865 | ||
| 866 | test "intToEnum with error return" { | 866 | test intToEnum { |
| 867 | const E1 = enum { | 867 | const E1 = enum { |
| 868 | A, | 868 | A, |
| 869 | }; | 869 | }; |
| ... | @@ -965,7 +965,7 @@ pub fn Float(comptime bit_count: u8) type { | ... | @@ -965,7 +965,7 @@ pub fn Float(comptime bit_count: u8) type { |
| 965 | }); | 965 | }); |
| 966 | } | 966 | } |
| 967 | 967 | ||
| 968 | test "Float" { | 968 | test Float { |
| 969 | try testing.expectEqual(f16, Float(16)); | 969 | try testing.expectEqual(f16, Float(16)); |
| 970 | try testing.expectEqual(f32, Float(32)); | 970 | try testing.expectEqual(f32, Float(32)); |
| 971 | try testing.expectEqual(f64, Float(64)); | 971 | try testing.expectEqual(f64, Float(64)); |
| ... | @@ -1057,7 +1057,7 @@ const TupleTester = struct { | ... | @@ -1057,7 +1057,7 @@ const TupleTester = struct { |
| 1057 | } | 1057 | } |
| 1058 | }; | 1058 | }; |
| 1059 | 1059 | ||
| 1060 | test "ArgsTuple" { | 1060 | test ArgsTuple { |
| 1061 | TupleTester.assertTuple(.{}, ArgsTuple(fn () void)); | 1061 | TupleTester.assertTuple(.{}, ArgsTuple(fn () void)); |
| 1062 | TupleTester.assertTuple(.{u32}, ArgsTuple(fn (a: u32) []const u8)); | 1062 | TupleTester.assertTuple(.{u32}, ArgsTuple(fn (a: u32) []const u8)); |
| 1063 | TupleTester.assertTuple(.{ u32, f16 }, ArgsTuple(fn (a: u32, b: f16) noreturn)); | 1063 | TupleTester.assertTuple(.{ u32, f16 }, ArgsTuple(fn (a: u32, b: f16) noreturn)); |
| ... | @@ -1065,7 +1065,7 @@ test "ArgsTuple" { | ... | @@ -1065,7 +1065,7 @@ test "ArgsTuple" { |
| 1065 | TupleTester.assertTuple(.{u32}, ArgsTuple(fn (comptime a: u32) []const u8)); | 1065 | TupleTester.assertTuple(.{u32}, ArgsTuple(fn (comptime a: u32) []const u8)); |
| 1066 | } | 1066 | } |
| 1067 | 1067 | ||
| 1068 | test "Tuple" { | 1068 | test Tuple { |
| 1069 | TupleTester.assertTuple(.{}, Tuple(&[_]type{})); | 1069 | TupleTester.assertTuple(.{}, Tuple(&[_]type{})); |
| 1070 | TupleTester.assertTuple(.{u32}, Tuple(&[_]type{u32})); | 1070 | TupleTester.assertTuple(.{u32}, Tuple(&[_]type{u32})); |
| 1071 | TupleTester.assertTuple(.{ u32, f16 }, Tuple(&[_]type{ u32, f16 })); | 1071 | TupleTester.assertTuple(.{ u32, f16 }, Tuple(&[_]type{ u32, f16 })); |
| ... | @@ -1103,7 +1103,7 @@ pub fn isError(error_union: anytype) bool { | ... | @@ -1103,7 +1103,7 @@ pub fn isError(error_union: anytype) bool { |
| 1103 | return if (error_union) |_| false else |_| true; | 1103 | return if (error_union) |_| false else |_| true; |
| 1104 | } | 1104 | } |
| 1105 | 1105 | ||
| 1106 | test "isError" { | 1106 | test isError { |
| 1107 | try std.testing.expect(isError(math.divTrunc(u8, 5, 0))); | 1107 | try std.testing.expect(isError(math.divTrunc(u8, 5, 0))); |
| 1108 | try std.testing.expect(!isError(math.divTrunc(u8, 5, 5))); | 1108 | try std.testing.expect(!isError(math.divTrunc(u8, 5, 5))); |
| 1109 | } | 1109 | } |
| ... | @@ -1121,7 +1121,7 @@ pub inline fn hasFn(comptime T: type, comptime name: []const u8) bool { | ... | @@ -1121,7 +1121,7 @@ pub inline fn hasFn(comptime T: type, comptime name: []const u8) bool { |
| 1121 | return @typeInfo(@TypeOf(@field(T, name))) == .Fn; | 1121 | return @typeInfo(@TypeOf(@field(T, name))) == .Fn; |
| 1122 | } | 1122 | } |
| 1123 | 1123 | ||
| 1124 | test "hasFn" { | 1124 | test hasFn { |
| 1125 | const S1 = struct { | 1125 | const S1 = struct { |
| 1126 | pub fn foo() void {} | 1126 | pub fn foo() void {} |
| 1127 | }; | 1127 | }; |
| ... | @@ -1149,7 +1149,7 @@ pub inline fn hasMethod(comptime T: type, comptime name: []const u8) bool { | ... | @@ -1149,7 +1149,7 @@ pub inline fn hasMethod(comptime T: type, comptime name: []const u8) bool { |
| 1149 | }; | 1149 | }; |
| 1150 | } | 1150 | } |
| 1151 | 1151 | ||
| 1152 | test "hasMethod" { | 1152 | test hasMethod { |
| 1153 | try std.testing.expect(!hasMethod(u32, "foo")); | 1153 | try std.testing.expect(!hasMethod(u32, "foo")); |
| 1154 | try std.testing.expect(!hasMethod([]u32, "len")); | 1154 | try std.testing.expect(!hasMethod([]u32, "len")); |
| 1155 | try std.testing.expect(!hasMethod(struct { u32, u64 }, "len")); | 1155 | try std.testing.expect(!hasMethod(struct { u32, u64 }, "len")); |
| ... | @@ -1218,7 +1218,7 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool { | ... | @@ -1218,7 +1218,7 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool { |
| 1218 | }; | 1218 | }; |
| 1219 | } | 1219 | } |
| 1220 | 1220 | ||
| 1221 | test "hasUniqueRepresentation" { | 1221 | test hasUniqueRepresentation { |
| 1222 | const TestStruct1 = struct { | 1222 | const TestStruct1 = struct { |
| 1223 | a: u32, | 1223 | a: u32, |
| 1224 | b: u32, | 1224 | b: u32, |