mirror of
https://github.com/dlang/phobos.git
synced 2025-05-02 08:00:48 +03:00
Remove unused debug writelns in std.algorithm
This commit is contained in:
parent
3e53849c78
commit
2e90b8ba16
6 changed files with 7 additions and 177 deletions
|
@ -665,9 +665,6 @@ private struct MapResult(alias fun, Range)
|
|||
import std.conv : to;
|
||||
import std.functional : adjoin;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
alias stringize = map!(to!string);
|
||||
assert(equal(stringize([ 1, 2, 3, 4 ]), [ "1", "2", "3", "4" ]));
|
||||
|
||||
|
@ -689,8 +686,6 @@ private struct MapResult(alias fun, Range)
|
|||
import std.range;
|
||||
import std.typecons : tuple;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
int[] arr1 = [ 1, 2, 3, 4 ];
|
||||
const int[] arr1Const = arr1;
|
||||
int[] arr2 = [ 5, 6 ];
|
||||
|
@ -1179,8 +1174,6 @@ private struct FilterResult(alias pred, Range)
|
|||
import std.internal.test.dummyrange;
|
||||
import std.range;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
int[] a = [ 3, 4, 2 ];
|
||||
auto r = filter!("a > 3")(a);
|
||||
static assert(isForwardRange!(typeof(r)));
|
||||
|
@ -1518,8 +1511,6 @@ if (isInputRange!R)
|
|||
import std.internal.test.dummyrange;
|
||||
import std.typecons : tuple, Tuple;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
int[] arr = [ 1, 2, 2, 2, 2, 3, 4, 4, 4, 5 ];
|
||||
assert(equal(group(arr), [ tuple(1, 1u), tuple(2, 4u), tuple(3, 1u),
|
||||
tuple(4, 3u), tuple(5, 1u) ][]));
|
||||
|
@ -3015,8 +3006,6 @@ The number of seeds must be correspondingly increased.
|
|||
|
||||
@safe unittest
|
||||
{
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
const float a = 0.0;
|
||||
const float[] b = [ 1.2, 3, 3.3 ];
|
||||
float[] c = [ 1.2, 3, 3.3 ];
|
||||
|
@ -3837,18 +3826,12 @@ if (is(typeof(binaryFun!pred(r.front, s)) : bool)
|
|||
import std.array : array;
|
||||
import std.range : retro;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
assert(equal(splitter("hello world", ' '), [ "hello", "", "world" ]));
|
||||
assert(equal(splitter("žlutoučkýřkůň", 'ř'), [ "žlutoučký", "kůň" ]));
|
||||
int[] a = [ 1, 2, 0, 0, 3, 0, 4, 5, 0 ];
|
||||
int[][] w = [ [1, 2], [], [3], [4, 5], [] ];
|
||||
static assert(isForwardRange!(typeof(splitter(a, 0))));
|
||||
|
||||
// foreach (x; splitter(a, 0))
|
||||
// {
|
||||
// writeln("[", x, "]");
|
||||
// }
|
||||
assert(equal(splitter(a, 0), w));
|
||||
a = null;
|
||||
assert(equal(splitter(a, 0), (int[][]).init));
|
||||
|
@ -4088,16 +4071,12 @@ if (is(typeof(binaryFun!pred(r.front, s.front)) : bool)
|
|||
import std.conv : text;
|
||||
import std.array : split;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
auto s = ",abc, de, fg,hi,";
|
||||
auto sp0 = splitter(s, ',');
|
||||
// //foreach (e; sp0) writeln("[", e, "]");
|
||||
assert(equal(sp0, ["", "abc", " de", " fg", "hi", ""][]));
|
||||
|
||||
auto s1 = ", abc, de, fg, hi, ";
|
||||
auto sp1 = splitter(s1, ", ");
|
||||
//foreach (e; sp1) writeln("[", e, "]");
|
||||
assert(equal(sp1, ["", "abc", "de", " fg", "hi", ""][]));
|
||||
static assert(isForwardRange!(typeof(sp1)));
|
||||
|
||||
|
@ -4141,14 +4120,9 @@ if (is(typeof(binaryFun!pred(r.front, s.front)) : bool)
|
|||
@safe unittest
|
||||
{
|
||||
import std.algorithm.comparison : equal;
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
auto s6 = ",";
|
||||
auto sp6 = splitter(s6, ',');
|
||||
foreach (e; sp6)
|
||||
{
|
||||
//writeln("{", e, "}");
|
||||
}
|
||||
foreach (e; sp6) {}
|
||||
assert(equal(sp6, ["", ""][]));
|
||||
}
|
||||
|
||||
|
@ -4363,8 +4337,6 @@ private struct SplitterResult(alias isTerminator, Range)
|
|||
import std.algorithm.comparison : equal;
|
||||
import std.internal.test.dummyrange;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
void compare(string sentence, string[] witness)
|
||||
{
|
||||
auto r = splitter!"a == ' '"(sentence);
|
||||
|
@ -5124,8 +5096,6 @@ private struct UniqResult(alias pred, Range)
|
|||
import std.internal.test.dummyrange;
|
||||
import std.range;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
int[] arr = [ 1, 2, 2, 2, 2, 3, 4, 4, 4, 5 ];
|
||||
auto r = uniq(arr);
|
||||
static assert(isForwardRange!(typeof(r)));
|
||||
|
|
|
@ -273,9 +273,6 @@ Unicode integrity is not preserved:
|
|||
import std.conv : text;
|
||||
import std.random : Random, unpredictableSeed, uniform;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
// a more elaborate test
|
||||
{
|
||||
auto rnd = Random(unpredictableSeed);
|
||||
|
@ -485,8 +482,6 @@ $(HTTP sgi.com/tech/stl/copy_backward.html, STL's copy_backward'):
|
|||
{
|
||||
import std.algorithm.iteration : filter;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
{
|
||||
int[] a = [ 1, 5 ];
|
||||
int[] b = [ 9, 8 ];
|
||||
|
@ -575,9 +570,6 @@ if (isInputRange!Range && is(typeof(range.front = value)))
|
|||
import std.conv : text;
|
||||
import std.internal.test.dummyrange;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
int[] a = [ 1, 2, 3 ];
|
||||
fill(a, 6);
|
||||
assert(a == [ 6, 6, 6 ], text(a));
|
||||
|
@ -590,8 +582,6 @@ if (isInputRange!Range && is(typeof(range.front = value)))
|
|||
}
|
||||
}
|
||||
void fun1() { foreach (i; 0 .. 1000) fill(a, 6); }
|
||||
//void fun2() { foreach (i; 0 .. 1000) fill2(a, 6); }
|
||||
//writeln(benchmark!(fun0, fun1, fun2)(10000));
|
||||
|
||||
// fill should accept InputRange
|
||||
alias InputRange = DummyRange!(ReturnBy.Reference, Length.No, RangeType.Input);
|
||||
|
@ -734,9 +724,6 @@ if (isInputRange!InputRange
|
|||
import std.exception : assertThrown;
|
||||
import std.internal.test.dummyrange;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
int[] a = [ 1, 2, 3, 4, 5 ];
|
||||
int[] b = [1, 2];
|
||||
fill(a, b);
|
||||
|
@ -854,9 +841,6 @@ if (is(Range == char[]) || is(Range == wchar[]))
|
|||
import std.meta : AliasSeq;
|
||||
import std.traits : hasElaborateAssign;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
//Test strings:
|
||||
//Must work on narrow strings.
|
||||
//Must reject const
|
||||
|
@ -1032,9 +1016,8 @@ pure nothrow @safe @nogc unittest
|
|||
@safe unittest
|
||||
{
|
||||
import std.traits;
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
import std.exception : assertCTFEable;
|
||||
|
||||
assertCTFEable!((){
|
||||
Object obj1 = new Object;
|
||||
Object obj2 = obj1;
|
||||
|
@ -1147,9 +1130,8 @@ private T moveImpl(T)(ref T source)
|
|||
@safe unittest
|
||||
{
|
||||
import std.traits;
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
import std.exception : assertCTFEable;
|
||||
|
||||
assertCTFEable!((){
|
||||
Object obj1 = new Object;
|
||||
Object obj2 = obj1;
|
||||
|
@ -1851,10 +1833,7 @@ if (s == SwapStrategy.stable
|
|||
@safe unittest
|
||||
{
|
||||
import std.range;
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
int[] a = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
|
||||
//writeln(remove!(SwapStrategy.stable)(a, 1));
|
||||
a = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
|
||||
assert(remove!(SwapStrategy.stable)(a, 1) ==
|
||||
[ 0, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]);
|
||||
|
@ -1871,20 +1850,14 @@ if (s == SwapStrategy.stable
|
|||
assert(remove!(SwapStrategy.unstable)(a, 2) ==
|
||||
[ 1, 2, 4 ]);
|
||||
|
||||
a = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
|
||||
//writeln(remove!(SwapStrategy.stable)(a, 1, 5));
|
||||
a = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
|
||||
assert(remove!(SwapStrategy.stable)(a, 1, 5) ==
|
||||
[ 0, 2, 3, 4, 6, 7, 8, 9, 10 ]);
|
||||
|
||||
a = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
|
||||
//writeln(remove!(SwapStrategy.stable)(a, 1, 3, 5));
|
||||
a = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
|
||||
assert(remove!(SwapStrategy.stable)(a, 1, 3, 5)
|
||||
== [ 0, 2, 4, 6, 7, 8, 9, 10]);
|
||||
a = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
|
||||
//writeln(remove!(SwapStrategy.stable)(a, 1, tuple(3, 5)));
|
||||
a = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
|
||||
assert(remove!(SwapStrategy.stable)(a, 1, tuple(3, 5))
|
||||
== [ 0, 2, 5, 6, 7, 8, 9, 10]);
|
||||
|
||||
|
@ -1992,13 +1965,10 @@ if (isBidirectionalRange!Range
|
|||
|
||||
@safe unittest
|
||||
{
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
int[] a = [ 1, 2, 3, 2, 3, 4, 5, 2, 5, 6 ];
|
||||
assert(remove!("a == 2", SwapStrategy.unstable)(a) ==
|
||||
[ 1, 6, 3, 5, 3, 4, 5 ]);
|
||||
a = [ 1, 2, 3, 2, 3, 4, 5, 2, 5, 6 ];
|
||||
//writeln(remove!("a != 2", SwapStrategy.stable)(a));
|
||||
assert(remove!("a == 2", SwapStrategy.stable)(a) ==
|
||||
[ 1, 3, 3, 4, 5, 5, 6 ]);
|
||||
}
|
||||
|
@ -2125,8 +2095,6 @@ if (isRandomAccessRange!Range && hasLength!Range)
|
|||
|
||||
@safe unittest
|
||||
{
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
int[] range = null;
|
||||
reverse(range);
|
||||
range = [ 1 ];
|
||||
|
|
|
@ -183,7 +183,6 @@ Authors: $(HTTP erdani.com, Andrei Alexandrescu)
|
|||
Source: $(PHOBOSSRC std/_algorithm/package.d)
|
||||
*/
|
||||
module std.algorithm;
|
||||
//debug = std_algorithm;
|
||||
|
||||
public import std.algorithm.comparison;
|
||||
public import std.algorithm.iteration;
|
||||
|
|
|
@ -204,8 +204,6 @@ evaluate to true.
|
|||
|
||||
@safe unittest
|
||||
{
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
auto a = [ 1, 2, 0, 4 ];
|
||||
assert(any!"a == 2"(a));
|
||||
}
|
||||
|
@ -646,9 +644,6 @@ if (isInputRange!Range && !isInfinite!Range &&
|
|||
{
|
||||
import std.conv : text;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
int[] a = [ 1, 2, 4, 3, 2, 5, 3, 2, 4 ];
|
||||
assert(count(a, 2) == 3, text(count(a, 2)));
|
||||
assert(count!("a > b")(a, 2) == 5, text(count!("a > b")(a, 2)));
|
||||
|
@ -665,7 +660,6 @@ if (isInputRange!Range && !isInfinite!Range &&
|
|||
|
||||
@safe unittest
|
||||
{
|
||||
debug(std_algorithm) printf("algorithm.count.unittest\n");
|
||||
string s = "This is a fofofof list";
|
||||
string sub = "fof";
|
||||
assert(count(s, sub) == 2);
|
||||
|
@ -709,8 +703,6 @@ if (isInputRange!R && !isInfinite!R &&
|
|||
|
||||
@safe unittest
|
||||
{
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
int[] a = [ 1, 2, 4, 3, 2, 5, 3, 2, 4 ];
|
||||
assert(count!("a == 3")(a) == 2);
|
||||
assert(count("日本語") == 3);
|
||||
|
@ -1158,9 +1150,6 @@ if (isInputRange!R &&
|
|||
import std.meta : AliasSeq;
|
||||
import std.conv : to;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
foreach (S; AliasSeq!(char[], wchar[], dchar[], string, wstring, dstring))
|
||||
{
|
||||
assert(!endsWith(to!S("abc"), 'a'));
|
||||
|
@ -1561,8 +1550,6 @@ if (isInputRange!InputRange &&
|
|||
import std.algorithm.comparison : equal;
|
||||
import std.container : SList;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
auto lst = SList!int(1, 2, 5, 7, 3);
|
||||
assert(lst.front == 1);
|
||||
auto r = find(lst[], 5);
|
||||
|
@ -1734,7 +1721,6 @@ if (isInputRange!InputRange)
|
|||
|
||||
@safe pure unittest
|
||||
{
|
||||
//scope(success) writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
int[] r = [ 1, 2, 3 ];
|
||||
assert(find!(a=>a > 2)(r) == [3]);
|
||||
bool pred(int x) { return x + 1 > 1.5; }
|
||||
|
@ -1821,8 +1807,6 @@ if (isForwardRange!R1 && isForwardRange!R2
|
|||
import std.algorithm.comparison : equal;
|
||||
import std.container : SList;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
auto lst = SList!int(1, 2, 5, 7, 3);
|
||||
static assert(isForwardRange!(int[]));
|
||||
static assert(isForwardRange!(typeof(lst[])));
|
||||
|
@ -1973,7 +1957,6 @@ if (isRandomAccessRange!R1 && hasLength!R1 && hasSlicing!R1 && isBidirectionalRa
|
|||
|
||||
@safe unittest
|
||||
{
|
||||
//scope(success) writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
// @@@BUG@@@ removing static below makes unittest fail
|
||||
static struct BiRange
|
||||
{
|
||||
|
@ -1985,13 +1968,7 @@ if (isRandomAccessRange!R1 && hasLength!R1 && hasSlicing!R1 && isBidirectionalRa
|
|||
void popFront() { return payload.popFront(); }
|
||||
void popBack() { return payload.popBack(); }
|
||||
}
|
||||
//static assert(isBidirectionalRange!BiRange);
|
||||
auto r = BiRange([1, 2, 3, 10, 11, 4]);
|
||||
//assert(equal(find(r, [3, 10]), BiRange([3, 10, 11, 4])));
|
||||
//assert(find("abc", "bc").length == 2);
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
//assert(find!"a == b"("abc", "bc").length == 2);
|
||||
}
|
||||
|
||||
/// ditto
|
||||
|
@ -2154,9 +2131,6 @@ private R1 simpleMindedFind(alias pred, R1, R2)(R1 haystack, scope R2 needle)
|
|||
{
|
||||
// Test simpleMindedFind for the case where both haystack and needle have
|
||||
// length.
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
struct CustomString
|
||||
{
|
||||
@safe:
|
||||
|
@ -2255,10 +2229,7 @@ if (Ranges.length > 1 && is(typeof(startsWith!pred(haystack, needles))))
|
|||
|
||||
@safe unittest
|
||||
{
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
auto s1 = "Mary has a little lamb";
|
||||
//writeln(find(s1, "has a", "has an"));
|
||||
assert(find(s1, "has a", "has an") == tuple("has a little lamb", 1));
|
||||
assert(find(s1, 't', "has a", "has an") == tuple("has a little lamb", 2));
|
||||
assert(find(s1, 't', "has a", 'y', "has an") == tuple("y has a little lamb", 3));
|
||||
|
@ -2271,9 +2242,6 @@ if (Ranges.length > 1 && is(typeof(startsWith!pred(haystack, needles))))
|
|||
import std.meta : AliasSeq;
|
||||
import std.uni : toUpper;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
int[] a = [ 1, 2, 3 ];
|
||||
assert(find(a, 5).empty);
|
||||
assert(find(a, 2) == [2, 3]);
|
||||
|
@ -2289,7 +2257,6 @@ if (Ranges.length > 1 && is(typeof(startsWith!pred(haystack, needles))))
|
|||
|
||||
// Case-insensitive find of a string
|
||||
string[] s = [ "Hello", "world", "!" ];
|
||||
//writeln(find!("toUpper(a) == toUpper(b)")(s, "hello"));
|
||||
assert(find!("toUpper(a) == toUpper(b)")(s, "hello").length == 3);
|
||||
|
||||
static bool f(string a, string b) { return toUpper(a) == toUpper(b); }
|
||||
|
@ -2303,9 +2270,6 @@ if (Ranges.length > 1 && is(typeof(startsWith!pred(haystack, needles))))
|
|||
import std.meta : AliasSeq;
|
||||
import std.range : retro;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
int[] a = [ 1, 2, 3, 2, 6 ];
|
||||
assert(find(retro(a), 5).empty);
|
||||
assert(equal(find(retro(a), 2), [ 2, 3, 2, 1 ][]));
|
||||
|
@ -2326,8 +2290,6 @@ if (Ranges.length > 1 && is(typeof(startsWith!pred(haystack, needles))))
|
|||
import std.algorithm.comparison : equal;
|
||||
import std.internal.test.dummyrange;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
int[] a = [ -1, 0, 1, 2, 3, 4, 5 ];
|
||||
int[] b = [ 1, 2, 3 ];
|
||||
assert(find(a, b) == [ 1, 2, 3, 4, 5 ]);
|
||||
|
@ -2361,8 +2323,6 @@ RandomAccessRange find(RandomAccessRange, alias pred, InputRange)(
|
|||
|
||||
@safe unittest
|
||||
{
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
string h = "/homes/aalexand/d/dmd/bin/../lib/libphobos.a(dmain2.o)"~
|
||||
"(.gnu.linkonce.tmain+0x74): In function `main' undefined reference"~
|
||||
" to `_Dmain':";
|
||||
|
@ -2477,8 +2437,7 @@ template canFind(alias pred="a == b")
|
|||
@safe unittest
|
||||
{
|
||||
import std.algorithm.internal : rndstuff;
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
auto a = rndstuff!(int)();
|
||||
if (a.length)
|
||||
{
|
||||
|
@ -2544,7 +2503,6 @@ if (isForwardRange!(Range))
|
|||
import std.internal.test.dummyrange;
|
||||
import std.range;
|
||||
|
||||
//scope(success) writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
int[] a = [ 11, 10, 10, 9, 8, 8, 7, 8, 9 ];
|
||||
auto p = findAdjacent(a);
|
||||
assert(p == [10, 10, 9, 8, 8, 7, 8, 9 ]);
|
||||
|
@ -2609,7 +2567,6 @@ if (isInputRange!InputRange && isForwardRange!ForwardRange)
|
|||
|
||||
@safe unittest
|
||||
{
|
||||
//scope(success) writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
int[] a = [ -1, 0, 2, 1, 2, 3, 4, 5 ];
|
||||
int[] b = [ 1, 2, 3 ];
|
||||
assert(findAmong(a, b) == [2, 1, 2, 3, 4, 5 ]);
|
||||
|
@ -3172,9 +3129,6 @@ if (isInputRange!Range && !isInfinite!Range &&
|
|||
import std.conv : text;
|
||||
import std.typecons : tuple;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
int[] a = [ 2, 3, 4, 1, 2, 4, 1, 1, 2 ];
|
||||
// Minimum is 1 and occurs 3 times
|
||||
assert(a.minCount == tuple(1, 3));
|
||||
|
@ -3188,9 +3142,6 @@ if (isInputRange!Range && !isInfinite!Range &&
|
|||
import std.exception : assertThrown;
|
||||
import std.internal.test.dummyrange;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
int[][] b = [ [4], [2, 4], [4], [4] ];
|
||||
auto c = minCount!("a[0] < b[0]")(b);
|
||||
assert(c == tuple([2, 4], 1), text(c[0]));
|
||||
|
@ -3208,9 +3159,6 @@ if (isInputRange!Range && !isInfinite!Range &&
|
|||
import std.conv : text;
|
||||
import std.meta : AliasSeq;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
static struct R(T) //input range
|
||||
{
|
||||
T[] arr;
|
||||
|
@ -3539,8 +3487,6 @@ if (isForwardRange!Range && !isInfinite!Range &&
|
|||
import std.algorithm.comparison : equal;
|
||||
import std.internal.test.dummyrange;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
int[] a = [ 2, 3, 4, 1, 2, 4, 1, 1, 2 ];
|
||||
//Test that an empty range works
|
||||
int[] b = a[$..$];
|
||||
|
@ -3556,9 +3502,6 @@ if (isForwardRange!Range && !isInfinite!Range &&
|
|||
import std.algorithm.comparison : equal;
|
||||
import std.container : Array;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
assert(Array!int(2, 3, 4, 1, 2, 4, 1, 1, 2)
|
||||
[]
|
||||
.minPos()
|
||||
|
@ -3568,8 +3511,6 @@ if (isForwardRange!Range && !isInfinite!Range &&
|
|||
@safe unittest
|
||||
{
|
||||
//BUG 9299
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
immutable a = [ 2, 3, 4, 1, 2, 4, 1, 1, 2 ];
|
||||
// Minimum is 1 and first occurs in position 3
|
||||
assert(minPos(a) == [ 1, 2, 4, 1, 1, 2 ]);
|
||||
|
@ -4155,9 +4096,6 @@ if (isInputRange!R &&
|
|||
import std.meta : AliasSeq;
|
||||
import std.range;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
foreach (S; AliasSeq!(char[], wchar[], dchar[], string, wstring, dstring))
|
||||
{
|
||||
assert(!startsWith(to!S("abc"), 'c'));
|
||||
|
@ -4266,7 +4204,6 @@ private void skipAll(alias pred = "a == b", R, Es...)(ref R r, Es es)
|
|||
|
||||
@safe unittest
|
||||
{
|
||||
//scope(success) writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
auto s1 = "Hello world";
|
||||
skipAll(s1, 'H', 'e');
|
||||
assert(s1 == "llo world");
|
||||
|
@ -4328,12 +4265,6 @@ if (isInputRange!Range)
|
|||
private Range _input;
|
||||
static if (!is(Sentinel == void))
|
||||
private Sentinel _sentinel;
|
||||
// mixin(bitfields!(
|
||||
// OpenRight, "_openRight", 1,
|
||||
// bool, "_done", 1,
|
||||
// uint, "", 6));
|
||||
// OpenRight, "_openRight", 1,
|
||||
// bool, "_done", 1,
|
||||
private OpenRight _openRight;
|
||||
private bool _done;
|
||||
|
||||
|
@ -4433,7 +4364,6 @@ if (isInputRange!Range)
|
|||
@safe unittest
|
||||
{
|
||||
import std.algorithm.comparison : equal;
|
||||
//scope(success) writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
int[] a = [ 1, 2, 4, 7, 7, 2, 4, 7, 3, 5];
|
||||
|
||||
static assert(isForwardRange!(typeof(a.until(7))));
|
||||
|
|
|
@ -677,9 +677,6 @@ void largestPartialIntersectionWeighted
|
|||
import std.conv : text;
|
||||
import std.typecons : tuple, Tuple, Yes;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
double[][] a =
|
||||
[
|
||||
[ 1, 4, 7, 8 ],
|
||||
|
@ -690,8 +687,6 @@ void largestPartialIntersectionWeighted
|
|||
];
|
||||
auto b = new Tuple!(double, uint)[2];
|
||||
largestPartialIntersection(a, b, Yes.sortOutput);
|
||||
//sort(b);
|
||||
//writeln(b);
|
||||
assert(b == [ tuple(7.0, 4u), tuple(1.0, 3u) ][], text(b));
|
||||
assert(a[0].empty);
|
||||
}
|
||||
|
@ -701,9 +696,6 @@ void largestPartialIntersectionWeighted
|
|||
import std.conv : text;
|
||||
import std.typecons : tuple, Tuple, Yes;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
string[][] a =
|
||||
[
|
||||
[ "1", "4", "7", "8" ],
|
||||
|
@ -714,7 +706,6 @@ void largestPartialIntersectionWeighted
|
|||
];
|
||||
auto b = new Tuple!(string, uint)[2];
|
||||
largestPartialIntersection(a, b, Yes.sortOutput);
|
||||
//writeln(b);
|
||||
assert(b == [ tuple("7", 4u), tuple("1", 3u) ][], text(b));
|
||||
}
|
||||
|
||||
|
@ -722,9 +713,8 @@ void largestPartialIntersectionWeighted
|
|||
{
|
||||
import std.typecons : tuple, Tuple;
|
||||
|
||||
//scope(success) writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
// Figure which number can be found in most arrays of the set of
|
||||
// arrays below, with specific per-element weights
|
||||
// Figure which number can be found in most arrays of the set of
|
||||
// arrays below, with specific per-element weights
|
||||
double[][] a =
|
||||
[
|
||||
[ 1, 4, 7, 8 ],
|
||||
|
@ -736,8 +726,7 @@ void largestPartialIntersectionWeighted
|
|||
auto b = new Tuple!(double, uint)[1];
|
||||
double[double] weights = [ 1:1.2, 4:2.3, 7:1.1, 8:1.1 ];
|
||||
largestPartialIntersectionWeighted(a, b, weights);
|
||||
// First member is the item, second is the occurrence count
|
||||
//writeln(b[0]);
|
||||
// First member is the item, second is the occurrence count
|
||||
assert(b[0] == tuple(4.0, 2u));
|
||||
}
|
||||
|
||||
|
|
|
@ -1024,8 +1024,6 @@ if (isRandomAccessRange!Range && !isInfinite!Range &&
|
|||
|
||||
@system unittest
|
||||
{
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
immutable(int)[] arr = [ 2, 3, 1, 5, 0 ];
|
||||
// index using pointers
|
||||
auto index1 = new immutable(int)*[arr.length];
|
||||
|
@ -1701,9 +1699,6 @@ private void shortSort(alias less, Range)(Range r)
|
|||
{
|
||||
import std.random : Random, uniform;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
auto rnd = Random(1);
|
||||
auto a = new int[uniform(100, 200, rnd)];
|
||||
foreach (ref e; a)
|
||||
|
@ -1944,9 +1939,6 @@ if (((ss == SwapStrategy.unstable && (hasSwappableElements!Range ||
|
|||
import std.random : Random, unpredictableSeed, uniform;
|
||||
import std.uni : toUpper;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
// sort using delegate
|
||||
auto a = new int[100];
|
||||
auto rnd = Random(unpredictableSeed);
|
||||
|
@ -2972,9 +2964,6 @@ if (isRandomAccessRange!R && hasLength!R)
|
|||
import std.algorithm.iteration : map;
|
||||
import std.numeric : entropy;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
auto lowEnt = [ 1.0, 0, 0 ],
|
||||
midEnt = [ 0.1, 0.1, 0.8 ],
|
||||
highEnt = [ 0.31, 0.29, 0.4 ];
|
||||
|
@ -3455,10 +3444,6 @@ private T[] randomArray(Flag!"exactSize" flag = No.exactSize, T = int)(
|
|||
import std.algorithm.comparison : max, min;
|
||||
import std.algorithm.iteration : reduce;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
//scope(failure) writeln(stderr, "Failure testing algorithm");
|
||||
//auto v = [ 25, 7, 9, 2, 0, 5, 21 ];
|
||||
int[] v = [ 7, 6, 5, 4, 3, 2, 1, 0 ];
|
||||
ptrdiff_t n = 3;
|
||||
topN!("a < b")(v, n);
|
||||
|
@ -3507,9 +3492,6 @@ private T[] randomArray(Flag!"exactSize" flag = No.exactSize, T = int)(
|
|||
import std.algorithm.iteration : reduce;
|
||||
import std.random : Random, uniform, unpredictableSeed;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
immutable uint[] seeds = [90027751, 2709791795, 1374631933, 995751648, 3541495258, 984840953, unpredictableSeed];
|
||||
foreach (s; seeds)
|
||||
{
|
||||
|
@ -3716,9 +3698,6 @@ if (isInputRange!(SRange) && isRandomAccessRange!(TRange)
|
|||
import std.random : Random, unpredictableSeed, uniform, randomShuffle;
|
||||
import std.typecons : Yes;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
auto r = Random(unpredictableSeed);
|
||||
ptrdiff_t[] a = new ptrdiff_t[uniform(1, 1000, r)];
|
||||
foreach (i, ref e; a) e = i;
|
||||
|
@ -3845,21 +3824,16 @@ if (isRandomAccessRange!Range &&
|
|||
{
|
||||
import std.conv : text;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
{
|
||||
int[] a = [ 10, 8, 9, 2, 4, 6, 7, 1, 3, 5 ];
|
||||
int*[] b = new int*[5];
|
||||
topNIndex!("a > b")(a, b, Yes.sortOutput);
|
||||
//foreach (e; b) writeln(*e);
|
||||
assert(b == [ &a[0], &a[2], &a[1], &a[6], &a[5]]);
|
||||
}
|
||||
{
|
||||
int[] a = [ 10, 8, 9, 2, 4, 6, 7, 1, 3, 5 ];
|
||||
auto b = new ubyte[5];
|
||||
topNIndex!("a > b")(a, b, Yes.sortOutput);
|
||||
//foreach (e; b) writeln(e, ":", a[e]);
|
||||
assert(b == [ cast(ubyte) 0, cast(ubyte) 2, cast(ubyte) 1, cast(ubyte) 6, cast(ubyte) 5], text(b));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue