mirror of
https://github.com/dlang/phobos.git
synced 2025-05-01 23:50:31 +03:00
fix Issue 8386 - writeln stopped working with wstring
This commit is contained in:
parent
534d44c979
commit
07ec7ce34f
1 changed files with 16 additions and 2 deletions
16
std/stdio.d
16
std/stdio.d
|
@ -1582,7 +1582,7 @@ void writeln(T...)(T args)
|
||||||
enforce(fputc('\n', .stdout.p.handle) == '\n');
|
enforce(fputc('\n', .stdout.p.handle) == '\n');
|
||||||
}
|
}
|
||||||
else static if (T.length == 1 &&
|
else static if (T.length == 1 &&
|
||||||
isSomeString!(typeof(args[0])) &&
|
isSomeString!(typeof(args[0])) && is(typeof(args[0]) : const(char)[]) &&
|
||||||
!isAggregateType!(typeof(args[0])))
|
!isAggregateType!(typeof(args[0])))
|
||||||
{
|
{
|
||||||
// Specialization for strings - a very frequent case
|
// Specialization for strings - a very frequent case
|
||||||
|
@ -1612,6 +1612,7 @@ unittest
|
||||||
{
|
{
|
||||||
//printf("Entering test at line %d\n", __LINE__);
|
//printf("Entering test at line %d\n", __LINE__);
|
||||||
scope(failure) printf("Failed test at line %d\n", __LINE__);
|
scope(failure) printf("Failed test at line %d\n", __LINE__);
|
||||||
|
|
||||||
// test writeln
|
// test writeln
|
||||||
auto deleteme = testFilename();
|
auto deleteme = testFilename();
|
||||||
auto f = File(deleteme, "w");
|
auto f = File(deleteme, "w");
|
||||||
|
@ -1624,6 +1625,7 @@ unittest
|
||||||
else
|
else
|
||||||
assert(cast(char[]) std.file.read(deleteme) ==
|
assert(cast(char[]) std.file.read(deleteme) ==
|
||||||
"Hello, world number 42!\n");
|
"Hello, world number 42!\n");
|
||||||
|
|
||||||
// test writeln on stdout
|
// test writeln on stdout
|
||||||
auto saveStdout = stdout;
|
auto saveStdout = stdout;
|
||||||
scope(exit) stdout = saveStdout;
|
scope(exit) stdout = saveStdout;
|
||||||
|
@ -1636,6 +1638,18 @@ unittest
|
||||||
else
|
else
|
||||||
assert(cast(char[]) std.file.read(deleteme) ==
|
assert(cast(char[]) std.file.read(deleteme) ==
|
||||||
"Hello, world number 42!\n");
|
"Hello, world number 42!\n");
|
||||||
|
|
||||||
|
stdout.open(deleteme, "w");
|
||||||
|
writeln("Hello!"c);
|
||||||
|
writeln("Hello!"w); // bug 8386
|
||||||
|
writeln("Hello!"d); // bug 8386
|
||||||
|
stdout.close();
|
||||||
|
version (Windows)
|
||||||
|
assert(cast(char[]) std.file.read(deleteme) ==
|
||||||
|
"Hello!\r\nHello!\r\nHello!\r\n");
|
||||||
|
else
|
||||||
|
assert(cast(char[]) std.file.read(deleteme) ==
|
||||||
|
"Hello!\nHello!\nHello!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue