authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-11 22:47:45-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-11 22:47:45-07:00
log98c950827f9e57ab4736140eede61eac6858157f
treef84582fc9078ff765a130dc7d30a6d5980437651
parent0f3e8497195f383b9f2eb8cddd84f4966502f521

std.math: remove redundant namespace in test names

related: #7923

1 files changed, 29 insertions(+), 29 deletions(-)

lib/std/math.zig+29-29
......@@ -366,7 +366,7 @@ pub fn min(x: anytype, y: anytype) Min(@TypeOf(x), @TypeOf(y)) {
366366 }
367367}
368368
369test "math.min" {
369test "min" {
370370 try testing.expect(min(@as(i32, -1), @as(i32, 2)) == -1);
371371 {
372372 var a: u16 = 999;
......@@ -403,7 +403,7 @@ pub fn min3(x: anytype, y: anytype, z: anytype) @TypeOf(x, y, z) {
403403 return min(x, min(y, z));
404404}
405405
406test "math.min3" {
406test "min3" {
407407 try testing.expect(min3(@as(i32, 0), @as(i32, 1), @as(i32, 2)) == 0);
408408 try testing.expect(min3(@as(i32, 0), @as(i32, 2), @as(i32, 1)) == 0);
409409 try testing.expect(min3(@as(i32, 1), @as(i32, 0), @as(i32, 2)) == 0);
......@@ -418,7 +418,7 @@ pub fn max(x: anytype, y: anytype) @TypeOf(x, y) {
418418 return if (x > y) x else y;
419419}
420420
421test "math.max" {
421test "max" {
422422 try testing.expect(max(@as(i32, -1), @as(i32, 2)) == 2);
423423 try testing.expect(max(@as(i32, 2), @as(i32, -1)) == 2);
424424}
......@@ -428,7 +428,7 @@ pub fn max3(x: anytype, y: anytype, z: anytype) @TypeOf(x, y, z) {
428428 return max(x, max(y, z));
429429}
430430
431test "math.max3" {
431test "max3" {
432432 try testing.expect(max3(@as(i32, 0), @as(i32, 1), @as(i32, 2)) == 2);
433433 try testing.expect(max3(@as(i32, 0), @as(i32, 2), @as(i32, 1)) == 2);
434434 try testing.expect(max3(@as(i32, 1), @as(i32, 0), @as(i32, 2)) == 2);
......@@ -442,7 +442,7 @@ pub fn clamp(val: anytype, lower: anytype, upper: anytype) @TypeOf(val, lower, u
442442 assert(lower <= upper);
443443 return max(lower, min(val, upper));
444444}
445test "math.clamp" {
445test "clamp" {
446446 // Within range
447447 try testing.expect(std.math.clamp(@as(i32, -1), @as(i32, -4), @as(i32, 7)) == -1);
448448 // Below
......@@ -515,7 +515,7 @@ pub fn shl(comptime T: type, a: T, shift_amt: anytype) T {
515515 return a << casted_shift_amt;
516516}
517517
518test "math.shl" {
518test "shl" {
519519 try testing.expect(shl(u8, 0b11111111, @as(usize, 3)) == 0b11111000);
520520 try testing.expect(shl(u8, 0b11111111, @as(usize, 8)) == 0);
521521 try testing.expect(shl(u8, 0b11111111, @as(usize, 9)) == 0);
......@@ -555,7 +555,7 @@ pub fn shr(comptime T: type, a: T, shift_amt: anytype) T {
555555 return a >> casted_shift_amt;
556556}
557557
558test "math.shr" {
558test "shr" {
559559 try testing.expect(shr(u8, 0b11111111, @as(usize, 3)) == 0b00011111);
560560 try testing.expect(shr(u8, 0b11111111, @as(usize, 8)) == 0);
561561 try testing.expect(shr(u8, 0b11111111, @as(usize, 9)) == 0);
......@@ -587,7 +587,7 @@ pub fn rotr(comptime T: type, x: T, r: anytype) T {
587587 }
588588}
589589
590test "math.rotr" {
590test "rotr" {
591591 try testing.expect(rotr(u8, 0b00000001, @as(usize, 0)) == 0b00000001);
592592 try testing.expect(rotr(u8, 0b00000001, @as(usize, 9)) == 0b10000000);
593593 try testing.expect(rotr(u8, 0b00000001, @as(usize, 8)) == 0b00000001);
......@@ -615,7 +615,7 @@ pub fn rotl(comptime T: type, x: T, r: anytype) T {
615615 }
616616}
617617
618test "math.rotl" {
618test "rotl" {
619619 try testing.expect(rotl(u8, 0b00000001, @as(usize, 0)) == 0b00000001);
620620 try testing.expect(rotl(u8, 0b00000001, @as(usize, 9)) == 0b00000010);
621621 try testing.expect(rotl(u8, 0b00000001, @as(usize, 8)) == 0b00000001);
......@@ -667,7 +667,7 @@ pub fn IntFittingRange(comptime from: comptime_int, comptime to: comptime_int) t
667667 return std.meta.Int(sign, magnitude_bits);
668668}
669669
670test "math.IntFittingRange" {
670test "IntFittingRange" {
671671 try testing.expect(IntFittingRange(0, 0) == u0);
672672 try testing.expect(IntFittingRange(0, 1) == u1);
673673 try testing.expect(IntFittingRange(0, 2) == u2);
......@@ -714,7 +714,7 @@ test "math.IntFittingRange" {
714714 try testing.expect(IntFittingRange(-1, 123456789123456798123456789123456789123456798123456789) == i178);
715715}
716716
717test "math overflow functions" {
717test "overflow functions" {
718718 try testOverflow();
719719 comptime try testOverflow();
720720}
......@@ -741,7 +741,7 @@ pub fn absInt(x: anytype) !@TypeOf(x) {
741741 }
742742}
743743
744test "math.absInt" {
744test "absInt" {
745745 try testAbsInt();
746746 comptime try testAbsInt();
747747}
......@@ -752,7 +752,7 @@ fn testAbsInt() !void {
752752
753753pub const absFloat = fabs;
754754
755test "math.absFloat" {
755test "absFloat" {
756756 try testAbsFloat();
757757 comptime try testAbsFloat();
758758}
......@@ -770,7 +770,7 @@ pub fn divTrunc(comptime T: type, numerator: T, denominator: T) !T {
770770 return @divTrunc(numerator, denominator);
771771}
772772
773test "math.divTrunc" {
773test "divTrunc" {
774774 try testDivTrunc();
775775 comptime try testDivTrunc();
776776}
......@@ -794,7 +794,7 @@ pub fn divFloor(comptime T: type, numerator: T, denominator: T) !T {
794794 return @divFloor(numerator, denominator);
795795}
796796
797test "math.divFloor" {
797test "divFloor" {
798798 try testDivFloor();
799799 comptime try testDivFloor();
800800}
......@@ -831,7 +831,7 @@ pub fn divCeil(comptime T: type, numerator: T, denominator: T) !T {
831831 }
832832}
833833
834test "math.divCeil" {
834test "divCeil" {
835835 try testDivCeil();
836836 comptime try testDivCeil();
837837}
......@@ -875,7 +875,7 @@ pub fn divExact(comptime T: type, numerator: T, denominator: T) !T {
875875 return result;
876876}
877877
878test "math.divExact" {
878test "divExact" {
879879 try testDivExact();
880880 comptime try testDivExact();
881881}
......@@ -901,7 +901,7 @@ pub fn mod(comptime T: type, numerator: T, denominator: T) !T {
901901 return @mod(numerator, denominator);
902902}
903903
904test "math.mod" {
904test "mod" {
905905 try testMod();
906906 comptime try testMod();
907907}
......@@ -927,7 +927,7 @@ pub fn rem(comptime T: type, numerator: T, denominator: T) !T {
927927 return @rem(numerator, denominator);
928928}
929929
930test "math.rem" {
930test "rem" {
931931 try testRem();
932932 comptime try testRem();
933933}
......@@ -971,7 +971,7 @@ pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) {
971971 }
972972}
973973
974test "math.absCast" {
974test "absCast" {
975975 try testing.expectEqual(@as(u1, 1), absCast(@as(i1, -1)));
976976 try testing.expectEqual(@as(u32, 999), absCast(@as(i32, -999)));
977977 try testing.expectEqual(@as(u32, 999), absCast(@as(i32, 999)));
......@@ -992,7 +992,7 @@ pub fn negateCast(x: anytype) !std.meta.Int(.signed, std.meta.bitCount(@TypeOf(x
992992 return -@intCast(int, x);
993993}
994994
995test "math.negateCast" {
995test "negateCast" {
996996 try testing.expect((negateCast(@as(u32, 999)) catch unreachable) == -999);
997997 try testing.expect(@TypeOf(negateCast(@as(u32, 999)) catch unreachable) == i32);
998998
......@@ -1017,7 +1017,7 @@ pub fn cast(comptime T: type, x: anytype) (error{Overflow}!T) {
10171017 }
10181018}
10191019
1020test "math.cast" {
1020test "cast" {
10211021 try testing.expectError(error.Overflow, cast(u8, @as(u32, 300)));
10221022 try testing.expectError(error.Overflow, cast(i8, @as(i32, -200)));
10231023 try testing.expectError(error.Overflow, cast(u8, @as(i8, -1)));
......@@ -1051,7 +1051,7 @@ pub fn floorPowerOfTwo(comptime T: type, value: T) T {
10511051 return @as(T, 1) << log2_int(uT, @intCast(uT, value));
10521052}
10531053
1054test "math.floorPowerOfTwo" {
1054test "floorPowerOfTwo" {
10551055 try testFloorPowerOfTwo();
10561056 comptime try testFloorPowerOfTwo();
10571057}
......@@ -1106,7 +1106,7 @@ pub fn ceilPowerOfTwoAssert(comptime T: type, value: T) T {
11061106 return ceilPowerOfTwo(T, value) catch unreachable;
11071107}
11081108
1109test "math.ceilPowerOfTwoPromote" {
1109test "ceilPowerOfTwoPromote" {
11101110 try testCeilPowerOfTwoPromote();
11111111 comptime try testCeilPowerOfTwoPromote();
11121112}
......@@ -1123,7 +1123,7 @@ fn testCeilPowerOfTwoPromote() !void {
11231123 try testing.expectEqual(@as(u5, 16), ceilPowerOfTwoPromote(u4, 9));
11241124}
11251125
1126test "math.ceilPowerOfTwo" {
1126test "ceilPowerOfTwo" {
11271127 try testCeilPowerOfTwo();
11281128 comptime try testCeilPowerOfTwo();
11291129}
......@@ -1214,13 +1214,13 @@ pub fn lossyCast(comptime T: type, value: anytype) T {
12141214 }
12151215}
12161216
1217test "math.lossyCast" {
1217test "lossyCast" {
12181218 try testing.expect(lossyCast(i16, 70000.0) == @as(i16, 32767));
12191219 try testing.expect(lossyCast(u32, @as(i16, -255)) == @as(u32, 0));
12201220 try testing.expect(lossyCast(i9, @as(u32, 200)) == @as(i9, 200));
12211221}
12221222
1223test "math.f64_min" {
1223test "f64_min" {
12241224 const f64_min_u64 = 0x0010000000000000;
12251225 const fmin: f64 = f64_min;
12261226 try testing.expect(@bitCast(u64, fmin) == f64_min_u64);
......@@ -1298,7 +1298,7 @@ pub fn mulWide(comptime T: type, a: T, b: T) std.meta.Int(
12981298 return @as(ResultInt, a) * @as(ResultInt, b);
12991299}
13001300
1301test "math.mulWide" {
1301test "mulWide" {
13021302 try testing.expect(mulWide(u8, 5, 5) == 25);
13031303 try testing.expect(mulWide(i8, 5, -5) == -25);
13041304 try testing.expect(mulWide(u8, 100, 100) == 10000);
......@@ -1439,7 +1439,7 @@ test "order.compare" {
14391439 try testing.expect(order(1, 0).compare(.neq));
14401440}
14411441
1442test "math.comptime" {
1442test "comptime sin and ln" {
14431443 const v = comptime (sin(@as(f32, 1)) + ln(@as(f32, 5)));
14441444 try testing.expect(v == sin(@as(f32, 1)) + ln(@as(f32, 5)));
14451445}