Skip to content

Commit

Permalink
Merge pull request #2912 from 9rnsr/fix_impurecall
Browse files Browse the repository at this point in the history
Remove pure attribute from the unittests which contain formatting floating point values
  • Loading branch information
yebblies committed Jan 26, 2015
2 parents b159a5b + 3ee0dc7 commit 4d9077d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions std/format.d
Expand Up @@ -1733,7 +1733,7 @@ unittest
assert(w.data == "1337.7");
}

@safe pure unittest
@safe /*pure*/ unittest // formatting floating point values is now impure
{
import std.conv : to;
foreach (T; TypeTuple!(float, double, real))
Expand Down Expand Up @@ -1787,7 +1787,7 @@ if (is(Unqual!T : creal) && !is(T == enum) && !hasToString!(T, Char))
put(w, 'i');
}

@safe pure unittest
@safe /*pure*/ unittest // formatting floating point values is now impure
{
import std.conv : to;
foreach (T; TypeTuple!(cfloat, cdouble, creal))
Expand Down Expand Up @@ -1838,7 +1838,7 @@ if (is(Unqual!T : ireal) && !is(T == enum) && !hasToString!(T, Char))
put(w, 'i');
}

@safe pure unittest
@safe /*pure*/ unittest // formatting floating point values is now impure
{
import std.conv : to;
foreach (T; TypeTuple!(ifloat, idouble, ireal))
Expand Down Expand Up @@ -3560,15 +3560,21 @@ void formatTest(T)(string fmt, T val, string[] expected, size_t ln = __LINE__, s
text("expected one of `", expected, "`, result = `", w.data, "`"), fn, ln);
}

pure unittest
@safe /*pure*/ unittest // formatting floating point values is now impure
{
import std.algorithm;
import std.array;

auto stream = appender!string();
formattedWrite(stream, "%s", 1.1);
assert(stream.data == "1.1", stream.data);
}

stream = appender!string();
pure unittest
{
import std.algorithm;
import std.array;

auto stream = appender!string();
formattedWrite(stream, "%s", map!"a*a"([2, 3, 5]));
assert(stream.data == "[4, 9, 25]", stream.data);

Expand Down

0 comments on commit 4d9077d

Please sign in to comment.