From e064e4ee7adeb442e28cddd650f1ff84be8f711d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Nordl=C3=B6w?= Date: Tue, 1 Oct 2024 07:31:07 +0200 Subject: [PATCH] Update src/gmp/q.d, src/gmp/z.d: Put version(gmp_test) first on lines --- src/gmp/q.d | 32 +++++++++++++-------------- src/gmp/z.d | 62 ++++++++++++++++++++++++++--------------------------- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/gmp/q.d b/src/gmp/q.d index b1e4344..a5c42fa 100644 --- a/src/gmp/q.d +++ b/src/gmp/q.d @@ -418,7 +418,7 @@ MpQ inverse()(auto ref const MpQ x) @trusted alias inv = inverse; /// construction and assignment -@safe @nogc version(gmp_test) unittest +version(gmp_test) @safe @nogc unittest { Q x = null; assert(x.numerator == 0); @@ -450,7 +450,7 @@ alias inv = inverse; } /// canonicalization -@safe @nogc version(gmp_test) unittest +version(gmp_test) @safe @nogc unittest { Q x = Q(2, 4); assert(x.numerator == 2); @@ -461,7 +461,7 @@ alias inv = inverse; } /// negative numerator canonicalization -@safe @nogc version(gmp_test) unittest +version(gmp_test) @safe @nogc unittest { Q x = Q(-2, 4); assert(x.numerator == -2); @@ -472,7 +472,7 @@ alias inv = inverse; } /// swap -@safe @nogc version(gmp_test) unittest +version(gmp_test) @safe @nogc unittest { Q x = Q(1, 2); Q y = Q(1, 3); @@ -482,7 +482,7 @@ alias inv = inverse; } /// invert -@safe version(gmp_test) unittest +version(gmp_test) @safe unittest { Q x = Q(1, 2); assert(x.numerator == 1); @@ -504,7 +504,7 @@ alias inv = inverse; } /// inversion -@safe version(gmp_test) unittest +version(gmp_test) @safe unittest { const Q q = Q(-2, 3); assert(inverse(q) == Q(-3, 2)); @@ -515,7 +515,7 @@ alias inv = inverse; } /// absolute value -@safe version(gmp_test) unittest +version(gmp_test) @safe unittest { const Q q = Q(-2, 3); assert(abs(q) == Q(2, 3)); @@ -523,7 +523,7 @@ alias inv = inverse; } /// integer and fractional part -@safe version(gmp_test) unittest +version(gmp_test) @safe unittest { Q x = Q(5, 2); @@ -548,7 +548,7 @@ alias inv = inverse; } /// casting -@safe @nogc version(gmp_test) unittest +version(gmp_test) @safe @nogc unittest { assert(cast(double)Q(1, 2) == 0.5f); assert(cast(double)Q(1, 2) == 0.5); @@ -557,7 +557,7 @@ alias inv = inverse; } /// equality -@safe version(gmp_test) unittest +version(gmp_test) @safe unittest { assert(Q(1, 1) == 1); assert(Q(2, 1) == 2); @@ -568,7 +568,7 @@ alias inv = inverse; } /// sign -@safe version(gmp_test) unittest +version(gmp_test) @safe unittest { assert(Q(-1, 3).sgn == -1); assert(Q( 0, 3).sgn == 0); @@ -576,7 +576,7 @@ alias inv = inverse; } /// comparison -@safe version(gmp_test) unittest +version(gmp_test) @safe unittest { assert(Q( 1, 3) < Q(1, 2)); assert(Q( 1, 2) > Q(1, 3)); @@ -599,7 +599,7 @@ alias inv = inverse; } /// addition -@safe version(gmp_test) unittest +version(gmp_test) @safe unittest { assert(Q(1, 2) + Q(1, 2) == Q(1, 1)); assert(Q(1, 3) + Q(1, 3) == Q(2, 3)); @@ -607,7 +607,7 @@ alias inv = inverse; } /// subtraction -@safe version(gmp_test) unittest +version(gmp_test) @safe unittest { assert(Q(1, 2) - Q(1, 2) == Q( 0, 1)); assert(Q(1, 2) - Q(1, 3) == Q (1, 6)); @@ -615,7 +615,7 @@ alias inv = inverse; } /// multiplication -@safe version(gmp_test) unittest +version(gmp_test) @safe unittest { assert(Q(1, 2) * Q(1, 2) == Q(1, 4)); assert(Q(2, 3) * Q(2, 3) == Q(4, 9)); @@ -623,7 +623,7 @@ alias inv = inverse; } /// division -@safe version(gmp_test) unittest +version(gmp_test) @safe unittest { assert(Q(2, 3) / Q(2, 3) == Q(1, 1)); assert(Q(2, 3) / Q(2, 3) == 1); diff --git a/src/gmp/z.d b/src/gmp/z.d index 06a3568..a32c95d 100644 --- a/src/gmp/z.d +++ b/src/gmp/z.d @@ -1549,7 +1549,7 @@ static assert(CopyableMpZ.sizeof == __mpz_struct.sizeof + size_t.sizeof); version(unittest) static assert(isMpZExpr!(MpZ)); version(benchmark) -@safe version(gmp_test) unittest +version(gmp_test) @safe unittest { import std.datetime.stopwatch : benchmark; bool odd; @@ -1644,7 +1644,7 @@ _Z!(cow) add(bool cow)(auto ref scope const _Z!(cow) x, auto ref scope const _Z! } /// -@safe nothrow @nogc version(gmp_test) unittest +version(gmp_test) @safe nothrow @nogc unittest { const Z x = Z(2)^^100; const Z y = 12; @@ -1696,7 +1696,7 @@ _Z!(cow) sub(bool cow)(auto ref scope const _Z!(cow) x, auto ref scope const _Z! } /// -@safe nothrow @nogc version(gmp_test) unittest +version(gmp_test) @safe nothrow @nogc unittest { Z x = 2.Z^^100; Z y = 12; @@ -1752,7 +1752,7 @@ _Z!(cow) mul(bool cow)(auto ref scope const _Z!(cow) x, auto ref scope const _Z! } /// -@safe nothrow @nogc version(gmp_test) unittest +version(gmp_test) @safe nothrow @nogc unittest { Z x = 2.Z^^100; Z y = 12; @@ -2115,7 +2115,7 @@ _Z!(cow) invert(bool cow)(auto ref scope const _Z!(cow) base, auto ref scope con } /// default construction -@safe nothrow @nogc version(gmp_test) unittest +version(gmp_test) @safe nothrow @nogc unittest { Z x = null; Z y = null; @@ -2138,7 +2138,7 @@ _Z!(cow) invert(bool cow)(auto ref scope const _Z!(cow) base, auto ref scope con } /// @nogc to ASCII generation -@trusted nothrow version(gmp_test) unittest +version(gmp_test) @trusted nothrow unittest { import core.memory : pureFree; const Z w = null; @@ -2148,7 +2148,7 @@ _Z!(cow) invert(bool cow)(auto ref scope const _Z!(cow) base, auto ref scope con } /// operate on default-constructed instances -@safe nothrow version(gmp_test) unittest +version(gmp_test) @safe nothrow unittest { Z w; @@ -2314,7 +2314,7 @@ _Z!(cow) invert(bool cow)(auto ref scope const _Z!(cow) base, auto ref scope con } /// null construction -@safe nothrow @nogc version(gmp_test) unittest +version(gmp_test) @safe nothrow @nogc unittest { const Z x = null; const Z y = null; @@ -2323,7 +2323,7 @@ _Z!(cow) invert(bool cow)(auto ref scope const _Z!(cow) base, auto ref scope con } /// -@safe @nogc version(gmp_test) unittest +version(gmp_test) @safe @nogc unittest { const x = 42.Z; assert(x.unaryMinus() == -42); // l-value `this` @@ -2331,7 +2331,7 @@ _Z!(cow) invert(bool cow)(auto ref scope const _Z!(cow) base, auto ref scope con } /// convert to string -@safe version(gmp_test) unittest +version(gmp_test) @safe unittest { assert(mpz( 42).toString == `42`); assert(mpz( -42).toString == `-42`); @@ -2353,7 +2353,7 @@ _Z!(cow) invert(bool cow)(auto ref scope const _Z!(cow) base, auto ref scope con } /// -@nogc version(gmp_test) unittest +version(gmp_test) @nogc unittest { ubyte[int.sizeof] storage; const ubyte[1] expected = [2]; @@ -2391,7 +2391,7 @@ version(gmp_test) unittest } /// opBinary with r-value right-hand-side -@safe @nogc version(gmp_test) unittest +version(gmp_test) @safe @nogc unittest { const Z a = 42; { @@ -2421,7 +2421,7 @@ version(gmp_test) unittest } /// -@safe version(gmp_test) unittest +version(gmp_test) @safe unittest { const _ = (cast(uint)42).Z; const a = 42.Z; @@ -3075,14 +3075,14 @@ version(gmp_test) unittest } /// generators -@safe @nogc version(gmp_test) unittest +version(gmp_test) @safe @nogc unittest { assert(Z.mersennePrime(15) == 2^^15 - 1); assert(Z.mersennePrime(15UL) == 2^^15 - 1); } /// left shift -@safe @nogc version(gmp_test) unittest +version(gmp_test) @safe @nogc unittest { assert(1.Z << 1.Z == 2^^1); assert(1.Z << 2.Z == 2^^2); @@ -3137,7 +3137,7 @@ version(gmp_test) unittest } /// right shift -@safe @nogc version(gmp_test) unittest +version(gmp_test) @safe @nogc unittest { assert(0x4.Z >> 1.Z == 0x2); assert(0x4.Z >> 2.Z == 0x1); @@ -3210,7 +3210,7 @@ version(gmp_test) unittest } /// verify compliance with Phobos' `BigInt` -@safe version(gmp_test) unittest +version(gmp_test) @safe unittest { alias bigInt = mpz; alias BigInt = Z; // Phobos naming convention @@ -3433,7 +3433,7 @@ version(gmp_test) unittest } /// Fermats Little Theorem -@safe @nogc version(gmp_test) unittest +version(gmp_test) @safe @nogc unittest { version (unittestLong) { @@ -3456,7 +3456,7 @@ version(gmp_test) unittest } // Euler's Sum of Powers Conjecture counter example -pure @nogc version(gmp_test) unittest +version(gmp_test) pure @nogc unittest { /* a^5 + b^5 + c^5 + d^5 = e^5 Lander & Parkin, 1966 found the first counter @@ -3523,7 +3523,7 @@ private struct AddExpr(bool cow) } version(unittest) static assert(isMpZExpr!(AddExpr!(true))); -@safe @nogc version(gmp_test) unittest +version(gmp_test) @safe @nogc unittest { assert(AddExpr!(false)(3.Z, 4.Z).eval() == 3 + 4); @@ -3556,7 +3556,7 @@ private struct SubExpr(bool cow) } version(unittest) static assert(isMpZExpr!(SubExpr!(false))); -@safe @nogc version(gmp_test) unittest +version(gmp_test) @safe @nogc unittest { assert(SubExpr!(false)(3.Z, 4.Z).eval() == 3 - 4); const Z x = SubExpr!(false)(3.Z, 4.Z); @@ -3583,7 +3583,7 @@ private struct MulExpr(bool cow) } version(unittest) static assert(isMpZExpr!(MulExpr!(false))); -@safe @nogc version(gmp_test) unittest +version(gmp_test) @safe @nogc unittest { assert(MulExpr!(false)(3.Z, 4.Z).eval() == 3 * 4); @@ -3611,7 +3611,7 @@ private struct DivExpr(bool cow) } version(unittest) static assert(isMpZExpr!(DivExpr!(false))); -@safe @nogc version(gmp_test) unittest +version(gmp_test) @safe @nogc unittest { assert(DivExpr!(false)(27.Z, 3.Z).eval() == 27 / 3); assert(DivExpr!(false)(28.Z, 3.Z).eval() == 28 / 3); @@ -3642,7 +3642,7 @@ private struct ModExpr(bool cow) } version(unittest) static assert(isMpZExpr!(ModExpr!(false))); -@safe @nogc version(gmp_test) unittest +version(gmp_test) @safe @nogc unittest { assert(ModExpr!(false)(27.Z, 3.Z).eval() == 27 % 3); assert(ModExpr!(false)(28.Z, 3.Z).eval() == 28 % 3); @@ -3675,7 +3675,7 @@ if (isMpZExpr!P && } version(unittest) static assert(isMpZExpr!(PowUExpr!(MpZ, ulong))); -@safe @nogc version(gmp_test) unittest +version(gmp_test) @safe @nogc unittest { assert(PowUExpr!(Z, ulong)(3.Z, 3).eval() == 3^^3); } @@ -3704,7 +3704,7 @@ if (isMpZExpr!P && } version(unittest) static assert(isMpZExpr!(PowMUExpr!(MpZ, ulong, MpZ))); -@safe @nogc version(gmp_test) unittest +version(gmp_test) @safe @nogc unittest { assert(PowMUExpr!(Z, ulong, Z)(3.Z, 3, 20.Z).eval() == 3^^3 % 20); } @@ -3728,7 +3728,7 @@ private struct NegExpr(bool cow) } version(unittest) static assert(isMpZExpr!(NegExpr!(false))); -@safe @nogc version(gmp_test) unittest +version(gmp_test) @safe @nogc unittest { assert(NegExpr!(false)(27.Z).eval() == -27); const Z x = NegExpr!(false)(27.Z); @@ -3757,7 +3757,7 @@ private struct SqrtExpr(bool cow) } version(unittest) static assert(isMpZExpr!(SqrtExpr!(false))); -@safe @nogc version(gmp_test) unittest +version(gmp_test) @safe @nogc unittest { foreach (const n; 16 .. 25) assert(SqrtExpr!(false)(n.Z).eval() == 4); @@ -3773,7 +3773,7 @@ if (isIntegral!T) } /// as hash table key -@safe version(gmp_test) unittest +version(gmp_test) @safe unittest { // TODO: disabled until non-copyable types work in AA's // string[Z] aa; @@ -3784,7 +3784,7 @@ if (isIntegral!T) } /// copyable integer -@trusted version(gmp_test) unittest +version(gmp_test) @trusted unittest { alias CZ = CopyableMpZ; @@ -3799,7 +3799,7 @@ if (isIntegral!T) } /// to string conversion -pure @safe nothrow version(gmp_test) unittest +version(gmp_test) pure @safe nothrow unittest { for (int i = -100; i < 100; ++i) {