98 changes: 51 additions & 47 deletions std/bigint.d
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ public:
sign = neg;
}

unittest
@system unittest
{
// system because of the dummy ranges eventually call std.array!string
import std.internal.test.dummyrange;
import std.exception : assertThrown;

Expand Down Expand Up @@ -149,8 +150,9 @@ public:
}

///
unittest
@system unittest
{
// @system due to failure in FreeBSD32
ulong data = 1_000_000_000_000;
auto bigData = BigInt(data);
assert(data == BigInt("1_000_000_000_000"));
Expand All @@ -163,7 +165,7 @@ public:
}

///
unittest
@system unittest
{
const(BigInt) b1 = BigInt("1_234_567_890");
BigInt b2 = BigInt(b1);
Expand All @@ -179,7 +181,7 @@ public:
}

///
unittest
@system unittest
{
auto b = BigInt("123");
b = 456;
Expand All @@ -195,7 +197,7 @@ public:
}

///
unittest
@system unittest
{
auto b1 = BigInt("123");
auto b2 = BigInt("456");
Expand Down Expand Up @@ -295,8 +297,9 @@ public:
}

///
unittest
@system unittest
{
//@system because opOpAssign is @system
auto b = BigInt("1_000_000_000");

b += 12345;
Expand Down Expand Up @@ -356,8 +359,9 @@ public:
}

///
unittest
@system unittest
{
// @system because opOpAssign is @system
auto x = BigInt("123");
auto y = BigInt("321");
x += y;
Expand All @@ -377,7 +381,7 @@ public:
}

///
unittest
@system unittest
{
auto x = BigInt("123");
auto y = BigInt("456");
Expand All @@ -398,7 +402,7 @@ public:
}

///
unittest
@system unittest
{
auto x = BigInt("123");
x *= 300;
Expand Down Expand Up @@ -450,7 +454,7 @@ public:
}

///
unittest
@system unittest
{
auto x = BigInt("1_000_000_500");
long l = 1_000_000L;
Expand All @@ -475,7 +479,7 @@ public:
}

///
unittest
@system unittest
{
auto x = BigInt("100");
BigInt y = 123 + x;
Expand Down Expand Up @@ -569,7 +573,7 @@ public:
}

///
unittest
@system unittest
{
auto x = BigInt("1234");
assert(-x == BigInt("-1234"));
Expand All @@ -596,7 +600,7 @@ public:
}

///
unittest
@system unittest
{
auto x = BigInt("12345");
auto y = BigInt("12340");
Expand All @@ -619,7 +623,7 @@ public:
}

///
unittest
@system unittest
{
// Non-zero values are regarded as true
auto x = BigInt("1");
Expand Down Expand Up @@ -666,7 +670,7 @@ public:
}

///
unittest
@system unittest
{
import std.conv : to, ConvOverflowException;
import std.exception : assertThrown;
Expand All @@ -679,7 +683,7 @@ public:
assertThrown!ConvOverflowException(BigInt("-1").to!ubyte);
}

unittest
@system unittest
{
import std.conv : to, ConvOverflowException;
import std.exception : assertThrown;
Expand Down Expand Up @@ -726,7 +730,7 @@ public:
}

///
unittest
@system unittest
{
const(BigInt) x = BigInt("123");
BigInt y = cast() x; // cast away const
Expand Down Expand Up @@ -764,7 +768,7 @@ public:
}

///
unittest
@system unittest
{
auto x = BigInt("100");
auto y = BigInt("10");
Expand All @@ -790,7 +794,7 @@ public:
}

///
unittest
@system unittest
{
auto b = BigInt("12345");
long l = b.toLong();
Expand All @@ -810,7 +814,7 @@ public:
}

///
unittest
@system unittest
{
auto big = BigInt("5_000_000");
auto i = big.toInt();
Expand Down Expand Up @@ -927,7 +931,7 @@ public:
$(D toString) is rarely directly invoked; the usual way of using it is via
$(REF format, std, format):
*/
unittest
@system unittest
{
import std.format : format;

Expand All @@ -954,7 +958,7 @@ public:
$(D toHash) is rarely directly invoked; it is implicitly used when
BigInt is used as the key of an associative array.
*/
unittest
@safe unittest
{
string[BigInt] aa;
aa[BigInt(123)] = "abc";
Expand Down Expand Up @@ -988,7 +992,7 @@ private:
}

///
unittest
@system unittest
{
BigInt a = "9588669891916142";
BigInt b = "7452469135154800";
Expand Down Expand Up @@ -1034,7 +1038,7 @@ string toDecimalString(const(BigInt) x)
}

///
unittest
@system unittest
{
auto x = BigInt("123");
x *= 1000;
Expand Down Expand Up @@ -1062,7 +1066,7 @@ string toHex(const(BigInt) x)
}

///
unittest
@system unittest
{
auto x = BigInt("123");
x *= 1000;
Expand Down Expand Up @@ -1099,7 +1103,7 @@ Unsigned!T absUnsign(T)(T x) if (isIntegral!T)
}
}

nothrow pure
nothrow pure @system
unittest
{
BigInt a, b;
Expand All @@ -1108,7 +1112,7 @@ unittest
auto c = a + b;
}

nothrow pure
nothrow pure @system
unittest
{
long a;
Expand All @@ -1117,7 +1121,7 @@ unittest
auto d = b + a;
}

nothrow pure
nothrow pure @system
unittest
{
BigInt x = 1, y = 2;
Expand All @@ -1142,7 +1146,7 @@ unittest
assert(incr == BigInt(1));
}

unittest
@system unittest
{
// Radix conversion
assert( toDecimalString(BigInt("-1_234_567_890_123_456_789"))
Expand Down Expand Up @@ -1180,7 +1184,7 @@ unittest
== "1234567");
}

unittest // Minimum signed value bug tests.
@system unittest // Minimum signed value bug tests.
{
assert(BigInt("-0x8000000000000000") == BigInt(long.min));
assert(BigInt("-0x8000000000000000")+1 > BigInt(long.min));
Expand All @@ -1201,7 +1205,7 @@ unittest // Minimum signed value bug tests.
assert((BigInt(int.min)-1)%int.min == -1);
}

unittest // Recursive division, bug 5568
@system unittest // Recursive division, bug 5568
{
enum Z = 4843;
BigInt m = (BigInt(1) << (Z*8) ) - 1;
Expand Down Expand Up @@ -1247,7 +1251,7 @@ unittest // Recursive division, bug 5568
a8165[0] = a8165[1] = 1;
}

unittest
@system unittest
{
import std.array;
import std.format;
Expand Down Expand Up @@ -1298,7 +1302,7 @@ unittest
}
}

unittest
@system unittest
{
import std.array;
import std.format;
Expand Down Expand Up @@ -1349,7 +1353,7 @@ unittest
}
}

unittest
@system unittest
{
import std.array;
import std.format;
Expand Down Expand Up @@ -1401,7 +1405,7 @@ unittest
}

// 6448
unittest
@system unittest
{
import std.array;
import std.format;
Expand All @@ -1427,7 +1431,7 @@ unittest
assert(y.toLong() == -2);
}

unittest
@safe unittest
{
import std.math : abs;
auto r = abs(BigInt(-1000)); // 6486
Expand All @@ -1443,7 +1447,7 @@ unittest
assert(one && !zero);
}

unittest // 6850
@system unittest // 6850
{
pure long pureTest() {
BigInt a = 1;
Expand All @@ -1455,7 +1459,7 @@ unittest // 6850
assert(pureTest() == 1337);
}

unittest // 8435 & 10118
@system unittest // 8435 & 10118
{
auto i = BigInt(100);
auto j = BigInt(100);
Expand All @@ -1479,7 +1483,7 @@ unittest // 8435 & 10118
assert(keys.empty);
}

unittest // 11148
@system unittest // 11148
{
void foo(BigInt) {}
const BigInt cbi = 3;
Expand Down Expand Up @@ -1516,13 +1520,13 @@ unittest // 11148
n *= 2;
}

unittest // 8167
@safe unittest // 8167
{
BigInt a = BigInt(3);
BigInt b = BigInt(a);
}

unittest // 9061
@safe unittest // 9061
{
long l1 = 0x12345678_90ABCDEF;
long l2 = 0xFEDCBA09_87654321;
Expand All @@ -1541,7 +1545,7 @@ unittest // 9061
assert(l5 == b5);
}

unittest // 11600
@system unittest // 11600
{
import std.conv;
import std.exception : assertThrown;
Expand All @@ -1556,13 +1560,13 @@ unittest // 11600
assertThrown!ConvException(to!BigInt("-123four"));
}

unittest // 11583
@safe unittest // 11583
{
BigInt x = 0;
assert((x > 0) == false);
}

unittest // 13391
@system unittest // 13391
{
BigInt x1 = "123456789";
BigInt x2 = "123456789123456789";
Expand Down Expand Up @@ -1593,7 +1597,7 @@ unittest // 13391
assert(x2 == 1);
}

unittest // 13963
@system unittest // 13963
{
BigInt x = 1;
import std.meta : AliasSeq;
Expand Down Expand Up @@ -1635,7 +1639,7 @@ unittest // 13963
assert(-x2 % ulong.max == -x2);
}

unittest // 14124
@system unittest // 14124
{
auto x = BigInt(-3);
x %= 3;
Expand All @@ -1659,7 +1663,7 @@ unittest // 14124
}

// issue 15678
unittest
@system unittest
{
import std.exception : assertThrown;
assertThrown!ConvException(BigInt(""));
Expand Down