Strict @property syntax compliance.

This enables the test suite to build with the -property switch enabled.

std.cpuid: vendor()/processor() have not been converted to properties in accordance to core.cpuid.
std.xml: Element.text() cannot be a property due to the optional parameter.
This commit is contained in:
David Nadlinger 2011-12-01 22:49:16 +01:00
parent 0eddab60b9
commit e312f9898b
33 changed files with 603 additions and 593 deletions

View file

@ -492,9 +492,9 @@ unittest
assert(squares2.back == 16); assert(squares2.back == 16);
assert(squares2.front == 1); assert(squares2.front == 1);
squares2.popFront; squares2.popFront();
assert(squares2.front == 4); assert(squares2.front == 4);
squares2.popBack; squares2.popBack();
assert(squares2.front == 4); assert(squares2.front == 4);
assert(squares2.back == 9); assert(squares2.back == 9);
@ -527,10 +527,10 @@ unittest
// stuff is disabled. // stuff is disabled.
auto fibsSquares = map!"a * a"(recurrence!("a[n-1] + a[n-2]")(1, 1)); auto fibsSquares = map!"a * a"(recurrence!("a[n-1] + a[n-2]")(1, 1));
assert(fibsSquares.front == 1); assert(fibsSquares.front == 1);
fibsSquares.popFront; fibsSquares.popFront();
fibsSquares.popFront; fibsSquares.popFront();
assert(fibsSquares.front == 4); assert(fibsSquares.front == 4);
fibsSquares.popFront; fibsSquares.popFront();
assert(fibsSquares.front == 9); assert(fibsSquares.front == 9);
auto repeatMap = map!"a"(repeat(1)); auto repeatMap = map!"a"(repeat(1));
@ -641,7 +641,7 @@ template reduce(fun...) if (fun.length >= 1)
alias args[0] seed; alias args[0] seed;
alias args[1] r; alias args[1] r;
Unqual!(Args[0]) result = seed; Unqual!(Args[0]) result = seed;
for (; !r.empty; r.popFront) for (; !r.empty; r.popFront())
{ {
static if (fun.length == 1) static if (fun.length == 1)
{ {
@ -849,7 +849,7 @@ if (isForwardRange!Range && is(typeof(range.front = filler)))
alias ElementType!Range T; alias ElementType!Range T;
static if (hasElaborateCopyConstructor!T || !isDynamicArray!Range) static if (hasElaborateCopyConstructor!T || !isDynamicArray!Range)
{ {
for (; !range.empty; range.popFront) for (; !range.empty; range.popFront())
{ {
range.front = filler; range.front = filler;
} }
@ -912,7 +912,7 @@ if (isForwardRange!Range1 && isForwardRange!Range2
{ {
enforce(!filler.empty); enforce(!filler.empty);
auto t = filler.save; auto t = filler.save;
for (; !range.empty; range.popFront, t.popFront) for (; !range.empty; range.popFront(), t.popFront())
{ {
if (t.empty) t = filler; if (t.empty) t = filler;
range.front = t.front; range.front = t.front;
@ -950,7 +950,7 @@ if (isForwardRange!Range && is(typeof(range.front = filler)))
static if (hasElaborateCopyConstructor!T) static if (hasElaborateCopyConstructor!T)
{ {
// Must construct stuff by the book // Must construct stuff by the book
for (; !range.empty; range.popFront) for (; !range.empty; range.popFront())
{ {
emplace(&range.front, filler); emplace(&range.front, filler);
} }
@ -1006,7 +1006,7 @@ if (isForwardRange!Range && is(typeof(range.front = range.front)))
static if (is(typeof(&(range.front())))) static if (is(typeof(&(range.front()))))
{ {
// Range exposes references // Range exposes references
for (; !range.empty; range.popFront) for (; !range.empty; range.popFront())
{ {
memcpy(&(range.front()), &T.init, T.sizeof); memcpy(&(range.front()), &T.init, T.sizeof);
} }
@ -1014,7 +1014,7 @@ if (isForwardRange!Range && is(typeof(range.front = range.front)))
else else
{ {
// Go the slow route // Go the slow route
for (; !range.empty; range.popFront) for (; !range.empty; range.popFront())
{ {
range.front = filler; range.front = filler;
} }
@ -1104,7 +1104,7 @@ template filter(alias pred) if (is(typeof(unaryFun!pred)))
{ {
do do
{ {
_input.popFront; _input.popFront();
} while (!_input.empty && !unaryFun!pred(_input.front)); } while (!_input.empty && !unaryFun!pred(_input.front));
} }
@ -1258,7 +1258,7 @@ template filterBidirectional(alias pred)
{ {
do do
{ {
_input.popFront; _input.popFront();
} while (!_input.empty && !predFun(_input.front)); } while (!_input.empty && !predFun(_input.front));
} }
@ -1271,7 +1271,7 @@ template filterBidirectional(alias pred)
{ {
do do
{ {
_input.popBack; _input.popBack();
} while (!_input.empty && !predFun(_input.back)); } while (!_input.empty && !predFun(_input.back));
} }
@ -1422,7 +1422,7 @@ Range2 moveAll(Range1, Range2)(Range1 src, Range2 tgt)
if (isInputRange!Range1 && isInputRange!Range2 if (isInputRange!Range1 && isInputRange!Range2
&& is(typeof(move(src.front, tgt.front)))) && is(typeof(move(src.front, tgt.front))))
{ {
for (; !src.empty; src.popFront, tgt.popFront) for (; !src.empty; src.popFront(), tgt.popFront())
{ {
enforce(!tgt.empty); enforce(!tgt.empty);
move(src.front, tgt.front); move(src.front, tgt.front);
@ -1452,7 +1452,7 @@ Tuple!(Range1, Range2) moveSome(Range1, Range2)(Range1 src, Range2 tgt)
if (isInputRange!Range1 && isInputRange!Range2 if (isInputRange!Range1 && isInputRange!Range2
&& is(typeof(move(src.front, tgt.front)))) && is(typeof(move(src.front, tgt.front))))
{ {
for (; !src.empty && !tgt.empty; src.popFront, tgt.popFront) for (; !src.empty && !tgt.empty; src.popFront(), tgt.popFront())
{ {
enforce(!tgt.empty); enforce(!tgt.empty);
move(src.front, tgt.front); move(src.front, tgt.front);
@ -1859,7 +1859,7 @@ if (is(typeof(Range.init.front == Separator.init.front) : bool))
static if (isBidirectionalRange!Range) static if (isBidirectionalRange!Range)
RIndexType _backLength = RIndexType.max; RIndexType _backLength = RIndexType.max;
auto separatorLength() { return _separator.length; } @property auto separatorLength() { return _separator.length; }
void ensureFrontLength() void ensureFrontLength()
{ {
@ -1913,7 +1913,7 @@ if (is(typeof(Range.init.front == Separator.init.front) : bool))
void popFront() void popFront()
{ {
assert(!empty); assert(!empty);
ensureFrontLength; ensureFrontLength();
if (_frontLength == _input.length) if (_frontLength == _input.length)
{ {
// done, there's no separator in sight // done, there's no separator in sight
@ -1955,13 +1955,13 @@ if (is(typeof(Range.init.front == Separator.init.front) : bool))
{ {
@property Range back() @property Range back()
{ {
ensureBackLength; ensureBackLength();
return _input[_input.length - _backLength .. _input.length]; return _input[_input.length - _backLength .. _input.length];
} }
void popBack() void popBack()
{ {
ensureBackLength; ensureBackLength();
if (_backLength == _input.length) if (_backLength == _input.length)
{ {
// done // done
@ -2482,7 +2482,7 @@ if (isInputRange!Range && is(typeof(binaryFun!pred(r.front, r.front)) == bool))
auto last = _input.front; auto last = _input.front;
do do
{ {
_input.popFront; _input.popFront();
} }
while (!_input.empty && binaryFun!(pred)(last, _input.front)); while (!_input.empty && binaryFun!(pred)(last, _input.front));
} }
@ -2496,7 +2496,7 @@ if (isInputRange!Range && is(typeof(binaryFun!pred(r.front, r.front)) == bool))
auto last = _input.back; auto last = _input.back;
do do
{ {
_input.popBack; _input.popBack();
} }
while (!_input.empty && binaryFun!pred(last, _input.back)); while (!_input.empty && binaryFun!pred(last, _input.back));
} }
@ -2575,7 +2575,7 @@ struct Group(alias pred, R) if (isInputRange!R)
this(R input) this(R input)
{ {
_input = input; _input = input;
if (!_input.empty) popFront; if (!_input.empty) popFront();
} }
void popFront() void popFront()
@ -2587,11 +2587,11 @@ struct Group(alias pred, R) if (isInputRange!R)
else else
{ {
_current = tuple(_input.front, 1u); _current = tuple(_input.front, 1u);
_input.popFront; _input.popFront();
while (!_input.empty && comp(_current[0], _input.front)) while (!_input.empty && comp(_current[0], _input.front))
{ {
++_current[1]; ++_current[1];
_input.popFront; _input.popFront();
} }
} }
} }
@ -2680,12 +2680,12 @@ assert(r == [ 1, 2, 3, 4, 5 ]);
// //auto target = begin(r), e = end(r); // //auto target = begin(r), e = end(r);
// auto target = r; // auto target = r;
// auto source = r; // auto source = r;
// source.popFront; // source.popFront();
// while (!source.empty) // while (!source.empty)
// { // {
// if (!pred(target.front, source.front)) // if (!pred(target.front, source.front))
// { // {
// target.popFront; // target.popFront();
// continue; // continue;
// } // }
// // found an equal *source and *target // // found an equal *source and *target
@ -2694,9 +2694,9 @@ assert(r == [ 1, 2, 3, 4, 5 ]);
// //@@@ // //@@@
// //move(source.front, target.front); // //move(source.front, target.front);
// target[0] = source[0]; // target[0] = source[0];
// source.popFront; // source.popFront();
// if (source.empty) break; // if (source.empty) break;
// if (!pred(target.front, source.front)) target.popFront; // if (!pred(target.front, source.front)) target.popFront();
// } // }
// break; // break;
// } // }
@ -3093,7 +3093,7 @@ Tuple!(Range, size_t) find(alias pred = "a == b", Range, Ranges...)
(Range haystack, Ranges needles) (Range haystack, Ranges needles)
if (Ranges.length > 1 && allSatisfy!(isForwardRange, Ranges)) if (Ranges.length > 1 && allSatisfy!(isForwardRange, Ranges))
{ {
for (;; haystack.popFront) for (;; haystack.popFront())
{ {
size_t r = startsWith!pred(haystack, needles); size_t r = startsWith!pred(haystack, needles);
if (r || haystack.empty) if (r || haystack.empty)
@ -3324,7 +3324,7 @@ assert(find!(pred)(arr) == arr);
Range find(alias pred, Range)(Range haystack) if (isInputRange!(Range)) Range find(alias pred, Range)(Range haystack) if (isInputRange!(Range))
{ {
alias unaryFun!(pred) predFun; alias unaryFun!(pred) predFun;
for (; !haystack.empty && !predFun(haystack.front); haystack.popFront) for (; !haystack.empty && !predFun(haystack.front); haystack.popFront())
{ {
} }
return haystack; return haystack;
@ -3794,13 +3794,13 @@ struct Until(alias pred, Range, Sentinel) if (isInputRange!Range)
_done = true; _done = true;
return; return;
} }
_input.popFront; _input.popFront();
_done = _input.empty; _done = _input.empty;
} }
else else
{ {
_input.popFront; _input.popFront();
_done = _input.empty || predSatisfied; _done = _input.empty || predSatisfied();
} }
} }
@ -4402,7 +4402,7 @@ Range findAdjacent(alias pred = "a == b", Range)(Range r)
auto ahead = r; auto ahead = r;
if (!ahead.empty) if (!ahead.empty)
{ {
for (ahead.popFront; !ahead.empty; r.popFront, ahead.popFront) for (ahead.popFront(); !ahead.empty; r.popFront(), ahead.popFront())
{ {
if (binaryFun!(pred)(r.front, ahead.front)) return r; if (binaryFun!(pred)(r.front, ahead.front)) return r;
} }
@ -4449,7 +4449,7 @@ Range1 findAmong(alias pred = "a == b", Range1, Range2)(
Range1 seq, Range2 choices) Range1 seq, Range2 choices)
if (isInputRange!Range1 && isForwardRange!Range2) if (isInputRange!Range1 && isForwardRange!Range2)
{ {
for (; !seq.empty && find!pred(choices, seq.front).empty; seq.popFront) for (; !seq.empty && find!pred(choices, seq.front).empty; seq.popFront())
{ {
} }
return seq; return seq;
@ -4968,7 +4968,7 @@ minCount(alias pred = "a < b", Range)(Range range)
if (range.empty) return typeof(return)(); if (range.empty) return typeof(return)();
auto p = &(range.front()); auto p = &(range.front());
size_t occurrences = 1; size_t occurrences = 1;
for (range.popFront; !range.empty; range.popFront) for (range.popFront(); !range.empty; range.popFront())
{ {
if (binaryFun!(pred)(*p, range.front)) continue; if (binaryFun!(pred)(*p, range.front)) continue;
if (binaryFun!(pred)(range.front, *p)) if (binaryFun!(pred)(range.front, *p))
@ -5018,7 +5018,7 @@ Range minPos(alias pred = "a < b", Range)(Range range)
{ {
if (range.empty) return range; if (range.empty) return range;
auto result = range; auto result = range;
for (range.popFront; !range.empty; range.popFront) for (range.popFront(); !range.empty; range.popFront())
{ {
if (binaryFun!(pred)(result.front, range.front) if (binaryFun!(pred)(result.front, range.front)
|| !binaryFun!(pred)(range.front, result.front)) continue; || !binaryFun!(pred)(range.front, result.front)) continue;
@ -5294,7 +5294,7 @@ levenshteinDistanceAndPath(alias equals = "a == b", Range1, Range2)
{ {
Levenshtein!(Range1, binaryFun!(equals)) lev; Levenshtein!(Range1, binaryFun!(equals)) lev;
auto d = lev.distance(s, t); auto d = lev.distance(s, t);
return tuple(d, lev.path); return tuple(d, lev.path());
} }
unittest unittest
@ -5429,7 +5429,7 @@ swapRanges(Range1, Range2)(Range1 r1, Range2 r2)
&& hasSwappableElements!(Range1) && hasSwappableElements!(Range2) && hasSwappableElements!(Range1) && hasSwappableElements!(Range2)
&& is(ElementType!(Range1) == ElementType!(Range2))) && is(ElementType!(Range1) == ElementType!(Range2)))
{ {
for (; !r1.empty && !r2.empty; r1.popFront, r2.popFront) for (; !r1.empty && !r2.empty; r1.popFront(), r2.popFront())
{ {
swap(r1.front, r2.front); swap(r1.front, r2.front);
} }
@ -5466,9 +5466,9 @@ if (isBidirectionalRange!(Range) && hasSwappableElements!(Range))
while (!r.empty) while (!r.empty)
{ {
swap(r.front, r.back); swap(r.front, r.back);
r.popFront; r.popFront();
if (r.empty) break; if (r.empty) break;
r.popBack; r.popBack();
} }
} }
@ -5874,8 +5874,8 @@ if (isBidirectionalRange!Range && hasLength!Range && s != SwapStrategy.stable
foreach (i; 0 .. rid) foreach (i; 0 .. rid)
{ {
move(range.back, t.front); move(range.back, t.front);
range.popBack; range.popBack();
t.popFront; t.popFront();
} }
if (rEnd - rStart == lEnd - lStart) if (rEnd - rStart == lEnd - lStart)
{ {
@ -5947,14 +5947,14 @@ if ((isForwardRange!Range && !isBidirectionalRange!Range
enum delta = 1; enum delta = 1;
} }
assert(pos <= from); assert(pos <= from);
for (; pos < from; ++pos, src.popFront, tgt.popFront) for (; pos < from; ++pos, src.popFront(), tgt.popFront())
{ {
move(src.front, tgt.front); move(src.front, tgt.front);
} }
// now skip source to the "to" position // now skip source to the "to" position
src.popFrontN(delta); src.popFrontN(delta);
pos += delta; pos += delta;
foreach (j; 0 .. delta) result.popBack; foreach (j; 0 .. delta) result.popBack();
} }
// leftover move // leftover move
moveAll(src, tgt); moveAll(src, tgt);
@ -6023,28 +6023,28 @@ if (isBidirectionalRange!Range)
{ {
if (!unaryFun!(pred)(range.front)) if (!unaryFun!(pred)(range.front))
{ {
range.popFront; range.popFront();
continue; continue;
} }
move(range.back, range.front); move(range.back, range.front);
range.popBack; range.popBack();
result.popBack; result.popBack();
} }
} }
else else
{ {
auto tgt = range; auto tgt = range;
for (; !range.empty; range.popFront) for (; !range.empty; range.popFront())
{ {
if (unaryFun!(pred)(range.front)) if (unaryFun!(pred)(range.front))
{ {
// yank this guy // yank this guy
result.popBack; result.popBack();
continue; continue;
} }
// keep this guy // keep this guy
move(range.front, tgt.front); move(range.front, tgt.front);
tgt.popFront; tgt.popFront();
} }
} }
return result; return result;
@ -6203,7 +6203,7 @@ Range partition(alias predicate,
{ {
if (r.length == 1) if (r.length == 1)
{ {
if (pred(r.front)) r.popFront; if (pred(r.front)) r.popFront();
return r; return r;
} }
const middle = r.length / 2; const middle = r.length / 2;
@ -6215,17 +6215,17 @@ Range partition(alias predicate,
} }
else static if (ss == SwapStrategy.semistable) else static if (ss == SwapStrategy.semistable)
{ {
for (; !r.empty; r.popFront) for (; !r.empty; r.popFront())
{ {
// skip the initial portion of "correct" elements // skip the initial portion of "correct" elements
if (pred(r.front)) continue; if (pred(r.front)) continue;
// hit the first "bad" element // hit the first "bad" element
auto result = r; auto result = r;
for (r.popFront; !r.empty; r.popFront) for (r.popFront(); !r.empty; r.popFront())
{ {
if (!pred(r.front)) continue; if (!pred(r.front)) continue;
swap(result.front, r.front); swap(result.front, r.front);
result.popFront; result.popFront();
} }
return result; return result;
} }
@ -6242,15 +6242,15 @@ Range partition(alias predicate,
{ {
if (r.empty) return result; if (r.empty) return result;
if (!pred(r.front)) break; if (!pred(r.front)) break;
r.popFront; r.popFront();
result.popFront; result.popFront();
} }
// found the left bound // found the left bound
assert(!r.empty); assert(!r.empty);
for (;;) for (;;)
{ {
if (pred(r.back)) break; if (pred(r.back)) break;
r.popBack; r.popBack();
if (r.empty) return result; if (r.empty) return result;
} }
// found the right bound, swap & make progress // found the right bound, swap & make progress
@ -6264,9 +6264,9 @@ Range partition(alias predicate,
r.front = t2; r.front = t2;
r.back = t1; r.back = t1;
} }
r.popFront; r.popFront();
result.popFront; result.popFront();
r.popBack; r.popBack();
} }
} }
} }
@ -6307,7 +6307,7 @@ unittest // partition
auto a = rndstuff!(int)(); auto a = rndstuff!(int)();
partition!(even)(a); partition!(even)(a);
assert(isPartitioned!(even)(a)); assert(isPartitioned!(even)(a));
auto b = rndstuff!(string); auto b = rndstuff!(string)();
partition!(`a.length < 5`)(b); partition!(`a.length < 5`)(b);
assert(isPartitioned!(`a.length < 5`)(b)); assert(isPartitioned!(`a.length < 5`)(b));
} }
@ -6325,10 +6325,10 @@ assert(isPartitioned!("a & 1")(r));
bool isPartitioned(alias pred, Range)(Range r) bool isPartitioned(alias pred, Range)(Range r)
if (isForwardRange!(Range)) if (isForwardRange!(Range))
{ {
for (; !r.empty; r.popFront) for (; !r.empty; r.popFront())
{ {
if (unaryFun!(pred)(r.front)) continue; if (unaryFun!(pred)(r.front)) continue;
for (r.popFront; !r.empty; r.popFront) for (r.popFront(); !r.empty; r.popFront())
{ {
if (unaryFun!(pred)(r.front)) return false; if (unaryFun!(pred)(r.front)) return false;
} }
@ -6602,7 +6602,7 @@ void topN(alias less = "a < b",
static assert(ss == SwapStrategy.unstable, static assert(ss == SwapStrategy.unstable,
"Stable topN not yet implemented"); "Stable topN not yet implemented");
auto heap = BinaryHeap!Range1(r1); auto heap = BinaryHeap!Range1(r1);
for (; !r2.empty; r2.popFront) for (; !r2.empty; r2.popFront())
{ {
heap.conditionalInsert(r2.front); heap.conditionalInsert(r2.front);
} }
@ -6714,10 +6714,10 @@ unittest
//sort!("b - a")(a); //sort!("b - a")(a);
//assert(isSorted!(less)(a)); //assert(isSorted!(less)(a));
a = rndstuff!(int); a = rndstuff!(int)();
sort(a); sort(a);
assert(isSorted(a)); assert(isSorted(a));
auto b = rndstuff!(string); auto b = rndstuff!(string)();
sort!("toLower(a) < toLower(b)")(b); sort!("toLower(a) < toLower(b)")(b);
assert(isSorted!("toUpper(a) < toUpper(b)")(b)); assert(isSorted!("toUpper(a) < toUpper(b)")(b));
} }
@ -7251,7 +7251,7 @@ void makeIndex(
{ {
// assume collection already ordered // assume collection already ordered
size_t i; size_t i;
for (; !r.empty; r.popFront, ++i) for (; !r.empty; r.popFront(), ++i)
index[i] = &(r.front); index[i] = &(r.front);
enforce(index.length == i); enforce(index.length == i);
// sort the index // sort the index
@ -7280,16 +7280,16 @@ void makeIndex(
static if(I.sizeof < size_t.sizeof) static if(I.sizeof < size_t.sizeof)
{ {
enforce(r.length <= I.max, "Cannot create an index with " ~ enforce(r.length <= I.max, "Cannot create an index with " ~
"element type " ~ I.stringof ~ " with length " ~ "element type " ~ I.stringof ~ " with length " ~
to!string(r.length) ~ "." to!string(r.length) ~ "."
); );
} }
for(I i = 0; i < r.length; ++i) for(I i = 0; i < r.length; ++i)
{ {
index[cast(size_t) i] = i; index[cast(size_t) i] = i;
} }
// sort the index // sort the index
bool indirectLess(ElementType!(RangeIndex) a, ElementType!(RangeIndex) b) bool indirectLess(ElementType!(RangeIndex) a, ElementType!(RangeIndex) b)
{ {
@ -7593,7 +7593,7 @@ unittest
} }
// random data // random data
auto b = rndstuff!(string); auto b = rndstuff!(string)();
auto index = new string*[b.length]; auto index = new string*[b.length];
partialIndex!("std.uni.toUpper(a) < std.uni.toUpper(b)")(b, index); partialIndex!("std.uni.toUpper(a) < std.uni.toUpper(b)")(b, index);
assert(isSorted!("std.uni.toUpper(*a) < std.uni.toUpper(*b)")(index)); assert(isSorted!("std.uni.toUpper(*a) < std.uni.toUpper(*b)")(index));
@ -7672,7 +7672,7 @@ unittest
// && *index[2] == "c" && *index[3] == "C"); // && *index[2] == "c" && *index[3] == "C");
// // random data // // random data
// auto b = rndstuff!(string); // auto b = rndstuff!(string)();
// auto index1 = schwartzMakeIndex!(toUpper)(b); // auto index1 = schwartzMakeIndex!(toUpper)(b);
// assert(isSorted!("toUpper(*a) < toUpper(*b)")(index1)); // assert(isSorted!("toUpper(*a) < toUpper(*b)")(index1));
// } // }
@ -7694,7 +7694,7 @@ unittest
{ {
debug(std_algorithm) scope(success) debug(std_algorithm) scope(success)
writeln("unittest @", __FILE__, ":", __LINE__, " done."); writeln("unittest @", __FILE__, ":", __LINE__, " done.");
auto a = rndstuff!(int); auto a = rndstuff!(int)();
if (a.length) if (a.length)
{ {
auto b = a[a.length / 2]; auto b = a[a.length / 2];
@ -7883,7 +7883,7 @@ public:
if (i < _crt) continue; if (i < _crt) continue;
// found _crt // found _crt
assert(!_r[i].empty); assert(!_r[i].empty);
_r[i].popFront; _r[i].popFront();
adjustPosition(); adjustPosition();
return; return;
} }
@ -7985,11 +7985,11 @@ private:
{ {
if (comp(_input[0].front, _input[1].front)) if (comp(_input[0].front, _input[1].front))
{ {
_input[0].popFront; _input[0].popFront();
} }
else if (comp(_input[1].front, _input[0].front)) else if (comp(_input[1].front, _input[0].front))
{ {
_input[1].popFront; _input[1].popFront();
} }
else else
{ {
@ -8003,7 +8003,7 @@ public:
{ {
this._input = input; this._input = input;
// position to the first element // position to the first element
adjustPosition; adjustPosition();
} }
@property bool empty() @property bool empty()
@ -8020,9 +8020,9 @@ public:
assert(!empty); assert(!empty);
assert(!comp(_input[0].front, _input[1].front) assert(!comp(_input[0].front, _input[1].front)
&& !comp(_input[1].front, _input[0].front)); && !comp(_input[1].front, _input[0].front));
_input[0].popFront; _input[0].popFront();
_input[1].popFront; _input[1].popFront();
adjustPosition; adjustPosition();
} }
@property ElementType front() @property ElementType front()
@ -8102,13 +8102,13 @@ private:
if (r2.empty || comp(r1.front, r2.front)) break; if (r2.empty || comp(r1.front, r2.front)) break;
if (comp(r2.front, r1.front)) if (comp(r2.front, r1.front))
{ {
r2.popFront; r2.popFront();
} }
else else
{ {
// both are equal // both are equal
r1.popFront; r1.popFront();
r2.popFront; r2.popFront();
} }
} }
} }
@ -8119,13 +8119,13 @@ public:
this.r1 = r1; this.r1 = r1;
this.r2 = r2; this.r2 = r2;
// position to the first element // position to the first element
adjustPosition; adjustPosition();
} }
void popFront() void popFront()
{ {
r1.popFront; r1.popFront();
adjustPosition; adjustPosition();
} }
@property ElementType!(R1) front() @property ElementType!(R1) front()
@ -8145,7 +8145,7 @@ public:
} }
} }
bool empty() { return r1.empty; } @property bool empty() { return r1.empty; }
} }
/// Ditto /// Ditto
@ -8198,8 +8198,8 @@ private:
break; break;
} }
// equal, pop both // equal, pop both
r1.popFront; r1.popFront();
r2.popFront; r2.popFront();
} }
} }
@ -8209,28 +8209,28 @@ public:
this.r1 = r1; this.r1 = r1;
this.r2 = r2; this.r2 = r2;
// position to the first element // position to the first element
adjustPosition; adjustPosition();
} }
void popFront() void popFront()
{ {
assert(!empty); assert(!empty);
if (r1.empty) r2.popFront; if (r1.empty) r2.popFront();
else if (r2.empty) r1.popFront; else if (r2.empty) r1.popFront();
else else
{ {
// neither is empty // neither is empty
if (comp(r1.front, r2.front)) if (comp(r1.front, r2.front))
{ {
r1.popFront; r1.popFront();
} }
else else
{ {
assert(comp(r2.front, r1.front)); assert(comp(r2.front, r1.front));
r2.popFront; r2.popFront();
} }
} }
adjustPosition; adjustPosition();
} }
@property ElementType!(R1) front() @property ElementType!(R1) front()
@ -8409,10 +8409,10 @@ struct NWayUnion(alias less, RangeOfRanges)
{ {
_heap.removeFront(); _heap.removeFront();
// let's look at the guy just popped // let's look at the guy just popped
_ror.back.popFront; _ror.back.popFront();
if (_ror.back.empty) if (_ror.back.empty)
{ {
_ror.popBack; _ror.popBack();
// nothing else to do: the empty range is not in the // nothing else to do: the empty range is not in the
// heap and not in _ror // heap and not in _ror
return; return;

View file

@ -333,8 +333,8 @@ unittest
auto a = [ 1, 2, 3 ]; auto a = [ 1, 2, 3 ];
a.popFront(); a.popFront();
assert(a == [ 2, 3 ]); assert(a == [ 2, 3 ]);
static assert(!__traits(compiles, popFront!(immutable int[]))); static assert(!__traits(compiles, popFront!(immutable int[])()));
static assert(!__traits(compiles, popFront!(void[]))); static assert(!__traits(compiles, popFront!(void[])()));
} }
// Specialization for narrow strings. The necessity of // Specialization for narrow strings. The necessity of
@ -1234,7 +1234,7 @@ ElementEncodingType!(ElementType!RoR)[] joinImpl(RoR, R)(RoR ror, R sep)
return result; return result;
} }
else else
return copy(iter, appender!(typeof(return))).data; return copy(iter, appender!(typeof(return))()).data;
} }
ElementEncodingType!(ElementType!RoR)[] joinImpl(RoR, R)(RoR ror, R sep) ElementEncodingType!(ElementType!RoR)[] joinImpl(RoR, R)(RoR ror, R sep)
@ -1326,7 +1326,7 @@ ElementEncodingType!(ElementType!RoR)[] joinImpl(RoR)(RoR ror)
return cast(typeof(return)) result; return cast(typeof(return)) result;
} }
else else
return copy(iter, appender!(typeof(return))).data; return copy(iter, appender!(typeof(return))()).data;
} }
ElementEncodingType!(ElementType!RoR)[] joinImpl(RoR)(RoR ror) ElementEncodingType!(ElementType!RoR)[] joinImpl(RoR)(RoR ror)
@ -2291,7 +2291,7 @@ struct SimpleSlice(T)
foreach (p; _b .. _e) foreach (p; _b .. _e)
{ {
*p = anotherSlice.front; *p = anotherSlice.front;
anotherSlice.popFront; anotherSlice.popFront();
} }
} }
} }
@ -2437,7 +2437,7 @@ struct SimpleSliceLvalue(T)
foreach (p; _b .. _e) foreach (p; _b .. _e)
{ {
*p = anotherSlice.front; *p = anotherSlice.front;
anotherSlice.popFront; anotherSlice.popFront();
} }
} }
} }

View file

@ -1518,7 +1518,7 @@ unittest
auto f = File("testingEncoder"); auto f = File("testingEncoder");
scope(exit) scope(exit)
{ {
f.close; f.close();
assert(!f.isOpen); assert(!f.isOpen);
std.file.remove("testingEncoder"); std.file.remove("testingEncoder");
} }
@ -1537,7 +1537,7 @@ unittest
auto f = File("testingDecoder"); auto f = File("testingDecoder");
scope(exit) scope(exit)
{ {
f.close; f.close();
assert(!f.isOpen); assert(!f.isOpen);
std.file.remove("testingDecoder"); std.file.remove("testingDecoder");
} }

View file

@ -87,7 +87,7 @@ private
data = Tuple!(T)( vals ); data = Tuple!(T)( vals );
} }
auto convertsTo(T...)() @property auto convertsTo(T...)()
{ {
static if( T.length == 1 ) static if( T.length == 1 )
return is( T[0] == Variant ) || return is( T[0] == Variant ) ||
@ -96,7 +96,7 @@ private
return data.convertsTo!(Tuple!(T)); return data.convertsTo!(Tuple!(T));
} }
auto get(T...)() @property auto get(T...)()
{ {
static if( T.length == 1 ) static if( T.length == 1 )
{ {
@ -1292,7 +1292,7 @@ private
/* /*
* *
*/ */
bool empty() @property bool empty()
{ {
return m_first is null; return m_first is null;
} }

View file

@ -941,7 +941,7 @@ Defines the container's primary range, which embodies a forward range.
private Node * _head; private Node * _head;
private this(Node * p) { _head = p; } private this(Node * p) { _head = p; }
/// Forward range primitives. /// Forward range primitives.
bool empty() const { return !_head; } @property bool empty() const { return !_head; }
/// ditto /// ditto
@property Range save() { return this; } @property Range save() { return this; }
/// ditto /// ditto
@ -2561,7 +2561,7 @@ the heap work incorrectly.
this.percolateDown(_store, i, _length); this.percolateDown(_store, i, _length);
if (i-- == 0) break; if (i-- == 0) break;
} }
assertValid; assertValid();
} }
/** /**
@ -2573,7 +2573,7 @@ heap.
_payload.RefCounted.ensureInitialized(); _payload.RefCounted.ensureInitialized();
_store() = s; _store() = s;
_length() = min(_store.length, initialSize); _length() = min(_store.length, initialSize);
assertValid; assertValid();
} }
/** /**
@ -2736,7 +2736,7 @@ Replaces the largest element in the store with $(D value).
assert(!empty); assert(!empty);
_store.front = value; _store.front = value;
percolateDown(_store, 0, _length); percolateDown(_store, 0, _length);
assertValid; assertValid();
} }
/** /**
@ -2760,7 +2760,7 @@ must be collected.
if (!comp(value, _store.front)) return false; // value >= largest if (!comp(value, _store.front)) return false; // value >= largest
_store.front = value; _store.front = value;
percolateDown(_store, 0, _length); percolateDown(_store, 0, _length);
assertValid; assertValid();
return true; return true;
} }
} }
@ -2817,7 +2817,7 @@ struct Array(T) if (is(T == bool))
Data; Data;
private RefCounted!(Data, RefCountedAutoInitialize.no) _store; private RefCounted!(Data, RefCountedAutoInitialize.no) _store;
private ref size_t[] data() private @property ref size_t[] data()
{ {
assert(_store.RefCounted.isInitialized); assert(_store.RefCounted.isInitialized);
return _store._backend._payload; return _store._backend._payload;

View file

@ -937,7 +937,7 @@ T toImpl(T, S)(S s, in T nullstr)
if (!s) if (!s)
return nullstr; return nullstr;
return to!T(s.toString); return to!T(s.toString());
} }
unittest unittest
@ -1507,7 +1507,7 @@ unittest
{ {
foreach (Floating; AllFloats) foreach (Floating; AllFloats)
{ {
testFloatingToIntegral!(Floating, Integral); testFloatingToIntegral!(Floating, Integral)();
} }
} }
} }
@ -1517,7 +1517,7 @@ unittest
{ {
foreach (Floating; AllFloats) foreach (Floating; AllFloats)
{ {
testIntegralToFloating!(Integral, Floating); testIntegralToFloating!(Integral, Floating)();
} }
} }
} }
@ -3049,28 +3049,28 @@ enum y = octal!160;
auto z = octal!"1_000_000u"; auto z = octal!"1_000_000u";
---- ----
*/ */
int octal(string num)() @property int octal(string num)()
if((octalFitsInInt!(num) && !literalIsLong!(num)) && !literalIsUnsigned!(num)) if((octalFitsInInt!(num) && !literalIsLong!(num)) && !literalIsUnsigned!(num))
{ {
return octal!(int, num); return octal!(int, num);
} }
/// Ditto /// Ditto
long octal(string num)() @property long octal(string num)()
if((!octalFitsInInt!(num) || literalIsLong!(num)) && !literalIsUnsigned!(num)) if((!octalFitsInInt!(num) || literalIsLong!(num)) && !literalIsUnsigned!(num))
{ {
return octal!(long, num); return octal!(long, num);
} }
/// Ditto /// Ditto
uint octal(string num)() @property uint octal(string num)()
if((octalFitsInInt!(num) && !literalIsLong!(num)) && literalIsUnsigned!(num)) if((octalFitsInInt!(num) && !literalIsLong!(num)) && literalIsUnsigned!(num))
{ {
return octal!(int, num); return octal!(int, num);
} }
/// Ditto /// Ditto
ulong octal(string num)() @property ulong octal(string num)()
if((!octalFitsInInt!(num) || literalIsLong!(num)) && literalIsUnsigned!(num)) if((!octalFitsInInt!(num) || literalIsLong!(num)) && literalIsUnsigned!(num))
{ {
return octal!(long, num); return octal!(long, num);
@ -3093,7 +3093,7 @@ template octal(alias s)
assert(a == 8); assert(a == 8);
*/ */
T octal(T, string num)() @property T octal(T, string num)()
if (isOctalLiteral!num) if (isOctalLiteral!num)
{ {
ulong pow = 1; ulong pow = 1;

View file

@ -69,8 +69,8 @@ version(D_InlineAsm_X86)
if (hyperThreading) feats ~= "HTT"; if (hyperThreading) feats ~= "HTT";
return format( return format(
"Vendor string: %s\n", vendor, "Vendor string: %s\n", vendor(),
"Processor string: %s\n", processor, "Processor string: %s\n", processor(),
"Signature: Family=%d Model=%d Stepping=%d\n", family, model, stepping, "Signature: Family=%d Model=%d Stepping=%d\n", family, model, stepping,
"Features: %s\n", feats, "Features: %s\n", feats,
"Multithreading: %d threads / %d cores\n", threadsPerCPU, coresPerCPU); "Multithreading: %d threads / %d cores\n", threadsPerCPU, coresPerCPU);
@ -114,6 +114,8 @@ version(D_InlineAsm_X86)
/// Returns number of cores in CPU /// Returns number of cores in CPU
alias core.cpuid.coresPerCPU coresPerCPU; alias core.cpuid.coresPerCPU coresPerCPU;
@property
{
/// Is this an Intel processor? /// Is this an Intel processor?
bool intel() {return manufac==INTEL;} bool intel() {return manufac==INTEL;}
/// Is this an AMD processor? /// Is this an AMD processor?
@ -125,6 +127,7 @@ version(D_InlineAsm_X86)
uint model() {return core.cpuid.model;} uint model() {return core.cpuid.model;}
/// Returns family /// Returns family
uint family() {return core.cpuid.family;} uint family() {return core.cpuid.family;}
}
shared static this() shared static this()
{ {
@ -164,6 +167,8 @@ else
auto vendor() {return "unknown vendor"; } auto vendor() {return "unknown vendor"; }
auto processor() {return "unknown processor"; } auto processor() {return "unknown processor"; }
@property
{
bool mmx() {return false; } bool mmx() {return false; }
bool fxsr() {return false; } bool fxsr() {return false; }
bool sse() {return false; } bool sse() {return false; }
@ -188,4 +193,5 @@ else
uint stepping() {return 0; } uint stepping() {return 0; }
uint model() {return 0; } uint model() {return 0; }
uint family() {return 0; } uint family() {return 0; }
}
} }

View file

@ -865,7 +865,7 @@ version (Win32)
unittest unittest
{ {
auto dt = getUTCtime; auto dt = getUTCtime();
auto ft = d_time2FILETIME(dt); auto ft = d_time2FILETIME(dt);
auto dt1 = FILETIME2d_time(&ft); auto dt1 = FILETIME2d_time(&ft);
assert(dt == dt1, text(dt, " != ", dt1)); assert(dt == dt1, text(dt, " != ", dt1));
@ -1191,12 +1191,12 @@ ulong[] benchmark(fun...)(uint times, ulong[] result = null)
result.length = 0; result.length = 0;
foreach (i, Unused; fun) foreach (i, Unused; fun)
{ {
immutable t = getUTCtime; immutable t = getUTCtime();
foreach (j; 0 .. times) foreach (j; 0 .. times)
{ {
fun[i](); fun[i]();
} }
immutable delta = getUTCtime - t; immutable delta = getUTCtime() - t;
result ~= cast(uint)delta; result ~= cast(uint)delta;
} }
foreach (ref e; result) foreach (ref e; result)

View file

@ -21,5 +21,5 @@ extern(C) void std_date_static_this();
shared static this() shared static this()
{ {
std_date_static_this; std_date_static_this();
} }

View file

@ -2255,15 +2255,15 @@ assert(SysTime(DateTime(-7, 4, 5, 7, 45, 2)).day == 5);
{ {
version(testStdDateTime) version(testStdDateTime)
{ {
_assertPred!"=="(SysTime(DateTime(1970, 1, 1), UTC()).toUnixTime, 0); _assertPred!"=="(SysTime(DateTime(1970, 1, 1), UTC()).toUnixTime(), 0);
_assertPred!"=="(SysTime(DateTime(1970, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(1), UTC()).toUnixTime, 0); _assertPred!"=="(SysTime(DateTime(1970, 1, 1, 0, 0, 0), FracSec.from!"hnsecs"(1), UTC()).toUnixTime(), 0);
_assertPred!"=="(SysTime(DateTime(1970, 1, 1, 0, 0, 0), FracSec.from!"usecs"(1), UTC()).toUnixTime, 0); _assertPred!"=="(SysTime(DateTime(1970, 1, 1, 0, 0, 0), FracSec.from!"usecs"(1), UTC()).toUnixTime(), 0);
_assertPred!"=="(SysTime(DateTime(1970, 1, 1, 0, 0, 0), FracSec.from!"msecs"(1), UTC()).toUnixTime, 0); _assertPred!"=="(SysTime(DateTime(1970, 1, 1, 0, 0, 0), FracSec.from!"msecs"(1), UTC()).toUnixTime(), 0);
_assertPred!"=="(SysTime(DateTime(1970, 1, 1, 0, 0, 1), UTC()).toUnixTime, 1); _assertPred!"=="(SysTime(DateTime(1970, 1, 1, 0, 0, 1), UTC()).toUnixTime(), 1);
_assertPred!"=="(SysTime(DateTime(1969, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999), UTC()).toUnixTime, 0); _assertPred!"=="(SysTime(DateTime(1969, 12, 31, 23, 59, 59), FracSec.from!"hnsecs"(9_999_999), UTC()).toUnixTime(), 0);
_assertPred!"=="(SysTime(DateTime(1969, 12, 31, 23, 59, 59), FracSec.from!"usecs"(999_999), UTC()).toUnixTime, 0); _assertPred!"=="(SysTime(DateTime(1969, 12, 31, 23, 59, 59), FracSec.from!"usecs"(999_999), UTC()).toUnixTime(), 0);
_assertPred!"=="(SysTime(DateTime(1969, 12, 31, 23, 59, 59), FracSec.from!"msecs"(999), UTC()).toUnixTime, 0); _assertPred!"=="(SysTime(DateTime(1969, 12, 31, 23, 59, 59), FracSec.from!"msecs"(999), UTC()).toUnixTime(), 0);
_assertPred!"=="(SysTime(DateTime(1969, 12, 31, 23, 59, 59), UTC()).toUnixTime, -1); _assertPred!"=="(SysTime(DateTime(1969, 12, 31, 23, 59, 59), UTC()).toUnixTime(), -1);
} }
} }
@ -30790,7 +30790,7 @@ public:
sw.start(); sw.start();
sw.stop(); sw.stop();
sw.reset(); sw.reset();
assert(sw.peek().to!("seconds", real) == 0); assert(sw.peek().to!("seconds", real)() == 0);
} }
@ -30816,7 +30816,7 @@ public:
doublestart = false; doublestart = false;
assert(!doublestart); assert(!doublestart);
sw.stop(); sw.stop();
assert((t1 - sw.peek()).to!("seconds", real) <= 0); assert((t1 - sw.peek()).to!("seconds", real)() <= 0);
} }
@ -30842,7 +30842,7 @@ public:
catch(AssertError e) catch(AssertError e)
doublestop = false; doublestop = false;
assert(!doublestop); assert(!doublestop);
assert((t1 - sw.peek()).to!("seconds", real) == 0); assert((t1 - sw.peek()).to!("seconds", real)() == 0);
} }
@ -30962,7 +30962,7 @@ version(testStdDateTime) unittest
void f1() {auto b = a;} void f1() {auto b = a;}
void f2() {auto b = to!(string)(a);} void f2() {auto b = to!(string)(a);}
auto r = benchmark!(f0, f1, f2)(10_000_000); auto r = benchmark!(f0, f1, f2)(10_000_000);
writefln("Milliseconds to call fun[0] n times: %s", r[0].to!("msecs", int)); writefln("Milliseconds to call fun[0] n times: %s", r[0].to!("msecs", int)());
} }
version(testStdDateTime) @safe unittest version(testStdDateTime) @safe unittest
@ -31073,7 +31073,7 @@ version(testStdDateTime) @safe unittest
void f2x() {} void f2x() {}
@safe void f1o() {} @safe void f1o() {}
@safe void f2o() {} @safe void f2o() {}
auto b1 = comparingBenchmark!(f1o, f2o, 1); // OK auto b1 = comparingBenchmark!(f1o, f2o, 1)(); // OK
//static auto b2 = comparingBenchmark!(f1x, f2x, 1); // NG //static auto b2 = comparingBenchmark!(f1x, f2x, 1); // NG
} }
@ -31084,8 +31084,8 @@ version(testStdDateTime) unittest
void f2x() {} void f2x() {}
@safe void f1o() {} @safe void f1o() {}
@safe void f2o() {} @safe void f2o() {}
auto b1 = comparingBenchmark!(f1o, f2o, 1); // OK auto b1 = comparingBenchmark!(f1o, f2o, 1)(); // OK
auto b2 = comparingBenchmark!(f1x, f2x, 1); // OK auto b2 = comparingBenchmark!(f1x, f2x, 1)(); // OK
} }
@ -32185,7 +32185,7 @@ version(testStdDateTime) @safe unittest
{ {
@safe static void func(TickDuration td) @safe static void func(TickDuration td)
{ {
assert(td.to!("seconds", real) <>= 0); assert(td.to!("seconds", real)() <>= 0);
} }
auto mt = measureTime!(func)(); auto mt = measureTime!(func)();
@ -32203,7 +32203,7 @@ version(testStdDateTime) unittest
{ {
static void func(TickDuration td) static void func(TickDuration td)
{ {
assert(td.to!("seconds", real) <>= 0); assert(td.to!("seconds", real)() <>= 0);
} }
auto mt = measureTime!(func)(); auto mt = measureTime!(func)();

View file

@ -369,14 +369,14 @@ template EncoderFunctions()
template ReadFromString() template ReadFromString()
{ {
bool canRead() { return s.length != 0; } @property bool canRead() { return s.length != 0; }
E peek() { return s[0]; } E peek() { return s[0]; }
E read() { E t = s[0]; s = s[1..$]; return t; } E read() { E t = s[0]; s = s[1..$]; return t; }
} }
template ReverseReadFromString() template ReverseReadFromString()
{ {
bool canRead() { return s.length != 0; } @property bool canRead() { return s.length != 0; }
E peek() { return s[$-1]; } E peek() { return s[$-1]; }
E read() { E t = s[$-1]; s = s[0..$-1]; return t; } E read() { E t = s[$-1]; s = s[0..$-1]; return t; }
} }
@ -665,7 +665,7 @@ template EncoderInstance(CharType : AsciiChar)
alias AsciiChar E; alias AsciiChar E;
alias AsciiString EString; alias AsciiString EString;
string encodingName() @property string encodingName()
{ {
return "ASCII"; return "ASCII";
} }
@ -709,21 +709,21 @@ template EncoderInstance(CharType : AsciiChar)
dchar decodeViaRead()() dchar decodeViaRead()()
{ {
return read; return read();
} }
dchar safeDecodeViaRead()() dchar safeDecodeViaRead()()
{ {
dchar c = read; dchar c = read();
return canEncode(c) ? c : INVALID_SEQUENCE; return canEncode(c) ? c : INVALID_SEQUENCE;
} }
dchar decodeReverseViaRead()() dchar decodeReverseViaRead()()
{ {
return read; return read();
} }
EString replacementSequence() @property EString replacementSequence()
{ {
return cast(EString)("?"); return cast(EString)("?");
} }
@ -748,7 +748,7 @@ template EncoderInstance(CharType : Latin1Char)
alias Latin1Char E; alias Latin1Char E;
alias Latin1String EString; alias Latin1String EString;
string encodingName() @property string encodingName()
{ {
return "ISO-8859-1"; return "ISO-8859-1";
} }
@ -786,20 +786,20 @@ template EncoderInstance(CharType : Latin1Char)
dchar decodeViaRead()() dchar decodeViaRead()()
{ {
return read; return read();
} }
dchar safeDecodeViaRead()() dchar safeDecodeViaRead()()
{ {
return read; return read();
} }
dchar decodeReverseViaRead()() dchar decodeReverseViaRead()()
{ {
return read; return read();
} }
EString replacementSequence() @property EString replacementSequence()
{ {
return cast(EString)("?"); return cast(EString)("?");
} }
@ -824,7 +824,7 @@ template EncoderInstance(CharType : Windows1252Char)
alias Windows1252Char E; alias Windows1252Char E;
alias Windows1252String EString; alias Windows1252String EString;
string encodingName() @property string encodingName()
{ {
return "windows-1252"; return "windows-1252";
} }
@ -887,24 +887,24 @@ template EncoderInstance(CharType : Windows1252Char)
dchar decodeViaRead()() dchar decodeViaRead()()
{ {
Windows1252Char c = read; Windows1252Char c = read();
return (c >= 0x80 && c < 0xA0) ? charMap[c-0x80] : c; return (c >= 0x80 && c < 0xA0) ? charMap[c-0x80] : c;
} }
dchar safeDecodeViaRead()() dchar safeDecodeViaRead()()
{ {
Windows1252Char c = read; Windows1252Char c = read();
dchar d = (c >= 0x80 && c < 0xA0) ? charMap[c-0x80] : c; dchar d = (c >= 0x80 && c < 0xA0) ? charMap[c-0x80] : c;
return d == 0xFFFD ? INVALID_SEQUENCE : d; return d == 0xFFFD ? INVALID_SEQUENCE : d;
} }
dchar decodeReverseViaRead()() dchar decodeReverseViaRead()()
{ {
Windows1252Char c = read; Windows1252Char c = read();
return (c >= 0x80 && c < 0xA0) ? charMap[c-0x80] : c; return (c >= 0x80 && c < 0xA0) ? charMap[c-0x80] : c;
} }
EString replacementSequence() @property EString replacementSequence()
{ {
return cast(EString)("?"); return cast(EString)("?");
} }
@ -921,7 +921,7 @@ template EncoderInstance(CharType : char)
alias char E; alias char E;
alias immutable(char)[] EString; alias immutable(char)[] EString;
string encodingName() @property string encodingName()
{ {
return "UTF-8"; return "UTF-8";
} }
@ -999,7 +999,7 @@ template EncoderInstance(CharType : char)
void skipViaRead()() void skipViaRead()()
{ {
auto c = read; auto c = read();
if (c < 0xC0) return; if (c < 0xC0) return;
int n = tails(cast(char) c); int n = tails(cast(char) c);
for (size_t i=0; i<n; ++i) for (size_t i=0; i<n; ++i)
@ -1010,26 +1010,26 @@ template EncoderInstance(CharType : char)
dchar decodeViaRead()() dchar decodeViaRead()()
{ {
dchar c = read; dchar c = read();
if (c < 0xC0) return c; if (c < 0xC0) return c;
int n = tails(cast(char) c); int n = tails(cast(char) c);
c &= (1 << (6 - n)) - 1; c &= (1 << (6 - n)) - 1;
for (size_t i=0; i<n; ++i) for (size_t i=0; i<n; ++i)
{ {
c = (c << 6) + (read & 0x3F); c = (c << 6) + (read() & 0x3F);
} }
return c; return c;
} }
dchar safeDecodeViaRead()() dchar safeDecodeViaRead()()
{ {
dchar c = read; dchar c = read();
if (c < 0x80) return c; if (c < 0x80) return c;
int n = tails(cast(char) c); int n = tails(cast(char) c);
if (n == 0) return INVALID_SEQUENCE; if (n == 0) return INVALID_SEQUENCE;
if (!canRead) return INVALID_SEQUENCE; if (!canRead) return INVALID_SEQUENCE;
size_t d = peek; size_t d = peek();
bool err = bool err =
( (
(c < 0xC2) // fail overlong 2-byte sequences (c < 0xC2) // fail overlong 2-byte sequences
@ -1044,9 +1044,9 @@ template EncoderInstance(CharType : char)
for (size_t i=0; i<n; ++i) for (size_t i=0; i<n; ++i)
{ {
if (!canRead) return INVALID_SEQUENCE; if (!canRead) return INVALID_SEQUENCE;
d = peek; d = peek();
if ((d & 0xC0) != 0x80) return INVALID_SEQUENCE; if ((d & 0xC0) != 0x80) return INVALID_SEQUENCE;
c = (c << 6) + (read & 0x3F); c = (c << 6) + (read() & 0x3F);
} }
return err ? INVALID_SEQUENCE : c; return err ? INVALID_SEQUENCE : c;
@ -1054,14 +1054,14 @@ template EncoderInstance(CharType : char)
dchar decodeReverseViaRead()() dchar decodeReverseViaRead()()
{ {
dchar c = read; dchar c = read();
if (c < 0x80) return c; if (c < 0x80) return c;
size_t shift = 0; size_t shift = 0;
c &= 0x3F; c &= 0x3F;
for (size_t i=0; i<4; ++i) for (size_t i=0; i<4; ++i)
{ {
shift += 6; shift += 6;
auto d = read; auto d = read();
size_t n = tails(cast(char) d); size_t n = tails(cast(char) d);
size_t mask = n == 0 ? 0x3F : (1 << (6 - n)) - 1; size_t mask = n == 0 ? 0x3F : (1 << (6 - n)) - 1;
c += ((d & mask) << shift); c += ((d & mask) << shift);
@ -1070,7 +1070,7 @@ template EncoderInstance(CharType : char)
return c; return c;
} }
EString replacementSequence() @property EString replacementSequence()
{ {
return "\uFFFD"; return "\uFFFD";
} }
@ -1087,7 +1087,7 @@ template EncoderInstance(CharType : wchar)
alias wchar E; alias wchar E;
alias immutable(wchar)[] EString; alias immutable(wchar)[] EString;
string encodingName() @property string encodingName()
{ {
return "UTF-16"; return "UTF-16";
} }
@ -1128,16 +1128,16 @@ template EncoderInstance(CharType : wchar)
void skipViaRead()() void skipViaRead()()
{ {
wchar c = read; wchar c = read();
if (c < 0xD800 || c >= 0xE000) return; if (c < 0xD800 || c >= 0xE000) return;
read(); read();
} }
dchar decodeViaRead()() dchar decodeViaRead()()
{ {
wchar c = read; wchar c = read();
if (c < 0xD800 || c >= 0xE000) return cast(dchar)c; if (c < 0xD800 || c >= 0xE000) return cast(dchar)c;
wchar d = read; wchar d = read();
c &= 0x3FF; c &= 0x3FF;
d &= 0x3FF; d &= 0x3FF;
return 0x10000 + (c << 10) + d; return 0x10000 + (c << 10) + d;
@ -1145,13 +1145,13 @@ template EncoderInstance(CharType : wchar)
dchar safeDecodeViaRead()() dchar safeDecodeViaRead()()
{ {
wchar c = read; wchar c = read();
if (c < 0xD800 || c >= 0xE000) return cast(dchar)c; if (c < 0xD800 || c >= 0xE000) return cast(dchar)c;
if (c >= 0xDC00) return INVALID_SEQUENCE; if (c >= 0xDC00) return INVALID_SEQUENCE;
if (!canRead) return INVALID_SEQUENCE; if (!canRead) return INVALID_SEQUENCE;
wchar d = peek; wchar d = peek();
if (d < 0xDC00 || d >= 0xE000) return INVALID_SEQUENCE; if (d < 0xDC00 || d >= 0xE000) return INVALID_SEQUENCE;
d = read; d = read();
c &= 0x3FF; c &= 0x3FF;
d &= 0x3FF; d &= 0x3FF;
return 0x10000 + (c << 10) + d; return 0x10000 + (c << 10) + d;
@ -1159,15 +1159,15 @@ template EncoderInstance(CharType : wchar)
dchar decodeReverseViaRead()() dchar decodeReverseViaRead()()
{ {
wchar c = read; wchar c = read();
if (c < 0xD800 || c >= 0xE000) return cast(dchar)c; if (c < 0xD800 || c >= 0xE000) return cast(dchar)c;
wchar d = read; wchar d = read();
c &= 0x3FF; c &= 0x3FF;
d &= 0x3FF; d &= 0x3FF;
return 0x10000 + (d << 10) + c; return 0x10000 + (d << 10) + c;
} }
EString replacementSequence() @property EString replacementSequence()
{ {
return "\uFFFD"w; return "\uFFFD"w;
} }
@ -1184,7 +1184,7 @@ template EncoderInstance(CharType : dchar)
alias dchar E; alias dchar E;
alias immutable(dchar)[] EString; alias immutable(dchar)[] EString;
string encodingName() @property string encodingName()
{ {
return "UTF-32"; return "UTF-32";
} }
@ -1221,21 +1221,21 @@ template EncoderInstance(CharType : dchar)
dchar decodeViaRead()() dchar decodeViaRead()()
{ {
return cast(dchar)read; return cast(dchar)read();
} }
dchar safeDecodeViaRead()() dchar safeDecodeViaRead()()
{ {
dchar c = read; dchar c = read();
return isValidCodePoint(c) ? c : INVALID_SEQUENCE; return isValidCodePoint(c) ? c : INVALID_SEQUENCE;
} }
dchar decodeReverseViaRead()() dchar decodeReverseViaRead()()
{ {
return cast(dchar)read; return cast(dchar)read();
} }
EString replacementSequence() @property EString replacementSequence()
{ {
return "\uFFFD"d; return "\uFFFD"d;
} }
@ -1279,7 +1279,7 @@ bool isValidCodePoint(dchar c)
assert(encodingName!(Latin1Char) == "ISO-8859-1"); assert(encodingName!(Latin1Char) == "ISO-8859-1");
----------------------------------- -----------------------------------
*/ */
string encodingName(T)() @property string encodingName(T)()
{ {
return EncoderInstance!(T).encodingName; return EncoderInstance!(T).encodingName;
} }
@ -2198,7 +2198,7 @@ abstract class EncodingScheme
* Normally this will be a representation of some substitution * Normally this will be a representation of some substitution
* character, such as U+FFFD or '?'. * character, such as U+FFFD or '?'.
*/ */
abstract immutable(ubyte)[] replacementSequence(); abstract @property immutable(ubyte)[] replacementSequence();
} }
/** /**
@ -2442,7 +2442,7 @@ class EncodingSchemeASCII : EncodingScheme
return c; return c;
} }
override immutable(ubyte)[] replacementSequence() override @property immutable(ubyte)[] replacementSequence()
{ {
return cast(immutable(ubyte)[])"?"; return cast(immutable(ubyte)[])"?";
} }
@ -2526,7 +2526,7 @@ class EncodingSchemeLatin1 : EncodingScheme
return c; return c;
} }
override immutable(ubyte)[] replacementSequence() override @property immutable(ubyte)[] replacementSequence()
{ {
return cast(immutable(ubyte)[])"?"; return cast(immutable(ubyte)[])"?";
} }
@ -2594,7 +2594,7 @@ class EncodingSchemeWindows1252 : EncodingScheme
return c; return c;
} }
override immutable(ubyte)[] replacementSequence() override @property immutable(ubyte)[] replacementSequence()
{ {
return cast(immutable(ubyte)[])"?"; return cast(immutable(ubyte)[])"?";
} }
@ -2662,7 +2662,7 @@ class EncodingSchemeUtf8 : EncodingScheme
return c; return c;
} }
override immutable(ubyte)[] replacementSequence() override @property immutable(ubyte)[] replacementSequence()
{ {
return cast(immutable(ubyte)[])"\uFFFD"; return cast(immutable(ubyte)[])"\uFFFD";
} }
@ -2740,7 +2740,7 @@ class EncodingSchemeUtf16Native : EncodingScheme
return c; return c;
} }
override immutable(ubyte)[] replacementSequence() override @property immutable(ubyte)[] replacementSequence()
{ {
return cast(immutable(ubyte)[])"\uFFFD"w; return cast(immutable(ubyte)[])"\uFFFD"w;
} }
@ -2818,7 +2818,7 @@ class EncodingSchemeUtf32Native : EncodingScheme
return c; return c;
} }
override immutable(ubyte)[] replacementSequence() override @property immutable(ubyte)[] replacementSequence()
{ {
return cast(immutable(ubyte)[])"\uFFFD"d; return cast(immutable(ubyte)[])"\uFFFD"d;
} }

View file

@ -863,7 +863,7 @@ class ErrnoException : Exception
uint errno; // operating system error code uint errno; // operating system error code
this(string msg, string file = null, size_t line = 0) this(string msg, string file = null, size_t line = 0)
{ {
errno = getErrno; errno = getErrno();
version (linux) version (linux)
{ {
char[1024] buf = void; char[1024] buf = void;

View file

@ -52,7 +52,7 @@ version (unittest)
{ {
import core.thread; import core.thread;
private string deleteme() private @property string deleteme()
{ {
static _deleteme = "deleteme.dmd.unittest"; static _deleteme = "deleteme.dmd.unittest";
static _first = true; static _first = true;
@ -229,7 +229,7 @@ class FileException : Exception
line = The line where the error occurred. line = The line where the error occurred.
+/ +/
version(Windows) this(in char[] name, version(Windows) this(in char[] name,
uint errno = GetLastError, uint errno = .GetLastError(),
string file = __FILE__, string file = __FILE__,
size_t line = __LINE__) size_t line = __LINE__)
{ {
@ -248,7 +248,7 @@ class FileException : Exception
line = The line where the error occurred. line = The line where the error occurred.
+/ +/
version(Posix) this(in char[] name, version(Posix) this(in char[] name,
uint errno = .getErrno, uint errno = .getErrno(),
string file = __FILE__, string file = __FILE__,
size_t line = __LINE__) size_t line = __LINE__)
{ {
@ -3572,7 +3572,7 @@ slurp(Types...)(string filename, in char[] format)
auto app = appender!(typeof(return))(); auto app = appender!(typeof(return))();
ElementType!(typeof(return)) toAdd; ElementType!(typeof(return)) toAdd;
auto f = File(filename); auto f = File(filename);
scope(exit) f.close; scope(exit) f.close();
foreach (line; f.byLine()) foreach (line; f.byLine())
{ {
formattedRead(line, format, &toAdd); formattedRead(line, format, &toAdd);

View file

@ -641,18 +641,18 @@ struct FormatSpec(Char)
assert(f.trailing == "ghi"); assert(f.trailing == "ghi");
// test with embedded %%s // test with embedded %%s
f = FormatSpec("ab%%cd%%ef%sg%%h%sij"); f = FormatSpec("ab%%cd%%ef%sg%%h%sij");
w.clear; w.clear();
f.writeUpToNextSpec(w); f.writeUpToNextSpec(w);
assert(w.data == "ab%cd%ef" && f.trailing == "g%%h%sij", w.data); assert(w.data == "ab%cd%ef" && f.trailing == "g%%h%sij", w.data);
f.writeUpToNextSpec(w); f.writeUpToNextSpec(w);
assert(w.data == "ab%cd%efg%h" && f.trailing == "ij"); assert(w.data == "ab%cd%efg%h" && f.trailing == "ij");
// bug4775 // bug4775
f = FormatSpec("%%%s"); f = FormatSpec("%%%s");
w.clear; w.clear();
f.writeUpToNextSpec(w); f.writeUpToNextSpec(w);
assert(w.data == "%" && f.trailing == ""); assert(w.data == "%" && f.trailing == "");
f = FormatSpec("%%%%%s%%"); f = FormatSpec("%%%%%s%%");
w.clear; w.clear();
while (f.writeUpToNextSpec(w)) continue; while (f.writeUpToNextSpec(w)) continue;
assert(w.data == "%%%"); assert(w.data == "%%%");
} }
@ -856,7 +856,7 @@ struct FormatSpec(Char)
text("parseToFormatSpec: Cannot find character `", text("parseToFormatSpec: Cannot find character `",
trailing.ptr[0], "' in the input string.")); trailing.ptr[0], "' in the input string."));
if (r.front != trailing.front) break; if (r.front != trailing.front) break;
r.popFront; r.popFront();
} }
trailing.popFront(); trailing.popFront();
} }
@ -1325,7 +1325,7 @@ if (isSomeString!T && !isStaticArray!T && !is(T == enum))
unittest unittest
{ {
FormatSpec!char f; FormatSpec!char f;
auto w = appender!(string); auto w = appender!(string)();
string s = "abc"; string s = "abc";
formatValue(w, s, f); formatValue(w, s, f);
assert(w.data == "abc"); assert(w.data == "abc");
@ -1779,7 +1779,7 @@ if (!isSomeString!T && is(T == class) && !isInputRange!T)
// TODO: Change this once toString() works for shared objects. // TODO: Change this once toString() works for shared objects.
static assert(!is(T == shared), "unable to format shared objects"); static assert(!is(T == shared), "unable to format shared objects");
if (val is null) put(w, "null"); if (val is null) put(w, "null");
else put(w, val.toString); else put(w, val.toString());
} }
/// ditto /// ditto
@ -2062,12 +2062,12 @@ unittest
int[] a = [ 1, 3, 2 ]; int[] a = [ 1, 3, 2 ];
formattedWrite(w, "testing %(%s & %) embedded", a); formattedWrite(w, "testing %(%s & %) embedded", a);
assert(w.data == "testing 1 & 3 & 2 embedded", w.data); assert(w.data == "testing 1 & 3 & 2 embedded", w.data);
w.clear; w.clear();
formattedWrite(w, "testing %((%s) %)) wyda3", a); formattedWrite(w, "testing %((%s) %)) wyda3", a);
assert(w.data == "testing (1) (3) (2) wyda3", w.data); assert(w.data == "testing (1) (3) (2) wyda3", w.data);
int[0] empt = []; int[0] empt = [];
w.clear; w.clear();
formattedWrite(w, "(%s)", empt); formattedWrite(w, "(%s)", empt);
assert(w.data == "([])", w.data); assert(w.data == "([])", w.data);
} }
@ -2131,7 +2131,7 @@ unittest
formattedWrite(w, "%+r", a); formattedWrite(w, "%+r", a);
assert(w.data.length == 4 && w.data[0] == 2 && w.data[1] == 3 assert(w.data.length == 4 && w.data[0] == 2 && w.data[1] == 3
&& w.data[2] == 4 && w.data[3] == 5); && w.data[2] == 4 && w.data[3] == 5);
w.clear; w.clear();
formattedWrite(w, "%-r", a); formattedWrite(w, "%-r", a);
assert(w.data.length == 4 && w.data[0] == 5 && w.data[1] == 4 assert(w.data.length == 4 && w.data[0] == 5 && w.data[1] == 4
&& w.data[2] == 3 && w.data[3] == 2); && w.data[2] == 3 && w.data[3] == 2);
@ -2146,10 +2146,10 @@ unittest
42, 0); 42, 0);
assert(w.data == "Numbers 0 and 42 are reversed and 420 repeated", assert(w.data == "Numbers 0 and 42 are reversed and 420 repeated",
w.data); w.data);
w.clear; w.clear();
formattedWrite(w, "asd%s", 23); formattedWrite(w, "asd%s", 23);
assert(w.data == "asd23", w.data); assert(w.data == "asd23", w.data);
w.clear; w.clear();
formattedWrite(w, "%s%s", 23, 45); formattedWrite(w, "%s%s", 23, 45);
assert(w.data == "2345", w.data); assert(w.data == "2345", w.data);
} }
@ -2166,7 +2166,7 @@ unittest
assert(stream.data == "hello world! true 57 ", assert(stream.data == "hello world! true 57 ",
stream.data); stream.data);
stream.clear; stream.clear();
formattedWrite(stream, "%g %A %s", 1.67, -1.28, float.nan); formattedWrite(stream, "%g %A %s", 1.67, -1.28, float.nan);
// std.c.stdio.fwrite(stream.data.ptr, stream.data.length, 1, stderr); // std.c.stdio.fwrite(stream.data.ptr, stream.data.length, 1, stderr);
@ -2189,54 +2189,54 @@ unittest
assert(stream.data == "1.67 -0X1.47AE147AE147BP+0 nan", assert(stream.data == "1.67 -0X1.47AE147AE147BP+0 nan",
stream.data); stream.data);
} }
stream.clear; stream.clear();
formattedWrite(stream, "%x %X", 0x1234AF, 0xAFAFAFAF); formattedWrite(stream, "%x %X", 0x1234AF, 0xAFAFAFAF);
assert(stream.data == "1234af AFAFAFAF"); assert(stream.data == "1234af AFAFAFAF");
stream.clear; stream.clear();
formattedWrite(stream, "%b %o", 0x1234AF, 0xAFAFAFAF); formattedWrite(stream, "%b %o", 0x1234AF, 0xAFAFAFAF);
assert(stream.data == "100100011010010101111 25753727657"); assert(stream.data == "100100011010010101111 25753727657");
stream.clear; stream.clear();
formattedWrite(stream, "%d %s", 0x1234AF, 0xAFAFAFAF); formattedWrite(stream, "%d %s", 0x1234AF, 0xAFAFAFAF);
assert(stream.data == "1193135 2947526575"); assert(stream.data == "1193135 2947526575");
stream.clear; stream.clear();
// formattedWrite(stream, "%s", 1.2 + 3.4i); // formattedWrite(stream, "%s", 1.2 + 3.4i);
// assert(stream.data == "1.2+3.4i"); // assert(stream.data == "1.2+3.4i");
// stream.clear; // stream.clear();
formattedWrite(stream, "%a %A", 1.32, 6.78f); formattedWrite(stream, "%a %A", 1.32, 6.78f);
//formattedWrite(stream, "%x %X", 1.32); //formattedWrite(stream, "%x %X", 1.32);
assert(stream.data == "0x1.51eb851eb851fp+0 0X1.B1EB86P+2"); assert(stream.data == "0x1.51eb851eb851fp+0 0X1.B1EB86P+2");
stream.clear; stream.clear();
formattedWrite(stream, "%#06.*f",2,12.345); formattedWrite(stream, "%#06.*f",2,12.345);
assert(stream.data == "012.35"); assert(stream.data == "012.35");
stream.clear; stream.clear();
formattedWrite(stream, "%#0*.*f",6,2,12.345); formattedWrite(stream, "%#0*.*f",6,2,12.345);
assert(stream.data == "012.35"); assert(stream.data == "012.35");
stream.clear; stream.clear();
const real constreal = 1; const real constreal = 1;
formattedWrite(stream, "%g",constreal); formattedWrite(stream, "%g",constreal);
assert(stream.data == "1"); assert(stream.data == "1");
stream.clear; stream.clear();
formattedWrite(stream, "%7.4g:", 12.678); formattedWrite(stream, "%7.4g:", 12.678);
assert(stream.data == " 12.68:"); assert(stream.data == " 12.68:");
stream.clear; stream.clear();
formattedWrite(stream, "%7.4g:", 12.678L); formattedWrite(stream, "%7.4g:", 12.678L);
assert(stream.data == " 12.68:"); assert(stream.data == " 12.68:");
stream.clear; stream.clear();
formattedWrite(stream, "%04f|%05d|%#05x|%#5x",-4.,-10,1,1); formattedWrite(stream, "%04f|%05d|%#05x|%#5x",-4.,-10,1,1);
assert(stream.data == "-4.000000|-0010|0x001| 0x1", assert(stream.data == "-4.000000|-0010|0x001| 0x1",
stream.data); stream.data);
stream.clear; stream.clear();
int i; int i;
string s; string s;
@ -2244,46 +2244,46 @@ unittest
i = -10; i = -10;
formattedWrite(stream, "%d|%3d|%03d|%1d|%01.4f",i,i,i,i,cast(double) i); formattedWrite(stream, "%d|%3d|%03d|%1d|%01.4f",i,i,i,i,cast(double) i);
assert(stream.data == "-10|-10|-10|-10|-10.0000"); assert(stream.data == "-10|-10|-10|-10|-10.0000");
stream.clear; stream.clear();
i = -5; i = -5;
formattedWrite(stream, "%d|%3d|%03d|%1d|%01.4f",i,i,i,i,cast(double) i); formattedWrite(stream, "%d|%3d|%03d|%1d|%01.4f",i,i,i,i,cast(double) i);
assert(stream.data == "-5| -5|-05|-5|-5.0000"); assert(stream.data == "-5| -5|-05|-5|-5.0000");
stream.clear; stream.clear();
i = 0; i = 0;
formattedWrite(stream, "%d|%3d|%03d|%1d|%01.4f",i,i,i,i,cast(double) i); formattedWrite(stream, "%d|%3d|%03d|%1d|%01.4f",i,i,i,i,cast(double) i);
assert(stream.data == "0| 0|000|0|0.0000"); assert(stream.data == "0| 0|000|0|0.0000");
stream.clear; stream.clear();
i = 5; i = 5;
formattedWrite(stream, "%d|%3d|%03d|%1d|%01.4f",i,i,i,i,cast(double) i); formattedWrite(stream, "%d|%3d|%03d|%1d|%01.4f",i,i,i,i,cast(double) i);
assert(stream.data == "5| 5|005|5|5.0000"); assert(stream.data == "5| 5|005|5|5.0000");
stream.clear; stream.clear();
i = 10; i = 10;
formattedWrite(stream, "%d|%3d|%03d|%1d|%01.4f",i,i,i,i,cast(double) i); formattedWrite(stream, "%d|%3d|%03d|%1d|%01.4f",i,i,i,i,cast(double) i);
assert(stream.data == "10| 10|010|10|10.0000"); assert(stream.data == "10| 10|010|10|10.0000");
stream.clear; stream.clear();
formattedWrite(stream, "%.0d", 0); formattedWrite(stream, "%.0d", 0);
assert(stream.data == ""); assert(stream.data == "");
stream.clear; stream.clear();
formattedWrite(stream, "%.g", .34); formattedWrite(stream, "%.g", .34);
assert(stream.data == "0.3"); assert(stream.data == "0.3");
stream.clear; stream.clear();
stream.clear; formattedWrite(stream, "%.0g", .34); stream.clear(); formattedWrite(stream, "%.0g", .34);
assert(stream.data == "0.3"); assert(stream.data == "0.3");
stream.clear; formattedWrite(stream, "%.2g", .34); stream.clear(); formattedWrite(stream, "%.2g", .34);
assert(stream.data == "0.34"); assert(stream.data == "0.34");
stream.clear; formattedWrite(stream, "%0.0008f", 1e-08); stream.clear(); formattedWrite(stream, "%0.0008f", 1e-08);
assert(stream.data == "0.00000001"); assert(stream.data == "0.00000001");
stream.clear; formattedWrite(stream, "%0.0008f", 1e-05); stream.clear(); formattedWrite(stream, "%0.0008f", 1e-05);
assert(stream.data == "0.00001000"); assert(stream.data == "0.00001000");
//return; //return;
@ -2291,209 +2291,209 @@ unittest
s = "helloworld"; s = "helloworld";
string r; string r;
stream.clear; formattedWrite(stream, "%.2s", s[0..5]); stream.clear(); formattedWrite(stream, "%.2s", s[0..5]);
assert(stream.data == "he"); assert(stream.data == "he");
stream.clear; formattedWrite(stream, "%.20s", s[0..5]); stream.clear(); formattedWrite(stream, "%.20s", s[0..5]);
assert(stream.data == "hello"); assert(stream.data == "hello");
stream.clear; formattedWrite(stream, "%8s", s[0..5]); stream.clear(); formattedWrite(stream, "%8s", s[0..5]);
assert(stream.data == " hello"); assert(stream.data == " hello");
byte[] arrbyte = new byte[4]; byte[] arrbyte = new byte[4];
arrbyte[0] = 100; arrbyte[0] = 100;
arrbyte[1] = -99; arrbyte[1] = -99;
arrbyte[3] = 0; arrbyte[3] = 0;
stream.clear; formattedWrite(stream, "%s", arrbyte); stream.clear(); formattedWrite(stream, "%s", arrbyte);
assert(stream.data == "[100, -99, 0, 0]", stream.data); assert(stream.data == "[100, -99, 0, 0]", stream.data);
ubyte[] arrubyte = new ubyte[4]; ubyte[] arrubyte = new ubyte[4];
arrubyte[0] = 100; arrubyte[0] = 100;
arrubyte[1] = 200; arrubyte[1] = 200;
arrubyte[3] = 0; arrubyte[3] = 0;
stream.clear; formattedWrite(stream, "%s", arrubyte); stream.clear(); formattedWrite(stream, "%s", arrubyte);
assert(stream.data == "[100, 200, 0, 0]", stream.data); assert(stream.data == "[100, 200, 0, 0]", stream.data);
short[] arrshort = new short[4]; short[] arrshort = new short[4];
arrshort[0] = 100; arrshort[0] = 100;
arrshort[1] = -999; arrshort[1] = -999;
arrshort[3] = 0; arrshort[3] = 0;
stream.clear; formattedWrite(stream, "%s", arrshort); stream.clear(); formattedWrite(stream, "%s", arrshort);
assert(stream.data == "[100, -999, 0, 0]"); assert(stream.data == "[100, -999, 0, 0]");
stream.clear; formattedWrite(stream, "%s",arrshort); stream.clear(); formattedWrite(stream, "%s",arrshort);
assert(stream.data == "[100, -999, 0, 0]"); assert(stream.data == "[100, -999, 0, 0]");
ushort[] arrushort = new ushort[4]; ushort[] arrushort = new ushort[4];
arrushort[0] = 100; arrushort[0] = 100;
arrushort[1] = 20_000; arrushort[1] = 20_000;
arrushort[3] = 0; arrushort[3] = 0;
stream.clear; formattedWrite(stream, "%s", arrushort); stream.clear(); formattedWrite(stream, "%s", arrushort);
assert(stream.data == "[100, 20000, 0, 0]"); assert(stream.data == "[100, 20000, 0, 0]");
int[] arrint = new int[4]; int[] arrint = new int[4];
arrint[0] = 100; arrint[0] = 100;
arrint[1] = -999; arrint[1] = -999;
arrint[3] = 0; arrint[3] = 0;
stream.clear; formattedWrite(stream, "%s", arrint); stream.clear(); formattedWrite(stream, "%s", arrint);
assert(stream.data == "[100, -999, 0, 0]"); assert(stream.data == "[100, -999, 0, 0]");
stream.clear; formattedWrite(stream, "%s",arrint); stream.clear(); formattedWrite(stream, "%s",arrint);
assert(stream.data == "[100, -999, 0, 0]"); assert(stream.data == "[100, -999, 0, 0]");
long[] arrlong = new long[4]; long[] arrlong = new long[4];
arrlong[0] = 100; arrlong[0] = 100;
arrlong[1] = -999; arrlong[1] = -999;
arrlong[3] = 0; arrlong[3] = 0;
stream.clear; formattedWrite(stream, "%s", arrlong); stream.clear(); formattedWrite(stream, "%s", arrlong);
assert(stream.data == "[100, -999, 0, 0]"); assert(stream.data == "[100, -999, 0, 0]");
stream.clear; formattedWrite(stream, "%s",arrlong); stream.clear(); formattedWrite(stream, "%s",arrlong);
assert(stream.data == "[100, -999, 0, 0]"); assert(stream.data == "[100, -999, 0, 0]");
ulong[] arrulong = new ulong[4]; ulong[] arrulong = new ulong[4];
arrulong[0] = 100; arrulong[0] = 100;
arrulong[1] = 999; arrulong[1] = 999;
arrulong[3] = 0; arrulong[3] = 0;
stream.clear; formattedWrite(stream, "%s", arrulong); stream.clear(); formattedWrite(stream, "%s", arrulong);
assert(stream.data == "[100, 999, 0, 0]"); assert(stream.data == "[100, 999, 0, 0]");
string[] arr2 = new string[4]; string[] arr2 = new string[4];
arr2[0] = "hello"; arr2[0] = "hello";
arr2[1] = "world"; arr2[1] = "world";
arr2[3] = "foo"; arr2[3] = "foo";
stream.clear; formattedWrite(stream, "%s", arr2); stream.clear(); formattedWrite(stream, "%s", arr2);
assert(stream.data == `["hello", "world", "", "foo"]`, stream.data); assert(stream.data == `["hello", "world", "", "foo"]`, stream.data);
stream.clear; formattedWrite(stream, "%.8d", 7); stream.clear(); formattedWrite(stream, "%.8d", 7);
assert(stream.data == "00000007"); assert(stream.data == "00000007");
stream.clear; formattedWrite(stream, "%.8x", 10); stream.clear(); formattedWrite(stream, "%.8x", 10);
assert(stream.data == "0000000a"); assert(stream.data == "0000000a");
stream.clear; formattedWrite(stream, "%-3d", 7); stream.clear(); formattedWrite(stream, "%-3d", 7);
assert(stream.data == "7 "); assert(stream.data == "7 ");
stream.clear; formattedWrite(stream, "%*d", -3, 7); stream.clear(); formattedWrite(stream, "%*d", -3, 7);
assert(stream.data == "7 "); assert(stream.data == "7 ");
stream.clear; formattedWrite(stream, "%.*d", -3, 7); stream.clear(); formattedWrite(stream, "%.*d", -3, 7);
//writeln(stream.data); //writeln(stream.data);
assert(stream.data == "7"); assert(stream.data == "7");
// assert(false); // assert(false);
// typedef int myint; // typedef int myint;
// myint m = -7; // myint m = -7;
// stream.clear; formattedWrite(stream, "", m); // stream.clear(); formattedWrite(stream, "", m);
// assert(stream.data == "-7"); // assert(stream.data == "-7");
stream.clear; formattedWrite(stream, "%s", "abc"c); stream.clear(); formattedWrite(stream, "%s", "abc"c);
assert(stream.data == "abc"); assert(stream.data == "abc");
stream.clear; formattedWrite(stream, "%s", "def"w); stream.clear(); formattedWrite(stream, "%s", "def"w);
assert(stream.data == "def", text(stream.data.length)); assert(stream.data == "def", text(stream.data.length));
stream.clear; formattedWrite(stream, "%s", "ghi"d); stream.clear(); formattedWrite(stream, "%s", "ghi"d);
assert(stream.data == "ghi"); assert(stream.data == "ghi");
here: here:
void* p = cast(void*)0xDEADBEEF; void* p = cast(void*)0xDEADBEEF;
stream.clear; formattedWrite(stream, "%s", p); stream.clear(); formattedWrite(stream, "%s", p);
assert(stream.data == "DEADBEEF", stream.data); assert(stream.data == "DEADBEEF", stream.data);
stream.clear; formattedWrite(stream, "%#x", 0xabcd); stream.clear(); formattedWrite(stream, "%#x", 0xabcd);
assert(stream.data == "0xabcd"); assert(stream.data == "0xabcd");
stream.clear; formattedWrite(stream, "%#X", 0xABCD); stream.clear(); formattedWrite(stream, "%#X", 0xABCD);
assert(stream.data == "0XABCD"); assert(stream.data == "0XABCD");
stream.clear; formattedWrite(stream, "%#o", octal!12345); stream.clear(); formattedWrite(stream, "%#o", octal!12345);
assert(stream.data == "012345"); assert(stream.data == "012345");
stream.clear; formattedWrite(stream, "%o", 9); stream.clear(); formattedWrite(stream, "%o", 9);
assert(stream.data == "11"); assert(stream.data == "11");
stream.clear; formattedWrite(stream, "%+d", 123); stream.clear(); formattedWrite(stream, "%+d", 123);
assert(stream.data == "+123"); assert(stream.data == "+123");
stream.clear; formattedWrite(stream, "%+d", -123); stream.clear(); formattedWrite(stream, "%+d", -123);
assert(stream.data == "-123"); assert(stream.data == "-123");
stream.clear; formattedWrite(stream, "% d", 123); stream.clear(); formattedWrite(stream, "% d", 123);
assert(stream.data == " 123"); assert(stream.data == " 123");
stream.clear; formattedWrite(stream, "% d", -123); stream.clear(); formattedWrite(stream, "% d", -123);
assert(stream.data == "-123"); assert(stream.data == "-123");
stream.clear; formattedWrite(stream, "%%"); stream.clear(); formattedWrite(stream, "%%");
assert(stream.data == "%"); assert(stream.data == "%");
stream.clear; formattedWrite(stream, "%d", true); stream.clear(); formattedWrite(stream, "%d", true);
assert(stream.data == "1"); assert(stream.data == "1");
stream.clear; formattedWrite(stream, "%d", false); stream.clear(); formattedWrite(stream, "%d", false);
assert(stream.data == "0"); assert(stream.data == "0");
stream.clear; formattedWrite(stream, "%d", 'a'); stream.clear(); formattedWrite(stream, "%d", 'a');
assert(stream.data == "97", stream.data); assert(stream.data == "97", stream.data);
wchar wc = 'a'; wchar wc = 'a';
stream.clear; formattedWrite(stream, "%d", wc); stream.clear(); formattedWrite(stream, "%d", wc);
assert(stream.data == "97"); assert(stream.data == "97");
dchar dc = 'a'; dchar dc = 'a';
stream.clear; formattedWrite(stream, "%d", dc); stream.clear(); formattedWrite(stream, "%d", dc);
assert(stream.data == "97"); assert(stream.data == "97");
byte b = byte.max; byte b = byte.max;
stream.clear; formattedWrite(stream, "%x", b); stream.clear(); formattedWrite(stream, "%x", b);
assert(stream.data == "7f"); assert(stream.data == "7f");
stream.clear; formattedWrite(stream, "%x", ++b); stream.clear(); formattedWrite(stream, "%x", ++b);
assert(stream.data == "80"); assert(stream.data == "80");
stream.clear; formattedWrite(stream, "%x", ++b); stream.clear(); formattedWrite(stream, "%x", ++b);
assert(stream.data == "81"); assert(stream.data == "81");
short sh = short.max; short sh = short.max;
stream.clear; formattedWrite(stream, "%x", sh); stream.clear(); formattedWrite(stream, "%x", sh);
assert(stream.data == "7fff"); assert(stream.data == "7fff");
stream.clear; formattedWrite(stream, "%x", ++sh); stream.clear(); formattedWrite(stream, "%x", ++sh);
assert(stream.data == "8000"); assert(stream.data == "8000");
stream.clear; formattedWrite(stream, "%x", ++sh); stream.clear(); formattedWrite(stream, "%x", ++sh);
assert(stream.data == "8001"); assert(stream.data == "8001");
i = int.max; i = int.max;
stream.clear; formattedWrite(stream, "%x", i); stream.clear(); formattedWrite(stream, "%x", i);
assert(stream.data == "7fffffff"); assert(stream.data == "7fffffff");
stream.clear; formattedWrite(stream, "%x", ++i); stream.clear(); formattedWrite(stream, "%x", ++i);
assert(stream.data == "80000000"); assert(stream.data == "80000000");
stream.clear; formattedWrite(stream, "%x", ++i); stream.clear(); formattedWrite(stream, "%x", ++i);
assert(stream.data == "80000001"); assert(stream.data == "80000001");
stream.clear; formattedWrite(stream, "%x", 10); stream.clear(); formattedWrite(stream, "%x", 10);
assert(stream.data == "a"); assert(stream.data == "a");
stream.clear; formattedWrite(stream, "%X", 10); stream.clear(); formattedWrite(stream, "%X", 10);
assert(stream.data == "A"); assert(stream.data == "A");
stream.clear; formattedWrite(stream, "%x", 15); stream.clear(); formattedWrite(stream, "%x", 15);
assert(stream.data == "f"); assert(stream.data == "f");
stream.clear; formattedWrite(stream, "%X", 15); stream.clear(); formattedWrite(stream, "%X", 15);
assert(stream.data == "F"); assert(stream.data == "F");
Object c = null; Object c = null;
stream.clear; formattedWrite(stream, "%s", c); stream.clear(); formattedWrite(stream, "%s", c);
assert(stream.data == "null"); assert(stream.data == "null");
enum TestEnum enum TestEnum
{ {
Value1, Value2 Value1, Value2
} }
stream.clear; formattedWrite(stream, "%s", TestEnum.Value2); stream.clear(); formattedWrite(stream, "%s", TestEnum.Value2);
assert(stream.data == "Value2", stream.data); assert(stream.data == "Value2", stream.data);
stream.clear; formattedWrite(stream, "%s", cast(TestEnum)5); stream.clear(); formattedWrite(stream, "%s", cast(TestEnum)5);
assert(stream.data == "cast(TestEnum)5", stream.data); assert(stream.data == "cast(TestEnum)5", stream.data);
//immutable(char[5])[int] aa = ([3:"hello", 4:"betty"]); //immutable(char[5])[int] aa = ([3:"hello", 4:"betty"]);
//stream.clear; formattedWrite(stream, "%s", aa.values); //stream.clear(); formattedWrite(stream, "%s", aa.values);
//std.c.stdio.fwrite(stream.data.ptr, stream.data.length, 1, stderr); //std.c.stdio.fwrite(stream.data.ptr, stream.data.length, 1, stderr);
//assert(stream.data == "[[h,e,l,l,o],[b,e,t,t,y]]"); //assert(stream.data == "[[h,e,l,l,o],[b,e,t,t,y]]");
//stream.clear; formattedWrite(stream, "%s", aa); //stream.clear(); formattedWrite(stream, "%s", aa);
//assert(stream.data == "[3:[h,e,l,l,o],4:[b,e,t,t,y]]"); //assert(stream.data == "[3:[h,e,l,l,o],4:[b,e,t,t,y]]");
static const dchar[] ds = ['a','b']; static const dchar[] ds = ['a','b'];
for (int j = 0; j < ds.length; ++j) for (int j = 0; j < ds.length; ++j)
{ {
stream.clear; formattedWrite(stream, " %d", ds[j]); stream.clear(); formattedWrite(stream, " %d", ds[j]);
if (j == 0) if (j == 0)
assert(stream.data == " 97"); assert(stream.data == " 97");
else else
assert(stream.data == " 98"); assert(stream.data == " 98");
} }
stream.clear; formattedWrite(stream, "%.-3d", 7); stream.clear(); formattedWrite(stream, "%.-3d", 7);
assert(stream.data == "7", ">" ~ stream.data ~ "<"); assert(stream.data == "7", ">" ~ stream.data ~ "<");
@ -2512,7 +2512,7 @@ here:
foreach (prec; precs) foreach (prec; precs)
foreach (format; formats) foreach (format; formats)
{ {
stream.clear; stream.clear();
auto fmt = "%" ~ flag1 ~ flag2 ~ flag3 auto fmt = "%" ~ flag1 ~ flag2 ~ flag3
~ flag4 ~ flag5 ~ width ~ prec ~ format ~ flag4 ~ flag5 ~ width ~ prec ~ format
~ '\0'; ~ '\0';
@ -2634,7 +2634,7 @@ unittest
} }
//auto r = std.string.format("%s", aa.values); //auto r = std.string.format("%s", aa.values);
stream.clear; formattedWrite(stream, "%s", aa); stream.clear(); formattedWrite(stream, "%s", aa);
//assert(stream.data == "[3:[h,e,l,l,o],4:[b,e,t,t,y]]", stream.data); //assert(stream.data == "[3:[h,e,l,l,o],4:[b,e,t,t,y]]", stream.data);
// r = std.string.format("%s", aa); // r = std.string.format("%s", aa);
// assert(r == "[3:[h,e,l,l,o],4:[b,e,t,t,y]]"); // assert(r == "[3:[h,e,l,l,o],4:[b,e,t,t,y]]");
@ -2655,12 +2655,12 @@ private void skipData(Range, Char)(ref Range input, ref FormatSpec!Char spec)
{ {
switch (spec.spec) switch (spec.spec)
{ {
case 'c': input.popFront; break; case 'c': input.popFront(); break;
case 'd': case 'd':
if (input.front == '+' || input.front == '-') input.popFront(); if (input.front == '+' || input.front == '-') input.popFront();
goto case 'u'; goto case 'u';
case 'u': case 'u':
while (!input.empty && isDigit(input.front)) input.popFront; while (!input.empty && isDigit(input.front)) input.popFront();
break; break;
default: default:
assert(false, assert(false,

View file

@ -94,7 +94,7 @@ struct Interval
/// ///
@trusted string toString()const @trusted string toString()const
{ {
auto s = appender!string; auto s = appender!string();
formattedWrite(s,"%s..%s", begin, end); formattedWrite(s,"%s..%s", begin, end);
return s.data; return s.data;
} }
@ -442,7 +442,7 @@ struct CodepointSet
j = ivals[0]; j = ivals[0];
} }
} }
auto ref save() const { return this; } @property auto ref save() const { return this; }
} }
static assert(isForwardRange!ByCodepoint); static assert(isForwardRange!ByCodepoint);
@ -534,7 +534,7 @@ public:
{ {
if(s.empty) if(s.empty)
return; return;
const(CodepointSet) set = s.chars > 500_000 ? (negative=true, s.dup.negate) : s; const(CodepointSet) set = s.chars > 500_000 ? (negative=true, s.dup.negate()) : s;
uint bound = 0;//set up on first iteration uint bound = 0;//set up on first iteration
ushort emptyBlock = ushort.max; ushort emptyBlock = ushort.max;
auto ivals = set.ivals; auto ivals = set.ivals;

View file

@ -2185,7 +2185,7 @@ public:
/// Set all of the floating-point status flags to false. /// Set all of the floating-point status flags to false.
void resetIeeeFlags() { IeeeFlags.resetIeeeFlags; } void resetIeeeFlags() { IeeeFlags.resetIeeeFlags(); }
/// Return a snapshot of the current state of the floating-point status flags. /// Return a snapshot of the current state of the floating-point status flags.
@property IeeeFlags ieeeFlags() @property IeeeFlags ieeeFlags()
@ -3908,7 +3908,7 @@ bool approxEqual(T, U, V)(T lhs, U rhs, V maxRelDiff, V maxAbsDiff = 1e-5)
static if (isInputRange!U) static if (isInputRange!U)
{ {
// Two ranges // Two ranges
for (;; lhs.popFront, rhs.popFront) for (;; lhs.popFront(), rhs.popFront())
{ {
if (lhs.empty) return rhs.empty; if (lhs.empty) return rhs.empty;
if (rhs.empty) return lhs.empty; if (rhs.empty) return lhs.empty;
@ -3919,7 +3919,7 @@ bool approxEqual(T, U, V)(T lhs, U rhs, V maxRelDiff, V maxAbsDiff = 1e-5)
else else
{ {
// lhs is range, rhs is number // lhs is range, rhs is number
for (; !lhs.empty; lhs.popFront) for (; !lhs.empty; lhs.popFront())
{ {
if (!approxEqual(lhs.front, rhs, maxRelDiff, maxAbsDiff)) if (!approxEqual(lhs.front, rhs, maxRelDiff, maxAbsDiff))
return false; return false;

View file

@ -143,7 +143,7 @@ string d = getDigestString(a, b, c);
string getDigestString(in void[][] data...) string getDigestString(in void[][] data...)
{ {
MD5_CTX ctx; MD5_CTX ctx;
ctx.start; ctx.start();
foreach (datum; data) { foreach (datum; data) {
ctx.update(datum); ctx.update(datum);
} }

View file

@ -737,7 +737,7 @@ EmailStatus isEmail (Char) (const(Char)[] email, CheckDns checkDNS = CheckDns.no
auto finalStatus = returnStatus.max; auto finalStatus = returnStatus.max;
if (returnStatus.length != 1) if (returnStatus.length != 1)
returnStatus.popFront; returnStatus.popFront();
parseData[EmailPart.status] = to!(tstring)(returnStatus); parseData[EmailPart.status] = to!(tstring)(returnStatus);
@ -1278,31 +1278,31 @@ struct EmailStatus
} }
/// Indicates if the email address is valid or not. /// Indicates if the email address is valid or not.
bool valid () @property bool valid ()
{ {
return valid_; return valid_;
} }
/// The local part of the email address, that is, the part before the @ sign. /// The local part of the email address, that is, the part before the @ sign.
string localPart () @property string localPart ()
{ {
return localPart_; return localPart_;
} }
/// The domain part of the email address, that is, the part after the @ sign. /// The domain part of the email address, that is, the part after the @ sign.
string domainPart () @property string domainPart ()
{ {
return domainPart_; return domainPart_;
} }
/// The email status code /// The email status code
EmailStatusCode statusCode () @property EmailStatusCode statusCode ()
{ {
return statusCode_; return statusCode_;
} }
/// Returns a describing string of the status code /// Returns a describing string of the status code
string status () @property string status ()
{ {
return statusCodeDescription(statusCode_); return statusCodeDescription(statusCode_);
} }

View file

@ -1170,7 +1170,7 @@ euclideanDistance(Range1, Range2)(Range1 a, Range2 b)
enum bool haveLen = hasLength!(Range1) && hasLength!(Range2); enum bool haveLen = hasLength!(Range1) && hasLength!(Range2);
static if (haveLen) enforce(a.length == b.length); static if (haveLen) enforce(a.length == b.length);
typeof(return) result = 0; typeof(return) result = 0;
for (; !a.empty; a.popFront, b.popFront) for (; !a.empty; a.popFront(), b.popFront())
{ {
auto t = a.front - b.front; auto t = a.front - b.front;
result += t * t; result += t * t;
@ -1188,7 +1188,7 @@ euclideanDistance(Range1, Range2, F)(Range1 a, Range2 b, F limit)
enum bool haveLen = hasLength!(Range1) && hasLength!(Range2); enum bool haveLen = hasLength!(Range1) && hasLength!(Range2);
static if (haveLen) enforce(a.length == b.length); static if (haveLen) enforce(a.length == b.length);
typeof(return) result = 0; typeof(return) result = 0;
for (; ; a.popFront, b.popFront) for (; ; a.popFront(), b.popFront())
{ {
if (a.empty) if (a.empty)
{ {
@ -1226,7 +1226,7 @@ dotProduct(Range1, Range2)(Range1 a, Range2 b)
enum bool haveLen = hasLength!(Range1) && hasLength!(Range2); enum bool haveLen = hasLength!(Range1) && hasLength!(Range2);
static if (haveLen) enforce(a.length == b.length); static if (haveLen) enforce(a.length == b.length);
typeof(return) result = 0; typeof(return) result = 0;
for (; !a.empty; a.popFront, b.popFront) for (; !a.empty; a.popFront(), b.popFront())
{ {
result += a.front * b.front; result += a.front * b.front;
} }
@ -1293,14 +1293,14 @@ unittest
double[] b = [ 4., 6., ]; double[] b = [ 4., 6., ];
assert(dotProduct(a, b) == 16); assert(dotProduct(a, b) == 16);
assert(dotProduct([1, 3, -5], [4, -2, -1]) == 3); assert(dotProduct([1, 3, -5], [4, -2, -1]) == 3);
// Make sure the unrolled loop codepath gets tested. // Make sure the unrolled loop codepath gets tested.
static const x = static const x =
[1.0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]; [1.0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18];
static const y = static const y =
[2.0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]; [2.0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19];
assert(dotProduct(x, y) == 2280); assert(dotProduct(x, y) == 2280);
// Test in CTFE // Test in CTFE
enum ctfeDot = dotProduct(x, y); enum ctfeDot = dotProduct(x, y);
static assert(ctfeDot == 2280); static assert(ctfeDot == 2280);
@ -1319,7 +1319,7 @@ cosineSimilarity(Range1, Range2)(Range1 a, Range2 b)
enum bool haveLen = hasLength!(Range1) && hasLength!(Range2); enum bool haveLen = hasLength!(Range1) && hasLength!(Range2);
static if (haveLen) enforce(a.length == b.length); static if (haveLen) enforce(a.length == b.length);
FPTemporary!(typeof(return)) norma = 0, normb = 0, dotprod = 0; FPTemporary!(typeof(return)) norma = 0, normb = 0, dotprod = 0;
for (; !a.empty; a.popFront, b.popFront) for (; !a.empty; a.popFront(), b.popFront())
{ {
immutable t1 = a.front, t2 = b.front; immutable t1 = a.front, t2 = b.front;
norma += t1 * t1; norma += t1 * t1;
@ -1464,7 +1464,7 @@ kullbackLeiblerDivergence(Range1, Range2)(Range1 a, Range2 b)
enum bool haveLen = hasLength!(Range1) && hasLength!(Range2); enum bool haveLen = hasLength!(Range1) && hasLength!(Range2);
static if (haveLen) enforce(a.length == b.length); static if (haveLen) enforce(a.length == b.length);
FPTemporary!(typeof(return)) result = 0; FPTemporary!(typeof(return)) result = 0;
for (; !a.empty; a.popFront, b.popFront) for (; !a.empty; a.popFront(), b.popFront())
{ {
immutable t1 = a.front; immutable t1 = a.front;
if (t1 == 0) continue; if (t1 == 0) continue;
@ -1509,7 +1509,7 @@ jensenShannonDivergence(Range1, Range2)(Range1 a, Range2 b)
enum bool haveLen = hasLength!(Range1) && hasLength!(Range2); enum bool haveLen = hasLength!(Range1) && hasLength!(Range2);
static if (haveLen) enforce(a.length == b.length); static if (haveLen) enforce(a.length == b.length);
FPTemporary!(typeof(return)) result = 0; FPTemporary!(typeof(return)) result = 0;
for (; !a.empty; a.popFront, b.popFront) for (; !a.empty; a.popFront(), b.popFront())
{ {
immutable t1 = a.front; immutable t1 = a.front;
immutable t2 = b.front; immutable t2 = b.front;
@ -1538,7 +1538,7 @@ jensenShannonDivergence(Range1, Range2, F)(Range1 a, Range2 b, F limit)
static if (haveLen) enforce(a.length == b.length); static if (haveLen) enforce(a.length == b.length);
FPTemporary!(typeof(return)) result = 0; FPTemporary!(typeof(return)) result = 0;
limit *= 2; limit *= 2;
for (; !a.empty; a.popFront, b.popFront) for (; !a.empty; a.popFront(), b.popFront())
{ {
immutable t1 = a.front; immutable t1 = a.front;
immutable t2 = b.front; immutable t2 = b.front;
@ -1813,11 +1813,11 @@ string[] s = ["Hello", "brave", "new", "world"];
string[] t = ["Hello", "new", "world"]; string[] t = ["Hello", "new", "world"];
auto simIter = gapWeightedSimilarityIncremental(s, t, 1); auto simIter = gapWeightedSimilarityIncremental(s, t, 1);
assert(simIter.front == 3); // three 1-length matches assert(simIter.front == 3); // three 1-length matches
simIter.popFront; simIter.popFront();
assert(simIter.front == 3); // three 2-length matches assert(simIter.front == 3); // three 2-length matches
simIter.popFront; simIter.popFront();
assert(simIter.front == 1); // one 3-length match assert(simIter.front == 1); // one 3-length match
simIter.popFront; simIter.popFront();
assert(simIter.empty); // no more match assert(simIter.empty); // no more match
---- ----
@ -1981,12 +1981,12 @@ t.length) time.
Returns the gapped similarity at the current match length (initially Returns the gapped similarity at the current match length (initially
1, grows with each call to $(D popFront)). 1, grows with each call to $(D popFront)).
*/ */
F front() { return currentValue; } @property F front() { return currentValue; }
/** /**
Returns whether there are more matches. Returns whether there are more matches.
*/ */
bool empty() { @property bool empty() {
if (currentValue) return false; if (currentValue) return false;
if (kl) { if (kl) {
free(kl); free(kl);
@ -2012,11 +2012,11 @@ unittest
auto simIter = gapWeightedSimilarityIncremental(s, t, 1.0); auto simIter = gapWeightedSimilarityIncremental(s, t, 1.0);
//foreach (e; simIter) writeln(e); //foreach (e; simIter) writeln(e);
assert(simIter.front == 3); // three 1-length matches assert(simIter.front == 3); // three 1-length matches
simIter.popFront; simIter.popFront();
assert(simIter.front == 3, text(simIter.front)); // three 2-length matches assert(simIter.front == 3, text(simIter.front)); // three 2-length matches
simIter.popFront; simIter.popFront();
assert(simIter.front == 1); // one 3-length matches assert(simIter.front == 1); // one 3-length matches
simIter.popFront; simIter.popFront();
assert(simIter.empty); // no more match assert(simIter.empty); // no more match
s = ["Hello"]; s = ["Hello"];
@ -2028,21 +2028,21 @@ unittest
t = ["Hello"]; t = ["Hello"];
simIter = gapWeightedSimilarityIncremental(s, t, 0.5); simIter = gapWeightedSimilarityIncremental(s, t, 0.5);
assert(simIter.front == 1); // one match assert(simIter.front == 1); // one match
simIter.popFront; simIter.popFront();
assert(simIter.empty); assert(simIter.empty);
s = ["Hello", "world"]; s = ["Hello", "world"];
t = ["Hello"]; t = ["Hello"];
simIter = gapWeightedSimilarityIncremental(s, t, 0.5); simIter = gapWeightedSimilarityIncremental(s, t, 0.5);
assert(simIter.front == 1); // one match assert(simIter.front == 1); // one match
simIter.popFront; simIter.popFront();
assert(simIter.empty); assert(simIter.empty);
s = ["Hello", "world"]; s = ["Hello", "world"];
t = ["Hello", "yah", "world"]; t = ["Hello", "yah", "world"];
simIter = gapWeightedSimilarityIncremental(s, t, 0.5); simIter = gapWeightedSimilarityIncremental(s, t, 0.5);
assert(simIter.front == 2); // two 1-gram matches assert(simIter.front == 2); // two 1-gram matches
simIter.popFront; simIter.popFront();
assert(simIter.front == 0.5, text(simIter.front)); // one 2-gram match, 1 gap assert(simIter.front == 0.5, text(simIter.front)); // one 2-gram match, 1 gap
} }
@ -2058,7 +2058,7 @@ unittest
{ {
//writeln(e); //writeln(e);
assert(e == witness.front); assert(e == witness.front);
witness.popFront; witness.popFront();
} }
witness = [ 3., 1.3125, 0.25 ]; witness = [ 3., 1.3125, 0.25 ];
sim = GapWeightedSimilarityIncremental!(string[])( sim = GapWeightedSimilarityIncremental!(string[])(
@ -2069,7 +2069,7 @@ unittest
{ {
//writeln(e); //writeln(e);
assert(e == witness.front); assert(e == witness.front);
witness.popFront; witness.popFront();
} }
assert(witness.empty); assert(witness.empty);
} }
@ -2567,7 +2567,7 @@ struct Stride(R) {
return range[index * _nSteps]; return range[index * _nSteps];
} }
E front() { E front() @property {
return range[0]; return range[0];
} }

View file

@ -1452,7 +1452,7 @@ auto pathSplitter(C)(const(C)[] path) @safe pure nothrow
_path = rtrimDirSeparators(_path[0 .. i+1]); _path = rtrimDirSeparators(_path[0 .. i+1]);
} }
} }
auto save() { return this; } @property auto save() { return this; }
private: private:
@ -1549,7 +1549,7 @@ unittest
// save() // save()
auto ps1 = pathSplitter("foo/bar/baz"); auto ps1 = pathSplitter("foo/bar/baz");
auto ps2 = ps1.save(); auto ps2 = ps1.save();
ps1.popFront; ps1.popFront();
assert (equal2(ps1, ["bar", "baz"])); assert (equal2(ps1, ["bar", "baz"]));
assert (equal2(ps2, ["foo", "bar", "baz"])); assert (equal2(ps2, ["foo", "bar", "baz"]));

View file

@ -830,7 +830,7 @@ else version(Posix)
public: public:
interval_t periodCount() const interval_t periodCount() const
{ {
return microseconds; return microseconds();
} }
interval_t seconds() const interval_t seconds() const

View file

@ -351,7 +351,7 @@ version (Windows) string shell(string cmd)
foreach (ref e; 0 .. 8) foreach (ref e; 0 .. 8)
{ {
formattedWrite(a, "%x", rndGen.front); formattedWrite(a, "%x", rndGen.front);
rndGen.popFront; rndGen.popFront();
} }
auto filename = a.data; auto filename = a.data;
scope(exit) if (exists(filename)) remove(filename); scope(exit) if (exists(filename)) remove(filename);
@ -369,7 +369,7 @@ version (Posix) string shell(string cmd)
{ {
result ~= line; result ~= line;
} }
f.close; f.close();
return result; return result;
} }

View file

@ -233,7 +233,7 @@ $(D x0).
~ LinearCongruentialEngine.stringof); ~ LinearCongruentialEngine.stringof);
} }
_x = modulus ? (x0 % modulus) : x0; _x = modulus ? (x0 % modulus) : x0;
popFront; popFront();
} }
/** /**
@ -343,12 +343,12 @@ unittest
foreach (e; checking0) foreach (e; checking0)
{ {
assert(rnd0.front == e); assert(rnd0.front == e);
rnd0.popFront; rnd0.popFront();
} }
// Test the 10000th invocation // Test the 10000th invocation
// Correct value taken from: // Correct value taken from:
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2461.pdf // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2461.pdf
rnd0.seed; rnd0.seed();
popFrontN(rnd0, 9999); popFrontN(rnd0, 9999);
assert(rnd0.front == 1043618065); assert(rnd0.front == 1043618065);
@ -360,13 +360,13 @@ unittest
foreach (e; checking) foreach (e; checking)
{ {
assert(rnd.front == e); assert(rnd.front == e);
rnd.popFront; rnd.popFront();
} }
// Test the 10000th invocation // Test the 10000th invocation
// Correct value taken from: // Correct value taken from:
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2461.pdf // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2461.pdf
rnd.seed; rnd.seed();
popFrontN(rnd, 9999); popFrontN(rnd, 9999);
assert(rnd.front == 399268537); assert(rnd.front == 399268537);
} }
@ -443,7 +443,7 @@ Parameter for the generator.
//mt[mti] &= ResultType.max; //mt[mti] &= ResultType.max;
/* for >32 bit machines */ /* for >32 bit machines */
} }
popFront; popFront();
} }
/** /**
@ -561,7 +561,7 @@ unittest
} }
{ {
Mt19937 gen; Mt19937 gen;
gen.popFront; gen.popFront();
//popFrontN(gen, 1); // skip 1 element //popFrontN(gen, 1); // skip 1 element
b = gen.front; b = gen.front;
} }
@ -814,16 +814,16 @@ auto n = rnd.front;
---- ----
*/ */
uint unpredictableSeed() @property uint unpredictableSeed()
{ {
static bool seeded; static bool seeded;
static MinstdRand0 rand; static MinstdRand0 rand;
if (!seeded) { if (!seeded) {
uint threadID = cast(uint) cast(void*) Thread.getThis(); uint threadID = cast(uint) cast(void*) Thread.getThis();
rand.seed((getpid + threadID) ^ cast(uint) TickDuration.currSystemTick().length); rand.seed((getpid() + threadID) ^ cast(uint) TickDuration.currSystemTick().length);
seeded = true; seeded = true;
} }
rand.popFront; rand.popFront();
return cast(uint) (TickDuration.currSystemTick().length ^ rand.front); return cast(uint) (TickDuration.currSystemTick().length ^ rand.front);
} }
@ -849,7 +849,7 @@ Global random number generator used by various functions in this
module whenever no generator is specified. It is allocated per-thread module whenever no generator is specified. It is allocated per-thread
and initialized to an unpredictable value for each thread. and initialized to an unpredictable value for each thread.
*/ */
ref Random rndGen() @property ref Random rndGen()
{ {
static Random result; static Random result;
static bool initialized; static bool initialized;
@ -1149,14 +1149,14 @@ if (isForwardRange!Range && isNumeric!(ElementType!Range) && !isArray!Range)
size_t dice(Range)(Range proportions) size_t dice(Range)(Range proportions)
if (isForwardRange!Range && isNumeric!(ElementType!Range) && !isArray!Range) if (isForwardRange!Range && isNumeric!(ElementType!Range) && !isArray!Range)
{ {
return diceImpl(rndGen(), proportions); return diceImpl(rndGen, proportions);
} }
/// Ditto /// Ditto
size_t dice(Num)(Num[] proportions...) size_t dice(Num)(Num[] proportions...)
if (isNumeric!Num) if (isNumeric!Num)
{ {
return diceImpl(rndGen(), proportions); return diceImpl(rndGen, proportions);
} }
private size_t diceImpl(Rng, Range)(ref Rng rng, Range proportions) private size_t diceImpl(Rng, Range)(ref Rng rng, Range proportions)
@ -1217,7 +1217,7 @@ struct RandomCover(Range, Random)
_input = input; _input = input;
_rnd = rnd; _rnd = rnd;
_chosen.length = _input.length; _chosen.length = _input.length;
popFront; popFront();
} }
static if (hasLength!Range) static if (hasLength!Range)
@ -1326,7 +1326,7 @@ struct RandomSample(R, Random = void)
// If we're using the default thread-local random number generator then // If we're using the default thread-local random number generator then
// we shouldn't store a copy of it here. Random == void is a sentinel // we shouldn't store a copy of it here. Random == void is a sentinel
// for this. If we're using a user-specified generator then we have no // for this. If we're using a user-specified generator then we have no
// choice but to store a copy. // choice but to store a copy.
static if(!is(Random == void)) static if(!is(Random == void))
{ {
@ -1350,7 +1350,7 @@ Constructor.
enforce(_toSelect <= _available); enforce(_toSelect <= _available);
// we should skip some elements initially so we don't always // we should skip some elements initially so we don't always
// start with the first // start with the first
prime; prime();
} }
/** /**
@ -1361,7 +1361,7 @@ Constructor.
return _toSelect == 0; return _toSelect == 0;
} }
auto ref front() @property auto ref front()
{ {
assert(!empty); assert(!empty);
return _input.front; return _input.front;
@ -1370,11 +1370,11 @@ Constructor.
/// Ditto /// Ditto
void popFront() void popFront()
{ {
_input.popFront; _input.popFront();
--_available; --_available;
--_toSelect; --_toSelect;
++_index; ++_index;
prime; prime();
} }
/// Ditto /// Ditto
@ -1408,12 +1408,12 @@ Returns the index of the visited record.
static if(is(Random == void)) static if(is(Random == void))
{ {
auto r = uniform(0, _available); auto r = uniform(0, _available);
} }
else else
{ {
auto r = uniform(0, _available, gen); auto r = uniform(0, _available, gen);
} }
if (r < _toSelect) if (r < _toSelect)
{ {
// chosen! // chosen!
@ -1421,7 +1421,7 @@ Returns the index of the visited record.
} }
// not chosen, retry // not chosen, retry
assert(!_input.empty); assert(!_input.empty);
_input.popFront; _input.popFront();
++_index; ++_index;
--_available; --_available;
assert(_available > 0); assert(_available > 0);
@ -1437,7 +1437,7 @@ if(isInputRange!R)
} }
/// Ditto /// Ditto
auto randomSample(R)(R r, size_t n) if (hasLength!R) auto randomSample(R)(R r, size_t n) if (hasLength!R)
{ {
return RandomSample!(R, void)(r, n, r.length); return RandomSample!(R, void)(r, n, r.length);
} }
@ -1452,8 +1452,8 @@ if(isInputRange!R && isInputRange!Random)
} }
/// Ditto /// Ditto
auto randomSample(R, Random)(R r, size_t n, Random gen) auto randomSample(R, Random)(R r, size_t n, Random gen)
if (isInputRange!R && hasLength!R && isInputRange!Random) if (isInputRange!R && hasLength!R && isInputRange!Random)
{ {
auto ret = RandomSample!(R, Random)(r, n, r.length); auto ret = RandomSample!(R, Random)(r, n, r.length);
ret.gen = gen; ret.gen = gen;

View file

@ -512,8 +512,8 @@ unittest
struct B struct B
{ {
void popFront(); void popFront();
bool empty(); @property bool empty();
int front(); @property int front();
} }
static assert(!isBidirectionalRange!(B)); static assert(!isBidirectionalRange!(B));
struct C struct C
@ -577,26 +577,26 @@ unittest
struct B struct B
{ {
void popFront(); void popFront();
bool empty(); @property bool empty();
int front(); @property int front();
} }
static assert(!isRandomAccessRange!(B)); static assert(!isRandomAccessRange!(B));
struct C struct C
{ {
void popFront(); void popFront();
bool empty(); @property bool empty();
int front(); @property int front();
void popBack(); void popBack();
int back(); @property int back();
} }
static assert(!isRandomAccessRange!(C)); static assert(!isRandomAccessRange!(C));
struct D struct D
{ {
bool empty(); @property bool empty();
@property D save(); @property D save();
int front(); @property int front();
void popFront(); void popFront();
int back(); @property int back();
void popBack(); void popBack();
ref int opIndex(uint); ref int opIndex(uint);
@property size_t length(); @property size_t length();
@ -621,7 +621,7 @@ unittest
@property R save() { return this; } @property R save() { return this; }
int back() const { return 0; } @property int back() const { return 0; }
void popBack(){} void popBack(){}
int opIndex(size_t n) const { return 0; } int opIndex(size_t n) const { return 0; }
@ -1002,7 +1002,7 @@ if (isBidirectionalRange!(Unqual!Range))
@property auto ref front() { return source.back; } @property auto ref front() { return source.back; }
void popFront() { source.popBack(); } void popFront() { source.popBack(); }
@property auto ref back() { return source.front; } @property auto ref back() { return source.front; }
void popBack() { source.popFront; } void popBack() { source.popFront(); }
static if(is(typeof(.moveBack(source)))) static if(is(typeof(.moveBack(source))))
{ {
@ -1607,7 +1607,7 @@ if (Ranges.length > 0 && allSatisfy!(isInputRange, staticMap!(Unqual, Ranges)))
foreach (i, Unused; R) foreach (i, Unused; R)
{ {
if (source[i].empty) continue; if (source[i].empty) continue;
source[i].popFront; source[i].popFront();
return; return;
} }
} }
@ -1941,7 +1941,7 @@ if (Rs.length > 1 && allSatisfy!(isInputRange, staticMap!(Unqual, Rs)))
public Rs source; public Rs source;
private size_t _current = size_t.max; private size_t _current = size_t.max;
bool empty() @property bool empty()
{ {
foreach (i, Unused; Rs) foreach (i, Unused; Rs)
{ {
@ -2002,7 +2002,7 @@ if (Rs.length > 1 && allSatisfy!(isInputRange, staticMap!(Unqual, Rs)))
} }
static if (allSatisfy!(isForwardRange, staticMap!(Unqual, Rs))) static if (allSatisfy!(isForwardRange, staticMap!(Unqual, Rs)))
auto save() @property auto save()
{ {
Result result; Result result;
result._current = _current; result._current = _current;
@ -2015,7 +2015,7 @@ if (Rs.length > 1 && allSatisfy!(isInputRange, staticMap!(Unqual, Rs)))
static if (allSatisfy!(hasLength, Rs)) static if (allSatisfy!(hasLength, Rs))
{ {
size_t length() @property size_t length()
{ {
size_t result; size_t result;
foreach (i, R; Rs) foreach (i, R; Rs)
@ -2659,7 +2659,7 @@ size_t popBackN(Range)(ref Range r, size_t n) if (isInputRange!(Range))
foreach (i; 0 .. n) foreach (i; 0 .. n)
{ {
if (r.empty) return i; if (r.empty) return i;
r.popBack; r.popBack();
} }
} }
return n; return n;
@ -2817,7 +2817,7 @@ if (isForwardRange!(Unqual!Range) && !isInfinite!(Unqual!Range))
/// Ditto /// Ditto
void popFront() void popFront()
{ {
_current.popFront; _current.popFront();
if (_current.empty) _current = _original; if (_current.empty) _current = _original;
} }
@ -2947,7 +2947,7 @@ unittest // For infinite ranges
struct InfRange struct InfRange
{ {
void popFront() { } void popFront() { }
int front() { return 0; } @property int front() { return 0; }
enum empty = false; enum empty = false;
} }
@ -3023,7 +3023,7 @@ if(Ranges.length && allSatisfy!(isInputRange, staticMap!(Unqual, Ranges)))
} }
else else
{ {
bool empty() @property bool empty()
{ {
final switch (stoppingPolicy) final switch (stoppingPolicy)
{ {
@ -3734,7 +3734,7 @@ unittest {
foreach(a, b; ls) {} foreach(a, b; ls) {}
// Make sure StoppingPolicy.requireSameLength throws. // Make sure StoppingPolicy.requireSameLength throws.
arr2.popBack; arr2.popBack();
ls = lockstep(arr1, arr2, StoppingPolicy.requireSameLength); ls = lockstep(arr1, arr2, StoppingPolicy.requireSameLength);
try { try {
@ -4348,7 +4348,7 @@ struct FrontTransversal(Ror,
TransverseOptions opt = TransverseOptions.assumeJagged) TransverseOptions opt = TransverseOptions.assumeJagged)
{ {
alias Unqual!(Ror) RangeOfRanges; alias Unqual!(Ror) RangeOfRanges;
alias typeof(RangeOfRanges.init.front().front()) ElementType; alias typeof(RangeOfRanges.init.front.front) ElementType;
private void prime() private void prime()
{ {
@ -4356,13 +4356,13 @@ struct FrontTransversal(Ror,
{ {
while (!_input.empty && _input.front.empty) while (!_input.empty && _input.front.empty)
{ {
_input.popFront; _input.popFront();
} }
static if (isBidirectionalRange!RangeOfRanges) static if (isBidirectionalRange!RangeOfRanges)
{ {
while (!_input.empty && _input.back.empty) while (!_input.empty && _input.back.empty)
{ {
_input.popBack; _input.popBack();
} }
} }
} }
@ -4374,7 +4374,7 @@ struct FrontTransversal(Ror,
this(RangeOfRanges input) this(RangeOfRanges input)
{ {
_input = input; _input = input;
prime; prime();
static if (opt == TransverseOptions.enforceNotJagged) static if (opt == TransverseOptions.enforceNotJagged)
// (isRandomAccessRange!RangeOfRanges // (isRandomAccessRange!RangeOfRanges
// && hasLength!(.ElementType!RangeOfRanges)) // && hasLength!(.ElementType!RangeOfRanges))
@ -4431,8 +4431,8 @@ struct FrontTransversal(Ror,
void popFront() void popFront()
{ {
assert(!empty); assert(!empty);
_input.popFront; _input.popFront();
prime; prime();
} }
/// Ditto /// Ditto
@ -4461,8 +4461,8 @@ struct FrontTransversal(Ror,
void popBack() void popBack()
{ {
assert(!empty); assert(!empty);
_input.popBack; _input.popBack();
prime; prime();
} }
/// Ditto /// Ditto
@ -4629,13 +4629,13 @@ struct Transversal(Ror,
{ {
while (!_input.empty && _input.front.length <= _n) while (!_input.empty && _input.front.length <= _n)
{ {
_input.popFront; _input.popFront();
} }
static if (isBidirectionalRange!RangeOfRanges) static if (isBidirectionalRange!RangeOfRanges)
{ {
while (!_input.empty && _input.back.length <= _n) while (!_input.empty && _input.back.length <= _n)
{ {
_input.popBack; _input.popBack();
} }
} }
} }
@ -4648,7 +4648,7 @@ struct Transversal(Ror,
{ {
_input = input; _input = input;
_n = n; _n = n;
prime; prime();
static if (opt == TransverseOptions.enforceNotJagged) static if (opt == TransverseOptions.enforceNotJagged)
{ {
if (empty) return; if (empty) return;
@ -4705,8 +4705,8 @@ struct Transversal(Ror,
void popFront() void popFront()
{ {
assert(!empty); assert(!empty);
_input.popFront; _input.popFront();
prime; prime();
} }
/// Ditto /// Ditto
@ -4735,8 +4735,8 @@ struct Transversal(Ror,
void popBack() void popBack()
{ {
assert(!empty); assert(!empty);
_input.popBack; _input.popBack();
prime; prime();
} }
/// Ditto /// Ditto
@ -4853,13 +4853,13 @@ unittest
ror.front = 5; ror.front = 5;
scope(exit) ror.front = 2; scope(exit) ror.front = 2;
assert(x[0][1] == 5); assert(x[0][1] == 5);
assert(ror.moveFront == 5); assert(ror.moveFront() == 5);
} }
{ {
ror.back = 999; ror.back = 999;
scope(exit) ror.back = 4; scope(exit) ror.back = 4;
assert(x[1][1] == 999); assert(x[1][1] == 999);
assert(ror.moveBack == 999); assert(ror.moveBack() == 999);
} }
{ {
ror[0] = 999; ror[0] = 999;
@ -4905,7 +4905,7 @@ struct Transposed(RangeOfRanges)
foreach (ref e; _input) foreach (ref e; _input)
{ {
if (e.empty) continue; if (e.empty) continue;
e.popFront; e.popFront();
} }
} }
@ -5378,7 +5378,7 @@ unittest
{ {
struct R struct R
{ {
ref int front() { static int x = 42; return x; } @property ref int front() { static int x = 42; return x; }
this(this){} this(this){}
} }
R r; R r;
@ -5746,7 +5746,7 @@ template InputRangeObject(R) if (isInputRange!(Unqual!R)) {
return .moveBack(_range); return .moveBack(_range);
} }
@property void popBack() { return _range.popBack; } @property void popBack() { return _range.popBack(); }
static if (hasAssignableElements!R) { static if (hasAssignableElements!R) {
@property void back(E newVal) { @property void back(E newVal) {

View file

@ -1550,7 +1550,7 @@ struct Parser(R, bool CTFE=false)
state = State.Start; state = State.Start;
break; break;
case 'D': case 'D':
set.add(unicodeNd.dup.negate); set.add(unicodeNd.dup.negate());
state = State.Start; state = State.Start;
break; break;
case 's': case 's':
@ -1558,7 +1558,7 @@ struct Parser(R, bool CTFE=false)
state = State.Start; state = State.Start;
break; break;
case 'S': case 'S':
set.add(unicodeWhite_Space.dup.negate); set.add(unicodeWhite_Space.dup.negate());
state = State.Start; state = State.Start;
break; break;
case 'w': case 'w':
@ -1566,7 +1566,7 @@ struct Parser(R, bool CTFE=false)
state = State.Start; state = State.Start;
break; break;
case 'W': case 'W':
set.add(wordCharacter.dup.negate); set.add(wordCharacter.dup.negate());
state = State.Start; state = State.Start;
break; break;
default: default:
@ -1665,7 +1665,7 @@ struct Parser(R, bool CTFE=false)
switch(op) switch(op)
{ {
case Operator.Negate: case Operator.Negate:
stack.top.negate; stack.top.negate();
break; break;
case Operator.Union: case Operator.Union:
auto s = stack.pop();//2nd operand auto s = stack.pop();//2nd operand
@ -1816,7 +1816,7 @@ struct Parser(R, bool CTFE=false)
break; break;
case 'D': case 'D':
next(); next();
charsetToIr(unicodeNd.dup.negate); charsetToIr(unicodeNd.dup.negate());
break; break;
case 'b': next(); put(Bytecode(IR.Wordboundary, 0)); break; case 'b': next(); put(Bytecode(IR.Wordboundary, 0)); break;
case 'B': next(); put(Bytecode(IR.Notwordboundary, 0)); break; case 'B': next(); put(Bytecode(IR.Notwordboundary, 0)); break;
@ -1826,7 +1826,7 @@ struct Parser(R, bool CTFE=false)
break; break;
case 'S': case 'S':
next(); next();
charsetToIr(unicodeWhite_Space.dup.negate); charsetToIr(unicodeWhite_Space.dup.negate());
break; break;
case 'w': case 'w':
next(); next();
@ -1834,7 +1834,7 @@ struct Parser(R, bool CTFE=false)
break; break;
case 'W': case 'W':
next(); next();
charsetToIr(wordCharacter.dup.negate); charsetToIr(wordCharacter.dup.negate());
break; break;
case 'p': case 'P': case 'p': case 'P':
auto CodepointSet = parseUnicodePropertySpec(current == 'P'); auto CodepointSet = parseUnicodePropertySpec(current == 'P');
@ -6731,7 +6731,7 @@ public:
{ {
//skip past the separator //skip past the separator
_offset = _match.pre.length + _match.hit.length; _offset = _match.pre.length + _match.hit.length;
_match.popFront; _match.popFront();
} }
} }

View file

@ -790,7 +790,7 @@ class RegExp
/******************* /*******************
* Return the slice of the input that precedes the matched substring. * Return the slice of the input that precedes the matched substring.
*/ */
public string pre() public @property string pre()
{ {
return input[0 .. pmatch[0].rm_so]; return input[0 .. pmatch[0].rm_so];
} }
@ -798,7 +798,7 @@ class RegExp
/******************* /*******************
* Return the slice of the input that follows the matched substring. * Return the slice of the input that follows the matched substring.
*/ */
public string post() public @property string post()
{ {
return input[pmatch[0].rm_eo .. $]; return input[pmatch[0].rm_eo .. $];
} }
@ -3361,12 +3361,12 @@ struct Splitter(Range)
return this; return this;
} }
Range front() @property Range front()
{ {
return _input[0 .. _chunkLength]; return _input[0 .. _chunkLength];
} }
bool empty() @property bool empty()
{ {
return _input.empty; return _input.empty;
} }
@ -3378,7 +3378,7 @@ struct Splitter(Range)
_input = _input[_chunkLength .. _input.length]; _input = _input[_chunkLength .. _input.length];
return; return;
} }
advance; advance();
_input = _input[_chunkLength .. _input.length]; _input = _input[_chunkLength .. _input.length];
_chunkLength = _input.length - search().length; _chunkLength = _input.length - search().length;
} }

View file

@ -1193,7 +1193,7 @@ abstract class Address
socklen_t nameLen() const; socklen_t nameLen() const;
/// Family of this address. /// Family of this address.
AddressFamily addressFamily() const @property AddressFamily addressFamily() const
{ {
return cast(AddressFamily) name().sa_family; return cast(AddressFamily) name().sa_family;
} }
@ -2297,7 +2297,7 @@ public:
/// Get underlying socket handle. /// Get underlying socket handle.
socket_t handle() const @property socket_t handle() const
{ {
return sock; return sock;
} }
@ -2351,13 +2351,13 @@ public:
/// Get the socket's address family. /// Get the socket's address family.
AddressFamily addressFamily() // getter @property AddressFamily addressFamily()
{ {
return _family; return _family;
} }
/// Property that indicates if this is a valid, alive socket. /// Property that indicates if this is a valid, alive socket.
bool isAlive() const // getter @property bool isAlive() const
{ {
int type; int type;
socklen_t typesize = cast(socklen_t) type.sizeof; socklen_t typesize = cast(socklen_t) type.sizeof;

View file

@ -172,7 +172,7 @@ public:
assert(f.isOpen); assert(f.isOpen);
file = f; file = f;
this.format = format; this.format = format;
popFront; // prime the range popFront(); // prime the range
} }
/// Range primitive implementations. /// Range primitive implementations.
@ -194,7 +194,7 @@ public:
file.readln(line); file.readln(line);
if (!line.length) if (!line.length)
{ {
file.detach; file.detach();
} }
else else
{ {
@ -293,7 +293,7 @@ object refers to it anymore.
~this() ~this()
{ {
if (!p) return; if (!p) return;
if (p.refs == 1) close; if (p.refs == 1) close();
else --p.refs; else --p.refs;
} }
@ -323,7 +323,7 @@ Throws exception in case of error.
*/ */
void open(string name, in char[] stdioOpenmode = "rb") void open(string name, in char[] stdioOpenmode = "rb")
{ {
detach; detach();
auto another = File(name, stdioOpenmode); auto another = File(name, stdioOpenmode);
swap(this, another); swap(this, another);
} }
@ -335,7 +335,7 @@ opengroup.org/onlinepubs/007908799/xsh/_popen.html, _popen).
*/ */
version(Posix) void popen(string command, in char[] stdioOpenmode = "r") version(Posix) void popen(string command, in char[] stdioOpenmode = "r")
{ {
detach; detach();
p = new Impl(errnoEnforce(.popen(command, stdioOpenmode), p = new Impl(errnoEnforce(.popen(command, stdioOpenmode),
"Cannot run command `"~command~"'"), "Cannot run command `"~command~"'"),
1, command, true); 1, command, true);
@ -382,7 +382,7 @@ and throws if that fails.
{ {
if (!p) return; if (!p) return;
// @@@BUG // @@@BUG
//if (p.refs == 1) close; //if (p.refs == 1) close();
p = null; p = null;
} }
@ -649,7 +649,7 @@ If the file is not opened, throws an exception. Otherwise, writes its
arguments in text format to the file. */ arguments in text format to the file. */
void write(S...)(S args) void write(S...)(S args)
{ {
auto w = lockingTextWriter(); auto w = lockingTextWriter;
foreach (arg; args) foreach (arg; args)
{ {
alias typeof(arg) A; alias typeof(arg) A;
@ -706,7 +706,7 @@ first argument. */
assert(p.handle); assert(p.handle);
static assert(S.length>0, errorMessage); static assert(S.length>0, errorMessage);
static assert(isSomeString!(S[0]), errorMessage); static assert(isSomeString!(S[0]), errorMessage);
auto w = lockingTextWriter(); auto w = lockingTextWriter;
std.format.formattedWrite(w, args); std.format.formattedWrite(w, args);
} }
@ -864,7 +864,7 @@ with every line. */
cplusplus.com/reference/clibrary/cstdio/_tmpfile.html, _tmpfile). */ cplusplus.com/reference/clibrary/cstdio/_tmpfile.html, _tmpfile). */
static File tmpfile() static File tmpfile()
{ {
auto h = errnoEnforce(core.stdc.stdio.tmpfile, auto h = errnoEnforce(core.stdc.stdio.tmpfile(),
"Could not create temporary file with tmpfile()"); "Could not create temporary file with tmpfile()");
File result = void; File result = void;
result.p = new Impl(h, 1, null); result.p = new Impl(h, 1, null);
@ -894,7 +894,7 @@ Returns the $(D FILE*) corresponding to this object.
unittest unittest
{ {
assert(stdout.getFP == std.c.stdio.stdout); assert(stdout.getFP() == std.c.stdio.stdout);
} }
/** /**
@ -926,13 +926,13 @@ Range that reads one line at a time. */
} }
/// Range primitive implementations. /// Range primitive implementations.
bool empty() const @property bool empty() const
{ {
return !file.isOpen; return !file.isOpen;
} }
/// Ditto /// Ditto
Char[] front() @property Char[] front()
{ {
if (line is null) popFront(); if (line is null) popFront();
return line; return line;
@ -945,7 +945,7 @@ Range that reads one line at a time. */
file.readln(line, terminator); file.readln(line, terminator);
assert(line !is null, "Bug in File.readln"); assert(line !is null, "Bug in File.readln");
if (!line.length) if (!line.length)
file.detach; file.detach();
else if (keepTerminator == KeepTerminator.no else if (keepTerminator == KeepTerminator.no
&& std.algorithm.endsWith(line, terminator)) && std.algorithm.endsWith(line, terminator))
line.length = line.length - 1; line.length = line.length - 1;
@ -974,7 +974,7 @@ to this file. */
auto f = File("testingByLine"); auto f = File("testingByLine");
scope(exit) scope(exit)
{ {
f.close; f.close();
assert(!f.isOpen); assert(!f.isOpen);
} }
foreach (line; f.byLine()) foreach (line; f.byLine())
@ -983,7 +983,7 @@ to this file. */
} }
assert(i == witness.length); assert(i == witness.length);
i = 0; i = 0;
f.rewind; f.rewind();
foreach (line; f.byLine(KeepTerminator.yes)) foreach (line; f.byLine(KeepTerminator.yes))
{ {
assert(line == witness[i++] ~ '\n' || i == witness.length); assert(line == witness[i++] ~ '\n' || i == witness.length);
@ -1005,7 +1005,7 @@ to this file. */
// std.file.write("deleteme", "1 2\n4 1\n5 100"); // std.file.write("deleteme", "1 2\n4 1\n5 100");
// scope(exit) std.file.remove("deleteme"); // scope(exit) std.file.remove("deleteme");
// File f = File("deleteme"); // File f = File("deleteme");
// scope(exit) f.close; // scope(exit) f.close();
// auto t = [ tuple(1, 2), tuple(4, 1), tuple(5, 100) ]; // auto t = [ tuple(1, 2), tuple(4, 1), tuple(5, 100) ];
// uint i; // uint i;
// foreach (e; f.byRecord!(int, int)("%s %s")) // foreach (e; f.byRecord!(int, int)("%s %s"))
@ -1105,7 +1105,7 @@ In case of an I/O error, an $(D StdioException) is thrown.
auto f = File("testingByChunk"); auto f = File("testingByChunk");
scope(exit) scope(exit)
{ {
f.close; f.close();
assert(!f.isOpen); assert(!f.isOpen);
std.file.remove("testingByChunk"); std.file.remove("testingByChunk");
} }
@ -1255,7 +1255,7 @@ $(D Range) that locks the file and allows fast writing to it.
} }
/// Convenience function. /// Convenience function.
LockingTextWriter lockingTextWriter() @property LockingTextWriter lockingTextWriter()
{ {
return LockingTextWriter(this); return LockingTextWriter(this);
} }
@ -1327,7 +1327,7 @@ struct LockingTextReader
return false; return false;
} }
dchar front() @property dchar front()
{ {
enforce(!empty); enforce(!empty);
return _crt; return _crt;
@ -1463,7 +1463,7 @@ unittest
auto f = File(file, "w"); auto f = File(file, "w");
// scope(exit) { std.file.remove(file); } // scope(exit) { std.file.remove(file); }
f.write("Hello, ", "world number ", 42, "!"); f.write("Hello, ", "world number ", 42, "!");
f.close; f.close();
assert(cast(char[]) std.file.read(file) == "Hello, world number 42!"); assert(cast(char[]) std.file.read(file) == "Hello, world number 42!");
// // test write on stdout // // test write on stdout
//auto saveStdout = stdout; //auto saveStdout = stdout;
@ -1471,7 +1471,7 @@ unittest
//stdout.open(file, "w"); //stdout.open(file, "w");
Object obj; Object obj;
//write("Hello, ", "world number ", 42, "! ", obj); //write("Hello, ", "world number ", 42, "! ", obj);
//stdout.close; //stdout.close();
// auto result = cast(char[]) std.file.read(file); // auto result = cast(char[]) std.file.read(file);
// assert(result == "Hello, world number 42! null", result); // assert(result == "Hello, world number 42! null", result);
} }
@ -1521,7 +1521,7 @@ unittest
auto f = File(file, "w"); auto f = File(file, "w");
scope(exit) { std.file.remove(file); } scope(exit) { std.file.remove(file); }
f.writeln("Hello, ", "world number ", 42, "!"); f.writeln("Hello, ", "world number ", 42, "!");
f.close; f.close();
version (Windows) version (Windows)
assert(cast(char[]) std.file.read(file) == assert(cast(char[]) std.file.read(file) ==
"Hello, world number 42!\r\n"); "Hello, world number 42!\r\n");
@ -1533,7 +1533,7 @@ unittest
scope(exit) stdout = saveStdout; scope(exit) stdout = saveStdout;
stdout.open(file, "w"); stdout.open(file, "w");
writeln("Hello, ", "world number ", 42, "!"); writeln("Hello, ", "world number ", 42, "!");
stdout.close; stdout.close();
version (Windows) version (Windows)
assert(cast(char[]) std.file.read(file) == assert(cast(char[]) std.file.read(file) ==
"Hello, world number 42!\r\n"); "Hello, world number 42!\r\n");
@ -1598,14 +1598,14 @@ unittest
auto f = File(file, "w"); auto f = File(file, "w");
scope(exit) { std.file.remove(file); } scope(exit) { std.file.remove(file); }
f.writef("Hello, %s world number %s!", "nice", 42); f.writef("Hello, %s world number %s!", "nice", 42);
f.close; f.close();
assert(cast(char[]) std.file.read(file) == "Hello, nice world number 42!"); assert(cast(char[]) std.file.read(file) == "Hello, nice world number 42!");
// test write on stdout // test write on stdout
auto saveStdout = stdout; auto saveStdout = stdout;
scope(exit) stdout = saveStdout; scope(exit) stdout = saveStdout;
stdout.open(file, "w"); stdout.open(file, "w");
writef("Hello, %s world number %s!", "nice", 42); writef("Hello, %s world number %s!", "nice", 42);
stdout.close; stdout.close();
assert(cast(char[]) std.file.read(file) == "Hello, nice world number 42!"); assert(cast(char[]) std.file.read(file) == "Hello, nice world number 42!");
} }
@ -1626,7 +1626,7 @@ unittest
auto f = File(file, "w"); auto f = File(file, "w");
scope(exit) { std.file.remove(file); } scope(exit) { std.file.remove(file); }
f.writefln("Hello, %s world number %s!", "nice", 42); f.writefln("Hello, %s world number %s!", "nice", 42);
f.close; f.close();
version (Windows) version (Windows)
assert(cast(char[]) std.file.read(file) == assert(cast(char[]) std.file.read(file) ==
"Hello, nice world number 42!\r\n"); "Hello, nice world number 42!\r\n");
@ -1646,7 +1646,7 @@ unittest
// F b = a % 2; // F b = a % 2;
// writeln(b); // writeln(b);
// } // }
// stdout.close; // stdout.close();
// auto read = cast(char[]) std.file.read(file); // auto read = cast(char[]) std.file.read(file);
// version (Windows) // version (Windows)
// assert(read == "Hello, nice world number 42!\r\n1\r\n1\r\n1\r\n", read); // assert(read == "Hello, nice world number 42!\r\n1\r\n1\r\n1\r\n", read);
@ -1916,7 +1916,7 @@ unittest
{ {
assert(false); assert(false);
} }
f.close; f.close();
// test looping with a file with three lines // test looping with a file with three lines
std.file.write(file, "Line one\nline two\nline three\n"); std.file.write(file, "Line one\nline two\nline three\n");
@ -1930,7 +1930,7 @@ unittest
else assert(false); else assert(false);
++i; ++i;
} }
f.close; f.close();
// test looping with a file with three lines, last without a newline // test looping with a file with three lines, last without a newline
std.file.write(file, "Line one\nline two\nline three"); std.file.write(file, "Line one\nline two\nline three");
@ -1944,7 +1944,7 @@ unittest
else assert(false); else assert(false);
++i; ++i;
} }
f.close; f.close();
} }
// test with ubyte[] inputs // test with ubyte[] inputs
@ -1959,7 +1959,7 @@ unittest
{ {
assert(false); assert(false);
} }
f.close; f.close();
// test looping with a file with three lines // test looping with a file with three lines
std.file.write(file, "Line one\nline two\nline three\n"); std.file.write(file, "Line one\nline two\nline three\n");
@ -1974,7 +1974,7 @@ unittest
else assert(false); else assert(false);
++i; ++i;
} }
f.close; f.close();
// test looping with a file with three lines, last without a newline // test looping with a file with three lines, last without a newline
std.file.write(file, "Line one\nline two\nline three"); std.file.write(file, "Line one\nline two\nline three");
@ -1988,7 +1988,7 @@ unittest
else assert(false); else assert(false);
++i; ++i;
} }
f.close; f.close();
} }
@ -2007,7 +2007,7 @@ unittest
else assert(false); else assert(false);
++i; ++i;
} }
f.close; f.close();
} }
} }
@ -2106,7 +2106,7 @@ unittest
{ {
assert(false); assert(false);
} }
f.close; f.close();
// test looping with a file with three lines // test looping with a file with three lines
std.file.write(file, "Line one\nline two\nline three\n"); std.file.write(file, "Line one\nline two\nline three\n");
@ -2120,7 +2120,7 @@ unittest
else break; else break;
++i; ++i;
} }
f.close; f.close();
} }
/********************* /*********************
@ -2133,7 +2133,7 @@ class StdioException : Exception
/** /**
Initialize with a message and an error code. */ Initialize with a message and an error code. */
this(string message, uint e = .getErrno) this(string message, uint e = .getErrno())
{ {
errno = e; errno = e;
version (Posix) version (Posix)
@ -2166,7 +2166,7 @@ Initialize with a message and an error code. */
/// ditto /// ditto
static void opCall() static void opCall()
{ {
throw new StdioException(null, .getErrno); throw new StdioException(null, .getErrno());
} }
} }
@ -2201,7 +2201,7 @@ unittest
scope(exit) std.file.remove("deleteme"); scope(exit) std.file.remove("deleteme");
{ {
File f = File("deleteme"); File f = File("deleteme");
scope(exit) f.close; scope(exit) f.close();
auto t = [ tuple(1, 2), tuple(4, 1), tuple(5, 100) ]; auto t = [ tuple(1, 2), tuple(4, 1), tuple(5, 100) ];
uint i; uint i;
foreach (e; f.byRecord!(int, int)("%s %s")) foreach (e; f.byRecord!(int, int)("%s %s"))

View file

@ -235,7 +235,7 @@ interface InputStream {
int readf(...); /// ditto int readf(...); /// ditto
/// Retrieve the number of bytes available for immediate reading. /// Retrieve the number of bytes available for immediate reading.
size_t available(); @property size_t available();
/*** /***
* Return whether the current file position is the same as the end of the * Return whether the current file position is the same as the end of the
@ -248,7 +248,7 @@ interface InputStream {
bool eof(); bool eof();
bool isOpen(); /// Return true if the stream is currently open. @property bool isOpen(); /// Return true if the stream is currently open.
} }
/// Interface for writable streams. /// Interface for writable streams.
@ -354,7 +354,7 @@ interface OutputStream {
void flush(); /// Flush pending output if appropriate. void flush(); /// Flush pending output if appropriate.
void close(); /// Close the stream, flushing output if appropriate. void close(); /// Close the stream, flushing output if appropriate.
bool isOpen(); /// Return true if the stream is currently open. @property bool isOpen(); /// Return true if the stream is currently open.
} }
@ -1029,7 +1029,7 @@ class Stream : InputStream, OutputStream {
} }
// returns estimated number of bytes available for immediate reading // returns estimated number of bytes available for immediate reading
size_t available() { return 0; } @property size_t available() { return 0; }
/*** /***
* Write up to size bytes from buffer in the stream, returning the actual * Write up to size bytes from buffer in the stream, returning the actual
@ -1198,9 +1198,9 @@ class Stream : InputStream, OutputStream {
*/ */
void copyFrom(Stream s) { void copyFrom(Stream s) {
if (seekable) { if (seekable) {
ulong pos = s.position(); ulong pos = s.position;
s.position(0); s.position(0);
copyFrom(s, s.size()); copyFrom(s, s.size);
s.position(pos); s.position(pos);
} else { } else {
ubyte[128] buf; ubyte[128] buf;
@ -1246,37 +1246,37 @@ class Stream : InputStream, OutputStream {
/*** /***
* Sets file position. Equivalent to calling seek(pos, SeekPos.Set). * Sets file position. Equivalent to calling seek(pos, SeekPos.Set).
*/ */
void position(ulong pos) { seek(cast(long)pos, SeekPos.Set); } @property void position(ulong pos) { seek(cast(long)pos, SeekPos.Set); }
/*** /***
* Returns current file position. Equivalent to seek(0, SeekPos.Current). * Returns current file position. Equivalent to seek(0, SeekPos.Current).
*/ */
ulong position() { return seek(0, SeekPos.Current); } @property ulong position() { return seek(0, SeekPos.Current); }
/*** /***
* Retrieve the size of the stream in bytes. * Retrieve the size of the stream in bytes.
* The stream must be seekable or a SeekException is thrown. * The stream must be seekable or a SeekException is thrown.
*/ */
ulong size() { @property ulong size() {
assertSeekable(); assertSeekable();
ulong pos = position(), result = seek(0, SeekPos.End); ulong pos = position, result = seek(0, SeekPos.End);
position(pos); position(pos);
return result; return result;
} }
// returns true if end of stream is reached, false otherwise // returns true if end of stream is reached, false otherwise
bool eof() { @property bool eof() {
// for unseekable streams we only know the end when we read it // for unseekable streams we only know the end when we read it
if (readEOF && !ungetAvailable()) if (readEOF && !ungetAvailable())
return true; return true;
else if (seekable) else if (seekable)
return position() == size(); return position == size;
else else
return false; return false;
} }
// returns true if the stream is open // returns true if the stream is open
bool isOpen() { return isopen; } @property bool isOpen() { return isopen; }
// flush the buffer if writeable // flush the buffer if writeable
void flush() { void flush() {
@ -1304,9 +1304,9 @@ class Stream : InputStream, OutputStream {
size_t blockSize; size_t blockSize;
char[] result; char[] result;
if (seekable) { if (seekable) {
ulong orig_pos = position(); ulong orig_pos = position;
position(0); position(0);
blockSize = cast(size_t)size(); blockSize = cast(size_t)size;
result = new char[blockSize]; result = new char[blockSize];
while (blockSize > 0) { while (blockSize > 0) {
rdlen = readBlock(&result[pos], blockSize); rdlen = readBlock(&result[pos], blockSize);
@ -1333,10 +1333,10 @@ class Stream : InputStream, OutputStream {
override size_t toHash() { override size_t toHash() {
if (!readable || !seekable) if (!readable || !seekable)
return super.toHash(); return super.toHash();
ulong pos = position(); ulong pos = position;
uint crc = init_crc32 (); uint crc = init_crc32 ();
position(0); position(0);
ulong len = size(); ulong len = size;
for (ulong i = 0; i < len; i++) { for (ulong i = 0; i < len; i++) {
ubyte c; ubyte c;
read(c); read(c);
@ -1419,7 +1419,7 @@ class FilterStream : Stream {
readable = s.readable; readable = s.readable;
writeable = s.writeable; writeable = s.writeable;
seekable = s.seekable; seekable = s.seekable;
isopen = s.isOpen(); isopen = s.isOpen;
} else { } else {
readable = writeable = seekable = false; readable = writeable = seekable = false;
isopen = false; isopen = false;
@ -1454,7 +1454,7 @@ class FilterStream : Stream {
return s.seek(offset,whence); return s.seek(offset,whence);
} }
override size_t available () { return s.available(); } override @property size_t available() { return s.available; }
override void flush() { super.flush(); s.flush(); } override void flush() { super.flush(); s.flush(); }
} }
@ -1744,13 +1744,13 @@ class BufferedStream : FilterStream {
} }
// returns size of stream // returns size of stream
override ulong size() { override @property ulong size() {
if (bufferDirty) flush(); if (bufferDirty) flush();
return s.size(); return s.size;
} }
// returns estimated number of bytes available for immediate reading // returns estimated number of bytes available for immediate reading
override size_t available() { override @property size_t available() {
return bufferLen - bufferCurPos; return bufferLen - bufferCurPos;
} }
} }
@ -1943,7 +1943,7 @@ class File: Stream {
version (Win32) { version (Win32) {
// returns size of stream // returns size of stream
override ulong size() { override @property ulong size() {
assertSeekable(); assertSeekable();
uint sizehi; uint sizehi;
uint sizelow = GetFileSize(hFile,&sizehi); uint sizelow = GetFileSize(hFile,&sizehi);
@ -2002,7 +2002,7 @@ class File: Stream {
* otherwise returns 0. * otherwise returns 0.
*/ */
override size_t available() { override @property size_t available() {
if (seekable) { if (seekable) {
ulong lavail = size - position; ulong lavail = size - position;
if (lavail > size_t.max) lavail = size_t.max; if (lavail > size_t.max) lavail = size_t.max;
@ -2027,9 +2027,9 @@ class File: Stream {
file.write(i); file.write(i);
// string#1 + string#2 + int should give exacly that // string#1 + string#2 + int should give exacly that
version (Win32) version (Win32)
assert(file.position() == 19 + 13 + 4); assert(file.position == 19 + 13 + 4);
version (Posix) version (Posix)
assert(file.position() == 18 + 13 + 4); assert(file.position == 18 + 13 + 4);
// we must be at the end of file // we must be at the end of file
assert(file.eof()); assert(file.eof());
file.close(); file.close();
@ -2047,17 +2047,17 @@ class File: Stream {
// jump over "Hello, " // jump over "Hello, "
file.seek(7, SeekPos.Current); file.seek(7, SeekPos.Current);
version (Win32) version (Win32)
assert(file.position() == 19 + 7); assert(file.position == 19 + 7);
version (Posix) version (Posix)
assert(file.position() == 18 + 7); assert(file.position == 18 + 7);
assert(!std.string.cmp(file.readString(6), "world!")); assert(!std.string.cmp(file.readString(6), "world!"));
i = 0; file.read(i); i = 0; file.read(i);
assert(i == 666); assert(i == 666);
// string#1 + string#2 + int should give exacly that // string#1 + string#2 + int should give exacly that
version (Win32) version (Win32)
assert(file.position() == 19 + 13 + 4); assert(file.position == 19 + 13 + 4);
version (Posix) version (Posix)
assert(file.position() == 18 + 13 + 4); assert(file.position == 18 + 13 + 4);
// we must be at the end of file // we must be at the end of file
assert(file.eof()); assert(file.eof());
file.close(); file.close();
@ -2144,37 +2144,37 @@ class BufferedFile: BufferedStream {
file.write(i); file.write(i);
// string#1 + string#2 + int should give exacly that // string#1 + string#2 + int should give exacly that
version (Win32) version (Win32)
assert(file.position() == 19 + 13 + 4); assert(file.position == 19 + 13 + 4);
version (Posix) version (Posix)
assert(file.position() == 18 + 13 + 4); assert(file.position == 18 + 13 + 4);
// we must be at the end of file // we must be at the end of file
assert(file.eof()); assert(file.eof());
long oldsize = cast(long)file.size(); long oldsize = cast(long)file.size;
file.close(); file.close();
// no operations are allowed when file is closed // no operations are allowed when file is closed
assert(!file.readable && !file.writeable && !file.seekable); assert(!file.readable && !file.writeable && !file.seekable);
file.open("stream.$$$"); file.open("stream.$$$");
// should be ok to read // should be ok to read
assert(file.readable); assert(file.readable);
// test getc/ungetc and size() // test getc/ungetc and size
char c1 = file.getc(); char c1 = file.getc();
file.ungetc(c1); file.ungetc(c1);
assert( file.size() == oldsize ); assert( file.size == oldsize );
assert(!std.string.cmp(file.readLine(), "Testing stream.d:")); assert(!std.string.cmp(file.readLine(), "Testing stream.d:"));
// jump over "Hello, " // jump over "Hello, "
file.seek(7, SeekPos.Current); file.seek(7, SeekPos.Current);
version (Win32) version (Win32)
assert(file.position() == 19 + 7); assert(file.position == 19 + 7);
version (Posix) version (Posix)
assert(file.position() == 18 + 7); assert(file.position == 18 + 7);
assert(!std.string.cmp(file.readString(6), "world!")); assert(!std.string.cmp(file.readString(6), "world!"));
i = 0; file.read(i); i = 0; file.read(i);
assert(i == 666); assert(i == 666);
// string#1 + string#2 + int should give exacly that // string#1 + string#2 + int should give exacly that
version (Win32) version (Win32)
assert(file.position() == 19 + 13 + 4); assert(file.position == 19 + 13 + 4);
version (Posix) version (Posix)
assert(file.position() == 18 + 13 + 4); assert(file.position == 18 + 13 + 4);
// we must be at the end of file // we must be at the end of file
assert(file.eof()); assert(file.eof());
file.close(); file.close();
@ -2420,7 +2420,7 @@ class EndianStream : FilterStream {
} }
override bool eof() { return s.eof() && !ungetAvailable(); } override bool eof() { return s.eof() && !ungetAvailable(); }
override ulong size() { return s.size(); } override @property ulong size() { return s.size; }
unittest { unittest {
MemoryStream m; MemoryStream m;
@ -2477,15 +2477,15 @@ class EndianStream : FilterStream {
assert( x3[11] == 1 ); assert( x3[11] == 1 );
} }
em.writeBOM(BOM.UTF8); em.writeBOM(BOM.UTF8);
assert( m.position() == 3 ); assert( m.position == 3 );
assert( m.data[0] == 0xEF ); assert( m.data[0] == 0xEF );
assert( m.data[1] == 0xBB ); assert( m.data[1] == 0xBB );
assert( m.data[2] == 0xBF ); assert( m.data[2] == 0xBF );
em.writeString ("Hello, world"); em.writeString ("Hello, world");
em.position(0); em.position(0);
assert( m.position() == 0 ); assert( m.position == 0 );
assert( em.readBOM == BOM.UTF8 ); assert( em.readBOM() == BOM.UTF8 );
assert( m.position() == 3 ); assert( m.position == 3 );
assert( em.getc() == 'H' ); assert( em.getc() == 'H' );
em.position(0); em.position(0);
em.writeBOM(BOM.UTF16BE); em.writeBOM(BOM.UTF16BE);
@ -2498,7 +2498,7 @@ class EndianStream : FilterStream {
em.position(0); em.position(0);
em.writeString ("Hello, world"); em.writeString ("Hello, world");
em.position(0); em.position(0);
assert( em.readBOM == -1 ); assert( em.readBOM() == -1 );
assert( em.getc() == 'H' ); assert( em.getc() == 'H' );
assert( em.getc() == 'e' ); assert( em.getc() == 'e' );
assert( em.getc() == 'l' ); assert( em.getc() == 'l' );
@ -2581,10 +2581,10 @@ class TArrayStream(Buffer): Stream {
return cur; return cur;
} }
override size_t available () { return cast(size_t)(len - cur); } override @property size_t available () { return cast(size_t)(len - cur); }
/// Get the current memory data in total. /// Get the current memory data in total.
ubyte[] data() { @property ubyte[] data() {
if (len > size_t.max) if (len > size_t.max)
throw new StreamException("Stream too big"); throw new StreamException("Stream too big");
const(void)[] res = buf[0 .. cast(size_t)len]; const(void)[] res = buf[0 .. cast(size_t)len];
@ -2593,7 +2593,7 @@ class TArrayStream(Buffer): Stream {
override string toString() { override string toString() {
// assume data is UTF8 // assume data is UTF8
return to!(string)(cast(char[]) data); return to!(string)(cast(char[])data);
} }
} }
@ -2613,14 +2613,14 @@ unittest {
assert (m.available == 96); assert (m.available == 96);
assert (m.seekEnd (-8) == 92); assert (m.seekEnd (-8) == 92);
assert (m.available == 8); assert (m.available == 8);
assert (m.size () == 100); assert (m.size == 100);
assert (m.seekSet (4) == 4); assert (m.seekSet (4) == 4);
assert (m.readString (4) == "o, w"); assert (m.readString (4) == "o, w");
m.writeString ("ie"); m.writeString ("ie");
assert (buf[0..12] == "Hello, wield"); assert (buf[0..12] == "Hello, wield");
assert (m.position == 10); assert (m.position == 10);
assert (m.available == 90); assert (m.available == 90);
assert (m.size () == 100); assert (m.size == 100);
} }
/// This subclass reads and constructs an array of bytes in memory. /// This subclass reads and constructs an array of bytes in memory.
@ -2662,7 +2662,7 @@ class MemoryStream: TArrayStream!(ubyte[]) {
assert (m.available == 8); assert (m.available == 8);
assert (m.seekEnd (-8) == 4); assert (m.seekEnd (-8) == 4);
assert (m.available == 8); assert (m.available == 8);
assert (m.size () == 12); assert (m.size == 12);
assert (m.readString (4) == "o, w"); assert (m.readString (4) == "o, w");
m.writeString ("ie"); m.writeString ("ie");
assert (cast(char[]) m.data () == "Hello, wield"); assert (cast(char[]) m.data () == "Hello, wield");
@ -2675,7 +2675,7 @@ class MemoryStream: TArrayStream!(ubyte[]) {
m.position = 0; m.position = 0;
assert (m.available == 42); assert (m.available == 42);
m.writef("%d %d %s",100,345,"hello"); m.writef("%d %d %s",100,345,"hello");
auto str = m.toString; auto str = m.toString();
assert (str[0..13] == "100 345 hello", str[0 .. 13]); assert (str[0..13] == "100 345 hello", str[0 .. 13]);
assert (m.available == 29); assert (m.available == 29);
assert (m.position == 13); assert (m.position == 13);
@ -2685,12 +2685,12 @@ class MemoryStream: TArrayStream!(ubyte[]) {
m2 = new MemoryStream (); m2 = new MemoryStream ();
m2.writeString("before"); m2.writeString("before");
m2.copyFrom(m,10); m2.copyFrom(m,10);
str = m2.toString; str = m2.toString();
assert (str[0..16] == "before 345 hello"); assert (str[0..16] == "before 345 hello");
m2.position = 3; m2.position = 3;
m2.copyFrom(m); m2.copyFrom(m);
auto str2 = m.toString; auto str2 = m.toString();
str = m2.toString; str = m2.toString();
assert (str == ("bef" ~ str2)); assert (str == ("bef" ~ str2));
} }
} }
@ -2706,7 +2706,7 @@ class MmFileStream : TArrayStream!(MmFile) {
/// Create stream wrapper for file. /// Create stream wrapper for file.
this(MmFile file) { this(MmFile file) {
super (file); super (file);
MmFile.Mode mode = file.mode; MmFile.Mode mode = file.mode();
writeable = mode > MmFile.Mode.read; writeable = mode > MmFile.Mode.read;
} }
@ -2735,7 +2735,7 @@ unittest {
assert (m.seekSet (0) == 0); assert (m.seekSet (0) == 0);
assert (m.seekCur (4) == 4); assert (m.seekCur (4) == 4);
assert (m.seekEnd (-8) == 92); assert (m.seekEnd (-8) == 92);
assert (m.size () == 100); assert (m.size == 100);
assert (m.seekSet (4)); assert (m.seekSet (4));
assert (m.readString (4) == "o, w"); assert (m.readString (4) == "o, w");
m.writeString ("ie"); m.writeString ("ie");
@ -2783,7 +2783,7 @@ class SliceStream : FilterStream {
*/ */
this (Stream s, ulong low) this (Stream s, ulong low)
in { in {
assert (low <= s.size ()); assert (low <= s.size);
} }
body { body {
super(s); super(s);
@ -2801,7 +2801,7 @@ class SliceStream : FilterStream {
this (Stream s, ulong low, ulong high) this (Stream s, ulong low, ulong high)
in { in {
assert (low <= high); assert (low <= high);
assert (high <= s.size ()); assert (high <= s.size);
} }
body { body {
super(s); super(s);
@ -2881,7 +2881,7 @@ class SliceStream : FilterStream {
return pos; return pos;
} }
override size_t available () { override @property size_t available() {
size_t res = s.available; size_t res = s.available;
ulong bp = s.position; ulong bp = s.position;
if (bp <= pos+low && pos+low <= bp+res) { if (bp <= pos+low && pos+low <= bp+res) {
@ -2899,7 +2899,7 @@ class SliceStream : FilterStream {
m = new MemoryStream ((cast(char[])"Hello, world").dup); m = new MemoryStream ((cast(char[])"Hello, world").dup);
s = new SliceStream (m, 4, 8); s = new SliceStream (m, 4, 8);
assert (s.size () == 4); assert (s.size == 4);
assert (m.position () == 0); assert (m.position () == 0);
assert (s.position () == 0); assert (s.position () == 0);
assert (m.available == 12); assert (m.available == 12);
@ -2925,7 +2925,7 @@ class SliceStream : FilterStream {
assert (s.available == 0); assert (s.available == 0);
s = new SliceStream (m, 4); s = new SliceStream (m, 4);
assert (s.size () == 14); assert (s.size == 14);
assert (s.toString () == "Vrooorld\nBlaho"); assert (s.toString () == "Vrooorld\nBlaho");
s.seekEnd (0); s.seekEnd (0);
assert (s.available == 0); assert (s.available == 0);
@ -2933,9 +2933,9 @@ class SliceStream : FilterStream {
s.writeString (", etcetera."); s.writeString (", etcetera.");
assert (s.position () == 25); assert (s.position () == 25);
assert (s.seekSet (0) == 0); assert (s.seekSet (0) == 0);
assert (s.size () == 25); assert (s.size == 25);
assert (m.position () == 18); assert (m.position () == 18);
assert (m.size () == 29); assert (m.size == 29);
assert (m.toString() == "HellVrooorld\nBlaho, etcetera."); assert (m.toString() == "HellVrooorld\nBlaho, etcetera.");
} }
} }

View file

@ -2873,7 +2873,7 @@ unittest {
struct Range struct Range
{ {
uint front() { assert(0); } @property uint front() { assert(0); }
void popFront() { assert(0); } void popFront() { assert(0); }
enum bool empty = false; enum bool empty = false;
} }

View file

@ -550,7 +550,7 @@ unittest
nosh[0] = 5; nosh[0] = 5;
nosh[1] = 0; nosh[1] = 0;
assert(nosh[0] == 5 && nosh[1] == 0); assert(nosh[0] == 5 && nosh[1] == 0);
assert(nosh.toString == "Tuple!(int,real)(5, 0)", nosh.toString); assert(nosh.toString() == "Tuple!(int,real)(5, 0)", nosh.toString());
Tuple!(int, int) yessh; Tuple!(int, int) yessh;
nosh = yessh; nosh = yessh;
} }
@ -559,7 +559,7 @@ unittest
t[0] = 10; t[0] = 10;
t[1] = "str"; t[1] = "str";
assert(t[0] == 10 && t[1] == "str"); assert(t[0] == 10 && t[1] == "str");
assert(t.toString == `Tuple!(int,string)(10, "str")`, t.toString); assert(t.toString() == `Tuple!(int,string)(10, "str")`, t.toString());
} }
{ {
Tuple!(int, "a", double, "b") x; Tuple!(int, "a", double, "b") x;
@ -973,7 +973,10 @@ Rebindable!(T) rebindable(T)(Rebindable!(T) obj)
unittest unittest
{ {
interface CI { const int foo(); } interface CI { const int foo(); }
class C : CI { int foo() const { return 42; } } class C : CI {
int foo() const { return 42; }
@property int bar() const { return 23; }
}
Rebindable!(C) obj0; Rebindable!(C) obj0;
static assert(is(typeof(obj0) == C)); static assert(is(typeof(obj0) == C));
@ -992,7 +995,8 @@ unittest
assert(obj1.get !is null); assert(obj1.get !is null);
// test opDot // test opDot
assert(obj2.foo == 42); assert(obj2.foo() == 42);
assert(obj2.bar == 23);
interface I { final int foo() const { return 42; } } interface I { final int foo() const { return 42; } }
Rebindable!(I) obj3; Rebindable!(I) obj3;
@ -1017,16 +1021,16 @@ unittest
auto obj6 = rebindable(new immutable(C)); auto obj6 = rebindable(new immutable(C));
static assert(is(typeof(obj6) == Rebindable!(immutable C))); static assert(is(typeof(obj6) == Rebindable!(immutable C)));
assert(obj6.foo == 42); assert(obj6.foo() == 42);
auto obj7 = rebindable(new C); auto obj7 = rebindable(new C);
CI interface1 = obj7; CI interface1 = obj7;
auto interfaceRebind1 = rebindable(interface1); auto interfaceRebind1 = rebindable(interface1);
assert(interfaceRebind1.foo == 42); assert(interfaceRebind1.foo() == 42);
const interface2 = interface1; const interface2 = interface1;
auto interfaceRebind2 = rebindable(interface2); auto interfaceRebind2 = rebindable(interface2);
assert(interfaceRebind2.foo == 42); assert(interfaceRebind2.foo() == 42);
auto arr = [1,2,3,4,5]; auto arr = [1,2,3,4,5];
const arrConst = arr; const arrConst = arr;
@ -1108,7 +1112,7 @@ struct Ref(T)
this(ref T value) { _p = &value; } this(ref T value) { _p = &value; }
ref T opDot() { return *_p; } ref T opDot() { return *_p; }
/*ref*/ T opImplicitCastTo() { return *_p; } /*ref*/ T opImplicitCastTo() { return *_p; }
ref T value() { return *_p; } @property ref T value() { return *_p; }
void opAssign(T value) void opAssign(T value)
{ {
@ -2753,7 +2757,7 @@ unittest
class A { static bool dead; ~this() { dead = true; } } class A { static bool dead; ~this() { dead = true; } }
class B : A { static bool dead; ~this() { dead = true; } } class B : A { static bool dead; ~this() { dead = true; } }
{ {
auto b = scoped!B; auto b = scoped!B();
} }
assert(B.dead, "asdasd"); assert(B.dead, "asdasd");
assert(A.dead, "asdasd"); assert(A.dead, "asdasd");
@ -2770,7 +2774,7 @@ unittest
bool check() { return this is a; } bool check() { return this is a; }
} }
auto a1 = scoped!A; auto a1 = scoped!A();
assert(a1.check()); assert(a1.check());
auto a2 = scoped!A(1); auto a2 = scoped!A(1);

View file

@ -380,9 +380,9 @@ private:
// TODO: The following test evaluates to true for shared objects. // TODO: The following test evaluates to true for shared objects.
// Use __traits for now until this is sorted out. // Use __traits for now until this is sorted out.
// else static if (is(typeof((*zis).toString))) // else static if (is(typeof((*zis).toString)))
else static if (__traits(compiles, {(*zis).toString;})) else static if (__traits(compiles, {(*zis).toString();}))
{ {
*target = (*zis).toString; *target = (*zis).toString();
break; break;
} }
else else
@ -560,7 +560,7 @@ public:
* ---- * ----
*/ */
bool hasValue() const @property bool hasValue() const
{ {
// @@@BUG@@@ in compiler, the cast shouldn't be needed // @@@BUG@@@ in compiler, the cast shouldn't be needed
return cast(typeof(&handler!(void))) fptr != &handler!(void); return cast(typeof(&handler!(void))) fptr != &handler!(void);
@ -582,7 +582,7 @@ public:
* assert(a == 6); * assert(a == 6);
* ---- * ----
*/ */
T * peek(T)() @property T * peek(T)()
{ {
static if (!is(T == void)) static if (!is(T == void))
static assert(allowed!(T), "Cannot store a " ~ T.stringof static assert(allowed!(T), "Cannot store a " ~ T.stringof
@ -594,7 +594,7 @@ public:
* Returns the $(D_PARAM typeid) of the currently held value. * Returns the $(D_PARAM typeid) of the currently held value.
*/ */
TypeInfo type() const @property TypeInfo type() const
{ {
TypeInfo result; TypeInfo result;
fptr(OpID.getTypeInfo, null, &result); fptr(OpID.getTypeInfo, null, &result);
@ -608,7 +608,7 @@ public:
* $(LINK2 std_traits.html#ImplicitConversionTargets,ImplicitConversionTargets). * $(LINK2 std_traits.html#ImplicitConversionTargets,ImplicitConversionTargets).
*/ */
bool convertsTo(T)() @property bool convertsTo(T)()
{ {
TypeInfo info = typeid(T); TypeInfo info = typeid(T);
return fptr(OpID.testConversion, null, &info) == 0; return fptr(OpID.testConversion, null, &info) == 0;
@ -648,7 +648,7 @@ public:
* VariantException). * VariantException).
*/ */
T get(T)() if (!is(T == const)) @property T get(T)() if (!is(T == const))
{ {
union Buf union Buf
{ {
@ -664,7 +664,7 @@ public:
return buf.result; return buf.result;
} }
T get(T)() const if (is(T == const)) @property T get(T)() const if (is(T == const))
{ {
union Buf union Buf
{ {
@ -690,7 +690,7 @@ public:
* VariantException). * VariantException).
*/ */
T coerce(T)() @property T coerce(T)()
{ {
static if (isNumeric!(T)) static if (isNumeric!(T))
{ {
@ -716,7 +716,7 @@ public:
} }
else static if (isSomeString!(T)) else static if (isSomeString!(T))
{ {
return to!(T)(toString); return to!(T)(toString());
} }
else else
{ {
@ -1168,8 +1168,8 @@ static class VariantException : Exception
this(TypeInfo source, TypeInfo target) this(TypeInfo source, TypeInfo target)
{ {
super("Variant: attempting to use incompatible types " super("Variant: attempting to use incompatible types "
~ source.toString ~ source.toString()
~ " and " ~ target.toString); ~ " and " ~ target.toString());
this.source = source; this.source = source;
this.target = target; this.target = target;
} }
@ -1230,7 +1230,7 @@ unittest
// assign // assign
a = *b.peek!(int); a = *b.peek!(int);
// comparison // comparison
assert(a == b, a.type.toString ~ " " ~ b.type.toString); assert(a == b, a.type.toString() ~ " " ~ b.type.toString());
auto c = Variant("this is a string"); auto c = Variant("this is a string");
assert(a != c); assert(a != c);
// comparison via implicit conversions // comparison via implicit conversions
@ -1250,8 +1250,8 @@ unittest
assert(failed); // :o) assert(failed); // :o)
// toString tests // toString tests
a = Variant(42); assert(a.toString == "42"); a = Variant(42); assert(a.toString() == "42");
a = Variant(42.22); assert(a.toString == "42.22"); a = Variant(42.22); assert(a.toString() == "42.22");
// coerce tests // coerce tests
a = Variant(42.22); assert(a.coerce!(int) == 42); a = Variant(42.22); assert(a.coerce!(int) == 42);
@ -1272,7 +1272,7 @@ unittest
// a = Big.init; // a = Big.init;
// hash // hash
assert(a.toHash != 0); assert(a.toHash() != 0);
} }
// tests adapted from // tests adapted from

View file

@ -73,12 +73,12 @@ void main()
Book book; Book book;
book.id = xml.tag.attr["id"]; book.id = xml.tag.attr["id"];
xml.onEndTag["author"] = (in Element e) { book.author = e.text; }; xml.onEndTag["author"] = (in Element e) { book.author = e.text(); };
xml.onEndTag["title"] = (in Element e) { book.title = e.text; }; xml.onEndTag["title"] = (in Element e) { book.title = e.text(); };
xml.onEndTag["genre"] = (in Element e) { book.genre = e.text; }; xml.onEndTag["genre"] = (in Element e) { book.genre = e.text(); };
xml.onEndTag["price"] = (in Element e) { book.price = e.text; }; xml.onEndTag["price"] = (in Element e) { book.price = e.text(); };
xml.onEndTag["publish-date"] = (in Element e) { book.pubDate = e.text; }; xml.onEndTag["publish-date"] = (in Element e) { book.pubDate = e.text(); };
xml.onEndTag["description"] = (in Element e) { book.description = e.text; }; xml.onEndTag["description"] = (in Element e) { book.description = e.text(); };
xml.parse(); xml.parse();
@ -639,7 +639,7 @@ class Document : Element
*/ */
override string toString() override string toString()
{ {
return prolog ~ super.toString ~ epilog; return prolog ~ super.toString() ~ epilog;
} }
} }
} }
@ -863,7 +863,7 @@ class Element : Item
*/ */
override hash_t toHash() override hash_t toHash()
{ {
hash_t hash = tag.toHash; hash_t hash = tag.toHash();
foreach(item;items) hash += item.toHash(); foreach(item;items) hash += item.toHash();
return hash; return hash;
} }
@ -888,8 +888,8 @@ class Element : Item
foreach(item;items) foreach(item;items)
{ {
Text t = cast(Text)item; Text t = cast(Text)item;
if (t is null) throw new DecodeException(item.toString); if (t is null) throw new DecodeException(item.toString());
buffer ~= decode(t.toString,mode); buffer ~= decode(t.toString(),mode);
} }
return buffer; return buffer;
} }
@ -904,18 +904,18 @@ class Element : Item
override string[] pretty(uint indent=2) override string[] pretty(uint indent=2)
{ {
if (isEmptyXML) return [ tag.toEmptyString ]; if (isEmptyXML) return [ tag.toEmptyString() ];
if (items.length == 1) if (items.length == 1)
{ {
Text t = cast(Text)(items[0]); Text t = cast(Text)(items[0]);
if (t !is null) if (t !is null)
{ {
return [tag.toStartString ~ t.toString ~ tag.toEndString]; return [tag.toStartString() ~ t.toString() ~ tag.toEndString()];
} }
} }
string[] a = [ tag.toStartString ]; string[] a = [ tag.toStartString() ];
foreach(item;items) foreach(item;items)
{ {
string[] b = item.pretty(indent); string[] b = item.pretty(indent);
@ -924,7 +924,7 @@ class Element : Item
a ~= rightJustify(s,s.length + indent); a ~= rightJustify(s,s.length + indent);
} }
} }
a ~= tag.toEndString; a ~= tag.toEndString();
return a; return a;
} }
@ -934,20 +934,20 @@ class Element : Item
* Examples: * Examples:
* -------------- * --------------
* auto element = new Element("br"); * auto element = new Element("br");
* writefln(element.toString); // writes "<br />" * writefln(element.toString()); // writes "<br />"
* -------------- * --------------
*/ */
override string toString() override string toString()
{ {
if (isEmptyXML) return tag.toEmptyString; if (isEmptyXML) return tag.toEmptyString();
string buffer = tag.toStartString; string buffer = tag.toStartString();
foreach (item;items) { buffer ~= item.toString; } foreach (item;items) { buffer ~= item.toString(); }
buffer ~= tag.toEndString; buffer ~= tag.toEndString();
return buffer; return buffer;
} }
override bool isEmptyXML() { return items.length == 0; } override @property bool isEmptyXML() { return items.length == 0; }
} }
} }
@ -991,14 +991,14 @@ class Tag
s = name; s = name;
try { checkName(s,t); } try { checkName(s,t); }
catch(Err e) { assert(false,"Invalid tag name:" ~ e.toString); } catch(Err e) { assert(false,"Invalid tag name:" ~ e.toString()); }
foreach(k,v;attr) foreach(k,v;attr)
{ {
s = k; s = k;
try { checkName(s,t); } try { checkName(s,t); }
catch(Err e) catch(Err e)
{ assert(false,"Invalid atrribute name:" ~ e.toString); } { assert(false,"Invalid atrribute name:" ~ e.toString()); }
} }
} }
@ -1133,7 +1133,7 @@ class Tag
* Examples: * Examples:
* -------------- * --------------
* auto tag = new Tag("book",TagType.START); * auto tag = new Tag("book",TagType.START);
* writefln(tag.toString); // writes "<book>" * writefln(tag.toString()); // writes "<book>"
* -------------- * --------------
*/ */
override string toString() override string toString()
@ -1167,7 +1167,7 @@ class Tag
* if (tag.isStart) { } * if (tag.isStart) { }
* -------------- * --------------
*/ */
bool isStart() { return type == TagType.START; } @property bool isStart() { return type == TagType.START; }
/** /**
* Returns true if the Tag is an end tag * Returns true if the Tag is an end tag
@ -1177,7 +1177,7 @@ class Tag
* if (tag.isEnd) { } * if (tag.isEnd) { }
* -------------- * --------------
*/ */
bool isEnd() { return type == TagType.END; } @property bool isEnd() { return type == TagType.END; }
/** /**
* Returns true if the Tag is an empty tag * Returns true if the Tag is an empty tag
@ -1187,7 +1187,7 @@ class Tag
* if (tag.isEmpty) { } * if (tag.isEmpty) { }
* -------------- * --------------
*/ */
bool isEmpty() { return type == TagType.EMPTY; } @property bool isEmpty() { return type == TagType.EMPTY; }
} }
} }
@ -1269,7 +1269,7 @@ class Comment : Item
*/ */
override const string toString() { return "<!--" ~ content ~ "-->"; } override const string toString() { return "<!--" ~ content ~ "-->"; }
override const bool isEmptyXML() { return false; } /// Returns false always override @property const bool isEmptyXML() { return false; } /// Returns false always
} }
/** /**
@ -1348,7 +1348,7 @@ class CData : Item
*/ */
override const string toString() { return cdata ~ content ~ "]]>"; } override const string toString() { return cdata ~ content ~ "]]>"; }
override const bool isEmptyXML() { return false; } /// Returns false always override @property const bool isEmptyXML() { return false; } /// Returns false always
} }
/** /**
@ -1428,7 +1428,7 @@ class Text : Item
/** /**
* Returns true if the content is the empty string * Returns true if the content is the empty string
*/ */
override const bool isEmptyXML() { return content.length == 0; } override @property const bool isEmptyXML() { return content.length == 0; }
} }
/** /**
@ -1507,7 +1507,7 @@ class XMLInstruction : Item
*/ */
override const string toString() { return "<!" ~ content ~ ">"; } override const string toString() { return "<!" ~ content ~ ">"; }
override const bool isEmptyXML() { return false; } /// Returns false always override @property const bool isEmptyXML() { return false; } /// Returns false always
} }
/** /**
@ -1586,7 +1586,7 @@ class ProcessingInstruction : Item
*/ */
override const string toString() { return "<?" ~ content ~ "?>"; } override const string toString() { return "<?" ~ content ~ "?>"; }
override const bool isEmptyXML() { return false; } /// Returns false always override @property const bool isEmptyXML() { return false; } /// Returns false always
} }
/** /**
@ -1619,7 +1619,7 @@ abstract class Item
} }
/// Returns true if the item represents empty XML text /// Returns true if the item represents empty XML text
abstract const bool isEmptyXML(); abstract @property const bool isEmptyXML();
} }
/** /**
@ -1725,7 +1725,7 @@ class ElementParser
* The Tag at the start of the element being parsed. You can read this to * The Tag at the start of the element being parsed. You can read this to
* determine the tag's name and attributes. * determine the tag's name and attributes.
*/ */
const const(Tag) tag() { return tag_; } const @property const(Tag) tag() { return tag_; }
/** /**
* Register a handler which will be called whenever a start tag is * Register a handler which will be called whenever a start tag is
@ -2718,7 +2718,7 @@ EOS";
}; };
xml.onEndTag["Test"] = (in Element e) { xml.onEndTag["Test"] = (in Element e) {
assert(e.text == "What & Up Second"); assert(e.text() == "What & Up Second");
}; };
xml.parse(); xml.parse();
} }
@ -2800,7 +2800,7 @@ class CheckException : XMLException
if (line != 0) s = format("Line %d, column %d: ",line,column); if (line != 0) s = format("Line %d, column %d: ",line,column);
s ~= msg; s ~= msg;
s ~= '\n'; s ~= '\n';
if (err !is null) s = err.toString ~ s; if (err !is null) s = err.toString() ~ s;
return s; return s;
} }
} }