authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-26 23:43:02-08:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-02-26 23:43:02-08:00
log085bde6889925b486291ddf1450b6bb6c8562a8f
tree02f7a49b4378dc2387b825bfc19825405f4502ca
parent4e2570baafb587c679ee0fc5e113ddeb36522a5d
parent726a1149e05669e5cc05a16ce877bbb2be787e39
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #19087 from squeek502/redundant-test-naming

Remove redundant test name prefixes now that test names are fully qualified

116 files changed, 783 insertions(+), 782 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}
175175
176test "isaac64 sequence" {176test "sequence" {
177 var r = Isaac64.init(0);177 var r = Isaac64.init(0);
178178
179 // from reference implementation179 // from reference implementation
...@@ -201,7 +201,7 @@ test "isaac64 sequence" {...@@ -201,7 +201,7 @@ test "isaac64 sequence" {
201 }201 }
202}202}
203203
204test "isaac64 fill" {204test fill {
205 var r = Isaac64.init(0);205 var r = Isaac64.init(0);
206206
207 // from reference implementation207 // 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}
7474
75test "pcg sequence" {75test "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}
9494
95test "pcg fill" {95test 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}
7474
75test "RomuTrio sequence" {75test "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);
7878
...@@ -94,7 +94,7 @@ test "RomuTrio sequence" {...@@ -94,7 +94,7 @@ test "RomuTrio sequence" {
94 }94 }
95}95}
9696
97test "RomuTrio fill" {97test 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);
100100
...@@ -120,7 +120,7 @@ test "RomuTrio fill" {...@@ -120,7 +120,7 @@ test "RomuTrio fill" {
120 }120 }
121}121}
122122
123test "RomuTrio buf seeding test" {123test "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}
7272
73test "Sfc64 sequence" {73test "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);
7676
...@@ -98,7 +98,7 @@ test "Sfc64 sequence" {...@@ -98,7 +98,7 @@ test "Sfc64 sequence" {
98 }98 }
99}99}
100100
101test "Sfc64 fill" {101test 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);
104104
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}
9090
91test "xoroshiro sequence" {91test "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}
124124
125test "xoroshiro fill" {125test 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}
9090
91test "xoroshiro sequence" {91test "sequence" {
92 if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest;92 if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest;
9393
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}
124124
125test "xoroshiro fill" {125test fill {
126 var r = Xoshiro256.init(0);126 var r = Xoshiro256.init(0);
127127
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(
166const expect = std.testing.expect;166const expect = std.testing.expect;
167const expectError = std.testing.expectError;167const expectError = std.testing.expectError;
168168
169test "SemanticVersion format" {169test 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.
171171
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}
279279
280test "SemanticVersion precedence" {280test "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}
14391439
1440test "Thread.join" {1440test join {
1441 if (builtin.single_threaded) return error.SkipZigTest;1441 if (builtin.single_threaded) return error.SkipZigTest;
14421442
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}
14511451
1452test "Thread.detach" {1452test detach {
1453 if (builtin.single_threaded) return error.SkipZigTest;1453 if (builtin.single_threaded) return error.SkipZigTest;
14541454
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};
298298
299test "Condition - smoke test" {299test "smoke test" {
300 var mutex = Mutex{};300 var mutex = Mutex{};
301 var cond = Condition{};301 var cond = Condition{};
302302
...@@ -317,7 +317,7 @@ test "Condition - smoke test" {...@@ -317,7 +317,7 @@ test "Condition - smoke test" {
317}317}
318318
319// Inspired from: https://github.com/Amanieu/parking_lot/pull/129319// Inspired from: https://github.com/Amanieu/parking_lot/pull/129
320test "Condition - wait and signal" {320test "wait and signal" {
321 // This test requires spawning threads321 // 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}
364364
365test "Condition - signal" {365test signal {
366 // This test requires spawning threads366 // 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}
431431
432test "Condition - multi signal" {432test "multi signal" {
433 // This test requires spawning threads433 // 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}
493493
494test "Condition - broadcasting" {494test broadcast {
495 // This test requires spawning threads495 // 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}
559559
560test "Condition - broadcasting - wake all threads" {560test "broadcasting - wake all threads" {
561 // Tests issue #12877561 // Tests issue #12877
562 // This test requires spawning threads562 // 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};
883883
884test "Futex - smoke test" {884test "smoke test" {
885 var value = atomic.Value(u32).init(0);885 var value = atomic.Value(u32).init(0);
886886
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}
900900
901test "Futex - signaling" {901test "signaling" {
902 // This test requires spawning threads902 // 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}
954954
955test "Futex - broadcasting" {955test "broadcasting" {
956 // This test requires spawning threads956 // 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};
10561056
1057test "Futex - Deadline" {1057test "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);
10601060
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};
217217
218test "Mutex - smoke test" {218test "smoke test" {
219 var mutex = Mutex{};219 var mutex = Mutex{};
220220
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};
245245
246test "Mutex - many uncontended" {246test "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}
276276
277test "Mutex - many contended" {277test "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};
159159
160test "ResetEvent - smoke test" {160test "smoke test" {
161 // make sure the event is unset161 // 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}
183183
184test "ResetEvent - signaling" {184test "signaling" {
185 // This test requires spawning threads185 // 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}
244244
245test "ResetEvent - broadcast" {245test "broadcast" {
246 // This test requires spawning threads246 // 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}
266266
267test "RwLock - smoke test" {267test "smoke test" {
268 var rwl = RwLock{};268 var rwl = RwLock{};
269269
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}
295295
296test "RwLock - concurrent access" {296test "concurrent access" {
297 if (builtin.single_threaded)297 if (builtin.single_threaded)
298 return;298 return;
299299
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}
7373
74test "Thread.Semaphore" {74test 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}
9999
100test "Thread.Semaphore - timedWait" {100test timedWait {
101 var sem = Semaphore{};101 var sem = Semaphore{};
102 try testing.expectEqual(0, sem.permits);102 try testing.expectEqual(0, sem.permits);
103103
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}
12331233
1234test "std.ArrayList/ArrayListUnmanaged.init" {1234test "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}
12501250
1251test "std.ArrayList/ArrayListUnmanaged.initCapacity" {1251test "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}
12661266
1267test "std.ArrayList/ArrayListUnmanaged.clone" {1267test "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}
13071307
1308test "std.ArrayList/ArrayListUnmanaged.basic" {1308test "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}
14111411
1412test "std.ArrayList/ArrayListUnmanaged.appendNTimes" {1412test "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}
14351435
1436test "std.ArrayList/ArrayListUnmanaged.appendNTimes with failing allocator" {1436test "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}
14491449
1450test "std.ArrayList/ArrayListUnmanaged.orderedRemove" {1450test "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}
15211521
1522test "std.ArrayList/ArrayListUnmanaged.swapRemove" {1522test "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}
15771577
1578test "std.ArrayList/ArrayListUnmanaged.insert" {1578test "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}
16071607
1608test "std.ArrayList/ArrayListUnmanaged.insertSlice" {1608test "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}
16531653
1654test "std.ArrayList/ArrayListUnmanaged.replaceRange" {1654test "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};
17751775
1776test "std.ArrayList/ArrayListUnmanaged: ArrayList(T) of struct T" {1776test "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}
17911791
1792test "std.ArrayList(u8)/ArrayListAligned implements writer" {1792test "ArrayList(u8) implements writer" {
1793 const a = testing.allocator;1793 const a = testing.allocator;
17941794
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}
18181818
1819test "std.ArrayListUnmanaged(u8) implements writer" {1819test "ArrayListUnmanaged(u8) implements writer" {
1820 const a = testing.allocator;1820 const a = testing.allocator;
18211821
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}
18851885
1886test "std.ArrayList/ArrayListUnmanaged.addManyAsArray" {1886test "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}
19091909
1910test "std.ArrayList/ArrayListUnmanaged growing memory preserves contents" {1910test "growing memory preserves contents" {
1911 // Shrink the list after every insertion to ensure that a memory growth1911 // 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}
19431943
1944test "std.ArrayList/ArrayList.fromOwnedSliceSentinel" {1944test "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
1957test "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");
19591950
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");
19631960
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}
19691967
1970test "std.ArrayList/ArrayListUnmanaged.fromOwnedSliceSentinel" {1968test "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");
19721974
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");
19761984
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}
19821991
1983test "std.ArrayList/ArrayListUnmanaged.toOwnedSliceSentinel" {1992test "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}
20062015
2007test "ArrayListAligned/ArrayListAlignedUnmanaged accepts unaligned slices" {2016test "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}
20302039
2031test "std.ArrayList(u0)" {2040test "ArrayList(u0)" {
2032 // An ArrayList on zero-sized types should not need to allocate2041 // An ArrayList on zero-sized types should not need to allocate
2033 const a = testing.failing_allocator;2042 const a = testing.failing_allocator;
20342043
...@@ -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}
20502059
2051test "std.ArrayList(?u32).popOrNull()" {2060test "ArrayList(?u32).popOrNull()" {
2052 const a = testing.allocator;2061 const a = testing.allocator;
20532062
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}
20672076
2068test "std.ArrayList(u32).getLast()" {2077test "ArrayList(u32).getLast()" {
2069 const a = testing.allocator;2078 const a = testing.allocator;
20702079
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}
20782087
2079test "std.ArrayList(u32).getLastOrNull()" {2088test "ArrayList(u32).getLastOrNull()" {
2080 const a = testing.allocator;2089 const a = testing.allocator;
20812090
2082 var list = ArrayList(u32).init(a);2091 var list = ArrayList(u32).init(a);
lib/std/buf_set.zig+19-19
...@@ -90,6 +90,23 @@ pub const BufSet = struct {...@@ -90,6 +90,23 @@ pub const BufSet = struct {
90 return self.cloneWithAllocator(self.allocator());90 return self.cloneWithAllocator(self.allocator());
91 }91 }
9292
93 test clone {
94 var original = BufSet.init(testing.allocator);
95 defer original.deinit();
96 try original.insert("x");
97
98 var cloned = try original.clone();
99 defer cloned.deinit();
100 cloned.remove("x");
101 try testing.expect(original.count() == 1);
102 try testing.expect(cloned.count() == 0);
103
104 try testing.expectError(
105 error.OutOfMemory,
106 original.cloneWithAllocator(testing.failing_allocator),
107 );
108 }
109
93 fn free(self: *const BufSet, value: []const u8) void {110 fn free(self: *const BufSet, value: []const u8) void {
94 self.hash_map.allocator.free(value);111 self.hash_map.allocator.free(value);
95 }112 }
...@@ -101,7 +118,7 @@ pub const BufSet = struct {...@@ -101,7 +118,7 @@ pub const BufSet = struct {
101 }118 }
102};119};
103120
104test "BufSet" {121test BufSet {
105 var bufset = BufSet.init(std.testing.allocator);122 var bufset = BufSet.init(std.testing.allocator);
106 defer bufset.deinit();123 defer bufset.deinit();
107124
...@@ -115,24 +132,7 @@ test "BufSet" {...@@ -115,24 +132,7 @@ test "BufSet" {
115 try bufset.insert("z");132 try bufset.insert("z");
116}133}
117134
118test "BufSet clone" {135test "clone with arena" {
119 var original = BufSet.init(testing.allocator);
120 defer original.deinit();
121 try original.insert("x");
122
123 var cloned = try original.clone();
124 defer cloned.deinit();
125 cloned.remove("x");
126 try testing.expect(original.count() == 1);
127 try testing.expect(cloned.count() == 0);
128
129 try testing.expectError(
130 error.OutOfMemory,
131 original.cloneWithAllocator(testing.failing_allocator),
132 );
133}
134
135test "BufSet.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}
8686
87test "flate compress/decompress" {87test "compress/decompress" {
88 if (builtin.target.cpu.arch == .wasm32) return error.SkipZigTest;88 if (builtin.target.cpu.arch == .wasm32) return error.SkipZigTest;
8989
90 var cmp_buf: [64 * 1024]u8 = undefined; // compressed data buffer90 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}
254254
255test "flate don't read past deflate stream's end" {255test "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}
266266
267test "flate zlib header" {267test "zlib header" {
268 // Truncated header268 // 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}
294294
295test "flate gzip header" {295test "gzip header" {
296 // Truncated header296 // 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}
355355
356test "flate public interface" {356test "public interface" {
357 if (builtin.target.cpu.arch == .wasm32) return error.SkipZigTest;357 if (builtin.target.cpu.arch == .wasm32) return error.SkipZigTest;
358358
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}
131131
132// example from: https://youtu.be/SJPvNi4HrWQ?t=3558132// example from: https://youtu.be/SJPvNi4HrWQ?t=3558
133test "flate.CircularBuffer writeMatch" {133test writeMatch {
134 var cb: Self = .{};134 var cb: Self = .{};
135135
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}
142142
143test "flate.CircularBuffer writeMatch overlap" {143test "writeMatch overlap" {
144 var cb: Self = .{};144 var cb: Self = .{};
145145
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}
152152
153test "flate.CircularBuffer readAtMost" {153test readAtMost {
154 var cb: Self = .{};154 var cb: Self = .{};
155155
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}
167167
168test "flate.CircularBuffer" {168test Self {
169 var cb: Self = .{};169 var cb: Self = .{};
170170
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 rest201 try testing.expectEqual(@as(usize, 200), cb.read().len); // read the rest
202}202}
203203
204test "flate.CircularBuffer write overlap" {204test "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}
220220
221test "flate.CircularBuffer writeMatch/read overlap" {221test "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}
8585
86test "flate.Lookup add/prev" {86test add {
87 const data = [_]u8{87 const data = [_]u8{
88 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,88 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
89 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,89 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
...@@ -107,7 +107,7 @@ test "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}
109109
110test "flate.Lookup bulkAdd" {110test bulkAdd {
111 const data = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";111 const data = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
112112
113 // one by one113 // 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}
124124
125test "flate.SlidingWindow match" {125test 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}
144144
145test "flate.SlidingWindow slide" {145test 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};
277277
278test "flate.Token size" {278test "size" {
279 try expect(@sizeOf(Token) == 4);279 try expect(@sizeOf(Token) == 4);
280}280}
281281
282// testing table https://datatracker.ietf.org/doc/html/rfc1951#page-12282// testing table https://datatracker.ietf.org/doc/html/rfc1951#page-12
283test "flate.Token MatchLength" {283test "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}
304304
305test "flate.Token MatchDistance" {305test "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}
316316
317test "flate.Token match_lengths" {317test "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}
220220
221test "flate.BitReader" {221test "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}
255255
256test "flate.BitReader read block type 1 data" {256test "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 1258 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}
279279
280test "flate.BitReader init" {280test "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}
304304
305test "flate.BitReader readAll" {305test "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}
322322
323test "flate.BitReader readFixedCode" {323test "readFixedCode" {
324 const fixed_codes = @import("huffman_encoder.zig").fixed_codes;324 const fixed_codes = @import("huffman_encoder.zig").fixed_codes;
325325
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;
596const testCases = @import("testdata/block_writer.zig").testCases;596const testCases = @import("testdata/block_writer.zig").testCases;
597597
598// tests if the writeBlock encoding has changed.598// tests if the writeBlock encoding has changed.
599test "flate.BlockWriter write" {599test "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}
604604
605// tests if the writeBlockDynamic encoding has changed.605// tests if the writeBlockDynamic encoding has changed.
606test "flate.BlockWriter dynamicBlock" {606test "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}
611611
612test "flate.BlockWriter huffmanBlock" {612test "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 unused96 if (sym.code_bits == 0) continue; // skip unused
98 sym.code = code;97 sym.code = code;
9998
...@@ -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 }
121119
122 /// Given the list of code lengths check that it represents a canonical120 /// 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}
178176
179test "flate.HuffmanDecoder init/find" {177test "init/find" {
180 // example data from: https://youtu.be/SJPvNi4HrWQ?t=8423178 // 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}
254252
255const print = std.debug.print;253test "encode/decode literals" {
256const assert = std.debug.assert;
257const expect = std.testing.expect;
258
259test "flate.HuffmanDecoder encode/decode literals" {
260 const LiteralEncoder = @import("huffman_encoder.zig").LiteralEncoder;254 const LiteralEncoder = @import("huffman_encoder.zig").LiteralEncoder;
261255
262 for (1..286) |j| { // for all different number of codes256 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 };
293287
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 }
297291
298 // find each symbol by code292 // 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" {
301295
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}
362362
363test "flate.HuffmanEncoder generate a Huffman code from an array of frequencies" {363test "generate a Huffman code from an array of frequencies" {
364 var freqs: [19]u16 = [_]u16{364 var freqs: [19]u16 = [_]u16{
365 8, // 0365 8, // 0
366 1, // 1366 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}
423423
424test "flate.HuffmanEncoder generate a Huffman code for the fixed literal table specific to Deflate" {424test "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}
445445
446test "flate.HuffmanEncoder generate a Huffman code for the 30 possible relative distances (LZ77 distances) of Deflate" {446test "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}
460460
461test "flate bitReverse" {461test 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}
484484
485test "flate.HuffmanEncoder fixedLiteralEncoder codes" {485test "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}
344344
345test "flate.Inflate decompress" {345test "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}
385385
386test "flate.Inflate gzip decompress" {386test "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}
442442
443test "flate.Inflate zlib decompress" {443test "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}
468468
469test "flate.Inflate fuzzing tests" {469test "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}
531531
532test "flate bug 18966" {532test "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");
535535
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}
2323
24test "LZMA: decompress empty world" {24test "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}
3333
34test "LZMA: decompress hello world" {34test "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}
4444
45test "LZMA: decompress huge dict" {45test "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}
5555
56test "LZMA: unknown size with end of payload marker" {56test "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}
6262
63test "LZMA: known size without end of payload marker" {63test "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}
6969
70test "LZMA: known size with end of payload marker" {70test "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}
7676
77test "LZMA: too big uncompressed size in header" {77test "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}
8383
84test "LZMA: too small uncompressed size in header" {84test "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;
49const expectEqualSlices = std.testing.expectEqualSlices;49const expectEqualSlices = std.testing.expectEqualSlices;
50const expectError = std.testing.expectError;50const expectError = std.testing.expectError;
5151
52test "Vec2D.init" {52test "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}
6060
61test "Vec2D.init overflow" {61test "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}
6868
69test "Vec2D.fill" {69test "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}
7979
80test "Vec2D.get" {80test "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}
9292
93test "Vec2D.getMut" {93test "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}
109109
110test "Vec2D.get multiplication overflow" {110test "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}
119119
120test "Vec2D.get addition overflow" {120test "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}
224224
225test "zstandard decompression" {225test "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}
241241
242test "zstandard streaming decompression" {242test "streaming decompression" {
243 // default stack size for wasm32 is too low for Decompressor - slightly243 // default stack size for wasm32 is too low for Decompressor - slightly
244 // over 1MiB stack space is needed via the --stack CLI flag244 // 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};
144144
145test "ComptimeStringMap list literal of list literals" {145test "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}
159159
160test "ComptimeStringMap array of structs" {160test "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}
172172
173test "ComptimeStringMap slice of structs" {173test "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}
200200
201test "ComptimeStringMap void value type, slice of structs" {201test "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}
217217
218test "ComptimeStringMap void value type, list literal of list literals" {218test "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}
260260
261test "ComptimeStringMap empty" {261test "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"));
264264
...@@ -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}
268268
269test "ComptimeStringMap redundant entries" {269test "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}
286286
287test "ComptimeStringMap redundant insensitive" {287test "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}
302302
303test "ComptimeStringMap comptime-only value" {303test "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}
139139
140test "curve25519 small order check" {140test "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};
484484
485test "ed25519 key pair creation" {485test "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}
493493
494test "ed25519 signature" {494test "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}
505505
506test "ed25519 batch verification" {506test "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}
534534
535test "ed25519 test vectors" {535test "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}
636636
637test "ed25519 with blind keys" {637test "with blind keys" {
638 const BlindKeyPair = Ed25519.key_blinding.BlindKeyPair;638 const BlindKeyPair = Ed25519.key_blinding.BlindKeyPair;
639639
640 // Create a standard Ed25519 key pair640 // 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}
659659
660test "ed25519 signatures with streaming" {660test "signatures with streaming" {
661 const kp = try Ed25519.KeyPair.create(null);661 const kp = try Ed25519.KeyPair.create(null);
662662
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}
675675
676test "ed25519 key pair from secret key" {676test "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 {
493493
494const htest = @import("../test.zig");494const htest = @import("../test.zig");
495495
496test "edwards25519 packing/unpacking" {496test "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}
531531
532test "edwards25519 point addition/subtraction" {532test "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}
545545
546test "edwards25519 uniform-to-point" {546test "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}
555555
556// Test vectors from draft-irtf-cfrg-hash-to-curve-12556// Test vectors from draft-irtf-cfrg-hash-to-curve-12
557test "edwards25519 hash-to-curve operation" {557test "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..]);
560560
...@@ -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}
564564
565test "edwards25519 implicit reduction of invalid scalars" {565test "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 {
8181
82const htest = @import("../test.zig");82const htest = @import("../test.zig");
8383
84test "x25519 public key calculation from secret key" {84test "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}
9292
93test "x25519 rfc7748 vector1" {93test "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 };
9696
...@@ -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}
102102
103test "x25519 rfc7748 vector2" {103test "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 };
106106
...@@ -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}
112112
113test "x25519 rfc7748 one iteration" {113test "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 };
116116
...@@ -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}
129129
130test "x25519 rfc7748 1,000 iterations" {130test "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}
151151
152test "x25519 rfc7748 1,000,000 iterations" {152test "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}
760760
761test "chacha20 AEAD API" {761test "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}
780780
781// https://tools.ietf.org/html/rfc7539#section-2.4.2781// https://tools.ietf.org/html/rfc7539#section-2.4.2
782test "crypto.chacha20 test vector sunscreen" {782test "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}
821821
822// https://tools.ietf.org/html/draft-agl-tls-chacha20poly1305-04#section-7822// https://tools.ietf.org/html/draft-agl-tls-chacha20poly1305-04#section-7
823test "crypto.chacha20 test vector 1" {823test "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}
856856
857test "crypto.chacha20 test vector 2" {857test "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}
890890
891test "crypto.chacha20 test vector 3" {891test "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}
924924
925test "crypto.chacha20 test vector 4" {925test "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}
958958
959test "crypto.chacha20 test vector 5" {959test "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}
11441144
1145test "crypto.xchacha20" {1145test "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}
373373
374test "ECDSA - Basic operations over EcdsaP384Sha384" {374test "Basic operations over EcdsaP384Sha384" {
375 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;375 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
376376
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}
389389
390test "ECDSA - Basic operations over Secp256k1" {390test "Basic operations over Secp256k1" {
391 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;391 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
392392
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}
405405
406test "ECDSA - Basic operations over EcdsaP384Sha256" {406test "Basic operations over EcdsaP384Sha256" {
407 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;407 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
408408
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}
421421
422test "ECDSA - Verifying a existing signature with EcdsaP384Sha256" {422test "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;
424424
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};
465465
466test "ECDSA - Test vectors from Project Wycheproof" {466test "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;
468468
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}
879879
880test "ECDSA - Sec1 encoding/decoding" {880test "Sec1 encoding/decoding" {
881 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;881 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
882882
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 {
7676
77const htest = @import("test.zig");77const htest = @import("test.zig");
7878
79test "hmac md5" {79test "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}
8787
88test "hmac sha1" {88test "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}
9696
97test "hmac sha256" {97test "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 {
232232
233const htest = @import("test.zig");233const htest = @import("test.zig");
234234
235test "md5 single" {235test "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}
244244
245test "md5 streaming" {245test "streaming" {
246 var h = Md5.init(.{});246 var h = Md5.init(.{});
247 var out: [16]u8 = undefined;247 var out: [16]u8 = undefined;
248248
...@@ -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}
265265
266test "md5 aligned final" {266test "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;
269269
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};
197197
198test "poly1305 rfc7439 vector1" {198test "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";
200200
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}
210210
211test "poly1305 requiring a final reduction" {211test "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}
140140
141test "crypto.utils.timingSafeEql" {141test "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}
150150
151test "crypto.utils.timingSafeEql (vectors)" {151test "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;
153153
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}
164164
165test "crypto.utils.timingSafeCompare" {165test "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}
177177
178test "crypto.utils.timingSafe{Add,Sub}" {178test "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}
197197
198test "crypto.utils.secureZero" {198test "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;
201201
lib/std/enums.zig+14-14
...@@ -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}
122122
123test "std.enums.directEnumArray" {123test 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}
165165
166test "std.enums.directEnumArrayDefault" {166test 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}
180180
181test "std.enums.directEnumArrayDefault slice" {181test "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}
216216
217test "std.enums.nameCast" {217test nameCast {
218 const A = enum(u1) { a = 0, b = 1 };218 const A = enum(u1) { a = 0, b = 1 };
219 const B = enum(u1) { a = 1, b = 0 };219 const B = enum(u1) { a = 1, b = 0 };
220 try testing.expectEqual(A.a, nameCast(A, .a));220 try testing.expectEqual(A.a, nameCast(A, .a));
...@@ -515,7 +515,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {...@@ -515,7 +515,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
515 };515 };
516}516}
517517
518test "EnumMultiset" {518test EnumMultiset {
519 const Ball = enum { red, green, blue };519 const Ball = enum { red, green, blue };
520520
521 const empty = EnumMultiset(Ball).initEmpty();521 const empty = EnumMultiset(Ball).initEmpty();
...@@ -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}
985985
986test "std.enums.EnumSet empty" {986test "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}
996996
997test "std.enums.EnumSet const iterator" {997test "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}
13001300
1301test "std.enums.ensureIndexer" {1301test 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}
14651465
1466test "std.enums.EnumIndexer dense zeroed" {1466test "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}
14811481
1482test "std.enums.EnumIndexer dense positive" {1482test "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}
14971497
1498test "std.enums.EnumIndexer dense negative" {1498test "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}
15131513
1514test "std.enums.EnumIndexer sparse" {1514test "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}
15291529
1530test "std.enums.EnumIndexer empty" {1530test "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);
...@@ -1535,7 +1535,7 @@ test "std.enums.EnumIndexer empty" {...@@ -1535,7 +1535,7 @@ test "std.enums.EnumIndexer empty" {
1535 try testing.expectEqual(0, Indexer.count);1535 try testing.expectEqual(0, Indexer.count);
1536}1536}
15371537
1538test "enumValues" {1538test values {
1539 const E = enum {1539 const E = enum {
1540 X,1540 X,
1541 Y,1541 Y,
lib/std/fmt/parse_float.zig+10-10
...@@ -12,7 +12,7 @@ const epsilon = 1e-7;...@@ -12,7 +12,7 @@ const epsilon = 1e-7;
1212
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.
1414
15test "fmt.parseFloat" {15test "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}
7070
71test "fmt.parseFloat nan and inf" {71test "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);
7474
...@@ -78,24 +78,24 @@ test "fmt.parseFloat nan and inf" {...@@ -78,24 +78,24 @@ test "fmt.parseFloat nan and inf" {
78 }78 }
79}79}
8080
81test "fmt.parseFloat largest normals" {81test "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}
8787
88test "fmt.parseFloat #11169" {88test "#11169" {
89 try expectEqual(try parseFloat(f128, "9007199254740993.0"), 9007199254740993.0);89 try expectEqual(try parseFloat(f128, "9007199254740993.0"), 9007199254740993.0);
90}90}
9191
92test "fmt.parseFloat hex.special" {92test "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}
98test "fmt.parseFloat hex.zero" {98test "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}
105105
106test "fmt.parseFloat hex.f16" {106test "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}
121121
122test "fmt.parseFloat hex.f32" {122test "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}
140140
141test "fmt.parseFloat hex.f64" {141test "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}
156test "fmt.parseFloat hex.f128" {156test "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;
1612const expect = std.testing.expect;1612const expect = std.testing.expect;
1613const expectEqual = std.testing.expectEqual;1613const expectEqual = std.testing.expectEqual;
16141614
1615test "std.hash_map basic usage" {1615test "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();
16181618
...@@ -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}
16421642
1643test "std.hash_map ensureTotalCapacity" {1643test "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();
16461646
...@@ -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}
16571657
1658test "std.hash_map ensureUnusedCapacity with tombstones" {1658test "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();
16611661
...@@ -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}
16691669
1670test "std.hash_map clearRetainingCapacity" {1670test "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();
16731673
...@@ -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}
16941694
1695test "std.hash_map grow" {1695test "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();
16981698
...@@ -1718,7 +1718,7 @@ test "std.hash_map grow" {...@@ -1718,7 +1718,7 @@ test "std.hash_map grow" {
1718 }1718 }
1719}1719}
17201720
1721test "std.hash_map clone" {1721test "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();
17241724
...@@ -1756,7 +1756,7 @@ test "std.hash_map clone" {...@@ -1756,7 +1756,7 @@ test "std.hash_map clone" {
1756 }1756 }
1757}1757}
17581758
1759test "std.hash_map ensureTotalCapacity with existing elements" {1759test "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();
17621762
...@@ -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}
17711771
1772test "std.hash_map ensureTotalCapacity satisfies max load factor" {1772test "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();
17751775
...@@ -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}
17791779
1780test "std.hash_map remove" {1780test "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();
17831783
...@@ -1809,7 +1809,7 @@ test "std.hash_map remove" {...@@ -1809,7 +1809,7 @@ test "std.hash_map remove" {
1809 }1809 }
1810}1810}
18111811
1812test "std.hash_map reverse removes" {1812test "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();
18151815
...@@ -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}
18331833
1834test "std.hash_map multiple removes on same metadata" {1834test "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();
18371837
...@@ -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}
18701870
1871test "std.hash_map put and remove loop in random order" {1871test "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();
18741874
...@@ -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}
19021902
1903test "std.hash_map remove one million elements in random order" {1903test "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}
19321932
1933test "std.hash_map put" {1933test "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();
19361936
...@@ -1955,7 +1955,7 @@ test "std.hash_map put" {...@@ -1955,7 +1955,7 @@ test "std.hash_map put" {
1955 }1955 }
1956}1956}
19571957
1958test "std.hash_map putAssumeCapacity" {1958test "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();
19611961
...@@ -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}
19871987
1988test "std.hash_map repeat putAssumeCapacity/remove" {1988test "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();
19911991
...@@ -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}
20192019
2020test "std.hash_map getOrPut" {2020test "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();
20232023
...@@ -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}
20422042
2043test "std.hash_map basic hash map usage" {2043test "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();
20462046
...@@ -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}
20872087
2088test "std.hash_map getOrPutAdapted" {2088test "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}
21362136
2137test "std.hash_map ensureUnusedCapacity" {2137test "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();
21402140
...@@ -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}
21492149
2150test "std.hash_map removeByPtr" {2150test "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();
21532153
...@@ -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}
21752175
2176test "std.hash_map removeByPtr 0 sized key" {2176test "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();
21792179
...@@ -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}
21932193
2194test "std.hash_map repeat fetchRemove" {2194test "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);
21972197
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};
248248
249test "ArenaAllocator (reset with preheating)" {249test "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 data252 // 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}
271271
272test "ArenaAllocator (reset while retaining a buffer)" {272test "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}
147147
148test "memory pool: basic" {148test "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();
151151
...@@ -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}
167167
168test "memory pool: preheating (success)" {168test "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();
171171
...@@ -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}
176176
177test "memory pool: preheating (failure)" {177test "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}
181181
182test "memory pool: growable" {182test "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();
185185
...@@ -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}
193193
194test "memory pool: greater than pointer default alignment" {194test "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}
205205
206test "memory pool: greater than pointer manual alignment" {206test "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}
1717
18test "Reader.isBytes" {18test "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}
2424
25test "Reader.skipBytes" {25test "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}
3333
34test "Reader.readUntilDelimiterArrayList returns ArrayLists with bytes read until the delimiter, then EndOfStream" {34test "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}
4848
49test "Reader.readUntilDelimiterArrayList returns an empty ArrayList" {49test "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}
6060
61test "Reader.readUntilDelimiterArrayList returns StreamTooLong, then an ArrayList with bytes read until the delimiter" {61test "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}
7474
75test "Reader.readUntilDelimiterArrayList returns EndOfStream" {75test "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}
8686
87test "Reader.readUntilDelimiterAlloc returns ArrayLists with bytes read until the delimiter, then EndOfStream" {87test "readUntilDelimiterAlloc returns ArrayLists with bytes read until the delimiter, then EndOfStream" {
88 const a = std.testing.allocator;88 const a = std.testing.allocator;
8989
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}
107107
108test "Reader.readUntilDelimiterAlloc returns an empty ArrayList" {108test "readUntilDelimiterAlloc returns an empty ArrayList" {
109 const a = std.testing.allocator;109 const a = std.testing.allocator;
110110
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}
120120
121test "Reader.readUntilDelimiterAlloc returns StreamTooLong, then an ArrayList with bytes read until the delimiter" {121test "readUntilDelimiterAlloc returns StreamTooLong, then an ArrayList with bytes read until the delimiter" {
122 const a = std.testing.allocator;122 const a = std.testing.allocator;
123123
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}
133133
134test "Reader.readUntilDelimiterAlloc returns EndOfStream" {134test "readUntilDelimiterAlloc returns EndOfStream" {
135 const a = std.testing.allocator;135 const a = std.testing.allocator;
136136
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}
142142
143test "Reader.readUntilDelimiter returns bytes read until the delimiter" {143test "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}
150150
151test "Reader.readUntilDelimiter returns an empty string" {151test "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}
157157
158test "Reader.readUntilDelimiter returns StreamTooLong, then an empty string" {158test "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}
165165
166test "Reader.readUntilDelimiter returns StreamTooLong, then bytes read until the delimiter" {166test "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}
173173
174test "Reader.readUntilDelimiter returns EndOfStream" {174test "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}
188188
189test "Reader.readUntilDelimiter returns bytes read until delimiter, then EndOfStream" {189test "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}
196196
197test "Reader.readUntilDelimiter returns StreamTooLong, then EndOfStream" {197test "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}
204204
205test "Reader.readUntilDelimiter writes all bytes read to the output buffer" {205test "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}
214214
215test "Reader.readUntilDelimiterOrEofAlloc returns ArrayLists with bytes read until the delimiter, then EndOfStream" {215test "readUntilDelimiterOrEofAlloc returns ArrayLists with bytes read until the delimiter, then EndOfStream" {
216 const a = std.testing.allocator;216 const a = std.testing.allocator;
217217
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}
235235
236test "Reader.readUntilDelimiterOrEofAlloc returns an empty ArrayList" {236test "readUntilDelimiterOrEofAlloc returns an empty ArrayList" {
237 const a = std.testing.allocator;237 const a = std.testing.allocator;
238238
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}
248248
249test "Reader.readUntilDelimiterOrEofAlloc returns StreamTooLong, then an ArrayList with bytes read until the delimiter" {249test "readUntilDelimiterOrEofAlloc returns StreamTooLong, then an ArrayList with bytes read until the delimiter" {
250 const a = std.testing.allocator;250 const a = std.testing.allocator;
251251
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}
261261
262test "Reader.readUntilDelimiterOrEof returns bytes read until the delimiter" {262test "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}
269269
270test "Reader.readUntilDelimiterOrEof returns an empty string" {270test "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}
276276
277test "Reader.readUntilDelimiterOrEof returns StreamTooLong, then an empty string" {277test "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}
284284
285test "Reader.readUntilDelimiterOrEof returns StreamTooLong, then bytes read until the delimiter" {285test "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}
292292
293test "Reader.readUntilDelimiterOrEof returns null" {293test "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}
299299
300test "Reader.readUntilDelimiterOrEof returns bytes read until delimiter, then null" {300test "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}
307307
308test "Reader.readUntilDelimiterOrEof returns bytes read until end-of-stream" {308test "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}
314314
315test "Reader.readUntilDelimiterOrEof returns StreamTooLong, then bytes read until end-of-stream" {315test "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}
322322
323test "Reader.readUntilDelimiterOrEof writes all bytes read to the output buffer" {323test "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}
332332
333test "Reader.streamUntilDelimiter writes all bytes without delimiter to the output" {333test "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}
351351
352test "Reader.readBoundedBytes correctly reads into a new bounded array" {352test "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}
360360
361test "Reader.readIntoBoundedBytes correctly reads into a provided bounded array" {361test "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}
5555
56test "io.BufferedReader OneByte" {56test "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" {
96fn smallBufferedReader(underlying_stream: anytype) BufferedReader(8, @TypeOf(underlying_stream)) {96fn smallBufferedReader(underlying_stream: anytype) BufferedReader(8, @TypeOf(underlying_stream)) {
97 return .{ .unbuffered_reader = underlying_stream };97 return .{ .unbuffered_reader = underlying_stream };
98}98}
99test "io.BufferedReader Block" {99test "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}
148148
149test "io.BufferedTee io.BufferedReader OneByte" {149test "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}
188188
189test "io.BufferedTee io.BufferedReader Block" {189test "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}
291291
292test "io.BufferedTee with zero lookahead" {292test "with zero lookahead" {
293 // output has same bytes as consumer293 // 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}
310310
311test "io.BufferedTee with lookahead" {311test "with lookahead" {
312 // output is lookahead bytes behind consumer312 // 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}
335335
336test "io.BufferedTee internal state" {336test "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}
2929
30test "io.CountingReader" {30test CountingReader {
31 const bytes = "yay" ** 100;31 const bytes = "yay" ** 100;
32 var fbs = io.fixedBufferStream(bytes);32 var fbs = io.fixedBufferStream(bytes);
3333
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}
3131
32test "io.CountingWriter" {32test 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();
3535
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}
134134
135test "FixedBufferStream output" {135test "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}
143143
144test "FixedBufferStream output at comptime" {144test "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}
154154
155test "FixedBufferStream output 2" {155test "output 2" {
156 var buffer: [10]u8 = undefined;156 var buffer: [10]u8 = undefined;
157 var fbs = fixedBufferStream(&buffer);157 var fbs = fixedBufferStream(&buffer);
158158
...@@ -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}
177177
178test "FixedBufferStream input" {178test "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);
181181
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};
101101
102test "StreamSource (refs)" {102test "refs" {
103 std.testing.refAllDecls(StreamSource);103 std.testing.refAllDecls(StreamSource);
104}104}
105105
106test "StreamSource (mutable buffer)" {106test "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) };
109109
...@@ -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}
116116
117test "StreamSource (const buffer)" {117test "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) };
120120
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}
3737
38test "json.token" {38test "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();
4141
...@@ -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}
155155
156test "json.token mismatched close" {156test "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}
165165
166test "json.token premature object close" {166test "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}
355355
356test "json.validate" {356test "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}
13001300
1301test "std.math.log2_int_ceil" {1301test 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}
150150
151test "math.acos" {151test 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}
155155
156test "math.acos32" {156test acos32 {
157 const epsilon = 0.000001;157 const epsilon = 0.000001;
158158
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}
166166
167test "math.acos64" {167test acos64 {
168 const epsilon = 0.000001;168 const epsilon = 0.000001;
169169
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}
177177
178test "math.acos32.special" {178test "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}
182182
183test "math.acos64.special" {183test "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}
6161
62test "math.acosh" {62test 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}
6666
67test "math.acosh32" {67test acosh32 {
68 const epsilon = 0.000001;68 const epsilon = 0.000001;
6969
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}
7575
76test "math.acosh64" {76test acosh64 {
77 const epsilon = 0.000001;77 const epsilon = 0.000001;
7878
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}
8484
85test "math.acosh32.special" {85test "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}
8989
90test "math.acosh64.special" {90test "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}
143143
144test "math.asin" {144test 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}
148148
149test "math.asin32" {149test asin32 {
150 const epsilon = 0.000001;150 const epsilon = 0.000001;
151151
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}
159159
160test "math.asin64" {160test asin64 {
161 const epsilon = 0.000001;161 const epsilon = 0.000001;
162162
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}
170170
171test "math.asin32.special" {171test "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}
177177
178test "math.asin64.special" {178test "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}
8282
83test "math.asinh" {83test 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}
8787
88test "math.asinh32" {88test asinh32 {
89 const epsilon = 0.000001;89 const epsilon = 0.000001;
9090
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}
100100
101test "math.asinh64" {101test asinh64 {
102 const epsilon = 0.000001;102 const epsilon = 0.000001;
103103
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}
113113
114test "math.asinh32.special" {114test "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}
121121
122test "math.asinh64.special" {122test "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}
214214
215test "math.atan" {215test 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}
219219
220test "math.atan32" {220test atan32 {
221 const epsilon = 0.000001;221 const epsilon = 0.000001;
222222
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}
229229
230test "math.atan64" {230test atan64 {
231 const epsilon = 0.000001;231 const epsilon = 0.000001;
232232
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}
239239
240test "math.atan32.special" {240test "atan32.special" {
241 const epsilon = 0.000001;241 const epsilon = 0.000001;
242242
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}
248248
249test "math.atan64.special" {249test "atan64.special" {
250 const epsilon = 0.000001;250 const epsilon = 0.000001;
251251
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}
216216
217test "math.atan2" {217test 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}
225225
226test "math.atan2_32" {226test atan2_32 {
227 const epsilon = 0.000001;227 const epsilon = 0.000001;
228228
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}
237237
238test "math.atan2_64" {238test atan2_64 {
239 const epsilon = 0.000001;239 const epsilon = 0.000001;
240240
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}
249249
250test "math.atan2_32.special" {250test "atan2_32.special" {
251 const epsilon = 0.000001;251 const epsilon = 0.000001;
252252
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}
273273
274test "math.atan2_64.special" {274test "atan2_64.special" {
275 const epsilon = 0.000001;275 const epsilon = 0.000001;
276276
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}
8686
87test "math.atanh" {87test 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}
9191
92test "math.atanh_32" {92test atanh_32 {
93 const epsilon = 0.000001;93 const epsilon = 0.000001;
9494
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}
9999
100test "math.atanh_64" {100test atanh_64 {
101 const epsilon = 0.000001;101 const epsilon = 0.000001;
102102
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}
107107
108test "math.atanh32.special" {108test "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}
115115
116test "math.atanh64.special" {116test "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-paths17// 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.
1919
20test "big.int comptime_int set" {20test "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}
3535
36test "big.int comptime_int set negative" {36test "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();
3939
...@@ -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}
4343
44test "big.int int set unaligned small" {44test "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();
4747
...@@ -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}
5151
52test "big.int comptime_int to" {52test "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();
5555
56 try testing.expect((try a.to(u128)) == 0xefffffff00000001eeeeeeefaaaaaaab);56 try testing.expect((try a.to(u128)) == 0xefffffff00000001eeeeeeefaaaaaaab);
57}57}
5858
59test "big.int sub-limb to" {59test "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();
6262
63 try testing.expect((try a.to(u8)) == 10);63 try testing.expect((try a.to(u8)) == 10);
64}64}
6565
66test "big.int set negative minimum" {66test "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();
6969
70 try testing.expect((try a.to(i64)) == minInt(i64));70 try testing.expect((try a.to(i64)) == minInt(i64));
71}71}
7272
73test "big.int set double-width maximum then zero" {73test "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}
8080
81test "big.int to target too small error" {81test "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();
8484
85 try testing.expectError(error.TargetTooSmall, a.to(u8));85 try testing.expectError(error.TargetTooSmall, a.to(u8));
86}86}
8787
88test "big.int normalize" {88test "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}
115115
116test "big.int normalize multi" {116test "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}
145145
146test "big.int parity" {146test "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();
149149
...@@ -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}
158158
159test "big.int bitcount + sizeInBaseUpperBound" {159test "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();
162162
...@@ -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}
186186
187test "big.int bitcount/to" {187test "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();
190190
...@@ -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}
217217
218test "big.int fits" {218test "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();
221221
...@@ -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}
245245
246test "big.int string set" {246test "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();
249249
...@@ -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}
253253
254test "big.int string negative" {254test "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();
257257
...@@ -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}
261261
262test "big.int string set number with underscores" {262test "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();
265265
...@@ -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}
269269
270test "big.int string set case insensitive number" {270test "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();
273273
...@@ -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}
277277
278test "big.int string set bad char error" {278test "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}
283283
284test "big.int string set bad base error" {284test "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}
289289
290test "big.int twos complement limit set" {290test "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}
317317
318test "big.int string to" {318test "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();
321321
...@@ -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}
328328
329test "big.int string to base base error" {329test "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();
332332
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}
335335
336test "big.int string to base 2" {336test "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();
339339
...@@ -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}
346346
347test "big.int string to base 16" {347test "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();
350350
...@@ -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}
357357
358test "big.int neg string to" {358test "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();
361361
...@@ -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}
368368
369test "big.int zero string to" {369test "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();
372372
...@@ -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}
379379
380test "big.int clone" {380test "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}
393393
394test "big.int swap" {394test "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}
408408
409test "big.int to negative" {409test "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();
412412
413 try testing.expect((try a.to(i32)) == -10);413 try testing.expect((try a.to(i32)) == -10);
414}414}
415415
416test "big.int compare" {416test "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}
425425
426test "big.int compare similar" {426test "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}
435435
436test "big.int compare different limb size" {436test "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}
445445
446test "big.int compare multi-limb" {446test "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}
455455
456test "big.int equality" {456test "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}
465465
466test "big.int abs" {466test "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();
469469
...@@ -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}
476476
477test "big.int negate" {477test "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();
480480
...@@ -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}
487487
488test "big.int add single-single" {488test "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}
500500
501test "big.int add multi-single" {501test "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}
516516
517test "big.int add multi-multi" {517test "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 the520 // 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}
534534
535test "big.int add zero-zero" {535test "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}
547547
548test "big.int add alias multi-limb nonzero-zero" {548test "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}
559559
560test "big.int add sign" {560test "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();
563563
...@@ -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}
585585
586test "big.int add comptime scalar" {586test "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();
589589
...@@ -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}
596596
597test "big.int add scalar" {597test "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();
600600
...@@ -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}
607607
608test "big.int addWrap single-single, unsigned" {608test "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();
611611
...@@ -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}
620620
621test "big.int subWrap single-single, unsigned" {621test "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();
624624
...@@ -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}
633633
634test "big.int addWrap multi-multi, unsigned, limb aligned" {634test "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();
637637
...@@ -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}
646646
647test "big.int subWrap single-multi, unsigned, limb aligned" {647test "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();
650650
...@@ -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}
659659
660test "big.int addWrap single-single, signed" {660test "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();
663663
...@@ -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}
672672
673test "big.int subWrap single-single, signed" {673test "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();
676676
...@@ -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}
685685
686test "big.int addWrap multi-multi, signed, limb aligned" {686test "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();
689689
...@@ -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}
698698
699test "big.int subWrap single-multi, signed, limb aligned" {699test "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();
702702
...@@ -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}
711711
712test "big.int addSat single-single, unsigned" {712test "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();
715715
...@@ -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}
723723
724test "big.int subSat single-single, unsigned" {724test "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();
727727
...@@ -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}
735735
736test "big.int addSat multi-multi, unsigned, limb aligned" {736test "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();
739739
...@@ -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}
747747
748test "big.int subSat single-multi, unsigned, limb aligned" {748test "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();
751751
...@@ -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}
759759
760test "big.int addSat single-single, signed" {760test "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();
763763
...@@ -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}
771771
772test "big.int subSat single-single, signed" {772test "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();
775775
...@@ -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}
783783
784test "big.int addSat multi-multi, signed, limb aligned" {784test "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();
787787
...@@ -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}
795795
796test "big.int subSat single-multi, signed, limb aligned" {796test "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();
799799
...@@ -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}
807807
808test "big.int sub single-single" {808test "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}
820820
821test "big.int sub multi-single" {821test "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}
833833
834test "big.int sub multi-multi" {834test "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}
850850
851test "big.int sub equal" {851test "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}
863863
864test "big.int sub sign" {864test "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();
867867
...@@ -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}
892892
893test "big.int mul single-single" {893test "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}
905905
906test "big.int mul multi-single" {906test "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}
918918
919test "big.int mul multi-multi" {919test "mul multi-multi" {
920 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;920 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
921921
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}
937937
938test "big.int mul alias r with a" {938test "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}
948948
949test "big.int mul alias r with b" {949test "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}
959959
960test "big.int mul alias r with a and b" {960test "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();
963963
...@@ -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}
968968
969test "big.int mul a*0" {969test "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}
981981
982test "big.int mul 0*0" {982test "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}
994994
995test "big.int mul large" {995test "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}
10151015
1016test "big.int mulWrap single-single unsigned" {1016test "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}
10281028
1029test "big.int mulWrap single-single signed" {1029test "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}
10411041
1042test "big.int mulWrap multi-multi unsigned" {1042test "mulWrap multi-multi unsigned" {
1043 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;1043 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
10441044
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}
10601060
1061test "big.int mulWrap multi-multi signed" {1061test "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}
10781078
1079test "big.int mulWrap large" {1079test "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}
11021102
1103test "big.int div single-half no rem" {1103test "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}
11181118
1119test "big.int div single-half with rem" {1119test "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}
11341134
1135test "big.int div single-single no rem" {1135test "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}
11511151
1152test "big.int div single-single with rem" {1152test "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}
11671167
1168test "big.int div multi-single no rem" {1168test "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}
11871187
1188test "big.int div multi-single with rem" {1188test "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}
12071207
1208test "big.int div multi>2-single" {1208test "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}
12271227
1228test "big.int div single-single q < r" {1228test "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}
12431243
1244test "big.int div single-single q == r" {1244test "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}
12591259
1260test "big.int div q=0 alias" {1260test "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}
12711271
1272test "big.int div multi-multi q < r" {1272test "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;
12741274
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}
12911291
1292test "big.int div trunc single-single +/+" {1292test "div trunc single-single +/+" {
1293 const u: i32 = 5;1293 const u: i32 = 5;
1294 const v: i32 = 3;1294 const v: i32 = 3;
12951295
...@@ -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}
13151315
1316test "big.int div trunc single-single -/+" {1316test "div trunc single-single -/+" {
1317 const u: i32 = -5;1317 const u: i32 = -5;
1318 const v: i32 = 3;1318 const v: i32 = 3;
13191319
...@@ -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}
13391339
1340test "big.int div trunc single-single +/-" {1340test "div trunc single-single +/-" {
1341 const u: i32 = 5;1341 const u: i32 = 5;
1342 const v: i32 = -3;1342 const v: i32 = -3;
13431343
...@@ -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}
13631363
1364test "big.int div trunc single-single -/-" {1364test "div trunc single-single -/-" {
1365 const u: i32 = -5;1365 const u: i32 = -5;
1366 const v: i32 = -3;1366 const v: i32 = -3;
13671367
...@@ -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}
13871387
1388test "big.int divTrunc #15535" {1388test "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}
14001400
1401test "big.int divFloor #10932" {1401test "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();
14041404
...@@ -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}
14241424
1425test "big.int divFloor #11166" {1425test "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();
14281428
...@@ -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}
14511451
1452test "big.int gcd #10932" {1452test "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();
14551455
...@@ -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}
14711471
1472test "big.int bitAnd #10932" {1472test "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();
14751475
...@@ -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}
14891489
1490test "big.int div floor single-single +/+" {1490test "div floor single-single +/+" {
1491 const u: i32 = 5;1491 const u: i32 = 5;
1492 const v: i32 = 3;1492 const v: i32 = 3;
14931493
...@@ -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}
15131513
1514test "big.int div floor single-single -/+" {1514test "div floor single-single -/+" {
1515 const u: i32 = -5;1515 const u: i32 = -5;
1516 const v: i32 = 3;1516 const v: i32 = 3;
15171517
...@@ -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}
15371537
1538test "big.int div floor single-single +/-" {1538test "div floor single-single +/-" {
1539 const u: i32 = 5;1539 const u: i32 = 5;
1540 const v: i32 = -3;1540 const v: i32 = -3;
15411541
...@@ -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}
15611561
1562test "big.int div floor single-single -/-" {1562test "div floor single-single -/-" {
1563 const u: i32 = -5;1563 const u: i32 = -5;
1564 const v: i32 = -3;1564 const v: i32 = -3;
15651565
...@@ -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}
15851585
1586test "big.int div floor no remainder negative quotient" {1586test "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;
15891589
...@@ -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}
16041604
1605test "big.int div floor negative close to zero" {1605test "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;
16081608
...@@ -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}
16231623
1624test "big.int div floor positive close to zero" {1624test "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;
16271627
...@@ -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}
16421642
1643test "big.int div multi-multi with rem" {1643test "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;
16451645
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}
16601660
1661test "big.int div multi-multi no rem" {1661test "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;
16631663
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}
16781678
1679test "big.int div multi-multi (2 branch)" {1679test "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;
16811681
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}
16961696
1697test "big.int div multi-multi (3.1/3.3 branch)" {1697test "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;
16991699
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}
17141714
1715test "big.int div multi-single zero-limb trailing" {1715test "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;
17171717
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}
17341734
1735test "big.int div multi-multi zero-limb trailing (with rem)" {1735test "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;
17371737
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}
17551755
1756test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-limb count > divisor zero-limb count" {1756test "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;
17581758
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}
17761776
1777test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-limb count < divisor zero-limb count" {1777test "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;
17791779
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}
17991799
1800test "big.int div multi-multi fuzz case #1" {1800test "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}
18231823
1824test "big.int div multi-multi fuzz case #2" {1824test "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}
18471847
1848test "big.int truncate single unsigned" {1848test "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();
18511851
...@@ -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}
18561856
1857test "big.int truncate single signed" {1857test "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();
18601860
...@@ -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}
18651865
1866test "big.int truncate multi to single unsigned" {1866test "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();
18691869
...@@ -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}
18741874
1875test "big.int truncate multi to single signed" {1875test "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();
18781878
...@@ -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}
18831883
1884test "big.int truncate multi to multi unsigned" {1884test "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);
18871887
...@@ -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}
18951895
1896test "big.int truncate multi to multi signed" {1896test "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();
18991899
...@@ -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}
19041904
1905test "big.int truncate negative multi to single" {1905test "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();
19081908
...@@ -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}
19131913
1914test "big.int truncate multi unsigned many" {1914test "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}
19251925
1926test "big.int saturate single signed positive" {1926test "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();
19291929
...@@ -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}
19341934
1935test "big.int saturate single signed negative" {1935test "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();
19381938
...@@ -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}
19431943
1944test "big.int saturate single signed" {1944test "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();
19471947
...@@ -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}
19521952
1953test "big.int saturate multi signed" {1953test "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();
19561956
...@@ -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}
19611961
1962test "big.int saturate single unsigned" {1962test "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();
19651965
...@@ -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}
19701970
1971test "big.int saturate multi unsigned zero" {1971test "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();
19741974
...@@ -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}
19791979
1980test "big.int saturate multi unsigned" {1980test "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();
19831983
...@@ -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}
19881988
1989test "big.int shift-right single" {1989test "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}
19961996
1997test "big.int shift-right multi" {1997test "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}
20102010
2011test "big.int shift-left single" {2011test "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}
20182018
2019test "big.int shift-left multi" {2019test "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}
20262026
2027test "big.int shift-right negative" {2027test "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();
20302030
...@@ -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 == -12044 try testing.expect((try a.to(i32)) == -1); // -10 >> 1232 == -1
2045}2045}
20462046
2047test "big.int sat shift-left simple unsigned" {2047test "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}
20542054
2055test "big.int sat shift-left simple unsigned no sat" {2055test "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}
20622062
2063test "big.int sat shift-left multi unsigned" {2063test "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}
20702070
2071test "big.int sat shift-left unsigned shift > bitcount" {2071test "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}
20782078
2079test "big.int sat shift-left unsigned zero" {2079test "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}
20862086
2087test "big.int sat shift-left unsigned negative" {2087test "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}
20942094
2095test "big.int sat shift-left signed simple negative" {2095test "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}
21022102
2103test "big.int sat shift-left signed simple positive" {2103test "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}
21102110
2111test "big.int sat shift-left signed multi positive" {2111test "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;
21132113
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}
21252125
2126test "big.int sat shift-left signed multi negative" {2126test "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;
21282128
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}
21402140
2141test "big.int bitNotWrap unsigned simple" {2141test "bitNotWrap unsigned simple" {
2142 var x: u10 = 123;2142 var x: u10 = 123;
2143 _ = &x;2143 _ = &x;
21442144
...@@ -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}
21522152
2153test "big.int bitNotWrap unsigned multi" {2153test "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();
21562156
...@@ -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}
21612161
2162test "big.int bitNotWrap signed simple" {2162test "bitNotWrap signed simple" {
2163 var x: i11 = -456;2163 var x: i11 = -456;
2164 _ = &x;2164 _ = &x;
21652165
...@@ -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}
21732173
2174test "big.int bitNotWrap signed multi" {2174test "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();
21772177
...@@ -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}
21822182
2183test "big.int bitNotWrap more than two limbs" {2183test "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; // TODO2185 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
2186 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO2186 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}
22082208
2209test "big.int bitwise and simple" {2209test "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}
22192219
2220test "big.int bitwise and multi-limb" {2220test "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}
22302230
2231test "big.int bitwise and negative-positive simple" {2231test "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}
22412241
2242test "big.int bitwise and negative-positive multi-limb" {2242test "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}
22522252
2253test "big.int bitwise and positive-negative simple" {2253test "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}
22632263
2264test "big.int bitwise and positive-negative multi-limb" {2264test "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}
22742274
2275test "big.int bitwise and negative-negative simple" {2275test "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}
22852285
2286test "big.int bitwise and negative-negative multi-limb" {2286test "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}
22962296
2297test "big.int bitwise and negative overflow" {2297test "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}
23072307
2308test "big.int bitwise xor simple" {2308test "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}
23182318
2319test "big.int bitwise xor multi-limb" {2319test "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}
23332333
2334test "big.int bitwise xor single negative simple" {2334test "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}
23442344
2345test "big.int bitwise xor single negative multi-limb" {2345test "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}
23552355
2356test "big.int bitwise xor single negative overflow" {2356test "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}
23662366
2367test "big.int bitwise xor double negative simple" {2367test "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}
23772377
2378test "big.int bitwise xor double negative multi-limb" {2378test "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}
23882388
2389test "big.int bitwise or simple" {2389test "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}
23992399
2400test "big.int bitwise or multi-limb" {2400test "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}
24102410
2411test "big.int bitwise or negative-positive simple" {2411test "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}
24212421
2422test "big.int bitwise or negative-positive multi-limb" {2422test "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}
24322432
2433test "big.int bitwise or positive-negative simple" {2433test "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}
24432443
2444test "big.int bitwise or positive-negative multi-limb" {2444test "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}
24542454
2455test "big.int bitwise or negative-negative simple" {2455test "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}
24652465
2466test "big.int bitwise or negative-negative multi-limb" {2466test "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}
24762476
2477test "big.int var args" {2477test "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();
24802480
...@@ -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}
24942494
2495test "big.int gcd non-one small" {2495test "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}
25072507
2508test "big.int gcd non-one medium" {2508test "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}
25202520
2521test "big.int gcd non-one large" {2521test "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}
25332533
2534test "big.int gcd large multi-limb result" {2534test "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;
25362536
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}
25492549
2550test "big.int gcd one large" {2550test "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}
25622562
2563test "big.int mutable to managed" {2563test "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}
25732573
2574test "big.int const to managed" {2574test "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();
25772577
...@@ -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}
25832583
2584test "big.int pow" {2584test "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}
26382638
2639test "big.int sqrt" {2639test "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}
26682668
2669test "big.int regression test for 1 limb overflow with alias" {2669test "regression test for 1 limb overflow with alias" {
2670 // Note these happen to be two consecutive Fibonacci sequence numbers, the2670 // 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}
26822682
2683test "big.int regression test for realloc with alias" {2683test "regression test for realloc with alias" {
2684 // Note these happen to be two consecutive Fibonacci sequence numbers, the2684 // 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}
31013101
3102test "big.int mul multi-multi alias r with a and b" {3102test "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();
31053105
...@@ -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}
31173117
3118test "big.int sqr multi alias r with a" {3118test "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();
31213121
...@@ -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}
31333133
3134test "big.int eql zeroes #17296" {3134test "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}
31543154
3155test "big.int.Const.order 0 == -0" {3155test "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}
31663166
3167test "big.int.Managed sqrt(0) = 0" {3167test "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}
31803180
3181test "big.int.Managed sqrt(-1) = error" {3181test "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}
31933193
3194test "big.int.Managed sqrt(n) succeed with res.bitCountAbs() >= usize bits" {3194test "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}
495495
496test "big.rational extractLowBits" {496test 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();
499499
...@@ -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}
515515
516test "big.rational set" {516test "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();
519519
...@@ -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}
544544
545test "big.rational setFloat" {545test "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();
548548
...@@ -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}
569569
570test "big.rational setFloatString" {570test "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();
573573
...@@ -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}
580580
581test "big.rational toFloat" {581test "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();
584584
...@@ -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}
593593
594test "big.rational set/to Float round-trip" {594test "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}
606606
607test "big.rational copy" {607test "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();
610610
...@@ -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}
636636
637test "big.rational negate" {637test "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();
640640
...@@ -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}
653653
654test "big.rational abs" {654test "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();
657657
...@@ -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}
670670
671test "big.rational swap" {671test "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}
694694
695test "big.rational order" {695test "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}
709709
710test "big.rational order/orderAbs with negative" {710test "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}
721721
722test "big.rational add single-limb" {722test "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}
736736
737test "big.rational add" {737test "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}
752752
753test "big.rational sub" {753test "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}
768768
769test "big.rational mul" {769test "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}
784784
785test "big.rational div" {785test "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}
121121
122test "math.cbrt" {122test 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}
126126
127test "math.cbrt32" {127test cbrt32 {
128 const epsilon = 0.000001;128 const epsilon = 0.000001;
129129
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}
137137
138test "math.cbrt64" {138test cbrt64 {
139 const epsilon = 0.000001;139 const epsilon = 0.000001;
140140
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}
148148
149test "math.cbrt.special" {149test "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}
156156
157test "math.cbrt64.special" {157test "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 {
120120
121const epsilon = 0.0001;121const epsilon = 0.0001;
122122
123test "complex.add" {123test "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}
130130
131test "complex.sub" {131test "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}
138138
139test "complex.mul" {139test "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}
146146
147test "complex.div" {147test "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}
155155
156test "complex.conjugate" {156test "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();
159159
160 try testing.expect(c.re == 5 and c.im == -3);160 try testing.expect(c.re == 5 and c.im == -3);
161}161}
162162
163test "complex.neg" {163test "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();
166166
167 try testing.expect(c.re == -5 and c.im == -3);167 try testing.expect(c.re == -5 and c.im == -3);
168}168}
169169
170test "complex.mulbyi" {170test "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();
173173
174 try testing.expect(c.re == -3 and c.im == 5);174 try testing.expect(c.re == -3 and c.im == 5);
175}175}
176176
177test "complex.reciprocal" {177test "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();
180180
...@@ -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}
184184
185test "complex.magnitude" {185test "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();
188188
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) {
1111
12const epsilon = 0.0001;12const epsilon = 0.0001;
1313
14test "complex.cabs" {14test 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)) {
1313
14const epsilon = 0.0001;14const epsilon = 0.0001;
1515
16test "complex.cacos" {16test 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);
1919
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)) {
1313
14const epsilon = 0.0001;14const epsilon = 0.0001;
1515
16test "complex.cacosh" {16test 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);
1919
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) {
1111
12const epsilon = 0.0001;12const epsilon = 0.0001;
1313
14test "complex.carg" {14test 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)) {
1919
20const epsilon = 0.0001;20const epsilon = 0.0001;
2121
22test "complex.casin" {22test 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);
2525
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)) {
1414
15const epsilon = 0.0001;15const epsilon = 0.0001;
1616
17test "complex.casinh" {17test 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);
2020
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) {
120120
121const epsilon = 0.0001;121const epsilon = 0.0001;
122122
123test "complex.catan32" {123test 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);
126126
...@@ -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}
130130
131test "complex.catan64" {131test 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);
134134
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)) {
1414
15const epsilon = 0.0001;15const epsilon = 0.0001;
1616
17test "complex.catanh" {17test 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);
2020
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}
1212
13test "complex.conj" {13test conj {
14 const a = Complex(f32).init(5, 3);14 const a = Complex(f32).init(5, 3);
15 const c = a.conjugate();15 const c = a.conjugate();
1616
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)) {
1313
14const epsilon = 0.0001;14const epsilon = 0.0001;
1515
16test "complex.ccos" {16test 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);
1919
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) {
155155
156const epsilon = 0.0001;156const epsilon = 0.0001;
157157
158test "complex.ccosh32" {158test 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);
161161
...@@ -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}
165165
166test "complex.ccosh64" {166test 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);
169169
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}
121121
122test "complex.cexp32" {122test exp32 {
123 const tolerance_f32 = @sqrt(math.floatEps(f32));123 const tolerance_f32 = @sqrt(math.floatEps(f32));
124124
125 {125 {
...@@ -139,7 +139,7 @@ test "complex.cexp32" {...@@ -139,7 +139,7 @@ test "complex.cexp32" {
139 }139 }
140}140}
141141
142test "complex.cexp64" {142test exp64 {
143 const tolerance_f64 = @sqrt(math.floatEps(f64));143 const tolerance_f64 = @sqrt(math.floatEps(f64));
144144
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)) {
1515
16const epsilon = 0.0001;16const epsilon = 0.0001;
1717
18test "complex.clog" {18test 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);
2121
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)) {
1111
12const epsilon = 0.0001;12const epsilon = 0.0001;
1313
14test "complex.cpow" {14test pow {
15 const a = Complex(f32).init(5, 3);15 const a = Complex(f32).init(5, 3);
16 const b = Complex(f32).init(2.3, -1.3);16 const b = Complex(f32).init(2.3, -1.3);
17 const c = pow(a, b);17 const c = pow(a, b);
lib/std/math/complex/proj.zig+1-3
...@@ -15,9 +15,7 @@ pub fn proj(z: anytype) Complex(@TypeOf(z.re, z.im)) {...@@ -15,9 +15,7 @@ pub fn proj(z: anytype) Complex(@TypeOf(z.re, z.im)) {
15 return Complex(T).init(z.re, z.im);15 return Complex(T).init(z.re, z.im);
16}16}
1717
18const epsilon = 0.0001;18test proj {
19
20test "complex.cproj" {
21 const a = Complex(f32).init(5, 3);19 const a = Complex(f32).init(5, 3);
22 const c = proj(a);20 const c = proj(a);
2321
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)) {
1414
15const epsilon = 0.0001;15const epsilon = 0.0001;
1616
17test "complex.csin" {17test 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);
2020
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) {
154154
155const epsilon = 0.0001;155const epsilon = 0.0001;
156156
157test "complex.csinh32" {157test 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);
160160
...@@ -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}
164164
165test "complex.csinh64" {165test 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);
168168
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) {
129129
130const epsilon = 0.0001;130const epsilon = 0.0001;
131131
132test "complex.csqrt32" {132test 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);
135135
...@@ -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}
139139
140test "complex.csqrt64" {140test 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);
143143
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)) {
1414
15const epsilon = 0.0001;15const epsilon = 0.0001;
1616
17test "complex.ctan" {17test 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);
2020
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) {
103103
104const epsilon = 0.0001;104const epsilon = 0.0001;
105105
106test "complex.ctanh32" {106test 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);
109109
...@@ -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}
113113
114test "complex.ctanh64" {114test 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);
117117
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}
1414
15test "math.copysign" {15test 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}
8888
89test "math.cosh" {89test 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}
9393
94test "math.cosh32" {94test cosh32 {
95 const epsilon = 0.000001;95 const epsilon = 0.000001;
9696
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}
106106
107test "math.cosh64" {107test cosh64 {
108 const epsilon = 0.000001;108 const epsilon = 0.000001;
109109
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}
119119
120test "math.cosh32.special" {120test "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}
127127
128test "math.cosh64.special" {128test "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}
288288
289test "math.exp1m" {289test expm1 {
290 try expect(expm1(@as(f32, 0.0)) == expm1_32(0.0));290 try expect(expm1(@as(f32, 0.0)) == expm1_32(0.0));
291 try expect(expm1(@as(f64, 0.0)) == expm1_64(0.0));291 try expect(expm1(@as(f64, 0.0)) == expm1_64(0.0));
292}292}
293293
294test "math.expm1_32" {294test expm1_32 {
295 const epsilon = 0.000001;295 const epsilon = 0.000001;
296296
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}
303303
304test "math.expm1_64" {304test expm1_64 {
305 const epsilon = 0.000001;305 const epsilon = 0.000001;
306306
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}
313313
314test "math.expm1_32.special" {314test "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}
319319
320test "math.expm1_64.special" {320test "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}
134134
135test "math.inf" {135test 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}
147147
148test "math.nan" {148test 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}
160160
161test "math.snan" {161test snan {
162 // TODO: https://github.com/ziglang/zig/issues/14366162 // 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;
164164
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;
240const expectEqual = std.testing.expectEqual;240const expectEqual = std.testing.expectEqual;
241const expectApproxEqRel = std.testing.expectApproxEqRel;241const expectApproxEqRel = std.testing.expectApproxEqRel;
242242
243test "math.gamma" {243test 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}
263263
264test "math.gamma.special" {264test "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}
288288
289test "math.lgamma" {289test 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}
309309
310test "math.lgamma.special" {310test "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}
126126
127test "math.hypot" {127test 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}
135135
136test "math.hypot32" {136test hypot32 {
137 const epsilon = 0.000001;137 const epsilon = 0.000001;
138138
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}
147147
148test "math.hypot64" {148test hypot64 {
149 const epsilon = 0.000001;149 const epsilon = 0.000001;
150150
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}
159159
160test "math.hypot32.special" {160test "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}
168168
169test "math.hypot64.special" {169test "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}
1212
13test "math.isFinite" {13test isFinite {
14 inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| {14 inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| {
15 // normals15 // 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}
2222
23test "math.isInf" {23test 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}
3333
34test "math.isPositiveInf" {34test 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}
4444
45test "math.isNegativeInf" {45test 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}
1919
20test "math.isNan" {20test 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}
2929
30test "math.isSignalNan" {30test 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 in32 // 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}
2121
22test "math.isNormal" {22test isNormal {
23 // TODO add `c_longdouble' when math.inf(T) supports it23 // 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}
6868
69test "math.ldexp" {69test ldexp {
70 // subnormals70 // 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}
4949
50test "math.log integer" {50test "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}
5757
58test "math.log float" {58test "log float" {
59 const epsilon = 0.000001;59 const epsilon = 0.000001;
6060
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}
6565
66test "math.log float_special" {66test "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)));
6969
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}
184184
185test "math.log1p" {185test 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}
189189
190test "math.log1p_32" {190test log1p_32 {
191 const epsilon = 0.000001;191 const epsilon = 0.000001;
192192
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}
201201
202test "math.log1p_64" {202test log1p_64 {
203 const epsilon = 0.000001;203 const epsilon = 0.000001;
204204
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}
213213
214test "math.log1p_32.special" {214test "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}
222222
223test "math.log1p_64.special" {223test "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/log2.zig+1-1
...@@ -42,7 +42,7 @@ pub fn log2(x: anytype) @TypeOf(x) {...@@ -42,7 +42,7 @@ pub fn log2(x: anytype) @TypeOf(x) {
42 }42 }
43}43}
4444
45test "log2" {45test log2 {
46 // https://github.com/ziglang/zig/issues/1370346 // https://github.com/ziglang/zig/issues/13703
47 if (builtin.cpu.arch == .aarch64 and builtin.os.tag == .windows) return error.SkipZigTest;47 if (builtin.cpu.arch == .aarch64 and builtin.os.tag == .windows) return error.SkipZigTest;
4848
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}
6262
63test "math.log_int" {63test "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}
9494
95test "math.log_int vs math.log2" {95test "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}
107107
108test "math.log_int vs math.log10" {108test "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}
120120
121test "math.log_int at comptime" {121test "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}
125125
126test "math.modf" {126test 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}
132132
133test "math.modf32" {133test modf32 {
134 const epsilon = 0.000001;134 const epsilon = 0.000001;
135 var r: modf32_result = undefined;135 var r: modf32_result = undefined;
136136
...@@ -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}
157157
158test "math.modf64" {158test modf64 {
159 const epsilon = 0.000001;159 const epsilon = 0.000001;
160 var r: modf64_result = undefined;160 var r: modf64_result = undefined;
161161
...@@ -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}
182182
183test "math.modf32.special" {183test "modf32.special" {
184 var r: modf32_result = undefined;184 var r: modf32_result = undefined;
185185
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}
195195
196test "math.modf64.special" {196test "modf64.special" {
197 var r: modf64_result = undefined;197 var r: modf64_result = undefined;
198198
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}
103103
104test "math.nextAfter.int" {104test "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}
145145
146test "math.nextAfter.float" {146test "float" {
147 @setEvalBranchQuota(2000);147 @setEvalBranchQuota(2000);
148148
149 // normal -> normal149 // 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}
192192
193test "math.pow.isOddInteger" {193test 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}
200200
201test "math.pow" {201test pow {
202 const epsilon = 0.000001;202 const epsilon = 0.000001;
203203
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}
218218
219test "math.pow.special" {219test "special" {
220 const epsilon = 0.000001;220 const epsilon = 0.000001;
221221
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}
260260
261test "math.pow.overflow" {261test "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}
9393
94test "math.powi" {94test 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}
143143
144test "math.powi.special" {144test "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}
188188
189test "math.powi.narrow" {189test "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.
7pub const scalbn = @import("ldexp.zig").ldexp;7pub const scalbn = @import("ldexp.zig").ldexp;
88
9test "math.scalbn" {9test 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}
1111
12test "math.signbit" {12test 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}
9393
94test "math.sinh" {94test 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}
9898
99test "math.sinh32" {99test sinh32 {
100 const epsilon = 0.000001;100 const epsilon = 0.000001;
101101
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}
111111
112test "math.sinh64" {112test sinh64 {
113 const epsilon = 0.000001;113 const epsilon = 0.000001;
114114
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}
124124
125test "math.sinh32.special" {125test "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}
132132
133test "math.sinh64.special" {133test "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}
6363
64test "math.sqrt_int" {64test 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}
106106
107test "math.tanh" {107test 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}
111111
112test "math.tanh32" {112test tanh32 {
113 const epsilon = 0.000001;113 const epsilon = 0.000001;
114114
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}
124124
125test "math.tanh64" {125test tanh64 {
126 const epsilon = 0.000001;126 const epsilon = 0.000001;
127127
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}
137137
138test "math.tanh32.special" {138test "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}
145145
146test "math.tanh64.special" {146test "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+26-26
...@@ -46,7 +46,7 @@ pub fn stringToEnum(comptime T: type, str: []const u8) ?T {...@@ -46,7 +46,7 @@ pub fn stringToEnum(comptime T: type, str: []const u8) ?T {
46 }46 }
47}47}
4848
49test "std.meta.stringToEnum" {49test 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}
7575
76test "std.meta.alignment" {76test 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}
9696
97test "std.meta.Child" {97test 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}
123123
124test "std.meta.Elem" {124test 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}
257257
258test "std.meta.containerLayout" {258test 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}
291291
292test "std.meta.declarations" {292test declarations {
293 const E1 = enum {293 const E1 = enum {
294 A,294 A,
295295
...@@ -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}
331331
332test "std.meta.declarationInfo" {332test declarationInfo {
333 const E1 = enum {333 const E1 = enum {
334 A,334 A,
335335
...@@ -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}
372372
373test "std.meta.fields" {373test 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}
411411
412test "std.meta.fieldInfo" {412test 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}
444444
445test "std.meta.FieldType" {445test 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}
472472
473test "std.meta.fieldNames" {473test 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}
513513
514test "std.meta.tags" {514test tags {
515 const E1 = enum { A, B };515 const E1 = enum { A, B };
516 const E2 = error{A};516 const E2 = error{A};
517517
...@@ -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}
606606
607test "std.meta.FieldEnum" {607test 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}
641641
642test "std.meta.DeclEnum" {642test 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}
672672
673test "std.meta.Tag" {673test 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}
692692
693test "std.meta.activeTag" {693test 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}
729729
730test "std.meta.TagPayload" {730test 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}
804804
805test "std.meta.eql" {805test eql {
806 const S = struct {806 const S = struct {
807 a: u32,807 a: u32,
808 b: f64,808 b: f64,
...@@ -863,7 +863,7 @@ test "std.meta.eql" {...@@ -863,7 +863,7 @@ test "std.meta.eql" {
863 try testing.expect(!eql(v1, v3));863 try testing.expect(!eql(v1, v3));
864}864}
865865
866test "intToEnum with error return" {866test intToEnum {
867 const E1 = enum {867 const E1 = enum {
868 A,868 A,
869 };869 };
...@@ -965,7 +965,7 @@ pub fn Float(comptime bit_count: u8) type {...@@ -965,7 +965,7 @@ pub fn Float(comptime bit_count: u8) type {
965 });965 });
966}966}
967967
968test "std.meta.Float" {968test Float {
969 try testing.expectEqual(f16, Float(16));969 try testing.expectEqual(f16, Float(16));
970 try testing.expectEqual(f32, Float(32));970 try testing.expectEqual(f32, Float(32));
971 try testing.expectEqual(f64, Float(64));971 try testing.expectEqual(f64, Float(64));
...@@ -1057,7 +1057,7 @@ const TupleTester = struct {...@@ -1057,7 +1057,7 @@ const TupleTester = struct {
1057 }1057 }
1058};1058};
10591059
1060test "ArgsTuple" {1060test ArgsTuple {
1061 TupleTester.assertTuple(.{}, ArgsTuple(fn () void));1061 TupleTester.assertTuple(.{}, ArgsTuple(fn () void));
1062 TupleTester.assertTuple(.{u32}, ArgsTuple(fn (a: u32) []const u8));1062 TupleTester.assertTuple(.{u32}, ArgsTuple(fn (a: u32) []const u8));
1063 TupleTester.assertTuple(.{ u32, f16 }, ArgsTuple(fn (a: u32, b: f16) noreturn));1063 TupleTester.assertTuple(.{ u32, f16 }, ArgsTuple(fn (a: u32, b: f16) noreturn));
...@@ -1065,7 +1065,7 @@ test "ArgsTuple" {...@@ -1065,7 +1065,7 @@ test "ArgsTuple" {
1065 TupleTester.assertTuple(.{u32}, ArgsTuple(fn (comptime a: u32) []const u8));1065 TupleTester.assertTuple(.{u32}, ArgsTuple(fn (comptime a: u32) []const u8));
1066}1066}
10671067
1068test "Tuple" {1068test Tuple {
1069 TupleTester.assertTuple(.{}, Tuple(&[_]type{}));1069 TupleTester.assertTuple(.{}, Tuple(&[_]type{}));
1070 TupleTester.assertTuple(.{u32}, Tuple(&[_]type{u32}));1070 TupleTester.assertTuple(.{u32}, Tuple(&[_]type{u32}));
1071 TupleTester.assertTuple(.{ u32, f16 }, Tuple(&[_]type{ u32, f16 }));1071 TupleTester.assertTuple(.{ u32, f16 }, Tuple(&[_]type{ u32, f16 }));
...@@ -1103,7 +1103,7 @@ pub fn isError(error_union: anytype) bool {...@@ -1103,7 +1103,7 @@ pub fn isError(error_union: anytype) bool {
1103 return if (error_union) |_| false else |_| true;1103 return if (error_union) |_| false else |_| true;
1104}1104}
11051105
1106test "isError" {1106test isError {
1107 try std.testing.expect(isError(math.divTrunc(u8, 5, 0)));1107 try std.testing.expect(isError(math.divTrunc(u8, 5, 0)));
1108 try std.testing.expect(!isError(math.divTrunc(u8, 5, 5)));1108 try std.testing.expect(!isError(math.divTrunc(u8, 5, 5)));
1109}1109}
...@@ -1121,7 +1121,7 @@ pub inline fn hasFn(comptime T: type, comptime name: []const u8) bool {...@@ -1121,7 +1121,7 @@ pub inline fn hasFn(comptime T: type, comptime name: []const u8) bool {
1121 return @typeInfo(@TypeOf(@field(T, name))) == .Fn;1121 return @typeInfo(@TypeOf(@field(T, name))) == .Fn;
1122}1122}
11231123
1124test "hasFn" {1124test hasFn {
1125 const S1 = struct {1125 const S1 = struct {
1126 pub fn foo() void {}1126 pub fn foo() void {}
1127 };1127 };
...@@ -1149,7 +1149,7 @@ pub inline fn hasMethod(comptime T: type, comptime name: []const u8) bool {...@@ -1149,7 +1149,7 @@ pub inline fn hasMethod(comptime T: type, comptime name: []const u8) bool {
1149 };1149 };
1150}1150}
11511151
1152test "hasMethod" {1152test hasMethod {
1153 try std.testing.expect(!hasMethod(u32, "foo"));1153 try std.testing.expect(!hasMethod(u32, "foo"));
1154 try std.testing.expect(!hasMethod([]u32, "len"));1154 try std.testing.expect(!hasMethod([]u32, "len"));
1155 try std.testing.expect(!hasMethod(struct { u32, u64 }, "len"));1155 try std.testing.expect(!hasMethod(struct { u32, u64 }, "len"));
...@@ -1218,7 +1218,7 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool {...@@ -1218,7 +1218,7 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool {
1218 };1218 };
1219}1219}
12201220
1221test "hasUniqueRepresentation" {1221test hasUniqueRepresentation {
1222 const TestStruct1 = struct {1222 const TestStruct1 = struct {
1223 a: u32,1223 a: u32,
1224 b: u32,1224 b: u32,
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}
395395
396test "std.Thread.getCurrentId" {396test "Thread.getCurrentId" {
397 if (builtin.single_threaded) return error.SkipZigTest;397 if (builtin.single_threaded) return error.SkipZigTest;
398398
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 {
467467
468const PDQ = PriorityDequeue(u32, void, lessThanComparison);468const PDQ = PriorityDequeue(u32, void, lessThanComparison);
469469
470test "std.PriorityDequeue: add and remove min" {470test "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();
473473
...@@ -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}
488488
489test "std.PriorityDequeue: add and remove min structs" {489test "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}
515515
516test "std.PriorityDequeue: add and remove max" {516test "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();
519519
...@@ -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}
534534
535test "std.PriorityDequeue: add and remove same min" {535test "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();
538538
...@@ -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}
553553
554test "std.PriorityDequeue: add and remove same max" {554test "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();
557557
...@@ -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}
572572
573test "std.PriorityDequeue: removeOrNull empty" {573test "removeOrNull empty" {
574 var queue = PDQ.init(testing.allocator, {});574 var queue = PDQ.init(testing.allocator, {});
575 defer queue.deinit();575 defer queue.deinit();
576576
...@@ -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}
580580
581test "std.PriorityDequeue: edge case 3 elements" {581test "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();
584584
...@@ -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}
593593
594test "std.PriorityDequeue: edge case 3 elements max" {594test "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();
597597
...@@ -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}
606606
607test "std.PriorityDequeue: peekMin" {607test "peekMin" {
608 var queue = PDQ.init(testing.allocator, {});608 var queue = PDQ.init(testing.allocator, {});
609 defer queue.deinit();609 defer queue.deinit();
610610
...@@ -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}
620620
621test "std.PriorityDequeue: peekMax" {621test "peekMax" {
622 var queue = PDQ.init(testing.allocator, {});622 var queue = PDQ.init(testing.allocator, {});
623 defer queue.deinit();623 defer queue.deinit();
624624
...@@ -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}
634634
635test "std.PriorityDequeue: sift up with odd indices, removeMin" {635test "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}
648648
649test "std.PriorityDequeue: sift up with odd indices, removeMax" {649test "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}
662662
663test "std.PriorityDequeue: addSlice min" {663test "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}
674674
675test "std.PriorityDequeue: addSlice max" {675test "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}
686686
687test "std.PriorityDequeue: fromOwnedSlice trivial case 0" {687test "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}
695695
696test "std.PriorityDequeue: fromOwnedSlice trivial case 1" {696test "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}
706706
707test "std.PriorityDequeue: fromOwnedSlice" {707test "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}
718718
719test "std.PriorityDequeue: update min queue" {719test "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();
722722
...@@ -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}
733733
734test "std.PriorityDequeue: update same min queue" {734test "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();
737737
...@@ -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}
749749
750test "std.PriorityDequeue: update max queue" {750test "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();
753753
...@@ -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}
765765
766test "std.PriorityDequeue: update same max queue" {766test "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();
769769
...@@ -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}
781781
782test "std.PriorityDequeue: update after remove" {782test "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();
785785
...@@ -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}
790790
791test "std.PriorityDequeue: iterator" {791test "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}
812812
813test "std.PriorityDequeue: remove at index" {813test "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();
816816
...@@ -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}
835835
836test "std.PriorityDequeue: iterator while empty" {836test "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();
839839
...@@ -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}
844844
845test "std.PriorityDequeue: shrinkAndFree" {845test "shrinkAndFree" {
846 var queue = PDQ.init(testing.allocator, {});846 var queue = PDQ.init(testing.allocator, {});
847 defer queue.deinit();847 defer queue.deinit();
848848
...@@ -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}
867867
868test "std.PriorityDequeue: fuzz testing min" {868test "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();
871871
...@@ -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}
896896
897test "std.PriorityDequeue: fuzz testing max" {897test "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();
900900
...@@ -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}
925925
926test "std.PriorityDequeue: fuzz testing min and max" {926test "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();
929929
...@@ -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 {
982982
983const CPDQ = PriorityDequeue(usize, []const u32, contextLessThanComparison);983const CPDQ = PriorityDequeue(usize, []const u32, contextLessThanComparison);
984984
985test "std.PriorityDequeue: add and remove" {985test "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 };
987987
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" {
10061006
1007var all_cmps_unique = true;1007var all_cmps_unique = true;
10081008
1009test "std.PriorityDeque: don't compare a value to a copy of itself" {1009test "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 {
271const PQlt = PriorityQueue(u32, void, lessThan);271const PQlt = PriorityQueue(u32, void, lessThan);
272const PQgt = PriorityQueue(u32, void, greaterThan);272const PQgt = PriorityQueue(u32, void, greaterThan);
273273
274test "std.PriorityQueue: add and remove min heap" {274test "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();
277277
...@@ -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}
291291
292test "std.PriorityQueue: add and remove same min heap" {292test "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();
295295
...@@ -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}
309309
310test "std.PriorityQueue: removeOrNull on empty" {310test "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();
313313
314 try expect(queue.removeOrNull() == null);314 try expect(queue.removeOrNull() == null);
315}315}
316316
317test "std.PriorityQueue: edge case 3 elements" {317test "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();
320320
...@@ -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}
328328
329test "std.PriorityQueue: peek" {329test "peek" {
330 var queue = PQlt.init(testing.allocator, {});330 var queue = PQlt.init(testing.allocator, {});
331 defer queue.deinit();331 defer queue.deinit();
332332
...@@ -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}
340340
341test "std.PriorityQueue: sift up with odd indices" {341test "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}
354354
355test "std.PriorityQueue: addSlice" {355test "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}
366366
367test "std.PriorityQueue: fromOwnedSlice trivial case 0" {367test "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}
375375
376test "std.PriorityQueue: fromOwnedSlice trivial case 1" {376test "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}
386386
387test "std.PriorityQueue: fromOwnedSlice" {387test "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}
398398
399test "std.PriorityQueue: add and remove max heap" {399test "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();
402402
...@@ -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}
416416
417test "std.PriorityQueue: add and remove same max heap" {417test "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();
420420
...@@ -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}
434434
435test "std.PriorityQueue: iterator" {435test "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}
456456
457test "std.PriorityQueue: remove at index" {457test "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();
460460
...@@ -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}
482482
483test "std.PriorityQueue: iterator while empty" {483test "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();
486486
...@@ -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}
491491
492test "std.PriorityQueue: shrinkAndFree" {492test "shrinkAndFree" {
493 var queue = PQlt.init(testing.allocator, {});493 var queue = PQlt.init(testing.allocator, {});
494 defer queue.deinit();494 defer queue.deinit();
495495
...@@ -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}
514514
515test "std.PriorityQueue: update min heap" {515test "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();
518518
...@@ -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}
529529
530test "std.PriorityQueue: update same min heap" {530test "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();
533533
...@@ -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}
545545
546test "std.PriorityQueue: update max heap" {546test "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();
549549
...@@ -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}
560560
561test "std.PriorityQueue: update same max heap" {561test "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();
564564
...@@ -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}
576576
577test "std.PriorityQueue: update after remove" {577test "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();
580580
...@@ -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}
585585
586test "std.PriorityQueue: siftUp in remove" {586test "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();
589589
...@@ -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 {
603603
604const CPQlt = PriorityQueue(usize, []const u32, contextLessThan);604const CPQlt = PriorityQueue(usize, []const u32, contextLessThan);
605605
606test "std.PriorityQueue: add and remove min heap with contextful comparator" {606test "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 };
608608
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}
410410
411test "SegmentedList basic usage" {411test "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}
509509
510test "std.segmented_list clearRetainingCapacity" {510test "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);
513513
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 {
349const TestTreap = Treap(u64, std.math.order);349const TestTreap = Treap(u64, std.math.order);
350const TestNode = TestTreap.Node;350const TestNode = TestTreap.Node;
351351
352test "std.Treap: insert, find, replace, remove" {352test "insert, find, replace, remove" {
353 var treap = TestTreap{};353 var treap = TestTreap{};
354 var nodes: [10]TestNode = undefined;354 var nodes: [10]TestNode = undefined;
355355
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}
203203
204test "Wasm - opcodes" {204test "opcodes" {
205 // Ensure our opcodes values remain intact as certain values are skipped due to them being reserved205 // 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}
627627
628test "Wasm - valtypes" {628test "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);