test_positive.derror×8 hover×8all
/// Positive tests — these must compile and produce correct results.
/// Run: dmd -i -run test_positive.d
import lib;
unable to read module `lib` Expected 'lib.d' or 'lib/package.d' in one of the following import paths:
unable to read module `lib` Expected 'lib.d' or 'lib/package.d' in one of the following import paths:
void
void D main()
main
()
{ import
(package) std
std
.
(module) std.stdio
Category 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:

  1. The lowest layer is the operating system layer. The two main schemes are Windows and Posix.

  2. C's stdio.h which unifies the two operating system schemes.

  3. std.stdio, this module, unifies the various stdio.h implementations into a high level package for D programs.

Source

std/stdio.d

@copyrightCopyright The D Language Foundation 2007-.@licenseBoost License 1.0.@authorsWalter Bright, Andrei Alexandrescu, Alex Rønne Petersen
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_ r1
r1
= lib.inflateRect(x: 10, y: 20, width: 100, height: 200, margin: 5);
forward reference of import `lib`
assert(r1 == lib.Rect(5, 15, 110, 210));
forward reference of import `lib`
// Function: partial named args (rest get defaults) auto
(local variable) _error_ r2
r2
= lib.inflateRect(width: 50, height: 50);
forward reference of import `lib`
assert(r2 == lib.Rect(0, 0, 50, 50));
forward reference of import `lib`
// Struct: named field init skips sentinel auto
(local variable) _error_ r3
r3
= lib.makeRect(lib.RectOpts(x: 10, y: 20, width: 100, height: 200));
forward reference of import `lib`
assert(r3 == lib.Rect(10, 20, 100, 200));
forward reference of import `lib`
void std.stdio.writefln!char(in char[] fmt) @safe

Equivalent to writef(fmt, args, '\n').

writefln
("All positive tests passed.");
}