| author | |
| committer | |
| log | 16b3d1004ee520341839305826fe065eb5d8c818 |
| tree | eac514666f5f49e2d77b3aa82efaac901151bbee |
| parent | 1b79a42da096fcdeac22b56f17f82b0c7ec22a9b |
Follow up to #19079, which made test names fully qualified.
This fixes tests that now-redundant information in their test names. For example here's a fully qualified test name before the changes in this commit:
"priority_queue.test.std.PriorityQueue: shrinkAndFree"
and the same test's name after the changes in this commit:
"priority_queue.test.shrinkAndFree"115 files changed, 757 insertions(+), 754 deletions(-)
lib/std/Random/Isaac64.zig+2-2| ... | @@ -173,7 +173,7 @@ pub fn fill(self: *Isaac64, buf: []u8) void { | ... | @@ -173,7 +173,7 @@ pub fn fill(self: *Isaac64, buf: []u8) void { |
| 173 | } | 173 | } |
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | test "isaac64 sequence" { | 176 | test "sequence" { |
| 177 | var r = Isaac64.init(0); | 177 | var r = Isaac64.init(0); |
| 178 | 178 | ||
| 179 | // from reference implementation | 179 | // from reference implementation |
| ... | @@ -201,7 +201,7 @@ test "isaac64 sequence" { | ... | @@ -201,7 +201,7 @@ test "isaac64 sequence" { |
| 201 | } | 201 | } |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | test "isaac64 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+2-2| ... | @@ -72,7 +72,7 @@ pub fn fill(self: *Pcg, buf: []u8) void { | ... | @@ -72,7 +72,7 @@ pub fn fill(self: *Pcg, buf: []u8) void { |
| 72 | } | 72 | } |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | test "pcg sequence" { | 75 | test "sequence" { |
| 76 | var r = Pcg.init(0); | 76 | var r = Pcg.init(0); |
| 77 | const s0: u64 = 0x9394bf54ce5d79de; | 77 | const s0: u64 = 0x9394bf54ce5d79de; |
| 78 | const s1: u64 = 0x84e9c579ef59bbf7; | 78 | const s1: u64 = 0x84e9c579ef59bbf7; |
| ... | @@ -92,7 +92,7 @@ test "pcg sequence" { | ... | @@ -92,7 +92,7 @@ test "pcg sequence" { |
| 92 | } | 92 | } |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | test "pcg 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+3-3| ... | @@ -72,7 +72,7 @@ pub fn fill(self: *RomuTrio, buf: []u8) void { | ... | @@ -72,7 +72,7 @@ pub fn fill(self: *RomuTrio, buf: []u8) void { |
| 72 | } | 72 | } |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | test "RomuTrio sequence" { | 75 | test "sequence" { |
| 76 | // Unfortunately there does not seem to be an official test sequence. | 76 | // Unfortunately there does not seem to be an official test sequence. |
| 77 | var r = RomuTrio.init(0); | 77 | var r = RomuTrio.init(0); |
| 78 | 78 | ||
| ... | @@ -94,7 +94,7 @@ test "RomuTrio sequence" { | ... | @@ -94,7 +94,7 @@ test "RomuTrio sequence" { |
| 94 | } | 94 | } |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | test "RomuTrio 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 | ||
| ... | @@ -120,7 +120,7 @@ test "RomuTrio fill" { | ... | @@ -120,7 +120,7 @@ test "RomuTrio fill" { |
| 120 | } | 120 | } |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | test "RomuTrio buf seeding test" { | 123 | test "buf seeding test" { |
| 124 | const buf0 = @as([24]u8, @bitCast([3]u64{ 16294208416658607535, 13964609475759908645, 4703697494102998476 })); | 124 | const buf0 = @as([24]u8, @bitCast([3]u64{ 16294208416658607535, 13964609475759908645, 4703697494102998476 })); |
| 125 | const resulting_state = .{ .x = 16294208416658607535, .y = 13964609475759908645, .z = 4703697494102998476 }; | 125 | const resulting_state = .{ .x = 16294208416658607535, .y = 13964609475759908645, .z = 4703697494102998476 }; |
| 126 | var r = RomuTrio.init(0); | 126 | var r = RomuTrio.init(0); |
lib/std/Random/Sfc64.zig+2-2| ... | @@ -70,7 +70,7 @@ pub fn fill(self: *Sfc64, buf: []u8) void { | ... | @@ -70,7 +70,7 @@ pub fn fill(self: *Sfc64, buf: []u8) void { |
| 70 | } | 70 | } |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | test "Sfc64 sequence" { | 73 | test "sequence" { |
| 74 | // Unfortunately there does not seem to be an official test sequence. | 74 | // Unfortunately there does not seem to be an official test sequence. |
| 75 | var r = Sfc64.init(0); | 75 | var r = Sfc64.init(0); |
| 76 | 76 | ||
| ... | @@ -98,7 +98,7 @@ test "Sfc64 sequence" { | ... | @@ -98,7 +98,7 @@ test "Sfc64 sequence" { |
| 98 | } | 98 | } |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | test "Sfc64 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+2-2| ... | @@ -88,7 +88,7 @@ pub fn fill(self: *Xoroshiro128, buf: []u8) void { | ... | @@ -88,7 +88,7 @@ pub fn fill(self: *Xoroshiro128, buf: []u8) void { |
| 88 | } | 88 | } |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | test "xoroshiro sequence" { | 91 | test "sequence" { |
| 92 | var r = Xoroshiro128.init(0); | 92 | var r = Xoroshiro128.init(0); |
| 93 | r.s[0] = 0xaeecf86f7878dd75; | 93 | r.s[0] = 0xaeecf86f7878dd75; |
| 94 | r.s[1] = 0x01cd153642e72622; | 94 | r.s[1] = 0x01cd153642e72622; |
| ... | @@ -122,7 +122,7 @@ test "xoroshiro sequence" { | ... | @@ -122,7 +122,7 @@ test "xoroshiro sequence" { |
| 122 | } | 122 | } |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | test "xoroshiro 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+2-2| ... | @@ -88,7 +88,7 @@ pub fn fill(self: *Xoshiro256, buf: []u8) void { | ... | @@ -88,7 +88,7 @@ pub fn fill(self: *Xoshiro256, buf: []u8) void { |
| 88 | } | 88 | } |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | test "xoroshiro sequence" { | 91 | test "sequence" { |
| 92 | if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; | 92 | if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; |
| 93 | 93 | ||
| 94 | var r = Xoshiro256.init(0); | 94 | var r = Xoshiro256.init(0); |
| ... | @@ -122,7 +122,7 @@ test "xoroshiro sequence" { | ... | @@ -122,7 +122,7 @@ test "xoroshiro sequence" { |
| 122 | } | 122 | } |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | test "xoroshiro 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+2-2| ... | @@ -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 "SemanticVersion 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. |
| ... | @@ -277,7 +277,7 @@ test "SemanticVersion format" { | ... | @@ -277,7 +277,7 @@ test "SemanticVersion format" { |
| 277 | if (parse(big_invalid)) |ver| std.debug.panic("expected error, found {}", .{ver}) else |_| {} | 277 | if (parse(big_invalid)) |ver| std.debug.panic("expected error, found {}", .{ver}) else |_| {} |
| 278 | } | 278 | } |
| 279 | 279 | ||
| 280 | test "SemanticVersion precedence" { | 280 | test "precedence" { |
| 281 | // SemVer 2 spec 11.2 example: 1.0.0 < 2.0.0 < 2.1.0 < 2.1.1. | 281 | // SemVer 2 spec 11.2 example: 1.0.0 < 2.0.0 < 2.1.0 < 2.1.1. |
| 282 | try expect(order(try parse("1.0.0"), try parse("2.0.0")) == .lt); | 282 | try expect(order(try parse("1.0.0"), try parse("2.0.0")) == .lt); |
| 283 | try expect(order(try parse("2.0.0"), try parse("2.1.0")) == .lt); | 283 | try expect(order(try parse("2.0.0"), try parse("2.1.0")) == .lt); |
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 "Thread.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 "Thread.join" { | ... | @@ -1449,7 +1449,7 @@ test "Thread.join" { |
| 1449 | try std.testing.expectEqual(value, 1); | 1449 | try std.testing.expectEqual(value, 1); |
| 1450 | } | 1450 | } |
| 1451 | 1451 | ||
| 1452 | test "Thread.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+6-6| ... | @@ -296,7 +296,7 @@ const FutexImpl = struct { | ... | @@ -296,7 +296,7 @@ const FutexImpl = struct { |
| 296 | } | 296 | } |
| 297 | }; | 297 | }; |
| 298 | 298 | ||
| 299 | test "Condition - smoke test" { | 299 | test "smoke test" { |
| 300 | var mutex = Mutex{}; | 300 | var mutex = Mutex{}; |
| 301 | var cond = Condition{}; | 301 | var cond = Condition{}; |
| 302 | 302 | ||
| ... | @@ -317,7 +317,7 @@ test "Condition - smoke test" { | ... | @@ -317,7 +317,7 @@ test "Condition - smoke test" { |
| 317 | } | 317 | } |
| 318 | 318 | ||
| 319 | // Inspired from: https://github.com/Amanieu/parking_lot/pull/129 | 319 | // Inspired from: https://github.com/Amanieu/parking_lot/pull/129 |
| 320 | test "Condition - wait and signal" { | 320 | test "wait and signal" { |
| 321 | // This test requires spawning threads | 321 | // This test requires spawning threads |
| 322 | if (builtin.single_threaded) { | 322 | if (builtin.single_threaded) { |
| 323 | return error.SkipZigTest; | 323 | return error.SkipZigTest; |
| ... | @@ -362,7 +362,7 @@ test "Condition - wait and signal" { | ... | @@ -362,7 +362,7 @@ test "Condition - wait and signal" { |
| 362 | } | 362 | } |
| 363 | } | 363 | } |
| 364 | 364 | ||
| 365 | test "Condition - 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; |
| ... | @@ -429,7 +429,7 @@ test "Condition - signal" { | ... | @@ -429,7 +429,7 @@ test "Condition - signal" { |
| 429 | } | 429 | } |
| 430 | } | 430 | } |
| 431 | 431 | ||
| 432 | test "Condition - multi signal" { | 432 | test "multi signal" { |
| 433 | // This test requires spawning threads | 433 | // This test requires spawning threads |
| 434 | if (builtin.single_threaded) { | 434 | if (builtin.single_threaded) { |
| 435 | return error.SkipZigTest; | 435 | return error.SkipZigTest; |
| ... | @@ -491,7 +491,7 @@ test "Condition - multi signal" { | ... | @@ -491,7 +491,7 @@ test "Condition - multi signal" { |
| 491 | } | 491 | } |
| 492 | } | 492 | } |
| 493 | 493 | ||
| 494 | test "Condition - broadcasting" { | 494 | test "broadcasting" { |
| 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; |
| ... | @@ -557,7 +557,7 @@ test "Condition - broadcasting" { | ... | @@ -557,7 +557,7 @@ test "Condition - broadcasting" { |
| 557 | } | 557 | } |
| 558 | } | 558 | } |
| 559 | 559 | ||
| 560 | test "Condition - broadcasting - wake all threads" { | 560 | test "broadcasting - wake all threads" { |
| 561 | // Tests issue #12877 | 561 | // Tests issue #12877 |
| 562 | // This test requires spawning threads | 562 | // This test requires spawning threads |
| 563 | if (builtin.single_threaded) { | 563 | if (builtin.single_threaded) { |
lib/std/Thread/Futex.zig+4-4| ... | @@ -881,7 +881,7 @@ const PosixImpl = struct { | ... | @@ -881,7 +881,7 @@ const PosixImpl = struct { |
| 881 | } | 881 | } |
| 882 | }; | 882 | }; |
| 883 | 883 | ||
| 884 | test "Futex - smoke test" { | 884 | test "smoke test" { |
| 885 | var value = atomic.Value(u32).init(0); | 885 | var value = atomic.Value(u32).init(0); |
| 886 | 886 | ||
| 887 | // Try waits with invalid values. | 887 | // Try waits with invalid values. |
| ... | @@ -898,7 +898,7 @@ test "Futex - smoke test" { | ... | @@ -898,7 +898,7 @@ test "Futex - smoke test" { |
| 898 | Futex.wake(&value, std.math.maxInt(u32)); | 898 | Futex.wake(&value, std.math.maxInt(u32)); |
| 899 | } | 899 | } |
| 900 | 900 | ||
| 901 | test "Futex - signaling" { | 901 | test "signaling" { |
| 902 | // This test requires spawning threads | 902 | // This test requires spawning threads |
| 903 | if (builtin.single_threaded) { | 903 | if (builtin.single_threaded) { |
| 904 | return error.SkipZigTest; | 904 | return error.SkipZigTest; |
| ... | @@ -952,7 +952,7 @@ test "Futex - signaling" { | ... | @@ -952,7 +952,7 @@ test "Futex - signaling" { |
| 952 | for (paddles) |p| try testing.expectEqual(p.current, num_iterations); | 952 | for (paddles) |p| try testing.expectEqual(p.current, num_iterations); |
| 953 | } | 953 | } |
| 954 | 954 | ||
| 955 | test "Futex - broadcasting" { | 955 | test "broadcasting" { |
| 956 | // This test requires spawning threads | 956 | // This test requires spawning threads |
| 957 | if (builtin.single_threaded) { | 957 | if (builtin.single_threaded) { |
| 958 | return error.SkipZigTest; | 958 | return error.SkipZigTest; |
| ... | @@ -1054,7 +1054,7 @@ pub const Deadline = struct { | ... | @@ -1054,7 +1054,7 @@ pub const Deadline = struct { |
| 1054 | } | 1054 | } |
| 1055 | }; | 1055 | }; |
| 1056 | 1056 | ||
| 1057 | test "Futex - Deadline" { | 1057 | test "Deadline" { |
| 1058 | var deadline = Deadline.init(100 * std.time.ns_per_ms); | 1058 | var deadline = Deadline.init(100 * std.time.ns_per_ms); |
| 1059 | var futex_word = atomic.Value(u32).init(0); | 1059 | var futex_word = atomic.Value(u32).init(0); |
| 1060 | 1060 |
lib/std/Thread/Mutex.zig+3-3| ... | @@ -215,7 +215,7 @@ const FutexImpl = struct { | ... | @@ -215,7 +215,7 @@ const FutexImpl = struct { |
| 215 | } | 215 | } |
| 216 | }; | 216 | }; |
| 217 | 217 | ||
| 218 | test "Mutex - smoke test" { | 218 | test "smoke test" { |
| 219 | var mutex = Mutex{}; | 219 | var mutex = Mutex{}; |
| 220 | 220 | ||
| 221 | try testing.expect(mutex.tryLock()); | 221 | try testing.expect(mutex.tryLock()); |
| ... | @@ -243,7 +243,7 @@ const NonAtomicCounter = struct { | ... | @@ -243,7 +243,7 @@ const NonAtomicCounter = struct { |
| 243 | } | 243 | } |
| 244 | }; | 244 | }; |
| 245 | 245 | ||
| 246 | test "Mutex - many uncontended" { | 246 | test "many uncontended" { |
| 247 | // This test requires spawning threads. | 247 | // This test requires spawning threads. |
| 248 | if (builtin.single_threaded) { | 248 | if (builtin.single_threaded) { |
| 249 | return error.SkipZigTest; | 249 | return error.SkipZigTest; |
| ... | @@ -274,7 +274,7 @@ test "Mutex - many uncontended" { | ... | @@ -274,7 +274,7 @@ test "Mutex - many uncontended" { |
| 274 | for (runners) |r| try testing.expectEqual(r.counter.get(), num_increments); | 274 | for (runners) |r| try testing.expectEqual(r.counter.get(), num_increments); |
| 275 | } | 275 | } |
| 276 | 276 | ||
| 277 | test "Mutex - many contended" { | 277 | test "many contended" { |
| 278 | // This test requires spawning threads. | 278 | // This test requires spawning threads. |
| 279 | if (builtin.single_threaded) { | 279 | if (builtin.single_threaded) { |
| 280 | return error.SkipZigTest; | 280 | return error.SkipZigTest; |
lib/std/Thread/ResetEvent.zig+3-3| ... | @@ -157,7 +157,7 @@ const FutexImpl = struct { | ... | @@ -157,7 +157,7 @@ const FutexImpl = struct { |
| 157 | } | 157 | } |
| 158 | }; | 158 | }; |
| 159 | 159 | ||
| 160 | test "ResetEvent - smoke test" { | 160 | test "smoke test" { |
| 161 | // make sure the event is unset | 161 | // make sure the event is unset |
| 162 | var event = ResetEvent{}; | 162 | var event = ResetEvent{}; |
| 163 | try testing.expectEqual(false, event.isSet()); | 163 | try testing.expectEqual(false, event.isSet()); |
| ... | @@ -181,7 +181,7 @@ test "ResetEvent - smoke test" { | ... | @@ -181,7 +181,7 @@ test "ResetEvent - smoke test" { |
| 181 | try testing.expectEqual(true, event.isSet()); | 181 | try testing.expectEqual(true, event.isSet()); |
| 182 | } | 182 | } |
| 183 | 183 | ||
| 184 | test "ResetEvent - signaling" { | 184 | test "signaling" { |
| 185 | // This test requires spawning threads | 185 | // This test requires spawning threads |
| 186 | if (builtin.single_threaded) { | 186 | if (builtin.single_threaded) { |
| 187 | return error.SkipZigTest; | 187 | return error.SkipZigTest; |
| ... | @@ -242,7 +242,7 @@ test "ResetEvent - signaling" { | ... | @@ -242,7 +242,7 @@ test "ResetEvent - signaling" { |
| 242 | try ctx.input(); | 242 | try ctx.input(); |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | test "ResetEvent - broadcast" { | 245 | test "broadcast" { |
| 246 | // This test requires spawning threads | 246 | // This test requires spawning threads |
| 247 | if (builtin.single_threaded) { | 247 | if (builtin.single_threaded) { |
| 248 | return error.SkipZigTest; | 248 | return error.SkipZigTest; |
lib/std/Thread/RwLock.zig+2-2| ... | @@ -264,7 +264,7 @@ test "DefaultRwLock - internal state" { | ... | @@ -264,7 +264,7 @@ test "DefaultRwLock - internal state" { |
| 264 | try testing.expectEqual(rwl, DefaultRwLock{}); | 264 | try testing.expectEqual(rwl, DefaultRwLock{}); |
| 265 | } | 265 | } |
| 266 | 266 | ||
| 267 | test "RwLock - smoke test" { | 267 | test "smoke test" { |
| 268 | var rwl = RwLock{}; | 268 | var rwl = RwLock{}; |
| 269 | 269 | ||
| 270 | rwl.lock(); | 270 | rwl.lock(); |
| ... | @@ -293,7 +293,7 @@ test "RwLock - smoke test" { | ... | @@ -293,7 +293,7 @@ test "RwLock - smoke test" { |
| 293 | rwl.unlock(); | 293 | rwl.unlock(); |
| 294 | } | 294 | } |
| 295 | 295 | ||
| 296 | test "RwLock - concurrent access" { | 296 | test "concurrent access" { |
| 297 | if (builtin.single_threaded) | 297 | if (builtin.single_threaded) |
| 298 | return; | 298 | return; |
| 299 | 299 |
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 "Thread.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 "Thread.Semaphore" { | ... | @@ -97,7 +97,7 @@ test "Thread.Semaphore" { |
| 97 | try testing.expect(n == num_threads); | 97 | try testing.expect(n == num_threads); |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | test "Thread.Semaphore - 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/array_list.zig+60-51| ... | @@ -1231,7 +1231,7 @@ fn addOrOom(a: usize, b: usize) error{OutOfMemory}!usize { | ... | @@ -1231,7 +1231,7 @@ fn addOrOom(a: usize, b: usize) error{OutOfMemory}!usize { |
| 1231 | return result; | 1231 | return result; |
| 1232 | } | 1232 | } |
| 1233 | 1233 | ||
| 1234 | test "std.ArrayList/ArrayListUnmanaged.init" { | 1234 | test "init" { |
| 1235 | { | 1235 | { |
| 1236 | var list = ArrayList(i32).init(testing.allocator); | 1236 | var list = ArrayList(i32).init(testing.allocator); |
| 1237 | defer list.deinit(); | 1237 | defer list.deinit(); |
| ... | @@ -1248,7 +1248,7 @@ test "std.ArrayList/ArrayListUnmanaged.init" { | ... | @@ -1248,7 +1248,7 @@ test "std.ArrayList/ArrayListUnmanaged.init" { |
| 1248 | } | 1248 | } |
| 1249 | } | 1249 | } |
| 1250 | 1250 | ||
| 1251 | test "std.ArrayList/ArrayListUnmanaged.initCapacity" { | 1251 | test "initCapacity" { |
| 1252 | const a = testing.allocator; | 1252 | const a = testing.allocator; |
| 1253 | { | 1253 | { |
| 1254 | var list = try ArrayList(i8).initCapacity(a, 200); | 1254 | var list = try ArrayList(i8).initCapacity(a, 200); |
| ... | @@ -1264,7 +1264,7 @@ test "std.ArrayList/ArrayListUnmanaged.initCapacity" { | ... | @@ -1264,7 +1264,7 @@ test "std.ArrayList/ArrayListUnmanaged.initCapacity" { |
| 1264 | } | 1264 | } |
| 1265 | } | 1265 | } |
| 1266 | 1266 | ||
| 1267 | test "std.ArrayList/ArrayListUnmanaged.clone" { | 1267 | test "clone" { |
| 1268 | const a = testing.allocator; | 1268 | const a = testing.allocator; |
| 1269 | { | 1269 | { |
| 1270 | var array = ArrayList(i32).init(a); | 1270 | var array = ArrayList(i32).init(a); |
| ... | @@ -1305,7 +1305,7 @@ test "std.ArrayList/ArrayListUnmanaged.clone" { | ... | @@ -1305,7 +1305,7 @@ test "std.ArrayList/ArrayListUnmanaged.clone" { |
| 1305 | } | 1305 | } |
| 1306 | } | 1306 | } |
| 1307 | 1307 | ||
| 1308 | test "std.ArrayList/ArrayListUnmanaged.basic" { | 1308 | test "basic" { |
| 1309 | const a = testing.allocator; | 1309 | const a = testing.allocator; |
| 1310 | { | 1310 | { |
| 1311 | var list = ArrayList(i32).init(a); | 1311 | var list = ArrayList(i32).init(a); |
| ... | @@ -1409,7 +1409,7 @@ test "std.ArrayList/ArrayListUnmanaged.basic" { | ... | @@ -1409,7 +1409,7 @@ test "std.ArrayList/ArrayListUnmanaged.basic" { |
| 1409 | } | 1409 | } |
| 1410 | } | 1410 | } |
| 1411 | 1411 | ||
| 1412 | test "std.ArrayList/ArrayListUnmanaged.appendNTimes" { | 1412 | test "appendNTimes" { |
| 1413 | const a = testing.allocator; | 1413 | const a = testing.allocator; |
| 1414 | { | 1414 | { |
| 1415 | var list = ArrayList(i32).init(a); | 1415 | var list = ArrayList(i32).init(a); |
| ... | @@ -1433,7 +1433,7 @@ test "std.ArrayList/ArrayListUnmanaged.appendNTimes" { | ... | @@ -1433,7 +1433,7 @@ test "std.ArrayList/ArrayListUnmanaged.appendNTimes" { |
| 1433 | } | 1433 | } |
| 1434 | } | 1434 | } |
| 1435 | 1435 | ||
| 1436 | test "std.ArrayList/ArrayListUnmanaged.appendNTimes with failing allocator" { | 1436 | test "appendNTimes with failing allocator" { |
| 1437 | const a = testing.failing_allocator; | 1437 | const a = testing.failing_allocator; |
| 1438 | { | 1438 | { |
| 1439 | var list = ArrayList(i32).init(a); | 1439 | var list = ArrayList(i32).init(a); |
| ... | @@ -1447,7 +1447,7 @@ test "std.ArrayList/ArrayListUnmanaged.appendNTimes with failing allocator" { | ... | @@ -1447,7 +1447,7 @@ test "std.ArrayList/ArrayListUnmanaged.appendNTimes with failing allocator" { |
| 1447 | } | 1447 | } |
| 1448 | } | 1448 | } |
| 1449 | 1449 | ||
| 1450 | test "std.ArrayList/ArrayListUnmanaged.orderedRemove" { | 1450 | test "orderedRemove" { |
| 1451 | const a = testing.allocator; | 1451 | const a = testing.allocator; |
| 1452 | { | 1452 | { |
| 1453 | var list = ArrayList(i32).init(a); | 1453 | var list = ArrayList(i32).init(a); |
| ... | @@ -1519,7 +1519,7 @@ test "std.ArrayList/ArrayListUnmanaged.orderedRemove" { | ... | @@ -1519,7 +1519,7 @@ test "std.ArrayList/ArrayListUnmanaged.orderedRemove" { |
| 1519 | } | 1519 | } |
| 1520 | } | 1520 | } |
| 1521 | 1521 | ||
| 1522 | test "std.ArrayList/ArrayListUnmanaged.swapRemove" { | 1522 | test "swapRemove" { |
| 1523 | const a = testing.allocator; | 1523 | const a = testing.allocator; |
| 1524 | { | 1524 | { |
| 1525 | var list = ArrayList(i32).init(a); | 1525 | var list = ArrayList(i32).init(a); |
| ... | @@ -1575,7 +1575,7 @@ test "std.ArrayList/ArrayListUnmanaged.swapRemove" { | ... | @@ -1575,7 +1575,7 @@ test "std.ArrayList/ArrayListUnmanaged.swapRemove" { |
| 1575 | } | 1575 | } |
| 1576 | } | 1576 | } |
| 1577 | 1577 | ||
| 1578 | test "std.ArrayList/ArrayListUnmanaged.insert" { | 1578 | test "insert" { |
| 1579 | const a = testing.allocator; | 1579 | const a = testing.allocator; |
| 1580 | { | 1580 | { |
| 1581 | var list = ArrayList(i32).init(a); | 1581 | var list = ArrayList(i32).init(a); |
| ... | @@ -1605,7 +1605,7 @@ test "std.ArrayList/ArrayListUnmanaged.insert" { | ... | @@ -1605,7 +1605,7 @@ test "std.ArrayList/ArrayListUnmanaged.insert" { |
| 1605 | } | 1605 | } |
| 1606 | } | 1606 | } |
| 1607 | 1607 | ||
| 1608 | test "std.ArrayList/ArrayListUnmanaged.insertSlice" { | 1608 | test "insertSlice" { |
| 1609 | const a = testing.allocator; | 1609 | const a = testing.allocator; |
| 1610 | { | 1610 | { |
| 1611 | var list = ArrayList(i32).init(a); | 1611 | var list = ArrayList(i32).init(a); |
| ... | @@ -1651,7 +1651,7 @@ test "std.ArrayList/ArrayListUnmanaged.insertSlice" { | ... | @@ -1651,7 +1651,7 @@ test "std.ArrayList/ArrayListUnmanaged.insertSlice" { |
| 1651 | } | 1651 | } |
| 1652 | } | 1652 | } |
| 1653 | 1653 | ||
| 1654 | test "std.ArrayList/ArrayListUnmanaged.replaceRange" { | 1654 | test "replaceRange" { |
| 1655 | var arena = std.heap.ArenaAllocator.init(testing.allocator); | 1655 | var arena = std.heap.ArenaAllocator.init(testing.allocator); |
| 1656 | defer arena.deinit(); | 1656 | defer arena.deinit(); |
| 1657 | const a = arena.allocator(); | 1657 | const a = arena.allocator(); |
| ... | @@ -1773,7 +1773,7 @@ const ItemUnmanaged = struct { | ... | @@ -1773,7 +1773,7 @@ const ItemUnmanaged = struct { |
| 1773 | sub_items: ArrayListUnmanaged(ItemUnmanaged), | 1773 | sub_items: ArrayListUnmanaged(ItemUnmanaged), |
| 1774 | }; | 1774 | }; |
| 1775 | 1775 | ||
| 1776 | test "std.ArrayList/ArrayListUnmanaged: ArrayList(T) of struct T" { | 1776 | test "ArrayList(T) of struct T" { |
| 1777 | const a = std.testing.allocator; | 1777 | const a = std.testing.allocator; |
| 1778 | { | 1778 | { |
| 1779 | var root = Item{ .integer = 1, .sub_items = ArrayList(Item).init(a) }; | 1779 | var root = Item{ .integer = 1, .sub_items = ArrayList(Item).init(a) }; |
| ... | @@ -1789,7 +1789,7 @@ test "std.ArrayList/ArrayListUnmanaged: ArrayList(T) of struct T" { | ... | @@ -1789,7 +1789,7 @@ test "std.ArrayList/ArrayListUnmanaged: ArrayList(T) of struct T" { |
| 1789 | } | 1789 | } |
| 1790 | } | 1790 | } |
| 1791 | 1791 | ||
| 1792 | test "std.ArrayList(u8)/ArrayListAligned implements writer" { | 1792 | test "ArrayList(u8) implements writer" { |
| 1793 | const a = testing.allocator; | 1793 | const a = testing.allocator; |
| 1794 | 1794 | ||
| 1795 | { | 1795 | { |
| ... | @@ -1816,7 +1816,7 @@ test "std.ArrayList(u8)/ArrayListAligned implements writer" { | ... | @@ -1816,7 +1816,7 @@ test "std.ArrayList(u8)/ArrayListAligned implements writer" { |
| 1816 | } | 1816 | } |
| 1817 | } | 1817 | } |
| 1818 | 1818 | ||
| 1819 | test "std.ArrayListUnmanaged(u8) implements writer" { | 1819 | test "ArrayListUnmanaged(u8) implements writer" { |
| 1820 | const a = testing.allocator; | 1820 | const a = testing.allocator; |
| 1821 | 1821 | ||
| 1822 | { | 1822 | { |
| ... | @@ -1883,7 +1883,7 @@ test "shrinkAndFree with a copy" { | ... | @@ -1883,7 +1883,7 @@ test "shrinkAndFree with a copy" { |
| 1883 | try testing.expect(mem.eql(i32, list.items, &.{ 3, 3, 3, 3 })); | 1883 | try testing.expect(mem.eql(i32, list.items, &.{ 3, 3, 3, 3 })); |
| 1884 | } | 1884 | } |
| 1885 | 1885 | ||
| 1886 | test "std.ArrayList/ArrayListUnmanaged.addManyAsArray" { | 1886 | test "addManyAsArray" { |
| 1887 | const a = std.testing.allocator; | 1887 | const a = std.testing.allocator; |
| 1888 | { | 1888 | { |
| 1889 | var list = ArrayList(u8).init(a); | 1889 | var list = ArrayList(u8).init(a); |
| ... | @@ -1907,7 +1907,7 @@ test "std.ArrayList/ArrayListUnmanaged.addManyAsArray" { | ... | @@ -1907,7 +1907,7 @@ test "std.ArrayList/ArrayListUnmanaged.addManyAsArray" { |
| 1907 | } | 1907 | } |
| 1908 | } | 1908 | } |
| 1909 | 1909 | ||
| 1910 | test "std.ArrayList/ArrayListUnmanaged growing memory preserves contents" { | 1910 | test "growing memory preserves contents" { |
| 1911 | // Shrink the list after every insertion to ensure that a memory growth | 1911 | // Shrink the list after every insertion to ensure that a memory growth |
| 1912 | // will be triggered in the next operation. | 1912 | // will be triggered in the next operation. |
| 1913 | const a = std.testing.allocator; | 1913 | const a = std.testing.allocator; |
| ... | @@ -1941,46 +1941,55 @@ test "std.ArrayList/ArrayListUnmanaged growing memory preserves contents" { | ... | @@ -1941,46 +1941,55 @@ test "std.ArrayList/ArrayListUnmanaged growing memory preserves contents" { |
| 1941 | } | 1941 | } |
| 1942 | } | 1942 | } |
| 1943 | 1943 | ||
| 1944 | test "std.ArrayList/ArrayList.fromOwnedSliceSentinel" { | 1944 | test "fromOwnedSlice" { |
| 1945 | const a = testing.allocator; | ||
| 1946 | |||
| 1947 | var orig_list = ArrayList(u8).init(a); | ||
| 1948 | defer orig_list.deinit(); | ||
| 1949 | try orig_list.appendSlice("foobar"); | ||
| 1950 | const sentinel_slice = try orig_list.toOwnedSliceSentinel(0); | ||
| 1951 | |||
| 1952 | var list = ArrayList(u8).fromOwnedSliceSentinel(a, 0, sentinel_slice); | ||
| 1953 | defer list.deinit(); | ||
| 1954 | try testing.expectEqualStrings(list.items, "foobar"); | ||
| 1955 | } | ||
| 1956 | |||
| 1957 | test "std.ArrayList/ArrayListUnmanaged.fromOwnedSlice" { | ||
| 1958 | const a = testing.allocator; | 1945 | const a = testing.allocator; |
| 1946 | { | ||
| 1947 | var orig_list = ArrayList(u8).init(a); | ||
| 1948 | defer orig_list.deinit(); | ||
| 1949 | try orig_list.appendSlice("foobar"); | ||
| 1959 | 1950 | ||
| 1960 | var list = ArrayList(u8).init(a); | 1951 | const slice = try orig_list.toOwnedSlice(); |
| 1961 | defer list.deinit(); | 1952 | var list = ArrayList(u8).fromOwnedSlice(a, slice); |
| 1962 | try list.appendSlice("foobar"); | 1953 | defer list.deinit(); |
| 1954 | try testing.expectEqualStrings(list.items, "foobar"); | ||
| 1955 | } | ||
| 1956 | { | ||
| 1957 | var list = ArrayList(u8).init(a); | ||
| 1958 | defer list.deinit(); | ||
| 1959 | try list.appendSlice("foobar"); | ||
| 1963 | 1960 | ||
| 1964 | const slice = try list.toOwnedSlice(); | 1961 | const slice = try list.toOwnedSlice(); |
| 1965 | var unmanaged = ArrayListUnmanaged(u8).fromOwnedSlice(slice); | 1962 | var unmanaged = ArrayListUnmanaged(u8).fromOwnedSlice(slice); |
| 1966 | defer unmanaged.deinit(a); | 1963 | defer unmanaged.deinit(a); |
| 1967 | try testing.expectEqualStrings(unmanaged.items, "foobar"); | 1964 | try testing.expectEqualStrings(unmanaged.items, "foobar"); |
| 1965 | } | ||
| 1968 | } | 1966 | } |
| 1969 | 1967 | ||
| 1970 | test "std.ArrayList/ArrayListUnmanaged.fromOwnedSliceSentinel" { | 1968 | test "fromOwnedSliceSentinel" { |
| 1971 | const a = testing.allocator; | 1969 | const a = testing.allocator; |
| 1970 | { | ||
| 1971 | var orig_list = ArrayList(u8).init(a); | ||
| 1972 | defer orig_list.deinit(); | ||
| 1973 | try orig_list.appendSlice("foobar"); | ||
| 1972 | 1974 | ||
| 1973 | var list = ArrayList(u8).init(a); | 1975 | const sentinel_slice = try orig_list.toOwnedSliceSentinel(0); |
| 1974 | defer list.deinit(); | 1976 | var list = ArrayList(u8).fromOwnedSliceSentinel(a, 0, sentinel_slice); |
| 1975 | try list.appendSlice("foobar"); | 1977 | defer list.deinit(); |
| 1978 | try testing.expectEqualStrings(list.items, "foobar"); | ||
| 1979 | } | ||
| 1980 | { | ||
| 1981 | var list = ArrayList(u8).init(a); | ||
| 1982 | defer list.deinit(); | ||
| 1983 | try list.appendSlice("foobar"); | ||
| 1976 | 1984 | ||
| 1977 | const sentinel_slice = try list.toOwnedSliceSentinel(0); | 1985 | const sentinel_slice = try list.toOwnedSliceSentinel(0); |
| 1978 | var unmanaged = ArrayListUnmanaged(u8).fromOwnedSliceSentinel(0, sentinel_slice); | 1986 | var unmanaged = ArrayListUnmanaged(u8).fromOwnedSliceSentinel(0, sentinel_slice); |
| 1979 | defer unmanaged.deinit(a); | 1987 | defer unmanaged.deinit(a); |
| 1980 | try testing.expectEqualStrings(unmanaged.items, "foobar"); | 1988 | try testing.expectEqualStrings(unmanaged.items, "foobar"); |
| 1989 | } | ||
| 1981 | } | 1990 | } |
| 1982 | 1991 | ||
| 1983 | test "std.ArrayList/ArrayListUnmanaged.toOwnedSliceSentinel" { | 1992 | test "toOwnedSliceSentinel" { |
| 1984 | const a = testing.allocator; | 1993 | const a = testing.allocator; |
| 1985 | { | 1994 | { |
| 1986 | var list = ArrayList(u8).init(a); | 1995 | var list = ArrayList(u8).init(a); |
| ... | @@ -2004,7 +2013,7 @@ test "std.ArrayList/ArrayListUnmanaged.toOwnedSliceSentinel" { | ... | @@ -2004,7 +2013,7 @@ test "std.ArrayList/ArrayListUnmanaged.toOwnedSliceSentinel" { |
| 2004 | } | 2013 | } |
| 2005 | } | 2014 | } |
| 2006 | 2015 | ||
| 2007 | test "ArrayListAligned/ArrayListAlignedUnmanaged accepts unaligned slices" { | 2016 | test "accepts unaligned slices" { |
| 2008 | const a = testing.allocator; | 2017 | const a = testing.allocator; |
| 2009 | { | 2018 | { |
| 2010 | var list = std.ArrayListAligned(u8, 8).init(a); | 2019 | var list = std.ArrayListAligned(u8, 8).init(a); |
| ... | @@ -2028,7 +2037,7 @@ test "ArrayListAligned/ArrayListAlignedUnmanaged accepts unaligned slices" { | ... | @@ -2028,7 +2037,7 @@ test "ArrayListAligned/ArrayListAlignedUnmanaged accepts unaligned slices" { |
| 2028 | } | 2037 | } |
| 2029 | } | 2038 | } |
| 2030 | 2039 | ||
| 2031 | test "std.ArrayList(u0)" { | 2040 | test "ArrayList(u0)" { |
| 2032 | // An ArrayList on zero-sized types should not need to allocate | 2041 | // An ArrayList on zero-sized types should not need to allocate |
| 2033 | const a = testing.failing_allocator; | 2042 | const a = testing.failing_allocator; |
| 2034 | 2043 | ||
| ... | @@ -2048,7 +2057,7 @@ test "std.ArrayList(u0)" { | ... | @@ -2048,7 +2057,7 @@ test "std.ArrayList(u0)" { |
| 2048 | try testing.expectEqual(count, 3); | 2057 | try testing.expectEqual(count, 3); |
| 2049 | } | 2058 | } |
| 2050 | 2059 | ||
| 2051 | test "std.ArrayList(?u32).popOrNull()" { | 2060 | test "ArrayList(?u32).popOrNull()" { |
| 2052 | const a = testing.allocator; | 2061 | const a = testing.allocator; |
| 2053 | 2062 | ||
| 2054 | var list = ArrayList(?u32).init(a); | 2063 | var list = ArrayList(?u32).init(a); |
| ... | @@ -2065,7 +2074,7 @@ test "std.ArrayList(?u32).popOrNull()" { | ... | @@ -2065,7 +2074,7 @@ test "std.ArrayList(?u32).popOrNull()" { |
| 2065 | try testing.expect(list.popOrNull() == null); | 2074 | try testing.expect(list.popOrNull() == null); |
| 2066 | } | 2075 | } |
| 2067 | 2076 | ||
| 2068 | test "std.ArrayList(u32).getLast()" { | 2077 | test "ArrayList(u32).getLast()" { |
| 2069 | const a = testing.allocator; | 2078 | const a = testing.allocator; |
| 2070 | 2079 | ||
| 2071 | var list = ArrayList(u32).init(a); | 2080 | var list = ArrayList(u32).init(a); |
| ... | @@ -2076,7 +2085,7 @@ test "std.ArrayList(u32).getLast()" { | ... | @@ -2076,7 +2085,7 @@ test "std.ArrayList(u32).getLast()" { |
| 2076 | try testing.expectEqual(const_list.getLast(), 2); | 2085 | try testing.expectEqual(const_list.getLast(), 2); |
| 2077 | } | 2086 | } |
| 2078 | 2087 | ||
| 2079 | test "std.ArrayList(u32).getLastOrNull()" { | 2088 | test "ArrayList(u32).getLastOrNull()" { |
| 2080 | const a = testing.allocator; | 2089 | const a = testing.allocator; |
| 2081 | 2090 | ||
| 2082 | var list = ArrayList(u32).init(a); | 2091 | var list = ArrayList(u32).init(a); |
lib/std/buf_set.zig+3-3| ... | @@ -101,7 +101,7 @@ pub const BufSet = struct { | ... | @@ -101,7 +101,7 @@ pub const BufSet = struct { |
| 101 | } | 101 | } |
| 102 | }; | 102 | }; |
| 103 | 103 | ||
| 104 | test "BufSet" { | 104 | test BufSet { |
| 105 | var bufset = BufSet.init(std.testing.allocator); | 105 | var bufset = BufSet.init(std.testing.allocator); |
| 106 | defer bufset.deinit(); | 106 | defer bufset.deinit(); |
| 107 | 107 | ||
| ... | @@ -115,7 +115,7 @@ test "BufSet" { | ... | @@ -115,7 +115,7 @@ test "BufSet" { |
| 115 | try bufset.insert("z"); | 115 | try bufset.insert("z"); |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | test "BufSet clone" { | 118 | test "clone" { |
| 119 | var original = BufSet.init(testing.allocator); | 119 | var original = BufSet.init(testing.allocator); |
| 120 | defer original.deinit(); | 120 | defer original.deinit(); |
| 121 | try original.insert("x"); | 121 | try original.insert("x"); |
| ... | @@ -132,7 +132,7 @@ test "BufSet clone" { | ... | @@ -132,7 +132,7 @@ test "BufSet clone" { |
| 132 | ); | 132 | ); |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | test "BufSet.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); |
| 138 | defer arena.deinit(); | 138 | defer arena.deinit(); |
lib/std/compress/flate.zig+5-5| ... | @@ -84,7 +84,7 @@ test { | ... | @@ -84,7 +84,7 @@ test { |
| 84 | _ = inflate; | 84 | _ = inflate; |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | test "flate compress/decompress" { | 87 | test "compress/decompress" { |
| 88 | if (builtin.target.cpu.arch == .wasm32) return error.SkipZigTest; | 88 | if (builtin.target.cpu.arch == .wasm32) return error.SkipZigTest; |
| 89 | 89 | ||
| 90 | var cmp_buf: [64 * 1024]u8 = undefined; // compressed data buffer | 90 | var cmp_buf: [64 * 1024]u8 = undefined; // compressed data buffer |
| ... | @@ -252,7 +252,7 @@ fn testDecompress(comptime container: Container, compressed: []const u8, expecte | ... | @@ -252,7 +252,7 @@ fn testDecompress(comptime container: Container, compressed: []const u8, expecte |
| 252 | try testing.expectEqualSlices(u8, expected_plain, out.items); | 252 | try testing.expectEqualSlices(u8, expected_plain, out.items); |
| 253 | } | 253 | } |
| 254 | 254 | ||
| 255 | test "flate don't read past deflate stream's end" { | 255 | test "don't read past deflate stream's end" { |
| 256 | try testDecompress(.zlib, &[_]u8{ | 256 | try testDecompress(.zlib, &[_]u8{ |
| 257 | 0x08, 0xd7, 0x63, 0xf8, 0xcf, 0xc0, 0xc0, 0x00, 0xc1, 0xff, | 257 | 0x08, 0xd7, 0x63, 0xf8, 0xcf, 0xc0, 0xc0, 0x00, 0xc1, 0xff, |
| 258 | 0xff, 0x43, 0x30, 0x03, 0x03, 0xc3, 0xff, 0xff, 0xff, 0x01, | 258 | 0xff, 0x43, 0x30, 0x03, 0x03, 0xc3, 0xff, 0xff, 0xff, 0x01, |
| ... | @@ -264,7 +264,7 @@ test "flate don't read past deflate stream's end" { | ... | @@ -264,7 +264,7 @@ test "flate don't read past deflate stream's end" { |
| 264 | }); | 264 | }); |
| 265 | } | 265 | } |
| 266 | 266 | ||
| 267 | test "flate zlib header" { | 267 | test "zlib header" { |
| 268 | // Truncated header | 268 | // Truncated header |
| 269 | try testing.expectError( | 269 | try testing.expectError( |
| 270 | error.EndOfStream, | 270 | error.EndOfStream, |
| ... | @@ -292,7 +292,7 @@ test "flate zlib header" { | ... | @@ -292,7 +292,7 @@ test "flate zlib header" { |
| 292 | ); | 292 | ); |
| 293 | } | 293 | } |
| 294 | 294 | ||
| 295 | test "flate gzip header" { | 295 | test "gzip header" { |
| 296 | // Truncated header | 296 | // Truncated header |
| 297 | try testing.expectError( | 297 | try testing.expectError( |
| 298 | error.EndOfStream, | 298 | error.EndOfStream, |
| ... | @@ -353,7 +353,7 @@ test "flate gzip header" { | ... | @@ -353,7 +353,7 @@ test "flate gzip header" { |
| 353 | }, ""); | 353 | }, ""); |
| 354 | } | 354 | } |
| 355 | 355 | ||
| 356 | test "flate public interface" { | 356 | test "public interface" { |
| 357 | if (builtin.target.cpu.arch == .wasm32) return error.SkipZigTest; | 357 | if (builtin.target.cpu.arch == .wasm32) return error.SkipZigTest; |
| 358 | 358 | ||
| 359 | const plain_data = [_]u8{ 'H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', 0x0a }; | 359 | const plain_data = [_]u8{ 'H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', 0x0a }; |
lib/std/compress/flate/CircularBuffer.zig+6-6| ... | @@ -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 "flate.CircularBuffer writeMatch" { | 133 | test "writeMatch" { |
| 134 | var cb: Self = .{}; | 134 | var cb: Self = .{}; |
| 135 | 135 | ||
| 136 | cb.writeAll("a salad; "); | 136 | cb.writeAll("a salad; "); |
| ... | @@ -140,7 +140,7 @@ test "flate.CircularBuffer writeMatch" { | ... | @@ -140,7 +140,7 @@ test "flate.CircularBuffer writeMatch" { |
| 140 | try testing.expectEqualStrings("a salad; a salsal", cb.read()); | 140 | try testing.expectEqualStrings("a salad; a salsal", cb.read()); |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | test "flate.CircularBuffer writeMatch overlap" { | 143 | test "writeMatch overlap" { |
| 144 | var cb: Self = .{}; | 144 | var cb: Self = .{}; |
| 145 | 145 | ||
| 146 | cb.writeAll("a b c "); | 146 | cb.writeAll("a b c "); |
| ... | @@ -150,7 +150,7 @@ test "flate.CircularBuffer writeMatch overlap" { | ... | @@ -150,7 +150,7 @@ test "flate.CircularBuffer 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 "flate.CircularBuffer 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 "flate.CircularBuffer readAtMost" { | ... | @@ -165,7 +165,7 @@ test "flate.CircularBuffer readAtMost" { |
| 165 | try testing.expectEqualStrings("", cb.read()); | 165 | try testing.expectEqualStrings("", cb.read()); |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | test "flate.CircularBuffer" { | 168 | test "CircularBuffer" { |
| 169 | var cb: Self = .{}; | 169 | var cb: Self = .{}; |
| 170 | 170 | ||
| 171 | const data = "0123456789abcdef" ** (1024 / 16); | 171 | const data = "0123456789abcdef" ** (1024 / 16); |
| ... | @@ -201,7 +201,7 @@ test "flate.CircularBuffer" { | ... | @@ -201,7 +201,7 @@ test "flate.CircularBuffer" { |
| 201 | try testing.expectEqual(@as(usize, 200), cb.read().len); // read the rest | 201 | try testing.expectEqual(@as(usize, 200), cb.read().len); // read the rest |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | test "flate.CircularBuffer write overlap" { | 204 | test "write overlap" { |
| 205 | var cb: Self = .{}; | 205 | var cb: Self = .{}; |
| 206 | cb.wp = cb.buffer.len - 15; | 206 | cb.wp = cb.buffer.len - 15; |
| 207 | cb.rp = cb.wp; | 207 | cb.rp = cb.wp; |
| ... | @@ -218,7 +218,7 @@ test "flate.CircularBuffer write overlap" { | ... | @@ -218,7 +218,7 @@ test "flate.CircularBuffer write overlap" { |
| 218 | try testing.expect(cb.wp == cb.rp); | 218 | try testing.expect(cb.wp == cb.rp); |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | test "flate.CircularBuffer writeMatch/read overlap" { | 221 | test "writeMatch/read overlap" { |
| 222 | var cb: Self = .{}; | 222 | var cb: Self = .{}; |
| 223 | cb.wp = cb.buffer.len - 15; | 223 | cb.wp = cb.buffer.len - 15; |
| 224 | cb.rp = cb.wp; | 224 | cb.rp = cb.wp; |
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 "flate.Lookup add/prev" { | 86 | test "add/prev" { |
| 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 "flate.Lookup add/prev" { | ... | @@ -107,7 +107,7 @@ test "flate.Lookup add/prev" { |
| 107 | try expect(h.chain[2 + 8] == 2); | 107 | try expect(h.chain[2 + 8] == 2); |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | test "flate.Lookup 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 "flate.SlidingWindow 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 "flate.SlidingWindow match" { | ... | @@ -142,7 +142,7 @@ test "flate.SlidingWindow 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 "flate.SlidingWindow 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/Token.zig+4-4| ... | @@ -275,12 +275,12 @@ const match_distances = [_]MatchDistance{ | ... | @@ -275,12 +275,12 @@ const match_distances = [_]MatchDistance{ |
| 275 | .{ .extra_bits = 13, .base_scaled = 0x6000, .code = 29, .base = 24577 }, | 275 | .{ .extra_bits = 13, .base_scaled = 0x6000, .code = 29, .base = 24577 }, |
| 276 | }; | 276 | }; |
| 277 | 277 | ||
| 278 | test "flate.Token size" { | 278 | test "size" { |
| 279 | try expect(@sizeOf(Token) == 4); | 279 | try expect(@sizeOf(Token) == 4); |
| 280 | } | 280 | } |
| 281 | 281 | ||
| 282 | // testing table https://datatracker.ietf.org/doc/html/rfc1951#page-12 | 282 | // testing table https://datatracker.ietf.org/doc/html/rfc1951#page-12 |
| 283 | test "flate.Token MatchLength" { | 283 | test "MatchLength" { |
| 284 | var c = Token.initMatch(1, 4).lengthEncoding(); | 284 | var c = Token.initMatch(1, 4).lengthEncoding(); |
| 285 | try expect(c.code == 258); | 285 | try expect(c.code == 258); |
| 286 | try expect(c.extra_bits == 0); | 286 | try expect(c.extra_bits == 0); |
| ... | @@ -302,7 +302,7 @@ test "flate.Token MatchLength" { | ... | @@ -302,7 +302,7 @@ test "flate.Token MatchLength" { |
| 302 | try expect(c.extra_length == 130 - 115); | 302 | try expect(c.extra_length == 130 - 115); |
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | test "flate.Token MatchDistance" { | 305 | test "MatchDistance" { |
| 306 | var c = Token.initMatch(1, 4).distanceEncoding(); | 306 | var c = Token.initMatch(1, 4).distanceEncoding(); |
| 307 | try expect(c.code == 0); | 307 | try expect(c.code == 0); |
| 308 | try expect(c.extra_bits == 0); | 308 | try expect(c.extra_bits == 0); |
| ... | @@ -314,7 +314,7 @@ test "flate.Token MatchDistance" { | ... | @@ -314,7 +314,7 @@ test "flate.Token MatchDistance" { |
| 314 | try expect(c.extra_distance == 192 - 129); | 314 | try expect(c.extra_distance == 192 - 129); |
| 315 | } | 315 | } |
| 316 | 316 | ||
| 317 | test "flate.Token match_lengths" { | 317 | test "match_lengths" { |
| 318 | for (match_lengths, 0..) |ml, i| { | 318 | for (match_lengths, 0..) |ml, i| { |
| 319 | try expect(@as(u16, ml.base_scaled) + 3 == ml.base); | 319 | try expect(@as(u16, ml.base_scaled) + 3 == ml.base); |
| 320 | try expect(i + 257 == ml.code); | 320 | try expect(i + 257 == ml.code); |
lib/std/compress/flate/bit_reader.zig+5-5| ... | @@ -218,7 +218,7 @@ pub fn BitReader(comptime ReaderType: type) type { | ... | @@ -218,7 +218,7 @@ pub fn BitReader(comptime ReaderType: type) type { |
| 218 | }; | 218 | }; |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | test "flate.BitReader" { | 221 | test "BitReader" { |
| 222 | var fbs = std.io.fixedBufferStream(&[_]u8{ 0xf3, 0x48, 0xcd, 0xc9, 0x00, 0x00 }); | 222 | var fbs = std.io.fixedBufferStream(&[_]u8{ 0xf3, 0x48, 0xcd, 0xc9, 0x00, 0x00 }); |
| 223 | var br = bitReader(fbs.reader()); | 223 | var br = bitReader(fbs.reader()); |
| 224 | const F = BitReader(@TypeOf(fbs.reader())).flag; | 224 | const F = BitReader(@TypeOf(fbs.reader())).flag; |
| ... | @@ -253,7 +253,7 @@ test "flate.BitReader" { | ... | @@ -253,7 +253,7 @@ test "flate.BitReader" { |
| 253 | try testing.expectEqual(@as(u16, 0xc), try br.readN(4, 0)); | 253 | try testing.expectEqual(@as(u16, 0xc), try br.readN(4, 0)); |
| 254 | } | 254 | } |
| 255 | 255 | ||
| 256 | test "flate.BitReader read block type 1 data" { | 256 | test "read block type 1 data" { |
| 257 | const data = [_]u8{ | 257 | const data = [_]u8{ |
| 258 | 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0x57, 0x28, 0xcf, // deflate data block type 1 | 258 | 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0x57, 0x28, 0xcf, // deflate data block type 1 |
| 259 | 0x2f, 0xca, 0x49, 0xe1, 0x02, 0x00, | 259 | 0x2f, 0xca, 0x49, 0xe1, 0x02, 0x00, |
| ... | @@ -277,7 +277,7 @@ test "flate.BitReader read block type 1 data" { | ... | @@ -277,7 +277,7 @@ test "flate.BitReader read block type 1 data" { |
| 277 | try testing.expectEqual(@as(u16, 0xddcc), try br.readF(u16, 0)); | 277 | try testing.expectEqual(@as(u16, 0xddcc), try br.readF(u16, 0)); |
| 278 | } | 278 | } |
| 279 | 279 | ||
| 280 | test "flate.BitReader init" { | 280 | test "init" { |
| 281 | const data = [_]u8{ | 281 | const data = [_]u8{ |
| 282 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, | 282 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
| 283 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, | 283 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
| ... | @@ -302,7 +302,7 @@ test "flate.BitReader init" { | ... | @@ -302,7 +302,7 @@ test "flate.BitReader init" { |
| 302 | try testing.expectEqual(@as(u64, 0x00_00_00_00_00_08_07_06), br.bits); | 302 | try testing.expectEqual(@as(u64, 0x00_00_00_00_00_08_07_06), br.bits); |
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | test "flate.BitReader readAll" { | 305 | test "readAll" { |
| 306 | const data = [_]u8{ | 306 | const data = [_]u8{ |
| 307 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, | 307 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
| 308 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, | 308 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
| ... | @@ -320,7 +320,7 @@ test "flate.BitReader readAll" { | ... | @@ -320,7 +320,7 @@ test "flate.BitReader readAll" { |
| 320 | try testing.expectEqualSlices(u8, data[0..16], &out); | 320 | try testing.expectEqualSlices(u8, data[0..16], &out); |
| 321 | } | 321 | } |
| 322 | 322 | ||
| 323 | test "flate.BitReader readFixedCode" { | 323 | test "readFixedCode" { |
| 324 | const fixed_codes = @import("huffman_encoder.zig").fixed_codes; | 324 | const fixed_codes = @import("huffman_encoder.zig").fixed_codes; |
| 325 | 325 | ||
| 326 | var fbs = std.io.fixedBufferStream(&fixed_codes); | 326 | var fbs = std.io.fixedBufferStream(&fixed_codes); |
lib/std/compress/flate/block_writer.zig+3-3| ... | @@ -596,20 +596,20 @@ const TestCase = @import("testdata/block_writer.zig").TestCase; | ... | @@ -596,20 +596,20 @@ const TestCase = @import("testdata/block_writer.zig").TestCase; |
| 596 | const testCases = @import("testdata/block_writer.zig").testCases; | 596 | const testCases = @import("testdata/block_writer.zig").testCases; |
| 597 | 597 | ||
| 598 | // tests if the writeBlock encoding has changed. | 598 | // tests if the writeBlock encoding has changed. |
| 599 | test "flate.BlockWriter write" { | 599 | test "write" { |
| 600 | inline for (0..testCases.len) |i| { | 600 | inline for (0..testCases.len) |i| { |
| 601 | try testBlock(testCases[i], .write_block); | 601 | try testBlock(testCases[i], .write_block); |
| 602 | } | 602 | } |
| 603 | } | 603 | } |
| 604 | 604 | ||
| 605 | // tests if the writeBlockDynamic encoding has changed. | 605 | // tests if the writeBlockDynamic encoding has changed. |
| 606 | test "flate.BlockWriter dynamicBlock" { | 606 | test "dynamicBlock" { |
| 607 | inline for (0..testCases.len) |i| { | 607 | inline for (0..testCases.len) |i| { |
| 608 | try testBlock(testCases[i], .write_dyn_block); | 608 | try testBlock(testCases[i], .write_dyn_block); |
| 609 | } | 609 | } |
| 610 | } | 610 | } |
| 611 | 611 | ||
| 612 | test "flate.BlockWriter huffmanBlock" { | 612 | test "huffmanBlock" { |
| 613 | inline for (0..testCases.len) |i| { | 613 | inline for (0..testCases.len) |i| { |
| 614 | try testBlock(testCases[i], .write_huffman_block); | 614 | try testBlock(testCases[i], .write_huffman_block); |
| 615 | } | 615 | } |
lib/std/compress/flate/huffman_decoder.zig+5-11| ... | @@ -93,7 +93,6 @@ fn HuffmanDecoder( | ... | @@ -93,7 +93,6 @@ fn HuffmanDecoder( |
| 93 | var code: u16 = 0; | 93 | var code: u16 = 0; |
| 94 | var idx: u16 = 0; | 94 | var idx: u16 = 0; |
| 95 | for (&self.symbols, 0..) |*sym, pos| { | 95 | for (&self.symbols, 0..) |*sym, pos| { |
| 96 | //print("sym: {}\n", .{sym}); | ||
| 97 | if (sym.code_bits == 0) continue; // skip unused | 96 | if (sym.code_bits == 0) continue; // skip unused |
| 98 | sym.code = code; | 97 | sym.code = code; |
| 99 | 98 | ||
| ... | @@ -116,7 +115,6 @@ fn HuffmanDecoder( | ... | @@ -116,7 +115,6 @@ fn HuffmanDecoder( |
| 116 | idx = next_idx; | 115 | idx = next_idx; |
| 117 | code = next_code; | 116 | code = next_code; |
| 118 | } | 117 | } |
| 119 | //print("decoder generate, code: {d}, idx: {d}\n", .{ code, idx }); | ||
| 120 | } | 118 | } |
| 121 | 119 | ||
| 122 | /// Given the list of code lengths check that it represents a canonical | 120 | /// Given the list of code lengths check that it represents a canonical |
| ... | @@ -176,7 +174,7 @@ fn HuffmanDecoder( | ... | @@ -176,7 +174,7 @@ fn HuffmanDecoder( |
| 176 | }; | 174 | }; |
| 177 | } | 175 | } |
| 178 | 176 | ||
| 179 | test "flate.HuffmanDecoder init/find" { | 177 | test "init/find" { |
| 180 | // example data from: https://youtu.be/SJPvNi4HrWQ?t=8423 | 178 | // example data from: https://youtu.be/SJPvNi4HrWQ?t=8423 |
| 181 | const code_lens = [_]u4{ 4, 3, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 3, 2 }; | 179 | const code_lens = [_]u4{ 4, 3, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 3, 2 }; |
| 182 | var h: CodegenDecoder = .{}; | 180 | var h: CodegenDecoder = .{}; |
| ... | @@ -252,11 +250,7 @@ test "flate.HuffmanDecoder init/find" { | ... | @@ -252,11 +250,7 @@ test "flate.HuffmanDecoder init/find" { |
| 252 | try testing.expectEqual(16, (try h.find(@intCast(c))).symbol); | 250 | try testing.expectEqual(16, (try h.find(@intCast(c))).symbol); |
| 253 | } | 251 | } |
| 254 | 252 | ||
| 255 | const print = std.debug.print; | 253 | test "encode/decode literals" { |
| 256 | const assert = std.debug.assert; | ||
| 257 | const expect = std.testing.expect; | ||
| 258 | |||
| 259 | test "flate.HuffmanDecoder encode/decode literals" { | ||
| 260 | const LiteralEncoder = @import("huffman_encoder.zig").LiteralEncoder; | 254 | const LiteralEncoder = @import("huffman_encoder.zig").LiteralEncoder; |
| 261 | 255 | ||
| 262 | for (1..286) |j| { // for all different number of codes | 256 | for (1..286) |j| { // for all different number of codes |
| ... | @@ -292,7 +286,7 @@ test "flate.HuffmanDecoder encode/decode literals" { | ... | @@ -292,7 +286,7 @@ test "flate.HuffmanDecoder encode/decode literals" { |
| 292 | }; | 286 | }; |
| 293 | 287 | ||
| 294 | const c = enc.codes[symbol]; | 288 | const c = enc.codes[symbol]; |
| 295 | try expect(c.code == c_code); | 289 | try testing.expect(c.code == c_code); |
| 296 | } | 290 | } |
| 297 | 291 | ||
| 298 | // find each symbol by code | 292 | // find each symbol by code |
| ... | @@ -301,8 +295,8 @@ test "flate.HuffmanDecoder encode/decode literals" { | ... | @@ -301,8 +295,8 @@ test "flate.HuffmanDecoder encode/decode literals" { |
| 301 | 295 | ||
| 302 | const s_code: u15 = @bitReverse(@as(u15, @intCast(c.code))); | 296 | const s_code: u15 = @bitReverse(@as(u15, @intCast(c.code))); |
| 303 | const s = try dec.find(s_code); | 297 | const s = try dec.find(s_code); |
| 304 | try expect(s.code == s_code); | 298 | try testing.expect(s.code == s_code); |
| 305 | try expect(s.code_bits == c.len); | 299 | try testing.expect(s.code_bits == c.len); |
| 306 | } | 300 | } |
| 307 | } | 301 | } |
| 308 | } | 302 | } |
lib/std/compress/flate/huffman_encoder.zig+5-5| ... | @@ -360,7 +360,7 @@ fn byFreq(context: void, a: LiteralNode, b: LiteralNode) bool { | ... | @@ -360,7 +360,7 @@ fn byFreq(context: void, a: LiteralNode, b: LiteralNode) bool { |
| 360 | return a.freq < b.freq; | 360 | return a.freq < b.freq; |
| 361 | } | 361 | } |
| 362 | 362 | ||
| 363 | test "flate.HuffmanEncoder generate a Huffman code from an array of frequencies" { | 363 | test "generate a Huffman code from an array of frequencies" { |
| 364 | var freqs: [19]u16 = [_]u16{ | 364 | var freqs: [19]u16 = [_]u16{ |
| 365 | 8, // 0 | 365 | 8, // 0 |
| 366 | 1, // 1 | 366 | 1, // 1 |
| ... | @@ -421,7 +421,7 @@ test "flate.HuffmanEncoder generate a Huffman code from an array of frequencies" | ... | @@ -421,7 +421,7 @@ test "flate.HuffmanEncoder generate a Huffman code from an array of frequencies" |
| 421 | try testing.expectEqual(@as(u16, 0x3f), enc.codes[16].code); | 421 | try testing.expectEqual(@as(u16, 0x3f), enc.codes[16].code); |
| 422 | } | 422 | } |
| 423 | 423 | ||
| 424 | test "flate.HuffmanEncoder generate a Huffman code for the fixed literal table specific to Deflate" { | 424 | test "generate a Huffman code for the fixed literal table specific to Deflate" { |
| 425 | const enc = fixedLiteralEncoder(); | 425 | const enc = fixedLiteralEncoder(); |
| 426 | for (enc.codes) |c| { | 426 | for (enc.codes) |c| { |
| 427 | switch (c.len) { | 427 | switch (c.len) { |
| ... | @@ -443,7 +443,7 @@ test "flate.HuffmanEncoder generate a Huffman code for the fixed literal table s | ... | @@ -443,7 +443,7 @@ test "flate.HuffmanEncoder generate a Huffman code for the fixed literal table s |
| 443 | } | 443 | } |
| 444 | } | 444 | } |
| 445 | 445 | ||
| 446 | test "flate.HuffmanEncoder generate a Huffman code for the 30 possible relative distances (LZ77 distances) of Deflate" { | 446 | test "generate a Huffman code for the 30 possible relative distances (LZ77 distances) of Deflate" { |
| 447 | const enc = fixedDistanceEncoder(); | 447 | const enc = fixedDistanceEncoder(); |
| 448 | for (enc.codes) |c| { | 448 | for (enc.codes) |c| { |
| 449 | const v = @bitReverse(@as(u5, @intCast(c.code))); | 449 | const v = @bitReverse(@as(u5, @intCast(c.code))); |
| ... | @@ -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 "flate 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, |
| ... | @@ -482,7 +482,7 @@ test "flate bitReverse" { | ... | @@ -482,7 +482,7 @@ test "flate bitReverse" { |
| 482 | } | 482 | } |
| 483 | } | 483 | } |
| 484 | 484 | ||
| 485 | test "flate.HuffmanEncoder fixedLiteralEncoder codes" { | 485 | test "fixedLiteralEncoder codes" { |
| 486 | var al = std.ArrayList(u8).init(testing.allocator); | 486 | var al = std.ArrayList(u8).init(testing.allocator); |
| 487 | defer al.deinit(); | 487 | defer al.deinit(); |
| 488 | var bw = std.io.bitWriter(.little, al.writer()); | 488 | var bw = std.io.bitWriter(.little, al.writer()); |
lib/std/compress/flate/inflate.zig+5-5| ... | @@ -342,7 +342,7 @@ pub fn Inflate(comptime container: Container, comptime ReaderType: type) type { | ... | @@ -342,7 +342,7 @@ pub fn Inflate(comptime container: Container, comptime ReaderType: type) type { |
| 342 | }; | 342 | }; |
| 343 | } | 343 | } |
| 344 | 344 | ||
| 345 | test "flate.Inflate decompress" { | 345 | test "decompress" { |
| 346 | const cases = [_]struct { | 346 | const cases = [_]struct { |
| 347 | in: []const u8, | 347 | in: []const u8, |
| 348 | out: []const u8, | 348 | out: []const u8, |
| ... | @@ -383,7 +383,7 @@ test "flate.Inflate decompress" { | ... | @@ -383,7 +383,7 @@ test "flate.Inflate decompress" { |
| 383 | } | 383 | } |
| 384 | } | 384 | } |
| 385 | 385 | ||
| 386 | test "flate.Inflate gzip decompress" { | 386 | test "gzip decompress" { |
| 387 | const cases = [_]struct { | 387 | const cases = [_]struct { |
| 388 | in: []const u8, | 388 | in: []const u8, |
| 389 | out: []const u8, | 389 | out: []const u8, |
| ... | @@ -440,7 +440,7 @@ test "flate.Inflate gzip decompress" { | ... | @@ -440,7 +440,7 @@ test "flate.Inflate gzip decompress" { |
| 440 | } | 440 | } |
| 441 | } | 441 | } |
| 442 | 442 | ||
| 443 | test "flate.Inflate zlib decompress" { | 443 | test "zlib decompress" { |
| 444 | const cases = [_]struct { | 444 | const cases = [_]struct { |
| 445 | in: []const u8, | 445 | in: []const u8, |
| 446 | out: []const u8, | 446 | out: []const u8, |
| ... | @@ -466,7 +466,7 @@ test "flate.Inflate zlib decompress" { | ... | @@ -466,7 +466,7 @@ test "flate.Inflate zlib decompress" { |
| 466 | } | 466 | } |
| 467 | } | 467 | } |
| 468 | 468 | ||
| 469 | test "flate.Inflate fuzzing tests" { | 469 | test "fuzzing tests" { |
| 470 | const cases = [_]struct { | 470 | const cases = [_]struct { |
| 471 | input: []const u8, | 471 | input: []const u8, |
| 472 | out: []const u8 = "", | 472 | out: []const u8 = "", |
| ... | @@ -529,7 +529,7 @@ test "flate.Inflate fuzzing tests" { | ... | @@ -529,7 +529,7 @@ test "flate.Inflate fuzzing tests" { |
| 529 | } | 529 | } |
| 530 | } | 530 | } |
| 531 | 531 | ||
| 532 | test "flate bug 18966" { | 532 | test "bug 18966" { |
| 533 | const input = @embedFile("testdata/fuzz/bug_18966.input"); | 533 | const input = @embedFile("testdata/fuzz/bug_18966.input"); |
| 534 | const expect = @embedFile("testdata/fuzz/bug_18966.expect"); | 534 | const expect = @embedFile("testdata/fuzz/bug_18966.expect"); |
| 535 | 535 |
lib/std/compress/lzma/test.zig+8-8| ... | @@ -21,7 +21,7 @@ fn testDecompressError(expected: anyerror, compressed: []const u8) !void { | ... | @@ -21,7 +21,7 @@ fn testDecompressError(expected: anyerror, compressed: []const u8) !void { |
| 21 | return std.testing.expectError(expected, testDecompress(compressed)); | 21 | return std.testing.expectError(expected, testDecompress(compressed)); |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | test "LZMA: decompress empty world" { | 24 | test "decompress empty world" { |
| 25 | try testDecompressEqual( | 25 | try testDecompressEqual( |
| 26 | "", | 26 | "", |
| 27 | &[_]u8{ | 27 | &[_]u8{ |
| ... | @@ -31,7 +31,7 @@ test "LZMA: decompress empty world" { | ... | @@ -31,7 +31,7 @@ test "LZMA: decompress empty world" { |
| 31 | ); | 31 | ); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | test "LZMA: decompress hello world" { | 34 | test "decompress hello world" { |
| 35 | try testDecompressEqual( | 35 | try testDecompressEqual( |
| 36 | "Hello world\n", | 36 | "Hello world\n", |
| 37 | &[_]u8{ | 37 | &[_]u8{ |
| ... | @@ -42,7 +42,7 @@ test "LZMA: decompress hello world" { | ... | @@ -42,7 +42,7 @@ test "LZMA: decompress hello world" { |
| 42 | ); | 42 | ); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | test "LZMA: decompress huge dict" { | 45 | test "decompress huge dict" { |
| 46 | try testDecompressEqual( | 46 | try testDecompressEqual( |
| 47 | "Hello world\n", | 47 | "Hello world\n", |
| 48 | &[_]u8{ | 48 | &[_]u8{ |
| ... | @@ -53,35 +53,35 @@ test "LZMA: decompress huge dict" { | ... | @@ -53,35 +53,35 @@ test "LZMA: decompress huge dict" { |
| 53 | ); | 53 | ); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | test "LZMA: unknown size with end of payload marker" { | 56 | test "unknown size with end of payload marker" { |
| 57 | try testDecompressEqual( | 57 | try testDecompressEqual( |
| 58 | "Hello\nWorld!\n", | 58 | "Hello\nWorld!\n", |
| 59 | @embedFile("testdata/good-unknown_size-with_eopm.lzma"), | 59 | @embedFile("testdata/good-unknown_size-with_eopm.lzma"), |
| 60 | ); | 60 | ); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | test "LZMA: known size without end of payload marker" { | 63 | test "known size without end of payload marker" { |
| 64 | try testDecompressEqual( | 64 | try testDecompressEqual( |
| 65 | "Hello\nWorld!\n", | 65 | "Hello\nWorld!\n", |
| 66 | @embedFile("testdata/good-known_size-without_eopm.lzma"), | 66 | @embedFile("testdata/good-known_size-without_eopm.lzma"), |
| 67 | ); | 67 | ); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | test "LZMA: known size with end of payload marker" { | 70 | test "known size with end of payload marker" { |
| 71 | try testDecompressEqual( | 71 | try testDecompressEqual( |
| 72 | "Hello\nWorld!\n", | 72 | "Hello\nWorld!\n", |
| 73 | @embedFile("testdata/good-known_size-with_eopm.lzma"), | 73 | @embedFile("testdata/good-known_size-with_eopm.lzma"), |
| 74 | ); | 74 | ); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | test "LZMA: too big uncompressed size in header" { | 77 | test "too big uncompressed size in header" { |
| 78 | try testDecompressError( | 78 | try testDecompressError( |
| 79 | error.CorruptInput, | 79 | error.CorruptInput, |
| 80 | @embedFile("testdata/bad-too_big_size-with_eopm.lzma"), | 80 | @embedFile("testdata/bad-too_big_size-with_eopm.lzma"), |
| 81 | ); | 81 | ); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | test "LZMA: too small uncompressed size in header" { | 84 | test "too small uncompressed size in header" { |
| 85 | try testDecompressError( | 85 | try testDecompressError( |
| 86 | error.CorruptInput, | 86 | error.CorruptInput, |
| 87 | @embedFile("testdata/bad-too_small_size-without_eopm-3.lzma"), | 87 | @embedFile("testdata/bad-too_small_size-without_eopm-3.lzma"), |
lib/std/compress/lzma/vec2d.zig+7-7| ... | @@ -49,7 +49,7 @@ const testing = std.testing; | ... | @@ -49,7 +49,7 @@ const testing = std.testing; |
| 49 | const expectEqualSlices = std.testing.expectEqualSlices; | 49 | const expectEqualSlices = std.testing.expectEqualSlices; |
| 50 | const expectError = std.testing.expectError; | 50 | const expectError = std.testing.expectError; |
| 51 | 51 | ||
| 52 | test "Vec2D.init" { | 52 | test "init" { |
| 53 | const allocator = testing.allocator; | 53 | const allocator = testing.allocator; |
| 54 | var vec2d = try Vec2D(i32).init(allocator, 1, .{ 2, 3 }); | 54 | var vec2d = try Vec2D(i32).init(allocator, 1, .{ 2, 3 }); |
| 55 | defer vec2d.deinit(allocator); | 55 | defer vec2d.deinit(allocator); |
| ... | @@ -58,7 +58,7 @@ test "Vec2D.init" { | ... | @@ -58,7 +58,7 @@ test "Vec2D.init" { |
| 58 | try expectEqualSlices(i32, &.{ 1, 1, 1 }, try vec2d.get(1)); | 58 | try expectEqualSlices(i32, &.{ 1, 1, 1 }, try vec2d.get(1)); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | test "Vec2D.init overflow" { | 61 | test "init overflow" { |
| 62 | const allocator = testing.allocator; | 62 | const allocator = testing.allocator; |
| 63 | try expectError( | 63 | try expectError( |
| 64 | error.Overflow, | 64 | error.Overflow, |
| ... | @@ -66,7 +66,7 @@ test "Vec2D.init overflow" { | ... | @@ -66,7 +66,7 @@ test "Vec2D.init overflow" { |
| 66 | ); | 66 | ); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | test "Vec2D.fill" { | 69 | test "fill" { |
| 70 | const allocator = testing.allocator; | 70 | const allocator = testing.allocator; |
| 71 | var vec2d = try Vec2D(i32).init(allocator, 0, .{ 2, 3 }); | 71 | var vec2d = try Vec2D(i32).init(allocator, 0, .{ 2, 3 }); |
| 72 | defer vec2d.deinit(allocator); | 72 | defer vec2d.deinit(allocator); |
| ... | @@ -77,7 +77,7 @@ test "Vec2D.fill" { | ... | @@ -77,7 +77,7 @@ test "Vec2D.fill" { |
| 77 | try expectEqualSlices(i32, &.{ 7, 7, 7 }, try vec2d.get(1)); | 77 | try expectEqualSlices(i32, &.{ 7, 7, 7 }, try vec2d.get(1)); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | test "Vec2D.get" { | 80 | test "get" { |
| 81 | var data = [_]i32{ 0, 1, 2, 3, 4, 5, 6, 7 }; | 81 | var data = [_]i32{ 0, 1, 2, 3, 4, 5, 6, 7 }; |
| 82 | const vec2d = Vec2D(i32){ | 82 | const vec2d = Vec2D(i32){ |
| 83 | .data = &data, | 83 | .data = &data, |
| ... | @@ -90,7 +90,7 @@ test "Vec2D.get" { | ... | @@ -90,7 +90,7 @@ test "Vec2D.get" { |
| 90 | try expectEqualSlices(i32, &.{ 6, 7 }, try vec2d.get(3)); | 90 | try expectEqualSlices(i32, &.{ 6, 7 }, try vec2d.get(3)); |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | test "Vec2D.getMut" { | 93 | test "getMut" { |
| 94 | var data = [_]i32{ 0, 1, 2, 3, 4, 5, 6, 7 }; | 94 | var data = [_]i32{ 0, 1, 2, 3, 4, 5, 6, 7 }; |
| 95 | var vec2d = Vec2D(i32){ | 95 | var vec2d = Vec2D(i32){ |
| 96 | .data = &data, | 96 | .data = &data, |
| ... | @@ -107,7 +107,7 @@ test "Vec2D.getMut" { | ... | @@ -107,7 +107,7 @@ test "Vec2D.getMut" { |
| 107 | try expectEqualSlices(i32, &.{ 6, 7 }, try vec2d.get(3)); | 107 | try expectEqualSlices(i32, &.{ 6, 7 }, try vec2d.get(3)); |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | test "Vec2D.get multiplication overflow" { | 110 | test "get multiplication overflow" { |
| 111 | const allocator = testing.allocator; | 111 | const allocator = testing.allocator; |
| 112 | var matrix = try Vec2D(i32).init(allocator, 0, .{ 3, 4 }); | 112 | var matrix = try Vec2D(i32).init(allocator, 0, .{ 3, 4 }); |
| 113 | defer matrix.deinit(allocator); | 113 | defer matrix.deinit(allocator); |
| ... | @@ -117,7 +117,7 @@ test "Vec2D.get multiplication overflow" { | ... | @@ -117,7 +117,7 @@ test "Vec2D.get multiplication overflow" { |
| 117 | try expectError(error.Overflow, matrix.getMut(row)); | 117 | try expectError(error.Overflow, matrix.getMut(row)); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | test "Vec2D.get addition overflow" { | 120 | test "get addition overflow" { |
| 121 | const allocator = testing.allocator; | 121 | const allocator = testing.allocator; |
| 122 | var matrix = try Vec2D(i32).init(allocator, 0, .{ 3, 5 }); | 122 | var matrix = try Vec2D(i32).init(allocator, 0, .{ 3, 5 }); |
| 123 | defer matrix.deinit(allocator); | 123 | defer matrix.deinit(allocator); |
lib/std/compress/zstandard.zig+2-2| ... | @@ -222,7 +222,7 @@ fn testReader(data: []const u8, comptime expected: []const u8) !void { | ... | @@ -222,7 +222,7 @@ fn testReader(data: []const u8, comptime expected: []const u8) !void { |
| 222 | try std.testing.expectEqualSlices(u8, expected, buf); | 222 | try std.testing.expectEqualSlices(u8, expected, buf); |
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | test "zstandard decompression" { | 225 | test "decompression" { |
| 226 | const uncompressed = @embedFile("testdata/rfc8478.txt"); | 226 | const uncompressed = @embedFile("testdata/rfc8478.txt"); |
| 227 | const compressed3 = @embedFile("testdata/rfc8478.txt.zst.3"); | 227 | const compressed3 = @embedFile("testdata/rfc8478.txt.zst.3"); |
| 228 | const compressed19 = @embedFile("testdata/rfc8478.txt.zst.19"); | 228 | const compressed19 = @embedFile("testdata/rfc8478.txt.zst.19"); |
| ... | @@ -239,7 +239,7 @@ test "zstandard decompression" { | ... | @@ -239,7 +239,7 @@ test "zstandard decompression" { |
| 239 | try std.testing.expectEqualSlices(u8, uncompressed, buffer); | 239 | try std.testing.expectEqualSlices(u8, uncompressed, buffer); |
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | test "zstandard streaming decompression" { | 242 | test "streaming decompression" { |
| 243 | // default stack size for wasm32 is too low for Decompressor - slightly | 243 | // default stack size for wasm32 is too low for Decompressor - slightly |
| 244 | // over 1MiB stack space is needed via the --stack CLI flag | 244 | // over 1MiB stack space is needed via the --stack CLI flag |
| 245 | if (@import("builtin").target.cpu.arch == .wasm32) return error.SkipZigTest; | 245 | if (@import("builtin").target.cpu.arch == .wasm32) return error.SkipZigTest; |
lib/std/comptime_string_map.zig+9-9| ... | @@ -142,7 +142,7 @@ const TestEnum = enum { | ... | @@ -142,7 +142,7 @@ const TestEnum = enum { |
| 142 | E, | 142 | E, |
| 143 | }; | 143 | }; |
| 144 | 144 | ||
| 145 | test "ComptimeStringMap list literal of list literals" { | 145 | test "list literal of list literals" { |
| 146 | const map = ComptimeStringMap(TestEnum, .{ | 146 | const map = ComptimeStringMap(TestEnum, .{ |
| 147 | .{ "these", .D }, | 147 | .{ "these", .D }, |
| 148 | .{ "have", .A }, | 148 | .{ "have", .A }, |
| ... | @@ -157,7 +157,7 @@ test "ComptimeStringMap list literal of list literals" { | ... | @@ -157,7 +157,7 @@ test "ComptimeStringMap list literal of list literals" { |
| 157 | try std.testing.expect(null == map.get("NOTHING")); | 157 | try std.testing.expect(null == map.get("NOTHING")); |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | test "ComptimeStringMap array of structs" { | 160 | test "array of structs" { |
| 161 | const KV = struct { []const u8, TestEnum }; | 161 | const KV = struct { []const u8, TestEnum }; |
| 162 | const map = ComptimeStringMap(TestEnum, [_]KV{ | 162 | const map = ComptimeStringMap(TestEnum, [_]KV{ |
| 163 | .{ "these", .D }, | 163 | .{ "these", .D }, |
| ... | @@ -170,7 +170,7 @@ test "ComptimeStringMap array of structs" { | ... | @@ -170,7 +170,7 @@ test "ComptimeStringMap array of structs" { |
| 170 | try testMap(map); | 170 | try testMap(map); |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | test "ComptimeStringMap slice of structs" { | 173 | test "slice of structs" { |
| 174 | const KV = struct { []const u8, TestEnum }; | 174 | const KV = struct { []const u8, TestEnum }; |
| 175 | const slice: []const KV = &[_]KV{ | 175 | const slice: []const KV = &[_]KV{ |
| 176 | .{ "these", .D }, | 176 | .{ "these", .D }, |
| ... | @@ -198,7 +198,7 @@ fn testMap(comptime map: anytype) !void { | ... | @@ -198,7 +198,7 @@ fn testMap(comptime map: anytype) !void { |
| 198 | try std.testing.expect(null == map.get("averylongstringthathasnomatches")); | 198 | try std.testing.expect(null == map.get("averylongstringthathasnomatches")); |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | test "ComptimeStringMap void value type, slice of structs" { | 201 | test "void value type, slice of structs" { |
| 202 | const KV = struct { []const u8 }; | 202 | const KV = struct { []const u8 }; |
| 203 | const slice: []const KV = &[_]KV{ | 203 | const slice: []const KV = &[_]KV{ |
| 204 | .{"these"}, | 204 | .{"these"}, |
| ... | @@ -215,7 +215,7 @@ test "ComptimeStringMap void value type, slice of structs" { | ... | @@ -215,7 +215,7 @@ test "ComptimeStringMap void value type, slice of structs" { |
| 215 | try std.testing.expect(null == map.get("NOTHING")); | 215 | try std.testing.expect(null == map.get("NOTHING")); |
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | test "ComptimeStringMap void value type, list literal of list literals" { | 218 | test "void value type, list literal of list literals" { |
| 219 | const map = ComptimeStringMap(void, .{ | 219 | const map = ComptimeStringMap(void, .{ |
| 220 | .{"these"}, | 220 | .{"these"}, |
| 221 | .{"have"}, | 221 | .{"have"}, |
| ... | @@ -258,7 +258,7 @@ test "ComptimeStringMapWithEql" { | ... | @@ -258,7 +258,7 @@ test "ComptimeStringMapWithEql" { |
| 258 | try std.testing.expect(map.has("ThESe")); | 258 | try std.testing.expect(map.has("ThESe")); |
| 259 | } | 259 | } |
| 260 | 260 | ||
| 261 | test "ComptimeStringMap empty" { | 261 | test "empty" { |
| 262 | const m1 = ComptimeStringMap(usize, .{}); | 262 | const m1 = ComptimeStringMap(usize, .{}); |
| 263 | try std.testing.expect(null == m1.get("anything")); | 263 | try std.testing.expect(null == m1.get("anything")); |
| 264 | 264 | ||
| ... | @@ -266,7 +266,7 @@ test "ComptimeStringMap empty" { | ... | @@ -266,7 +266,7 @@ test "ComptimeStringMap empty" { |
| 266 | try std.testing.expect(null == m2.get("anything")); | 266 | try std.testing.expect(null == m2.get("anything")); |
| 267 | } | 267 | } |
| 268 | 268 | ||
| 269 | test "ComptimeStringMap redundant entries" { | 269 | test "redundant entries" { |
| 270 | const map = ComptimeStringMap(TestEnum, .{ | 270 | const map = ComptimeStringMap(TestEnum, .{ |
| 271 | .{ "redundant", .D }, | 271 | .{ "redundant", .D }, |
| 272 | .{ "theNeedle", .A }, | 272 | .{ "theNeedle", .A }, |
| ... | @@ -284,7 +284,7 @@ test "ComptimeStringMap redundant entries" { | ... | @@ -284,7 +284,7 @@ test "ComptimeStringMap redundant entries" { |
| 284 | try std.testing.expectEqual(TestEnum.A, map.get("theNeedle").?); | 284 | try std.testing.expectEqual(TestEnum.A, map.get("theNeedle").?); |
| 285 | } | 285 | } |
| 286 | 286 | ||
| 287 | test "ComptimeStringMap redundant insensitive" { | 287 | test "redundant insensitive" { |
| 288 | const map = ComptimeStringMapWithEql(TestEnum, .{ | 288 | const map = ComptimeStringMapWithEql(TestEnum, .{ |
| 289 | .{ "redundant", .D }, | 289 | .{ "redundant", .D }, |
| 290 | .{ "theNeedle", .A }, | 290 | .{ "theNeedle", .A }, |
| ... | @@ -300,7 +300,7 @@ test "ComptimeStringMap redundant insensitive" { | ... | @@ -300,7 +300,7 @@ test "ComptimeStringMap redundant insensitive" { |
| 300 | try std.testing.expectEqual(TestEnum.A, map.get("theNeedle").?); | 300 | try std.testing.expectEqual(TestEnum.A, map.get("theNeedle").?); |
| 301 | } | 301 | } |
| 302 | 302 | ||
| 303 | test "ComptimeStringMap comptime-only value" { | 303 | test "comptime-only value" { |
| 304 | const map = std.ComptimeStringMap(type, .{ | 304 | const map = std.ComptimeStringMap(type, .{ |
| 305 | .{ "a", struct { | 305 | .{ "a", struct { |
| 306 | pub const foo = 1; | 306 | pub const foo = 1; |
lib/std/crypto/25519/curve25519.zig+1-1| ... | @@ -137,7 +137,7 @@ test "non-affine edwards25519 to curve25519 projection" { | ... | @@ -137,7 +137,7 @@ test "non-affine edwards25519 to curve25519 projection" { |
| 137 | try std.testing.expectEqualSlices(u8, &xp.toBytes(), &expected); | 137 | try std.testing.expectEqualSlices(u8, &xp.toBytes(), &expected); |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | test "curve25519 small order check" { | 140 | test "small order check" { |
| 141 | var s: [32]u8 = [_]u8{1} ++ [_]u8{0} ** 31; | 141 | var s: [32]u8 = [_]u8{1} ++ [_]u8{0} ** 31; |
| 142 | const small_order_ss: [7][32]u8 = .{ | 142 | const small_order_ss: [7][32]u8 = .{ |
| 143 | .{ | 143 | .{ |
lib/std/crypto/25519/ed25519.zig+7-7| ... | @@ -482,7 +482,7 @@ pub const Ed25519 = struct { | ... | @@ -482,7 +482,7 @@ pub const Ed25519 = struct { |
| 482 | }; | 482 | }; |
| 483 | }; | 483 | }; |
| 484 | 484 | ||
| 485 | test "ed25519 key pair creation" { | 485 | test "key pair creation" { |
| 486 | var seed: [32]u8 = undefined; | 486 | var seed: [32]u8 = undefined; |
| 487 | _ = try fmt.hexToBytes(seed[0..], "8052030376d47112be7f73ed7a019293dd12ad910b654455798b4667d73de166"); | 487 | _ = try fmt.hexToBytes(seed[0..], "8052030376d47112be7f73ed7a019293dd12ad910b654455798b4667d73de166"); |
| 488 | const key_pair = try Ed25519.KeyPair.create(seed); | 488 | const key_pair = try Ed25519.KeyPair.create(seed); |
| ... | @@ -491,7 +491,7 @@ test "ed25519 key pair creation" { | ... | @@ -491,7 +491,7 @@ test "ed25519 key pair creation" { |
| 491 | try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{s}", .{std.fmt.fmtSliceHexUpper(&key_pair.public_key.toBytes())}), "2D6F7455D97B4A3A10D7293909D1A4F2058CB9A370E43FA8154BB280DB839083"); | 491 | try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{s}", .{std.fmt.fmtSliceHexUpper(&key_pair.public_key.toBytes())}), "2D6F7455D97B4A3A10D7293909D1A4F2058CB9A370E43FA8154BB280DB839083"); |
| 492 | } | 492 | } |
| 493 | 493 | ||
| 494 | test "ed25519 signature" { | 494 | test "signature" { |
| 495 | var seed: [32]u8 = undefined; | 495 | var seed: [32]u8 = undefined; |
| 496 | _ = try fmt.hexToBytes(seed[0..], "8052030376d47112be7f73ed7a019293dd12ad910b654455798b4667d73de166"); | 496 | _ = try fmt.hexToBytes(seed[0..], "8052030376d47112be7f73ed7a019293dd12ad910b654455798b4667d73de166"); |
| 497 | const key_pair = try Ed25519.KeyPair.create(seed); | 497 | const key_pair = try Ed25519.KeyPair.create(seed); |
| ... | @@ -503,7 +503,7 @@ test "ed25519 signature" { | ... | @@ -503,7 +503,7 @@ test "ed25519 signature" { |
| 503 | try std.testing.expectError(error.SignatureVerificationFailed, sig.verify("TEST", key_pair.public_key)); | 503 | try std.testing.expectError(error.SignatureVerificationFailed, sig.verify("TEST", key_pair.public_key)); |
| 504 | } | 504 | } |
| 505 | 505 | ||
| 506 | test "ed25519 batch verification" { | 506 | test "batch verification" { |
| 507 | var i: usize = 0; | 507 | var i: usize = 0; |
| 508 | while (i < 100) : (i += 1) { | 508 | while (i < 100) : (i += 1) { |
| 509 | const key_pair = try Ed25519.KeyPair.create(null); | 509 | const key_pair = try Ed25519.KeyPair.create(null); |
| ... | @@ -532,7 +532,7 @@ test "ed25519 batch verification" { | ... | @@ -532,7 +532,7 @@ test "ed25519 batch verification" { |
| 532 | } | 532 | } |
| 533 | } | 533 | } |
| 534 | 534 | ||
| 535 | test "ed25519 test vectors" { | 535 | test "test vectors" { |
| 536 | const Vec = struct { | 536 | const Vec = struct { |
| 537 | msg_hex: *const [64:0]u8, | 537 | msg_hex: *const [64:0]u8, |
| 538 | public_key_hex: *const [64:0]u8, | 538 | public_key_hex: *const [64:0]u8, |
| ... | @@ -634,7 +634,7 @@ test "ed25519 test vectors" { | ... | @@ -634,7 +634,7 @@ test "ed25519 test vectors" { |
| 634 | } | 634 | } |
| 635 | } | 635 | } |
| 636 | 636 | ||
| 637 | test "ed25519 with blind keys" { | 637 | test "with blind keys" { |
| 638 | const BlindKeyPair = Ed25519.key_blinding.BlindKeyPair; | 638 | const BlindKeyPair = Ed25519.key_blinding.BlindKeyPair; |
| 639 | 639 | ||
| 640 | // Create a standard Ed25519 key pair | 640 | // Create a standard Ed25519 key pair |
| ... | @@ -657,7 +657,7 @@ test "ed25519 with blind keys" { | ... | @@ -657,7 +657,7 @@ test "ed25519 with blind keys" { |
| 657 | try std.testing.expectEqualSlices(u8, &pk.toBytes(), &kp.public_key.toBytes()); | 657 | try std.testing.expectEqualSlices(u8, &pk.toBytes(), &kp.public_key.toBytes()); |
| 658 | } | 658 | } |
| 659 | 659 | ||
| 660 | test "ed25519 signatures with streaming" { | 660 | test "signatures with streaming" { |
| 661 | const kp = try Ed25519.KeyPair.create(null); | 661 | const kp = try Ed25519.KeyPair.create(null); |
| 662 | 662 | ||
| 663 | var signer = try kp.signer(null); | 663 | var signer = try kp.signer(null); |
| ... | @@ -673,7 +673,7 @@ test "ed25519 signatures with streaming" { | ... | @@ -673,7 +673,7 @@ test "ed25519 signatures with streaming" { |
| 673 | try verifier.verify(); | 673 | try verifier.verify(); |
| 674 | } | 674 | } |
| 675 | 675 | ||
| 676 | test "ed25519 key pair from secret key" { | 676 | test "key pair from secret key" { |
| 677 | const kp = try Ed25519.KeyPair.create(null); | 677 | const kp = try Ed25519.KeyPair.create(null); |
| 678 | const kp2 = try Ed25519.KeyPair.fromSecretKey(kp.secret_key); | 678 | const kp2 = try Ed25519.KeyPair.fromSecretKey(kp.secret_key); |
| 679 | try std.testing.expectEqualSlices(u8, &kp.secret_key.toBytes(), &kp2.secret_key.toBytes()); | 679 | try std.testing.expectEqualSlices(u8, &kp.secret_key.toBytes(), &kp2.secret_key.toBytes()); |
lib/std/crypto/25519/edwards25519.zig+5-5| ... | @@ -493,7 +493,7 @@ pub const Edwards25519 = struct { | ... | @@ -493,7 +493,7 @@ pub const Edwards25519 = struct { |
| 493 | 493 | ||
| 494 | const htest = @import("../test.zig"); | 494 | const htest = @import("../test.zig"); |
| 495 | 495 | ||
| 496 | test "edwards25519 packing/unpacking" { | 496 | test "packing/unpacking" { |
| 497 | const s = [_]u8{170} ++ [_]u8{0} ** 31; | 497 | const s = [_]u8{170} ++ [_]u8{0} ** 31; |
| 498 | var b = Edwards25519.basePoint; | 498 | var b = Edwards25519.basePoint; |
| 499 | const pk = try b.mul(s); | 499 | const pk = try b.mul(s); |
| ... | @@ -529,7 +529,7 @@ test "edwards25519 packing/unpacking" { | ... | @@ -529,7 +529,7 @@ test "edwards25519 packing/unpacking" { |
| 529 | } | 529 | } |
| 530 | } | 530 | } |
| 531 | 531 | ||
| 532 | test "edwards25519 point addition/subtraction" { | 532 | test "point addition/subtraction" { |
| 533 | var s1: [32]u8 = undefined; | 533 | var s1: [32]u8 = undefined; |
| 534 | var s2: [32]u8 = undefined; | 534 | var s2: [32]u8 = undefined; |
| 535 | crypto.random.bytes(&s1); | 535 | crypto.random.bytes(&s1); |
| ... | @@ -543,7 +543,7 @@ test "edwards25519 point addition/subtraction" { | ... | @@ -543,7 +543,7 @@ test "edwards25519 point addition/subtraction" { |
| 543 | try std.testing.expectError(error.IdentityElement, p.sub(q).add(q).sub(p).rejectIdentity()); | 543 | try std.testing.expectError(error.IdentityElement, p.sub(q).add(q).sub(p).rejectIdentity()); |
| 544 | } | 544 | } |
| 545 | 545 | ||
| 546 | test "edwards25519 uniform-to-point" { | 546 | test "uniform-to-point" { |
| 547 | var r = [32]u8{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }; | 547 | var r = [32]u8{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }; |
| 548 | var p = Edwards25519.fromUniform(r); | 548 | var p = Edwards25519.fromUniform(r); |
| 549 | try htest.assertEqual("0691eee3cf70a0056df6bfa03120635636581b5c4ea571dfc680f78c7e0b4137", p.toBytes()[0..]); | 549 | try htest.assertEqual("0691eee3cf70a0056df6bfa03120635636581b5c4ea571dfc680f78c7e0b4137", p.toBytes()[0..]); |
| ... | @@ -554,7 +554,7 @@ test "edwards25519 uniform-to-point" { | ... | @@ -554,7 +554,7 @@ test "edwards25519 uniform-to-point" { |
| 554 | } | 554 | } |
| 555 | 555 | ||
| 556 | // Test vectors from draft-irtf-cfrg-hash-to-curve-12 | 556 | // Test vectors from draft-irtf-cfrg-hash-to-curve-12 |
| 557 | test "edwards25519 hash-to-curve operation" { | 557 | test "hash-to-curve operation" { |
| 558 | var p = Edwards25519.fromString(true, "QUUX-V01-CS02-with-edwards25519_XMD:SHA-512_ELL2_RO_", "abc"); | 558 | var p = Edwards25519.fromString(true, "QUUX-V01-CS02-with-edwards25519_XMD:SHA-512_ELL2_RO_", "abc"); |
| 559 | try htest.assertEqual("31558a26887f23fb8218f143e69d5f0af2e7831130bd5b432ef23883b895839a", p.toBytes()[0..]); | 559 | try htest.assertEqual("31558a26887f23fb8218f143e69d5f0af2e7831130bd5b432ef23883b895839a", p.toBytes()[0..]); |
| 560 | 560 | ||
| ... | @@ -562,7 +562,7 @@ test "edwards25519 hash-to-curve operation" { | ... | @@ -562,7 +562,7 @@ test "edwards25519 hash-to-curve operation" { |
| 562 | try htest.assertEqual("42fa27c8f5a1ae0aa38bb59d5938e5145622ba5dedd11d11736fa2f9502d7367", p.toBytes()[0..]); | 562 | try htest.assertEqual("42fa27c8f5a1ae0aa38bb59d5938e5145622ba5dedd11d11736fa2f9502d7367", p.toBytes()[0..]); |
| 563 | } | 563 | } |
| 564 | 564 | ||
| 565 | test "edwards25519 implicit reduction of invalid scalars" { | 565 | test "implicit reduction of invalid scalars" { |
| 566 | const s = [_]u8{0} ** 31 ++ [_]u8{255}; | 566 | const s = [_]u8{0} ** 31 ++ [_]u8{255}; |
| 567 | const p1 = try Edwards25519.basePoint.mulPublic(s); | 567 | const p1 = try Edwards25519.basePoint.mulPublic(s); |
| 568 | const p2 = try Edwards25519.basePoint.mul(s); | 568 | const p2 = try Edwards25519.basePoint.mul(s); |
lib/std/crypto/25519/x25519.zig+6-6| ... | @@ -81,7 +81,7 @@ pub const X25519 = struct { | ... | @@ -81,7 +81,7 @@ pub const X25519 = struct { |
| 81 | 81 | ||
| 82 | const htest = @import("../test.zig"); | 82 | const htest = @import("../test.zig"); |
| 83 | 83 | ||
| 84 | test "x25519 public key calculation from secret key" { | 84 | test "public key calculation from secret key" { |
| 85 | var sk: [32]u8 = undefined; | 85 | var sk: [32]u8 = undefined; |
| 86 | var pk_expected: [32]u8 = undefined; | 86 | var pk_expected: [32]u8 = undefined; |
| 87 | _ = try fmt.hexToBytes(sk[0..], "8052030376d47112be7f73ed7a019293dd12ad910b654455798b4667d73de166"); | 87 | _ = try fmt.hexToBytes(sk[0..], "8052030376d47112be7f73ed7a019293dd12ad910b654455798b4667d73de166"); |
| ... | @@ -90,7 +90,7 @@ test "x25519 public key calculation from secret key" { | ... | @@ -90,7 +90,7 @@ test "x25519 public key calculation from secret key" { |
| 90 | try std.testing.expectEqual(pk_calculated, pk_expected); | 90 | try std.testing.expectEqual(pk_calculated, pk_expected); |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | test "x25519 rfc7748 vector1" { | 93 | test "rfc7748 vector1" { |
| 94 | const secret_key = [32]u8{ 0xa5, 0x46, 0xe3, 0x6b, 0xf0, 0x52, 0x7c, 0x9d, 0x3b, 0x16, 0x15, 0x4b, 0x82, 0x46, 0x5e, 0xdd, 0x62, 0x14, 0x4c, 0x0a, 0xc1, 0xfc, 0x5a, 0x18, 0x50, 0x6a, 0x22, 0x44, 0xba, 0x44, 0x9a, 0xc4 }; | 94 | const secret_key = [32]u8{ 0xa5, 0x46, 0xe3, 0x6b, 0xf0, 0x52, 0x7c, 0x9d, 0x3b, 0x16, 0x15, 0x4b, 0x82, 0x46, 0x5e, 0xdd, 0x62, 0x14, 0x4c, 0x0a, 0xc1, 0xfc, 0x5a, 0x18, 0x50, 0x6a, 0x22, 0x44, 0xba, 0x44, 0x9a, 0xc4 }; |
| 95 | const public_key = [32]u8{ 0xe6, 0xdb, 0x68, 0x67, 0x58, 0x30, 0x30, 0xdb, 0x35, 0x94, 0xc1, 0xa4, 0x24, 0xb1, 0x5f, 0x7c, 0x72, 0x66, 0x24, 0xec, 0x26, 0xb3, 0x35, 0x3b, 0x10, 0xa9, 0x03, 0xa6, 0xd0, 0xab, 0x1c, 0x4c }; | 95 | const public_key = [32]u8{ 0xe6, 0xdb, 0x68, 0x67, 0x58, 0x30, 0x30, 0xdb, 0x35, 0x94, 0xc1, 0xa4, 0x24, 0xb1, 0x5f, 0x7c, 0x72, 0x66, 0x24, 0xec, 0x26, 0xb3, 0x35, 0x3b, 0x10, 0xa9, 0x03, 0xa6, 0xd0, 0xab, 0x1c, 0x4c }; |
| 96 | 96 | ||
| ... | @@ -100,7 +100,7 @@ test "x25519 rfc7748 vector1" { | ... | @@ -100,7 +100,7 @@ test "x25519 rfc7748 vector1" { |
| 100 | try std.testing.expectEqual(output, expected_output); | 100 | try std.testing.expectEqual(output, expected_output); |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | test "x25519 rfc7748 vector2" { | 103 | test "rfc7748 vector2" { |
| 104 | const secret_key = [32]u8{ 0x4b, 0x66, 0xe9, 0xd4, 0xd1, 0xb4, 0x67, 0x3c, 0x5a, 0xd2, 0x26, 0x91, 0x95, 0x7d, 0x6a, 0xf5, 0xc1, 0x1b, 0x64, 0x21, 0xe0, 0xea, 0x01, 0xd4, 0x2c, 0xa4, 0x16, 0x9e, 0x79, 0x18, 0xba, 0x0d }; | 104 | const secret_key = [32]u8{ 0x4b, 0x66, 0xe9, 0xd4, 0xd1, 0xb4, 0x67, 0x3c, 0x5a, 0xd2, 0x26, 0x91, 0x95, 0x7d, 0x6a, 0xf5, 0xc1, 0x1b, 0x64, 0x21, 0xe0, 0xea, 0x01, 0xd4, 0x2c, 0xa4, 0x16, 0x9e, 0x79, 0x18, 0xba, 0x0d }; |
| 105 | const public_key = [32]u8{ 0xe5, 0x21, 0x0f, 0x12, 0x78, 0x68, 0x11, 0xd3, 0xf4, 0xb7, 0x95, 0x9d, 0x05, 0x38, 0xae, 0x2c, 0x31, 0xdb, 0xe7, 0x10, 0x6f, 0xc0, 0x3c, 0x3e, 0xfc, 0x4c, 0xd5, 0x49, 0xc7, 0x15, 0xa4, 0x93 }; | 105 | const public_key = [32]u8{ 0xe5, 0x21, 0x0f, 0x12, 0x78, 0x68, 0x11, 0xd3, 0xf4, 0xb7, 0x95, 0x9d, 0x05, 0x38, 0xae, 0x2c, 0x31, 0xdb, 0xe7, 0x10, 0x6f, 0xc0, 0x3c, 0x3e, 0xfc, 0x4c, 0xd5, 0x49, 0xc7, 0x15, 0xa4, 0x93 }; |
| 106 | 106 | ||
| ... | @@ -110,7 +110,7 @@ test "x25519 rfc7748 vector2" { | ... | @@ -110,7 +110,7 @@ test "x25519 rfc7748 vector2" { |
| 110 | try std.testing.expectEqual(output, expected_output); | 110 | try std.testing.expectEqual(output, expected_output); |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | test "x25519 rfc7748 one iteration" { | 113 | test "rfc7748 one iteration" { |
| 114 | const initial_value = [32]u8{ 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 114 | const initial_value = [32]u8{ 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
| 115 | const expected_output = [32]u8{ 0x42, 0x2c, 0x8e, 0x7a, 0x62, 0x27, 0xd7, 0xbc, 0xa1, 0x35, 0x0b, 0x3e, 0x2b, 0xb7, 0x27, 0x9f, 0x78, 0x97, 0xb8, 0x7b, 0xb6, 0x85, 0x4b, 0x78, 0x3c, 0x60, 0xe8, 0x03, 0x11, 0xae, 0x30, 0x79 }; | 115 | const expected_output = [32]u8{ 0x42, 0x2c, 0x8e, 0x7a, 0x62, 0x27, 0xd7, 0xbc, 0xa1, 0x35, 0x0b, 0x3e, 0x2b, 0xb7, 0x27, 0x9f, 0x78, 0x97, 0xb8, 0x7b, 0xb6, 0x85, 0x4b, 0x78, 0x3c, 0x60, 0xe8, 0x03, 0x11, 0xae, 0x30, 0x79 }; |
| 116 | 116 | ||
| ... | @@ -127,7 +127,7 @@ test "x25519 rfc7748 one iteration" { | ... | @@ -127,7 +127,7 @@ test "x25519 rfc7748 one iteration" { |
| 127 | try std.testing.expectEqual(k, expected_output); | 127 | try std.testing.expectEqual(k, expected_output); |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | test "x25519 rfc7748 1,000 iterations" { | 130 | test "rfc7748 1,000 iterations" { |
| 131 | // These iteration tests are slow so we always skip them. Results have been verified. | 131 | // These iteration tests are slow so we always skip them. Results have been verified. |
| 132 | if (true) { | 132 | if (true) { |
| 133 | return error.SkipZigTest; | 133 | return error.SkipZigTest; |
| ... | @@ -149,7 +149,7 @@ test "x25519 rfc7748 1,000 iterations" { | ... | @@ -149,7 +149,7 @@ test "x25519 rfc7748 1,000 iterations" { |
| 149 | try std.testing.expectEqual(k, expected_output); | 149 | try std.testing.expectEqual(k, expected_output); |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | test "x25519 rfc7748 1,000,000 iterations" { | 152 | test "rfc7748 1,000,000 iterations" { |
| 153 | if (true) { | 153 | if (true) { |
| 154 | return error.SkipZigTest; | 154 | return error.SkipZigTest; |
| 155 | } | 155 | } |
lib/std/crypto/chacha20.zig+8-8| ... | @@ -758,7 +758,7 @@ fn XChaChaPoly1305(comptime rounds_nb: usize) type { | ... | @@ -758,7 +758,7 @@ fn XChaChaPoly1305(comptime rounds_nb: usize) type { |
| 758 | }; | 758 | }; |
| 759 | } | 759 | } |
| 760 | 760 | ||
| 761 | test "chacha20 AEAD API" { | 761 | test "AEAD API" { |
| 762 | const aeads = [_]type{ ChaCha20Poly1305, XChaCha20Poly1305 }; | 762 | const aeads = [_]type{ ChaCha20Poly1305, XChaCha20Poly1305 }; |
| 763 | const m = "Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it."; | 763 | const m = "Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it."; |
| 764 | const ad = "Additional data"; | 764 | const ad = "Additional data"; |
| ... | @@ -779,7 +779,7 @@ test "chacha20 AEAD API" { | ... | @@ -779,7 +779,7 @@ test "chacha20 AEAD API" { |
| 779 | } | 779 | } |
| 780 | 780 | ||
| 781 | // https://tools.ietf.org/html/rfc7539#section-2.4.2 | 781 | // https://tools.ietf.org/html/rfc7539#section-2.4.2 |
| 782 | test "crypto.chacha20 test vector sunscreen" { | 782 | test "test vector sunscreen" { |
| 783 | const expected_result = [_]u8{ | 783 | const expected_result = [_]u8{ |
| 784 | 0x6e, 0x2e, 0x35, 0x9a, 0x25, 0x68, 0xf9, 0x80, | 784 | 0x6e, 0x2e, 0x35, 0x9a, 0x25, 0x68, 0xf9, 0x80, |
| 785 | 0x41, 0xba, 0x07, 0x28, 0xdd, 0x0d, 0x69, 0x81, | 785 | 0x41, 0xba, 0x07, 0x28, 0xdd, 0x0d, 0x69, 0x81, |
| ... | @@ -820,7 +820,7 @@ test "crypto.chacha20 test vector sunscreen" { | ... | @@ -820,7 +820,7 @@ test "crypto.chacha20 test vector sunscreen" { |
| 820 | } | 820 | } |
| 821 | 821 | ||
| 822 | // https://tools.ietf.org/html/draft-agl-tls-chacha20poly1305-04#section-7 | 822 | // https://tools.ietf.org/html/draft-agl-tls-chacha20poly1305-04#section-7 |
| 823 | test "crypto.chacha20 test vector 1" { | 823 | test "test vector 1" { |
| 824 | const expected_result = [_]u8{ | 824 | const expected_result = [_]u8{ |
| 825 | 0x76, 0xb8, 0xe0, 0xad, 0xa0, 0xf1, 0x3d, 0x90, | 825 | 0x76, 0xb8, 0xe0, 0xad, 0xa0, 0xf1, 0x3d, 0x90, |
| 826 | 0x40, 0x5d, 0x6a, 0xe5, 0x53, 0x86, 0xbd, 0x28, | 826 | 0x40, 0x5d, 0x6a, 0xe5, 0x53, 0x86, 0xbd, 0x28, |
| ... | @@ -854,7 +854,7 @@ test "crypto.chacha20 test vector 1" { | ... | @@ -854,7 +854,7 @@ test "crypto.chacha20 test vector 1" { |
| 854 | try testing.expectEqualSlices(u8, &expected_result, &result); | 854 | try testing.expectEqualSlices(u8, &expected_result, &result); |
| 855 | } | 855 | } |
| 856 | 856 | ||
| 857 | test "crypto.chacha20 test vector 2" { | 857 | test "test vector 2" { |
| 858 | const expected_result = [_]u8{ | 858 | const expected_result = [_]u8{ |
| 859 | 0x45, 0x40, 0xf0, 0x5a, 0x9f, 0x1f, 0xb2, 0x96, | 859 | 0x45, 0x40, 0xf0, 0x5a, 0x9f, 0x1f, 0xb2, 0x96, |
| 860 | 0xd7, 0x73, 0x6e, 0x7b, 0x20, 0x8e, 0x3c, 0x96, | 860 | 0xd7, 0x73, 0x6e, 0x7b, 0x20, 0x8e, 0x3c, 0x96, |
| ... | @@ -888,7 +888,7 @@ test "crypto.chacha20 test vector 2" { | ... | @@ -888,7 +888,7 @@ test "crypto.chacha20 test vector 2" { |
| 888 | try testing.expectEqualSlices(u8, &expected_result, &result); | 888 | try testing.expectEqualSlices(u8, &expected_result, &result); |
| 889 | } | 889 | } |
| 890 | 890 | ||
| 891 | test "crypto.chacha20 test vector 3" { | 891 | test "test vector 3" { |
| 892 | const expected_result = [_]u8{ | 892 | const expected_result = [_]u8{ |
| 893 | 0xde, 0x9c, 0xba, 0x7b, 0xf3, 0xd6, 0x9e, 0xf5, | 893 | 0xde, 0x9c, 0xba, 0x7b, 0xf3, 0xd6, 0x9e, 0xf5, |
| 894 | 0xe7, 0x86, 0xdc, 0x63, 0x97, 0x3f, 0x65, 0x3a, | 894 | 0xe7, 0x86, 0xdc, 0x63, 0x97, 0x3f, 0x65, 0x3a, |
| ... | @@ -922,7 +922,7 @@ test "crypto.chacha20 test vector 3" { | ... | @@ -922,7 +922,7 @@ test "crypto.chacha20 test vector 3" { |
| 922 | try testing.expectEqualSlices(u8, &expected_result, &result); | 922 | try testing.expectEqualSlices(u8, &expected_result, &result); |
| 923 | } | 923 | } |
| 924 | 924 | ||
| 925 | test "crypto.chacha20 test vector 4" { | 925 | test "test vector 4" { |
| 926 | const expected_result = [_]u8{ | 926 | const expected_result = [_]u8{ |
| 927 | 0xef, 0x3f, 0xdf, 0xd6, 0xc6, 0x15, 0x78, 0xfb, | 927 | 0xef, 0x3f, 0xdf, 0xd6, 0xc6, 0x15, 0x78, 0xfb, |
| 928 | 0xf5, 0xcf, 0x35, 0xbd, 0x3d, 0xd3, 0x3b, 0x80, | 928 | 0xf5, 0xcf, 0x35, 0xbd, 0x3d, 0xd3, 0x3b, 0x80, |
| ... | @@ -956,7 +956,7 @@ test "crypto.chacha20 test vector 4" { | ... | @@ -956,7 +956,7 @@ test "crypto.chacha20 test vector 4" { |
| 956 | try testing.expectEqualSlices(u8, &expected_result, &result); | 956 | try testing.expectEqualSlices(u8, &expected_result, &result); |
| 957 | } | 957 | } |
| 958 | 958 | ||
| 959 | test "crypto.chacha20 test vector 5" { | 959 | test "test vector 5" { |
| 960 | const expected_result = [_]u8{ | 960 | const expected_result = [_]u8{ |
| 961 | 0xf7, 0x98, 0xa1, 0x89, 0xf1, 0x95, 0xe6, 0x69, | 961 | 0xf7, 0x98, 0xa1, 0x89, 0xf1, 0x95, 0xe6, 0x69, |
| 962 | 0x82, 0x10, 0x5f, 0xfb, 0x64, 0x0b, 0xb7, 0x75, | 962 | 0x82, 0x10, 0x5f, 0xfb, 0x64, 0x0b, 0xb7, 0x75, |
| ... | @@ -1142,7 +1142,7 @@ test "open" { | ... | @@ -1142,7 +1142,7 @@ test "open" { |
| 1142 | } | 1142 | } |
| 1143 | } | 1143 | } |
| 1144 | 1144 | ||
| 1145 | test "crypto.xchacha20" { | 1145 | test "xchacha20" { |
| 1146 | const key = [_]u8{69} ** 32; | 1146 | const key = [_]u8{69} ** 32; |
| 1147 | const nonce = [_]u8{42} ** 24; | 1147 | const nonce = [_]u8{42} ** 24; |
| 1148 | const m = "Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it."; | 1148 | const m = "Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it."; |
lib/std/crypto/ecdsa.zig+6-6| ... | @@ -371,7 +371,7 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type { | ... | @@ -371,7 +371,7 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type { |
| 371 | }; | 371 | }; |
| 372 | } | 372 | } |
| 373 | 373 | ||
| 374 | test "ECDSA - Basic operations over EcdsaP384Sha384" { | 374 | test "Basic operations over EcdsaP384Sha384" { |
| 375 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 375 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 376 | 376 | ||
| 377 | const Scheme = EcdsaP384Sha384; | 377 | const Scheme = EcdsaP384Sha384; |
| ... | @@ -387,7 +387,7 @@ test "ECDSA - Basic operations over EcdsaP384Sha384" { | ... | @@ -387,7 +387,7 @@ test "ECDSA - Basic operations over EcdsaP384Sha384" { |
| 387 | try sig2.verify(msg, kp.public_key); | 387 | try sig2.verify(msg, kp.public_key); |
| 388 | } | 388 | } |
| 389 | 389 | ||
| 390 | test "ECDSA - Basic operations over Secp256k1" { | 390 | test "Basic operations over Secp256k1" { |
| 391 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 391 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 392 | 392 | ||
| 393 | const Scheme = EcdsaSecp256k1Sha256oSha256; | 393 | const Scheme = EcdsaSecp256k1Sha256oSha256; |
| ... | @@ -403,7 +403,7 @@ test "ECDSA - Basic operations over Secp256k1" { | ... | @@ -403,7 +403,7 @@ test "ECDSA - Basic operations over Secp256k1" { |
| 403 | try sig2.verify(msg, kp.public_key); | 403 | try sig2.verify(msg, kp.public_key); |
| 404 | } | 404 | } |
| 405 | 405 | ||
| 406 | test "ECDSA - Basic operations over EcdsaP384Sha256" { | 406 | test "Basic operations over EcdsaP384Sha256" { |
| 407 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 407 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 408 | 408 | ||
| 409 | const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256); | 409 | const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256); |
| ... | @@ -419,7 +419,7 @@ test "ECDSA - Basic operations over EcdsaP384Sha256" { | ... | @@ -419,7 +419,7 @@ test "ECDSA - Basic operations over EcdsaP384Sha256" { |
| 419 | try sig2.verify(msg, kp.public_key); | 419 | try sig2.verify(msg, kp.public_key); |
| 420 | } | 420 | } |
| 421 | 421 | ||
| 422 | test "ECDSA - Verifying a existing signature with EcdsaP384Sha256" { | 422 | test "Verifying a existing signature with EcdsaP384Sha256" { |
| 423 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 423 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 424 | 424 | ||
| 425 | const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256); | 425 | const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256); |
| ... | @@ -463,7 +463,7 @@ const TestVector = struct { | ... | @@ -463,7 +463,7 @@ const TestVector = struct { |
| 463 | result: enum { valid, invalid, acceptable }, | 463 | result: enum { valid, invalid, acceptable }, |
| 464 | }; | 464 | }; |
| 465 | 465 | ||
| 466 | test "ECDSA - Test vectors from Project Wycheproof" { | 466 | test "Test vectors from Project Wycheproof" { |
| 467 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 467 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 468 | 468 | ||
| 469 | const vectors = [_]TestVector{ | 469 | const vectors = [_]TestVector{ |
| ... | @@ -877,7 +877,7 @@ fn tvTry(vector: TestVector) !void { | ... | @@ -877,7 +877,7 @@ fn tvTry(vector: TestVector) !void { |
| 877 | try sig.verify(msg, pk); | 877 | try sig.verify(msg, pk); |
| 878 | } | 878 | } |
| 879 | 879 | ||
| 880 | test "ECDSA - Sec1 encoding/decoding" { | 880 | test "Sec1 encoding/decoding" { |
| 881 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 881 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 882 | 882 | ||
| 883 | const Scheme = EcdsaP384Sha384; | 883 | const Scheme = EcdsaP384Sha384; |
lib/std/crypto/hmac.zig+3-3| ... | @@ -76,7 +76,7 @@ pub fn Hmac(comptime Hash: type) type { | ... | @@ -76,7 +76,7 @@ pub fn Hmac(comptime Hash: type) type { |
| 76 | 76 | ||
| 77 | const htest = @import("test.zig"); | 77 | const htest = @import("test.zig"); |
| 78 | 78 | ||
| 79 | test "hmac md5" { | 79 | test "md5" { |
| 80 | var out: [HmacMd5.mac_length]u8 = undefined; | 80 | var out: [HmacMd5.mac_length]u8 = undefined; |
| 81 | HmacMd5.create(out[0..], "", ""); | 81 | HmacMd5.create(out[0..], "", ""); |
| 82 | try htest.assertEqual("74e6f7298a9c2d168935f58c001bad88", out[0..]); | 82 | try htest.assertEqual("74e6f7298a9c2d168935f58c001bad88", out[0..]); |
| ... | @@ -85,7 +85,7 @@ test "hmac md5" { | ... | @@ -85,7 +85,7 @@ test "hmac md5" { |
| 85 | try htest.assertEqual("80070713463e7749b90c2dc24911e275", out[0..]); | 85 | try htest.assertEqual("80070713463e7749b90c2dc24911e275", out[0..]); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | test "hmac sha1" { | 88 | test "sha1" { |
| 89 | var out: [HmacSha1.mac_length]u8 = undefined; | 89 | var out: [HmacSha1.mac_length]u8 = undefined; |
| 90 | HmacSha1.create(out[0..], "", ""); | 90 | HmacSha1.create(out[0..], "", ""); |
| 91 | try htest.assertEqual("fbdb1d1b18aa6c08324b7d64b71fb76370690e1d", out[0..]); | 91 | try htest.assertEqual("fbdb1d1b18aa6c08324b7d64b71fb76370690e1d", out[0..]); |
| ... | @@ -94,7 +94,7 @@ test "hmac sha1" { | ... | @@ -94,7 +94,7 @@ test "hmac sha1" { |
| 94 | try htest.assertEqual("de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9", out[0..]); | 94 | try htest.assertEqual("de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9", out[0..]); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | test "hmac sha256" { | 97 | test "sha256" { |
| 98 | var out: [sha2.HmacSha256.mac_length]u8 = undefined; | 98 | var out: [sha2.HmacSha256.mac_length]u8 = undefined; |
| 99 | sha2.HmacSha256.create(out[0..], "", ""); | 99 | sha2.HmacSha256.create(out[0..], "", ""); |
| 100 | try htest.assertEqual("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad", out[0..]); | 100 | try htest.assertEqual("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad", out[0..]); |
lib/std/crypto/md5.zig+3-3| ... | @@ -232,7 +232,7 @@ pub const Md5 = struct { | ... | @@ -232,7 +232,7 @@ pub const Md5 = struct { |
| 232 | 232 | ||
| 233 | const htest = @import("test.zig"); | 233 | const htest = @import("test.zig"); |
| 234 | 234 | ||
| 235 | test "md5 single" { | 235 | test "single" { |
| 236 | try htest.assertEqualHash(Md5, "d41d8cd98f00b204e9800998ecf8427e", ""); | 236 | try htest.assertEqualHash(Md5, "d41d8cd98f00b204e9800998ecf8427e", ""); |
| 237 | try htest.assertEqualHash(Md5, "0cc175b9c0f1b6a831c399e269772661", "a"); | 237 | try htest.assertEqualHash(Md5, "0cc175b9c0f1b6a831c399e269772661", "a"); |
| 238 | try htest.assertEqualHash(Md5, "900150983cd24fb0d6963f7d28e17f72", "abc"); | 238 | try htest.assertEqualHash(Md5, "900150983cd24fb0d6963f7d28e17f72", "abc"); |
| ... | @@ -242,7 +242,7 @@ test "md5 single" { | ... | @@ -242,7 +242,7 @@ test "md5 single" { |
| 242 | try htest.assertEqualHash(Md5, "57edf4a22be3c955ac49da2e2107b67a", "12345678901234567890123456789012345678901234567890123456789012345678901234567890"); | 242 | try htest.assertEqualHash(Md5, "57edf4a22be3c955ac49da2e2107b67a", "12345678901234567890123456789012345678901234567890123456789012345678901234567890"); |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | test "md5 streaming" { | 245 | test "streaming" { |
| 246 | var h = Md5.init(.{}); | 246 | var h = Md5.init(.{}); |
| 247 | var out: [16]u8 = undefined; | 247 | var out: [16]u8 = undefined; |
| 248 | 248 | ||
| ... | @@ -263,7 +263,7 @@ test "md5 streaming" { | ... | @@ -263,7 +263,7 @@ test "md5 streaming" { |
| 263 | try htest.assertEqual("900150983cd24fb0d6963f7d28e17f72", out[0..]); | 263 | try htest.assertEqual("900150983cd24fb0d6963f7d28e17f72", out[0..]); |
| 264 | } | 264 | } |
| 265 | 265 | ||
| 266 | test "md5 aligned final" { | 266 | test "aligned final" { |
| 267 | var block = [_]u8{0} ** Md5.block_length; | 267 | var block = [_]u8{0} ** Md5.block_length; |
| 268 | var out: [Md5.digest_length]u8 = undefined; | 268 | var out: [Md5.digest_length]u8 = undefined; |
| 269 | 269 |
lib/std/crypto/poly1305.zig+2-2| ... | @@ -195,7 +195,7 @@ pub const Poly1305 = struct { | ... | @@ -195,7 +195,7 @@ pub const Poly1305 = struct { |
| 195 | } | 195 | } |
| 196 | }; | 196 | }; |
| 197 | 197 | ||
| 198 | test "poly1305 rfc7439 vector1" { | 198 | test "rfc7439 vector1" { |
| 199 | const expected_mac = "\xa8\x06\x1d\xc1\x30\x51\x36\xc6\xc2\x2b\x8b\xaf\x0c\x01\x27\xa9"; | 199 | const expected_mac = "\xa8\x06\x1d\xc1\x30\x51\x36\xc6\xc2\x2b\x8b\xaf\x0c\x01\x27\xa9"; |
| 200 | 200 | ||
| 201 | const msg = "Cryptographic Forum Research Group"; | 201 | const msg = "Cryptographic Forum Research Group"; |
| ... | @@ -208,7 +208,7 @@ test "poly1305 rfc7439 vector1" { | ... | @@ -208,7 +208,7 @@ test "poly1305 rfc7439 vector1" { |
| 208 | try std.testing.expectEqualSlices(u8, expected_mac, &mac); | 208 | try std.testing.expectEqualSlices(u8, expected_mac, &mac); |
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | test "poly1305 requiring a final reduction" { | 211 | test "requiring a final reduction" { |
| 212 | const expected_mac = [_]u8{ 25, 13, 249, 42, 164, 57, 99, 60, 149, 181, 74, 74, 13, 63, 121, 6 }; | 212 | const expected_mac = [_]u8{ 25, 13, 249, 42, 164, 57, 99, 60, 149, 181, 74, 74, 13, 63, 121, 6 }; |
| 213 | const msg = [_]u8{ 253, 193, 249, 146, 70, 6, 214, 226, 131, 213, 241, 116, 20, 24, 210, 224, 65, 151, 255, 104, 133 }; | 213 | const msg = [_]u8{ 253, 193, 249, 146, 70, 6, 214, 226, 131, 213, 241, 116, 20, 24, 210, 224, 65, 151, 255, 104, 133 }; |
| 214 | const key = [_]u8{ 190, 63, 95, 57, 155, 103, 77, 170, 7, 98, 106, 44, 117, 186, 90, 185, 109, 118, 184, 24, 69, 41, 166, 243, 119, 132, 151, 61, 52, 43, 64, 250 }; | 214 | const key = [_]u8{ 190, 63, 95, 57, 155, 103, 77, 170, 7, 98, 106, 44, 117, 186, 90, 185, 109, 118, 184, 24, 69, 41, 166, 243, 119, 132, 151, 61, 52, 43, 64, 250 }; |
lib/std/crypto/utils.zig+5-5| ... | @@ -138,7 +138,7 @@ pub inline fn secureZero(comptime T: type, s: []T) void { | ... | @@ -138,7 +138,7 @@ pub inline fn secureZero(comptime T: type, s: []T) void { |
| 138 | @memset(@as([]volatile T, s), 0); | 138 | @memset(@as([]volatile T, s), 0); |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | test "crypto.utils.timingSafeEql" { | 141 | test "timingSafeEql" { |
| 142 | var a: [100]u8 = undefined; | 142 | var a: [100]u8 = undefined; |
| 143 | var b: [100]u8 = undefined; | 143 | var b: [100]u8 = undefined; |
| 144 | random.bytes(a[0..]); | 144 | random.bytes(a[0..]); |
| ... | @@ -148,7 +148,7 @@ test "crypto.utils.timingSafeEql" { | ... | @@ -148,7 +148,7 @@ test "crypto.utils.timingSafeEql" { |
| 148 | try testing.expect(timingSafeEql([100]u8, a, b)); | 148 | try testing.expect(timingSafeEql([100]u8, a, b)); |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | test "crypto.utils.timingSafeEql (vectors)" { | 151 | test "timingSafeEql (vectors)" { |
| 152 | if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; | 152 | if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 153 | 153 | ||
| 154 | var a: [100]u8 = undefined; | 154 | var a: [100]u8 = undefined; |
| ... | @@ -162,7 +162,7 @@ test "crypto.utils.timingSafeEql (vectors)" { | ... | @@ -162,7 +162,7 @@ test "crypto.utils.timingSafeEql (vectors)" { |
| 162 | try testing.expect(timingSafeEql(@Vector(100, u8), v1, v3)); | 162 | try testing.expect(timingSafeEql(@Vector(100, u8), v1, v3)); |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | test "crypto.utils.timingSafeCompare" { | 165 | test "timingSafeCompare" { |
| 166 | var a = [_]u8{10} ** 32; | 166 | var a = [_]u8{10} ** 32; |
| 167 | var b = [_]u8{10} ** 32; | 167 | var b = [_]u8{10} ** 32; |
| 168 | try testing.expectEqual(timingSafeCompare(u8, &a, &b, .big), .eq); | 168 | try testing.expectEqual(timingSafeCompare(u8, &a, &b, .big), .eq); |
| ... | @@ -175,7 +175,7 @@ test "crypto.utils.timingSafeCompare" { | ... | @@ -175,7 +175,7 @@ test "crypto.utils.timingSafeCompare" { |
| 175 | try testing.expectEqual(timingSafeCompare(u8, &a, &b, .little), .lt); | 175 | try testing.expectEqual(timingSafeCompare(u8, &a, &b, .little), .lt); |
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | test "crypto.utils.timingSafe{Add,Sub}" { | 178 | test "timingSafe{Add,Sub}" { |
| 179 | const len = 32; | 179 | const len = 32; |
| 180 | var a: [len]u8 = undefined; | 180 | var a: [len]u8 = undefined; |
| 181 | var b: [len]u8 = undefined; | 181 | var b: [len]u8 = undefined; |
| ... | @@ -195,7 +195,7 @@ test "crypto.utils.timingSafe{Add,Sub}" { | ... | @@ -195,7 +195,7 @@ test "crypto.utils.timingSafe{Add,Sub}" { |
| 195 | } | 195 | } |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | test "crypto.utils.secureZero" { | 198 | test "secureZero" { |
| 199 | var a = [_]u8{0xfe} ** 8; | 199 | var a = [_]u8{0xfe} ** 8; |
| 200 | var b = [_]u8{0xfe} ** 8; | 200 | var b = [_]u8{0xfe} ** 8; |
| 201 | 201 |
lib/std/enums.zig+12-12| ... | @@ -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 "std.enums.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 "std.enums.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; |
| ... | @@ -178,7 +178,7 @@ test "std.enums.directEnumArrayDefault" { | ... | @@ -178,7 +178,7 @@ test "std.enums.directEnumArrayDefault" { |
| 178 | try testing.expectEqual(false, array[2]); | 178 | try testing.expectEqual(false, array[2]); |
| 179 | } | 179 | } |
| 180 | 180 | ||
| 181 | test "std.enums.directEnumArrayDefault slice" { | 181 | test "directEnumArrayDefault slice" { |
| 182 | const E = enum(i4) { a = 4, b = 6, c = 2 }; | 182 | const E = enum(i4) { a = 4, b = 6, c = 2 }; |
| 183 | var runtime_b = "b"; | 183 | var runtime_b = "b"; |
| 184 | _ = &runtime_b; | 184 | _ = &runtime_b; |
| ... | @@ -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 "std.enums.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)); |
| ... | @@ -983,7 +983,7 @@ test "pure EnumSet fns" { | ... | @@ -983,7 +983,7 @@ test "pure EnumSet fns" { |
| 983 | try testing.expect(full.differenceWith(black).eql(red)); | 983 | try testing.expect(full.differenceWith(black).eql(red)); |
| 984 | } | 984 | } |
| 985 | 985 | ||
| 986 | test "std.enums.EnumSet empty" { | 986 | test "EnumSet empty" { |
| 987 | const E = enum {}; | 987 | const E = enum {}; |
| 988 | const empty = EnumSet(E).initEmpty(); | 988 | const empty = EnumSet(E).initEmpty(); |
| 989 | const full = EnumSet(E).initFull(); | 989 | const full = EnumSet(E).initFull(); |
| ... | @@ -994,7 +994,7 @@ test "std.enums.EnumSet empty" { | ... | @@ -994,7 +994,7 @@ test "std.enums.EnumSet empty" { |
| 994 | try std.testing.expect(empty.eql(full.complement())); | 994 | try std.testing.expect(empty.eql(full.complement())); |
| 995 | } | 995 | } |
| 996 | 996 | ||
| 997 | test "std.enums.EnumSet const iterator" { | 997 | test "EnumSet const iterator" { |
| 998 | const Direction = enum { up, down, left, right }; | 998 | const Direction = enum { up, down, left, right }; |
| 999 | const diag_move = init: { | 999 | const diag_move = init: { |
| 1000 | var move = EnumSet(Direction).initEmpty(); | 1000 | var move = EnumSet(Direction).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 "std.enums.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; |
| ... | @@ -1463,7 +1463,7 @@ test "EnumIndexer non-exhaustive" { | ... | @@ -1463,7 +1463,7 @@ test "EnumIndexer non-exhaustive" { |
| 1463 | } | 1463 | } |
| 1464 | } | 1464 | } |
| 1465 | 1465 | ||
| 1466 | test "std.enums.EnumIndexer dense zeroed" { | 1466 | test "EnumIndexer dense zeroed" { |
| 1467 | const E = enum(u2) { b = 1, a = 0, c = 2 }; | 1467 | const E = enum(u2) { b = 1, a = 0, c = 2 }; |
| 1468 | const Indexer = EnumIndexer(E); | 1468 | const Indexer = EnumIndexer(E); |
| 1469 | ensureIndexer(Indexer); | 1469 | ensureIndexer(Indexer); |
| ... | @@ -1479,7 +1479,7 @@ test "std.enums.EnumIndexer dense zeroed" { | ... | @@ -1479,7 +1479,7 @@ test "std.enums.EnumIndexer dense zeroed" { |
| 1479 | try testing.expectEqual(E.c, Indexer.keyForIndex(2)); | 1479 | try testing.expectEqual(E.c, Indexer.keyForIndex(2)); |
| 1480 | } | 1480 | } |
| 1481 | 1481 | ||
| 1482 | test "std.enums.EnumIndexer dense positive" { | 1482 | test "EnumIndexer dense positive" { |
| 1483 | const E = enum(u4) { c = 6, a = 4, b = 5 }; | 1483 | const E = enum(u4) { c = 6, a = 4, b = 5 }; |
| 1484 | const Indexer = EnumIndexer(E); | 1484 | const Indexer = EnumIndexer(E); |
| 1485 | ensureIndexer(Indexer); | 1485 | ensureIndexer(Indexer); |
| ... | @@ -1495,7 +1495,7 @@ test "std.enums.EnumIndexer dense positive" { | ... | @@ -1495,7 +1495,7 @@ test "std.enums.EnumIndexer dense positive" { |
| 1495 | try testing.expectEqual(E.c, Indexer.keyForIndex(2)); | 1495 | try testing.expectEqual(E.c, Indexer.keyForIndex(2)); |
| 1496 | } | 1496 | } |
| 1497 | 1497 | ||
| 1498 | test "std.enums.EnumIndexer dense negative" { | 1498 | test "EnumIndexer dense negative" { |
| 1499 | const E = enum(i4) { a = -6, c = -4, b = -5 }; | 1499 | const E = enum(i4) { a = -6, c = -4, b = -5 }; |
| 1500 | const Indexer = EnumIndexer(E); | 1500 | const Indexer = EnumIndexer(E); |
| 1501 | ensureIndexer(Indexer); | 1501 | ensureIndexer(Indexer); |
| ... | @@ -1511,7 +1511,7 @@ test "std.enums.EnumIndexer dense negative" { | ... | @@ -1511,7 +1511,7 @@ test "std.enums.EnumIndexer dense negative" { |
| 1511 | try testing.expectEqual(E.c, Indexer.keyForIndex(2)); | 1511 | try testing.expectEqual(E.c, Indexer.keyForIndex(2)); |
| 1512 | } | 1512 | } |
| 1513 | 1513 | ||
| 1514 | test "std.enums.EnumIndexer sparse" { | 1514 | test "EnumIndexer sparse" { |
| 1515 | const E = enum(i4) { a = -2, c = 6, b = 4 }; | 1515 | const E = enum(i4) { a = -2, c = 6, b = 4 }; |
| 1516 | const Indexer = EnumIndexer(E); | 1516 | const Indexer = EnumIndexer(E); |
| 1517 | ensureIndexer(Indexer); | 1517 | ensureIndexer(Indexer); |
| ... | @@ -1527,7 +1527,7 @@ test "std.enums.EnumIndexer sparse" { | ... | @@ -1527,7 +1527,7 @@ test "std.enums.EnumIndexer sparse" { |
| 1527 | try testing.expectEqual(E.c, Indexer.keyForIndex(2)); | 1527 | try testing.expectEqual(E.c, Indexer.keyForIndex(2)); |
| 1528 | } | 1528 | } |
| 1529 | 1529 | ||
| 1530 | test "std.enums.EnumIndexer empty" { | 1530 | test "EnumIndexer empty" { |
| 1531 | const E = enum {}; | 1531 | const E = enum {}; |
| 1532 | const Indexer = EnumIndexer(E); | 1532 | const Indexer = EnumIndexer(E); |
| 1533 | ensureIndexer(Indexer); | 1533 | ensureIndexer(Indexer); |
lib/std/fmt/parse_float.zig+10-10| ... | @@ -12,7 +12,7 @@ const epsilon = 1e-7; | ... | @@ -12,7 +12,7 @@ const epsilon = 1e-7; |
| 12 | 12 | ||
| 13 | // See https://github.com/tiehuis/parse-number-fxx-test-data for a wider-selection of test-data. | 13 | // See https://github.com/tiehuis/parse-number-fxx-test-data for a wider-selection of test-data. |
| 14 | 14 | ||
| 15 | test "fmt.parseFloat" { | 15 | test "parseFloat" { |
| 16 | inline for ([_]type{ f16, f32, f64, f128 }) |T| { | 16 | inline for ([_]type{ f16, f32, f64, f128 }) |T| { |
| 17 | try testing.expectError(error.InvalidCharacter, parseFloat(T, "")); | 17 | try testing.expectError(error.InvalidCharacter, parseFloat(T, "")); |
| 18 | try testing.expectError(error.InvalidCharacter, parseFloat(T, " 1")); | 18 | try testing.expectError(error.InvalidCharacter, parseFloat(T, " 1")); |
| ... | @@ -68,7 +68,7 @@ test "fmt.parseFloat" { | ... | @@ -68,7 +68,7 @@ test "fmt.parseFloat" { |
| 68 | } | 68 | } |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | test "fmt.parseFloat nan and inf" { | 71 | test "nan and inf" { |
| 72 | inline for ([_]type{ f16, f32, f64, f128 }) |T| { | 72 | inline for ([_]type{ f16, f32, f64, f128 }) |T| { |
| 73 | const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | 73 | const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); |
| 74 | 74 | ||
| ... | @@ -78,24 +78,24 @@ test "fmt.parseFloat nan and inf" { | ... | @@ -78,24 +78,24 @@ test "fmt.parseFloat nan and inf" { |
| 78 | } | 78 | } |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | test "fmt.parseFloat largest normals" { | 81 | test "largest normals" { |
| 82 | try expectEqual(@as(u16, @bitCast(try parseFloat(f16, "65504"))), 0x7bff); | 82 | try expectEqual(@as(u16, @bitCast(try parseFloat(f16, "65504"))), 0x7bff); |
| 83 | try expectEqual(@as(u32, @bitCast(try parseFloat(f32, "3.4028234664E38"))), 0x7f7f_ffff); | 83 | try expectEqual(@as(u32, @bitCast(try parseFloat(f32, "3.4028234664E38"))), 0x7f7f_ffff); |
| 84 | try expectEqual(@as(u64, @bitCast(try parseFloat(f64, "1.7976931348623157E308"))), 0x7fef_ffff_ffff_ffff); | 84 | try expectEqual(@as(u64, @bitCast(try parseFloat(f64, "1.7976931348623157E308"))), 0x7fef_ffff_ffff_ffff); |
| 85 | try expectEqual(@as(u128, @bitCast(try parseFloat(f128, "1.1897314953572317650857593266280070162E4932"))), 0x7ffe_ffff_ffff_ffff_ffff_ffff_ffff_ffff); | 85 | try expectEqual(@as(u128, @bitCast(try parseFloat(f128, "1.1897314953572317650857593266280070162E4932"))), 0x7ffe_ffff_ffff_ffff_ffff_ffff_ffff_ffff); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | test "fmt.parseFloat #11169" { | 88 | test "#11169" { |
| 89 | try expectEqual(try parseFloat(f128, "9007199254740993.0"), 9007199254740993.0); | 89 | try expectEqual(try parseFloat(f128, "9007199254740993.0"), 9007199254740993.0); |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | test "fmt.parseFloat hex.special" { | 92 | test "hex.special" { |
| 93 | try testing.expect(math.isNan(try parseFloat(f32, "nAn"))); | 93 | try testing.expect(math.isNan(try parseFloat(f32, "nAn"))); |
| 94 | try testing.expect(math.isPositiveInf(try parseFloat(f32, "iNf"))); | 94 | try testing.expect(math.isPositiveInf(try parseFloat(f32, "iNf"))); |
| 95 | try testing.expect(math.isPositiveInf(try parseFloat(f32, "+Inf"))); | 95 | try testing.expect(math.isPositiveInf(try parseFloat(f32, "+Inf"))); |
| 96 | try testing.expect(math.isNegativeInf(try parseFloat(f32, "-iNf"))); | 96 | try testing.expect(math.isNegativeInf(try parseFloat(f32, "-iNf"))); |
| 97 | } | 97 | } |
| 98 | test "fmt.parseFloat hex.zero" { | 98 | test "hex.zero" { |
| 99 | try testing.expectEqual(@as(f32, 0.0), try parseFloat(f32, "0x0")); | 99 | try testing.expectEqual(@as(f32, 0.0), try parseFloat(f32, "0x0")); |
| 100 | try testing.expectEqual(@as(f32, 0.0), try parseFloat(f32, "-0x0")); | 100 | try testing.expectEqual(@as(f32, 0.0), try parseFloat(f32, "-0x0")); |
| 101 | try testing.expectEqual(@as(f32, 0.0), try parseFloat(f32, "0x0p42")); | 101 | try testing.expectEqual(@as(f32, 0.0), try parseFloat(f32, "0x0p42")); |
| ... | @@ -103,7 +103,7 @@ test "fmt.parseFloat hex.zero" { | ... | @@ -103,7 +103,7 @@ test "fmt.parseFloat hex.zero" { |
| 103 | try testing.expectEqual(@as(f32, 0.0), try parseFloat(f32, "0x0.00000p666")); | 103 | try testing.expectEqual(@as(f32, 0.0), try parseFloat(f32, "0x0.00000p666")); |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | test "fmt.parseFloat hex.f16" { | 106 | test "hex.f16" { |
| 107 | try testing.expectEqual(try parseFloat(f16, "0x1p0"), 1.0); | 107 | try testing.expectEqual(try parseFloat(f16, "0x1p0"), 1.0); |
| 108 | try testing.expectEqual(try parseFloat(f16, "-0x1p-1"), -0.5); | 108 | try testing.expectEqual(try parseFloat(f16, "-0x1p-1"), -0.5); |
| 109 | try testing.expectEqual(try parseFloat(f16, "0x10p+10"), 16384.0); | 109 | try testing.expectEqual(try parseFloat(f16, "0x10p+10"), 16384.0); |
| ... | @@ -119,7 +119,7 @@ test "fmt.parseFloat hex.f16" { | ... | @@ -119,7 +119,7 @@ test "fmt.parseFloat hex.f16" { |
| 119 | try testing.expectEqual(try parseFloat(f16, "-0x1p-24"), -math.floatTrueMin(f16)); | 119 | try testing.expectEqual(try parseFloat(f16, "-0x1p-24"), -math.floatTrueMin(f16)); |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | test "fmt.parseFloat hex.f32" { | 122 | test "hex.f32" { |
| 123 | try testing.expectError(error.InvalidCharacter, parseFloat(f32, "0x")); | 123 | try testing.expectError(error.InvalidCharacter, parseFloat(f32, "0x")); |
| 124 | try testing.expectEqual(try parseFloat(f32, "0x1p0"), 1.0); | 124 | try testing.expectEqual(try parseFloat(f32, "0x1p0"), 1.0); |
| 125 | try testing.expectEqual(try parseFloat(f32, "-0x1p-1"), -0.5); | 125 | try testing.expectEqual(try parseFloat(f32, "-0x1p-1"), -0.5); |
| ... | @@ -138,7 +138,7 @@ test "fmt.parseFloat hex.f32" { | ... | @@ -138,7 +138,7 @@ test "fmt.parseFloat hex.f32" { |
| 138 | try testing.expectEqual(try parseFloat(f32, "-0x1P-149"), -math.floatTrueMin(f32)); | 138 | try testing.expectEqual(try parseFloat(f32, "-0x1P-149"), -math.floatTrueMin(f32)); |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | test "fmt.parseFloat hex.f64" { | 141 | test "hex.f64" { |
| 142 | try testing.expectEqual(try parseFloat(f64, "0x1p0"), 1.0); | 142 | try testing.expectEqual(try parseFloat(f64, "0x1p0"), 1.0); |
| 143 | try testing.expectEqual(try parseFloat(f64, "-0x1p-1"), -0.5); | 143 | try testing.expectEqual(try parseFloat(f64, "-0x1p-1"), -0.5); |
| 144 | try testing.expectEqual(try parseFloat(f64, "0x10p+10"), 16384.0); | 144 | try testing.expectEqual(try parseFloat(f64, "0x10p+10"), 16384.0); |
| ... | @@ -153,7 +153,7 @@ test "fmt.parseFloat hex.f64" { | ... | @@ -153,7 +153,7 @@ test "fmt.parseFloat hex.f64" { |
| 153 | try testing.expectEqual(try parseFloat(f64, "0x1p-1074"), math.floatTrueMin(f64)); | 153 | try testing.expectEqual(try parseFloat(f64, "0x1p-1074"), math.floatTrueMin(f64)); |
| 154 | try testing.expectEqual(try parseFloat(f64, "-0x1p-1074"), -math.floatTrueMin(f64)); | 154 | try testing.expectEqual(try parseFloat(f64, "-0x1p-1074"), -math.floatTrueMin(f64)); |
| 155 | } | 155 | } |
| 156 | test "fmt.parseFloat hex.f128" { | 156 | test "hex.f128" { |
| 157 | try testing.expectEqual(try parseFloat(f128, "0x1p0"), 1.0); | 157 | try testing.expectEqual(try parseFloat(f128, "0x1p0"), 1.0); |
| 158 | try testing.expectEqual(try parseFloat(f128, "-0x1p-1"), -0.5); | 158 | try testing.expectEqual(try parseFloat(f128, "-0x1p-1"), -0.5); |
| 159 | try testing.expectEqual(try parseFloat(f128, "0x10p+10"), 16384.0); | 159 | try testing.expectEqual(try parseFloat(f128, "0x10p+10"), 16384.0); |
lib/std/hash_map.zig+23-23| ... | @@ -1612,7 +1612,7 @@ const testing = std.testing; | ... | @@ -1612,7 +1612,7 @@ const testing = std.testing; |
| 1612 | const expect = std.testing.expect; | 1612 | const expect = std.testing.expect; |
| 1613 | const expectEqual = std.testing.expectEqual; | 1613 | const expectEqual = std.testing.expectEqual; |
| 1614 | 1614 | ||
| 1615 | test "std.hash_map basic usage" { | 1615 | test "basic usage" { |
| 1616 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); | 1616 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); |
| 1617 | defer map.deinit(); | 1617 | defer map.deinit(); |
| 1618 | 1618 | ||
| ... | @@ -1640,7 +1640,7 @@ test "std.hash_map basic usage" { | ... | @@ -1640,7 +1640,7 @@ test "std.hash_map basic usage" { |
| 1640 | try expectEqual(total, sum); | 1640 | try expectEqual(total, sum); |
| 1641 | } | 1641 | } |
| 1642 | 1642 | ||
| 1643 | test "std.hash_map ensureTotalCapacity" { | 1643 | test "ensureTotalCapacity" { |
| 1644 | var map = AutoHashMap(i32, i32).init(std.testing.allocator); | 1644 | var map = AutoHashMap(i32, i32).init(std.testing.allocator); |
| 1645 | defer map.deinit(); | 1645 | defer map.deinit(); |
| 1646 | 1646 | ||
| ... | @@ -1655,7 +1655,7 @@ test "std.hash_map ensureTotalCapacity" { | ... | @@ -1655,7 +1655,7 @@ test "std.hash_map ensureTotalCapacity" { |
| 1655 | try testing.expect(initial_capacity == map.capacity()); | 1655 | try testing.expect(initial_capacity == map.capacity()); |
| 1656 | } | 1656 | } |
| 1657 | 1657 | ||
| 1658 | test "std.hash_map ensureUnusedCapacity with tombstones" { | 1658 | test "ensureUnusedCapacity with tombstones" { |
| 1659 | var map = AutoHashMap(i32, i32).init(std.testing.allocator); | 1659 | var map = AutoHashMap(i32, i32).init(std.testing.allocator); |
| 1660 | defer map.deinit(); | 1660 | defer map.deinit(); |
| 1661 | 1661 | ||
| ... | @@ -1667,7 +1667,7 @@ test "std.hash_map ensureUnusedCapacity with tombstones" { | ... | @@ -1667,7 +1667,7 @@ test "std.hash_map ensureUnusedCapacity with tombstones" { |
| 1667 | } | 1667 | } |
| 1668 | } | 1668 | } |
| 1669 | 1669 | ||
| 1670 | test "std.hash_map clearRetainingCapacity" { | 1670 | test "clearRetainingCapacity" { |
| 1671 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); | 1671 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); |
| 1672 | defer map.deinit(); | 1672 | defer map.deinit(); |
| 1673 | 1673 | ||
| ... | @@ -1692,7 +1692,7 @@ test "std.hash_map clearRetainingCapacity" { | ... | @@ -1692,7 +1692,7 @@ test "std.hash_map clearRetainingCapacity" { |
| 1692 | try expect(!map.contains(1)); | 1692 | try expect(!map.contains(1)); |
| 1693 | } | 1693 | } |
| 1694 | 1694 | ||
| 1695 | test "std.hash_map grow" { | 1695 | test "grow" { |
| 1696 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); | 1696 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); |
| 1697 | defer map.deinit(); | 1697 | defer map.deinit(); |
| 1698 | 1698 | ||
| ... | @@ -1718,7 +1718,7 @@ test "std.hash_map grow" { | ... | @@ -1718,7 +1718,7 @@ test "std.hash_map grow" { |
| 1718 | } | 1718 | } |
| 1719 | } | 1719 | } |
| 1720 | 1720 | ||
| 1721 | test "std.hash_map clone" { | 1721 | test "clone" { |
| 1722 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); | 1722 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); |
| 1723 | defer map.deinit(); | 1723 | defer map.deinit(); |
| 1724 | 1724 | ||
| ... | @@ -1756,7 +1756,7 @@ test "std.hash_map clone" { | ... | @@ -1756,7 +1756,7 @@ test "std.hash_map clone" { |
| 1756 | } | 1756 | } |
| 1757 | } | 1757 | } |
| 1758 | 1758 | ||
| 1759 | test "std.hash_map ensureTotalCapacity with existing elements" { | 1759 | test "ensureTotalCapacity with existing elements" { |
| 1760 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); | 1760 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); |
| 1761 | defer map.deinit(); | 1761 | defer map.deinit(); |
| 1762 | 1762 | ||
| ... | @@ -1769,7 +1769,7 @@ test "std.hash_map ensureTotalCapacity with existing elements" { | ... | @@ -1769,7 +1769,7 @@ test "std.hash_map ensureTotalCapacity with existing elements" { |
| 1769 | try expectEqual(map.capacity(), 128); | 1769 | try expectEqual(map.capacity(), 128); |
| 1770 | } | 1770 | } |
| 1771 | 1771 | ||
| 1772 | test "std.hash_map ensureTotalCapacity satisfies max load factor" { | 1772 | test "ensureTotalCapacity satisfies max load factor" { |
| 1773 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); | 1773 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); |
| 1774 | defer map.deinit(); | 1774 | defer map.deinit(); |
| 1775 | 1775 | ||
| ... | @@ -1777,7 +1777,7 @@ test "std.hash_map ensureTotalCapacity satisfies max load factor" { | ... | @@ -1777,7 +1777,7 @@ test "std.hash_map ensureTotalCapacity satisfies max load factor" { |
| 1777 | try expectEqual(map.capacity(), 256); | 1777 | try expectEqual(map.capacity(), 256); |
| 1778 | } | 1778 | } |
| 1779 | 1779 | ||
| 1780 | test "std.hash_map remove" { | 1780 | test "remove" { |
| 1781 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); | 1781 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); |
| 1782 | defer map.deinit(); | 1782 | defer map.deinit(); |
| 1783 | 1783 | ||
| ... | @@ -1809,7 +1809,7 @@ test "std.hash_map remove" { | ... | @@ -1809,7 +1809,7 @@ test "std.hash_map remove" { |
| 1809 | } | 1809 | } |
| 1810 | } | 1810 | } |
| 1811 | 1811 | ||
| 1812 | test "std.hash_map reverse removes" { | 1812 | test "reverse removes" { |
| 1813 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); | 1813 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); |
| 1814 | defer map.deinit(); | 1814 | defer map.deinit(); |
| 1815 | 1815 | ||
| ... | @@ -1831,7 +1831,7 @@ test "std.hash_map reverse removes" { | ... | @@ -1831,7 +1831,7 @@ test "std.hash_map reverse removes" { |
| 1831 | try expectEqual(map.count(), 0); | 1831 | try expectEqual(map.count(), 0); |
| 1832 | } | 1832 | } |
| 1833 | 1833 | ||
| 1834 | test "std.hash_map multiple removes on same metadata" { | 1834 | test "multiple removes on same metadata" { |
| 1835 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); | 1835 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); |
| 1836 | defer map.deinit(); | 1836 | defer map.deinit(); |
| 1837 | 1837 | ||
| ... | @@ -1868,7 +1868,7 @@ test "std.hash_map multiple removes on same metadata" { | ... | @@ -1868,7 +1868,7 @@ test "std.hash_map multiple removes on same metadata" { |
| 1868 | } | 1868 | } |
| 1869 | } | 1869 | } |
| 1870 | 1870 | ||
| 1871 | test "std.hash_map put and remove loop in random order" { | 1871 | test "put and remove loop in random order" { |
| 1872 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); | 1872 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); |
| 1873 | defer map.deinit(); | 1873 | defer map.deinit(); |
| 1874 | 1874 | ||
| ... | @@ -1900,7 +1900,7 @@ test "std.hash_map put and remove loop in random order" { | ... | @@ -1900,7 +1900,7 @@ test "std.hash_map put and remove loop in random order" { |
| 1900 | } | 1900 | } |
| 1901 | } | 1901 | } |
| 1902 | 1902 | ||
| 1903 | test "std.hash_map remove one million elements in random order" { | 1903 | test "remove one million elements in random order" { |
| 1904 | const Map = AutoHashMap(u32, u32); | 1904 | const Map = AutoHashMap(u32, u32); |
| 1905 | const n = 1000 * 1000; | 1905 | const n = 1000 * 1000; |
| 1906 | var map = Map.init(std.heap.page_allocator); | 1906 | var map = Map.init(std.heap.page_allocator); |
| ... | @@ -1930,7 +1930,7 @@ test "std.hash_map remove one million elements in random order" { | ... | @@ -1930,7 +1930,7 @@ test "std.hash_map remove one million elements in random order" { |
| 1930 | } | 1930 | } |
| 1931 | } | 1931 | } |
| 1932 | 1932 | ||
| 1933 | test "std.hash_map put" { | 1933 | test "put" { |
| 1934 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); | 1934 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); |
| 1935 | defer map.deinit(); | 1935 | defer map.deinit(); |
| 1936 | 1936 | ||
| ... | @@ -1955,7 +1955,7 @@ test "std.hash_map put" { | ... | @@ -1955,7 +1955,7 @@ test "std.hash_map put" { |
| 1955 | } | 1955 | } |
| 1956 | } | 1956 | } |
| 1957 | 1957 | ||
| 1958 | test "std.hash_map putAssumeCapacity" { | 1958 | test "putAssumeCapacity" { |
| 1959 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); | 1959 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); |
| 1960 | defer map.deinit(); | 1960 | defer map.deinit(); |
| 1961 | 1961 | ||
| ... | @@ -1985,7 +1985,7 @@ test "std.hash_map putAssumeCapacity" { | ... | @@ -1985,7 +1985,7 @@ test "std.hash_map putAssumeCapacity" { |
| 1985 | try expectEqual(sum, 20); | 1985 | try expectEqual(sum, 20); |
| 1986 | } | 1986 | } |
| 1987 | 1987 | ||
| 1988 | test "std.hash_map repeat putAssumeCapacity/remove" { | 1988 | test "repeat putAssumeCapacity/remove" { |
| 1989 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); | 1989 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); |
| 1990 | defer map.deinit(); | 1990 | defer map.deinit(); |
| 1991 | 1991 | ||
| ... | @@ -2017,7 +2017,7 @@ test "std.hash_map repeat putAssumeCapacity/remove" { | ... | @@ -2017,7 +2017,7 @@ test "std.hash_map repeat putAssumeCapacity/remove" { |
| 2017 | try expectEqual(map.unmanaged.count(), limit); | 2017 | try expectEqual(map.unmanaged.count(), limit); |
| 2018 | } | 2018 | } |
| 2019 | 2019 | ||
| 2020 | test "std.hash_map getOrPut" { | 2020 | test "getOrPut" { |
| 2021 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); | 2021 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); |
| 2022 | defer map.deinit(); | 2022 | defer map.deinit(); |
| 2023 | 2023 | ||
| ... | @@ -2040,7 +2040,7 @@ test "std.hash_map getOrPut" { | ... | @@ -2040,7 +2040,7 @@ test "std.hash_map getOrPut" { |
| 2040 | try expectEqual(sum, 30); | 2040 | try expectEqual(sum, 30); |
| 2041 | } | 2041 | } |
| 2042 | 2042 | ||
| 2043 | test "std.hash_map basic hash map usage" { | 2043 | test "basic hash map usage" { |
| 2044 | var map = AutoHashMap(i32, i32).init(std.testing.allocator); | 2044 | var map = AutoHashMap(i32, i32).init(std.testing.allocator); |
| 2045 | defer map.deinit(); | 2045 | defer map.deinit(); |
| 2046 | 2046 | ||
| ... | @@ -2085,7 +2085,7 @@ test "std.hash_map basic hash map usage" { | ... | @@ -2085,7 +2085,7 @@ test "std.hash_map basic hash map usage" { |
| 2085 | try testing.expect(map.remove(3) == true); | 2085 | try testing.expect(map.remove(3) == true); |
| 2086 | } | 2086 | } |
| 2087 | 2087 | ||
| 2088 | test "std.hash_map getOrPutAdapted" { | 2088 | test "getOrPutAdapted" { |
| 2089 | const AdaptedContext = struct { | 2089 | const AdaptedContext = struct { |
| 2090 | fn eql(self: @This(), adapted_key: []const u8, test_key: u64) bool { | 2090 | fn eql(self: @This(), adapted_key: []const u8, test_key: u64) bool { |
| 2091 | _ = self; | 2091 | _ = self; |
| ... | @@ -2134,7 +2134,7 @@ test "std.hash_map getOrPutAdapted" { | ... | @@ -2134,7 +2134,7 @@ test "std.hash_map getOrPutAdapted" { |
| 2134 | } | 2134 | } |
| 2135 | } | 2135 | } |
| 2136 | 2136 | ||
| 2137 | test "std.hash_map ensureUnusedCapacity" { | 2137 | test "ensureUnusedCapacity" { |
| 2138 | var map = AutoHashMap(u64, u64).init(testing.allocator); | 2138 | var map = AutoHashMap(u64, u64).init(testing.allocator); |
| 2139 | defer map.deinit(); | 2139 | defer map.deinit(); |
| 2140 | 2140 | ||
| ... | @@ -2147,7 +2147,7 @@ test "std.hash_map ensureUnusedCapacity" { | ... | @@ -2147,7 +2147,7 @@ test "std.hash_map ensureUnusedCapacity" { |
| 2147 | try testing.expectEqual(capacity, map.capacity()); | 2147 | try testing.expectEqual(capacity, map.capacity()); |
| 2148 | } | 2148 | } |
| 2149 | 2149 | ||
| 2150 | test "std.hash_map removeByPtr" { | 2150 | test "removeByPtr" { |
| 2151 | var map = AutoHashMap(i32, u64).init(testing.allocator); | 2151 | var map = AutoHashMap(i32, u64).init(testing.allocator); |
| 2152 | defer map.deinit(); | 2152 | defer map.deinit(); |
| 2153 | 2153 | ||
| ... | @@ -2173,7 +2173,7 @@ test "std.hash_map removeByPtr" { | ... | @@ -2173,7 +2173,7 @@ test "std.hash_map removeByPtr" { |
| 2173 | try testing.expect(map.count() == 0); | 2173 | try testing.expect(map.count() == 0); |
| 2174 | } | 2174 | } |
| 2175 | 2175 | ||
| 2176 | test "std.hash_map removeByPtr 0 sized key" { | 2176 | test "removeByPtr 0 sized key" { |
| 2177 | var map = AutoHashMap(u0, u64).init(testing.allocator); | 2177 | var map = AutoHashMap(u0, u64).init(testing.allocator); |
| 2178 | defer map.deinit(); | 2178 | defer map.deinit(); |
| 2179 | 2179 | ||
| ... | @@ -2191,7 +2191,7 @@ test "std.hash_map removeByPtr 0 sized key" { | ... | @@ -2191,7 +2191,7 @@ test "std.hash_map removeByPtr 0 sized key" { |
| 2191 | try testing.expect(map.count() == 0); | 2191 | try testing.expect(map.count() == 0); |
| 2192 | } | 2192 | } |
| 2193 | 2193 | ||
| 2194 | test "std.hash_map repeat fetchRemove" { | 2194 | test "repeat fetchRemove" { |
| 2195 | var map = AutoHashMapUnmanaged(u64, void){}; | 2195 | var map = AutoHashMapUnmanaged(u64, void){}; |
| 2196 | defer map.deinit(testing.allocator); | 2196 | defer map.deinit(testing.allocator); |
| 2197 | 2197 |
lib/std/heap/arena_allocator.zig+2-2| ... | @@ -246,7 +246,7 @@ pub const ArenaAllocator = struct { | ... | @@ -246,7 +246,7 @@ pub const ArenaAllocator = struct { |
| 246 | } | 246 | } |
| 247 | }; | 247 | }; |
| 248 | 248 | ||
| 249 | test "ArenaAllocator (reset with preheating)" { | 249 | test "reset with preheating" { |
| 250 | var arena_allocator = ArenaAllocator.init(std.testing.allocator); | 250 | var arena_allocator = ArenaAllocator.init(std.testing.allocator); |
| 251 | defer arena_allocator.deinit(); | 251 | defer arena_allocator.deinit(); |
| 252 | // provides some variance in the allocated data | 252 | // provides some variance in the allocated data |
| ... | @@ -269,7 +269,7 @@ test "ArenaAllocator (reset with preheating)" { | ... | @@ -269,7 +269,7 @@ test "ArenaAllocator (reset with preheating)" { |
| 269 | } | 269 | } |
| 270 | } | 270 | } |
| 271 | 271 | ||
| 272 | test "ArenaAllocator (reset while retaining a buffer)" { | 272 | test "reset while retaining a buffer" { |
| 273 | var arena_allocator = ArenaAllocator.init(std.testing.allocator); | 273 | var arena_allocator = ArenaAllocator.init(std.testing.allocator); |
| 274 | defer arena_allocator.deinit(); | 274 | defer arena_allocator.deinit(); |
| 275 | const a = arena_allocator.allocator(); | 275 | const a = arena_allocator.allocator(); |
lib/std/heap/memory_pool.zig+6-6| ... | @@ -145,7 +145,7 @@ pub fn MemoryPoolExtra(comptime Item: type, comptime pool_options: Options) type | ... | @@ -145,7 +145,7 @@ pub fn MemoryPoolExtra(comptime Item: type, comptime pool_options: Options) type |
| 145 | }; | 145 | }; |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | test "memory pool: basic" { | 148 | test "basic" { |
| 149 | var pool = MemoryPool(u32).init(std.testing.allocator); | 149 | var pool = MemoryPool(u32).init(std.testing.allocator); |
| 150 | defer pool.deinit(); | 150 | defer pool.deinit(); |
| 151 | 151 | ||
| ... | @@ -165,7 +165,7 @@ test "memory pool: basic" { | ... | @@ -165,7 +165,7 @@ test "memory pool: basic" { |
| 165 | try std.testing.expect(p2 == p4); | 165 | try std.testing.expect(p2 == p4); |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | test "memory pool: preheating (success)" { | 168 | test "preheating (success)" { |
| 169 | var pool = try MemoryPool(u32).initPreheated(std.testing.allocator, 4); | 169 | var pool = try MemoryPool(u32).initPreheated(std.testing.allocator, 4); |
| 170 | defer pool.deinit(); | 170 | defer pool.deinit(); |
| 171 | 171 | ||
| ... | @@ -174,12 +174,12 @@ test "memory pool: preheating (success)" { | ... | @@ -174,12 +174,12 @@ test "memory pool: preheating (success)" { |
| 174 | _ = try pool.create(); | 174 | _ = try pool.create(); |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | test "memory pool: preheating (failure)" { | 177 | test "preheating (failure)" { |
| 178 | const failer = std.testing.failing_allocator; | 178 | const failer = std.testing.failing_allocator; |
| 179 | try std.testing.expectError(error.OutOfMemory, MemoryPool(u32).initPreheated(failer, 5)); | 179 | try std.testing.expectError(error.OutOfMemory, MemoryPool(u32).initPreheated(failer, 5)); |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | test "memory pool: growable" { | 182 | test "growable" { |
| 183 | var pool = try MemoryPoolExtra(u32, .{ .growable = false }).initPreheated(std.testing.allocator, 4); | 183 | var pool = try MemoryPoolExtra(u32, .{ .growable = false }).initPreheated(std.testing.allocator, 4); |
| 184 | defer pool.deinit(); | 184 | defer pool.deinit(); |
| 185 | 185 | ||
| ... | @@ -191,7 +191,7 @@ test "memory pool: growable" { | ... | @@ -191,7 +191,7 @@ test "memory pool: growable" { |
| 191 | try std.testing.expectError(error.OutOfMemory, pool.create()); | 191 | try std.testing.expectError(error.OutOfMemory, pool.create()); |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | test "memory pool: greater than pointer default alignment" { | 194 | test "greater than pointer default alignment" { |
| 195 | const Foo = struct { | 195 | const Foo = struct { |
| 196 | data: u64 align(16), | 196 | data: u64 align(16), |
| 197 | }; | 197 | }; |
| ... | @@ -203,7 +203,7 @@ test "memory pool: greater than pointer default alignment" { | ... | @@ -203,7 +203,7 @@ test "memory pool: greater than pointer default alignment" { |
| 203 | _ = foo; | 203 | _ = foo; |
| 204 | } | 204 | } |
| 205 | 205 | ||
| 206 | test "memory pool: greater than pointer manual alignment" { | 206 | test "greater than pointer manual alignment" { |
| 207 | const Foo = struct { | 207 | const Foo = struct { |
| 208 | data: u64, | 208 | data: u64, |
| 209 | }; | 209 | }; |
lib/std/io/Reader/test.zig+33-33| ... | @@ -15,14 +15,14 @@ test "Reader" { | ... | @@ -15,14 +15,14 @@ test "Reader" { |
| 15 | try testing.expectError(error.EndOfStream, reader.readByte()); | 15 | try testing.expectError(error.EndOfStream, reader.readByte()); |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | test "Reader.isBytes" { | 18 | test "isBytes" { |
| 19 | var fis = std.io.fixedBufferStream("foobar"); | 19 | var fis = std.io.fixedBufferStream("foobar"); |
| 20 | const reader = fis.reader(); | 20 | const reader = fis.reader(); |
| 21 | try testing.expectEqual(true, try reader.isBytes("foo")); | 21 | try testing.expectEqual(true, try reader.isBytes("foo")); |
| 22 | try testing.expectEqual(false, try reader.isBytes("qux")); | 22 | try testing.expectEqual(false, try reader.isBytes("qux")); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | test "Reader.skipBytes" { | 25 | test "skipBytes" { |
| 26 | var fis = std.io.fixedBufferStream("foobar"); | 26 | var fis = std.io.fixedBufferStream("foobar"); |
| 27 | const reader = fis.reader(); | 27 | const reader = fis.reader(); |
| 28 | try reader.skipBytes(3, .{}); | 28 | try reader.skipBytes(3, .{}); |
| ... | @@ -31,7 +31,7 @@ test "Reader.skipBytes" { | ... | @@ -31,7 +31,7 @@ test "Reader.skipBytes" { |
| 31 | try testing.expectError(error.EndOfStream, reader.skipBytes(1, .{})); | 31 | try testing.expectError(error.EndOfStream, reader.skipBytes(1, .{})); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | test "Reader.readUntilDelimiterArrayList returns ArrayLists with bytes read until the delimiter, then EndOfStream" { | 34 | test "readUntilDelimiterArrayList returns ArrayLists with bytes read until the delimiter, then EndOfStream" { |
| 35 | const a = std.testing.allocator; | 35 | const a = std.testing.allocator; |
| 36 | var list = std.ArrayList(u8).init(a); | 36 | var list = std.ArrayList(u8).init(a); |
| 37 | defer list.deinit(); | 37 | defer list.deinit(); |
| ... | @@ -46,7 +46,7 @@ test "Reader.readUntilDelimiterArrayList returns ArrayLists with bytes read unti | ... | @@ -46,7 +46,7 @@ test "Reader.readUntilDelimiterArrayList returns ArrayLists with bytes read unti |
| 46 | try std.testing.expectError(error.EndOfStream, reader.readUntilDelimiterArrayList(&list, '\n', 5)); | 46 | try std.testing.expectError(error.EndOfStream, reader.readUntilDelimiterArrayList(&list, '\n', 5)); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | test "Reader.readUntilDelimiterArrayList returns an empty ArrayList" { | 49 | test "readUntilDelimiterArrayList returns an empty ArrayList" { |
| 50 | const a = std.testing.allocator; | 50 | const a = std.testing.allocator; |
| 51 | var list = std.ArrayList(u8).init(a); | 51 | var list = std.ArrayList(u8).init(a); |
| 52 | defer list.deinit(); | 52 | defer list.deinit(); |
| ... | @@ -58,7 +58,7 @@ test "Reader.readUntilDelimiterArrayList returns an empty ArrayList" { | ... | @@ -58,7 +58,7 @@ test "Reader.readUntilDelimiterArrayList returns an empty ArrayList" { |
| 58 | try std.testing.expectEqualStrings("", list.items); | 58 | try std.testing.expectEqualStrings("", list.items); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | test "Reader.readUntilDelimiterArrayList returns StreamTooLong, then an ArrayList with bytes read until the delimiter" { | 61 | test "readUntilDelimiterArrayList returns StreamTooLong, then an ArrayList with bytes read until the delimiter" { |
| 62 | const a = std.testing.allocator; | 62 | const a = std.testing.allocator; |
| 63 | var list = std.ArrayList(u8).init(a); | 63 | var list = std.ArrayList(u8).init(a); |
| 64 | defer list.deinit(); | 64 | defer list.deinit(); |
| ... | @@ -72,7 +72,7 @@ test "Reader.readUntilDelimiterArrayList returns StreamTooLong, then an ArrayLis | ... | @@ -72,7 +72,7 @@ test "Reader.readUntilDelimiterArrayList returns StreamTooLong, then an ArrayLis |
| 72 | try std.testing.expectEqualStrings("67", list.items); | 72 | try std.testing.expectEqualStrings("67", list.items); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | test "Reader.readUntilDelimiterArrayList returns EndOfStream" { | 75 | test "readUntilDelimiterArrayList returns EndOfStream" { |
| 76 | const a = std.testing.allocator; | 76 | const a = std.testing.allocator; |
| 77 | var list = std.ArrayList(u8).init(a); | 77 | var list = std.ArrayList(u8).init(a); |
| 78 | defer list.deinit(); | 78 | defer list.deinit(); |
| ... | @@ -84,7 +84,7 @@ test "Reader.readUntilDelimiterArrayList returns EndOfStream" { | ... | @@ -84,7 +84,7 @@ test "Reader.readUntilDelimiterArrayList returns EndOfStream" { |
| 84 | try std.testing.expectEqualStrings("1234", list.items); | 84 | try std.testing.expectEqualStrings("1234", list.items); |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | test "Reader.readUntilDelimiterAlloc returns ArrayLists with bytes read until the delimiter, then EndOfStream" { | 87 | test "readUntilDelimiterAlloc returns ArrayLists with bytes read until the delimiter, then EndOfStream" { |
| 88 | const a = std.testing.allocator; | 88 | const a = std.testing.allocator; |
| 89 | 89 | ||
| 90 | var fis = std.io.fixedBufferStream("0000\n1234\n"); | 90 | var fis = std.io.fixedBufferStream("0000\n1234\n"); |
| ... | @@ -105,7 +105,7 @@ test "Reader.readUntilDelimiterAlloc returns ArrayLists with bytes read until th | ... | @@ -105,7 +105,7 @@ test "Reader.readUntilDelimiterAlloc returns ArrayLists with bytes read until th |
| 105 | try std.testing.expectError(error.EndOfStream, reader.readUntilDelimiterAlloc(a, '\n', 5)); | 105 | try std.testing.expectError(error.EndOfStream, reader.readUntilDelimiterAlloc(a, '\n', 5)); |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | test "Reader.readUntilDelimiterAlloc returns an empty ArrayList" { | 108 | test "readUntilDelimiterAlloc returns an empty ArrayList" { |
| 109 | const a = std.testing.allocator; | 109 | const a = std.testing.allocator; |
| 110 | 110 | ||
| 111 | var fis = std.io.fixedBufferStream("\n"); | 111 | var fis = std.io.fixedBufferStream("\n"); |
| ... | @@ -118,7 +118,7 @@ test "Reader.readUntilDelimiterAlloc returns an empty ArrayList" { | ... | @@ -118,7 +118,7 @@ test "Reader.readUntilDelimiterAlloc returns an empty ArrayList" { |
| 118 | } | 118 | } |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | test "Reader.readUntilDelimiterAlloc returns StreamTooLong, then an ArrayList with bytes read until the delimiter" { | 121 | test "readUntilDelimiterAlloc returns StreamTooLong, then an ArrayList with bytes read until the delimiter" { |
| 122 | const a = std.testing.allocator; | 122 | const a = std.testing.allocator; |
| 123 | 123 | ||
| 124 | var fis = std.io.fixedBufferStream("1234567\n"); | 124 | var fis = std.io.fixedBufferStream("1234567\n"); |
| ... | @@ -131,7 +131,7 @@ test "Reader.readUntilDelimiterAlloc returns StreamTooLong, then an ArrayList wi | ... | @@ -131,7 +131,7 @@ test "Reader.readUntilDelimiterAlloc returns StreamTooLong, then an ArrayList wi |
| 131 | try std.testing.expectEqualStrings("67", result); | 131 | try std.testing.expectEqualStrings("67", result); |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | test "Reader.readUntilDelimiterAlloc returns EndOfStream" { | 134 | test "readUntilDelimiterAlloc returns EndOfStream" { |
| 135 | const a = std.testing.allocator; | 135 | const a = std.testing.allocator; |
| 136 | 136 | ||
| 137 | var fis = std.io.fixedBufferStream("1234"); | 137 | var fis = std.io.fixedBufferStream("1234"); |
| ... | @@ -140,7 +140,7 @@ test "Reader.readUntilDelimiterAlloc returns EndOfStream" { | ... | @@ -140,7 +140,7 @@ test "Reader.readUntilDelimiterAlloc returns EndOfStream" { |
| 140 | try std.testing.expectError(error.EndOfStream, reader.readUntilDelimiterAlloc(a, '\n', 5)); | 140 | try std.testing.expectError(error.EndOfStream, reader.readUntilDelimiterAlloc(a, '\n', 5)); |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | test "Reader.readUntilDelimiter returns bytes read until the delimiter" { | 143 | test "readUntilDelimiter returns bytes read until the delimiter" { |
| 144 | var buf: [5]u8 = undefined; | 144 | var buf: [5]u8 = undefined; |
| 145 | var fis = std.io.fixedBufferStream("0000\n1234\n"); | 145 | var fis = std.io.fixedBufferStream("0000\n1234\n"); |
| 146 | const reader = fis.reader(); | 146 | const reader = fis.reader(); |
| ... | @@ -148,14 +148,14 @@ test "Reader.readUntilDelimiter returns bytes read until the delimiter" { | ... | @@ -148,14 +148,14 @@ test "Reader.readUntilDelimiter returns bytes read until the delimiter" { |
| 148 | try std.testing.expectEqualStrings("1234", try reader.readUntilDelimiter(&buf, '\n')); | 148 | try std.testing.expectEqualStrings("1234", try reader.readUntilDelimiter(&buf, '\n')); |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | test "Reader.readUntilDelimiter returns an empty string" { | 151 | test "readUntilDelimiter returns an empty string" { |
| 152 | var buf: [5]u8 = undefined; | 152 | var buf: [5]u8 = undefined; |
| 153 | var fis = std.io.fixedBufferStream("\n"); | 153 | var fis = std.io.fixedBufferStream("\n"); |
| 154 | const reader = fis.reader(); | 154 | const reader = fis.reader(); |
| 155 | try std.testing.expectEqualStrings("", try reader.readUntilDelimiter(&buf, '\n')); | 155 | try std.testing.expectEqualStrings("", try reader.readUntilDelimiter(&buf, '\n')); |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | test "Reader.readUntilDelimiter returns StreamTooLong, then an empty string" { | 158 | test "readUntilDelimiter returns StreamTooLong, then an empty string" { |
| 159 | var buf: [5]u8 = undefined; | 159 | var buf: [5]u8 = undefined; |
| 160 | var fis = std.io.fixedBufferStream("12345\n"); | 160 | var fis = std.io.fixedBufferStream("12345\n"); |
| 161 | const reader = fis.reader(); | 161 | const reader = fis.reader(); |
| ... | @@ -163,7 +163,7 @@ test "Reader.readUntilDelimiter returns StreamTooLong, then an empty string" { | ... | @@ -163,7 +163,7 @@ test "Reader.readUntilDelimiter returns StreamTooLong, then an empty string" { |
| 163 | try std.testing.expectEqualStrings("", try reader.readUntilDelimiter(&buf, '\n')); | 163 | try std.testing.expectEqualStrings("", try reader.readUntilDelimiter(&buf, '\n')); |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | test "Reader.readUntilDelimiter returns StreamTooLong, then bytes read until the delimiter" { | 166 | test "readUntilDelimiter returns StreamTooLong, then bytes read until the delimiter" { |
| 167 | var buf: [5]u8 = undefined; | 167 | var buf: [5]u8 = undefined; |
| 168 | var fis = std.io.fixedBufferStream("1234567\n"); | 168 | var fis = std.io.fixedBufferStream("1234567\n"); |
| 169 | const reader = fis.reader(); | 169 | const reader = fis.reader(); |
| ... | @@ -171,7 +171,7 @@ test "Reader.readUntilDelimiter returns StreamTooLong, then bytes read until the | ... | @@ -171,7 +171,7 @@ test "Reader.readUntilDelimiter returns StreamTooLong, then bytes read until the |
| 171 | try std.testing.expectEqualStrings("67", try reader.readUntilDelimiter(&buf, '\n')); | 171 | try std.testing.expectEqualStrings("67", try reader.readUntilDelimiter(&buf, '\n')); |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | test "Reader.readUntilDelimiter returns EndOfStream" { | 174 | test "readUntilDelimiter returns EndOfStream" { |
| 175 | { | 175 | { |
| 176 | var buf: [5]u8 = undefined; | 176 | var buf: [5]u8 = undefined; |
| 177 | var fis = std.io.fixedBufferStream(""); | 177 | var fis = std.io.fixedBufferStream(""); |
| ... | @@ -186,7 +186,7 @@ test "Reader.readUntilDelimiter returns EndOfStream" { | ... | @@ -186,7 +186,7 @@ test "Reader.readUntilDelimiter returns EndOfStream" { |
| 186 | } | 186 | } |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | test "Reader.readUntilDelimiter returns bytes read until delimiter, then EndOfStream" { | 189 | test "readUntilDelimiter returns bytes read until delimiter, then EndOfStream" { |
| 190 | var buf: [5]u8 = undefined; | 190 | var buf: [5]u8 = undefined; |
| 191 | var fis = std.io.fixedBufferStream("1234\n"); | 191 | var fis = std.io.fixedBufferStream("1234\n"); |
| 192 | const reader = fis.reader(); | 192 | const reader = fis.reader(); |
| ... | @@ -194,7 +194,7 @@ test "Reader.readUntilDelimiter returns bytes read until delimiter, then EndOfSt | ... | @@ -194,7 +194,7 @@ test "Reader.readUntilDelimiter returns bytes read until delimiter, then EndOfSt |
| 194 | try std.testing.expectError(error.EndOfStream, reader.readUntilDelimiter(&buf, '\n')); | 194 | try std.testing.expectError(error.EndOfStream, reader.readUntilDelimiter(&buf, '\n')); |
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | test "Reader.readUntilDelimiter returns StreamTooLong, then EndOfStream" { | 197 | test "readUntilDelimiter returns StreamTooLong, then EndOfStream" { |
| 198 | var buf: [5]u8 = undefined; | 198 | var buf: [5]u8 = undefined; |
| 199 | var fis = std.io.fixedBufferStream("12345"); | 199 | var fis = std.io.fixedBufferStream("12345"); |
| 200 | const reader = fis.reader(); | 200 | const reader = fis.reader(); |
| ... | @@ -202,7 +202,7 @@ test "Reader.readUntilDelimiter returns StreamTooLong, then EndOfStream" { | ... | @@ -202,7 +202,7 @@ test "Reader.readUntilDelimiter returns StreamTooLong, then EndOfStream" { |
| 202 | try std.testing.expectError(error.EndOfStream, reader.readUntilDelimiter(&buf, '\n')); | 202 | try std.testing.expectError(error.EndOfStream, reader.readUntilDelimiter(&buf, '\n')); |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | test "Reader.readUntilDelimiter writes all bytes read to the output buffer" { | 205 | test "readUntilDelimiter writes all bytes read to the output buffer" { |
| 206 | var buf: [5]u8 = undefined; | 206 | var buf: [5]u8 = undefined; |
| 207 | var fis = std.io.fixedBufferStream("0000\n12345"); | 207 | var fis = std.io.fixedBufferStream("0000\n12345"); |
| 208 | const reader = fis.reader(); | 208 | const reader = fis.reader(); |
| ... | @@ -212,7 +212,7 @@ test "Reader.readUntilDelimiter writes all bytes read to the output buffer" { | ... | @@ -212,7 +212,7 @@ test "Reader.readUntilDelimiter writes all bytes read to the output buffer" { |
| 212 | try std.testing.expectEqualStrings("12345", &buf); | 212 | try std.testing.expectEqualStrings("12345", &buf); |
| 213 | } | 213 | } |
| 214 | 214 | ||
| 215 | test "Reader.readUntilDelimiterOrEofAlloc returns ArrayLists with bytes read until the delimiter, then EndOfStream" { | 215 | test "readUntilDelimiterOrEofAlloc returns ArrayLists with bytes read until the delimiter, then EndOfStream" { |
| 216 | const a = std.testing.allocator; | 216 | const a = std.testing.allocator; |
| 217 | 217 | ||
| 218 | var fis = std.io.fixedBufferStream("0000\n1234\n"); | 218 | var fis = std.io.fixedBufferStream("0000\n1234\n"); |
| ... | @@ -233,7 +233,7 @@ test "Reader.readUntilDelimiterOrEofAlloc returns ArrayLists with bytes read unt | ... | @@ -233,7 +233,7 @@ test "Reader.readUntilDelimiterOrEofAlloc returns ArrayLists with bytes read unt |
| 233 | try std.testing.expect((try reader.readUntilDelimiterOrEofAlloc(a, '\n', 5)) == null); | 233 | try std.testing.expect((try reader.readUntilDelimiterOrEofAlloc(a, '\n', 5)) == null); |
| 234 | } | 234 | } |
| 235 | 235 | ||
| 236 | test "Reader.readUntilDelimiterOrEofAlloc returns an empty ArrayList" { | 236 | test "readUntilDelimiterOrEofAlloc returns an empty ArrayList" { |
| 237 | const a = std.testing.allocator; | 237 | const a = std.testing.allocator; |
| 238 | 238 | ||
| 239 | var fis = std.io.fixedBufferStream("\n"); | 239 | var fis = std.io.fixedBufferStream("\n"); |
| ... | @@ -246,7 +246,7 @@ test "Reader.readUntilDelimiterOrEofAlloc returns an empty ArrayList" { | ... | @@ -246,7 +246,7 @@ test "Reader.readUntilDelimiterOrEofAlloc returns an empty ArrayList" { |
| 246 | } | 246 | } |
| 247 | } | 247 | } |
| 248 | 248 | ||
| 249 | test "Reader.readUntilDelimiterOrEofAlloc returns StreamTooLong, then an ArrayList with bytes read until the delimiter" { | 249 | test "readUntilDelimiterOrEofAlloc returns StreamTooLong, then an ArrayList with bytes read until the delimiter" { |
| 250 | const a = std.testing.allocator; | 250 | const a = std.testing.allocator; |
| 251 | 251 | ||
| 252 | var fis = std.io.fixedBufferStream("1234567\n"); | 252 | var fis = std.io.fixedBufferStream("1234567\n"); |
| ... | @@ -259,7 +259,7 @@ test "Reader.readUntilDelimiterOrEofAlloc returns StreamTooLong, then an ArrayLi | ... | @@ -259,7 +259,7 @@ test "Reader.readUntilDelimiterOrEofAlloc returns StreamTooLong, then an ArrayLi |
| 259 | try std.testing.expectEqualStrings("67", result); | 259 | try std.testing.expectEqualStrings("67", result); |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | test "Reader.readUntilDelimiterOrEof returns bytes read until the delimiter" { | 262 | test "readUntilDelimiterOrEof returns bytes read until the delimiter" { |
| 263 | var buf: [5]u8 = undefined; | 263 | var buf: [5]u8 = undefined; |
| 264 | var fis = std.io.fixedBufferStream("0000\n1234\n"); | 264 | var fis = std.io.fixedBufferStream("0000\n1234\n"); |
| 265 | const reader = fis.reader(); | 265 | const reader = fis.reader(); |
| ... | @@ -267,14 +267,14 @@ test "Reader.readUntilDelimiterOrEof returns bytes read until the delimiter" { | ... | @@ -267,14 +267,14 @@ test "Reader.readUntilDelimiterOrEof returns bytes read until the delimiter" { |
| 267 | try std.testing.expectEqualStrings("1234", (try reader.readUntilDelimiterOrEof(&buf, '\n')).?); | 267 | try std.testing.expectEqualStrings("1234", (try reader.readUntilDelimiterOrEof(&buf, '\n')).?); |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | test "Reader.readUntilDelimiterOrEof returns an empty string" { | 270 | test "readUntilDelimiterOrEof returns an empty string" { |
| 271 | var buf: [5]u8 = undefined; | 271 | var buf: [5]u8 = undefined; |
| 272 | var fis = std.io.fixedBufferStream("\n"); | 272 | var fis = std.io.fixedBufferStream("\n"); |
| 273 | const reader = fis.reader(); | 273 | const reader = fis.reader(); |
| 274 | try std.testing.expectEqualStrings("", (try reader.readUntilDelimiterOrEof(&buf, '\n')).?); | 274 | try std.testing.expectEqualStrings("", (try reader.readUntilDelimiterOrEof(&buf, '\n')).?); |
| 275 | } | 275 | } |
| 276 | 276 | ||
| 277 | test "Reader.readUntilDelimiterOrEof returns StreamTooLong, then an empty string" { | 277 | test "readUntilDelimiterOrEof returns StreamTooLong, then an empty string" { |
| 278 | var buf: [5]u8 = undefined; | 278 | var buf: [5]u8 = undefined; |
| 279 | var fis = std.io.fixedBufferStream("12345\n"); | 279 | var fis = std.io.fixedBufferStream("12345\n"); |
| 280 | const reader = fis.reader(); | 280 | const reader = fis.reader(); |
| ... | @@ -282,7 +282,7 @@ test "Reader.readUntilDelimiterOrEof returns StreamTooLong, then an empty string | ... | @@ -282,7 +282,7 @@ test "Reader.readUntilDelimiterOrEof returns StreamTooLong, then an empty string |
| 282 | try std.testing.expectEqualStrings("", (try reader.readUntilDelimiterOrEof(&buf, '\n')).?); | 282 | try std.testing.expectEqualStrings("", (try reader.readUntilDelimiterOrEof(&buf, '\n')).?); |
| 283 | } | 283 | } |
| 284 | 284 | ||
| 285 | test "Reader.readUntilDelimiterOrEof returns StreamTooLong, then bytes read until the delimiter" { | 285 | test "readUntilDelimiterOrEof returns StreamTooLong, then bytes read until the delimiter" { |
| 286 | var buf: [5]u8 = undefined; | 286 | var buf: [5]u8 = undefined; |
| 287 | var fis = std.io.fixedBufferStream("1234567\n"); | 287 | var fis = std.io.fixedBufferStream("1234567\n"); |
| 288 | const reader = fis.reader(); | 288 | const reader = fis.reader(); |
| ... | @@ -290,14 +290,14 @@ test "Reader.readUntilDelimiterOrEof returns StreamTooLong, then bytes read unti | ... | @@ -290,14 +290,14 @@ test "Reader.readUntilDelimiterOrEof returns StreamTooLong, then bytes read unti |
| 290 | try std.testing.expectEqualStrings("67", (try reader.readUntilDelimiterOrEof(&buf, '\n')).?); | 290 | try std.testing.expectEqualStrings("67", (try reader.readUntilDelimiterOrEof(&buf, '\n')).?); |
| 291 | } | 291 | } |
| 292 | 292 | ||
| 293 | test "Reader.readUntilDelimiterOrEof returns null" { | 293 | test "readUntilDelimiterOrEof returns null" { |
| 294 | var buf: [5]u8 = undefined; | 294 | var buf: [5]u8 = undefined; |
| 295 | var fis = std.io.fixedBufferStream(""); | 295 | var fis = std.io.fixedBufferStream(""); |
| 296 | const reader = fis.reader(); | 296 | const reader = fis.reader(); |
| 297 | try std.testing.expect((try reader.readUntilDelimiterOrEof(&buf, '\n')) == null); | 297 | try std.testing.expect((try reader.readUntilDelimiterOrEof(&buf, '\n')) == null); |
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | test "Reader.readUntilDelimiterOrEof returns bytes read until delimiter, then null" { | 300 | test "readUntilDelimiterOrEof returns bytes read until delimiter, then null" { |
| 301 | var buf: [5]u8 = undefined; | 301 | var buf: [5]u8 = undefined; |
| 302 | var fis = std.io.fixedBufferStream("1234\n"); | 302 | var fis = std.io.fixedBufferStream("1234\n"); |
| 303 | const reader = fis.reader(); | 303 | const reader = fis.reader(); |
| ... | @@ -305,14 +305,14 @@ test "Reader.readUntilDelimiterOrEof returns bytes read until delimiter, then nu | ... | @@ -305,14 +305,14 @@ test "Reader.readUntilDelimiterOrEof returns bytes read until delimiter, then nu |
| 305 | try std.testing.expect((try reader.readUntilDelimiterOrEof(&buf, '\n')) == null); | 305 | try std.testing.expect((try reader.readUntilDelimiterOrEof(&buf, '\n')) == null); |
| 306 | } | 306 | } |
| 307 | 307 | ||
| 308 | test "Reader.readUntilDelimiterOrEof returns bytes read until end-of-stream" { | 308 | test "readUntilDelimiterOrEof returns bytes read until end-of-stream" { |
| 309 | var buf: [5]u8 = undefined; | 309 | var buf: [5]u8 = undefined; |
| 310 | var fis = std.io.fixedBufferStream("1234"); | 310 | var fis = std.io.fixedBufferStream("1234"); |
| 311 | const reader = fis.reader(); | 311 | const reader = fis.reader(); |
| 312 | try std.testing.expectEqualStrings("1234", (try reader.readUntilDelimiterOrEof(&buf, '\n')).?); | 312 | try std.testing.expectEqualStrings("1234", (try reader.readUntilDelimiterOrEof(&buf, '\n')).?); |
| 313 | } | 313 | } |
| 314 | 314 | ||
| 315 | test "Reader.readUntilDelimiterOrEof returns StreamTooLong, then bytes read until end-of-stream" { | 315 | test "readUntilDelimiterOrEof returns StreamTooLong, then bytes read until end-of-stream" { |
| 316 | var buf: [5]u8 = undefined; | 316 | var buf: [5]u8 = undefined; |
| 317 | var fis = std.io.fixedBufferStream("1234567"); | 317 | var fis = std.io.fixedBufferStream("1234567"); |
| 318 | const reader = fis.reader(); | 318 | const reader = fis.reader(); |
| ... | @@ -320,7 +320,7 @@ test "Reader.readUntilDelimiterOrEof returns StreamTooLong, then bytes read unti | ... | @@ -320,7 +320,7 @@ test "Reader.readUntilDelimiterOrEof returns StreamTooLong, then bytes read unti |
| 320 | try std.testing.expectEqualStrings("67", (try reader.readUntilDelimiterOrEof(&buf, '\n')).?); | 320 | try std.testing.expectEqualStrings("67", (try reader.readUntilDelimiterOrEof(&buf, '\n')).?); |
| 321 | } | 321 | } |
| 322 | 322 | ||
| 323 | test "Reader.readUntilDelimiterOrEof writes all bytes read to the output buffer" { | 323 | test "readUntilDelimiterOrEof writes all bytes read to the output buffer" { |
| 324 | var buf: [5]u8 = undefined; | 324 | var buf: [5]u8 = undefined; |
| 325 | var fis = std.io.fixedBufferStream("0000\n12345"); | 325 | var fis = std.io.fixedBufferStream("0000\n12345"); |
| 326 | const reader = fis.reader(); | 326 | const reader = fis.reader(); |
| ... | @@ -330,7 +330,7 @@ test "Reader.readUntilDelimiterOrEof writes all bytes read to the output buffer" | ... | @@ -330,7 +330,7 @@ test "Reader.readUntilDelimiterOrEof writes all bytes read to the output buffer" |
| 330 | try std.testing.expectEqualStrings("12345", &buf); | 330 | try std.testing.expectEqualStrings("12345", &buf); |
| 331 | } | 331 | } |
| 332 | 332 | ||
| 333 | test "Reader.streamUntilDelimiter writes all bytes without delimiter to the output" { | 333 | test "streamUntilDelimiter writes all bytes without delimiter to the output" { |
| 334 | const input_string = "some_string_with_delimiter!"; | 334 | const input_string = "some_string_with_delimiter!"; |
| 335 | var input_fbs = std.io.fixedBufferStream(input_string); | 335 | var input_fbs = std.io.fixedBufferStream(input_string); |
| 336 | const reader = input_fbs.reader(); | 336 | const reader = input_fbs.reader(); |
| ... | @@ -349,7 +349,7 @@ test "Reader.streamUntilDelimiter writes all bytes without delimiter to the outp | ... | @@ -349,7 +349,7 @@ test "Reader.streamUntilDelimiter writes all bytes without delimiter to the outp |
| 349 | try std.testing.expectError(error.StreamTooLong, reader.streamUntilDelimiter(writer, '!', 5)); | 349 | try std.testing.expectError(error.StreamTooLong, reader.streamUntilDelimiter(writer, '!', 5)); |
| 350 | } | 350 | } |
| 351 | 351 | ||
| 352 | test "Reader.readBoundedBytes correctly reads into a new bounded array" { | 352 | test "readBoundedBytes correctly reads into a new bounded array" { |
| 353 | const test_string = "abcdefg"; | 353 | const test_string = "abcdefg"; |
| 354 | var fis = std.io.fixedBufferStream(test_string); | 354 | var fis = std.io.fixedBufferStream(test_string); |
| 355 | const reader = fis.reader(); | 355 | const reader = fis.reader(); |
| ... | @@ -358,7 +358,7 @@ test "Reader.readBoundedBytes correctly reads into a new bounded array" { | ... | @@ -358,7 +358,7 @@ test "Reader.readBoundedBytes correctly reads into a new bounded array" { |
| 358 | try testing.expectEqualStrings(array.slice(), test_string); | 358 | try testing.expectEqualStrings(array.slice(), test_string); |
| 359 | } | 359 | } |
| 360 | 360 | ||
| 361 | test "Reader.readIntoBoundedBytes correctly reads into a provided bounded array" { | 361 | test "readIntoBoundedBytes correctly reads into a provided bounded array" { |
| 362 | const test_string = "abcdefg"; | 362 | const test_string = "abcdefg"; |
| 363 | var fis = std.io.fixedBufferStream(test_string); | 363 | var fis = std.io.fixedBufferStream(test_string); |
| 364 | const reader = fis.reader(); | 364 | const reader = fis.reader(); |
lib/std/io/buffered_reader.zig+2-2| ... | @@ -53,7 +53,7 @@ pub fn bufferedReaderSize(comptime size: usize, reader: anytype) BufferedReader( | ... | @@ -53,7 +53,7 @@ pub fn bufferedReaderSize(comptime size: usize, reader: anytype) BufferedReader( |
| 53 | return .{ .unbuffered_reader = reader }; | 53 | return .{ .unbuffered_reader = reader }; |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | test "io.BufferedReader OneByte" { | 56 | test "OneByte" { |
| 57 | const OneByteReadReader = struct { | 57 | const OneByteReadReader = struct { |
| 58 | str: []const u8, | 58 | str: []const u8, |
| 59 | curr: usize, | 59 | curr: usize, |
| ... | @@ -96,7 +96,7 @@ test "io.BufferedReader OneByte" { | ... | @@ -96,7 +96,7 @@ test "io.BufferedReader OneByte" { |
| 96 | fn smallBufferedReader(underlying_stream: anytype) BufferedReader(8, @TypeOf(underlying_stream)) { | 96 | fn smallBufferedReader(underlying_stream: anytype) BufferedReader(8, @TypeOf(underlying_stream)) { |
| 97 | return .{ .unbuffered_reader = underlying_stream }; | 97 | return .{ .unbuffered_reader = underlying_stream }; |
| 98 | } | 98 | } |
| 99 | test "io.BufferedReader Block" { | 99 | test "Block" { |
| 100 | const BlockReader = struct { | 100 | const BlockReader = struct { |
| 101 | block: []const u8, | 101 | block: []const u8, |
| 102 | reads_allowed: usize, | 102 | reads_allowed: usize, |
lib/std/io/buffered_tee.zig+5-5| ... | @@ -146,7 +146,7 @@ fn bufferedReader(reader: anytype) BufferedReader(4096, @TypeOf(reader)) { | ... | @@ -146,7 +146,7 @@ fn bufferedReader(reader: anytype) BufferedReader(4096, @TypeOf(reader)) { |
| 146 | }; | 146 | }; |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | test "io.BufferedTee io.BufferedReader OneByte" { | 149 | test "OneByte" { |
| 150 | const OneByteReadReader = struct { | 150 | const OneByteReadReader = struct { |
| 151 | str: []const u8, | 151 | str: []const u8, |
| 152 | curr: usize, | 152 | curr: usize, |
| ... | @@ -186,7 +186,7 @@ test "io.BufferedTee io.BufferedReader OneByte" { | ... | @@ -186,7 +186,7 @@ test "io.BufferedTee io.BufferedReader OneByte" { |
| 186 | try testing.expectEqualSlices(u8, str, res); | 186 | try testing.expectEqualSlices(u8, str, res); |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | test "io.BufferedTee io.BufferedReader Block" { | 189 | test "Block" { |
| 190 | const BlockReader = struct { | 190 | const BlockReader = struct { |
| 191 | block: []const u8, | 191 | block: []const u8, |
| 192 | reads_allowed: usize, | 192 | reads_allowed: usize, |
| ... | @@ -289,7 +289,7 @@ test "io.BufferedTee io.BufferedReader Block" { | ... | @@ -289,7 +289,7 @@ test "io.BufferedTee io.BufferedReader Block" { |
| 289 | } | 289 | } |
| 290 | } | 290 | } |
| 291 | 291 | ||
| 292 | test "io.BufferedTee with zero lookahead" { | 292 | test "with zero lookahead" { |
| 293 | // output has same bytes as consumer | 293 | // output has same bytes as consumer |
| 294 | const data = [_]u8{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } ** 12; | 294 | const data = [_]u8{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } ** 12; |
| 295 | var in = io.fixedBufferStream(&data); | 295 | var in = io.fixedBufferStream(&data); |
| ... | @@ -308,7 +308,7 @@ test "io.BufferedTee with zero lookahead" { | ... | @@ -308,7 +308,7 @@ test "io.BufferedTee with zero lookahead" { |
| 308 | } | 308 | } |
| 309 | } | 309 | } |
| 310 | 310 | ||
| 311 | test "io.BufferedTee with lookahead" { | 311 | test "with lookahead" { |
| 312 | // output is lookahead bytes behind consumer | 312 | // output is lookahead bytes behind consumer |
| 313 | inline for (1..8) |lookahead| { | 313 | inline for (1..8) |lookahead| { |
| 314 | const data = [_]u8{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } ** 12; | 314 | const data = [_]u8{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } ** 12; |
| ... | @@ -333,7 +333,7 @@ test "io.BufferedTee with lookahead" { | ... | @@ -333,7 +333,7 @@ test "io.BufferedTee with lookahead" { |
| 333 | } | 333 | } |
| 334 | } | 334 | } |
| 335 | 335 | ||
| 336 | test "io.BufferedTee internal state" { | 336 | test "internal state" { |
| 337 | const data = [_]u8{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } ** 2; | 337 | const data = [_]u8{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } ** 2; |
| 338 | var in = io.fixedBufferStream(&data); | 338 | var in = io.fixedBufferStream(&data); |
| 339 | var out = std.ArrayList(u8).init(testing.allocator); | 339 | var out = std.ArrayList(u8).init(testing.allocator); |
lib/std/io/counting_reader.zig+1-1| ... | @@ -27,7 +27,7 @@ pub fn countingReader(reader: anytype) CountingReader(@TypeOf(reader)) { | ... | @@ -27,7 +27,7 @@ pub fn countingReader(reader: anytype) CountingReader(@TypeOf(reader)) { |
| 27 | return .{ .child_reader = reader }; | 27 | return .{ .child_reader = reader }; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | test "io.CountingReader" { | 30 | test CountingReader { |
| 31 | const bytes = "yay" ** 100; | 31 | const bytes = "yay" ** 100; |
| 32 | var fbs = io.fixedBufferStream(bytes); | 32 | var fbs = io.fixedBufferStream(bytes); |
| 33 | 33 |
lib/std/io/counting_writer.zig+1-1| ... | @@ -29,7 +29,7 @@ pub fn countingWriter(child_stream: anytype) CountingWriter(@TypeOf(child_stream | ... | @@ -29,7 +29,7 @@ pub fn countingWriter(child_stream: anytype) CountingWriter(@TypeOf(child_stream |
| 29 | return .{ .bytes_written = 0, .child_stream = child_stream }; | 29 | return .{ .bytes_written = 0, .child_stream = child_stream }; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | test "io.CountingWriter" { | 32 | test CountingWriter { |
| 33 | var counting_stream = countingWriter(std.io.null_writer); | 33 | var counting_stream = countingWriter(std.io.null_writer); |
| 34 | const stream = counting_stream.writer(); | 34 | const stream = counting_stream.writer(); |
| 35 | 35 |
lib/std/io/fixed_buffer_stream.zig+4-4| ... | @@ -132,7 +132,7 @@ fn Slice(comptime T: type) type { | ... | @@ -132,7 +132,7 @@ fn Slice(comptime T: type) type { |
| 132 | } | 132 | } |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | test "FixedBufferStream output" { | 135 | test "output" { |
| 136 | var buf: [255]u8 = undefined; | 136 | var buf: [255]u8 = undefined; |
| 137 | var fbs = fixedBufferStream(&buf); | 137 | var fbs = fixedBufferStream(&buf); |
| 138 | const stream = fbs.writer(); | 138 | const stream = fbs.writer(); |
| ... | @@ -141,7 +141,7 @@ test "FixedBufferStream output" { | ... | @@ -141,7 +141,7 @@ test "FixedBufferStream output" { |
| 141 | try testing.expectEqualSlices(u8, "HelloWorld!", fbs.getWritten()); | 141 | try testing.expectEqualSlices(u8, "HelloWorld!", fbs.getWritten()); |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | test "FixedBufferStream output at comptime" { | 144 | test "output at comptime" { |
| 145 | comptime { | 145 | comptime { |
| 146 | var buf: [255]u8 = undefined; | 146 | var buf: [255]u8 = undefined; |
| 147 | var fbs = fixedBufferStream(&buf); | 147 | var fbs = fixedBufferStream(&buf); |
| ... | @@ -152,7 +152,7 @@ test "FixedBufferStream output at comptime" { | ... | @@ -152,7 +152,7 @@ test "FixedBufferStream output at comptime" { |
| 152 | } | 152 | } |
| 153 | } | 153 | } |
| 154 | 154 | ||
| 155 | test "FixedBufferStream output 2" { | 155 | test "output 2" { |
| 156 | var buffer: [10]u8 = undefined; | 156 | var buffer: [10]u8 = undefined; |
| 157 | var fbs = fixedBufferStream(&buffer); | 157 | var fbs = fixedBufferStream(&buffer); |
| 158 | 158 | ||
| ... | @@ -175,7 +175,7 @@ test "FixedBufferStream output 2" { | ... | @@ -175,7 +175,7 @@ test "FixedBufferStream output 2" { |
| 175 | try testing.expectError(error.NoSpaceLeft, fbs.writer().writeAll("H")); | 175 | try testing.expectError(error.NoSpaceLeft, fbs.writer().writeAll("H")); |
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | test "FixedBufferStream input" { | 178 | test "input" { |
| 179 | const bytes = [_]u8{ 1, 2, 3, 4, 5, 6, 7 }; | 179 | const bytes = [_]u8{ 1, 2, 3, 4, 5, 6, 7 }; |
| 180 | var fbs = fixedBufferStream(&bytes); | 180 | var fbs = fixedBufferStream(&bytes); |
| 181 | 181 |
lib/std/io/stream_source.zig+3-3| ... | @@ -99,11 +99,11 @@ pub const StreamSource = union(enum) { | ... | @@ -99,11 +99,11 @@ pub const StreamSource = union(enum) { |
| 99 | } | 99 | } |
| 100 | }; | 100 | }; |
| 101 | 101 | ||
| 102 | test "StreamSource (refs)" { | 102 | test "refs" { |
| 103 | std.testing.refAllDecls(StreamSource); | 103 | std.testing.refAllDecls(StreamSource); |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | test "StreamSource (mutable buffer)" { | 106 | test "mutable buffer" { |
| 107 | var buffer: [64]u8 = undefined; | 107 | var buffer: [64]u8 = undefined; |
| 108 | var source = StreamSource{ .buffer = std.io.fixedBufferStream(&buffer) }; | 108 | var source = StreamSource{ .buffer = std.io.fixedBufferStream(&buffer) }; |
| 109 | 109 | ||
| ... | @@ -114,7 +114,7 @@ test "StreamSource (mutable buffer)" { | ... | @@ -114,7 +114,7 @@ test "StreamSource (mutable buffer)" { |
| 114 | try std.testing.expectEqualStrings("Hello, World!", source.buffer.getWritten()); | 114 | try std.testing.expectEqualStrings("Hello, World!", source.buffer.getWritten()); |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | test "StreamSource (const buffer)" { | 117 | test "const buffer" { |
| 118 | const buffer: [64]u8 = "Hello, World!".* ++ ([1]u8{0xAA} ** 51); | 118 | const buffer: [64]u8 = "Hello, World!".* ++ ([1]u8{0xAA} ** 51); |
| 119 | var source = StreamSource{ .const_buffer = std.io.fixedBufferStream(&buffer) }; | 119 | var source = StreamSource{ .const_buffer = std.io.fixedBufferStream(&buffer) }; |
| 120 | 120 |
lib/std/json/scanner_test.zig+4-4| ... | @@ -35,7 +35,7 @@ fn expectPeekNext(scanner_or_reader: anytype, expected_token_type: TokenType, ex | ... | @@ -35,7 +35,7 @@ fn expectPeekNext(scanner_or_reader: anytype, expected_token_type: TokenType, ex |
| 35 | try expectEqualTokens(expected_token, try scanner_or_reader.next()); | 35 | try expectEqualTokens(expected_token, try scanner_or_reader.next()); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | test "json.token" { | 38 | test "token" { |
| 39 | var scanner = JsonScanner.initCompleteInput(std.testing.allocator, example_document_str); | 39 | var scanner = JsonScanner.initCompleteInput(std.testing.allocator, example_document_str); |
| 40 | defer scanner.deinit(); | 40 | defer scanner.deinit(); |
| 41 | 41 | ||
| ... | @@ -153,7 +153,7 @@ test "peek all types" { | ... | @@ -153,7 +153,7 @@ test "peek all types" { |
| 153 | try testAllTypes(&tiny_json_reader, false); | 153 | try testAllTypes(&tiny_json_reader, false); |
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | test "json.token mismatched close" { | 156 | test "token mismatched close" { |
| 157 | var scanner = JsonScanner.initCompleteInput(std.testing.allocator, "[102, 111, 111 }"); | 157 | var scanner = JsonScanner.initCompleteInput(std.testing.allocator, "[102, 111, 111 }"); |
| 158 | defer scanner.deinit(); | 158 | defer scanner.deinit(); |
| 159 | try expectNext(&scanner, .array_begin); | 159 | try expectNext(&scanner, .array_begin); |
| ... | @@ -163,7 +163,7 @@ test "json.token mismatched close" { | ... | @@ -163,7 +163,7 @@ test "json.token mismatched close" { |
| 163 | try std.testing.expectError(error.SyntaxError, scanner.next()); | 163 | try std.testing.expectError(error.SyntaxError, scanner.next()); |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | test "json.token premature object close" { | 166 | test "token premature object close" { |
| 167 | var scanner = JsonScanner.initCompleteInput(std.testing.allocator, "{ \"key\": }"); | 167 | var scanner = JsonScanner.initCompleteInput(std.testing.allocator, "{ \"key\": }"); |
| 168 | defer scanner.deinit(); | 168 | defer scanner.deinit(); |
| 169 | try expectNext(&scanner, .object_begin); | 169 | try expectNext(&scanner, .object_begin); |
| ... | @@ -353,7 +353,7 @@ test "BufferUnderrun" { | ... | @@ -353,7 +353,7 @@ test "BufferUnderrun" { |
| 353 | } | 353 | } |
| 354 | } | 354 | } |
| 355 | 355 | ||
| 356 | test "json.validate" { | 356 | test "validate" { |
| 357 | try std.testing.expectEqual(true, try validate(std.testing.allocator, "{}")); | 357 | try std.testing.expectEqual(true, try validate(std.testing.allocator, "{}")); |
| 358 | try std.testing.expectEqual(true, try validate(std.testing.allocator, "[]")); | 358 | try std.testing.expectEqual(true, try validate(std.testing.allocator, "[]")); |
| 359 | try std.testing.expectEqual(false, try validate(std.testing.allocator, "[{[[[[{}]]]]}]")); | 359 | try std.testing.expectEqual(false, try validate(std.testing.allocator, "[{[[[[{}]]]]}]")); |
lib/std/math.zig+1-1| ... | @@ -1298,7 +1298,7 @@ pub fn log2_int_ceil(comptime T: type, x: T) Log2IntCeil(T) { | ... | @@ -1298,7 +1298,7 @@ pub fn log2_int_ceil(comptime T: type, x: T) Log2IntCeil(T) { |
| 1298 | return log2_val + 1; | 1298 | return log2_val + 1; |
| 1299 | } | 1299 | } |
| 1300 | 1300 | ||
| 1301 | test "std.math.log2_int_ceil" { | 1301 | test log2_int_ceil { |
| 1302 | try testing.expect(log2_int_ceil(u32, 1) == 0); | 1302 | try testing.expect(log2_int_ceil(u32, 1) == 0); |
| 1303 | try testing.expect(log2_int_ceil(u32, 2) == 1); | 1303 | try testing.expect(log2_int_ceil(u32, 2) == 1); |
| 1304 | try testing.expect(log2_int_ceil(u32, 3) == 2); | 1304 | try testing.expect(log2_int_ceil(u32, 3) == 2); |
lib/std/math/acos.zig+5-5| ... | @@ -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 "math.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 "math.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 "math.acos32" { | ... | @@ -164,7 +164,7 @@ test "math.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 "math.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)); |
| ... | @@ -175,12 +175,12 @@ test "math.acos64" { | ... | @@ -175,12 +175,12 @@ test "math.acos64" { |
| 175 | try expect(math.approxEqAbs(f64, acos64(-0.2), 1.772154, epsilon)); | 175 | try expect(math.approxEqAbs(f64, acos64(-0.2), 1.772154, epsilon)); |
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | test "math.acos32.special" { | 178 | test "acos32.special" { |
| 179 | try expect(math.isNan(acos32(-2))); | 179 | try expect(math.isNan(acos32(-2))); |
| 180 | try expect(math.isNan(acos32(1.5))); | 180 | try expect(math.isNan(acos32(1.5))); |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | test "math.acos64.special" { | 183 | test "acos64.special" { |
| 184 | try expect(math.isNan(acos64(-2))); | 184 | try expect(math.isNan(acos64(-2))); |
| 185 | try expect(math.isNan(acos64(1.5))); | 185 | try expect(math.isNan(acos64(1.5))); |
| 186 | } | 186 | } |
lib/std/math/acosh.zig+5-5| ... | @@ -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 "math.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 "math.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 "math.acosh32" { | ... | @@ -73,7 +73,7 @@ test "math.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 "math.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)); |
| ... | @@ -82,12 +82,12 @@ test "math.acosh64" { | ... | @@ -82,12 +82,12 @@ test "math.acosh64" { |
| 82 | try expect(math.approxEqAbs(f64, acosh64(123123.234375), 12.414088, epsilon)); | 82 | try expect(math.approxEqAbs(f64, acosh64(123123.234375), 12.414088, epsilon)); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | test "math.acosh32.special" { | 85 | test "acosh32.special" { |
| 86 | try expect(math.isNan(acosh32(math.nan(f32)))); | 86 | try expect(math.isNan(acosh32(math.nan(f32)))); |
| 87 | try expect(math.isNan(acosh32(0.5))); | 87 | try expect(math.isNan(acosh32(0.5))); |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | test "math.acosh64.special" { | 90 | test "acosh64.special" { |
| 91 | try expect(math.isNan(acosh64(math.nan(f64)))); | 91 | try expect(math.isNan(acosh64(math.nan(f64)))); |
| 92 | try expect(math.isNan(acosh64(0.5))); | 92 | try expect(math.isNan(acosh64(0.5))); |
| 93 | } | 93 | } |
lib/std/math/asin.zig+5-5| ... | @@ -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 "math.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 "math.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 "math.asin32" { | ... | @@ -157,7 +157,7 @@ test "math.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 "math.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)); |
| ... | @@ -168,14 +168,14 @@ test "math.asin64" { | ... | @@ -168,14 +168,14 @@ test "math.asin64" { |
| 168 | try expect(math.approxEqAbs(f64, asin64(0.8923), 1.102415, epsilon)); | 168 | try expect(math.approxEqAbs(f64, asin64(0.8923), 1.102415, epsilon)); |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | test "math.asin32.special" { | 171 | test "asin32.special" { |
| 172 | try expect(math.isPositiveZero(asin32(0.0))); | 172 | try expect(math.isPositiveZero(asin32(0.0))); |
| 173 | try expect(math.isNegativeZero(asin32(-0.0))); | 173 | try expect(math.isNegativeZero(asin32(-0.0))); |
| 174 | try expect(math.isNan(asin32(-2))); | 174 | try expect(math.isNan(asin32(-2))); |
| 175 | try expect(math.isNan(asin32(1.5))); | 175 | try expect(math.isNan(asin32(1.5))); |
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | test "math.asin64.special" { | 178 | test "asin64.special" { |
| 179 | try expect(math.isPositiveZero(asin64(0.0))); | 179 | try expect(math.isPositiveZero(asin64(0.0))); |
| 180 | try expect(math.isNegativeZero(asin64(-0.0))); | 180 | try expect(math.isNegativeZero(asin64(-0.0))); |
| 181 | try expect(math.isNan(asin64(-2))); | 181 | try expect(math.isNan(asin64(-2))); |
lib/std/math/asinh.zig+5-5| ... | @@ -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 "math.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 "math.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 "math.asinh32" { | ... | @@ -98,7 +98,7 @@ test "math.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 "math.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)); |
| ... | @@ -111,7 +111,7 @@ test "math.asinh64" { | ... | @@ -111,7 +111,7 @@ test "math.asinh64" { |
| 111 | try expect(math.approxEqAbs(f64, asinh64(123123.234375), 12.414088, epsilon)); | 111 | try expect(math.approxEqAbs(f64, asinh64(123123.234375), 12.414088, epsilon)); |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | test "math.asinh32.special" { | 114 | test "asinh32.special" { |
| 115 | try expect(math.isPositiveZero(asinh32(0.0))); | 115 | try expect(math.isPositiveZero(asinh32(0.0))); |
| 116 | try expect(math.isNegativeZero(asinh32(-0.0))); | 116 | try expect(math.isNegativeZero(asinh32(-0.0))); |
| 117 | try expect(math.isPositiveInf(asinh32(math.inf(f32)))); | 117 | try expect(math.isPositiveInf(asinh32(math.inf(f32)))); |
| ... | @@ -119,7 +119,7 @@ test "math.asinh32.special" { | ... | @@ -119,7 +119,7 @@ test "math.asinh32.special" { |
| 119 | try expect(math.isNan(asinh32(math.nan(f32)))); | 119 | try expect(math.isNan(asinh32(math.nan(f32)))); |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | test "math.asinh64.special" { | 122 | test "asinh64.special" { |
| 123 | try expect(math.isPositiveZero(asinh64(0.0))); | 123 | try expect(math.isPositiveZero(asinh64(0.0))); |
| 124 | try expect(math.isNegativeZero(asinh64(-0.0))); | 124 | try expect(math.isNegativeZero(asinh64(-0.0))); |
| 125 | try expect(math.isPositiveInf(asinh64(math.inf(f64)))); | 125 | try expect(math.isPositiveInf(asinh64(math.inf(f64)))); |
lib/std/math/atan.zig+5-5| ... | @@ -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 "math.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 "math.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 "math.atan32" { | ... | @@ -227,7 +227,7 @@ test "math.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 "math.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)); |
| ... | @@ -237,7 +237,7 @@ test "math.atan64" { | ... | @@ -237,7 +237,7 @@ test "math.atan64" { |
| 237 | try expect(math.approxEqAbs(f64, atan64(1.5), 0.982794, epsilon)); | 237 | try expect(math.approxEqAbs(f64, atan64(1.5), 0.982794, epsilon)); |
| 238 | } | 238 | } |
| 239 | 239 | ||
| 240 | test "math.atan32.special" { | 240 | test "atan32.special" { |
| 241 | const epsilon = 0.000001; | 241 | const epsilon = 0.000001; |
| 242 | 242 | ||
| 243 | try expect(math.isPositiveZero(atan32(0.0))); | 243 | try expect(math.isPositiveZero(atan32(0.0))); |
| ... | @@ -246,7 +246,7 @@ test "math.atan32.special" { | ... | @@ -246,7 +246,7 @@ test "math.atan32.special" { |
| 246 | try expect(math.approxEqAbs(f32, atan32(-math.inf(f32)), -math.pi / 2.0, epsilon)); | 246 | try expect(math.approxEqAbs(f32, atan32(-math.inf(f32)), -math.pi / 2.0, epsilon)); |
| 247 | } | 247 | } |
| 248 | 248 | ||
| 249 | test "math.atan64.special" { | 249 | test "atan64.special" { |
| 250 | const epsilon = 0.000001; | 250 | const epsilon = 0.000001; |
| 251 | 251 | ||
| 252 | try expect(math.isPositiveZero(atan64(0.0))); | 252 | try expect(math.isPositiveZero(atan64(0.0))); |
lib/std/math/atan2.zig+5-5| ... | @@ -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 "math.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 "math.atan2" { | ... | @@ -223,7 +223,7 @@ test "math.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 "math.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 "math.atan2_32" { | ... | @@ -235,7 +235,7 @@ test "math.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 "math.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)); |
| ... | @@ -247,7 +247,7 @@ test "math.atan2_64" { | ... | @@ -247,7 +247,7 @@ test "math.atan2_64" { |
| 247 | try expect(math.approxEqAbs(f64, atan2_64(0.34, 1.243), 0.267001, epsilon)); | 247 | try expect(math.approxEqAbs(f64, atan2_64(0.34, 1.243), 0.267001, epsilon)); |
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | test "math.atan2_32.special" { | 250 | test "atan2_32.special" { |
| 251 | const epsilon = 0.000001; | 251 | const epsilon = 0.000001; |
| 252 | 252 | ||
| 253 | try expect(math.isNan(atan2_32(1.0, math.nan(f32)))); | 253 | try expect(math.isNan(atan2_32(1.0, math.nan(f32)))); |
| ... | @@ -271,7 +271,7 @@ test "math.atan2_32.special" { | ... | @@ -271,7 +271,7 @@ test "math.atan2_32.special" { |
| 271 | try expect(math.approxEqAbs(f32, atan2_32(-math.inf(f32), 1.0), -math.pi / 2.0, epsilon)); | 271 | try expect(math.approxEqAbs(f32, atan2_32(-math.inf(f32), 1.0), -math.pi / 2.0, epsilon)); |
| 272 | } | 272 | } |
| 273 | 273 | ||
| 274 | test "math.atan2_64.special" { | 274 | test "atan2_64.special" { |
| 275 | const epsilon = 0.000001; | 275 | const epsilon = 0.000001; |
| 276 | 276 | ||
| 277 | try expect(math.isNan(atan2_64(1.0, math.nan(f64)))); | 277 | try expect(math.isNan(atan2_64(1.0, math.nan(f64)))); |
lib/std/math/atanh.zig+5-5| ... | @@ -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 "math.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 "math.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 "math.atanh_32" { | ... | @@ -97,7 +97,7 @@ test "math.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 "math.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)); |
| ... | @@ -105,7 +105,7 @@ test "math.atanh_64" { | ... | @@ -105,7 +105,7 @@ test "math.atanh_64" { |
| 105 | try expect(math.approxEqAbs(f64, atanh_64(0.8923), 1.433099, epsilon)); | 105 | try expect(math.approxEqAbs(f64, atanh_64(0.8923), 1.433099, epsilon)); |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | test "math.atanh32.special" { | 108 | test "atanh32.special" { |
| 109 | try expect(math.isPositiveInf(atanh_32(1))); | 109 | try expect(math.isPositiveInf(atanh_32(1))); |
| 110 | try expect(math.isNegativeInf(atanh_32(-1))); | 110 | try expect(math.isNegativeInf(atanh_32(-1))); |
| 111 | try expect(math.isNan(atanh_32(1.5))); | 111 | try expect(math.isNan(atanh_32(1.5))); |
| ... | @@ -113,7 +113,7 @@ test "math.atanh32.special" { | ... | @@ -113,7 +113,7 @@ test "math.atanh32.special" { |
| 113 | try expect(math.isNan(atanh_32(math.nan(f32)))); | 113 | try expect(math.isNan(atanh_32(math.nan(f32)))); |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | test "math.atanh64.special" { | 116 | test "atanh64.special" { |
| 117 | try expect(math.isPositiveInf(atanh_64(1))); | 117 | try expect(math.isPositiveInf(atanh_64(1))); |
| 118 | try expect(math.isNegativeInf(atanh_64(-1))); | 118 | try expect(math.isNegativeInf(atanh_64(-1))); |
| 119 | try expect(math.isNan(atanh_64(1.5))); | 119 | try expect(math.isNan(atanh_64(1.5))); |
lib/std/math/big/int_test.zig+195-195| ... | @@ -17,7 +17,7 @@ const minInt = std.math.minInt; | ... | @@ -17,7 +17,7 @@ const minInt = std.math.minInt; |
| 17 | // They will still run on larger than this and should pass, but the multi-limb code-paths | 17 | // They will still run on larger than this and should pass, but the multi-limb code-paths |
| 18 | // may be untested in some cases. | 18 | // may be untested in some cases. |
| 19 | 19 | ||
| 20 | test "big.int comptime_int set" { | 20 | test "comptime_int set" { |
| 21 | comptime var s = 0xefffffff00000001eeeeeeefaaaaaaab; | 21 | comptime var s = 0xefffffff00000001eeeeeeefaaaaaaab; |
| 22 | var a = try Managed.initSet(testing.allocator, s); | 22 | var a = try Managed.initSet(testing.allocator, s); |
| 23 | defer a.deinit(); | 23 | defer a.deinit(); |
| ... | @@ -33,7 +33,7 @@ test "big.int comptime_int set" { | ... | @@ -33,7 +33,7 @@ test "big.int comptime_int set" { |
| 33 | } | 33 | } |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | test "big.int comptime_int set negative" { | 36 | test "comptime_int set negative" { |
| 37 | var a = try Managed.initSet(testing.allocator, -10); | 37 | var a = try Managed.initSet(testing.allocator, -10); |
| 38 | defer a.deinit(); | 38 | defer a.deinit(); |
| 39 | 39 | ||
| ... | @@ -41,7 +41,7 @@ test "big.int comptime_int set negative" { | ... | @@ -41,7 +41,7 @@ test "big.int comptime_int set negative" { |
| 41 | try testing.expect(a.isPositive() == false); | 41 | try testing.expect(a.isPositive() == false); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | test "big.int int set unaligned small" { | 44 | test "int set unaligned small" { |
| 45 | var a = try Managed.initSet(testing.allocator, @as(u7, 45)); | 45 | var a = try Managed.initSet(testing.allocator, @as(u7, 45)); |
| 46 | defer a.deinit(); | 46 | defer a.deinit(); |
| 47 | 47 | ||
| ... | @@ -49,28 +49,28 @@ test "big.int int set unaligned small" { | ... | @@ -49,28 +49,28 @@ test "big.int int set unaligned small" { |
| 49 | try testing.expect(a.isPositive() == true); | 49 | try testing.expect(a.isPositive() == true); |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | test "big.int comptime_int to" { | 52 | test "comptime_int to" { |
| 53 | var a = try Managed.initSet(testing.allocator, 0xefffffff00000001eeeeeeefaaaaaaab); | 53 | var a = try Managed.initSet(testing.allocator, 0xefffffff00000001eeeeeeefaaaaaaab); |
| 54 | defer a.deinit(); | 54 | defer a.deinit(); |
| 55 | 55 | ||
| 56 | try testing.expect((try a.to(u128)) == 0xefffffff00000001eeeeeeefaaaaaaab); | 56 | try testing.expect((try a.to(u128)) == 0xefffffff00000001eeeeeeefaaaaaaab); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | test "big.int sub-limb to" { | 59 | test "sub-limb to" { |
| 60 | var a = try Managed.initSet(testing.allocator, 10); | 60 | var a = try Managed.initSet(testing.allocator, 10); |
| 61 | defer a.deinit(); | 61 | defer a.deinit(); |
| 62 | 62 | ||
| 63 | try testing.expect((try a.to(u8)) == 10); | 63 | try testing.expect((try a.to(u8)) == 10); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | test "big.int set negative minimum" { | 66 | test "set negative minimum" { |
| 67 | var a = try Managed.initSet(testing.allocator, @as(i64, minInt(i64))); | 67 | var a = try Managed.initSet(testing.allocator, @as(i64, minInt(i64))); |
| 68 | defer a.deinit(); | 68 | defer a.deinit(); |
| 69 | 69 | ||
| 70 | try testing.expect((try a.to(i64)) == minInt(i64)); | 70 | try testing.expect((try a.to(i64)) == minInt(i64)); |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | test "big.int set double-width maximum then zero" { | 73 | test "set double-width maximum then zero" { |
| 74 | var a = try Managed.initSet(testing.allocator, maxInt(DoubleLimb)); | 74 | var a = try Managed.initSet(testing.allocator, maxInt(DoubleLimb)); |
| 75 | defer a.deinit(); | 75 | defer a.deinit(); |
| 76 | try a.set(@as(DoubleLimb, 0)); | 76 | try a.set(@as(DoubleLimb, 0)); |
| ... | @@ -78,14 +78,14 @@ test "big.int set double-width maximum then zero" { | ... | @@ -78,14 +78,14 @@ test "big.int set double-width maximum then zero" { |
| 78 | try testing.expectEqual(@as(DoubleLimb, 0), try a.to(DoubleLimb)); | 78 | try testing.expectEqual(@as(DoubleLimb, 0), try a.to(DoubleLimb)); |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | test "big.int to target too small error" { | 81 | test "to target too small error" { |
| 82 | var a = try Managed.initSet(testing.allocator, 0xffffffff); | 82 | var a = try Managed.initSet(testing.allocator, 0xffffffff); |
| 83 | defer a.deinit(); | 83 | defer a.deinit(); |
| 84 | 84 | ||
| 85 | try testing.expectError(error.TargetTooSmall, a.to(u8)); | 85 | try testing.expectError(error.TargetTooSmall, a.to(u8)); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | test "big.int normalize" { | 88 | test "normalize" { |
| 89 | var a = try Managed.init(testing.allocator); | 89 | var a = try Managed.init(testing.allocator); |
| 90 | defer a.deinit(); | 90 | defer a.deinit(); |
| 91 | try a.ensureCapacity(8); | 91 | try a.ensureCapacity(8); |
| ... | @@ -113,7 +113,7 @@ test "big.int normalize" { | ... | @@ -113,7 +113,7 @@ test "big.int normalize" { |
| 113 | try testing.expect(a.len() == 1); | 113 | try testing.expect(a.len() == 1); |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | test "big.int normalize multi" { | 116 | test "normalize multi" { |
| 117 | var a = try Managed.init(testing.allocator); | 117 | var a = try Managed.init(testing.allocator); |
| 118 | defer a.deinit(); | 118 | defer a.deinit(); |
| 119 | try a.ensureCapacity(8); | 119 | try a.ensureCapacity(8); |
| ... | @@ -143,7 +143,7 @@ test "big.int normalize multi" { | ... | @@ -143,7 +143,7 @@ test "big.int normalize multi" { |
| 143 | try testing.expect(a.len() == 1); | 143 | try testing.expect(a.len() == 1); |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | test "big.int parity" { | 146 | test "parity" { |
| 147 | var a = try Managed.init(testing.allocator); | 147 | var a = try Managed.init(testing.allocator); |
| 148 | defer a.deinit(); | 148 | defer a.deinit(); |
| 149 | 149 | ||
| ... | @@ -156,7 +156,7 @@ test "big.int parity" { | ... | @@ -156,7 +156,7 @@ test "big.int parity" { |
| 156 | try testing.expect(a.isOdd()); | 156 | try testing.expect(a.isOdd()); |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | test "big.int bitcount + sizeInBaseUpperBound" { | 159 | test "bitcount + sizeInBaseUpperBound" { |
| 160 | var a = try Managed.init(testing.allocator); | 160 | var a = try Managed.init(testing.allocator); |
| 161 | defer a.deinit(); | 161 | defer a.deinit(); |
| 162 | 162 | ||
| ... | @@ -184,7 +184,7 @@ test "big.int bitcount + sizeInBaseUpperBound" { | ... | @@ -184,7 +184,7 @@ test "big.int bitcount + sizeInBaseUpperBound" { |
| 184 | try testing.expect(a.sizeInBaseUpperBound(2) >= 5033); | 184 | try testing.expect(a.sizeInBaseUpperBound(2) >= 5033); |
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | test "big.int bitcount/to" { | 187 | test "bitcount/to" { |
| 188 | var a = try Managed.init(testing.allocator); | 188 | var a = try Managed.init(testing.allocator); |
| 189 | defer a.deinit(); | 189 | defer a.deinit(); |
| 190 | 190 | ||
| ... | @@ -215,7 +215,7 @@ test "big.int bitcount/to" { | ... | @@ -215,7 +215,7 @@ test "big.int bitcount/to" { |
| 215 | try testing.expect((try a.to(i9)) == -129); | 215 | try testing.expect((try a.to(i9)) == -129); |
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | test "big.int fits" { | 218 | test "fits" { |
| 219 | var a = try Managed.init(testing.allocator); | 219 | var a = try Managed.init(testing.allocator); |
| 220 | defer a.deinit(); | 220 | defer a.deinit(); |
| 221 | 221 | ||
| ... | @@ -243,7 +243,7 @@ test "big.int fits" { | ... | @@ -243,7 +243,7 @@ test "big.int fits" { |
| 243 | try testing.expect(a.fits(u65)); | 243 | try testing.expect(a.fits(u65)); |
| 244 | } | 244 | } |
| 245 | 245 | ||
| 246 | test "big.int string set" { | 246 | test "string set" { |
| 247 | var a = try Managed.init(testing.allocator); | 247 | var a = try Managed.init(testing.allocator); |
| 248 | defer a.deinit(); | 248 | defer a.deinit(); |
| 249 | 249 | ||
| ... | @@ -251,7 +251,7 @@ test "big.int string set" { | ... | @@ -251,7 +251,7 @@ test "big.int string set" { |
| 251 | try testing.expect((try a.to(u128)) == 120317241209124781241290847124); | 251 | try testing.expect((try a.to(u128)) == 120317241209124781241290847124); |
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | test "big.int string negative" { | 254 | test "string negative" { |
| 255 | var a = try Managed.init(testing.allocator); | 255 | var a = try Managed.init(testing.allocator); |
| 256 | defer a.deinit(); | 256 | defer a.deinit(); |
| 257 | 257 | ||
| ... | @@ -259,7 +259,7 @@ test "big.int string negative" { | ... | @@ -259,7 +259,7 @@ test "big.int string negative" { |
| 259 | try testing.expect((try a.to(i32)) == -1023); | 259 | try testing.expect((try a.to(i32)) == -1023); |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | test "big.int string set number with underscores" { | 262 | test "string set number with underscores" { |
| 263 | var a = try Managed.init(testing.allocator); | 263 | var a = try Managed.init(testing.allocator); |
| 264 | defer a.deinit(); | 264 | defer a.deinit(); |
| 265 | 265 | ||
| ... | @@ -267,7 +267,7 @@ test "big.int string set number with underscores" { | ... | @@ -267,7 +267,7 @@ test "big.int string set number with underscores" { |
| 267 | try testing.expect((try a.to(u128)) == 120317241209124781241290847124); | 267 | try testing.expect((try a.to(u128)) == 120317241209124781241290847124); |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | test "big.int string set case insensitive number" { | 270 | test "string set case insensitive number" { |
| 271 | var a = try Managed.init(testing.allocator); | 271 | var a = try Managed.init(testing.allocator); |
| 272 | defer a.deinit(); | 272 | defer a.deinit(); |
| 273 | 273 | ||
| ... | @@ -275,19 +275,19 @@ test "big.int string set case insensitive number" { | ... | @@ -275,19 +275,19 @@ test "big.int string set case insensitive number" { |
| 275 | try testing.expect((try a.to(u32)) == 0xabcdef); | 275 | try testing.expect((try a.to(u32)) == 0xabcdef); |
| 276 | } | 276 | } |
| 277 | 277 | ||
| 278 | test "big.int string set bad char error" { | 278 | test "string set bad char error" { |
| 279 | var a = try Managed.init(testing.allocator); | 279 | var a = try Managed.init(testing.allocator); |
| 280 | defer a.deinit(); | 280 | defer a.deinit(); |
| 281 | try testing.expectError(error.InvalidCharacter, a.setString(10, "x")); | 281 | try testing.expectError(error.InvalidCharacter, a.setString(10, "x")); |
| 282 | } | 282 | } |
| 283 | 283 | ||
| 284 | test "big.int string set bad base error" { | 284 | test "string set bad base error" { |
| 285 | var a = try Managed.init(testing.allocator); | 285 | var a = try Managed.init(testing.allocator); |
| 286 | defer a.deinit(); | 286 | defer a.deinit(); |
| 287 | try testing.expectError(error.InvalidBase, a.setString(45, "10")); | 287 | try testing.expectError(error.InvalidBase, a.setString(45, "10")); |
| 288 | } | 288 | } |
| 289 | 289 | ||
| 290 | test "big.int twos complement limit set" { | 290 | test "twos complement limit set" { |
| 291 | const test_types = [_]type{ | 291 | const test_types = [_]type{ |
| 292 | u64, | 292 | u64, |
| 293 | i64, | 293 | i64, |
| ... | @@ -315,7 +315,7 @@ test "big.int twos complement limit set" { | ... | @@ -315,7 +315,7 @@ test "big.int twos complement limit set" { |
| 315 | } | 315 | } |
| 316 | } | 316 | } |
| 317 | 317 | ||
| 318 | test "big.int string to" { | 318 | test "string to" { |
| 319 | var a = try Managed.initSet(testing.allocator, 120317241209124781241290847124); | 319 | var a = try Managed.initSet(testing.allocator, 120317241209124781241290847124); |
| 320 | defer a.deinit(); | 320 | defer a.deinit(); |
| 321 | 321 | ||
| ... | @@ -326,14 +326,14 @@ test "big.int string to" { | ... | @@ -326,14 +326,14 @@ test "big.int string to" { |
| 326 | try testing.expect(mem.eql(u8, as, es)); | 326 | try testing.expect(mem.eql(u8, as, es)); |
| 327 | } | 327 | } |
| 328 | 328 | ||
| 329 | test "big.int string to base base error" { | 329 | test "string to base base error" { |
| 330 | var a = try Managed.initSet(testing.allocator, 0xffffffff); | 330 | var a = try Managed.initSet(testing.allocator, 0xffffffff); |
| 331 | defer a.deinit(); | 331 | defer a.deinit(); |
| 332 | 332 | ||
| 333 | try testing.expectError(error.InvalidBase, a.toString(testing.allocator, 45, .lower)); | 333 | try testing.expectError(error.InvalidBase, a.toString(testing.allocator, 45, .lower)); |
| 334 | } | 334 | } |
| 335 | 335 | ||
| 336 | test "big.int string to base 2" { | 336 | test "string to base 2" { |
| 337 | var a = try Managed.initSet(testing.allocator, -0b1011); | 337 | var a = try Managed.initSet(testing.allocator, -0b1011); |
| 338 | defer a.deinit(); | 338 | defer a.deinit(); |
| 339 | 339 | ||
| ... | @@ -344,7 +344,7 @@ test "big.int string to base 2" { | ... | @@ -344,7 +344,7 @@ test "big.int string to base 2" { |
| 344 | try testing.expect(mem.eql(u8, as, es)); | 344 | try testing.expect(mem.eql(u8, as, es)); |
| 345 | } | 345 | } |
| 346 | 346 | ||
| 347 | test "big.int string to base 16" { | 347 | test "string to base 16" { |
| 348 | var a = try Managed.initSet(testing.allocator, 0xefffffff00000001eeeeeeefaaaaaaab); | 348 | var a = try Managed.initSet(testing.allocator, 0xefffffff00000001eeeeeeefaaaaaaab); |
| 349 | defer a.deinit(); | 349 | defer a.deinit(); |
| 350 | 350 | ||
| ... | @@ -355,7 +355,7 @@ test "big.int string to base 16" { | ... | @@ -355,7 +355,7 @@ test "big.int string to base 16" { |
| 355 | try testing.expect(mem.eql(u8, as, es)); | 355 | try testing.expect(mem.eql(u8, as, es)); |
| 356 | } | 356 | } |
| 357 | 357 | ||
| 358 | test "big.int neg string to" { | 358 | test "neg string to" { |
| 359 | var a = try Managed.initSet(testing.allocator, -123907434); | 359 | var a = try Managed.initSet(testing.allocator, -123907434); |
| 360 | defer a.deinit(); | 360 | defer a.deinit(); |
| 361 | 361 | ||
| ... | @@ -366,7 +366,7 @@ test "big.int neg string to" { | ... | @@ -366,7 +366,7 @@ test "big.int neg string to" { |
| 366 | try testing.expect(mem.eql(u8, as, es)); | 366 | try testing.expect(mem.eql(u8, as, es)); |
| 367 | } | 367 | } |
| 368 | 368 | ||
| 369 | test "big.int zero string to" { | 369 | test "zero string to" { |
| 370 | var a = try Managed.initSet(testing.allocator, 0); | 370 | var a = try Managed.initSet(testing.allocator, 0); |
| 371 | defer a.deinit(); | 371 | defer a.deinit(); |
| 372 | 372 | ||
| ... | @@ -377,7 +377,7 @@ test "big.int zero string to" { | ... | @@ -377,7 +377,7 @@ test "big.int zero string to" { |
| 377 | try testing.expect(mem.eql(u8, as, es)); | 377 | try testing.expect(mem.eql(u8, as, es)); |
| 378 | } | 378 | } |
| 379 | 379 | ||
| 380 | test "big.int clone" { | 380 | test "clone" { |
| 381 | var a = try Managed.initSet(testing.allocator, 1234); | 381 | var a = try Managed.initSet(testing.allocator, 1234); |
| 382 | defer a.deinit(); | 382 | defer a.deinit(); |
| 383 | var b = try a.clone(); | 383 | var b = try a.clone(); |
| ... | @@ -391,7 +391,7 @@ test "big.int clone" { | ... | @@ -391,7 +391,7 @@ test "big.int clone" { |
| 391 | try testing.expect((try b.to(u32)) == 1234); | 391 | try testing.expect((try b.to(u32)) == 1234); |
| 392 | } | 392 | } |
| 393 | 393 | ||
| 394 | test "big.int swap" { | 394 | test "swap" { |
| 395 | var a = try Managed.initSet(testing.allocator, 1234); | 395 | var a = try Managed.initSet(testing.allocator, 1234); |
| 396 | defer a.deinit(); | 396 | defer a.deinit(); |
| 397 | var b = try Managed.initSet(testing.allocator, 5678); | 397 | var b = try Managed.initSet(testing.allocator, 5678); |
| ... | @@ -406,14 +406,14 @@ test "big.int swap" { | ... | @@ -406,14 +406,14 @@ test "big.int swap" { |
| 406 | try testing.expect((try b.to(u32)) == 1234); | 406 | try testing.expect((try b.to(u32)) == 1234); |
| 407 | } | 407 | } |
| 408 | 408 | ||
| 409 | test "big.int to negative" { | 409 | test "to negative" { |
| 410 | var a = try Managed.initSet(testing.allocator, -10); | 410 | var a = try Managed.initSet(testing.allocator, -10); |
| 411 | defer a.deinit(); | 411 | defer a.deinit(); |
| 412 | 412 | ||
| 413 | try testing.expect((try a.to(i32)) == -10); | 413 | try testing.expect((try a.to(i32)) == -10); |
| 414 | } | 414 | } |
| 415 | 415 | ||
| 416 | test "big.int compare" { | 416 | test "compare" { |
| 417 | var a = try Managed.initSet(testing.allocator, -11); | 417 | var a = try Managed.initSet(testing.allocator, -11); |
| 418 | defer a.deinit(); | 418 | defer a.deinit(); |
| 419 | var b = try Managed.initSet(testing.allocator, 10); | 419 | var b = try Managed.initSet(testing.allocator, 10); |
| ... | @@ -423,7 +423,7 @@ test "big.int compare" { | ... | @@ -423,7 +423,7 @@ test "big.int compare" { |
| 423 | try testing.expect(a.order(b) == .lt); | 423 | try testing.expect(a.order(b) == .lt); |
| 424 | } | 424 | } |
| 425 | 425 | ||
| 426 | test "big.int compare similar" { | 426 | test "compare similar" { |
| 427 | var a = try Managed.initSet(testing.allocator, 0xffffffffeeeeeeeeffffffffeeeeeeee); | 427 | var a = try Managed.initSet(testing.allocator, 0xffffffffeeeeeeeeffffffffeeeeeeee); |
| 428 | defer a.deinit(); | 428 | defer a.deinit(); |
| 429 | var b = try Managed.initSet(testing.allocator, 0xffffffffeeeeeeeeffffffffeeeeeeef); | 429 | var b = try Managed.initSet(testing.allocator, 0xffffffffeeeeeeeeffffffffeeeeeeef); |
| ... | @@ -433,7 +433,7 @@ test "big.int compare similar" { | ... | @@ -433,7 +433,7 @@ test "big.int compare similar" { |
| 433 | try testing.expect(b.orderAbs(a) == .gt); | 433 | try testing.expect(b.orderAbs(a) == .gt); |
| 434 | } | 434 | } |
| 435 | 435 | ||
| 436 | test "big.int compare different limb size" { | 436 | test "compare different limb size" { |
| 437 | var a = try Managed.initSet(testing.allocator, maxInt(Limb) + 1); | 437 | var a = try Managed.initSet(testing.allocator, maxInt(Limb) + 1); |
| 438 | defer a.deinit(); | 438 | defer a.deinit(); |
| 439 | var b = try Managed.initSet(testing.allocator, 1); | 439 | var b = try Managed.initSet(testing.allocator, 1); |
| ... | @@ -443,7 +443,7 @@ test "big.int compare different limb size" { | ... | @@ -443,7 +443,7 @@ test "big.int compare different limb size" { |
| 443 | try testing.expect(b.orderAbs(a) == .lt); | 443 | try testing.expect(b.orderAbs(a) == .lt); |
| 444 | } | 444 | } |
| 445 | 445 | ||
| 446 | test "big.int compare multi-limb" { | 446 | test "compare multi-limb" { |
| 447 | var a = try Managed.initSet(testing.allocator, -0x7777777799999999ffffeeeeffffeeeeffffeeeef); | 447 | var a = try Managed.initSet(testing.allocator, -0x7777777799999999ffffeeeeffffeeeeffffeeeef); |
| 448 | defer a.deinit(); | 448 | defer a.deinit(); |
| 449 | var b = try Managed.initSet(testing.allocator, 0x7777777799999999ffffeeeeffffeeeeffffeeeee); | 449 | var b = try Managed.initSet(testing.allocator, 0x7777777799999999ffffeeeeffffeeeeffffeeeee); |
| ... | @@ -453,7 +453,7 @@ test "big.int compare multi-limb" { | ... | @@ -453,7 +453,7 @@ test "big.int compare multi-limb" { |
| 453 | try testing.expect(a.order(b) == .lt); | 453 | try testing.expect(a.order(b) == .lt); |
| 454 | } | 454 | } |
| 455 | 455 | ||
| 456 | test "big.int equality" { | 456 | test "equality" { |
| 457 | var a = try Managed.initSet(testing.allocator, 0xffffffff1); | 457 | var a = try Managed.initSet(testing.allocator, 0xffffffff1); |
| 458 | defer a.deinit(); | 458 | defer a.deinit(); |
| 459 | var b = try Managed.initSet(testing.allocator, -0xffffffff1); | 459 | var b = try Managed.initSet(testing.allocator, -0xffffffff1); |
| ... | @@ -463,7 +463,7 @@ test "big.int equality" { | ... | @@ -463,7 +463,7 @@ test "big.int equality" { |
| 463 | try testing.expect(!a.eql(b)); | 463 | try testing.expect(!a.eql(b)); |
| 464 | } | 464 | } |
| 465 | 465 | ||
| 466 | test "big.int abs" { | 466 | test "abs" { |
| 467 | var a = try Managed.initSet(testing.allocator, -5); | 467 | var a = try Managed.initSet(testing.allocator, -5); |
| 468 | defer a.deinit(); | 468 | defer a.deinit(); |
| 469 | 469 | ||
| ... | @@ -474,7 +474,7 @@ test "big.int abs" { | ... | @@ -474,7 +474,7 @@ test "big.int abs" { |
| 474 | try testing.expect((try a.to(u32)) == 5); | 474 | try testing.expect((try a.to(u32)) == 5); |
| 475 | } | 475 | } |
| 476 | 476 | ||
| 477 | test "big.int negate" { | 477 | test "negate" { |
| 478 | var a = try Managed.initSet(testing.allocator, 5); | 478 | var a = try Managed.initSet(testing.allocator, 5); |
| 479 | defer a.deinit(); | 479 | defer a.deinit(); |
| 480 | 480 | ||
| ... | @@ -485,7 +485,7 @@ test "big.int negate" { | ... | @@ -485,7 +485,7 @@ test "big.int negate" { |
| 485 | try testing.expect((try a.to(i32)) == 5); | 485 | try testing.expect((try a.to(i32)) == 5); |
| 486 | } | 486 | } |
| 487 | 487 | ||
| 488 | test "big.int add single-single" { | 488 | test "add single-single" { |
| 489 | var a = try Managed.initSet(testing.allocator, 50); | 489 | var a = try Managed.initSet(testing.allocator, 50); |
| 490 | defer a.deinit(); | 490 | defer a.deinit(); |
| 491 | var b = try Managed.initSet(testing.allocator, 5); | 491 | var b = try Managed.initSet(testing.allocator, 5); |
| ... | @@ -498,7 +498,7 @@ test "big.int add single-single" { | ... | @@ -498,7 +498,7 @@ test "big.int add single-single" { |
| 498 | try testing.expect((try c.to(u32)) == 55); | 498 | try testing.expect((try c.to(u32)) == 55); |
| 499 | } | 499 | } |
| 500 | 500 | ||
| 501 | test "big.int add multi-single" { | 501 | test "add multi-single" { |
| 502 | var a = try Managed.initSet(testing.allocator, maxInt(Limb) + 1); | 502 | var a = try Managed.initSet(testing.allocator, maxInt(Limb) + 1); |
| 503 | defer a.deinit(); | 503 | defer a.deinit(); |
| 504 | var b = try Managed.initSet(testing.allocator, 1); | 504 | var b = try Managed.initSet(testing.allocator, 1); |
| ... | @@ -514,7 +514,7 @@ test "big.int add multi-single" { | ... | @@ -514,7 +514,7 @@ test "big.int add multi-single" { |
| 514 | try testing.expect((try c.to(DoubleLimb)) == maxInt(Limb) + 2); | 514 | try testing.expect((try c.to(DoubleLimb)) == maxInt(Limb) + 2); |
| 515 | } | 515 | } |
| 516 | 516 | ||
| 517 | test "big.int add multi-multi" { | 517 | test "add multi-multi" { |
| 518 | var op1: u128 = 0xefefefef7f7f7f7f; | 518 | var op1: u128 = 0xefefefef7f7f7f7f; |
| 519 | var op2: u128 = 0xfefefefe9f9f9f9f; | 519 | var op2: u128 = 0xfefefefe9f9f9f9f; |
| 520 | // These must be runtime-known to prevent this comparison being tautological, as the | 520 | // These must be runtime-known to prevent this comparison being tautological, as the |
| ... | @@ -532,7 +532,7 @@ test "big.int add multi-multi" { | ... | @@ -532,7 +532,7 @@ test "big.int add multi-multi" { |
| 532 | try testing.expect((try c.to(u128)) == op1 + op2); | 532 | try testing.expect((try c.to(u128)) == op1 + op2); |
| 533 | } | 533 | } |
| 534 | 534 | ||
| 535 | test "big.int add zero-zero" { | 535 | test "add zero-zero" { |
| 536 | var a = try Managed.initSet(testing.allocator, 0); | 536 | var a = try Managed.initSet(testing.allocator, 0); |
| 537 | defer a.deinit(); | 537 | defer a.deinit(); |
| 538 | var b = try Managed.initSet(testing.allocator, 0); | 538 | var b = try Managed.initSet(testing.allocator, 0); |
| ... | @@ -545,7 +545,7 @@ test "big.int add zero-zero" { | ... | @@ -545,7 +545,7 @@ test "big.int add zero-zero" { |
| 545 | try testing.expect((try c.to(u32)) == 0); | 545 | try testing.expect((try c.to(u32)) == 0); |
| 546 | } | 546 | } |
| 547 | 547 | ||
| 548 | test "big.int add alias multi-limb nonzero-zero" { | 548 | test "add alias multi-limb nonzero-zero" { |
| 549 | const op1 = 0xffffffff777777771; | 549 | const op1 = 0xffffffff777777771; |
| 550 | var a = try Managed.initSet(testing.allocator, op1); | 550 | var a = try Managed.initSet(testing.allocator, op1); |
| 551 | defer a.deinit(); | 551 | defer a.deinit(); |
| ... | @@ -557,7 +557,7 @@ test "big.int add alias multi-limb nonzero-zero" { | ... | @@ -557,7 +557,7 @@ test "big.int add alias multi-limb nonzero-zero" { |
| 557 | try testing.expect((try a.to(u128)) == op1); | 557 | try testing.expect((try a.to(u128)) == op1); |
| 558 | } | 558 | } |
| 559 | 559 | ||
| 560 | test "big.int add sign" { | 560 | test "add sign" { |
| 561 | var a = try Managed.init(testing.allocator); | 561 | var a = try Managed.init(testing.allocator); |
| 562 | defer a.deinit(); | 562 | defer a.deinit(); |
| 563 | 563 | ||
| ... | @@ -583,7 +583,7 @@ test "big.int add sign" { | ... | @@ -583,7 +583,7 @@ test "big.int add sign" { |
| 583 | try testing.expect((try a.to(i32)) == -3); | 583 | try testing.expect((try a.to(i32)) == -3); |
| 584 | } | 584 | } |
| 585 | 585 | ||
| 586 | test "big.int add comptime scalar" { | 586 | test "add comptime scalar" { |
| 587 | var a = try Managed.initSet(testing.allocator, 50); | 587 | var a = try Managed.initSet(testing.allocator, 50); |
| 588 | defer a.deinit(); | 588 | defer a.deinit(); |
| 589 | 589 | ||
| ... | @@ -594,7 +594,7 @@ test "big.int add comptime scalar" { | ... | @@ -594,7 +594,7 @@ test "big.int add comptime scalar" { |
| 594 | try testing.expect((try b.to(u32)) == 55); | 594 | try testing.expect((try b.to(u32)) == 55); |
| 595 | } | 595 | } |
| 596 | 596 | ||
| 597 | test "big.int add scalar" { | 597 | test "add scalar" { |
| 598 | var a = try Managed.initSet(testing.allocator, 123); | 598 | var a = try Managed.initSet(testing.allocator, 123); |
| 599 | defer a.deinit(); | 599 | defer a.deinit(); |
| 600 | 600 | ||
| ... | @@ -605,7 +605,7 @@ test "big.int add scalar" { | ... | @@ -605,7 +605,7 @@ test "big.int add scalar" { |
| 605 | try testing.expect((try b.to(u32)) == 154); | 605 | try testing.expect((try b.to(u32)) == 154); |
| 606 | } | 606 | } |
| 607 | 607 | ||
| 608 | test "big.int addWrap single-single, unsigned" { | 608 | test "addWrap single-single, unsigned" { |
| 609 | var a = try Managed.initSet(testing.allocator, maxInt(u17)); | 609 | var a = try Managed.initSet(testing.allocator, maxInt(u17)); |
| 610 | defer a.deinit(); | 610 | defer a.deinit(); |
| 611 | 611 | ||
| ... | @@ -618,7 +618,7 @@ test "big.int addWrap single-single, unsigned" { | ... | @@ -618,7 +618,7 @@ test "big.int addWrap single-single, unsigned" { |
| 618 | try testing.expect((try a.to(u17)) == 9); | 618 | try testing.expect((try a.to(u17)) == 9); |
| 619 | } | 619 | } |
| 620 | 620 | ||
| 621 | test "big.int subWrap single-single, unsigned" { | 621 | test "subWrap single-single, unsigned" { |
| 622 | var a = try Managed.initSet(testing.allocator, 0); | 622 | var a = try Managed.initSet(testing.allocator, 0); |
| 623 | defer a.deinit(); | 623 | defer a.deinit(); |
| 624 | 624 | ||
| ... | @@ -631,7 +631,7 @@ test "big.int subWrap single-single, unsigned" { | ... | @@ -631,7 +631,7 @@ test "big.int subWrap single-single, unsigned" { |
| 631 | try testing.expect((try a.to(u17)) == 1); | 631 | try testing.expect((try a.to(u17)) == 1); |
| 632 | } | 632 | } |
| 633 | 633 | ||
| 634 | test "big.int addWrap multi-multi, unsigned, limb aligned" { | 634 | test "addWrap multi-multi, unsigned, limb aligned" { |
| 635 | var a = try Managed.initSet(testing.allocator, maxInt(DoubleLimb)); | 635 | var a = try Managed.initSet(testing.allocator, maxInt(DoubleLimb)); |
| 636 | defer a.deinit(); | 636 | defer a.deinit(); |
| 637 | 637 | ||
| ... | @@ -644,7 +644,7 @@ test "big.int addWrap multi-multi, unsigned, limb aligned" { | ... | @@ -644,7 +644,7 @@ test "big.int addWrap multi-multi, unsigned, limb aligned" { |
| 644 | try testing.expect((try a.to(DoubleLimb)) == maxInt(DoubleLimb) - 1); | 644 | try testing.expect((try a.to(DoubleLimb)) == maxInt(DoubleLimb) - 1); |
| 645 | } | 645 | } |
| 646 | 646 | ||
| 647 | test "big.int subWrap single-multi, unsigned, limb aligned" { | 647 | test "subWrap single-multi, unsigned, limb aligned" { |
| 648 | var a = try Managed.initSet(testing.allocator, 10); | 648 | var a = try Managed.initSet(testing.allocator, 10); |
| 649 | defer a.deinit(); | 649 | defer a.deinit(); |
| 650 | 650 | ||
| ... | @@ -657,7 +657,7 @@ test "big.int subWrap single-multi, unsigned, limb aligned" { | ... | @@ -657,7 +657,7 @@ test "big.int subWrap single-multi, unsigned, limb aligned" { |
| 657 | try testing.expect((try a.to(DoubleLimb)) == maxInt(DoubleLimb) - 88); | 657 | try testing.expect((try a.to(DoubleLimb)) == maxInt(DoubleLimb) - 88); |
| 658 | } | 658 | } |
| 659 | 659 | ||
| 660 | test "big.int addWrap single-single, signed" { | 660 | test "addWrap single-single, signed" { |
| 661 | var a = try Managed.initSet(testing.allocator, maxInt(i21)); | 661 | var a = try Managed.initSet(testing.allocator, maxInt(i21)); |
| 662 | defer a.deinit(); | 662 | defer a.deinit(); |
| 663 | 663 | ||
| ... | @@ -670,7 +670,7 @@ test "big.int addWrap single-single, signed" { | ... | @@ -670,7 +670,7 @@ test "big.int addWrap single-single, signed" { |
| 670 | try testing.expect((try a.to(i21)) == minInt(i21)); | 670 | try testing.expect((try a.to(i21)) == minInt(i21)); |
| 671 | } | 671 | } |
| 672 | 672 | ||
| 673 | test "big.int subWrap single-single, signed" { | 673 | test "subWrap single-single, signed" { |
| 674 | var a = try Managed.initSet(testing.allocator, minInt(i21)); | 674 | var a = try Managed.initSet(testing.allocator, minInt(i21)); |
| 675 | defer a.deinit(); | 675 | defer a.deinit(); |
| 676 | 676 | ||
| ... | @@ -683,7 +683,7 @@ test "big.int subWrap single-single, signed" { | ... | @@ -683,7 +683,7 @@ test "big.int subWrap single-single, signed" { |
| 683 | try testing.expect((try a.to(i21)) == maxInt(i21)); | 683 | try testing.expect((try a.to(i21)) == maxInt(i21)); |
| 684 | } | 684 | } |
| 685 | 685 | ||
| 686 | test "big.int addWrap multi-multi, signed, limb aligned" { | 686 | test "addWrap multi-multi, signed, limb aligned" { |
| 687 | var a = try Managed.initSet(testing.allocator, maxInt(SignedDoubleLimb)); | 687 | var a = try Managed.initSet(testing.allocator, maxInt(SignedDoubleLimb)); |
| 688 | defer a.deinit(); | 688 | defer a.deinit(); |
| 689 | 689 | ||
| ... | @@ -696,7 +696,7 @@ test "big.int addWrap multi-multi, signed, limb aligned" { | ... | @@ -696,7 +696,7 @@ test "big.int addWrap multi-multi, signed, limb aligned" { |
| 696 | try testing.expect((try a.to(SignedDoubleLimb)) == -2); | 696 | try testing.expect((try a.to(SignedDoubleLimb)) == -2); |
| 697 | } | 697 | } |
| 698 | 698 | ||
| 699 | test "big.int subWrap single-multi, signed, limb aligned" { | 699 | test "subWrap single-multi, signed, limb aligned" { |
| 700 | var a = try Managed.initSet(testing.allocator, minInt(SignedDoubleLimb)); | 700 | var a = try Managed.initSet(testing.allocator, minInt(SignedDoubleLimb)); |
| 701 | defer a.deinit(); | 701 | defer a.deinit(); |
| 702 | 702 | ||
| ... | @@ -709,7 +709,7 @@ test "big.int subWrap single-multi, signed, limb aligned" { | ... | @@ -709,7 +709,7 @@ test "big.int subWrap single-multi, signed, limb aligned" { |
| 709 | try testing.expect((try a.to(SignedDoubleLimb)) == maxInt(SignedDoubleLimb)); | 709 | try testing.expect((try a.to(SignedDoubleLimb)) == maxInt(SignedDoubleLimb)); |
| 710 | } | 710 | } |
| 711 | 711 | ||
| 712 | test "big.int addSat single-single, unsigned" { | 712 | test "addSat single-single, unsigned" { |
| 713 | var a = try Managed.initSet(testing.allocator, maxInt(u17) - 5); | 713 | var a = try Managed.initSet(testing.allocator, maxInt(u17) - 5); |
| 714 | defer a.deinit(); | 714 | defer a.deinit(); |
| 715 | 715 | ||
| ... | @@ -721,7 +721,7 @@ test "big.int addSat single-single, unsigned" { | ... | @@ -721,7 +721,7 @@ test "big.int addSat single-single, unsigned" { |
| 721 | try testing.expect((try a.to(u17)) == maxInt(u17)); | 721 | try testing.expect((try a.to(u17)) == maxInt(u17)); |
| 722 | } | 722 | } |
| 723 | 723 | ||
| 724 | test "big.int subSat single-single, unsigned" { | 724 | test "subSat single-single, unsigned" { |
| 725 | var a = try Managed.initSet(testing.allocator, 123); | 725 | var a = try Managed.initSet(testing.allocator, 123); |
| 726 | defer a.deinit(); | 726 | defer a.deinit(); |
| 727 | 727 | ||
| ... | @@ -733,7 +733,7 @@ test "big.int subSat single-single, unsigned" { | ... | @@ -733,7 +733,7 @@ test "big.int subSat single-single, unsigned" { |
| 733 | try testing.expect((try a.to(u17)) == 0); | 733 | try testing.expect((try a.to(u17)) == 0); |
| 734 | } | 734 | } |
| 735 | 735 | ||
| 736 | test "big.int addSat multi-multi, unsigned, limb aligned" { | 736 | test "addSat multi-multi, unsigned, limb aligned" { |
| 737 | var a = try Managed.initSet(testing.allocator, maxInt(DoubleLimb)); | 737 | var a = try Managed.initSet(testing.allocator, maxInt(DoubleLimb)); |
| 738 | defer a.deinit(); | 738 | defer a.deinit(); |
| 739 | 739 | ||
| ... | @@ -745,7 +745,7 @@ test "big.int addSat multi-multi, unsigned, limb aligned" { | ... | @@ -745,7 +745,7 @@ test "big.int addSat multi-multi, unsigned, limb aligned" { |
| 745 | try testing.expect((try a.to(DoubleLimb)) == maxInt(DoubleLimb)); | 745 | try testing.expect((try a.to(DoubleLimb)) == maxInt(DoubleLimb)); |
| 746 | } | 746 | } |
| 747 | 747 | ||
| 748 | test "big.int subSat single-multi, unsigned, limb aligned" { | 748 | test "subSat single-multi, unsigned, limb aligned" { |
| 749 | var a = try Managed.initSet(testing.allocator, 10); | 749 | var a = try Managed.initSet(testing.allocator, 10); |
| 750 | defer a.deinit(); | 750 | defer a.deinit(); |
| 751 | 751 | ||
| ... | @@ -757,7 +757,7 @@ test "big.int subSat single-multi, unsigned, limb aligned" { | ... | @@ -757,7 +757,7 @@ test "big.int subSat single-multi, unsigned, limb aligned" { |
| 757 | try testing.expect((try a.to(DoubleLimb)) == 0); | 757 | try testing.expect((try a.to(DoubleLimb)) == 0); |
| 758 | } | 758 | } |
| 759 | 759 | ||
| 760 | test "big.int addSat single-single, signed" { | 760 | test "addSat single-single, signed" { |
| 761 | var a = try Managed.initSet(testing.allocator, maxInt(i14)); | 761 | var a = try Managed.initSet(testing.allocator, maxInt(i14)); |
| 762 | defer a.deinit(); | 762 | defer a.deinit(); |
| 763 | 763 | ||
| ... | @@ -769,7 +769,7 @@ test "big.int addSat single-single, signed" { | ... | @@ -769,7 +769,7 @@ test "big.int addSat single-single, signed" { |
| 769 | try testing.expect((try a.to(i14)) == maxInt(i14)); | 769 | try testing.expect((try a.to(i14)) == maxInt(i14)); |
| 770 | } | 770 | } |
| 771 | 771 | ||
| 772 | test "big.int subSat single-single, signed" { | 772 | test "subSat single-single, signed" { |
| 773 | var a = try Managed.initSet(testing.allocator, minInt(i21)); | 773 | var a = try Managed.initSet(testing.allocator, minInt(i21)); |
| 774 | defer a.deinit(); | 774 | defer a.deinit(); |
| 775 | 775 | ||
| ... | @@ -781,7 +781,7 @@ test "big.int subSat single-single, signed" { | ... | @@ -781,7 +781,7 @@ test "big.int subSat single-single, signed" { |
| 781 | try testing.expect((try a.to(i21)) == minInt(i21)); | 781 | try testing.expect((try a.to(i21)) == minInt(i21)); |
| 782 | } | 782 | } |
| 783 | 783 | ||
| 784 | test "big.int addSat multi-multi, signed, limb aligned" { | 784 | test "addSat multi-multi, signed, limb aligned" { |
| 785 | var a = try Managed.initSet(testing.allocator, maxInt(SignedDoubleLimb)); | 785 | var a = try Managed.initSet(testing.allocator, maxInt(SignedDoubleLimb)); |
| 786 | defer a.deinit(); | 786 | defer a.deinit(); |
| 787 | 787 | ||
| ... | @@ -793,7 +793,7 @@ test "big.int addSat multi-multi, signed, limb aligned" { | ... | @@ -793,7 +793,7 @@ test "big.int addSat multi-multi, signed, limb aligned" { |
| 793 | try testing.expect((try a.to(SignedDoubleLimb)) == maxInt(SignedDoubleLimb)); | 793 | try testing.expect((try a.to(SignedDoubleLimb)) == maxInt(SignedDoubleLimb)); |
| 794 | } | 794 | } |
| 795 | 795 | ||
| 796 | test "big.int subSat single-multi, signed, limb aligned" { | 796 | test "subSat single-multi, signed, limb aligned" { |
| 797 | var a = try Managed.initSet(testing.allocator, minInt(SignedDoubleLimb)); | 797 | var a = try Managed.initSet(testing.allocator, minInt(SignedDoubleLimb)); |
| 798 | defer a.deinit(); | 798 | defer a.deinit(); |
| 799 | 799 | ||
| ... | @@ -805,7 +805,7 @@ test "big.int subSat single-multi, signed, limb aligned" { | ... | @@ -805,7 +805,7 @@ test "big.int subSat single-multi, signed, limb aligned" { |
| 805 | try testing.expect((try a.to(SignedDoubleLimb)) == minInt(SignedDoubleLimb)); | 805 | try testing.expect((try a.to(SignedDoubleLimb)) == minInt(SignedDoubleLimb)); |
| 806 | } | 806 | } |
| 807 | 807 | ||
| 808 | test "big.int sub single-single" { | 808 | test "sub single-single" { |
| 809 | var a = try Managed.initSet(testing.allocator, 50); | 809 | var a = try Managed.initSet(testing.allocator, 50); |
| 810 | defer a.deinit(); | 810 | defer a.deinit(); |
| 811 | var b = try Managed.initSet(testing.allocator, 5); | 811 | var b = try Managed.initSet(testing.allocator, 5); |
| ... | @@ -818,7 +818,7 @@ test "big.int sub single-single" { | ... | @@ -818,7 +818,7 @@ test "big.int sub single-single" { |
| 818 | try testing.expect((try c.to(u32)) == 45); | 818 | try testing.expect((try c.to(u32)) == 45); |
| 819 | } | 819 | } |
| 820 | 820 | ||
| 821 | test "big.int sub multi-single" { | 821 | test "sub multi-single" { |
| 822 | var a = try Managed.initSet(testing.allocator, maxInt(Limb) + 1); | 822 | var a = try Managed.initSet(testing.allocator, maxInt(Limb) + 1); |
| 823 | defer a.deinit(); | 823 | defer a.deinit(); |
| 824 | var b = try Managed.initSet(testing.allocator, 1); | 824 | var b = try Managed.initSet(testing.allocator, 1); |
| ... | @@ -831,7 +831,7 @@ test "big.int sub multi-single" { | ... | @@ -831,7 +831,7 @@ test "big.int sub multi-single" { |
| 831 | try testing.expect((try c.to(Limb)) == maxInt(Limb)); | 831 | try testing.expect((try c.to(Limb)) == maxInt(Limb)); |
| 832 | } | 832 | } |
| 833 | 833 | ||
| 834 | test "big.int sub multi-multi" { | 834 | test "sub multi-multi" { |
| 835 | var op1: u128 = 0xefefefefefefefefefefefef; | 835 | var op1: u128 = 0xefefefefefefefefefefefef; |
| 836 | var op2: u128 = 0xabababababababababababab; | 836 | var op2: u128 = 0xabababababababababababab; |
| 837 | _ = .{ &op1, &op2 }; | 837 | _ = .{ &op1, &op2 }; |
| ... | @@ -848,7 +848,7 @@ test "big.int sub multi-multi" { | ... | @@ -848,7 +848,7 @@ test "big.int sub multi-multi" { |
| 848 | try testing.expect((try c.to(u128)) == op1 - op2); | 848 | try testing.expect((try c.to(u128)) == op1 - op2); |
| 849 | } | 849 | } |
| 850 | 850 | ||
| 851 | test "big.int sub equal" { | 851 | test "sub equal" { |
| 852 | var a = try Managed.initSet(testing.allocator, 0x11efefefefefefefefefefefef); | 852 | var a = try Managed.initSet(testing.allocator, 0x11efefefefefefefefefefefef); |
| 853 | defer a.deinit(); | 853 | defer a.deinit(); |
| 854 | var b = try Managed.initSet(testing.allocator, 0x11efefefefefefefefefefefef); | 854 | var b = try Managed.initSet(testing.allocator, 0x11efefefefefefefefefefefef); |
| ... | @@ -861,7 +861,7 @@ test "big.int sub equal" { | ... | @@ -861,7 +861,7 @@ test "big.int sub equal" { |
| 861 | try testing.expect((try c.to(u32)) == 0); | 861 | try testing.expect((try c.to(u32)) == 0); |
| 862 | } | 862 | } |
| 863 | 863 | ||
| 864 | test "big.int sub sign" { | 864 | test "sub sign" { |
| 865 | var a = try Managed.init(testing.allocator); | 865 | var a = try Managed.init(testing.allocator); |
| 866 | defer a.deinit(); | 866 | defer a.deinit(); |
| 867 | 867 | ||
| ... | @@ -890,7 +890,7 @@ test "big.int sub sign" { | ... | @@ -890,7 +890,7 @@ test "big.int sub sign" { |
| 890 | try testing.expect((try a.to(i32)) == -1); | 890 | try testing.expect((try a.to(i32)) == -1); |
| 891 | } | 891 | } |
| 892 | 892 | ||
| 893 | test "big.int mul single-single" { | 893 | test "mul single-single" { |
| 894 | var a = try Managed.initSet(testing.allocator, 50); | 894 | var a = try Managed.initSet(testing.allocator, 50); |
| 895 | defer a.deinit(); | 895 | defer a.deinit(); |
| 896 | var b = try Managed.initSet(testing.allocator, 5); | 896 | var b = try Managed.initSet(testing.allocator, 5); |
| ... | @@ -903,7 +903,7 @@ test "big.int mul single-single" { | ... | @@ -903,7 +903,7 @@ test "big.int mul single-single" { |
| 903 | try testing.expect((try c.to(u64)) == 250); | 903 | try testing.expect((try c.to(u64)) == 250); |
| 904 | } | 904 | } |
| 905 | 905 | ||
| 906 | test "big.int mul multi-single" { | 906 | test "mul multi-single" { |
| 907 | var a = try Managed.initSet(testing.allocator, maxInt(Limb)); | 907 | var a = try Managed.initSet(testing.allocator, maxInt(Limb)); |
| 908 | defer a.deinit(); | 908 | defer a.deinit(); |
| 909 | var b = try Managed.initSet(testing.allocator, 2); | 909 | var b = try Managed.initSet(testing.allocator, 2); |
| ... | @@ -916,7 +916,7 @@ test "big.int mul multi-single" { | ... | @@ -916,7 +916,7 @@ test "big.int mul multi-single" { |
| 916 | try testing.expect((try c.to(DoubleLimb)) == 2 * maxInt(Limb)); | 916 | try testing.expect((try c.to(DoubleLimb)) == 2 * maxInt(Limb)); |
| 917 | } | 917 | } |
| 918 | 918 | ||
| 919 | test "big.int mul multi-multi" { | 919 | test "mul multi-multi" { |
| 920 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 920 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 921 | 921 | ||
| 922 | var op1: u256 = 0x998888efefefefefefefef; | 922 | var op1: u256 = 0x998888efefefefefefefef; |
| ... | @@ -935,7 +935,7 @@ test "big.int mul multi-multi" { | ... | @@ -935,7 +935,7 @@ test "big.int mul multi-multi" { |
| 935 | try testing.expect((try c.to(u256)) == op1 * op2); | 935 | try testing.expect((try c.to(u256)) == op1 * op2); |
| 936 | } | 936 | } |
| 937 | 937 | ||
| 938 | test "big.int mul alias r with a" { | 938 | test "mul alias r with a" { |
| 939 | var a = try Managed.initSet(testing.allocator, maxInt(Limb)); | 939 | var a = try Managed.initSet(testing.allocator, maxInt(Limb)); |
| 940 | defer a.deinit(); | 940 | defer a.deinit(); |
| 941 | var b = try Managed.initSet(testing.allocator, 2); | 941 | var b = try Managed.initSet(testing.allocator, 2); |
| ... | @@ -946,7 +946,7 @@ test "big.int mul alias r with a" { | ... | @@ -946,7 +946,7 @@ test "big.int mul alias r with a" { |
| 946 | try testing.expect((try a.to(DoubleLimb)) == 2 * maxInt(Limb)); | 946 | try testing.expect((try a.to(DoubleLimb)) == 2 * maxInt(Limb)); |
| 947 | } | 947 | } |
| 948 | 948 | ||
| 949 | test "big.int mul alias r with b" { | 949 | test "mul alias r with b" { |
| 950 | var a = try Managed.initSet(testing.allocator, maxInt(Limb)); | 950 | var a = try Managed.initSet(testing.allocator, maxInt(Limb)); |
| 951 | defer a.deinit(); | 951 | defer a.deinit(); |
| 952 | var b = try Managed.initSet(testing.allocator, 2); | 952 | var b = try Managed.initSet(testing.allocator, 2); |
| ... | @@ -957,7 +957,7 @@ test "big.int mul alias r with b" { | ... | @@ -957,7 +957,7 @@ test "big.int mul alias r with b" { |
| 957 | try testing.expect((try a.to(DoubleLimb)) == 2 * maxInt(Limb)); | 957 | try testing.expect((try a.to(DoubleLimb)) == 2 * maxInt(Limb)); |
| 958 | } | 958 | } |
| 959 | 959 | ||
| 960 | test "big.int mul alias r with a and b" { | 960 | test "mul alias r with a and b" { |
| 961 | var a = try Managed.initSet(testing.allocator, maxInt(Limb)); | 961 | var a = try Managed.initSet(testing.allocator, maxInt(Limb)); |
| 962 | defer a.deinit(); | 962 | defer a.deinit(); |
| 963 | 963 | ||
| ... | @@ -966,7 +966,7 @@ test "big.int mul alias r with a and b" { | ... | @@ -966,7 +966,7 @@ test "big.int mul alias r with a and b" { |
| 966 | try testing.expect((try a.to(DoubleLimb)) == maxInt(Limb) * maxInt(Limb)); | 966 | try testing.expect((try a.to(DoubleLimb)) == maxInt(Limb) * maxInt(Limb)); |
| 967 | } | 967 | } |
| 968 | 968 | ||
| 969 | test "big.int mul a*0" { | 969 | test "mul a*0" { |
| 970 | var a = try Managed.initSet(testing.allocator, 0xefefefefefefefef); | 970 | var a = try Managed.initSet(testing.allocator, 0xefefefefefefefef); |
| 971 | defer a.deinit(); | 971 | defer a.deinit(); |
| 972 | var b = try Managed.initSet(testing.allocator, 0); | 972 | var b = try Managed.initSet(testing.allocator, 0); |
| ... | @@ -979,7 +979,7 @@ test "big.int mul a*0" { | ... | @@ -979,7 +979,7 @@ test "big.int mul a*0" { |
| 979 | try testing.expect((try c.to(u32)) == 0); | 979 | try testing.expect((try c.to(u32)) == 0); |
| 980 | } | 980 | } |
| 981 | 981 | ||
| 982 | test "big.int mul 0*0" { | 982 | test "mul 0*0" { |
| 983 | var a = try Managed.initSet(testing.allocator, 0); | 983 | var a = try Managed.initSet(testing.allocator, 0); |
| 984 | defer a.deinit(); | 984 | defer a.deinit(); |
| 985 | var b = try Managed.initSet(testing.allocator, 0); | 985 | var b = try Managed.initSet(testing.allocator, 0); |
| ... | @@ -992,7 +992,7 @@ test "big.int mul 0*0" { | ... | @@ -992,7 +992,7 @@ test "big.int mul 0*0" { |
| 992 | try testing.expect((try c.to(u32)) == 0); | 992 | try testing.expect((try c.to(u32)) == 0); |
| 993 | } | 993 | } |
| 994 | 994 | ||
| 995 | test "big.int mul large" { | 995 | test "mul large" { |
| 996 | var a = try Managed.initCapacity(testing.allocator, 50); | 996 | var a = try Managed.initCapacity(testing.allocator, 50); |
| 997 | defer a.deinit(); | 997 | defer a.deinit(); |
| 998 | var b = try Managed.initCapacity(testing.allocator, 100); | 998 | var b = try Managed.initCapacity(testing.allocator, 100); |
| ... | @@ -1013,7 +1013,7 @@ test "big.int mul large" { | ... | @@ -1013,7 +1013,7 @@ test "big.int mul large" { |
| 1013 | try testing.expect(b.eql(c)); | 1013 | try testing.expect(b.eql(c)); |
| 1014 | } | 1014 | } |
| 1015 | 1015 | ||
| 1016 | test "big.int mulWrap single-single unsigned" { | 1016 | test "mulWrap single-single unsigned" { |
| 1017 | var a = try Managed.initSet(testing.allocator, 1234); | 1017 | var a = try Managed.initSet(testing.allocator, 1234); |
| 1018 | defer a.deinit(); | 1018 | defer a.deinit(); |
| 1019 | var b = try Managed.initSet(testing.allocator, 5678); | 1019 | var b = try Managed.initSet(testing.allocator, 5678); |
| ... | @@ -1026,7 +1026,7 @@ test "big.int mulWrap single-single unsigned" { | ... | @@ -1026,7 +1026,7 @@ test "big.int mulWrap single-single unsigned" { |
| 1026 | try testing.expect((try c.to(u17)) == 59836); | 1026 | try testing.expect((try c.to(u17)) == 59836); |
| 1027 | } | 1027 | } |
| 1028 | 1028 | ||
| 1029 | test "big.int mulWrap single-single signed" { | 1029 | test "mulWrap single-single signed" { |
| 1030 | var a = try Managed.initSet(testing.allocator, 1234); | 1030 | var a = try Managed.initSet(testing.allocator, 1234); |
| 1031 | defer a.deinit(); | 1031 | defer a.deinit(); |
| 1032 | var b = try Managed.initSet(testing.allocator, -5678); | 1032 | var b = try Managed.initSet(testing.allocator, -5678); |
| ... | @@ -1039,7 +1039,7 @@ test "big.int mulWrap single-single signed" { | ... | @@ -1039,7 +1039,7 @@ test "big.int mulWrap single-single signed" { |
| 1039 | try testing.expect((try c.to(i17)) == -59836); | 1039 | try testing.expect((try c.to(i17)) == -59836); |
| 1040 | } | 1040 | } |
| 1041 | 1041 | ||
| 1042 | test "big.int mulWrap multi-multi unsigned" { | 1042 | test "mulWrap multi-multi unsigned" { |
| 1043 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 1043 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 1044 | 1044 | ||
| 1045 | var op1: u256 = 0x998888efefefefefefefef; | 1045 | var op1: u256 = 0x998888efefefefefefefef; |
| ... | @@ -1058,7 +1058,7 @@ test "big.int mulWrap multi-multi unsigned" { | ... | @@ -1058,7 +1058,7 @@ test "big.int mulWrap multi-multi unsigned" { |
| 1058 | try testing.expect((try c.to(u256)) == (op1 * op2) & ((1 << 65) - 1)); | 1058 | try testing.expect((try c.to(u256)) == (op1 * op2) & ((1 << 65) - 1)); |
| 1059 | } | 1059 | } |
| 1060 | 1060 | ||
| 1061 | test "big.int mulWrap multi-multi signed" { | 1061 | test "mulWrap multi-multi signed" { |
| 1062 | switch (builtin.zig_backend) { | 1062 | switch (builtin.zig_backend) { |
| 1063 | .stage2_c => return error.SkipZigTest, | 1063 | .stage2_c => return error.SkipZigTest, |
| 1064 | else => {}, | 1064 | else => {}, |
| ... | @@ -1076,7 +1076,7 @@ test "big.int mulWrap multi-multi signed" { | ... | @@ -1076,7 +1076,7 @@ test "big.int mulWrap multi-multi signed" { |
| 1076 | try testing.expect((try c.to(SignedDoubleLimb)) == minInt(SignedDoubleLimb) + 2); | 1076 | try testing.expect((try c.to(SignedDoubleLimb)) == minInt(SignedDoubleLimb) + 2); |
| 1077 | } | 1077 | } |
| 1078 | 1078 | ||
| 1079 | test "big.int mulWrap large" { | 1079 | test "mulWrap large" { |
| 1080 | var a = try Managed.initCapacity(testing.allocator, 50); | 1080 | var a = try Managed.initCapacity(testing.allocator, 50); |
| 1081 | defer a.deinit(); | 1081 | defer a.deinit(); |
| 1082 | var b = try Managed.initCapacity(testing.allocator, 100); | 1082 | var b = try Managed.initCapacity(testing.allocator, 100); |
| ... | @@ -1100,7 +1100,7 @@ test "big.int mulWrap large" { | ... | @@ -1100,7 +1100,7 @@ test "big.int mulWrap large" { |
| 1100 | try testing.expect(b.eql(c)); | 1100 | try testing.expect(b.eql(c)); |
| 1101 | } | 1101 | } |
| 1102 | 1102 | ||
| 1103 | test "big.int div single-half no rem" { | 1103 | test "div single-half no rem" { |
| 1104 | var a = try Managed.initSet(testing.allocator, 50); | 1104 | var a = try Managed.initSet(testing.allocator, 50); |
| 1105 | defer a.deinit(); | 1105 | defer a.deinit(); |
| 1106 | var b = try Managed.initSet(testing.allocator, 5); | 1106 | var b = try Managed.initSet(testing.allocator, 5); |
| ... | @@ -1116,7 +1116,7 @@ test "big.int div single-half no rem" { | ... | @@ -1116,7 +1116,7 @@ test "big.int div single-half no rem" { |
| 1116 | try testing.expect((try r.to(u32)) == 0); | 1116 | try testing.expect((try r.to(u32)) == 0); |
| 1117 | } | 1117 | } |
| 1118 | 1118 | ||
| 1119 | test "big.int div single-half with rem" { | 1119 | test "div single-half with rem" { |
| 1120 | var a = try Managed.initSet(testing.allocator, 49); | 1120 | var a = try Managed.initSet(testing.allocator, 49); |
| 1121 | defer a.deinit(); | 1121 | defer a.deinit(); |
| 1122 | var b = try Managed.initSet(testing.allocator, 5); | 1122 | var b = try Managed.initSet(testing.allocator, 5); |
| ... | @@ -1132,7 +1132,7 @@ test "big.int div single-half with rem" { | ... | @@ -1132,7 +1132,7 @@ test "big.int div single-half with rem" { |
| 1132 | try testing.expect((try r.to(u32)) == 4); | 1132 | try testing.expect((try r.to(u32)) == 4); |
| 1133 | } | 1133 | } |
| 1134 | 1134 | ||
| 1135 | test "big.int div single-single no rem" { | 1135 | test "div single-single no rem" { |
| 1136 | // assumes usize is <= 64 bits. | 1136 | // assumes usize is <= 64 bits. |
| 1137 | var a = try Managed.initSet(testing.allocator, 1 << 52); | 1137 | var a = try Managed.initSet(testing.allocator, 1 << 52); |
| 1138 | defer a.deinit(); | 1138 | defer a.deinit(); |
| ... | @@ -1149,7 +1149,7 @@ test "big.int div single-single no rem" { | ... | @@ -1149,7 +1149,7 @@ test "big.int div single-single no rem" { |
| 1149 | try testing.expect((try r.to(u32)) == 0); | 1149 | try testing.expect((try r.to(u32)) == 0); |
| 1150 | } | 1150 | } |
| 1151 | 1151 | ||
| 1152 | test "big.int div single-single with rem" { | 1152 | test "div single-single with rem" { |
| 1153 | var a = try Managed.initSet(testing.allocator, (1 << 52) | (1 << 33)); | 1153 | var a = try Managed.initSet(testing.allocator, (1 << 52) | (1 << 33)); |
| 1154 | defer a.deinit(); | 1154 | defer a.deinit(); |
| 1155 | var b = try Managed.initSet(testing.allocator, (1 << 35)); | 1155 | var b = try Managed.initSet(testing.allocator, (1 << 35)); |
| ... | @@ -1165,7 +1165,7 @@ test "big.int div single-single with rem" { | ... | @@ -1165,7 +1165,7 @@ test "big.int div single-single with rem" { |
| 1165 | try testing.expect((try r.to(u64)) == 8589934592); | 1165 | try testing.expect((try r.to(u64)) == 8589934592); |
| 1166 | } | 1166 | } |
| 1167 | 1167 | ||
| 1168 | test "big.int div multi-single no rem" { | 1168 | test "div multi-single no rem" { |
| 1169 | var op1: u128 = 0xffffeeeeddddcccc; | 1169 | var op1: u128 = 0xffffeeeeddddcccc; |
| 1170 | var op2: u128 = 34; | 1170 | var op2: u128 = 34; |
| 1171 | _ = .{ &op1, &op2 }; | 1171 | _ = .{ &op1, &op2 }; |
| ... | @@ -1185,7 +1185,7 @@ test "big.int div multi-single no rem" { | ... | @@ -1185,7 +1185,7 @@ test "big.int div multi-single no rem" { |
| 1185 | try testing.expect((try r.to(u64)) == 0); | 1185 | try testing.expect((try r.to(u64)) == 0); |
| 1186 | } | 1186 | } |
| 1187 | 1187 | ||
| 1188 | test "big.int div multi-single with rem" { | 1188 | test "div multi-single with rem" { |
| 1189 | var op1: u128 = 0xffffeeeeddddcccf; | 1189 | var op1: u128 = 0xffffeeeeddddcccf; |
| 1190 | var op2: u128 = 34; | 1190 | var op2: u128 = 34; |
| 1191 | _ = .{ &op1, &op2 }; | 1191 | _ = .{ &op1, &op2 }; |
| ... | @@ -1205,7 +1205,7 @@ test "big.int div multi-single with rem" { | ... | @@ -1205,7 +1205,7 @@ test "big.int div multi-single with rem" { |
| 1205 | try testing.expect((try r.to(u64)) == 3); | 1205 | try testing.expect((try r.to(u64)) == 3); |
| 1206 | } | 1206 | } |
| 1207 | 1207 | ||
| 1208 | test "big.int div multi>2-single" { | 1208 | test "div multi>2-single" { |
| 1209 | var op1: u128 = 0xfefefefefefefefefefefefefefefefe; | 1209 | var op1: u128 = 0xfefefefefefefefefefefefefefefefe; |
| 1210 | var op2: u128 = 0xefab8; | 1210 | var op2: u128 = 0xefab8; |
| 1211 | _ = .{ &op1, &op2 }; | 1211 | _ = .{ &op1, &op2 }; |
| ... | @@ -1225,7 +1225,7 @@ test "big.int div multi>2-single" { | ... | @@ -1225,7 +1225,7 @@ test "big.int div multi>2-single" { |
| 1225 | try testing.expect((try r.to(u32)) == 0x3e4e); | 1225 | try testing.expect((try r.to(u32)) == 0x3e4e); |
| 1226 | } | 1226 | } |
| 1227 | 1227 | ||
| 1228 | test "big.int div single-single q < r" { | 1228 | test "div single-single q < r" { |
| 1229 | var a = try Managed.initSet(testing.allocator, 0x0078f432); | 1229 | var a = try Managed.initSet(testing.allocator, 0x0078f432); |
| 1230 | defer a.deinit(); | 1230 | defer a.deinit(); |
| 1231 | var b = try Managed.initSet(testing.allocator, 0x01000000); | 1231 | var b = try Managed.initSet(testing.allocator, 0x01000000); |
| ... | @@ -1241,7 +1241,7 @@ test "big.int div single-single q < r" { | ... | @@ -1241,7 +1241,7 @@ test "big.int div single-single q < r" { |
| 1241 | try testing.expect((try r.to(u64)) == 0x0078f432); | 1241 | try testing.expect((try r.to(u64)) == 0x0078f432); |
| 1242 | } | 1242 | } |
| 1243 | 1243 | ||
| 1244 | test "big.int div single-single q == r" { | 1244 | test "div single-single q == r" { |
| 1245 | var a = try Managed.initSet(testing.allocator, 10); | 1245 | var a = try Managed.initSet(testing.allocator, 10); |
| 1246 | defer a.deinit(); | 1246 | defer a.deinit(); |
| 1247 | var b = try Managed.initSet(testing.allocator, 10); | 1247 | var b = try Managed.initSet(testing.allocator, 10); |
| ... | @@ -1257,7 +1257,7 @@ test "big.int div single-single q == r" { | ... | @@ -1257,7 +1257,7 @@ test "big.int div single-single q == r" { |
| 1257 | try testing.expect((try r.to(u64)) == 0); | 1257 | try testing.expect((try r.to(u64)) == 0); |
| 1258 | } | 1258 | } |
| 1259 | 1259 | ||
| 1260 | test "big.int div q=0 alias" { | 1260 | test "div q=0 alias" { |
| 1261 | var a = try Managed.initSet(testing.allocator, 3); | 1261 | var a = try Managed.initSet(testing.allocator, 3); |
| 1262 | defer a.deinit(); | 1262 | defer a.deinit(); |
| 1263 | var b = try Managed.initSet(testing.allocator, 10); | 1263 | var b = try Managed.initSet(testing.allocator, 10); |
| ... | @@ -1269,7 +1269,7 @@ test "big.int div q=0 alias" { | ... | @@ -1269,7 +1269,7 @@ test "big.int div q=0 alias" { |
| 1269 | try testing.expect((try b.to(u64)) == 3); | 1269 | try testing.expect((try b.to(u64)) == 3); |
| 1270 | } | 1270 | } |
| 1271 | 1271 | ||
| 1272 | test "big.int div multi-multi q < r" { | 1272 | test "div multi-multi q < r" { |
| 1273 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 1273 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 1274 | 1274 | ||
| 1275 | const op1 = 0x1ffffffff0078f432; | 1275 | const op1 = 0x1ffffffff0078f432; |
| ... | @@ -1289,7 +1289,7 @@ test "big.int div multi-multi q < r" { | ... | @@ -1289,7 +1289,7 @@ test "big.int div multi-multi q < r" { |
| 1289 | try testing.expect((try r.to(u128)) == op1); | 1289 | try testing.expect((try r.to(u128)) == op1); |
| 1290 | } | 1290 | } |
| 1291 | 1291 | ||
| 1292 | test "big.int div trunc single-single +/+" { | 1292 | test "div trunc single-single +/+" { |
| 1293 | const u: i32 = 5; | 1293 | const u: i32 = 5; |
| 1294 | const v: i32 = 3; | 1294 | const v: i32 = 3; |
| 1295 | 1295 | ||
| ... | @@ -1313,7 +1313,7 @@ test "big.int div trunc single-single +/+" { | ... | @@ -1313,7 +1313,7 @@ test "big.int div trunc single-single +/+" { |
| 1313 | try testing.expect((try r.to(i32)) == er); | 1313 | try testing.expect((try r.to(i32)) == er); |
| 1314 | } | 1314 | } |
| 1315 | 1315 | ||
| 1316 | test "big.int div trunc single-single -/+" { | 1316 | test "div trunc single-single -/+" { |
| 1317 | const u: i32 = -5; | 1317 | const u: i32 = -5; |
| 1318 | const v: i32 = 3; | 1318 | const v: i32 = 3; |
| 1319 | 1319 | ||
| ... | @@ -1337,7 +1337,7 @@ test "big.int div trunc single-single -/+" { | ... | @@ -1337,7 +1337,7 @@ test "big.int div trunc single-single -/+" { |
| 1337 | try testing.expect((try r.to(i32)) == er); | 1337 | try testing.expect((try r.to(i32)) == er); |
| 1338 | } | 1338 | } |
| 1339 | 1339 | ||
| 1340 | test "big.int div trunc single-single +/-" { | 1340 | test "div trunc single-single +/-" { |
| 1341 | const u: i32 = 5; | 1341 | const u: i32 = 5; |
| 1342 | const v: i32 = -3; | 1342 | const v: i32 = -3; |
| 1343 | 1343 | ||
| ... | @@ -1361,7 +1361,7 @@ test "big.int div trunc single-single +/-" { | ... | @@ -1361,7 +1361,7 @@ test "big.int div trunc single-single +/-" { |
| 1361 | try testing.expect((try r.to(i32)) == er); | 1361 | try testing.expect((try r.to(i32)) == er); |
| 1362 | } | 1362 | } |
| 1363 | 1363 | ||
| 1364 | test "big.int div trunc single-single -/-" { | 1364 | test "div trunc single-single -/-" { |
| 1365 | const u: i32 = -5; | 1365 | const u: i32 = -5; |
| 1366 | const v: i32 = -3; | 1366 | const v: i32 = -3; |
| 1367 | 1367 | ||
| ... | @@ -1385,7 +1385,7 @@ test "big.int div trunc single-single -/-" { | ... | @@ -1385,7 +1385,7 @@ test "big.int div trunc single-single -/-" { |
| 1385 | try testing.expect((try r.to(i32)) == er); | 1385 | try testing.expect((try r.to(i32)) == er); |
| 1386 | } | 1386 | } |
| 1387 | 1387 | ||
| 1388 | test "big.int divTrunc #15535" { | 1388 | test "divTrunc #15535" { |
| 1389 | var one = try Managed.initSet(testing.allocator, 1); | 1389 | var one = try Managed.initSet(testing.allocator, 1); |
| 1390 | defer one.deinit(); | 1390 | defer one.deinit(); |
| 1391 | var x = try Managed.initSet(testing.allocator, std.math.pow(u128, 2, 64)); | 1391 | var x = try Managed.initSet(testing.allocator, std.math.pow(u128, 2, 64)); |
| ... | @@ -1398,7 +1398,7 @@ test "big.int divTrunc #15535" { | ... | @@ -1398,7 +1398,7 @@ test "big.int divTrunc #15535" { |
| 1398 | try testing.expect(r.order(one) == std.math.Order.lt); | 1398 | try testing.expect(r.order(one) == std.math.Order.lt); |
| 1399 | } | 1399 | } |
| 1400 | 1400 | ||
| 1401 | test "big.int divFloor #10932" { | 1401 | test "divFloor #10932" { |
| 1402 | var a = try Managed.init(testing.allocator); | 1402 | var a = try Managed.init(testing.allocator); |
| 1403 | defer a.deinit(); | 1403 | defer a.deinit(); |
| 1404 | 1404 | ||
| ... | @@ -1422,7 +1422,7 @@ test "big.int divFloor #10932" { | ... | @@ -1422,7 +1422,7 @@ test "big.int divFloor #10932" { |
| 1422 | try testing.expect((try mod.to(i32)) == 0); | 1422 | try testing.expect((try mod.to(i32)) == 0); |
| 1423 | } | 1423 | } |
| 1424 | 1424 | ||
| 1425 | test "big.int divFloor #11166" { | 1425 | test "divFloor #11166" { |
| 1426 | var a = try Managed.init(testing.allocator); | 1426 | var a = try Managed.init(testing.allocator); |
| 1427 | defer a.deinit(); | 1427 | defer a.deinit(); |
| 1428 | 1428 | ||
| ... | @@ -1449,7 +1449,7 @@ test "big.int divFloor #11166" { | ... | @@ -1449,7 +1449,7 @@ test "big.int divFloor #11166" { |
| 1449 | try testing.expect(std.mem.eql(u8, mods, "870000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")); | 1449 | try testing.expect(std.mem.eql(u8, mods, "870000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")); |
| 1450 | } | 1450 | } |
| 1451 | 1451 | ||
| 1452 | test "big.int gcd #10932" { | 1452 | test "gcd #10932" { |
| 1453 | var a = try Managed.init(testing.allocator); | 1453 | var a = try Managed.init(testing.allocator); |
| 1454 | defer a.deinit(); | 1454 | defer a.deinit(); |
| 1455 | 1455 | ||
| ... | @@ -1469,7 +1469,7 @@ test "big.int gcd #10932" { | ... | @@ -1469,7 +1469,7 @@ test "big.int gcd #10932" { |
| 1469 | try testing.expect(std.mem.eql(u8, ress, "1a974a5c9734476ff5a3604bcc678a756beacfc21b4427d1f2c1f56f5d4e411a162c56136e20000000000000000000000000000000")); | 1469 | try testing.expect(std.mem.eql(u8, ress, "1a974a5c9734476ff5a3604bcc678a756beacfc21b4427d1f2c1f56f5d4e411a162c56136e20000000000000000000000000000000")); |
| 1470 | } | 1470 | } |
| 1471 | 1471 | ||
| 1472 | test "big.int bitAnd #10932" { | 1472 | test "bitAnd #10932" { |
| 1473 | var a = try Managed.init(testing.allocator); | 1473 | var a = try Managed.init(testing.allocator); |
| 1474 | defer a.deinit(); | 1474 | defer a.deinit(); |
| 1475 | 1475 | ||
| ... | @@ -1487,7 +1487,7 @@ test "big.int bitAnd #10932" { | ... | @@ -1487,7 +1487,7 @@ test "big.int bitAnd #10932" { |
| 1487 | try testing.expect((try res.to(i32)) == 0); | 1487 | try testing.expect((try res.to(i32)) == 0); |
| 1488 | } | 1488 | } |
| 1489 | 1489 | ||
| 1490 | test "big.int div floor single-single +/+" { | 1490 | test "div floor single-single +/+" { |
| 1491 | const u: i32 = 5; | 1491 | const u: i32 = 5; |
| 1492 | const v: i32 = 3; | 1492 | const v: i32 = 3; |
| 1493 | 1493 | ||
| ... | @@ -1511,7 +1511,7 @@ test "big.int div floor single-single +/+" { | ... | @@ -1511,7 +1511,7 @@ test "big.int div floor single-single +/+" { |
| 1511 | try testing.expect((try r.to(i32)) == er); | 1511 | try testing.expect((try r.to(i32)) == er); |
| 1512 | } | 1512 | } |
| 1513 | 1513 | ||
| 1514 | test "big.int div floor single-single -/+" { | 1514 | test "div floor single-single -/+" { |
| 1515 | const u: i32 = -5; | 1515 | const u: i32 = -5; |
| 1516 | const v: i32 = 3; | 1516 | const v: i32 = 3; |
| 1517 | 1517 | ||
| ... | @@ -1535,7 +1535,7 @@ test "big.int div floor single-single -/+" { | ... | @@ -1535,7 +1535,7 @@ test "big.int div floor single-single -/+" { |
| 1535 | try testing.expect((try r.to(i32)) == er); | 1535 | try testing.expect((try r.to(i32)) == er); |
| 1536 | } | 1536 | } |
| 1537 | 1537 | ||
| 1538 | test "big.int div floor single-single +/-" { | 1538 | test "div floor single-single +/-" { |
| 1539 | const u: i32 = 5; | 1539 | const u: i32 = 5; |
| 1540 | const v: i32 = -3; | 1540 | const v: i32 = -3; |
| 1541 | 1541 | ||
| ... | @@ -1559,7 +1559,7 @@ test "big.int div floor single-single +/-" { | ... | @@ -1559,7 +1559,7 @@ test "big.int div floor single-single +/-" { |
| 1559 | try testing.expect((try r.to(i32)) == er); | 1559 | try testing.expect((try r.to(i32)) == er); |
| 1560 | } | 1560 | } |
| 1561 | 1561 | ||
| 1562 | test "big.int div floor single-single -/-" { | 1562 | test "div floor single-single -/-" { |
| 1563 | const u: i32 = -5; | 1563 | const u: i32 = -5; |
| 1564 | const v: i32 = -3; | 1564 | const v: i32 = -3; |
| 1565 | 1565 | ||
| ... | @@ -1583,7 +1583,7 @@ test "big.int div floor single-single -/-" { | ... | @@ -1583,7 +1583,7 @@ test "big.int div floor single-single -/-" { |
| 1583 | try testing.expect((try r.to(i32)) == er); | 1583 | try testing.expect((try r.to(i32)) == er); |
| 1584 | } | 1584 | } |
| 1585 | 1585 | ||
| 1586 | test "big.int div floor no remainder negative quotient" { | 1586 | test "div floor no remainder negative quotient" { |
| 1587 | const u: i32 = -0x80000000; | 1587 | const u: i32 = -0x80000000; |
| 1588 | const v: i32 = 1; | 1588 | const v: i32 = 1; |
| 1589 | 1589 | ||
| ... | @@ -1602,7 +1602,7 @@ test "big.int div floor no remainder negative quotient" { | ... | @@ -1602,7 +1602,7 @@ test "big.int div floor no remainder negative quotient" { |
| 1602 | try testing.expect((try r.to(i32)) == 0); | 1602 | try testing.expect((try r.to(i32)) == 0); |
| 1603 | } | 1603 | } |
| 1604 | 1604 | ||
| 1605 | test "big.int div floor negative close to zero" { | 1605 | test "div floor negative close to zero" { |
| 1606 | const u: i32 = -2; | 1606 | const u: i32 = -2; |
| 1607 | const v: i32 = 12; | 1607 | const v: i32 = 12; |
| 1608 | 1608 | ||
| ... | @@ -1621,7 +1621,7 @@ test "big.int div floor negative close to zero" { | ... | @@ -1621,7 +1621,7 @@ test "big.int div floor negative close to zero" { |
| 1621 | try testing.expect((try r.to(i32)) == 10); | 1621 | try testing.expect((try r.to(i32)) == 10); |
| 1622 | } | 1622 | } |
| 1623 | 1623 | ||
| 1624 | test "big.int div floor positive close to zero" { | 1624 | test "div floor positive close to zero" { |
| 1625 | const u: i32 = 10; | 1625 | const u: i32 = 10; |
| 1626 | const v: i32 = 12; | 1626 | const v: i32 = 12; |
| 1627 | 1627 | ||
| ... | @@ -1640,7 +1640,7 @@ test "big.int div floor positive close to zero" { | ... | @@ -1640,7 +1640,7 @@ test "big.int div floor positive close to zero" { |
| 1640 | try testing.expect((try r.to(i32)) == 10); | 1640 | try testing.expect((try r.to(i32)) == 10); |
| 1641 | } | 1641 | } |
| 1642 | 1642 | ||
| 1643 | test "big.int div multi-multi with rem" { | 1643 | test "div multi-multi with rem" { |
| 1644 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 1644 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 1645 | 1645 | ||
| 1646 | var a = try Managed.initSet(testing.allocator, 0x8888999911110000ffffeeeeddddccccbbbbaaaa9999); | 1646 | var a = try Managed.initSet(testing.allocator, 0x8888999911110000ffffeeeeddddccccbbbbaaaa9999); |
| ... | @@ -1658,7 +1658,7 @@ test "big.int div multi-multi with rem" { | ... | @@ -1658,7 +1658,7 @@ test "big.int div multi-multi with rem" { |
| 1658 | try testing.expect((try r.to(u128)) == 0x28de0acacd806823638); | 1658 | try testing.expect((try r.to(u128)) == 0x28de0acacd806823638); |
| 1659 | } | 1659 | } |
| 1660 | 1660 | ||
| 1661 | test "big.int div multi-multi no rem" { | 1661 | test "div multi-multi no rem" { |
| 1662 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 1662 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 1663 | 1663 | ||
| 1664 | var a = try Managed.initSet(testing.allocator, 0x8888999911110000ffffeeeedb4fec200ee3a4286361); | 1664 | var a = try Managed.initSet(testing.allocator, 0x8888999911110000ffffeeeedb4fec200ee3a4286361); |
| ... | @@ -1676,7 +1676,7 @@ test "big.int div multi-multi no rem" { | ... | @@ -1676,7 +1676,7 @@ test "big.int div multi-multi no rem" { |
| 1676 | try testing.expect((try r.to(u128)) == 0); | 1676 | try testing.expect((try r.to(u128)) == 0); |
| 1677 | } | 1677 | } |
| 1678 | 1678 | ||
| 1679 | test "big.int div multi-multi (2 branch)" { | 1679 | test "div multi-multi (2 branch)" { |
| 1680 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 1680 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 1681 | 1681 | ||
| 1682 | var a = try Managed.initSet(testing.allocator, 0x866666665555555588888887777777761111111111111111); | 1682 | var a = try Managed.initSet(testing.allocator, 0x866666665555555588888887777777761111111111111111); |
| ... | @@ -1694,7 +1694,7 @@ test "big.int div multi-multi (2 branch)" { | ... | @@ -1694,7 +1694,7 @@ test "big.int div multi-multi (2 branch)" { |
| 1694 | try testing.expect((try r.to(u128)) == 0x44444443444444431111111111111111); | 1694 | try testing.expect((try r.to(u128)) == 0x44444443444444431111111111111111); |
| 1695 | } | 1695 | } |
| 1696 | 1696 | ||
| 1697 | test "big.int div multi-multi (3.1/3.3 branch)" { | 1697 | test "div multi-multi (3.1/3.3 branch)" { |
| 1698 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 1698 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 1699 | 1699 | ||
| 1700 | var a = try Managed.initSet(testing.allocator, 0x11111111111111111111111111111111111111111111111111111111111111); | 1700 | var a = try Managed.initSet(testing.allocator, 0x11111111111111111111111111111111111111111111111111111111111111); |
| ... | @@ -1712,7 +1712,7 @@ test "big.int div multi-multi (3.1/3.3 branch)" { | ... | @@ -1712,7 +1712,7 @@ test "big.int div multi-multi (3.1/3.3 branch)" { |
| 1712 | try testing.expect((try r.to(u256)) == 0x1111111111111111111110b12222222222222222282); | 1712 | try testing.expect((try r.to(u256)) == 0x1111111111111111111110b12222222222222222282); |
| 1713 | } | 1713 | } |
| 1714 | 1714 | ||
| 1715 | test "big.int div multi-single zero-limb trailing" { | 1715 | test "div multi-single zero-limb trailing" { |
| 1716 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 1716 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 1717 | 1717 | ||
| 1718 | var a = try Managed.initSet(testing.allocator, 0x60000000000000000000000000000000000000000000000000000000000000000); | 1718 | var a = try Managed.initSet(testing.allocator, 0x60000000000000000000000000000000000000000000000000000000000000000); |
| ... | @@ -1732,7 +1732,7 @@ test "big.int div multi-single zero-limb trailing" { | ... | @@ -1732,7 +1732,7 @@ test "big.int div multi-single zero-limb trailing" { |
| 1732 | try testing.expect(r.eqlZero()); | 1732 | try testing.expect(r.eqlZero()); |
| 1733 | } | 1733 | } |
| 1734 | 1734 | ||
| 1735 | test "big.int div multi-multi zero-limb trailing (with rem)" { | 1735 | test "div multi-multi zero-limb trailing (with rem)" { |
| 1736 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 1736 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 1737 | 1737 | ||
| 1738 | var a = try Managed.initSet(testing.allocator, 0x86666666555555558888888777777776111111111111111100000000000000000000000000000000); | 1738 | var a = try Managed.initSet(testing.allocator, 0x86666666555555558888888777777776111111111111111100000000000000000000000000000000); |
| ... | @@ -1753,7 +1753,7 @@ test "big.int div multi-multi zero-limb trailing (with rem)" { | ... | @@ -1753,7 +1753,7 @@ test "big.int div multi-multi zero-limb trailing (with rem)" { |
| 1753 | try testing.expect(std.mem.eql(u8, rs, "4444444344444443111111111111111100000000000000000000000000000000")); | 1753 | try testing.expect(std.mem.eql(u8, rs, "4444444344444443111111111111111100000000000000000000000000000000")); |
| 1754 | } | 1754 | } |
| 1755 | 1755 | ||
| 1756 | test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-limb count > divisor zero-limb count" { | 1756 | test "div multi-multi zero-limb trailing (with rem) and dividend zero-limb count > divisor zero-limb count" { |
| 1757 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 1757 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 1758 | 1758 | ||
| 1759 | var a = try Managed.initSet(testing.allocator, 0x8666666655555555888888877777777611111111111111110000000000000000); | 1759 | var a = try Managed.initSet(testing.allocator, 0x8666666655555555888888877777777611111111111111110000000000000000); |
| ... | @@ -1774,7 +1774,7 @@ test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-li | ... | @@ -1774,7 +1774,7 @@ test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-li |
| 1774 | try testing.expect(std.mem.eql(u8, rs, "444444434444444311111111111111110000000000000000")); | 1774 | try testing.expect(std.mem.eql(u8, rs, "444444434444444311111111111111110000000000000000")); |
| 1775 | } | 1775 | } |
| 1776 | 1776 | ||
| 1777 | test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-limb count < divisor zero-limb count" { | 1777 | test "div multi-multi zero-limb trailing (with rem) and dividend zero-limb count < divisor zero-limb count" { |
| 1778 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 1778 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 1779 | 1779 | ||
| 1780 | var a = try Managed.initSet(testing.allocator, 0x86666666555555558888888777777776111111111111111100000000000000000000000000000000); | 1780 | var a = try Managed.initSet(testing.allocator, 0x86666666555555558888888777777776111111111111111100000000000000000000000000000000); |
| ... | @@ -1797,7 +1797,7 @@ test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-li | ... | @@ -1797,7 +1797,7 @@ test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-li |
| 1797 | try testing.expect(std.mem.eql(u8, rs, "4e11f2baa5896a321d463b543d0104e30000000000000000")); | 1797 | try testing.expect(std.mem.eql(u8, rs, "4e11f2baa5896a321d463b543d0104e30000000000000000")); |
| 1798 | } | 1798 | } |
| 1799 | 1799 | ||
| 1800 | test "big.int div multi-multi fuzz case #1" { | 1800 | test "div multi-multi fuzz case #1" { |
| 1801 | var a = try Managed.init(testing.allocator); | 1801 | var a = try Managed.init(testing.allocator); |
| 1802 | defer a.deinit(); | 1802 | defer a.deinit(); |
| 1803 | var b = try Managed.init(testing.allocator); | 1803 | var b = try Managed.init(testing.allocator); |
| ... | @@ -1821,7 +1821,7 @@ test "big.int div multi-multi fuzz case #1" { | ... | @@ -1821,7 +1821,7 @@ test "big.int div multi-multi fuzz case #1" { |
| 1821 | try testing.expect(std.mem.eql(u8, rs, "310d1d4c414426b4836c2635bad1df3a424e50cbdd167ffccb4dfff57d36b4aae0d6ca0910698220171a0f3373c1060a046c2812f0027e321f72979daa5e7973214170d49e885de0c0ecc167837d44502430674a82522e5df6a0759548052420b91ec1")); | 1821 | try testing.expect(std.mem.eql(u8, rs, "310d1d4c414426b4836c2635bad1df3a424e50cbdd167ffccb4dfff57d36b4aae0d6ca0910698220171a0f3373c1060a046c2812f0027e321f72979daa5e7973214170d49e885de0c0ecc167837d44502430674a82522e5df6a0759548052420b91ec1")); |
| 1822 | } | 1822 | } |
| 1823 | 1823 | ||
| 1824 | test "big.int div multi-multi fuzz case #2" { | 1824 | test "div multi-multi fuzz case #2" { |
| 1825 | var a = try Managed.init(testing.allocator); | 1825 | var a = try Managed.init(testing.allocator); |
| 1826 | defer a.deinit(); | 1826 | defer a.deinit(); |
| 1827 | var b = try Managed.init(testing.allocator); | 1827 | var b = try Managed.init(testing.allocator); |
| ... | @@ -1845,7 +1845,7 @@ test "big.int div multi-multi fuzz case #2" { | ... | @@ -1845,7 +1845,7 @@ test "big.int div multi-multi fuzz case #2" { |
| 1845 | try testing.expect(std.mem.eql(u8, rs, "a900000000000000000000000000000000000000000000000000")); | 1845 | try testing.expect(std.mem.eql(u8, rs, "a900000000000000000000000000000000000000000000000000")); |
| 1846 | } | 1846 | } |
| 1847 | 1847 | ||
| 1848 | test "big.int truncate single unsigned" { | 1848 | test "truncate single unsigned" { |
| 1849 | var a = try Managed.initSet(testing.allocator, maxInt(u47)); | 1849 | var a = try Managed.initSet(testing.allocator, maxInt(u47)); |
| 1850 | defer a.deinit(); | 1850 | defer a.deinit(); |
| 1851 | 1851 | ||
| ... | @@ -1854,7 +1854,7 @@ test "big.int truncate single unsigned" { | ... | @@ -1854,7 +1854,7 @@ test "big.int truncate single unsigned" { |
| 1854 | try testing.expect((try a.to(u17)) == maxInt(u17)); | 1854 | try testing.expect((try a.to(u17)) == maxInt(u17)); |
| 1855 | } | 1855 | } |
| 1856 | 1856 | ||
| 1857 | test "big.int truncate single signed" { | 1857 | test "truncate single signed" { |
| 1858 | var a = try Managed.initSet(testing.allocator, 0x1_0000); | 1858 | var a = try Managed.initSet(testing.allocator, 0x1_0000); |
| 1859 | defer a.deinit(); | 1859 | defer a.deinit(); |
| 1860 | 1860 | ||
| ... | @@ -1863,7 +1863,7 @@ test "big.int truncate single signed" { | ... | @@ -1863,7 +1863,7 @@ test "big.int truncate single signed" { |
| 1863 | try testing.expect((try a.to(i17)) == minInt(i17)); | 1863 | try testing.expect((try a.to(i17)) == minInt(i17)); |
| 1864 | } | 1864 | } |
| 1865 | 1865 | ||
| 1866 | test "big.int truncate multi to single unsigned" { | 1866 | test "truncate multi to single unsigned" { |
| 1867 | var a = try Managed.initSet(testing.allocator, (maxInt(Limb) + 1) | 0x1234_5678_9ABC_DEF0); | 1867 | var a = try Managed.initSet(testing.allocator, (maxInt(Limb) + 1) | 0x1234_5678_9ABC_DEF0); |
| 1868 | defer a.deinit(); | 1868 | defer a.deinit(); |
| 1869 | 1869 | ||
| ... | @@ -1872,7 +1872,7 @@ test "big.int truncate multi to single unsigned" { | ... | @@ -1872,7 +1872,7 @@ test "big.int truncate multi to single unsigned" { |
| 1872 | try testing.expect((try a.to(u27)) == 0x2BC_DEF0); | 1872 | try testing.expect((try a.to(u27)) == 0x2BC_DEF0); |
| 1873 | } | 1873 | } |
| 1874 | 1874 | ||
| 1875 | test "big.int truncate multi to single signed" { | 1875 | test "truncate multi to single signed" { |
| 1876 | var a = try Managed.initSet(testing.allocator, maxInt(Limb) << 10); | 1876 | var a = try Managed.initSet(testing.allocator, maxInt(Limb) << 10); |
| 1877 | defer a.deinit(); | 1877 | defer a.deinit(); |
| 1878 | 1878 | ||
| ... | @@ -1881,7 +1881,7 @@ test "big.int truncate multi to single signed" { | ... | @@ -1881,7 +1881,7 @@ test "big.int truncate multi to single signed" { |
| 1881 | try testing.expect((try a.to(i11)) == minInt(i11)); | 1881 | try testing.expect((try a.to(i11)) == minInt(i11)); |
| 1882 | } | 1882 | } |
| 1883 | 1883 | ||
| 1884 | test "big.int truncate multi to multi unsigned" { | 1884 | test "truncate multi to multi unsigned" { |
| 1885 | const bits = @typeInfo(SignedDoubleLimb).Int.bits; | 1885 | const bits = @typeInfo(SignedDoubleLimb).Int.bits; |
| 1886 | const Int = std.meta.Int(.unsigned, bits - 1); | 1886 | const Int = std.meta.Int(.unsigned, bits - 1); |
| 1887 | 1887 | ||
| ... | @@ -1893,7 +1893,7 @@ test "big.int truncate multi to multi unsigned" { | ... | @@ -1893,7 +1893,7 @@ test "big.int truncate multi to multi unsigned" { |
| 1893 | try testing.expect((try a.to(Int)) == maxInt(Int)); | 1893 | try testing.expect((try a.to(Int)) == maxInt(Int)); |
| 1894 | } | 1894 | } |
| 1895 | 1895 | ||
| 1896 | test "big.int truncate multi to multi signed" { | 1896 | test "truncate multi to multi signed" { |
| 1897 | var a = try Managed.initSet(testing.allocator, 3 << @bitSizeOf(Limb)); | 1897 | var a = try Managed.initSet(testing.allocator, 3 << @bitSizeOf(Limb)); |
| 1898 | defer a.deinit(); | 1898 | defer a.deinit(); |
| 1899 | 1899 | ||
| ... | @@ -1902,7 +1902,7 @@ test "big.int truncate multi to multi signed" { | ... | @@ -1902,7 +1902,7 @@ test "big.int truncate multi to multi signed" { |
| 1902 | try testing.expect((try a.to(std.meta.Int(.signed, @bitSizeOf(Limb) + 1))) == -1 << @bitSizeOf(Limb)); | 1902 | try testing.expect((try a.to(std.meta.Int(.signed, @bitSizeOf(Limb) + 1))) == -1 << @bitSizeOf(Limb)); |
| 1903 | } | 1903 | } |
| 1904 | 1904 | ||
| 1905 | test "big.int truncate negative multi to single" { | 1905 | test "truncate negative multi to single" { |
| 1906 | var a = try Managed.initSet(testing.allocator, -@as(SignedDoubleLimb, maxInt(Limb) + 1)); | 1906 | var a = try Managed.initSet(testing.allocator, -@as(SignedDoubleLimb, maxInt(Limb) + 1)); |
| 1907 | defer a.deinit(); | 1907 | defer a.deinit(); |
| 1908 | 1908 | ||
| ... | @@ -1911,7 +1911,7 @@ test "big.int truncate negative multi to single" { | ... | @@ -1911,7 +1911,7 @@ test "big.int truncate negative multi to single" { |
| 1911 | try testing.expect((try a.to(i17)) == 0); | 1911 | try testing.expect((try a.to(i17)) == 0); |
| 1912 | } | 1912 | } |
| 1913 | 1913 | ||
| 1914 | test "big.int truncate multi unsigned many" { | 1914 | test "truncate multi unsigned many" { |
| 1915 | var a = try Managed.initSet(testing.allocator, 1); | 1915 | var a = try Managed.initSet(testing.allocator, 1); |
| 1916 | defer a.deinit(); | 1916 | defer a.deinit(); |
| 1917 | try a.shiftLeft(&a, 1023); | 1917 | try a.shiftLeft(&a, 1023); |
| ... | @@ -1923,7 +1923,7 @@ test "big.int truncate multi unsigned many" { | ... | @@ -1923,7 +1923,7 @@ test "big.int truncate multi unsigned many" { |
| 1923 | try testing.expect((try b.to(i1)) == 0); | 1923 | try testing.expect((try b.to(i1)) == 0); |
| 1924 | } | 1924 | } |
| 1925 | 1925 | ||
| 1926 | test "big.int saturate single signed positive" { | 1926 | test "saturate single signed positive" { |
| 1927 | var a = try Managed.initSet(testing.allocator, 0xBBBB_BBBB); | 1927 | var a = try Managed.initSet(testing.allocator, 0xBBBB_BBBB); |
| 1928 | defer a.deinit(); | 1928 | defer a.deinit(); |
| 1929 | 1929 | ||
| ... | @@ -1932,7 +1932,7 @@ test "big.int saturate single signed positive" { | ... | @@ -1932,7 +1932,7 @@ test "big.int saturate single signed positive" { |
| 1932 | try testing.expect((try a.to(i17)) == maxInt(i17)); | 1932 | try testing.expect((try a.to(i17)) == maxInt(i17)); |
| 1933 | } | 1933 | } |
| 1934 | 1934 | ||
| 1935 | test "big.int saturate single signed negative" { | 1935 | test "saturate single signed negative" { |
| 1936 | var a = try Managed.initSet(testing.allocator, -1_234_567); | 1936 | var a = try Managed.initSet(testing.allocator, -1_234_567); |
| 1937 | defer a.deinit(); | 1937 | defer a.deinit(); |
| 1938 | 1938 | ||
| ... | @@ -1941,7 +1941,7 @@ test "big.int saturate single signed negative" { | ... | @@ -1941,7 +1941,7 @@ test "big.int saturate single signed negative" { |
| 1941 | try testing.expect((try a.to(i17)) == minInt(i17)); | 1941 | try testing.expect((try a.to(i17)) == minInt(i17)); |
| 1942 | } | 1942 | } |
| 1943 | 1943 | ||
| 1944 | test "big.int saturate single signed" { | 1944 | test "saturate single signed" { |
| 1945 | var a = try Managed.initSet(testing.allocator, maxInt(i17) - 1); | 1945 | var a = try Managed.initSet(testing.allocator, maxInt(i17) - 1); |
| 1946 | defer a.deinit(); | 1946 | defer a.deinit(); |
| 1947 | 1947 | ||
| ... | @@ -1950,7 +1950,7 @@ test "big.int saturate single signed" { | ... | @@ -1950,7 +1950,7 @@ test "big.int saturate single signed" { |
| 1950 | try testing.expect((try a.to(i17)) == maxInt(i17) - 1); | 1950 | try testing.expect((try a.to(i17)) == maxInt(i17) - 1); |
| 1951 | } | 1951 | } |
| 1952 | 1952 | ||
| 1953 | test "big.int saturate multi signed" { | 1953 | test "saturate multi signed" { |
| 1954 | var a = try Managed.initSet(testing.allocator, maxInt(Limb) << @bitSizeOf(SignedDoubleLimb)); | 1954 | var a = try Managed.initSet(testing.allocator, maxInt(Limb) << @bitSizeOf(SignedDoubleLimb)); |
| 1955 | defer a.deinit(); | 1955 | defer a.deinit(); |
| 1956 | 1956 | ||
| ... | @@ -1959,7 +1959,7 @@ test "big.int saturate multi signed" { | ... | @@ -1959,7 +1959,7 @@ test "big.int saturate multi signed" { |
| 1959 | try testing.expect((try a.to(SignedDoubleLimb)) == maxInt(SignedDoubleLimb)); | 1959 | try testing.expect((try a.to(SignedDoubleLimb)) == maxInt(SignedDoubleLimb)); |
| 1960 | } | 1960 | } |
| 1961 | 1961 | ||
| 1962 | test "big.int saturate single unsigned" { | 1962 | test "saturate single unsigned" { |
| 1963 | var a = try Managed.initSet(testing.allocator, 0xFEFE_FEFE); | 1963 | var a = try Managed.initSet(testing.allocator, 0xFEFE_FEFE); |
| 1964 | defer a.deinit(); | 1964 | defer a.deinit(); |
| 1965 | 1965 | ||
| ... | @@ -1968,7 +1968,7 @@ test "big.int saturate single unsigned" { | ... | @@ -1968,7 +1968,7 @@ test "big.int saturate single unsigned" { |
| 1968 | try testing.expect((try a.to(u23)) == maxInt(u23)); | 1968 | try testing.expect((try a.to(u23)) == maxInt(u23)); |
| 1969 | } | 1969 | } |
| 1970 | 1970 | ||
| 1971 | test "big.int saturate multi unsigned zero" { | 1971 | test "saturate multi unsigned zero" { |
| 1972 | var a = try Managed.initSet(testing.allocator, -1); | 1972 | var a = try Managed.initSet(testing.allocator, -1); |
| 1973 | defer a.deinit(); | 1973 | defer a.deinit(); |
| 1974 | 1974 | ||
| ... | @@ -1977,7 +1977,7 @@ test "big.int saturate multi unsigned zero" { | ... | @@ -1977,7 +1977,7 @@ test "big.int saturate multi unsigned zero" { |
| 1977 | try testing.expect(a.eqlZero()); | 1977 | try testing.expect(a.eqlZero()); |
| 1978 | } | 1978 | } |
| 1979 | 1979 | ||
| 1980 | test "big.int saturate multi unsigned" { | 1980 | test "saturate multi unsigned" { |
| 1981 | var a = try Managed.initSet(testing.allocator, maxInt(Limb) << @bitSizeOf(DoubleLimb)); | 1981 | var a = try Managed.initSet(testing.allocator, maxInt(Limb) << @bitSizeOf(DoubleLimb)); |
| 1982 | defer a.deinit(); | 1982 | defer a.deinit(); |
| 1983 | 1983 | ||
| ... | @@ -1986,7 +1986,7 @@ test "big.int saturate multi unsigned" { | ... | @@ -1986,7 +1986,7 @@ test "big.int saturate multi unsigned" { |
| 1986 | try testing.expect((try a.to(DoubleLimb)) == maxInt(DoubleLimb)); | 1986 | try testing.expect((try a.to(DoubleLimb)) == maxInt(DoubleLimb)); |
| 1987 | } | 1987 | } |
| 1988 | 1988 | ||
| 1989 | test "big.int shift-right single" { | 1989 | test "shift-right single" { |
| 1990 | var a = try Managed.initSet(testing.allocator, 0xffff0000); | 1990 | var a = try Managed.initSet(testing.allocator, 0xffff0000); |
| 1991 | defer a.deinit(); | 1991 | defer a.deinit(); |
| 1992 | try a.shiftRight(&a, 16); | 1992 | try a.shiftRight(&a, 16); |
| ... | @@ -1994,7 +1994,7 @@ test "big.int shift-right single" { | ... | @@ -1994,7 +1994,7 @@ test "big.int shift-right single" { |
| 1994 | try testing.expect((try a.to(u32)) == 0xffff); | 1994 | try testing.expect((try a.to(u32)) == 0xffff); |
| 1995 | } | 1995 | } |
| 1996 | 1996 | ||
| 1997 | test "big.int shift-right multi" { | 1997 | test "shift-right multi" { |
| 1998 | var a = try Managed.initSet(testing.allocator, 0xffff0000eeee1111dddd2222cccc3333); | 1998 | var a = try Managed.initSet(testing.allocator, 0xffff0000eeee1111dddd2222cccc3333); |
| 1999 | defer a.deinit(); | 1999 | defer a.deinit(); |
| 2000 | try a.shiftRight(&a, 67); | 2000 | try a.shiftRight(&a, 67); |
| ... | @@ -2008,7 +2008,7 @@ test "big.int shift-right multi" { | ... | @@ -2008,7 +2008,7 @@ test "big.int shift-right multi" { |
| 2008 | try testing.expect(a.eqlZero()); | 2008 | try testing.expect(a.eqlZero()); |
| 2009 | } | 2009 | } |
| 2010 | 2010 | ||
| 2011 | test "big.int shift-left single" { | 2011 | test "shift-left single" { |
| 2012 | var a = try Managed.initSet(testing.allocator, 0xffff); | 2012 | var a = try Managed.initSet(testing.allocator, 0xffff); |
| 2013 | defer a.deinit(); | 2013 | defer a.deinit(); |
| 2014 | try a.shiftLeft(&a, 16); | 2014 | try a.shiftLeft(&a, 16); |
| ... | @@ -2016,7 +2016,7 @@ test "big.int shift-left single" { | ... | @@ -2016,7 +2016,7 @@ test "big.int shift-left single" { |
| 2016 | try testing.expect((try a.to(u64)) == 0xffff0000); | 2016 | try testing.expect((try a.to(u64)) == 0xffff0000); |
| 2017 | } | 2017 | } |
| 2018 | 2018 | ||
| 2019 | test "big.int shift-left multi" { | 2019 | test "shift-left multi" { |
| 2020 | var a = try Managed.initSet(testing.allocator, 0x1fffe0001dddc222); | 2020 | var a = try Managed.initSet(testing.allocator, 0x1fffe0001dddc222); |
| 2021 | defer a.deinit(); | 2021 | defer a.deinit(); |
| 2022 | try a.shiftLeft(&a, 67); | 2022 | try a.shiftLeft(&a, 67); |
| ... | @@ -2024,7 +2024,7 @@ test "big.int shift-left multi" { | ... | @@ -2024,7 +2024,7 @@ test "big.int shift-left multi" { |
| 2024 | try testing.expect((try a.to(u128)) == 0xffff0000eeee11100000000000000000); | 2024 | try testing.expect((try a.to(u128)) == 0xffff0000eeee11100000000000000000); |
| 2025 | } | 2025 | } |
| 2026 | 2026 | ||
| 2027 | test "big.int shift-right negative" { | 2027 | test "shift-right negative" { |
| 2028 | var a = try Managed.init(testing.allocator); | 2028 | var a = try Managed.init(testing.allocator); |
| 2029 | defer a.deinit(); | 2029 | defer a.deinit(); |
| 2030 | 2030 | ||
| ... | @@ -2044,7 +2044,7 @@ test "big.int shift-right negative" { | ... | @@ -2044,7 +2044,7 @@ test "big.int shift-right negative" { |
| 2044 | try testing.expect((try a.to(i32)) == -1); // -10 >> 1232 == -1 | 2044 | try testing.expect((try a.to(i32)) == -1); // -10 >> 1232 == -1 |
| 2045 | } | 2045 | } |
| 2046 | 2046 | ||
| 2047 | test "big.int sat shift-left simple unsigned" { | 2047 | test "sat shift-left simple unsigned" { |
| 2048 | var a = try Managed.initSet(testing.allocator, 0xffff); | 2048 | var a = try Managed.initSet(testing.allocator, 0xffff); |
| 2049 | defer a.deinit(); | 2049 | defer a.deinit(); |
| 2050 | try a.shiftLeftSat(&a, 16, .unsigned, 21); | 2050 | try a.shiftLeftSat(&a, 16, .unsigned, 21); |
| ... | @@ -2052,7 +2052,7 @@ test "big.int sat shift-left simple unsigned" { | ... | @@ -2052,7 +2052,7 @@ test "big.int sat shift-left simple unsigned" { |
| 2052 | try testing.expect((try a.to(u64)) == 0x1fffff); | 2052 | try testing.expect((try a.to(u64)) == 0x1fffff); |
| 2053 | } | 2053 | } |
| 2054 | 2054 | ||
| 2055 | test "big.int sat shift-left simple unsigned no sat" { | 2055 | test "sat shift-left simple unsigned no sat" { |
| 2056 | var a = try Managed.initSet(testing.allocator, 1); | 2056 | var a = try Managed.initSet(testing.allocator, 1); |
| 2057 | defer a.deinit(); | 2057 | defer a.deinit(); |
| 2058 | try a.shiftLeftSat(&a, 16, .unsigned, 21); | 2058 | try a.shiftLeftSat(&a, 16, .unsigned, 21); |
| ... | @@ -2060,7 +2060,7 @@ test "big.int sat shift-left simple unsigned no sat" { | ... | @@ -2060,7 +2060,7 @@ test "big.int sat shift-left simple unsigned no sat" { |
| 2060 | try testing.expect((try a.to(u64)) == 0x10000); | 2060 | try testing.expect((try a.to(u64)) == 0x10000); |
| 2061 | } | 2061 | } |
| 2062 | 2062 | ||
| 2063 | test "big.int sat shift-left multi unsigned" { | 2063 | test "sat shift-left multi unsigned" { |
| 2064 | var a = try Managed.initSet(testing.allocator, 16); | 2064 | var a = try Managed.initSet(testing.allocator, 16); |
| 2065 | defer a.deinit(); | 2065 | defer a.deinit(); |
| 2066 | try a.shiftLeftSat(&a, @bitSizeOf(DoubleLimb) - 3, .unsigned, @bitSizeOf(DoubleLimb) - 1); | 2066 | try a.shiftLeftSat(&a, @bitSizeOf(DoubleLimb) - 3, .unsigned, @bitSizeOf(DoubleLimb) - 1); |
| ... | @@ -2068,7 +2068,7 @@ test "big.int sat shift-left multi unsigned" { | ... | @@ -2068,7 +2068,7 @@ test "big.int sat shift-left multi unsigned" { |
| 2068 | try testing.expect((try a.to(DoubleLimb)) == maxInt(DoubleLimb) >> 1); | 2068 | try testing.expect((try a.to(DoubleLimb)) == maxInt(DoubleLimb) >> 1); |
| 2069 | } | 2069 | } |
| 2070 | 2070 | ||
| 2071 | test "big.int sat shift-left unsigned shift > bitcount" { | 2071 | test "sat shift-left unsigned shift > bitcount" { |
| 2072 | var a = try Managed.initSet(testing.allocator, 1); | 2072 | var a = try Managed.initSet(testing.allocator, 1); |
| 2073 | defer a.deinit(); | 2073 | defer a.deinit(); |
| 2074 | try a.shiftLeftSat(&a, 10, .unsigned, 10); | 2074 | try a.shiftLeftSat(&a, 10, .unsigned, 10); |
| ... | @@ -2076,7 +2076,7 @@ test "big.int sat shift-left unsigned shift > bitcount" { | ... | @@ -2076,7 +2076,7 @@ test "big.int sat shift-left unsigned shift > bitcount" { |
| 2076 | try testing.expect((try a.to(u10)) == maxInt(u10)); | 2076 | try testing.expect((try a.to(u10)) == maxInt(u10)); |
| 2077 | } | 2077 | } |
| 2078 | 2078 | ||
| 2079 | test "big.int sat shift-left unsigned zero" { | 2079 | test "sat shift-left unsigned zero" { |
| 2080 | var a = try Managed.initSet(testing.allocator, 0); | 2080 | var a = try Managed.initSet(testing.allocator, 0); |
| 2081 | defer a.deinit(); | 2081 | defer a.deinit(); |
| 2082 | try a.shiftLeftSat(&a, 1, .unsigned, 0); | 2082 | try a.shiftLeftSat(&a, 1, .unsigned, 0); |
| ... | @@ -2084,7 +2084,7 @@ test "big.int sat shift-left unsigned zero" { | ... | @@ -2084,7 +2084,7 @@ test "big.int sat shift-left unsigned zero" { |
| 2084 | try testing.expect((try a.to(u64)) == 0); | 2084 | try testing.expect((try a.to(u64)) == 0); |
| 2085 | } | 2085 | } |
| 2086 | 2086 | ||
| 2087 | test "big.int sat shift-left unsigned negative" { | 2087 | test "sat shift-left unsigned negative" { |
| 2088 | var a = try Managed.initSet(testing.allocator, -100); | 2088 | var a = try Managed.initSet(testing.allocator, -100); |
| 2089 | defer a.deinit(); | 2089 | defer a.deinit(); |
| 2090 | try a.shiftLeftSat(&a, 0, .unsigned, 0); | 2090 | try a.shiftLeftSat(&a, 0, .unsigned, 0); |
| ... | @@ -2092,7 +2092,7 @@ test "big.int sat shift-left unsigned negative" { | ... | @@ -2092,7 +2092,7 @@ test "big.int sat shift-left unsigned negative" { |
| 2092 | try testing.expect((try a.to(u64)) == 0); | 2092 | try testing.expect((try a.to(u64)) == 0); |
| 2093 | } | 2093 | } |
| 2094 | 2094 | ||
| 2095 | test "big.int sat shift-left signed simple negative" { | 2095 | test "sat shift-left signed simple negative" { |
| 2096 | var a = try Managed.initSet(testing.allocator, -100); | 2096 | var a = try Managed.initSet(testing.allocator, -100); |
| 2097 | defer a.deinit(); | 2097 | defer a.deinit(); |
| 2098 | try a.shiftLeftSat(&a, 3, .signed, 10); | 2098 | try a.shiftLeftSat(&a, 3, .signed, 10); |
| ... | @@ -2100,7 +2100,7 @@ test "big.int sat shift-left signed simple negative" { | ... | @@ -2100,7 +2100,7 @@ test "big.int sat shift-left signed simple negative" { |
| 2100 | try testing.expect((try a.to(i10)) == minInt(i10)); | 2100 | try testing.expect((try a.to(i10)) == minInt(i10)); |
| 2101 | } | 2101 | } |
| 2102 | 2102 | ||
| 2103 | test "big.int sat shift-left signed simple positive" { | 2103 | test "sat shift-left signed simple positive" { |
| 2104 | var a = try Managed.initSet(testing.allocator, 100); | 2104 | var a = try Managed.initSet(testing.allocator, 100); |
| 2105 | defer a.deinit(); | 2105 | defer a.deinit(); |
| 2106 | try a.shiftLeftSat(&a, 3, .signed, 10); | 2106 | try a.shiftLeftSat(&a, 3, .signed, 10); |
| ... | @@ -2108,7 +2108,7 @@ test "big.int sat shift-left signed simple positive" { | ... | @@ -2108,7 +2108,7 @@ test "big.int sat shift-left signed simple positive" { |
| 2108 | try testing.expect((try a.to(i10)) == maxInt(i10)); | 2108 | try testing.expect((try a.to(i10)) == maxInt(i10)); |
| 2109 | } | 2109 | } |
| 2110 | 2110 | ||
| 2111 | test "big.int sat shift-left signed multi positive" { | 2111 | test "sat shift-left signed multi positive" { |
| 2112 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | 2112 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 2113 | 2113 | ||
| 2114 | var x: SignedDoubleLimb = 1; | 2114 | var x: SignedDoubleLimb = 1; |
| ... | @@ -2123,7 +2123,7 @@ test "big.int sat shift-left signed multi positive" { | ... | @@ -2123,7 +2123,7 @@ test "big.int sat shift-left signed multi positive" { |
| 2123 | try testing.expect((try a.to(SignedDoubleLimb)) == x <<| shift); | 2123 | try testing.expect((try a.to(SignedDoubleLimb)) == x <<| shift); |
| 2124 | } | 2124 | } |
| 2125 | 2125 | ||
| 2126 | test "big.int sat shift-left signed multi negative" { | 2126 | test "sat shift-left signed multi negative" { |
| 2127 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | 2127 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 2128 | 2128 | ||
| 2129 | var x: SignedDoubleLimb = -1; | 2129 | var x: SignedDoubleLimb = -1; |
| ... | @@ -2138,7 +2138,7 @@ test "big.int sat shift-left signed multi negative" { | ... | @@ -2138,7 +2138,7 @@ test "big.int sat shift-left signed multi negative" { |
| 2138 | try testing.expect((try a.to(SignedDoubleLimb)) == x <<| shift); | 2138 | try testing.expect((try a.to(SignedDoubleLimb)) == x <<| shift); |
| 2139 | } | 2139 | } |
| 2140 | 2140 | ||
| 2141 | test "big.int bitNotWrap unsigned simple" { | 2141 | test "bitNotWrap unsigned simple" { |
| 2142 | var x: u10 = 123; | 2142 | var x: u10 = 123; |
| 2143 | _ = &x; | 2143 | _ = &x; |
| 2144 | 2144 | ||
| ... | @@ -2150,7 +2150,7 @@ test "big.int bitNotWrap unsigned simple" { | ... | @@ -2150,7 +2150,7 @@ test "big.int bitNotWrap unsigned simple" { |
| 2150 | try testing.expect((try a.to(u10)) == ~x); | 2150 | try testing.expect((try a.to(u10)) == ~x); |
| 2151 | } | 2151 | } |
| 2152 | 2152 | ||
| 2153 | test "big.int bitNotWrap unsigned multi" { | 2153 | test "bitNotWrap unsigned multi" { |
| 2154 | var a = try Managed.initSet(testing.allocator, 0); | 2154 | var a = try Managed.initSet(testing.allocator, 0); |
| 2155 | defer a.deinit(); | 2155 | defer a.deinit(); |
| 2156 | 2156 | ||
| ... | @@ -2159,7 +2159,7 @@ test "big.int bitNotWrap unsigned multi" { | ... | @@ -2159,7 +2159,7 @@ test "big.int bitNotWrap unsigned multi" { |
| 2159 | try testing.expect((try a.to(DoubleLimb)) == maxInt(DoubleLimb)); | 2159 | try testing.expect((try a.to(DoubleLimb)) == maxInt(DoubleLimb)); |
| 2160 | } | 2160 | } |
| 2161 | 2161 | ||
| 2162 | test "big.int bitNotWrap signed simple" { | 2162 | test "bitNotWrap signed simple" { |
| 2163 | var x: i11 = -456; | 2163 | var x: i11 = -456; |
| 2164 | _ = &x; | 2164 | _ = &x; |
| 2165 | 2165 | ||
| ... | @@ -2171,7 +2171,7 @@ test "big.int bitNotWrap signed simple" { | ... | @@ -2171,7 +2171,7 @@ test "big.int bitNotWrap signed simple" { |
| 2171 | try testing.expect((try a.to(i11)) == ~x); | 2171 | try testing.expect((try a.to(i11)) == ~x); |
| 2172 | } | 2172 | } |
| 2173 | 2173 | ||
| 2174 | test "big.int bitNotWrap signed multi" { | 2174 | test "bitNotWrap signed multi" { |
| 2175 | var a = try Managed.initSet(testing.allocator, 0); | 2175 | var a = try Managed.initSet(testing.allocator, 0); |
| 2176 | defer a.deinit(); | 2176 | defer a.deinit(); |
| 2177 | 2177 | ||
| ... | @@ -2180,7 +2180,7 @@ test "big.int bitNotWrap signed multi" { | ... | @@ -2180,7 +2180,7 @@ test "big.int bitNotWrap signed multi" { |
| 2180 | try testing.expect((try a.to(SignedDoubleLimb)) == -1); | 2180 | try testing.expect((try a.to(SignedDoubleLimb)) == -1); |
| 2181 | } | 2181 | } |
| 2182 | 2182 | ||
| 2183 | test "big.int bitNotWrap more than two limbs" { | 2183 | test "bitNotWrap more than two limbs" { |
| 2184 | // This test requires int sizes greater than 128 bits. | 2184 | // This test requires int sizes greater than 128 bits. |
| 2185 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | 2185 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO |
| 2186 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 2186 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| ... | @@ -2206,7 +2206,7 @@ test "big.int bitNotWrap more than two limbs" { | ... | @@ -2206,7 +2206,7 @@ test "big.int bitNotWrap more than two limbs" { |
| 2206 | try testing.expectEqual((try res.to(Signed)), ~@as(Signed, maxInt(Limb))); | 2206 | try testing.expectEqual((try res.to(Signed)), ~@as(Signed, maxInt(Limb))); |
| 2207 | } | 2207 | } |
| 2208 | 2208 | ||
| 2209 | test "big.int bitwise and simple" { | 2209 | test "bitwise and simple" { |
| 2210 | var a = try Managed.initSet(testing.allocator, 0xffffffff11111111); | 2210 | var a = try Managed.initSet(testing.allocator, 0xffffffff11111111); |
| 2211 | defer a.deinit(); | 2211 | defer a.deinit(); |
| 2212 | var b = try Managed.initSet(testing.allocator, 0xeeeeeeee22222222); | 2212 | var b = try Managed.initSet(testing.allocator, 0xeeeeeeee22222222); |
| ... | @@ -2217,7 +2217,7 @@ test "big.int bitwise and simple" { | ... | @@ -2217,7 +2217,7 @@ test "big.int bitwise and simple" { |
| 2217 | try testing.expect((try a.to(u64)) == 0xeeeeeeee00000000); | 2217 | try testing.expect((try a.to(u64)) == 0xeeeeeeee00000000); |
| 2218 | } | 2218 | } |
| 2219 | 2219 | ||
| 2220 | test "big.int bitwise and multi-limb" { | 2220 | test "bitwise and multi-limb" { |
| 2221 | var a = try Managed.initSet(testing.allocator, maxInt(Limb) + 1); | 2221 | var a = try Managed.initSet(testing.allocator, maxInt(Limb) + 1); |
| 2222 | defer a.deinit(); | 2222 | defer a.deinit(); |
| 2223 | var b = try Managed.initSet(testing.allocator, maxInt(Limb)); | 2223 | var b = try Managed.initSet(testing.allocator, maxInt(Limb)); |
| ... | @@ -2228,7 +2228,7 @@ test "big.int bitwise and multi-limb" { | ... | @@ -2228,7 +2228,7 @@ test "big.int bitwise and multi-limb" { |
| 2228 | try testing.expect((try a.to(u128)) == 0); | 2228 | try testing.expect((try a.to(u128)) == 0); |
| 2229 | } | 2229 | } |
| 2230 | 2230 | ||
| 2231 | test "big.int bitwise and negative-positive simple" { | 2231 | test "bitwise and negative-positive simple" { |
| 2232 | var a = try Managed.initSet(testing.allocator, -0xffffffff11111111); | 2232 | var a = try Managed.initSet(testing.allocator, -0xffffffff11111111); |
| 2233 | defer a.deinit(); | 2233 | defer a.deinit(); |
| 2234 | var b = try Managed.initSet(testing.allocator, 0xeeeeeeee22222222); | 2234 | var b = try Managed.initSet(testing.allocator, 0xeeeeeeee22222222); |
| ... | @@ -2239,7 +2239,7 @@ test "big.int bitwise and negative-positive simple" { | ... | @@ -2239,7 +2239,7 @@ test "big.int bitwise and negative-positive simple" { |
| 2239 | try testing.expect((try a.to(u64)) == 0x22222222); | 2239 | try testing.expect((try a.to(u64)) == 0x22222222); |
| 2240 | } | 2240 | } |
| 2241 | 2241 | ||
| 2242 | test "big.int bitwise and negative-positive multi-limb" { | 2242 | test "bitwise and negative-positive multi-limb" { |
| 2243 | var a = try Managed.initSet(testing.allocator, -maxInt(Limb) - 1); | 2243 | var a = try Managed.initSet(testing.allocator, -maxInt(Limb) - 1); |
| 2244 | defer a.deinit(); | 2244 | defer a.deinit(); |
| 2245 | var b = try Managed.initSet(testing.allocator, maxInt(Limb)); | 2245 | var b = try Managed.initSet(testing.allocator, maxInt(Limb)); |
| ... | @@ -2250,7 +2250,7 @@ test "big.int bitwise and negative-positive multi-limb" { | ... | @@ -2250,7 +2250,7 @@ test "big.int bitwise and negative-positive multi-limb" { |
| 2250 | try testing.expect(a.eqlZero()); | 2250 | try testing.expect(a.eqlZero()); |
| 2251 | } | 2251 | } |
| 2252 | 2252 | ||
| 2253 | test "big.int bitwise and positive-negative simple" { | 2253 | test "bitwise and positive-negative simple" { |
| 2254 | var a = try Managed.initSet(testing.allocator, 0xffffffff11111111); | 2254 | var a = try Managed.initSet(testing.allocator, 0xffffffff11111111); |
| 2255 | defer a.deinit(); | 2255 | defer a.deinit(); |
| 2256 | var b = try Managed.initSet(testing.allocator, -0xeeeeeeee22222222); | 2256 | var b = try Managed.initSet(testing.allocator, -0xeeeeeeee22222222); |
| ... | @@ -2261,7 +2261,7 @@ test "big.int bitwise and positive-negative simple" { | ... | @@ -2261,7 +2261,7 @@ test "big.int bitwise and positive-negative simple" { |
| 2261 | try testing.expect((try a.to(u64)) == 0x1111111111111110); | 2261 | try testing.expect((try a.to(u64)) == 0x1111111111111110); |
| 2262 | } | 2262 | } |
| 2263 | 2263 | ||
| 2264 | test "big.int bitwise and positive-negative multi-limb" { | 2264 | test "bitwise and positive-negative multi-limb" { |
| 2265 | var a = try Managed.initSet(testing.allocator, maxInt(Limb)); | 2265 | var a = try Managed.initSet(testing.allocator, maxInt(Limb)); |
| 2266 | defer a.deinit(); | 2266 | defer a.deinit(); |
| 2267 | var b = try Managed.initSet(testing.allocator, -maxInt(Limb) - 1); | 2267 | var b = try Managed.initSet(testing.allocator, -maxInt(Limb) - 1); |
| ... | @@ -2272,7 +2272,7 @@ test "big.int bitwise and positive-negative multi-limb" { | ... | @@ -2272,7 +2272,7 @@ test "big.int bitwise and positive-negative multi-limb" { |
| 2272 | try testing.expect(a.eqlZero()); | 2272 | try testing.expect(a.eqlZero()); |
| 2273 | } | 2273 | } |
| 2274 | 2274 | ||
| 2275 | test "big.int bitwise and negative-negative simple" { | 2275 | test "bitwise and negative-negative simple" { |
| 2276 | var a = try Managed.initSet(testing.allocator, -0xffffffff11111111); | 2276 | var a = try Managed.initSet(testing.allocator, -0xffffffff11111111); |
| 2277 | defer a.deinit(); | 2277 | defer a.deinit(); |
| 2278 | var b = try Managed.initSet(testing.allocator, -0xeeeeeeee22222222); | 2278 | var b = try Managed.initSet(testing.allocator, -0xeeeeeeee22222222); |
| ... | @@ -2283,7 +2283,7 @@ test "big.int bitwise and negative-negative simple" { | ... | @@ -2283,7 +2283,7 @@ test "big.int bitwise and negative-negative simple" { |
| 2283 | try testing.expect((try a.to(i128)) == -0xffffffff33333332); | 2283 | try testing.expect((try a.to(i128)) == -0xffffffff33333332); |
| 2284 | } | 2284 | } |
| 2285 | 2285 | ||
| 2286 | test "big.int bitwise and negative-negative multi-limb" { | 2286 | test "bitwise and negative-negative multi-limb" { |
| 2287 | var a = try Managed.initSet(testing.allocator, -maxInt(Limb) - 1); | 2287 | var a = try Managed.initSet(testing.allocator, -maxInt(Limb) - 1); |
| 2288 | defer a.deinit(); | 2288 | defer a.deinit(); |
| 2289 | var b = try Managed.initSet(testing.allocator, -maxInt(Limb) - 2); | 2289 | var b = try Managed.initSet(testing.allocator, -maxInt(Limb) - 2); |
| ... | @@ -2294,7 +2294,7 @@ test "big.int bitwise and negative-negative multi-limb" { | ... | @@ -2294,7 +2294,7 @@ test "big.int bitwise and negative-negative multi-limb" { |
| 2294 | try testing.expect((try a.to(i128)) == -maxInt(Limb) * 2 - 2); | 2294 | try testing.expect((try a.to(i128)) == -maxInt(Limb) * 2 - 2); |
| 2295 | } | 2295 | } |
| 2296 | 2296 | ||
| 2297 | test "big.int bitwise and negative overflow" { | 2297 | test "bitwise and negative overflow" { |
| 2298 | var a = try Managed.initSet(testing.allocator, -maxInt(Limb)); | 2298 | var a = try Managed.initSet(testing.allocator, -maxInt(Limb)); |
| 2299 | defer a.deinit(); | 2299 | defer a.deinit(); |
| 2300 | var b = try Managed.initSet(testing.allocator, -2); | 2300 | var b = try Managed.initSet(testing.allocator, -2); |
| ... | @@ -2305,7 +2305,7 @@ test "big.int bitwise and negative overflow" { | ... | @@ -2305,7 +2305,7 @@ test "big.int bitwise and negative overflow" { |
| 2305 | try testing.expect((try a.to(SignedDoubleLimb)) == -maxInt(Limb) - 1); | 2305 | try testing.expect((try a.to(SignedDoubleLimb)) == -maxInt(Limb) - 1); |
| 2306 | } | 2306 | } |
| 2307 | 2307 | ||
| 2308 | test "big.int bitwise xor simple" { | 2308 | test "bitwise xor simple" { |
| 2309 | var a = try Managed.initSet(testing.allocator, 0xffffffff11111111); | 2309 | var a = try Managed.initSet(testing.allocator, 0xffffffff11111111); |
| 2310 | defer a.deinit(); | 2310 | defer a.deinit(); |
| 2311 | var b = try Managed.initSet(testing.allocator, 0xeeeeeeee22222222); | 2311 | var b = try Managed.initSet(testing.allocator, 0xeeeeeeee22222222); |
| ... | @@ -2316,7 +2316,7 @@ test "big.int bitwise xor simple" { | ... | @@ -2316,7 +2316,7 @@ test "big.int bitwise xor simple" { |
| 2316 | try testing.expect((try a.to(u64)) == 0x1111111133333333); | 2316 | try testing.expect((try a.to(u64)) == 0x1111111133333333); |
| 2317 | } | 2317 | } |
| 2318 | 2318 | ||
| 2319 | test "big.int bitwise xor multi-limb" { | 2319 | test "bitwise xor multi-limb" { |
| 2320 | var x: DoubleLimb = maxInt(Limb) + 1; | 2320 | var x: DoubleLimb = maxInt(Limb) + 1; |
| 2321 | var y: DoubleLimb = maxInt(Limb); | 2321 | var y: DoubleLimb = maxInt(Limb); |
| 2322 | _ = .{ &x, &y }; | 2322 | _ = .{ &x, &y }; |
| ... | @@ -2331,7 +2331,7 @@ test "big.int bitwise xor multi-limb" { | ... | @@ -2331,7 +2331,7 @@ test "big.int bitwise xor multi-limb" { |
| 2331 | try testing.expect((try a.to(DoubleLimb)) == x ^ y); | 2331 | try testing.expect((try a.to(DoubleLimb)) == x ^ y); |
| 2332 | } | 2332 | } |
| 2333 | 2333 | ||
| 2334 | test "big.int bitwise xor single negative simple" { | 2334 | test "bitwise xor single negative simple" { |
| 2335 | var a = try Managed.initSet(testing.allocator, 0x6b03e381328a3154); | 2335 | var a = try Managed.initSet(testing.allocator, 0x6b03e381328a3154); |
| 2336 | defer a.deinit(); | 2336 | defer a.deinit(); |
| 2337 | var b = try Managed.initSet(testing.allocator, -0x45fd3acef9191fad); | 2337 | var b = try Managed.initSet(testing.allocator, -0x45fd3acef9191fad); |
| ... | @@ -2342,7 +2342,7 @@ test "big.int bitwise xor single negative simple" { | ... | @@ -2342,7 +2342,7 @@ test "big.int bitwise xor single negative simple" { |
| 2342 | try testing.expect((try a.to(i64)) == -0x2efed94fcb932ef9); | 2342 | try testing.expect((try a.to(i64)) == -0x2efed94fcb932ef9); |
| 2343 | } | 2343 | } |
| 2344 | 2344 | ||
| 2345 | test "big.int bitwise xor single negative multi-limb" { | 2345 | test "bitwise xor single negative multi-limb" { |
| 2346 | var a = try Managed.initSet(testing.allocator, -0x9849c6e7a10d66d0e4260d4846254c32); | 2346 | var a = try Managed.initSet(testing.allocator, -0x9849c6e7a10d66d0e4260d4846254c32); |
| 2347 | defer a.deinit(); | 2347 | defer a.deinit(); |
| 2348 | var b = try Managed.initSet(testing.allocator, 0xf2194e7d1c855272a997fcde16f6d5a8); | 2348 | var b = try Managed.initSet(testing.allocator, 0xf2194e7d1c855272a997fcde16f6d5a8); |
| ... | @@ -2353,7 +2353,7 @@ test "big.int bitwise xor single negative multi-limb" { | ... | @@ -2353,7 +2353,7 @@ test "big.int bitwise xor single negative multi-limb" { |
| 2353 | try testing.expect((try a.to(i128)) == -0x6a50889abd8834a24db1f19650d3999a); | 2353 | try testing.expect((try a.to(i128)) == -0x6a50889abd8834a24db1f19650d3999a); |
| 2354 | } | 2354 | } |
| 2355 | 2355 | ||
| 2356 | test "big.int bitwise xor single negative overflow" { | 2356 | test "bitwise xor single negative overflow" { |
| 2357 | var a = try Managed.initSet(testing.allocator, maxInt(Limb)); | 2357 | var a = try Managed.initSet(testing.allocator, maxInt(Limb)); |
| 2358 | defer a.deinit(); | 2358 | defer a.deinit(); |
| 2359 | var b = try Managed.initSet(testing.allocator, -1); | 2359 | var b = try Managed.initSet(testing.allocator, -1); |
| ... | @@ -2364,7 +2364,7 @@ test "big.int bitwise xor single negative overflow" { | ... | @@ -2364,7 +2364,7 @@ test "big.int bitwise xor single negative overflow" { |
| 2364 | try testing.expect((try a.to(SignedDoubleLimb)) == -(maxInt(Limb) + 1)); | 2364 | try testing.expect((try a.to(SignedDoubleLimb)) == -(maxInt(Limb) + 1)); |
| 2365 | } | 2365 | } |
| 2366 | 2366 | ||
| 2367 | test "big.int bitwise xor double negative simple" { | 2367 | test "bitwise xor double negative simple" { |
| 2368 | var a = try Managed.initSet(testing.allocator, -0x8e48bd5f755ef1f3); | 2368 | var a = try Managed.initSet(testing.allocator, -0x8e48bd5f755ef1f3); |
| 2369 | defer a.deinit(); | 2369 | defer a.deinit(); |
| 2370 | var b = try Managed.initSet(testing.allocator, -0x4dd4fa576f3046ac); | 2370 | var b = try Managed.initSet(testing.allocator, -0x4dd4fa576f3046ac); |
| ... | @@ -2375,7 +2375,7 @@ test "big.int bitwise xor double negative simple" { | ... | @@ -2375,7 +2375,7 @@ test "big.int bitwise xor double negative simple" { |
| 2375 | try testing.expect((try a.to(u64)) == 0xc39c47081a6eb759); | 2375 | try testing.expect((try a.to(u64)) == 0xc39c47081a6eb759); |
| 2376 | } | 2376 | } |
| 2377 | 2377 | ||
| 2378 | test "big.int bitwise xor double negative multi-limb" { | 2378 | test "bitwise xor double negative multi-limb" { |
| 2379 | var a = try Managed.initSet(testing.allocator, -0x684e5da8f500ec8ca7204c33ccc51c9c); | 2379 | var a = try Managed.initSet(testing.allocator, -0x684e5da8f500ec8ca7204c33ccc51c9c); |
| 2380 | defer a.deinit(); | 2380 | defer a.deinit(); |
| 2381 | var b = try Managed.initSet(testing.allocator, -0xcb07736a7b62289c78d967c3985eebeb); | 2381 | var b = try Managed.initSet(testing.allocator, -0xcb07736a7b62289c78d967c3985eebeb); |
| ... | @@ -2386,7 +2386,7 @@ test "big.int bitwise xor double negative multi-limb" { | ... | @@ -2386,7 +2386,7 @@ test "big.int bitwise xor double negative multi-limb" { |
| 2386 | try testing.expect((try a.to(u128)) == 0xa3492ec28e62c410dff92bf0549bf771); | 2386 | try testing.expect((try a.to(u128)) == 0xa3492ec28e62c410dff92bf0549bf771); |
| 2387 | } | 2387 | } |
| 2388 | 2388 | ||
| 2389 | test "big.int bitwise or simple" { | 2389 | test "bitwise or simple" { |
| 2390 | var a = try Managed.initSet(testing.allocator, 0xffffffff11111111); | 2390 | var a = try Managed.initSet(testing.allocator, 0xffffffff11111111); |
| 2391 | defer a.deinit(); | 2391 | defer a.deinit(); |
| 2392 | var b = try Managed.initSet(testing.allocator, 0xeeeeeeee22222222); | 2392 | var b = try Managed.initSet(testing.allocator, 0xeeeeeeee22222222); |
| ... | @@ -2397,7 +2397,7 @@ test "big.int bitwise or simple" { | ... | @@ -2397,7 +2397,7 @@ test "big.int bitwise or simple" { |
| 2397 | try testing.expect((try a.to(u64)) == 0xffffffff33333333); | 2397 | try testing.expect((try a.to(u64)) == 0xffffffff33333333); |
| 2398 | } | 2398 | } |
| 2399 | 2399 | ||
| 2400 | test "big.int bitwise or multi-limb" { | 2400 | test "bitwise or multi-limb" { |
| 2401 | var a = try Managed.initSet(testing.allocator, maxInt(Limb) + 1); | 2401 | var a = try Managed.initSet(testing.allocator, maxInt(Limb) + 1); |
| 2402 | defer a.deinit(); | 2402 | defer a.deinit(); |
| 2403 | var b = try Managed.initSet(testing.allocator, maxInt(Limb)); | 2403 | var b = try Managed.initSet(testing.allocator, maxInt(Limb)); |
| ... | @@ -2408,7 +2408,7 @@ test "big.int bitwise or multi-limb" { | ... | @@ -2408,7 +2408,7 @@ test "big.int bitwise or multi-limb" { |
| 2408 | try testing.expect((try a.to(DoubleLimb)) == (maxInt(Limb) + 1) + maxInt(Limb)); | 2408 | try testing.expect((try a.to(DoubleLimb)) == (maxInt(Limb) + 1) + maxInt(Limb)); |
| 2409 | } | 2409 | } |
| 2410 | 2410 | ||
| 2411 | test "big.int bitwise or negative-positive simple" { | 2411 | test "bitwise or negative-positive simple" { |
| 2412 | var a = try Managed.initSet(testing.allocator, -0xffffffff11111111); | 2412 | var a = try Managed.initSet(testing.allocator, -0xffffffff11111111); |
| 2413 | defer a.deinit(); | 2413 | defer a.deinit(); |
| 2414 | var b = try Managed.initSet(testing.allocator, 0xeeeeeeee22222222); | 2414 | var b = try Managed.initSet(testing.allocator, 0xeeeeeeee22222222); |
| ... | @@ -2419,7 +2419,7 @@ test "big.int bitwise or negative-positive simple" { | ... | @@ -2419,7 +2419,7 @@ test "big.int bitwise or negative-positive simple" { |
| 2419 | try testing.expect((try a.to(i64)) == -0x1111111111111111); | 2419 | try testing.expect((try a.to(i64)) == -0x1111111111111111); |
| 2420 | } | 2420 | } |
| 2421 | 2421 | ||
| 2422 | test "big.int bitwise or negative-positive multi-limb" { | 2422 | test "bitwise or negative-positive multi-limb" { |
| 2423 | var a = try Managed.initSet(testing.allocator, -maxInt(Limb) - 1); | 2423 | var a = try Managed.initSet(testing.allocator, -maxInt(Limb) - 1); |
| 2424 | defer a.deinit(); | 2424 | defer a.deinit(); |
| 2425 | var b = try Managed.initSet(testing.allocator, 1); | 2425 | var b = try Managed.initSet(testing.allocator, 1); |
| ... | @@ -2430,7 +2430,7 @@ test "big.int bitwise or negative-positive multi-limb" { | ... | @@ -2430,7 +2430,7 @@ test "big.int bitwise or negative-positive multi-limb" { |
| 2430 | try testing.expect((try a.to(SignedDoubleLimb)) == -maxInt(Limb)); | 2430 | try testing.expect((try a.to(SignedDoubleLimb)) == -maxInt(Limb)); |
| 2431 | } | 2431 | } |
| 2432 | 2432 | ||
| 2433 | test "big.int bitwise or positive-negative simple" { | 2433 | test "bitwise or positive-negative simple" { |
| 2434 | var a = try Managed.initSet(testing.allocator, 0xffffffff11111111); | 2434 | var a = try Managed.initSet(testing.allocator, 0xffffffff11111111); |
| 2435 | defer a.deinit(); | 2435 | defer a.deinit(); |
| 2436 | var b = try Managed.initSet(testing.allocator, -0xeeeeeeee22222222); | 2436 | var b = try Managed.initSet(testing.allocator, -0xeeeeeeee22222222); |
| ... | @@ -2441,7 +2441,7 @@ test "big.int bitwise or positive-negative simple" { | ... | @@ -2441,7 +2441,7 @@ test "big.int bitwise or positive-negative simple" { |
| 2441 | try testing.expect((try a.to(i64)) == -0x22222221); | 2441 | try testing.expect((try a.to(i64)) == -0x22222221); |
| 2442 | } | 2442 | } |
| 2443 | 2443 | ||
| 2444 | test "big.int bitwise or positive-negative multi-limb" { | 2444 | test "bitwise or positive-negative multi-limb" { |
| 2445 | var a = try Managed.initSet(testing.allocator, maxInt(Limb) + 1); | 2445 | var a = try Managed.initSet(testing.allocator, maxInt(Limb) + 1); |
| 2446 | defer a.deinit(); | 2446 | defer a.deinit(); |
| 2447 | var b = try Managed.initSet(testing.allocator, -1); | 2447 | var b = try Managed.initSet(testing.allocator, -1); |
| ... | @@ -2452,7 +2452,7 @@ test "big.int bitwise or positive-negative multi-limb" { | ... | @@ -2452,7 +2452,7 @@ test "big.int bitwise or positive-negative multi-limb" { |
| 2452 | try testing.expect((try a.to(SignedDoubleLimb)) == -1); | 2452 | try testing.expect((try a.to(SignedDoubleLimb)) == -1); |
| 2453 | } | 2453 | } |
| 2454 | 2454 | ||
| 2455 | test "big.int bitwise or negative-negative simple" { | 2455 | test "bitwise or negative-negative simple" { |
| 2456 | var a = try Managed.initSet(testing.allocator, -0xffffffff11111111); | 2456 | var a = try Managed.initSet(testing.allocator, -0xffffffff11111111); |
| 2457 | defer a.deinit(); | 2457 | defer a.deinit(); |
| 2458 | var b = try Managed.initSet(testing.allocator, -0xeeeeeeee22222222); | 2458 | var b = try Managed.initSet(testing.allocator, -0xeeeeeeee22222222); |
| ... | @@ -2463,7 +2463,7 @@ test "big.int bitwise or negative-negative simple" { | ... | @@ -2463,7 +2463,7 @@ test "big.int bitwise or negative-negative simple" { |
| 2463 | try testing.expect((try a.to(i128)) == -0xeeeeeeee00000001); | 2463 | try testing.expect((try a.to(i128)) == -0xeeeeeeee00000001); |
| 2464 | } | 2464 | } |
| 2465 | 2465 | ||
| 2466 | test "big.int bitwise or negative-negative multi-limb" { | 2466 | test "bitwise or negative-negative multi-limb" { |
| 2467 | var a = try Managed.initSet(testing.allocator, -maxInt(Limb) - 1); | 2467 | var a = try Managed.initSet(testing.allocator, -maxInt(Limb) - 1); |
| 2468 | defer a.deinit(); | 2468 | defer a.deinit(); |
| 2469 | var b = try Managed.initSet(testing.allocator, -maxInt(Limb)); | 2469 | var b = try Managed.initSet(testing.allocator, -maxInt(Limb)); |
| ... | @@ -2474,7 +2474,7 @@ test "big.int bitwise or negative-negative multi-limb" { | ... | @@ -2474,7 +2474,7 @@ test "big.int bitwise or negative-negative multi-limb" { |
| 2474 | try testing.expect((try a.to(SignedDoubleLimb)) == -maxInt(Limb)); | 2474 | try testing.expect((try a.to(SignedDoubleLimb)) == -maxInt(Limb)); |
| 2475 | } | 2475 | } |
| 2476 | 2476 | ||
| 2477 | test "big.int var args" { | 2477 | test "var args" { |
| 2478 | var a = try Managed.initSet(testing.allocator, 5); | 2478 | var a = try Managed.initSet(testing.allocator, 5); |
| 2479 | defer a.deinit(); | 2479 | defer a.deinit(); |
| 2480 | 2480 | ||
| ... | @@ -2492,7 +2492,7 @@ test "big.int var args" { | ... | @@ -2492,7 +2492,7 @@ test "big.int var args" { |
| 2492 | try testing.expect(a.order(d) != .gt); | 2492 | try testing.expect(a.order(d) != .gt); |
| 2493 | } | 2493 | } |
| 2494 | 2494 | ||
| 2495 | test "big.int gcd non-one small" { | 2495 | test "gcd non-one small" { |
| 2496 | var a = try Managed.initSet(testing.allocator, 17); | 2496 | var a = try Managed.initSet(testing.allocator, 17); |
| 2497 | defer a.deinit(); | 2497 | defer a.deinit(); |
| 2498 | var b = try Managed.initSet(testing.allocator, 97); | 2498 | var b = try Managed.initSet(testing.allocator, 97); |
| ... | @@ -2505,7 +2505,7 @@ test "big.int gcd non-one small" { | ... | @@ -2505,7 +2505,7 @@ test "big.int gcd non-one small" { |
| 2505 | try testing.expect((try r.to(u32)) == 1); | 2505 | try testing.expect((try r.to(u32)) == 1); |
| 2506 | } | 2506 | } |
| 2507 | 2507 | ||
| 2508 | test "big.int gcd non-one medium" { | 2508 | test "gcd non-one medium" { |
| 2509 | var a = try Managed.initSet(testing.allocator, 4864); | 2509 | var a = try Managed.initSet(testing.allocator, 4864); |
| 2510 | defer a.deinit(); | 2510 | defer a.deinit(); |
| 2511 | var b = try Managed.initSet(testing.allocator, 3458); | 2511 | var b = try Managed.initSet(testing.allocator, 3458); |
| ... | @@ -2518,7 +2518,7 @@ test "big.int gcd non-one medium" { | ... | @@ -2518,7 +2518,7 @@ test "big.int gcd non-one medium" { |
| 2518 | try testing.expect((try r.to(u32)) == 38); | 2518 | try testing.expect((try r.to(u32)) == 38); |
| 2519 | } | 2519 | } |
| 2520 | 2520 | ||
| 2521 | test "big.int gcd non-one large" { | 2521 | test "gcd non-one large" { |
| 2522 | var a = try Managed.initSet(testing.allocator, 0xffffffffffffffff); | 2522 | var a = try Managed.initSet(testing.allocator, 0xffffffffffffffff); |
| 2523 | defer a.deinit(); | 2523 | defer a.deinit(); |
| 2524 | var b = try Managed.initSet(testing.allocator, 0xffffffffffffffff7777); | 2524 | var b = try Managed.initSet(testing.allocator, 0xffffffffffffffff7777); |
| ... | @@ -2531,7 +2531,7 @@ test "big.int gcd non-one large" { | ... | @@ -2531,7 +2531,7 @@ test "big.int gcd non-one large" { |
| 2531 | try testing.expect((try r.to(u32)) == 4369); | 2531 | try testing.expect((try r.to(u32)) == 4369); |
| 2532 | } | 2532 | } |
| 2533 | 2533 | ||
| 2534 | test "big.int gcd large multi-limb result" { | 2534 | test "gcd large multi-limb result" { |
| 2535 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 2535 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 2536 | 2536 | ||
| 2537 | var a = try Managed.initSet(testing.allocator, 0x12345678123456781234567812345678123456781234567812345678); | 2537 | var a = try Managed.initSet(testing.allocator, 0x12345678123456781234567812345678123456781234567812345678); |
| ... | @@ -2547,7 +2547,7 @@ test "big.int gcd large multi-limb result" { | ... | @@ -2547,7 +2547,7 @@ test "big.int gcd large multi-limb result" { |
| 2547 | try testing.expect(answer == 0xf000000ff00000fff0000ffff000fffff00ffffff1); | 2547 | try testing.expect(answer == 0xf000000ff00000fff0000ffff000fffff00ffffff1); |
| 2548 | } | 2548 | } |
| 2549 | 2549 | ||
| 2550 | test "big.int gcd one large" { | 2550 | test "gcd one large" { |
| 2551 | var a = try Managed.initSet(testing.allocator, 1897056385327307); | 2551 | var a = try Managed.initSet(testing.allocator, 1897056385327307); |
| 2552 | defer a.deinit(); | 2552 | defer a.deinit(); |
| 2553 | var b = try Managed.initSet(testing.allocator, 2251799813685248); | 2553 | var b = try Managed.initSet(testing.allocator, 2251799813685248); |
| ... | @@ -2560,7 +2560,7 @@ test "big.int gcd one large" { | ... | @@ -2560,7 +2560,7 @@ test "big.int gcd one large" { |
| 2560 | try testing.expect((try r.to(u64)) == 1); | 2560 | try testing.expect((try r.to(u64)) == 1); |
| 2561 | } | 2561 | } |
| 2562 | 2562 | ||
| 2563 | test "big.int mutable to managed" { | 2563 | test "mutable to managed" { |
| 2564 | const allocator = testing.allocator; | 2564 | const allocator = testing.allocator; |
| 2565 | const limbs_buf = try allocator.alloc(Limb, 8); | 2565 | const limbs_buf = try allocator.alloc(Limb, 8); |
| 2566 | defer allocator.free(limbs_buf); | 2566 | defer allocator.free(limbs_buf); |
| ... | @@ -2571,7 +2571,7 @@ test "big.int mutable to managed" { | ... | @@ -2571,7 +2571,7 @@ test "big.int mutable to managed" { |
| 2571 | try testing.expect(a.toConst().eql(a_managed.toConst())); | 2571 | try testing.expect(a.toConst().eql(a_managed.toConst())); |
| 2572 | } | 2572 | } |
| 2573 | 2573 | ||
| 2574 | test "big.int const to managed" { | 2574 | test "const to managed" { |
| 2575 | var a = try Managed.initSet(testing.allocator, 123423453456); | 2575 | var a = try Managed.initSet(testing.allocator, 123423453456); |
| 2576 | defer a.deinit(); | 2576 | defer a.deinit(); |
| 2577 | 2577 | ||
| ... | @@ -2581,7 +2581,7 @@ test "big.int const to managed" { | ... | @@ -2581,7 +2581,7 @@ test "big.int const to managed" { |
| 2581 | try testing.expect(a.toConst().eql(b.toConst())); | 2581 | try testing.expect(a.toConst().eql(b.toConst())); |
| 2582 | } | 2582 | } |
| 2583 | 2583 | ||
| 2584 | test "big.int pow" { | 2584 | test "pow" { |
| 2585 | { | 2585 | { |
| 2586 | var a = try Managed.initSet(testing.allocator, -3); | 2586 | var a = try Managed.initSet(testing.allocator, -3); |
| 2587 | defer a.deinit(); | 2587 | defer a.deinit(); |
| ... | @@ -2636,7 +2636,7 @@ test "big.int pow" { | ... | @@ -2636,7 +2636,7 @@ test "big.int pow" { |
| 2636 | } | 2636 | } |
| 2637 | } | 2637 | } |
| 2638 | 2638 | ||
| 2639 | test "big.int sqrt" { | 2639 | test "sqrt" { |
| 2640 | var r = try Managed.init(testing.allocator); | 2640 | var r = try Managed.init(testing.allocator); |
| 2641 | defer r.deinit(); | 2641 | defer r.deinit(); |
| 2642 | var a = try Managed.init(testing.allocator); | 2642 | var a = try Managed.init(testing.allocator); |
| ... | @@ -2666,7 +2666,7 @@ test "big.int sqrt" { | ... | @@ -2666,7 +2666,7 @@ test "big.int sqrt" { |
| 2666 | try testing.expectEqual(@as(i32, 0x100_0000), try r.to(i32)); | 2666 | try testing.expectEqual(@as(i32, 0x100_0000), try r.to(i32)); |
| 2667 | } | 2667 | } |
| 2668 | 2668 | ||
| 2669 | test "big.int regression test for 1 limb overflow with alias" { | 2669 | test "regression test for 1 limb overflow with alias" { |
| 2670 | // Note these happen to be two consecutive Fibonacci sequence numbers, the | 2670 | // Note these happen to be two consecutive Fibonacci sequence numbers, the |
| 2671 | // first two whose sum exceeds 2**64. | 2671 | // first two whose sum exceeds 2**64. |
| 2672 | var a = try Managed.initSet(testing.allocator, 7540113804746346429); | 2672 | var a = try Managed.initSet(testing.allocator, 7540113804746346429); |
| ... | @@ -2680,7 +2680,7 @@ test "big.int regression test for 1 limb overflow with alias" { | ... | @@ -2680,7 +2680,7 @@ test "big.int regression test for 1 limb overflow with alias" { |
| 2680 | try testing.expect(a.toConst().orderAgainstScalar(19740274219868223167) == .eq); | 2680 | try testing.expect(a.toConst().orderAgainstScalar(19740274219868223167) == .eq); |
| 2681 | } | 2681 | } |
| 2682 | 2682 | ||
| 2683 | test "big.int regression test for realloc with alias" { | 2683 | test "regression test for realloc with alias" { |
| 2684 | // Note these happen to be two consecutive Fibonacci sequence numbers, the | 2684 | // Note these happen to be two consecutive Fibonacci sequence numbers, the |
| 2685 | // second of which is the first such number to exceed 2**192. | 2685 | // second of which is the first such number to exceed 2**192. |
| 2686 | var a = try Managed.initSet(testing.allocator, 5611500259351924431073312796924978741056961814867751431689); | 2686 | var a = try Managed.initSet(testing.allocator, 5611500259351924431073312796924978741056961814867751431689); |
| ... | @@ -3099,7 +3099,7 @@ test "big int byte swap" { | ... | @@ -3099,7 +3099,7 @@ test "big int byte swap" { |
| 3099 | try byteSwapTest(i48, 0x123456789abc, @as(i48, @bitCast(@as(u48, 0xbc9a78563412)))); | 3099 | try byteSwapTest(i48, 0x123456789abc, @as(i48, @bitCast(@as(u48, 0xbc9a78563412)))); |
| 3100 | } | 3100 | } |
| 3101 | 3101 | ||
| 3102 | test "big.int mul multi-multi alias r with a and b" { | 3102 | test "mul multi-multi alias r with a and b" { |
| 3103 | var a = try Managed.initSet(testing.allocator, 2 * maxInt(Limb)); | 3103 | var a = try Managed.initSet(testing.allocator, 2 * maxInt(Limb)); |
| 3104 | defer a.deinit(); | 3104 | defer a.deinit(); |
| 3105 | 3105 | ||
| ... | @@ -3115,7 +3115,7 @@ test "big.int mul multi-multi alias r with a and b" { | ... | @@ -3115,7 +3115,7 @@ test "big.int mul multi-multi alias r with a and b" { |
| 3115 | } | 3115 | } |
| 3116 | } | 3116 | } |
| 3117 | 3117 | ||
| 3118 | test "big.int sqr multi alias r with a" { | 3118 | test "sqr multi alias r with a" { |
| 3119 | var a = try Managed.initSet(testing.allocator, 2 * maxInt(Limb)); | 3119 | var a = try Managed.initSet(testing.allocator, 2 * maxInt(Limb)); |
| 3120 | defer a.deinit(); | 3120 | defer a.deinit(); |
| 3121 | 3121 | ||
| ... | @@ -3131,7 +3131,7 @@ test "big.int sqr multi alias r with a" { | ... | @@ -3131,7 +3131,7 @@ test "big.int sqr multi alias r with a" { |
| 3131 | } | 3131 | } |
| 3132 | } | 3132 | } |
| 3133 | 3133 | ||
| 3134 | test "big.int eql zeroes #17296" { | 3134 | test "eql zeroes #17296" { |
| 3135 | var zero = try Managed.init(testing.allocator); | 3135 | var zero = try Managed.init(testing.allocator); |
| 3136 | defer zero.deinit(); | 3136 | defer zero.deinit(); |
| 3137 | try zero.setString(10, "0"); | 3137 | try zero.setString(10, "0"); |
| ... | @@ -3152,7 +3152,7 @@ test "big.int eql zeroes #17296" { | ... | @@ -3152,7 +3152,7 @@ test "big.int eql zeroes #17296" { |
| 3152 | } | 3152 | } |
| 3153 | } | 3153 | } |
| 3154 | 3154 | ||
| 3155 | test "big.int.Const.order 0 == -0" { | 3155 | test "Const.order 0 == -0" { |
| 3156 | const a = std.math.big.int.Const{ | 3156 | const a = std.math.big.int.Const{ |
| 3157 | .limbs = &.{0}, | 3157 | .limbs = &.{0}, |
| 3158 | .positive = true, | 3158 | .positive = true, |
| ... | @@ -3164,7 +3164,7 @@ test "big.int.Const.order 0 == -0" { | ... | @@ -3164,7 +3164,7 @@ test "big.int.Const.order 0 == -0" { |
| 3164 | try std.testing.expectEqual(std.math.Order.eq, a.order(b)); | 3164 | try std.testing.expectEqual(std.math.Order.eq, a.order(b)); |
| 3165 | } | 3165 | } |
| 3166 | 3166 | ||
| 3167 | test "big.int.Managed sqrt(0) = 0" { | 3167 | test "Managed sqrt(0) = 0" { |
| 3168 | const allocator = testing.allocator; | 3168 | const allocator = testing.allocator; |
| 3169 | var a = try Managed.initSet(allocator, 1); | 3169 | var a = try Managed.initSet(allocator, 1); |
| 3170 | defer a.deinit(); | 3170 | defer a.deinit(); |
| ... | @@ -3178,7 +3178,7 @@ test "big.int.Managed sqrt(0) = 0" { | ... | @@ -3178,7 +3178,7 @@ test "big.int.Managed sqrt(0) = 0" { |
| 3178 | try testing.expectEqual(@as(i32, 0), try res.to(i32)); | 3178 | try testing.expectEqual(@as(i32, 0), try res.to(i32)); |
| 3179 | } | 3179 | } |
| 3180 | 3180 | ||
| 3181 | test "big.int.Managed sqrt(-1) = error" { | 3181 | test "Managed sqrt(-1) = error" { |
| 3182 | const allocator = testing.allocator; | 3182 | const allocator = testing.allocator; |
| 3183 | var a = try Managed.initSet(allocator, 1); | 3183 | var a = try Managed.initSet(allocator, 1); |
| 3184 | defer a.deinit(); | 3184 | defer a.deinit(); |
| ... | @@ -3191,7 +3191,7 @@ test "big.int.Managed sqrt(-1) = error" { | ... | @@ -3191,7 +3191,7 @@ test "big.int.Managed sqrt(-1) = error" { |
| 3191 | try testing.expectError(error.SqrtOfNegativeNumber, res.sqrt(&a)); | 3191 | try testing.expectError(error.SqrtOfNegativeNumber, res.sqrt(&a)); |
| 3192 | } | 3192 | } |
| 3193 | 3193 | ||
| 3194 | test "big.int.Managed sqrt(n) succeed with res.bitCountAbs() >= usize bits" { | 3194 | test "Managed sqrt(n) succeed with res.bitCountAbs() >= usize bits" { |
| 3195 | const allocator = testing.allocator; | 3195 | const allocator = testing.allocator; |
| 3196 | var a = try Managed.initSet(allocator, 1); | 3196 | var a = try Managed.initSet(allocator, 1); |
| 3197 | defer a.deinit(); | 3197 | defer a.deinit(); |
lib/std/math/big/rational.zig+17-17| ... | @@ -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 "big.rational 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 | ||
| ... | @@ -513,7 +513,7 @@ test "big.rational extractLowBits" { | ... | @@ -513,7 +513,7 @@ test "big.rational extractLowBits" { |
| 513 | try testing.expect(a5 == 0x11112222333344441234567887654321); | 513 | try testing.expect(a5 == 0x11112222333344441234567887654321); |
| 514 | } | 514 | } |
| 515 | 515 | ||
| 516 | test "big.rational set" { | 516 | test "set" { |
| 517 | var a = try Rational.init(testing.allocator); | 517 | var a = try Rational.init(testing.allocator); |
| 518 | defer a.deinit(); | 518 | defer a.deinit(); |
| 519 | 519 | ||
| ... | @@ -542,7 +542,7 @@ test "big.rational set" { | ... | @@ -542,7 +542,7 @@ test "big.rational set" { |
| 542 | try testing.expect((try a.q.to(i32)) == 1); | 542 | try testing.expect((try a.q.to(i32)) == 1); |
| 543 | } | 543 | } |
| 544 | 544 | ||
| 545 | test "big.rational setFloat" { | 545 | test "setFloat" { |
| 546 | var a = try Rational.init(testing.allocator); | 546 | var a = try Rational.init(testing.allocator); |
| 547 | defer a.deinit(); | 547 | defer a.deinit(); |
| 548 | 548 | ||
| ... | @@ -567,7 +567,7 @@ test "big.rational setFloat" { | ... | @@ -567,7 +567,7 @@ test "big.rational setFloat" { |
| 567 | try testing.expect((try a.q.to(u128)) == 70368744177664); | 567 | try testing.expect((try a.q.to(u128)) == 70368744177664); |
| 568 | } | 568 | } |
| 569 | 569 | ||
| 570 | test "big.rational setFloatString" { | 570 | test "setFloatString" { |
| 571 | var a = try Rational.init(testing.allocator); | 571 | var a = try Rational.init(testing.allocator); |
| 572 | defer a.deinit(); | 572 | defer a.deinit(); |
| 573 | 573 | ||
| ... | @@ -578,7 +578,7 @@ test "big.rational setFloatString" { | ... | @@ -578,7 +578,7 @@ test "big.rational setFloatString" { |
| 578 | try testing.expect((try a.q.to(u128)) == 100000000000000000000000000000000000); | 578 | try testing.expect((try a.q.to(u128)) == 100000000000000000000000000000000000); |
| 579 | } | 579 | } |
| 580 | 580 | ||
| 581 | test "big.rational toFloat" { | 581 | test "toFloat" { |
| 582 | var a = try Rational.init(testing.allocator); | 582 | var a = try Rational.init(testing.allocator); |
| 583 | defer a.deinit(); | 583 | defer a.deinit(); |
| 584 | 584 | ||
| ... | @@ -591,7 +591,7 @@ test "big.rational toFloat" { | ... | @@ -591,7 +591,7 @@ test "big.rational toFloat" { |
| 591 | try testing.expect((try a.toFloat(f64)) == 72.141593120712409172417410926841290461290467124); | 591 | try testing.expect((try a.toFloat(f64)) == 72.141593120712409172417410926841290461290467124); |
| 592 | } | 592 | } |
| 593 | 593 | ||
| 594 | test "big.rational set/to Float round-trip" { | 594 | test "set/to Float round-trip" { |
| 595 | var a = try Rational.init(testing.allocator); | 595 | var a = try Rational.init(testing.allocator); |
| 596 | defer a.deinit(); | 596 | defer a.deinit(); |
| 597 | var prng = std.Random.DefaultPrng.init(0x5EED); | 597 | var prng = std.Random.DefaultPrng.init(0x5EED); |
| ... | @@ -604,7 +604,7 @@ test "big.rational set/to Float round-trip" { | ... | @@ -604,7 +604,7 @@ test "big.rational set/to Float round-trip" { |
| 604 | } | 604 | } |
| 605 | } | 605 | } |
| 606 | 606 | ||
| 607 | test "big.rational copy" { | 607 | test "copy" { |
| 608 | var a = try Rational.init(testing.allocator); | 608 | var a = try Rational.init(testing.allocator); |
| 609 | defer a.deinit(); | 609 | defer a.deinit(); |
| 610 | 610 | ||
| ... | @@ -634,7 +634,7 @@ test "big.rational copy" { | ... | @@ -634,7 +634,7 @@ test "big.rational copy" { |
| 634 | try testing.expect((try a.q.to(u32)) == 1); | 634 | try testing.expect((try a.q.to(u32)) == 1); |
| 635 | } | 635 | } |
| 636 | 636 | ||
| 637 | test "big.rational negate" { | 637 | test "negate" { |
| 638 | var a = try Rational.init(testing.allocator); | 638 | var a = try Rational.init(testing.allocator); |
| 639 | defer a.deinit(); | 639 | defer a.deinit(); |
| 640 | 640 | ||
| ... | @@ -651,7 +651,7 @@ test "big.rational negate" { | ... | @@ -651,7 +651,7 @@ test "big.rational negate" { |
| 651 | try testing.expect((try a.q.to(i32)) == 1); | 651 | try testing.expect((try a.q.to(i32)) == 1); |
| 652 | } | 652 | } |
| 653 | 653 | ||
| 654 | test "big.rational abs" { | 654 | test "abs" { |
| 655 | var a = try Rational.init(testing.allocator); | 655 | var a = try Rational.init(testing.allocator); |
| 656 | defer a.deinit(); | 656 | defer a.deinit(); |
| 657 | 657 | ||
| ... | @@ -668,7 +668,7 @@ test "big.rational abs" { | ... | @@ -668,7 +668,7 @@ test "big.rational abs" { |
| 668 | try testing.expect((try a.q.to(i32)) == 1); | 668 | try testing.expect((try a.q.to(i32)) == 1); |
| 669 | } | 669 | } |
| 670 | 670 | ||
| 671 | test "big.rational swap" { | 671 | test "swap" { |
| 672 | var a = try Rational.init(testing.allocator); | 672 | var a = try Rational.init(testing.allocator); |
| 673 | defer a.deinit(); | 673 | defer a.deinit(); |
| 674 | var b = try Rational.init(testing.allocator); | 674 | var b = try Rational.init(testing.allocator); |
| ... | @@ -692,7 +692,7 @@ test "big.rational swap" { | ... | @@ -692,7 +692,7 @@ test "big.rational swap" { |
| 692 | try testing.expect((try b.q.to(u32)) == 23); | 692 | try testing.expect((try b.q.to(u32)) == 23); |
| 693 | } | 693 | } |
| 694 | 694 | ||
| 695 | test "big.rational order" { | 695 | test "order" { |
| 696 | var a = try Rational.init(testing.allocator); | 696 | var a = try Rational.init(testing.allocator); |
| 697 | defer a.deinit(); | 697 | defer a.deinit(); |
| 698 | var b = try Rational.init(testing.allocator); | 698 | var b = try Rational.init(testing.allocator); |
| ... | @@ -707,7 +707,7 @@ test "big.rational order" { | ... | @@ -707,7 +707,7 @@ test "big.rational order" { |
| 707 | try testing.expect((try a.order(b)) == .eq); | 707 | try testing.expect((try a.order(b)) == .eq); |
| 708 | } | 708 | } |
| 709 | 709 | ||
| 710 | test "big.rational order/orderAbs with negative" { | 710 | test "order/orderAbs with negative" { |
| 711 | var a = try Rational.init(testing.allocator); | 711 | var a = try Rational.init(testing.allocator); |
| 712 | defer a.deinit(); | 712 | defer a.deinit(); |
| 713 | var b = try Rational.init(testing.allocator); | 713 | var b = try Rational.init(testing.allocator); |
| ... | @@ -719,7 +719,7 @@ test "big.rational order/orderAbs with negative" { | ... | @@ -719,7 +719,7 @@ test "big.rational order/orderAbs with negative" { |
| 719 | try testing.expect((try a.orderAbs(b)) == .lt); | 719 | try testing.expect((try a.orderAbs(b)) == .lt); |
| 720 | } | 720 | } |
| 721 | 721 | ||
| 722 | test "big.rational add single-limb" { | 722 | test "add single-limb" { |
| 723 | var a = try Rational.init(testing.allocator); | 723 | var a = try Rational.init(testing.allocator); |
| 724 | defer a.deinit(); | 724 | defer a.deinit(); |
| 725 | var b = try Rational.init(testing.allocator); | 725 | var b = try Rational.init(testing.allocator); |
| ... | @@ -734,7 +734,7 @@ test "big.rational add single-limb" { | ... | @@ -734,7 +734,7 @@ test "big.rational add single-limb" { |
| 734 | try testing.expect((try a.order(b)) == .eq); | 734 | try testing.expect((try a.order(b)) == .eq); |
| 735 | } | 735 | } |
| 736 | 736 | ||
| 737 | test "big.rational add" { | 737 | test "add" { |
| 738 | var a = try Rational.init(testing.allocator); | 738 | var a = try Rational.init(testing.allocator); |
| 739 | defer a.deinit(); | 739 | defer a.deinit(); |
| 740 | var b = try Rational.init(testing.allocator); | 740 | var b = try Rational.init(testing.allocator); |
| ... | @@ -750,7 +750,7 @@ test "big.rational add" { | ... | @@ -750,7 +750,7 @@ test "big.rational add" { |
| 750 | try testing.expect((try a.order(r)) == .eq); | 750 | try testing.expect((try a.order(r)) == .eq); |
| 751 | } | 751 | } |
| 752 | 752 | ||
| 753 | test "big.rational sub" { | 753 | test "sub" { |
| 754 | var a = try Rational.init(testing.allocator); | 754 | var a = try Rational.init(testing.allocator); |
| 755 | defer a.deinit(); | 755 | defer a.deinit(); |
| 756 | var b = try Rational.init(testing.allocator); | 756 | var b = try Rational.init(testing.allocator); |
| ... | @@ -766,7 +766,7 @@ test "big.rational sub" { | ... | @@ -766,7 +766,7 @@ test "big.rational sub" { |
| 766 | try testing.expect((try a.order(r)) == .eq); | 766 | try testing.expect((try a.order(r)) == .eq); |
| 767 | } | 767 | } |
| 768 | 768 | ||
| 769 | test "big.rational mul" { | 769 | test "mul" { |
| 770 | var a = try Rational.init(testing.allocator); | 770 | var a = try Rational.init(testing.allocator); |
| 771 | defer a.deinit(); | 771 | defer a.deinit(); |
| 772 | var b = try Rational.init(testing.allocator); | 772 | var b = try Rational.init(testing.allocator); |
| ... | @@ -782,7 +782,7 @@ test "big.rational mul" { | ... | @@ -782,7 +782,7 @@ test "big.rational mul" { |
| 782 | try testing.expect((try a.order(r)) == .eq); | 782 | try testing.expect((try a.order(r)) == .eq); |
| 783 | } | 783 | } |
| 784 | 784 | ||
| 785 | test "big.rational div" { | 785 | test "div" { |
| 786 | { | 786 | { |
| 787 | var a = try Rational.init(testing.allocator); | 787 | var a = try Rational.init(testing.allocator); |
| 788 | defer a.deinit(); | 788 | defer a.deinit(); |
lib/std/math/cbrt.zig+5-5| ... | @@ -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 "math.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 "math.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 "math.cbrt32" { | ... | @@ -135,7 +135,7 @@ test "math.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 "math.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))); |
| ... | @@ -146,7 +146,7 @@ test "math.cbrt64" { | ... | @@ -146,7 +146,7 @@ test "math.cbrt64" { |
| 146 | try expect(math.approxEqAbs(f64, cbrt64(123123.234375), 49.748501, epsilon)); | 146 | try expect(math.approxEqAbs(f64, cbrt64(123123.234375), 49.748501, epsilon)); |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | test "math.cbrt.special" { | 149 | test "cbrt.special" { |
| 150 | try expect(math.isPositiveZero(cbrt32(0.0))); | 150 | try expect(math.isPositiveZero(cbrt32(0.0))); |
| 151 | try expect(@as(u32, @bitCast(cbrt32(-0.0))) == @as(u32, 0x80000000)); | 151 | try expect(@as(u32, @bitCast(cbrt32(-0.0))) == @as(u32, 0x80000000)); |
| 152 | try expect(math.isPositiveInf(cbrt32(math.inf(f32)))); | 152 | try expect(math.isPositiveInf(cbrt32(math.inf(f32)))); |
| ... | @@ -154,7 +154,7 @@ test "math.cbrt.special" { | ... | @@ -154,7 +154,7 @@ test "math.cbrt.special" { |
| 154 | try expect(math.isNan(cbrt32(math.nan(f32)))); | 154 | try expect(math.isNan(cbrt32(math.nan(f32)))); |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | test "math.cbrt64.special" { | 157 | test "cbrt64.special" { |
| 158 | try expect(math.isPositiveZero(cbrt64(0.0))); | 158 | try expect(math.isPositiveZero(cbrt64(0.0))); |
| 159 | try expect(math.isNegativeZero(cbrt64(-0.0))); | 159 | try expect(math.isNegativeZero(cbrt64(-0.0))); |
| 160 | try expect(math.isPositiveInf(cbrt64(math.inf(f64)))); | 160 | try expect(math.isPositiveInf(cbrt64(math.inf(f64)))); |
lib/std/math/complex.zig+9-9| ... | @@ -120,7 +120,7 @@ pub fn Complex(comptime T: type) type { | ... | @@ -120,7 +120,7 @@ pub fn Complex(comptime T: type) type { |
| 120 | 120 | ||
| 121 | const epsilon = 0.0001; | 121 | const epsilon = 0.0001; |
| 122 | 122 | ||
| 123 | test "complex.add" { | 123 | test "add" { |
| 124 | const a = Complex(f32).init(5, 3); | 124 | const a = Complex(f32).init(5, 3); |
| 125 | const b = Complex(f32).init(2, 7); | 125 | const b = Complex(f32).init(2, 7); |
| 126 | const c = a.add(b); | 126 | const c = a.add(b); |
| ... | @@ -128,7 +128,7 @@ test "complex.add" { | ... | @@ -128,7 +128,7 @@ test "complex.add" { |
| 128 | try testing.expect(c.re == 7 and c.im == 10); | 128 | try testing.expect(c.re == 7 and c.im == 10); |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | test "complex.sub" { | 131 | test "sub" { |
| 132 | const a = Complex(f32).init(5, 3); | 132 | const a = Complex(f32).init(5, 3); |
| 133 | const b = Complex(f32).init(2, 7); | 133 | const b = Complex(f32).init(2, 7); |
| 134 | const c = a.sub(b); | 134 | const c = a.sub(b); |
| ... | @@ -136,7 +136,7 @@ test "complex.sub" { | ... | @@ -136,7 +136,7 @@ test "complex.sub" { |
| 136 | try testing.expect(c.re == 3 and c.im == -4); | 136 | try testing.expect(c.re == 3 and c.im == -4); |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | test "complex.mul" { | 139 | test "mul" { |
| 140 | const a = Complex(f32).init(5, 3); | 140 | const a = Complex(f32).init(5, 3); |
| 141 | const b = Complex(f32).init(2, 7); | 141 | const b = Complex(f32).init(2, 7); |
| 142 | const c = a.mul(b); | 142 | const c = a.mul(b); |
| ... | @@ -144,7 +144,7 @@ test "complex.mul" { | ... | @@ -144,7 +144,7 @@ test "complex.mul" { |
| 144 | try testing.expect(c.re == -11 and c.im == 41); | 144 | try testing.expect(c.re == -11 and c.im == 41); |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | test "complex.div" { | 147 | test "div" { |
| 148 | const a = Complex(f32).init(5, 3); | 148 | const a = Complex(f32).init(5, 3); |
| 149 | const b = Complex(f32).init(2, 7); | 149 | const b = Complex(f32).init(2, 7); |
| 150 | const c = a.div(b); | 150 | const c = a.div(b); |
| ... | @@ -153,28 +153,28 @@ test "complex.div" { | ... | @@ -153,28 +153,28 @@ test "complex.div" { |
| 153 | math.approxEqAbs(f32, c.im, @as(f32, -29) / 53, epsilon)); | 153 | math.approxEqAbs(f32, c.im, @as(f32, -29) / 53, epsilon)); |
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | test "complex.conjugate" { | 156 | test "conjugate" { |
| 157 | const a = Complex(f32).init(5, 3); | 157 | const a = Complex(f32).init(5, 3); |
| 158 | const c = a.conjugate(); | 158 | const c = a.conjugate(); |
| 159 | 159 | ||
| 160 | try testing.expect(c.re == 5 and c.im == -3); | 160 | try testing.expect(c.re == 5 and c.im == -3); |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | test "complex.neg" { | 163 | test "neg" { |
| 164 | const a = Complex(f32).init(5, 3); | 164 | const a = Complex(f32).init(5, 3); |
| 165 | const c = a.neg(); | 165 | const c = a.neg(); |
| 166 | 166 | ||
| 167 | try testing.expect(c.re == -5 and c.im == -3); | 167 | try testing.expect(c.re == -5 and c.im == -3); |
| 168 | } | 168 | } |
| 169 | 169 | ||
| 170 | test "complex.mulbyi" { | 170 | test "mulbyi" { |
| 171 | const a = Complex(f32).init(5, 3); | 171 | const a = Complex(f32).init(5, 3); |
| 172 | const c = a.mulbyi(); | 172 | const c = a.mulbyi(); |
| 173 | 173 | ||
| 174 | try testing.expect(c.re == -3 and c.im == 5); | 174 | try testing.expect(c.re == -3 and c.im == 5); |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | test "complex.reciprocal" { | 177 | test "reciprocal" { |
| 178 | const a = Complex(f32).init(5, 3); | 178 | const a = Complex(f32).init(5, 3); |
| 179 | const c = a.reciprocal(); | 179 | const c = a.reciprocal(); |
| 180 | 180 | ||
| ... | @@ -182,7 +182,7 @@ test "complex.reciprocal" { | ... | @@ -182,7 +182,7 @@ test "complex.reciprocal" { |
| 182 | math.approxEqAbs(f32, c.im, @as(f32, -3) / 34, epsilon)); | 182 | math.approxEqAbs(f32, c.im, @as(f32, -3) / 34, epsilon)); |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | test "complex.magnitude" { | 185 | test "magnitude" { |
| 186 | const a = Complex(f32).init(5, 3); | 186 | const a = Complex(f32).init(5, 3); |
| 187 | const c = a.magnitude(); | 187 | const c = a.magnitude(); |
| 188 | 188 |
lib/std/math/complex/abs.zig+1-1| ... | @@ -11,7 +11,7 @@ pub fn abs(z: anytype) @TypeOf(z.re, z.im) { | ... | @@ -11,7 +11,7 @@ pub fn abs(z: anytype) @TypeOf(z.re, z.im) { |
| 11 | 11 | ||
| 12 | const epsilon = 0.0001; | 12 | const epsilon = 0.0001; |
| 13 | 13 | ||
| 14 | test "complex.cabs" { | 14 | test abs { |
| 15 | const a = Complex(f32).init(5, 3); | 15 | const a = Complex(f32).init(5, 3); |
| 16 | const c = abs(a); | 16 | const c = abs(a); |
| 17 | try testing.expect(math.approxEqAbs(f32, c, 5.83095, epsilon)); | 17 | try testing.expect(math.approxEqAbs(f32, c, 5.83095, epsilon)); |
lib/std/math/complex/acos.zig+1-1| ... | @@ -13,7 +13,7 @@ pub fn acos(z: anytype) Complex(@TypeOf(z.re, z.im)) { | ... | @@ -13,7 +13,7 @@ pub fn acos(z: anytype) Complex(@TypeOf(z.re, z.im)) { |
| 13 | 13 | ||
| 14 | const epsilon = 0.0001; | 14 | const epsilon = 0.0001; |
| 15 | 15 | ||
| 16 | test "complex.cacos" { | 16 | test acos { |
| 17 | const a = Complex(f32).init(5, 3); | 17 | const a = Complex(f32).init(5, 3); |
| 18 | const c = acos(a); | 18 | const c = acos(a); |
| 19 | 19 |
lib/std/math/complex/acosh.zig+1-1| ... | @@ -13,7 +13,7 @@ pub fn acosh(z: anytype) Complex(@TypeOf(z.re, z.im)) { | ... | @@ -13,7 +13,7 @@ pub fn acosh(z: anytype) Complex(@TypeOf(z.re, z.im)) { |
| 13 | 13 | ||
| 14 | const epsilon = 0.0001; | 14 | const epsilon = 0.0001; |
| 15 | 15 | ||
| 16 | test "complex.cacosh" { | 16 | test acosh { |
| 17 | const a = Complex(f32).init(5, 3); | 17 | const a = Complex(f32).init(5, 3); |
| 18 | const c = acosh(a); | 18 | const c = acosh(a); |
| 19 | 19 |
lib/std/math/complex/arg.zig+1-1| ... | @@ -11,7 +11,7 @@ pub fn arg(z: anytype) @TypeOf(z.re, z.im) { | ... | @@ -11,7 +11,7 @@ pub fn arg(z: anytype) @TypeOf(z.re, z.im) { |
| 11 | 11 | ||
| 12 | const epsilon = 0.0001; | 12 | const epsilon = 0.0001; |
| 13 | 13 | ||
| 14 | test "complex.carg" { | 14 | test arg { |
| 15 | const a = Complex(f32).init(5, 3); | 15 | const a = Complex(f32).init(5, 3); |
| 16 | const c = arg(a); | 16 | const c = arg(a); |
| 17 | try testing.expect(math.approxEqAbs(f32, c, 0.540420, epsilon)); | 17 | try testing.expect(math.approxEqAbs(f32, c, 0.540420, epsilon)); |
lib/std/math/complex/asin.zig+1-1| ... | @@ -19,7 +19,7 @@ pub fn asin(z: anytype) Complex(@TypeOf(z.re, z.im)) { | ... | @@ -19,7 +19,7 @@ pub fn asin(z: anytype) Complex(@TypeOf(z.re, z.im)) { |
| 19 | 19 | ||
| 20 | const epsilon = 0.0001; | 20 | const epsilon = 0.0001; |
| 21 | 21 | ||
| 22 | test "complex.casin" { | 22 | test asin { |
| 23 | const a = Complex(f32).init(5, 3); | 23 | const a = Complex(f32).init(5, 3); |
| 24 | const c = asin(a); | 24 | const c = asin(a); |
| 25 | 25 |
lib/std/math/complex/asinh.zig+1-1| ... | @@ -14,7 +14,7 @@ pub fn asinh(z: anytype) Complex(@TypeOf(z.re, z.im)) { | ... | @@ -14,7 +14,7 @@ pub fn asinh(z: anytype) Complex(@TypeOf(z.re, z.im)) { |
| 14 | 14 | ||
| 15 | const epsilon = 0.0001; | 15 | const epsilon = 0.0001; |
| 16 | 16 | ||
| 17 | test "complex.casinh" { | 17 | test asinh { |
| 18 | const a = Complex(f32).init(5, 3); | 18 | const a = Complex(f32).init(5, 3); |
| 19 | const c = asinh(a); | 19 | const c = asinh(a); |
| 20 | 20 |
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 "complex.catan32" { | 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 "complex.catan32" { | ... | @@ -128,7 +128,7 @@ test "complex.catan32" { |
| 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 "complex.catan64" { | 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 "complex.catanh" { | 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 "complex.conj" { | 13 | test "onj" { |
| 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 "complex.ccos" { | 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 "complex.ccosh32" { | 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 "complex.ccosh32" { | ... | @@ -163,7 +163,7 @@ test "complex.ccosh32" { |
| 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 "complex.ccosh64" { | 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 "complex.cexp32" { | 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 "complex.cexp32" { | ... | @@ -139,7 +139,7 @@ test "complex.cexp32" { |
| 139 | } | 139 | } |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | test "complex.cexp64" { | 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 "complex.clog" { | 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 "complex.cpow" { | 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-1| ... | @@ -17,7 +17,7 @@ pub fn proj(z: anytype) Complex(@TypeOf(z.re, z.im)) { | ... | @@ -17,7 +17,7 @@ pub fn proj(z: anytype) Complex(@TypeOf(z.re, z.im)) { |
| 17 | 17 | ||
| 18 | const epsilon = 0.0001; | 18 | const epsilon = 0.0001; |
| 19 | 19 | ||
| 20 | test "complex.cproj" { | 20 | test "proj" { |
| 21 | const a = Complex(f32).init(5, 3); | 21 | const a = Complex(f32).init(5, 3); |
| 22 | const c = proj(a); | 22 | const c = proj(a); |
| 23 | 23 |
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 "complex.csin" { | 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 "complex.csinh32" { | 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 "complex.csinh32" { | ... | @@ -162,7 +162,7 @@ test "complex.csinh32" { |
| 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 "complex.csinh64" { | 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 "complex.csqrt32" { | 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 "complex.csqrt32" { | ... | @@ -137,7 +137,7 @@ test "complex.csqrt32" { |
| 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 "complex.csqrt64" { | 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 "complex.ctan" { | 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 "complex.ctanh32" { | 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 "complex.ctanh32" { | ... | @@ -111,7 +111,7 @@ test "complex.ctanh32" { |
| 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 "complex.ctanh64" { | 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/copysign.zig+1-1| ... | @@ -12,7 +12,7 @@ pub fn copysign(magnitude: anytype, sign: @TypeOf(magnitude)) @TypeOf(magnitude) | ... | @@ -12,7 +12,7 @@ pub fn copysign(magnitude: anytype, sign: @TypeOf(magnitude)) @TypeOf(magnitude) |
| 12 | return @as(T, @bitCast(mag | sgn)); | 12 | return @as(T, @bitCast(mag | sgn)); |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | test "math.copysign" { | 15 | test copysign { |
| 16 | inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { | 16 | inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { |
| 17 | try expect(copysign(@as(T, 1.0), @as(T, 1.0)) == 1.0); | 17 | try expect(copysign(@as(T, 1.0), @as(T, 1.0)) == 1.0); |
| 18 | try expect(copysign(@as(T, 2.0), @as(T, -2.0)) == -2.0); | 18 | try expect(copysign(@as(T, 2.0), @as(T, -2.0)) == -2.0); |
lib/std/math/cosh.zig+5-5| ... | @@ -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 "math.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 "math.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 "math.cosh32" { | ... | @@ -104,7 +104,7 @@ test "math.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 "math.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)); |
| ... | @@ -117,7 +117,7 @@ test "math.cosh64" { | ... | @@ -117,7 +117,7 @@ test "math.cosh64" { |
| 117 | try expect(math.approxEqAbs(f64, cosh64(-1.5), 2.352410, epsilon)); | 117 | try expect(math.approxEqAbs(f64, cosh64(-1.5), 2.352410, epsilon)); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | test "math.cosh32.special" { | 120 | test "cosh32.special" { |
| 121 | try expect(cosh32(0.0) == 1.0); | 121 | try expect(cosh32(0.0) == 1.0); |
| 122 | try expect(cosh32(-0.0) == 1.0); | 122 | try expect(cosh32(-0.0) == 1.0); |
| 123 | try expect(math.isPositiveInf(cosh32(math.inf(f32)))); | 123 | try expect(math.isPositiveInf(cosh32(math.inf(f32)))); |
| ... | @@ -125,7 +125,7 @@ test "math.cosh32.special" { | ... | @@ -125,7 +125,7 @@ test "math.cosh32.special" { |
| 125 | try expect(math.isNan(cosh32(math.nan(f32)))); | 125 | try expect(math.isNan(cosh32(math.nan(f32)))); |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | test "math.cosh64.special" { | 128 | test "cosh64.special" { |
| 129 | try expect(cosh64(0.0) == 1.0); | 129 | try expect(cosh64(0.0) == 1.0); |
| 130 | try expect(cosh64(-0.0) == 1.0); | 130 | try expect(cosh64(-0.0) == 1.0); |
| 131 | try expect(math.isPositiveInf(cosh64(math.inf(f64)))); | 131 | try expect(math.isPositiveInf(cosh64(math.inf(f64)))); |
lib/std/math/expm1.zig+5-5| ... | @@ -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 "math.exp1m" { | 289 | test "exp1m" { |
| 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 "math.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 "math.expm1_32" { | ... | @@ -301,7 +301,7 @@ test "math.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 "math.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))); |
| ... | @@ -311,13 +311,13 @@ test "math.expm1_64" { | ... | @@ -311,13 +311,13 @@ test "math.expm1_64" { |
| 311 | try expect(math.approxEqAbs(f64, expm1_64(1.5), 3.481689, epsilon)); | 311 | try expect(math.approxEqAbs(f64, expm1_64(1.5), 3.481689, epsilon)); |
| 312 | } | 312 | } |
| 313 | 313 | ||
| 314 | test "math.expm1_32.special" { | 314 | test "expm1_32.special" { |
| 315 | try expect(math.isPositiveInf(expm1_32(math.inf(f32)))); | 315 | try expect(math.isPositiveInf(expm1_32(math.inf(f32)))); |
| 316 | try expect(expm1_32(-math.inf(f32)) == -1.0); | 316 | try expect(expm1_32(-math.inf(f32)) == -1.0); |
| 317 | try expect(math.isNan(expm1_32(math.nan(f32)))); | 317 | try expect(math.isNan(expm1_32(math.nan(f32)))); |
| 318 | } | 318 | } |
| 319 | 319 | ||
| 320 | test "math.expm1_64.special" { | 320 | test "expm1_64.special" { |
| 321 | try expect(math.isPositiveInf(expm1_64(math.inf(f64)))); | 321 | try expect(math.isPositiveInf(expm1_64(math.inf(f64)))); |
| 322 | try expect(expm1_64(-math.inf(f64)) == -1.0); | 322 | try expect(expm1_64(-math.inf(f64)) == -1.0); |
| 323 | try expect(math.isNan(expm1_64(math.nan(f64)))); | 323 | try expect(math.isNan(expm1_64(math.nan(f64)))); |
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 "math.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 "math.inf" { | ... | @@ -145,7 +145,7 @@ test "math.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 "math.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 "math.nan" { | ... | @@ -158,7 +158,7 @@ test "math.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 "math.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+4-4| ... | @@ -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 "math.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); |
| ... | @@ -261,7 +261,7 @@ test "math.gamma" { | ... | @@ -261,7 +261,7 @@ test "math.gamma" { |
| 261 | } | 261 | } |
| 262 | } | 262 | } |
| 263 | 263 | ||
| 264 | test "math.gamma.special" { | 264 | test "gamma.special" { |
| 265 | inline for (&.{ f32, f64 }) |T| { | 265 | inline for (&.{ f32, f64 }) |T| { |
| 266 | try expect(std.math.isNan(gamma(T, -std.math.nan(T)))); | 266 | try expect(std.math.isNan(gamma(T, -std.math.nan(T)))); |
| 267 | try expect(std.math.isNan(gamma(T, std.math.nan(T)))); | 267 | try expect(std.math.isNan(gamma(T, std.math.nan(T)))); |
| ... | @@ -286,7 +286,7 @@ test "math.gamma.special" { | ... | @@ -286,7 +286,7 @@ test "math.gamma.special" { |
| 286 | } | 286 | } |
| 287 | } | 287 | } |
| 288 | 288 | ||
| 289 | test "math.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); |
| ... | @@ -307,7 +307,7 @@ test "math.lgamma" { | ... | @@ -307,7 +307,7 @@ test "math.lgamma" { |
| 307 | } | 307 | } |
| 308 | } | 308 | } |
| 309 | 309 | ||
| 310 | test "math.lgamma.special" { | 310 | test "lgamma.special" { |
| 311 | inline for (&.{ f32, f64 }) |T| { | 311 | inline for (&.{ f32, f64 }) |T| { |
| 312 | try expect(std.math.isNan(lgamma(T, -std.math.nan(T)))); | 312 | try expect(std.math.isNan(lgamma(T, -std.math.nan(T)))); |
| 313 | try expect(std.math.isNan(lgamma(T, std.math.nan(T)))); | 313 | try expect(std.math.isNan(lgamma(T, std.math.nan(T)))); |
lib/std/math/hypot.zig+5-5| ... | @@ -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 "math.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 "math.hypot" { | ... | @@ -133,7 +133,7 @@ test "math.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 "math.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 "math.hypot32" { | ... | @@ -145,7 +145,7 @@ test "math.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 "math.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)); |
| ... | @@ -157,7 +157,7 @@ test "math.hypot64" { | ... | @@ -157,7 +157,7 @@ test "math.hypot64" { |
| 157 | try expect(math.approxEqAbs(f64, hypot64(123123.234375, 529428.707813), 543556.885247, epsilon)); | 157 | try expect(math.approxEqAbs(f64, hypot64(123123.234375, 529428.707813), 543556.885247, epsilon)); |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | test "math.hypot32.special" { | 160 | test "hypot32.special" { |
| 161 | try expect(math.isPositiveInf(hypot32(math.inf(f32), 0.0))); | 161 | try expect(math.isPositiveInf(hypot32(math.inf(f32), 0.0))); |
| 162 | try expect(math.isPositiveInf(hypot32(-math.inf(f32), 0.0))); | 162 | try expect(math.isPositiveInf(hypot32(-math.inf(f32), 0.0))); |
| 163 | try expect(math.isPositiveInf(hypot32(0.0, math.inf(f32)))); | 163 | try expect(math.isPositiveInf(hypot32(0.0, math.inf(f32)))); |
| ... | @@ -166,7 +166,7 @@ test "math.hypot32.special" { | ... | @@ -166,7 +166,7 @@ test "math.hypot32.special" { |
| 166 | try expect(math.isNan(hypot32(0.0, math.nan(f32)))); | 166 | try expect(math.isNan(hypot32(0.0, math.nan(f32)))); |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | test "math.hypot64.special" { | 169 | test "hypot64.special" { |
| 170 | try expect(math.isPositiveInf(hypot64(math.inf(f64), 0.0))); | 170 | try expect(math.isPositiveInf(hypot64(math.inf(f64), 0.0))); |
| 171 | try expect(math.isPositiveInf(hypot64(-math.inf(f64), 0.0))); | 171 | try expect(math.isPositiveInf(hypot64(-math.inf(f64), 0.0))); |
| 172 | try expect(math.isPositiveInf(hypot64(0.0, math.inf(f64)))); | 172 | try expect(math.isPositiveInf(hypot64(0.0, math.inf(f64)))); |
lib/std/math/isfinite.zig+1-1| ... | @@ -10,7 +10,7 @@ pub fn isFinite(x: anytype) bool { | ... | @@ -10,7 +10,7 @@ pub fn isFinite(x: anytype) bool { |
| 10 | return @as(TBits, @bitCast(x)) & remove_sign < @as(TBits, @bitCast(math.inf(T))); | 10 | return @as(TBits, @bitCast(x)) & remove_sign < @as(TBits, @bitCast(math.inf(T))); |
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | test "math.isFinite" { | 13 | test isFinite { |
| 14 | inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { | 14 | inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { |
| 15 | // normals | 15 | // normals |
| 16 | try expect(isFinite(@as(T, 1.0))); | 16 | try expect(isFinite(@as(T, 1.0))); |
lib/std/math/isinf.zig+3-3| ... | @@ -20,7 +20,7 @@ pub inline fn isNegativeInf(x: anytype) bool { | ... | @@ -20,7 +20,7 @@ pub inline fn isNegativeInf(x: anytype) bool { |
| 20 | return x == -math.inf(@TypeOf(x)); | 20 | return x == -math.inf(@TypeOf(x)); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | test "math.isInf" { | 23 | test isInf { |
| 24 | inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { | 24 | inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { |
| 25 | try expect(!isInf(@as(T, 0.0))); | 25 | try expect(!isInf(@as(T, 0.0))); |
| 26 | try expect(!isInf(@as(T, -0.0))); | 26 | try expect(!isInf(@as(T, -0.0))); |
| ... | @@ -31,7 +31,7 @@ test "math.isInf" { | ... | @@ -31,7 +31,7 @@ test "math.isInf" { |
| 31 | } | 31 | } |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | test "math.isPositiveInf" { | 34 | test isPositiveInf { |
| 35 | inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { | 35 | inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { |
| 36 | try expect(!isPositiveInf(@as(T, 0.0))); | 36 | try expect(!isPositiveInf(@as(T, 0.0))); |
| 37 | try expect(!isPositiveInf(@as(T, -0.0))); | 37 | try expect(!isPositiveInf(@as(T, -0.0))); |
| ... | @@ -42,7 +42,7 @@ test "math.isPositiveInf" { | ... | @@ -42,7 +42,7 @@ test "math.isPositiveInf" { |
| 42 | } | 42 | } |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | test "math.isNegativeInf" { | 45 | test isNegativeInf { |
| 46 | inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { | 46 | inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { |
| 47 | try expect(!isNegativeInf(@as(T, 0.0))); | 47 | try expect(!isNegativeInf(@as(T, 0.0))); |
| 48 | try expect(!isNegativeInf(@as(T, -0.0))); | 48 | try expect(!isNegativeInf(@as(T, -0.0))); |
lib/std/math/isnan.zig+2-2| ... | @@ -17,7 +17,7 @@ pub fn isSignalNan(x: anytype) bool { | ... | @@ -17,7 +17,7 @@ pub fn isSignalNan(x: anytype) bool { |
| 17 | return isNan(x) and (@as(U, @bitCast(x)) & quiet_signal_bit_mask == 0); | 17 | return isNan(x) and (@as(U, @bitCast(x)) & quiet_signal_bit_mask == 0); |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | test "math.isNan" { | 20 | test isNan { |
| 21 | inline for ([_]type{ f16, f32, f64, f80, f128, c_longdouble }) |T| { | 21 | inline for ([_]type{ f16, f32, f64, f80, f128, c_longdouble }) |T| { |
| 22 | try expect(isNan(math.nan(T))); | 22 | try expect(isNan(math.nan(T))); |
| 23 | try expect(isNan(-math.nan(T))); | 23 | try expect(isNan(-math.nan(T))); |
| ... | @@ -27,7 +27,7 @@ test "math.isNan" { | ... | @@ -27,7 +27,7 @@ test "math.isNan" { |
| 27 | } | 27 | } |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | test "math.isSignalNan" { | 30 | test isSignalNan { |
| 31 | inline for ([_]type{ f16, f32, f64, f80, f128, c_longdouble }) |T| { | 31 | inline for ([_]type{ f16, f32, f64, f80, f128, c_longdouble }) |T| { |
| 32 | // TODO: Signalling NaN values get converted to quiet NaN values in | 32 | // TODO: Signalling NaN values get converted to quiet NaN values in |
| 33 | // some cases where they shouldn't such that this can fail. | 33 | // some cases where they shouldn't such that this can fail. |
lib/std/math/isnormal.zig+1-1| ... | @@ -19,7 +19,7 @@ pub fn isNormal(x: anytype) bool { | ... | @@ -19,7 +19,7 @@ pub fn isNormal(x: anytype) bool { |
| 19 | return value & remove_sign >= (increment_exp << 1); | 19 | return value & remove_sign >= (increment_exp << 1); |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | test "math.isNormal" { | 22 | test isNormal { |
| 23 | // TODO add `c_longdouble' when math.inf(T) supports it | 23 | // TODO add `c_longdouble' when math.inf(T) supports it |
| 24 | inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { | 24 | inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { |
| 25 | const TBits = std.meta.Int(.unsigned, @bitSizeOf(T)); | 25 | const TBits = std.meta.Int(.unsigned, @bitSizeOf(T)); |
lib/std/math/ldexp.zig+1-1| ... | @@ -66,7 +66,7 @@ pub fn ldexp(x: anytype, n: i32) @TypeOf(x) { | ... | @@ -66,7 +66,7 @@ pub fn ldexp(x: anytype, n: i32) @TypeOf(x) { |
| 66 | } | 66 | } |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | test "math.ldexp" { | 69 | test ldexp { |
| 70 | // subnormals | 70 | // subnormals |
| 71 | try expect(ldexp(@as(f16, 0x1.1FFp14), -14 - 9 - 15) == math.floatTrueMin(f16)); | 71 | try expect(ldexp(@as(f16, 0x1.1FFp14), -14 - 9 - 15) == math.floatTrueMin(f16)); |
| 72 | try expect(ldexp(@as(f32, 0x1.3FFFFFp-1), -126 - 22) == math.floatTrueMin(f32)); | 72 | try expect(ldexp(@as(f32, 0x1.3FFFFFp-1), -126 - 22) == math.floatTrueMin(f32)); |
lib/std/math/log.zig+3-3| ... | @@ -47,7 +47,7 @@ pub fn log(comptime T: type, base: T, x: T) T { | ... | @@ -47,7 +47,7 @@ pub fn log(comptime T: type, base: T, x: T) T { |
| 47 | } | 47 | } |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | test "math.log integer" { | 50 | test "log integer" { |
| 51 | try expect(log(u8, 2, 0x1) == 0); | 51 | try expect(log(u8, 2, 0x1) == 0); |
| 52 | try expect(log(u8, 2, 0x2) == 1); | 52 | try expect(log(u8, 2, 0x2) == 1); |
| 53 | try expect(log(u16, 2, 0x72) == 6); | 53 | try expect(log(u16, 2, 0x72) == 6); |
| ... | @@ -55,7 +55,7 @@ test "math.log integer" { | ... | @@ -55,7 +55,7 @@ test "math.log integer" { |
| 55 | try expect(log(u64, 2, 0x7FF0123456789ABC) == 62); | 55 | try expect(log(u64, 2, 0x7FF0123456789ABC) == 62); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | test "math.log float" { | 58 | test "log float" { |
| 59 | const epsilon = 0.000001; | 59 | const epsilon = 0.000001; |
| 60 | 60 | ||
| 61 | try expect(math.approxEqAbs(f32, log(f32, 6, 0.23947), -0.797723, epsilon)); | 61 | try expect(math.approxEqAbs(f32, log(f32, 6, 0.23947), -0.797723, epsilon)); |
| ... | @@ -63,7 +63,7 @@ test "math.log float" { | ... | @@ -63,7 +63,7 @@ test "math.log float" { |
| 63 | try expect(math.approxEqAbs(f64, log(f64, 123897, 12389216414), 1.981724596, epsilon)); | 63 | try expect(math.approxEqAbs(f64, log(f64, 123897, 12389216414), 1.981724596, epsilon)); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | test "math.log float_special" { | 66 | test "log float_special" { |
| 67 | try expect(log(f32, 2, 0.2301974) == math.log2(@as(f32, 0.2301974))); | 67 | try expect(log(f32, 2, 0.2301974) == math.log2(@as(f32, 0.2301974))); |
| 68 | try expect(log(f32, 10, 0.2301974) == math.log10(@as(f32, 0.2301974))); | 68 | try expect(log(f32, 10, 0.2301974) == math.log10(@as(f32, 0.2301974))); |
| 69 | 69 |
lib/std/math/log1p.zig+5-5| ... | @@ -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 "math.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 "math.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 "math.log1p_32" { | ... | @@ -199,7 +199,7 @@ test "math.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 "math.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)); |
| ... | @@ -211,7 +211,7 @@ test "math.log1p_64" { | ... | @@ -211,7 +211,7 @@ test "math.log1p_64" { |
| 211 | try expect(math.approxEqAbs(f64, log1p_64(123123.234375), 11.720949, epsilon)); | 211 | try expect(math.approxEqAbs(f64, log1p_64(123123.234375), 11.720949, epsilon)); |
| 212 | } | 212 | } |
| 213 | 213 | ||
| 214 | test "math.log1p_32.special" { | 214 | test "log1p_32.special" { |
| 215 | try expect(math.isPositiveInf(log1p_32(math.inf(f32)))); | 215 | try expect(math.isPositiveInf(log1p_32(math.inf(f32)))); |
| 216 | try expect(math.isPositiveZero(log1p_32(0.0))); | 216 | try expect(math.isPositiveZero(log1p_32(0.0))); |
| 217 | try expect(math.isNegativeZero(log1p_32(-0.0))); | 217 | try expect(math.isNegativeZero(log1p_32(-0.0))); |
| ... | @@ -220,7 +220,7 @@ test "math.log1p_32.special" { | ... | @@ -220,7 +220,7 @@ test "math.log1p_32.special" { |
| 220 | try expect(math.isNan(log1p_32(math.nan(f32)))); | 220 | try expect(math.isNan(log1p_32(math.nan(f32)))); |
| 221 | } | 221 | } |
| 222 | 222 | ||
| 223 | test "math.log1p_64.special" { | 223 | test "log1p_64.special" { |
| 224 | try expect(math.isPositiveInf(log1p_64(math.inf(f64)))); | 224 | try expect(math.isPositiveInf(log1p_64(math.inf(f64)))); |
| 225 | try expect(math.isPositiveZero(log1p_64(0.0))); | 225 | try expect(math.isPositiveZero(log1p_64(0.0))); |
| 226 | try expect(math.isNegativeZero(log1p_64(-0.0))); | 226 | try expect(math.isNegativeZero(log1p_64(-0.0))); |
lib/std/math/log_int.zig+4-4| ... | @@ -60,7 +60,7 @@ pub fn log_int(comptime T: type, base: T, x: T) Log2Int(T) { | ... | @@ -60,7 +60,7 @@ pub fn log_int(comptime T: type, base: T, x: T) Log2Int(T) { |
| 60 | return exponent; | 60 | return exponent; |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | test "math.log_int" { | 63 | test "log_int" { |
| 64 | // Test all unsigned integers with 2, 3, ..., 64 bits. | 64 | // Test all unsigned integers with 2, 3, ..., 64 bits. |
| 65 | // We cannot test 0 or 1 bits since base must be > 1. | 65 | // We cannot test 0 or 1 bits since base must be > 1. |
| 66 | inline for (2..64 + 1) |bits| { | 66 | inline for (2..64 + 1) |bits| { |
| ... | @@ -92,7 +92,7 @@ test "math.log_int" { | ... | @@ -92,7 +92,7 @@ test "math.log_int" { |
| 92 | } | 92 | } |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | test "math.log_int vs math.log2" { | 95 | test "log_int vs math.log2" { |
| 96 | const types = [_]type{ u2, u3, u4, u8, u16 }; | 96 | const types = [_]type{ u2, u3, u4, u8, u16 }; |
| 97 | inline for (types) |T| { | 97 | inline for (types) |T| { |
| 98 | var n: T = 0; | 98 | var n: T = 0; |
| ... | @@ -105,7 +105,7 @@ test "math.log_int vs math.log2" { | ... | @@ -105,7 +105,7 @@ test "math.log_int vs math.log2" { |
| 105 | } | 105 | } |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | test "math.log_int vs math.log10" { | 108 | test "log_int vs math.log10" { |
| 109 | const types = [_]type{ u4, u5, u6, u8, u16 }; | 109 | const types = [_]type{ u4, u5, u6, u8, u16 }; |
| 110 | inline for (types) |T| { | 110 | inline for (types) |T| { |
| 111 | var n: T = 0; | 111 | var n: T = 0; |
| ... | @@ -118,7 +118,7 @@ test "math.log_int vs math.log10" { | ... | @@ -118,7 +118,7 @@ test "math.log_int vs math.log10" { |
| 118 | } | 118 | } |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | test "math.log_int at comptime" { | 121 | test "log_int at comptime" { |
| 122 | const x = 59049; // 9 ** 5; | 122 | const x = 59049; // 9 ** 5; |
| 123 | comptime { | 123 | comptime { |
| 124 | if (math.log_int(comptime_int, 9, x) != 5) { | 124 | if (math.log_int(comptime_int, 9, x) != 5) { |
lib/std/math/modf.zig+5-5| ... | @@ -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 "math.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 "math.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 "math.modf32" { | ... | @@ -155,7 +155,7 @@ test "math.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 "math.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 | ||
| ... | @@ -180,7 +180,7 @@ test "math.modf64" { | ... | @@ -180,7 +180,7 @@ test "math.modf64" { |
| 180 | try expect(math.approxEqAbs(f64, r.fpart, 0.340780, epsilon)); | 180 | try expect(math.approxEqAbs(f64, r.fpart, 0.340780, epsilon)); |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | test "math.modf32.special" { | 183 | test "modf32.special" { |
| 184 | var r: modf32_result = undefined; | 184 | var r: modf32_result = undefined; |
| 185 | 185 | ||
| 186 | r = modf32(math.inf(f32)); | 186 | r = modf32(math.inf(f32)); |
| ... | @@ -193,7 +193,7 @@ test "math.modf32.special" { | ... | @@ -193,7 +193,7 @@ test "math.modf32.special" { |
| 193 | try expect(math.isNan(r.ipart) and math.isNan(r.fpart)); | 193 | try expect(math.isNan(r.ipart) and math.isNan(r.fpart)); |
| 194 | } | 194 | } |
| 195 | 195 | ||
| 196 | test "math.modf64.special" { | 196 | test "modf64.special" { |
| 197 | var r: modf64_result = undefined; | 197 | var r: modf64_result = undefined; |
| 198 | 198 | ||
| 199 | r = modf64(math.inf(f64)); | 199 | r = modf64(math.inf(f64)); |
lib/std/math/nextafter.zig+2-2| ... | @@ -101,7 +101,7 @@ fn nextAfterFloat(comptime T: type, x: T, y: T) T { | ... | @@ -101,7 +101,7 @@ fn nextAfterFloat(comptime T: type, x: T, y: T) T { |
| 101 | } | 101 | } |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | test "math.nextAfter.int" { | 104 | test "int" { |
| 105 | try expect(nextAfter(i0, 0, 0) == 0); | 105 | try expect(nextAfter(i0, 0, 0) == 0); |
| 106 | try expect(nextAfter(u0, 0, 0) == 0); | 106 | try expect(nextAfter(u0, 0, 0) == 0); |
| 107 | try expect(nextAfter(i1, 0, 0) == 0); | 107 | try expect(nextAfter(i1, 0, 0) == 0); |
| ... | @@ -143,7 +143,7 @@ test "math.nextAfter.int" { | ... | @@ -143,7 +143,7 @@ test "math.nextAfter.int" { |
| 143 | } | 143 | } |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | test "math.nextAfter.float" { | 146 | test "float" { |
| 147 | @setEvalBranchQuota(2000); | 147 | @setEvalBranchQuota(2000); |
| 148 | 148 | ||
| 149 | // normal -> normal | 149 | // normal -> normal |
lib/std/math/pow.zig+4-4| ... | @@ -190,7 +190,7 @@ fn isOddInteger(x: f64) bool { | ... | @@ -190,7 +190,7 @@ fn isOddInteger(x: f64) bool { |
| 190 | return r.fpart == 0.0 and @as(i64, @intFromFloat(r.ipart)) & 1 == 1; | 190 | return r.fpart == 0.0 and @as(i64, @intFromFloat(r.ipart)) & 1 == 1; |
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | test "math.pow.isOddInteger" { | 193 | test isOddInteger { |
| 194 | try expect(isOddInteger(math.maxInt(i64) * 2) == false); | 194 | try expect(isOddInteger(math.maxInt(i64) * 2) == false); |
| 195 | try expect(isOddInteger(math.maxInt(i64) * 2 + 1) == false); | 195 | try expect(isOddInteger(math.maxInt(i64) * 2 + 1) == false); |
| 196 | try expect(isOddInteger(1 << 53) == false); | 196 | try expect(isOddInteger(1 << 53) == false); |
| ... | @@ -198,7 +198,7 @@ test "math.pow.isOddInteger" { | ... | @@ -198,7 +198,7 @@ test "math.pow.isOddInteger" { |
| 198 | try expect(isOddInteger(15.0) == true); | 198 | try expect(isOddInteger(15.0) == true); |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | test "math.pow" { | 201 | test pow { |
| 202 | const epsilon = 0.000001; | 202 | const epsilon = 0.000001; |
| 203 | 203 | ||
| 204 | try expect(math.approxEqAbs(f32, pow(f32, 0.0, 3.3), 0.0, epsilon)); | 204 | try expect(math.approxEqAbs(f32, pow(f32, 0.0, 3.3), 0.0, epsilon)); |
| ... | @@ -216,7 +216,7 @@ test "math.pow" { | ... | @@ -216,7 +216,7 @@ test "math.pow" { |
| 216 | try expect(math.approxEqAbs(f64, pow(f64, 89.123, 3.3), 2722490.231436, epsilon)); | 216 | try expect(math.approxEqAbs(f64, pow(f64, 89.123, 3.3), 2722490.231436, epsilon)); |
| 217 | } | 217 | } |
| 218 | 218 | ||
| 219 | test "math.pow.special" { | 219 | test "special" { |
| 220 | const epsilon = 0.000001; | 220 | const epsilon = 0.000001; |
| 221 | 221 | ||
| 222 | try expect(pow(f32, 4, 0.0) == 1.0); | 222 | try expect(pow(f32, 4, 0.0) == 1.0); |
| ... | @@ -258,7 +258,7 @@ test "math.pow.special" { | ... | @@ -258,7 +258,7 @@ test "math.pow.special" { |
| 258 | try expect(math.isNan(pow(f32, -12.4, 78.5))); | 258 | try expect(math.isNan(pow(f32, -12.4, 78.5))); |
| 259 | } | 259 | } |
| 260 | 260 | ||
| 261 | test "math.pow.overflow" { | 261 | test "overflow" { |
| 262 | try expect(math.isPositiveInf(pow(f64, 2, 1 << 32))); | 262 | try expect(math.isPositiveInf(pow(f64, 2, 1 << 32))); |
| 263 | try expect(pow(f64, 2, -(1 << 32)) == 0); | 263 | try expect(pow(f64, 2, -(1 << 32)) == 0); |
| 264 | try expect(math.isNegativeInf(pow(f64, -2, (1 << 32) + 1))); | 264 | try expect(math.isNegativeInf(pow(f64, -2, (1 << 32) + 1))); |
lib/std/math/powi.zig+3-3| ... | @@ -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 "math.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)); |
| ... | @@ -141,7 +141,7 @@ test "math.powi" { | ... | @@ -141,7 +141,7 @@ test "math.powi" { |
| 141 | try testing.expectError(error.Underflow, powi(i42, 34, -6)); | 141 | try testing.expectError(error.Underflow, powi(i42, 34, -6)); |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | test "math.powi.special" { | 144 | test "powi.special" { |
| 145 | try testing.expectError(error.Overflow, powi(i8, -2, 8)); | 145 | try testing.expectError(error.Overflow, powi(i8, -2, 8)); |
| 146 | try testing.expectError(error.Overflow, powi(i16, -2, 16)); | 146 | try testing.expectError(error.Overflow, powi(i16, -2, 16)); |
| 147 | try testing.expectError(error.Overflow, powi(i32, -2, 32)); | 147 | try testing.expectError(error.Overflow, powi(i32, -2, 32)); |
| ... | @@ -186,7 +186,7 @@ test "math.powi.special" { | ... | @@ -186,7 +186,7 @@ test "math.powi.special" { |
| 186 | try testing.expect((try powi(u42, 34, 0)) == 1); | 186 | try testing.expect((try powi(u42, 34, 0)) == 1); |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | test "math.powi.narrow" { | 189 | test "powi.narrow" { |
| 190 | try testing.expectError(error.Overflow, powi(u0, 0, 0)); | 190 | try testing.expectError(error.Overflow, powi(u0, 0, 0)); |
| 191 | try testing.expectError(error.Overflow, powi(i0, 0, 0)); | 191 | try testing.expectError(error.Overflow, powi(i0, 0, 0)); |
| 192 | try testing.expectError(error.Overflow, powi(i1, 0, 0)); | 192 | try testing.expectError(error.Overflow, powi(i1, 0, 0)); |
lib/std/math/scalbn.zig+1-1| ... | @@ -6,7 +6,7 @@ const expect = std.testing.expect; | ... | @@ -6,7 +6,7 @@ const expect = std.testing.expect; |
| 6 | /// Zig only supports binary base IEEE-754 floats. Hence FLT_RADIX=2, and this is an alias for ldexp. | 6 | /// Zig only supports binary base IEEE-754 floats. Hence FLT_RADIX=2, and this is an alias for ldexp. |
| 7 | pub const scalbn = @import("ldexp.zig").ldexp; | 7 | pub const scalbn = @import("ldexp.zig").ldexp; |
| 8 | 8 | ||
| 9 | test "math.scalbn" { | 9 | test scalbn { |
| 10 | // Verify we are using base 2. | 10 | // Verify we are using base 2. |
| 11 | try expect(scalbn(@as(f16, 1.5), 4) == 24.0); | 11 | try expect(scalbn(@as(f16, 1.5), 4) == 24.0); |
| 12 | try expect(scalbn(@as(f32, 1.5), 4) == 24.0); | 12 | try expect(scalbn(@as(f32, 1.5), 4) == 24.0); |
lib/std/math/signbit.zig+1-1| ... | @@ -9,7 +9,7 @@ pub fn signbit(x: anytype) bool { | ... | @@ -9,7 +9,7 @@ pub fn signbit(x: anytype) bool { |
| 9 | return @as(TBits, @bitCast(x)) >> (@bitSizeOf(T) - 1) != 0; | 9 | return @as(TBits, @bitCast(x)) >> (@bitSizeOf(T) - 1) != 0; |
| 10 | } | 10 | } |
| 11 | 11 | ||
| 12 | test "math.signbit" { | 12 | test signbit { |
| 13 | inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { | 13 | inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { |
| 14 | try expect(!signbit(@as(T, 0.0))); | 14 | try expect(!signbit(@as(T, 0.0))); |
| 15 | try expect(!signbit(@as(T, 1.0))); | 15 | try expect(!signbit(@as(T, 1.0))); |
lib/std/math/sinh.zig+5-5| ... | @@ -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 "math.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 "math.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 "math.sinh32" { | ... | @@ -109,7 +109,7 @@ test "math.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 "math.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)); |
| ... | @@ -122,7 +122,7 @@ test "math.sinh64" { | ... | @@ -122,7 +122,7 @@ test "math.sinh64" { |
| 122 | try expect(math.approxEqAbs(f64, sinh64(-1.5), -2.129279, epsilon)); | 122 | try expect(math.approxEqAbs(f64, sinh64(-1.5), -2.129279, epsilon)); |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | test "math.sinh32.special" { | 125 | test "sinh32.special" { |
| 126 | try expect(math.isPositiveZero(sinh32(0.0))); | 126 | try expect(math.isPositiveZero(sinh32(0.0))); |
| 127 | try expect(math.isNegativeZero(sinh32(-0.0))); | 127 | try expect(math.isNegativeZero(sinh32(-0.0))); |
| 128 | try expect(math.isPositiveInf(sinh32(math.inf(f32)))); | 128 | try expect(math.isPositiveInf(sinh32(math.inf(f32)))); |
| ... | @@ -130,7 +130,7 @@ test "math.sinh32.special" { | ... | @@ -130,7 +130,7 @@ test "math.sinh32.special" { |
| 130 | try expect(math.isNan(sinh32(math.nan(f32)))); | 130 | try expect(math.isNan(sinh32(math.nan(f32)))); |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | test "math.sinh64.special" { | 133 | test "sinh64.special" { |
| 134 | try expect(math.isPositiveZero(sinh64(0.0))); | 134 | try expect(math.isPositiveZero(sinh64(0.0))); |
| 135 | try expect(math.isNegativeZero(sinh64(-0.0))); | 135 | try expect(math.isNegativeZero(sinh64(-0.0))); |
| 136 | try expect(math.isPositiveInf(sinh64(math.inf(f64)))); | 136 | try expect(math.isPositiveInf(sinh64(math.inf(f64)))); |
lib/std/math/sqrt.zig+1-1| ... | @@ -61,7 +61,7 @@ fn sqrt_int(comptime T: type, value: T) Sqrt(T) { | ... | @@ -61,7 +61,7 @@ fn sqrt_int(comptime T: type, value: T) Sqrt(T) { |
| 61 | } | 61 | } |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | test "math.sqrt_int" { | 64 | test sqrt_int { |
| 65 | try expect(sqrt_int(u32, 3) == 1); | 65 | try expect(sqrt_int(u32, 3) == 1); |
| 66 | try expect(sqrt_int(u32, 4) == 2); | 66 | try expect(sqrt_int(u32, 4) == 2); |
| 67 | try expect(sqrt_int(u32, 5) == 2); | 67 | try expect(sqrt_int(u32, 5) == 2); |
lib/std/math/tanh.zig+5-5| ... | @@ -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 "math.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 "math.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 "math.tanh32" { | ... | @@ -122,7 +122,7 @@ test "math.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 "math.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)); |
| ... | @@ -135,7 +135,7 @@ test "math.tanh64" { | ... | @@ -135,7 +135,7 @@ test "math.tanh64" { |
| 135 | try expect(math.approxEqAbs(f64, tanh64(-37.45), -1.0, epsilon)); | 135 | try expect(math.approxEqAbs(f64, tanh64(-37.45), -1.0, epsilon)); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | test "math.tanh32.special" { | 138 | test "tanh32.special" { |
| 139 | try expect(math.isPositiveZero(tanh32(0.0))); | 139 | try expect(math.isPositiveZero(tanh32(0.0))); |
| 140 | try expect(math.isNegativeZero(tanh32(-0.0))); | 140 | try expect(math.isNegativeZero(tanh32(-0.0))); |
| 141 | try expect(tanh32(math.inf(f32)) == 1.0); | 141 | try expect(tanh32(math.inf(f32)) == 1.0); |
| ... | @@ -143,7 +143,7 @@ test "math.tanh32.special" { | ... | @@ -143,7 +143,7 @@ test "math.tanh32.special" { |
| 143 | try expect(math.isNan(tanh32(math.nan(f32)))); | 143 | try expect(math.isNan(tanh32(math.nan(f32)))); |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | test "math.tanh64.special" { | 146 | test "tanh64.special" { |
| 147 | try expect(math.isPositiveZero(tanh64(0.0))); | 147 | try expect(math.isPositiveZero(tanh64(0.0))); |
| 148 | try expect(math.isNegativeZero(tanh64(-0.0))); | 148 | try expect(math.isNegativeZero(tanh64(-0.0))); |
| 149 | try expect(tanh64(math.inf(f64)) == 1.0); | 149 | try expect(tanh64(math.inf(f64)) == 1.0); |
lib/std/meta.zig+19-19| ... | @@ -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 "std.meta.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 "std.meta.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 "std.meta.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 "std.meta.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 "std.meta.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 "std.meta.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 "std.meta.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 "std.meta.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 "std.meta.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 "std.meta.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 "std.meta.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 "std.meta.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 "std.meta.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 "std.meta.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 "std.meta.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 "std.meta.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 "std.meta.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 "std.meta.eql" { | 805 | test "eql" { |
| 806 | const S = struct { | 806 | const S = struct { |
| 807 | a: u32, | 807 | a: u32, |
| 808 | b: f64, | 808 | b: f64, |
| ... | @@ -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 "std.meta.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)); |
lib/std/os/test.zig+1-1| ... | @@ -393,7 +393,7 @@ fn testThreadIdFn(thread_id: *Thread.Id) void { | ... | @@ -393,7 +393,7 @@ fn testThreadIdFn(thread_id: *Thread.Id) void { |
| 393 | thread_id.* = Thread.getCurrentId(); | 393 | thread_id.* = Thread.getCurrentId(); |
| 394 | } | 394 | } |
| 395 | 395 | ||
| 396 | test "std.Thread.getCurrentId" { | 396 | test "Thread.getCurrentId" { |
| 397 | if (builtin.single_threaded) return error.SkipZigTest; | 397 | if (builtin.single_threaded) return error.SkipZigTest; |
| 398 | 398 | ||
| 399 | var thread_current_id: Thread.Id = undefined; | 399 | var thread_current_id: Thread.Id = undefined; |
lib/std/priority_dequeue.zig+31-31| ... | @@ -467,7 +467,7 @@ fn lessThanComparison(context: void, a: u32, b: u32) Order { | ... | @@ -467,7 +467,7 @@ fn lessThanComparison(context: void, a: u32, b: u32) Order { |
| 467 | 467 | ||
| 468 | const PDQ = PriorityDequeue(u32, void, lessThanComparison); | 468 | const PDQ = PriorityDequeue(u32, void, lessThanComparison); |
| 469 | 469 | ||
| 470 | test "std.PriorityDequeue: add and remove min" { | 470 | test "add and remove min" { |
| 471 | var queue = PDQ.init(testing.allocator, {}); | 471 | var queue = PDQ.init(testing.allocator, {}); |
| 472 | defer queue.deinit(); | 472 | defer queue.deinit(); |
| 473 | 473 | ||
| ... | @@ -486,7 +486,7 @@ test "std.PriorityDequeue: add and remove min" { | ... | @@ -486,7 +486,7 @@ test "std.PriorityDequeue: add and remove min" { |
| 486 | try expectEqual(@as(u32, 54), queue.removeMin()); | 486 | try expectEqual(@as(u32, 54), queue.removeMin()); |
| 487 | } | 487 | } |
| 488 | 488 | ||
| 489 | test "std.PriorityDequeue: add and remove min structs" { | 489 | test "add and remove min structs" { |
| 490 | const S = struct { | 490 | const S = struct { |
| 491 | size: u32, | 491 | size: u32, |
| 492 | }; | 492 | }; |
| ... | @@ -513,7 +513,7 @@ test "std.PriorityDequeue: add and remove min structs" { | ... | @@ -513,7 +513,7 @@ test "std.PriorityDequeue: add and remove min structs" { |
| 513 | try expectEqual(@as(u32, 54), queue.removeMin().size); | 513 | try expectEqual(@as(u32, 54), queue.removeMin().size); |
| 514 | } | 514 | } |
| 515 | 515 | ||
| 516 | test "std.PriorityDequeue: add and remove max" { | 516 | test "add and remove max" { |
| 517 | var queue = PDQ.init(testing.allocator, {}); | 517 | var queue = PDQ.init(testing.allocator, {}); |
| 518 | defer queue.deinit(); | 518 | defer queue.deinit(); |
| 519 | 519 | ||
| ... | @@ -532,7 +532,7 @@ test "std.PriorityDequeue: add and remove max" { | ... | @@ -532,7 +532,7 @@ test "std.PriorityDequeue: add and remove max" { |
| 532 | try expectEqual(@as(u32, 7), queue.removeMax()); | 532 | try expectEqual(@as(u32, 7), queue.removeMax()); |
| 533 | } | 533 | } |
| 534 | 534 | ||
| 535 | test "std.PriorityDequeue: add and remove same min" { | 535 | test "add and remove same min" { |
| 536 | var queue = PDQ.init(testing.allocator, {}); | 536 | var queue = PDQ.init(testing.allocator, {}); |
| 537 | defer queue.deinit(); | 537 | defer queue.deinit(); |
| 538 | 538 | ||
| ... | @@ -551,7 +551,7 @@ test "std.PriorityDequeue: add and remove same min" { | ... | @@ -551,7 +551,7 @@ test "std.PriorityDequeue: add and remove same min" { |
| 551 | try expectEqual(@as(u32, 2), queue.removeMin()); | 551 | try expectEqual(@as(u32, 2), queue.removeMin()); |
| 552 | } | 552 | } |
| 553 | 553 | ||
| 554 | test "std.PriorityDequeue: add and remove same max" { | 554 | test "add and remove same max" { |
| 555 | var queue = PDQ.init(testing.allocator, {}); | 555 | var queue = PDQ.init(testing.allocator, {}); |
| 556 | defer queue.deinit(); | 556 | defer queue.deinit(); |
| 557 | 557 | ||
| ... | @@ -570,7 +570,7 @@ test "std.PriorityDequeue: add and remove same max" { | ... | @@ -570,7 +570,7 @@ test "std.PriorityDequeue: add and remove same max" { |
| 570 | try expectEqual(@as(u32, 1), queue.removeMax()); | 570 | try expectEqual(@as(u32, 1), queue.removeMax()); |
| 571 | } | 571 | } |
| 572 | 572 | ||
| 573 | test "std.PriorityDequeue: removeOrNull empty" { | 573 | test "removeOrNull empty" { |
| 574 | var queue = PDQ.init(testing.allocator, {}); | 574 | var queue = PDQ.init(testing.allocator, {}); |
| 575 | defer queue.deinit(); | 575 | defer queue.deinit(); |
| 576 | 576 | ||
| ... | @@ -578,7 +578,7 @@ test "std.PriorityDequeue: removeOrNull empty" { | ... | @@ -578,7 +578,7 @@ test "std.PriorityDequeue: removeOrNull empty" { |
| 578 | try expect(queue.removeMaxOrNull() == null); | 578 | try expect(queue.removeMaxOrNull() == null); |
| 579 | } | 579 | } |
| 580 | 580 | ||
| 581 | test "std.PriorityDequeue: edge case 3 elements" { | 581 | test "edge case 3 elements" { |
| 582 | var queue = PDQ.init(testing.allocator, {}); | 582 | var queue = PDQ.init(testing.allocator, {}); |
| 583 | defer queue.deinit(); | 583 | defer queue.deinit(); |
| 584 | 584 | ||
| ... | @@ -591,7 +591,7 @@ test "std.PriorityDequeue: edge case 3 elements" { | ... | @@ -591,7 +591,7 @@ test "std.PriorityDequeue: edge case 3 elements" { |
| 591 | try expectEqual(@as(u32, 9), queue.removeMin()); | 591 | try expectEqual(@as(u32, 9), queue.removeMin()); |
| 592 | } | 592 | } |
| 593 | 593 | ||
| 594 | test "std.PriorityDequeue: edge case 3 elements max" { | 594 | test "edge case 3 elements max" { |
| 595 | var queue = PDQ.init(testing.allocator, {}); | 595 | var queue = PDQ.init(testing.allocator, {}); |
| 596 | defer queue.deinit(); | 596 | defer queue.deinit(); |
| 597 | 597 | ||
| ... | @@ -604,7 +604,7 @@ test "std.PriorityDequeue: edge case 3 elements max" { | ... | @@ -604,7 +604,7 @@ test "std.PriorityDequeue: edge case 3 elements max" { |
| 604 | try expectEqual(@as(u32, 2), queue.removeMax()); | 604 | try expectEqual(@as(u32, 2), queue.removeMax()); |
| 605 | } | 605 | } |
| 606 | 606 | ||
| 607 | test "std.PriorityDequeue: peekMin" { | 607 | test "peekMin" { |
| 608 | var queue = PDQ.init(testing.allocator, {}); | 608 | var queue = PDQ.init(testing.allocator, {}); |
| 609 | defer queue.deinit(); | 609 | defer queue.deinit(); |
| 610 | 610 | ||
| ... | @@ -618,7 +618,7 @@ test "std.PriorityDequeue: peekMin" { | ... | @@ -618,7 +618,7 @@ test "std.PriorityDequeue: peekMin" { |
| 618 | try expect(queue.peekMin().? == 2); | 618 | try expect(queue.peekMin().? == 2); |
| 619 | } | 619 | } |
| 620 | 620 | ||
| 621 | test "std.PriorityDequeue: peekMax" { | 621 | test "peekMax" { |
| 622 | var queue = PDQ.init(testing.allocator, {}); | 622 | var queue = PDQ.init(testing.allocator, {}); |
| 623 | defer queue.deinit(); | 623 | defer queue.deinit(); |
| 624 | 624 | ||
| ... | @@ -632,7 +632,7 @@ test "std.PriorityDequeue: peekMax" { | ... | @@ -632,7 +632,7 @@ test "std.PriorityDequeue: peekMax" { |
| 632 | try expect(queue.peekMax().? == 9); | 632 | try expect(queue.peekMax().? == 9); |
| 633 | } | 633 | } |
| 634 | 634 | ||
| 635 | test "std.PriorityDequeue: sift up with odd indices, removeMin" { | 635 | test "sift up with odd indices, removeMin" { |
| 636 | var queue = PDQ.init(testing.allocator, {}); | 636 | var queue = PDQ.init(testing.allocator, {}); |
| 637 | defer queue.deinit(); | 637 | defer queue.deinit(); |
| 638 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; | 638 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; |
| ... | @@ -646,7 +646,7 @@ test "std.PriorityDequeue: sift up with odd indices, removeMin" { | ... | @@ -646,7 +646,7 @@ test "std.PriorityDequeue: sift up with odd indices, removeMin" { |
| 646 | } | 646 | } |
| 647 | } | 647 | } |
| 648 | 648 | ||
| 649 | test "std.PriorityDequeue: sift up with odd indices, removeMax" { | 649 | test "sift up with odd indices, removeMax" { |
| 650 | var queue = PDQ.init(testing.allocator, {}); | 650 | var queue = PDQ.init(testing.allocator, {}); |
| 651 | defer queue.deinit(); | 651 | defer queue.deinit(); |
| 652 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; | 652 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; |
| ... | @@ -660,7 +660,7 @@ test "std.PriorityDequeue: sift up with odd indices, removeMax" { | ... | @@ -660,7 +660,7 @@ test "std.PriorityDequeue: sift up with odd indices, removeMax" { |
| 660 | } | 660 | } |
| 661 | } | 661 | } |
| 662 | 662 | ||
| 663 | test "std.PriorityDequeue: addSlice min" { | 663 | test "addSlice min" { |
| 664 | var queue = PDQ.init(testing.allocator, {}); | 664 | var queue = PDQ.init(testing.allocator, {}); |
| 665 | defer queue.deinit(); | 665 | defer queue.deinit(); |
| 666 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; | 666 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; |
| ... | @@ -672,7 +672,7 @@ test "std.PriorityDequeue: addSlice min" { | ... | @@ -672,7 +672,7 @@ test "std.PriorityDequeue: addSlice min" { |
| 672 | } | 672 | } |
| 673 | } | 673 | } |
| 674 | 674 | ||
| 675 | test "std.PriorityDequeue: addSlice max" { | 675 | test "addSlice max" { |
| 676 | var queue = PDQ.init(testing.allocator, {}); | 676 | var queue = PDQ.init(testing.allocator, {}); |
| 677 | defer queue.deinit(); | 677 | defer queue.deinit(); |
| 678 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; | 678 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; |
| ... | @@ -684,7 +684,7 @@ test "std.PriorityDequeue: addSlice max" { | ... | @@ -684,7 +684,7 @@ test "std.PriorityDequeue: addSlice max" { |
| 684 | } | 684 | } |
| 685 | } | 685 | } |
| 686 | 686 | ||
| 687 | test "std.PriorityDequeue: fromOwnedSlice trivial case 0" { | 687 | test "fromOwnedSlice trivial case 0" { |
| 688 | const items = [0]u32{}; | 688 | const items = [0]u32{}; |
| 689 | const queue_items = try testing.allocator.dupe(u32, &items); | 689 | const queue_items = try testing.allocator.dupe(u32, &items); |
| 690 | var queue = PDQ.fromOwnedSlice(testing.allocator, queue_items[0..], {}); | 690 | var queue = PDQ.fromOwnedSlice(testing.allocator, queue_items[0..], {}); |
| ... | @@ -693,7 +693,7 @@ test "std.PriorityDequeue: fromOwnedSlice trivial case 0" { | ... | @@ -693,7 +693,7 @@ test "std.PriorityDequeue: fromOwnedSlice trivial case 0" { |
| 693 | try expect(queue.removeMinOrNull() == null); | 693 | try expect(queue.removeMinOrNull() == null); |
| 694 | } | 694 | } |
| 695 | 695 | ||
| 696 | test "std.PriorityDequeue: fromOwnedSlice trivial case 1" { | 696 | test "fromOwnedSlice trivial case 1" { |
| 697 | const items = [1]u32{1}; | 697 | const items = [1]u32{1}; |
| 698 | const queue_items = try testing.allocator.dupe(u32, &items); | 698 | const queue_items = try testing.allocator.dupe(u32, &items); |
| 699 | var queue = PDQ.fromOwnedSlice(testing.allocator, queue_items[0..], {}); | 699 | var queue = PDQ.fromOwnedSlice(testing.allocator, queue_items[0..], {}); |
| ... | @@ -704,7 +704,7 @@ test "std.PriorityDequeue: fromOwnedSlice trivial case 1" { | ... | @@ -704,7 +704,7 @@ test "std.PriorityDequeue: fromOwnedSlice trivial case 1" { |
| 704 | try expect(queue.removeMinOrNull() == null); | 704 | try expect(queue.removeMinOrNull() == null); |
| 705 | } | 705 | } |
| 706 | 706 | ||
| 707 | test "std.PriorityDequeue: fromOwnedSlice" { | 707 | test "fromOwnedSlice" { |
| 708 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; | 708 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; |
| 709 | const queue_items = try testing.allocator.dupe(u32, items[0..]); | 709 | const queue_items = try testing.allocator.dupe(u32, items[0..]); |
| 710 | var queue = PDQ.fromOwnedSlice(testing.allocator, queue_items[0..], {}); | 710 | var queue = PDQ.fromOwnedSlice(testing.allocator, queue_items[0..], {}); |
| ... | @@ -716,7 +716,7 @@ test "std.PriorityDequeue: fromOwnedSlice" { | ... | @@ -716,7 +716,7 @@ test "std.PriorityDequeue: fromOwnedSlice" { |
| 716 | } | 716 | } |
| 717 | } | 717 | } |
| 718 | 718 | ||
| 719 | test "std.PriorityDequeue: update min queue" { | 719 | test "update min queue" { |
| 720 | var queue = PDQ.init(testing.allocator, {}); | 720 | var queue = PDQ.init(testing.allocator, {}); |
| 721 | defer queue.deinit(); | 721 | defer queue.deinit(); |
| 722 | 722 | ||
| ... | @@ -731,7 +731,7 @@ test "std.PriorityDequeue: update min queue" { | ... | @@ -731,7 +731,7 @@ test "std.PriorityDequeue: update min queue" { |
| 731 | try expectEqual(@as(u32, 5), queue.removeMin()); | 731 | try expectEqual(@as(u32, 5), queue.removeMin()); |
| 732 | } | 732 | } |
| 733 | 733 | ||
| 734 | test "std.PriorityDequeue: update same min queue" { | 734 | test "update same min queue" { |
| 735 | var queue = PDQ.init(testing.allocator, {}); | 735 | var queue = PDQ.init(testing.allocator, {}); |
| 736 | defer queue.deinit(); | 736 | defer queue.deinit(); |
| 737 | 737 | ||
| ... | @@ -747,7 +747,7 @@ test "std.PriorityDequeue: update same min queue" { | ... | @@ -747,7 +747,7 @@ test "std.PriorityDequeue: update same min queue" { |
| 747 | try expectEqual(@as(u32, 5), queue.removeMin()); | 747 | try expectEqual(@as(u32, 5), queue.removeMin()); |
| 748 | } | 748 | } |
| 749 | 749 | ||
| 750 | test "std.PriorityDequeue: update max queue" { | 750 | test "update max queue" { |
| 751 | var queue = PDQ.init(testing.allocator, {}); | 751 | var queue = PDQ.init(testing.allocator, {}); |
| 752 | defer queue.deinit(); | 752 | defer queue.deinit(); |
| 753 | 753 | ||
| ... | @@ -763,7 +763,7 @@ test "std.PriorityDequeue: update max queue" { | ... | @@ -763,7 +763,7 @@ test "std.PriorityDequeue: update max queue" { |
| 763 | try expectEqual(@as(u32, 1), queue.removeMax()); | 763 | try expectEqual(@as(u32, 1), queue.removeMax()); |
| 764 | } | 764 | } |
| 765 | 765 | ||
| 766 | test "std.PriorityDequeue: update same max queue" { | 766 | test "update same max queue" { |
| 767 | var queue = PDQ.init(testing.allocator, {}); | 767 | var queue = PDQ.init(testing.allocator, {}); |
| 768 | defer queue.deinit(); | 768 | defer queue.deinit(); |
| 769 | 769 | ||
| ... | @@ -779,7 +779,7 @@ test "std.PriorityDequeue: update same max queue" { | ... | @@ -779,7 +779,7 @@ test "std.PriorityDequeue: update same max queue" { |
| 779 | try expectEqual(@as(u32, 1), queue.removeMax()); | 779 | try expectEqual(@as(u32, 1), queue.removeMax()); |
| 780 | } | 780 | } |
| 781 | 781 | ||
| 782 | test "std.PriorityDequeue: update after remove" { | 782 | test "update after remove" { |
| 783 | var queue = PDQ.init(testing.allocator, {}); | 783 | var queue = PDQ.init(testing.allocator, {}); |
| 784 | defer queue.deinit(); | 784 | defer queue.deinit(); |
| 785 | 785 | ||
| ... | @@ -788,7 +788,7 @@ test "std.PriorityDequeue: update after remove" { | ... | @@ -788,7 +788,7 @@ test "std.PriorityDequeue: update after remove" { |
| 788 | try expectError(error.ElementNotFound, queue.update(1, 1)); | 788 | try expectError(error.ElementNotFound, queue.update(1, 1)); |
| 789 | } | 789 | } |
| 790 | 790 | ||
| 791 | test "std.PriorityDequeue: iterator" { | 791 | test "iterator" { |
| 792 | var queue = PDQ.init(testing.allocator, {}); | 792 | var queue = PDQ.init(testing.allocator, {}); |
| 793 | var map = std.AutoHashMap(u32, void).init(testing.allocator); | 793 | var map = std.AutoHashMap(u32, void).init(testing.allocator); |
| 794 | defer { | 794 | defer { |
| ... | @@ -810,7 +810,7 @@ test "std.PriorityDequeue: iterator" { | ... | @@ -810,7 +810,7 @@ test "std.PriorityDequeue: iterator" { |
| 810 | try expectEqual(@as(usize, 0), map.count()); | 810 | try expectEqual(@as(usize, 0), map.count()); |
| 811 | } | 811 | } |
| 812 | 812 | ||
| 813 | test "std.PriorityDequeue: remove at index" { | 813 | test "remove at index" { |
| 814 | var queue = PDQ.init(testing.allocator, {}); | 814 | var queue = PDQ.init(testing.allocator, {}); |
| 815 | defer queue.deinit(); | 815 | defer queue.deinit(); |
| 816 | 816 | ||
| ... | @@ -833,7 +833,7 @@ test "std.PriorityDequeue: remove at index" { | ... | @@ -833,7 +833,7 @@ test "std.PriorityDequeue: remove at index" { |
| 833 | try expectEqual(queue.removeMinOrNull(), null); | 833 | try expectEqual(queue.removeMinOrNull(), null); |
| 834 | } | 834 | } |
| 835 | 835 | ||
| 836 | test "std.PriorityDequeue: iterator while empty" { | 836 | test "iterator while empty" { |
| 837 | var queue = PDQ.init(testing.allocator, {}); | 837 | var queue = PDQ.init(testing.allocator, {}); |
| 838 | defer queue.deinit(); | 838 | defer queue.deinit(); |
| 839 | 839 | ||
| ... | @@ -842,7 +842,7 @@ test "std.PriorityDequeue: iterator while empty" { | ... | @@ -842,7 +842,7 @@ test "std.PriorityDequeue: iterator while empty" { |
| 842 | try expectEqual(it.next(), null); | 842 | try expectEqual(it.next(), null); |
| 843 | } | 843 | } |
| 844 | 844 | ||
| 845 | test "std.PriorityDequeue: shrinkAndFree" { | 845 | test "shrinkAndFree" { |
| 846 | var queue = PDQ.init(testing.allocator, {}); | 846 | var queue = PDQ.init(testing.allocator, {}); |
| 847 | defer queue.deinit(); | 847 | defer queue.deinit(); |
| 848 | 848 | ||
| ... | @@ -865,7 +865,7 @@ test "std.PriorityDequeue: shrinkAndFree" { | ... | @@ -865,7 +865,7 @@ test "std.PriorityDequeue: shrinkAndFree" { |
| 865 | try expect(queue.removeMaxOrNull() == null); | 865 | try expect(queue.removeMaxOrNull() == null); |
| 866 | } | 866 | } |
| 867 | 867 | ||
| 868 | test "std.PriorityDequeue: fuzz testing min" { | 868 | test "fuzz testing min" { |
| 869 | var prng = std.Random.DefaultPrng.init(0x12345678); | 869 | var prng = std.Random.DefaultPrng.init(0x12345678); |
| 870 | const random = prng.random(); | 870 | const random = prng.random(); |
| 871 | 871 | ||
| ... | @@ -894,7 +894,7 @@ fn fuzzTestMin(rng: std.Random, comptime queue_size: usize) !void { | ... | @@ -894,7 +894,7 @@ fn fuzzTestMin(rng: std.Random, comptime queue_size: usize) !void { |
| 894 | } | 894 | } |
| 895 | } | 895 | } |
| 896 | 896 | ||
| 897 | test "std.PriorityDequeue: fuzz testing max" { | 897 | test "fuzz testing max" { |
| 898 | var prng = std.Random.DefaultPrng.init(0x87654321); | 898 | var prng = std.Random.DefaultPrng.init(0x87654321); |
| 899 | const random = prng.random(); | 899 | const random = prng.random(); |
| 900 | 900 | ||
| ... | @@ -923,7 +923,7 @@ fn fuzzTestMax(rng: std.Random, queue_size: usize) !void { | ... | @@ -923,7 +923,7 @@ fn fuzzTestMax(rng: std.Random, queue_size: usize) !void { |
| 923 | } | 923 | } |
| 924 | } | 924 | } |
| 925 | 925 | ||
| 926 | test "std.PriorityDequeue: fuzz testing min and max" { | 926 | test "fuzz testing min and max" { |
| 927 | var prng = std.Random.DefaultPrng.init(0x87654321); | 927 | var prng = std.Random.DefaultPrng.init(0x87654321); |
| 928 | const random = prng.random(); | 928 | const random = prng.random(); |
| 929 | 929 | ||
| ... | @@ -982,7 +982,7 @@ fn contextLessThanComparison(context: []const u32, a: usize, b: usize) Order { | ... | @@ -982,7 +982,7 @@ fn contextLessThanComparison(context: []const u32, a: usize, b: usize) Order { |
| 982 | 982 | ||
| 983 | const CPDQ = PriorityDequeue(usize, []const u32, contextLessThanComparison); | 983 | const CPDQ = PriorityDequeue(usize, []const u32, contextLessThanComparison); |
| 984 | 984 | ||
| 985 | test "std.PriorityDequeue: add and remove" { | 985 | test "add and remove" { |
| 986 | const context = [_]u32{ 5, 3, 4, 2, 2, 8, 0 }; | 986 | const context = [_]u32{ 5, 3, 4, 2, 2, 8, 0 }; |
| 987 | 987 | ||
| 988 | var queue = CPDQ.init(testing.allocator, context[0..]); | 988 | var queue = CPDQ.init(testing.allocator, context[0..]); |
| ... | @@ -1006,7 +1006,7 @@ test "std.PriorityDequeue: add and remove" { | ... | @@ -1006,7 +1006,7 @@ test "std.PriorityDequeue: add and remove" { |
| 1006 | 1006 | ||
| 1007 | var all_cmps_unique = true; | 1007 | var all_cmps_unique = true; |
| 1008 | 1008 | ||
| 1009 | test "std.PriorityDeque: don't compare a value to a copy of itself" { | 1009 | test "don't compare a value to a copy of itself" { |
| 1010 | var depq = PriorityDequeue(u32, void, struct { | 1010 | var depq = PriorityDequeue(u32, void, struct { |
| 1011 | fn uniqueLessThan(_: void, a: u32, b: u32) Order { | 1011 | fn uniqueLessThan(_: void, a: u32, b: u32) Order { |
| 1012 | all_cmps_unique = all_cmps_unique and (a != b); | 1012 | all_cmps_unique = all_cmps_unique and (a != b); |
lib/std/priority_queue.zig+23-23| ... | @@ -271,7 +271,7 @@ fn greaterThan(context: void, a: u32, b: u32) Order { | ... | @@ -271,7 +271,7 @@ fn greaterThan(context: void, a: u32, b: u32) Order { |
| 271 | const PQlt = PriorityQueue(u32, void, lessThan); | 271 | const PQlt = PriorityQueue(u32, void, lessThan); |
| 272 | const PQgt = PriorityQueue(u32, void, greaterThan); | 272 | const PQgt = PriorityQueue(u32, void, greaterThan); |
| 273 | 273 | ||
| 274 | test "std.PriorityQueue: add and remove min heap" { | 274 | test "add and remove min heap" { |
| 275 | var queue = PQlt.init(testing.allocator, {}); | 275 | var queue = PQlt.init(testing.allocator, {}); |
| 276 | defer queue.deinit(); | 276 | defer queue.deinit(); |
| 277 | 277 | ||
| ... | @@ -289,7 +289,7 @@ test "std.PriorityQueue: add and remove min heap" { | ... | @@ -289,7 +289,7 @@ test "std.PriorityQueue: add and remove min heap" { |
| 289 | try expectEqual(@as(u32, 54), queue.remove()); | 289 | try expectEqual(@as(u32, 54), queue.remove()); |
| 290 | } | 290 | } |
| 291 | 291 | ||
| 292 | test "std.PriorityQueue: add and remove same min heap" { | 292 | test "add and remove same min heap" { |
| 293 | var queue = PQlt.init(testing.allocator, {}); | 293 | var queue = PQlt.init(testing.allocator, {}); |
| 294 | defer queue.deinit(); | 294 | defer queue.deinit(); |
| 295 | 295 | ||
| ... | @@ -307,14 +307,14 @@ test "std.PriorityQueue: add and remove same min heap" { | ... | @@ -307,14 +307,14 @@ test "std.PriorityQueue: add and remove same min heap" { |
| 307 | try expectEqual(@as(u32, 2), queue.remove()); | 307 | try expectEqual(@as(u32, 2), queue.remove()); |
| 308 | } | 308 | } |
| 309 | 309 | ||
| 310 | test "std.PriorityQueue: removeOrNull on empty" { | 310 | test "removeOrNull on empty" { |
| 311 | var queue = PQlt.init(testing.allocator, {}); | 311 | var queue = PQlt.init(testing.allocator, {}); |
| 312 | defer queue.deinit(); | 312 | defer queue.deinit(); |
| 313 | 313 | ||
| 314 | try expect(queue.removeOrNull() == null); | 314 | try expect(queue.removeOrNull() == null); |
| 315 | } | 315 | } |
| 316 | 316 | ||
| 317 | test "std.PriorityQueue: edge case 3 elements" { | 317 | test "edge case 3 elements" { |
| 318 | var queue = PQlt.init(testing.allocator, {}); | 318 | var queue = PQlt.init(testing.allocator, {}); |
| 319 | defer queue.deinit(); | 319 | defer queue.deinit(); |
| 320 | 320 | ||
| ... | @@ -326,7 +326,7 @@ test "std.PriorityQueue: edge case 3 elements" { | ... | @@ -326,7 +326,7 @@ test "std.PriorityQueue: edge case 3 elements" { |
| 326 | try expectEqual(@as(u32, 9), queue.remove()); | 326 | try expectEqual(@as(u32, 9), queue.remove()); |
| 327 | } | 327 | } |
| 328 | 328 | ||
| 329 | test "std.PriorityQueue: peek" { | 329 | test "peek" { |
| 330 | var queue = PQlt.init(testing.allocator, {}); | 330 | var queue = PQlt.init(testing.allocator, {}); |
| 331 | defer queue.deinit(); | 331 | defer queue.deinit(); |
| 332 | 332 | ||
| ... | @@ -338,7 +338,7 @@ test "std.PriorityQueue: peek" { | ... | @@ -338,7 +338,7 @@ test "std.PriorityQueue: peek" { |
| 338 | try expectEqual(@as(u32, 2), queue.peek().?); | 338 | try expectEqual(@as(u32, 2), queue.peek().?); |
| 339 | } | 339 | } |
| 340 | 340 | ||
| 341 | test "std.PriorityQueue: sift up with odd indices" { | 341 | test "sift up with odd indices" { |
| 342 | var queue = PQlt.init(testing.allocator, {}); | 342 | var queue = PQlt.init(testing.allocator, {}); |
| 343 | defer queue.deinit(); | 343 | defer queue.deinit(); |
| 344 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; | 344 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; |
| ... | @@ -352,7 +352,7 @@ test "std.PriorityQueue: sift up with odd indices" { | ... | @@ -352,7 +352,7 @@ test "std.PriorityQueue: sift up with odd indices" { |
| 352 | } | 352 | } |
| 353 | } | 353 | } |
| 354 | 354 | ||
| 355 | test "std.PriorityQueue: addSlice" { | 355 | test "addSlice" { |
| 356 | var queue = PQlt.init(testing.allocator, {}); | 356 | var queue = PQlt.init(testing.allocator, {}); |
| 357 | defer queue.deinit(); | 357 | defer queue.deinit(); |
| 358 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; | 358 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; |
| ... | @@ -364,7 +364,7 @@ test "std.PriorityQueue: addSlice" { | ... | @@ -364,7 +364,7 @@ test "std.PriorityQueue: addSlice" { |
| 364 | } | 364 | } |
| 365 | } | 365 | } |
| 366 | 366 | ||
| 367 | test "std.PriorityQueue: fromOwnedSlice trivial case 0" { | 367 | test "fromOwnedSlice trivial case 0" { |
| 368 | const items = [0]u32{}; | 368 | const items = [0]u32{}; |
| 369 | const queue_items = try testing.allocator.dupe(u32, &items); | 369 | const queue_items = try testing.allocator.dupe(u32, &items); |
| 370 | var queue = PQlt.fromOwnedSlice(testing.allocator, queue_items[0..], {}); | 370 | var queue = PQlt.fromOwnedSlice(testing.allocator, queue_items[0..], {}); |
| ... | @@ -373,7 +373,7 @@ test "std.PriorityQueue: fromOwnedSlice trivial case 0" { | ... | @@ -373,7 +373,7 @@ test "std.PriorityQueue: fromOwnedSlice trivial case 0" { |
| 373 | try expect(queue.removeOrNull() == null); | 373 | try expect(queue.removeOrNull() == null); |
| 374 | } | 374 | } |
| 375 | 375 | ||
| 376 | test "std.PriorityQueue: fromOwnedSlice trivial case 1" { | 376 | test "fromOwnedSlice trivial case 1" { |
| 377 | const items = [1]u32{1}; | 377 | const items = [1]u32{1}; |
| 378 | const queue_items = try testing.allocator.dupe(u32, &items); | 378 | const queue_items = try testing.allocator.dupe(u32, &items); |
| 379 | var queue = PQlt.fromOwnedSlice(testing.allocator, queue_items[0..], {}); | 379 | var queue = PQlt.fromOwnedSlice(testing.allocator, queue_items[0..], {}); |
| ... | @@ -384,7 +384,7 @@ test "std.PriorityQueue: fromOwnedSlice trivial case 1" { | ... | @@ -384,7 +384,7 @@ test "std.PriorityQueue: fromOwnedSlice trivial case 1" { |
| 384 | try expect(queue.removeOrNull() == null); | 384 | try expect(queue.removeOrNull() == null); |
| 385 | } | 385 | } |
| 386 | 386 | ||
| 387 | test "std.PriorityQueue: fromOwnedSlice" { | 387 | test "fromOwnedSlice" { |
| 388 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; | 388 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; |
| 389 | const heap_items = try testing.allocator.dupe(u32, items[0..]); | 389 | const heap_items = try testing.allocator.dupe(u32, items[0..]); |
| 390 | var queue = PQlt.fromOwnedSlice(testing.allocator, heap_items[0..], {}); | 390 | var queue = PQlt.fromOwnedSlice(testing.allocator, heap_items[0..], {}); |
| ... | @@ -396,7 +396,7 @@ test "std.PriorityQueue: fromOwnedSlice" { | ... | @@ -396,7 +396,7 @@ test "std.PriorityQueue: fromOwnedSlice" { |
| 396 | } | 396 | } |
| 397 | } | 397 | } |
| 398 | 398 | ||
| 399 | test "std.PriorityQueue: add and remove max heap" { | 399 | test "add and remove max heap" { |
| 400 | var queue = PQgt.init(testing.allocator, {}); | 400 | var queue = PQgt.init(testing.allocator, {}); |
| 401 | defer queue.deinit(); | 401 | defer queue.deinit(); |
| 402 | 402 | ||
| ... | @@ -414,7 +414,7 @@ test "std.PriorityQueue: add and remove max heap" { | ... | @@ -414,7 +414,7 @@ test "std.PriorityQueue: add and remove max heap" { |
| 414 | try expectEqual(@as(u32, 7), queue.remove()); | 414 | try expectEqual(@as(u32, 7), queue.remove()); |
| 415 | } | 415 | } |
| 416 | 416 | ||
| 417 | test "std.PriorityQueue: add and remove same max heap" { | 417 | test "add and remove same max heap" { |
| 418 | var queue = PQgt.init(testing.allocator, {}); | 418 | var queue = PQgt.init(testing.allocator, {}); |
| 419 | defer queue.deinit(); | 419 | defer queue.deinit(); |
| 420 | 420 | ||
| ... | @@ -432,7 +432,7 @@ test "std.PriorityQueue: add and remove same max heap" { | ... | @@ -432,7 +432,7 @@ test "std.PriorityQueue: add and remove same max heap" { |
| 432 | try expectEqual(@as(u32, 1), queue.remove()); | 432 | try expectEqual(@as(u32, 1), queue.remove()); |
| 433 | } | 433 | } |
| 434 | 434 | ||
| 435 | test "std.PriorityQueue: iterator" { | 435 | test "iterator" { |
| 436 | var queue = PQlt.init(testing.allocator, {}); | 436 | var queue = PQlt.init(testing.allocator, {}); |
| 437 | var map = std.AutoHashMap(u32, void).init(testing.allocator); | 437 | var map = std.AutoHashMap(u32, void).init(testing.allocator); |
| 438 | defer { | 438 | defer { |
| ... | @@ -454,7 +454,7 @@ test "std.PriorityQueue: iterator" { | ... | @@ -454,7 +454,7 @@ test "std.PriorityQueue: iterator" { |
| 454 | try expectEqual(@as(usize, 0), map.count()); | 454 | try expectEqual(@as(usize, 0), map.count()); |
| 455 | } | 455 | } |
| 456 | 456 | ||
| 457 | test "std.PriorityQueue: remove at index" { | 457 | test "remove at index" { |
| 458 | var queue = PQlt.init(testing.allocator, {}); | 458 | var queue = PQlt.init(testing.allocator, {}); |
| 459 | defer queue.deinit(); | 459 | defer queue.deinit(); |
| 460 | 460 | ||
| ... | @@ -480,7 +480,7 @@ test "std.PriorityQueue: remove at index" { | ... | @@ -480,7 +480,7 @@ test "std.PriorityQueue: remove at index" { |
| 480 | try expectEqual(queue.removeOrNull(), null); | 480 | try expectEqual(queue.removeOrNull(), null); |
| 481 | } | 481 | } |
| 482 | 482 | ||
| 483 | test "std.PriorityQueue: iterator while empty" { | 483 | test "iterator while empty" { |
| 484 | var queue = PQlt.init(testing.allocator, {}); | 484 | var queue = PQlt.init(testing.allocator, {}); |
| 485 | defer queue.deinit(); | 485 | defer queue.deinit(); |
| 486 | 486 | ||
| ... | @@ -489,7 +489,7 @@ test "std.PriorityQueue: iterator while empty" { | ... | @@ -489,7 +489,7 @@ test "std.PriorityQueue: iterator while empty" { |
| 489 | try expectEqual(it.next(), null); | 489 | try expectEqual(it.next(), null); |
| 490 | } | 490 | } |
| 491 | 491 | ||
| 492 | test "std.PriorityQueue: shrinkAndFree" { | 492 | test "shrinkAndFree" { |
| 493 | var queue = PQlt.init(testing.allocator, {}); | 493 | var queue = PQlt.init(testing.allocator, {}); |
| 494 | defer queue.deinit(); | 494 | defer queue.deinit(); |
| 495 | 495 | ||
| ... | @@ -512,7 +512,7 @@ test "std.PriorityQueue: shrinkAndFree" { | ... | @@ -512,7 +512,7 @@ test "std.PriorityQueue: shrinkAndFree" { |
| 512 | try expect(queue.removeOrNull() == null); | 512 | try expect(queue.removeOrNull() == null); |
| 513 | } | 513 | } |
| 514 | 514 | ||
| 515 | test "std.PriorityQueue: update min heap" { | 515 | test "update min heap" { |
| 516 | var queue = PQlt.init(testing.allocator, {}); | 516 | var queue = PQlt.init(testing.allocator, {}); |
| 517 | defer queue.deinit(); | 517 | defer queue.deinit(); |
| 518 | 518 | ||
| ... | @@ -527,7 +527,7 @@ test "std.PriorityQueue: update min heap" { | ... | @@ -527,7 +527,7 @@ test "std.PriorityQueue: update min heap" { |
| 527 | try expectEqual(@as(u32, 5), queue.remove()); | 527 | try expectEqual(@as(u32, 5), queue.remove()); |
| 528 | } | 528 | } |
| 529 | 529 | ||
| 530 | test "std.PriorityQueue: update same min heap" { | 530 | test "update same min heap" { |
| 531 | var queue = PQlt.init(testing.allocator, {}); | 531 | var queue = PQlt.init(testing.allocator, {}); |
| 532 | defer queue.deinit(); | 532 | defer queue.deinit(); |
| 533 | 533 | ||
| ... | @@ -543,7 +543,7 @@ test "std.PriorityQueue: update same min heap" { | ... | @@ -543,7 +543,7 @@ test "std.PriorityQueue: update same min heap" { |
| 543 | try expectEqual(@as(u32, 5), queue.remove()); | 543 | try expectEqual(@as(u32, 5), queue.remove()); |
| 544 | } | 544 | } |
| 545 | 545 | ||
| 546 | test "std.PriorityQueue: update max heap" { | 546 | test "update max heap" { |
| 547 | var queue = PQgt.init(testing.allocator, {}); | 547 | var queue = PQgt.init(testing.allocator, {}); |
| 548 | defer queue.deinit(); | 548 | defer queue.deinit(); |
| 549 | 549 | ||
| ... | @@ -558,7 +558,7 @@ test "std.PriorityQueue: update max heap" { | ... | @@ -558,7 +558,7 @@ test "std.PriorityQueue: update max heap" { |
| 558 | try expectEqual(@as(u32, 1), queue.remove()); | 558 | try expectEqual(@as(u32, 1), queue.remove()); |
| 559 | } | 559 | } |
| 560 | 560 | ||
| 561 | test "std.PriorityQueue: update same max heap" { | 561 | test "update same max heap" { |
| 562 | var queue = PQgt.init(testing.allocator, {}); | 562 | var queue = PQgt.init(testing.allocator, {}); |
| 563 | defer queue.deinit(); | 563 | defer queue.deinit(); |
| 564 | 564 | ||
| ... | @@ -574,7 +574,7 @@ test "std.PriorityQueue: update same max heap" { | ... | @@ -574,7 +574,7 @@ test "std.PriorityQueue: update same max heap" { |
| 574 | try expectEqual(@as(u32, 1), queue.remove()); | 574 | try expectEqual(@as(u32, 1), queue.remove()); |
| 575 | } | 575 | } |
| 576 | 576 | ||
| 577 | test "std.PriorityQueue: update after remove" { | 577 | test "update after remove" { |
| 578 | var queue = PQlt.init(testing.allocator, {}); | 578 | var queue = PQlt.init(testing.allocator, {}); |
| 579 | defer queue.deinit(); | 579 | defer queue.deinit(); |
| 580 | 580 | ||
| ... | @@ -583,7 +583,7 @@ test "std.PriorityQueue: update after remove" { | ... | @@ -583,7 +583,7 @@ test "std.PriorityQueue: update after remove" { |
| 583 | try expectError(error.ElementNotFound, queue.update(1, 1)); | 583 | try expectError(error.ElementNotFound, queue.update(1, 1)); |
| 584 | } | 584 | } |
| 585 | 585 | ||
| 586 | test "std.PriorityQueue: siftUp in remove" { | 586 | test "siftUp in remove" { |
| 587 | var queue = PQlt.init(testing.allocator, {}); | 587 | var queue = PQlt.init(testing.allocator, {}); |
| 588 | defer queue.deinit(); | 588 | defer queue.deinit(); |
| 589 | 589 | ||
| ... | @@ -603,7 +603,7 @@ fn contextLessThan(context: []const u32, a: usize, b: usize) Order { | ... | @@ -603,7 +603,7 @@ fn contextLessThan(context: []const u32, a: usize, b: usize) Order { |
| 603 | 603 | ||
| 604 | const CPQlt = PriorityQueue(usize, []const u32, contextLessThan); | 604 | const CPQlt = PriorityQueue(usize, []const u32, contextLessThan); |
| 605 | 605 | ||
| 606 | test "std.PriorityQueue: add and remove min heap with contextful comparator" { | 606 | test "add and remove min heap with contextful comparator" { |
| 607 | const context = [_]u32{ 5, 3, 4, 2, 2, 8, 0 }; | 607 | const context = [_]u32{ 5, 3, 4, 2, 2, 8, 0 }; |
| 608 | 608 | ||
| 609 | var queue = CPQlt.init(testing.allocator, context[0..]); | 609 | var queue = CPQlt.init(testing.allocator, context[0..]); |
lib/std/segmented_list.zig+2-2| ... | @@ -408,7 +408,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type | ... | @@ -408,7 +408,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type |
| 408 | }; | 408 | }; |
| 409 | } | 409 | } |
| 410 | 410 | ||
| 411 | test "SegmentedList basic usage" { | 411 | test "basic usage" { |
| 412 | try testSegmentedList(0); | 412 | try testSegmentedList(0); |
| 413 | try testSegmentedList(1); | 413 | try testSegmentedList(1); |
| 414 | try testSegmentedList(2); | 414 | try testSegmentedList(2); |
| ... | @@ -507,7 +507,7 @@ fn testSegmentedList(comptime prealloc: usize) !void { | ... | @@ -507,7 +507,7 @@ fn testSegmentedList(comptime prealloc: usize) !void { |
| 507 | try list.setCapacity(testing.allocator, 0); | 507 | try list.setCapacity(testing.allocator, 0); |
| 508 | } | 508 | } |
| 509 | 509 | ||
| 510 | test "std.segmented_list clearRetainingCapacity" { | 510 | test "clearRetainingCapacity" { |
| 511 | var list = SegmentedList(i32, 1){}; | 511 | var list = SegmentedList(i32, 1){}; |
| 512 | defer list.deinit(testing.allocator); | 512 | defer list.deinit(testing.allocator); |
| 513 | 513 |
lib/std/treap.zig+1-1| ... | @@ -349,7 +349,7 @@ fn SliceIterRandomOrder(comptime T: type) type { | ... | @@ -349,7 +349,7 @@ fn SliceIterRandomOrder(comptime T: type) type { |
| 349 | const TestTreap = Treap(u64, std.math.order); | 349 | const TestTreap = Treap(u64, std.math.order); |
| 350 | const TestNode = TestTreap.Node; | 350 | const TestNode = TestTreap.Node; |
| 351 | 351 | ||
| 352 | test "std.Treap: insert, find, replace, remove" { | 352 | test "insert, find, replace, remove" { |
| 353 | var treap = TestTreap{}; | 353 | var treap = TestTreap{}; |
| 354 | var nodes: [10]TestNode = undefined; | 354 | var nodes: [10]TestNode = undefined; |
| 355 | 355 |
lib/std/wasm.zig+2-2| ... | @@ -201,7 +201,7 @@ pub fn opcode(op: Opcode) u8 { | ... | @@ -201,7 +201,7 @@ pub fn opcode(op: Opcode) u8 { |
| 201 | return @intFromEnum(op); | 201 | return @intFromEnum(op); |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | test "Wasm - opcodes" { | 204 | test "opcodes" { |
| 205 | // Ensure our opcodes values remain intact as certain values are skipped due to them being reserved | 205 | // Ensure our opcodes values remain intact as certain values are skipped due to them being reserved |
| 206 | const i32_const = opcode(.i32_const); | 206 | const i32_const = opcode(.i32_const); |
| 207 | const end = opcode(.end); | 207 | const end = opcode(.end); |
| ... | @@ -625,7 +625,7 @@ pub fn reftype(value: RefType) u8 { | ... | @@ -625,7 +625,7 @@ pub fn reftype(value: RefType) u8 { |
| 625 | return @intFromEnum(value); | 625 | return @intFromEnum(value); |
| 626 | } | 626 | } |
| 627 | 627 | ||
| 628 | test "Wasm - valtypes" { | 628 | test "valtypes" { |
| 629 | const _i32 = valtype(.i32); | 629 | const _i32 = valtype(.i32); |
| 630 | const _i64 = valtype(.i64); | 630 | const _i64 = valtype(.i64); |
| 631 | const _f32 = valtype(.f32); | 631 | const _f32 = valtype(.f32); |