/// Positive tests — these must compile and produce correct results.
/// Run: dmd -i -run test_positive.d
import lib;
void void D main()main()
{
import (package) stdstd.(module) std.stdioCategory Symbols File handles _popen File isFileHandle openNetwork stderr stdin stdout Reading chunks lines readf readfln readln Writing toFile write writef writefln writeln Misc KeepTerminator LockType StdioException
Standard I/O functions that extend core.stdc.stdio. core.stdc.stdio
is publically imported when importing std.stdio.
There are three layers of I/O:
The lowest layer is the operating system layer. The two main schemes are Windows and Posix.
C's stdio.h which unifies the two operating system schemes.
std.stdio, this module, unifies the various stdio.h implementations into
a high level package for D programs.
Source
std/stdio.d
stdio : (alias template) writefln = std.stdio.writefln(alias fmt, A...)(A args) if (isSomeString!(typeof(fmt)))Equivalent to $(D writef(fmt, args, '\n')).
writefln;
// Function: named args skip the sentinel
auto (local variable) _error_ r1r1 = lib.inflateRect(x: 10, y: 20, width: 100, height: 200, margin: 5);
assert(r1 == lib.Rect(5, 15, 110, 210));
// Function: partial named args (rest get defaults)
auto (local variable) _error_ r2r2 = lib.inflateRect(width: 50, height: 50);
assert(r2 == lib.Rect(0, 0, 50, 50));
// Struct: named field init skips sentinel
auto (local variable) _error_ r3r3 = lib.makeRect(lib.RectOpts(x: 10, y: 20, width: 100, height: 200));
assert(r3 == lib.Rect(10, 20, 100, 200));
void std.stdio.writefln!char(in char[] fmt) @safeEquivalent to writef(fmt, args, '\n').
writefln("All positive tests passed.");
}