Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 1 addition & 31 deletions std/algorithm/iteration.d
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]));

Expand All @@ -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 ];
Expand Down Expand Up @@ -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)));
Expand Down Expand Up @@ -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) ][]));
Expand Down Expand Up @@ -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 ];
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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)));

Expand Down Expand Up @@ -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, ["", ""][]));
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)));
Expand Down
36 changes: 2 additions & 34 deletions std/algorithm/mutation.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 ];
Expand Down Expand Up @@ -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));
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 ]);
Expand All @@ -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]);

Expand Down Expand Up @@ -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 ]);
}
Expand Down Expand Up @@ -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 ];
Expand Down
1 change: 0 additions & 1 deletion std/algorithm/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading