mirror of
https://github.com/dlang/phobos.git
synced 2025-04-27 21:51:40 +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
18
std/stdio.d
18
std/stdio.d
|
@ -1582,7 +1582,7 @@ void writeln(T...)(T args)
|
|||
enforce(fputc('\n', .stdout.p.handle) == '\n');
|
||||
}
|
||||
else static if (T.length == 1 &&
|
||||
isSomeString!(typeof(args[0])) &&
|
||||
isSomeString!(typeof(args[0])) && is(typeof(args[0]) : const(char)[]) &&
|
||||
!isAggregateType!(typeof(args[0])))
|
||||
{
|
||||
// Specialization for strings - a very frequent case
|
||||
|
@ -1610,8 +1610,9 @@ unittest
|
|||
|
||||
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__);
|
||||
|
||||
// test writeln
|
||||
auto deleteme = testFilename();
|
||||
auto f = File(deleteme, "w");
|
||||
|
@ -1624,6 +1625,7 @@ unittest
|
|||
else
|
||||
assert(cast(char[]) std.file.read(deleteme) ==
|
||||
"Hello, world number 42!\n");
|
||||
|
||||
// test writeln on stdout
|
||||
auto saveStdout = stdout;
|
||||
scope(exit) stdout = saveStdout;
|
||||
|
@ -1636,6 +1638,18 @@ unittest
|
|||
else
|
||||
assert(cast(char[]) std.file.read(deleteme) ==
|
||||
"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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue