hey unittests - SHUT UP!

This commit is contained in:
Cameron Ross 2018-04-30 19:11:36 -03:00
parent 2ccdb49943
commit 75e2d69d76
No known key found for this signature in database
GPG key ID: 777897D98DC91C54
18 changed files with 39 additions and 70 deletions

View file

@ -19,7 +19,6 @@ import std.container;
import std.conv; import std.conv;
import std.datetime; import std.datetime;
import std.exception; import std.exception;
import std.stdio;
import std.regex; import std.regex;
import std.string; import std.string;
import std.typecons; import std.typecons;
@ -613,8 +612,6 @@ SysTime constructTimestamp(ref Node node) @safe
} }
@safe unittest @safe unittest
{ {
writeln("D:YAML construction timestamp unittest");
string timestamp(string value) string timestamp(string value)
{ {
auto node = Node(value); auto node = Node(value);
@ -682,8 +679,6 @@ Node.Pair[] constructOrderedMap(ref Node node) @safe
} }
@safe unittest @safe unittest
{ {
writeln("D:YAML construction ordered map unittest");
alias Node.Pair Pair; alias Node.Pair Pair;
Node[] alternateTypes(uint length) @safe Node[] alternateTypes(uint length) @safe
@ -750,8 +745,6 @@ Node[] constructSet(ref Node node) @safe
} }
@safe unittest @safe unittest
{ {
writeln("D:YAML construction set unittest");
Node.Pair[] set(uint length) @safe Node.Pair[] set(uint length) @safe
{ {
Node.Pair[] pairs; Node.Pair[] pairs;

View file

@ -61,9 +61,6 @@ struct Flags(names ...) if(names.length <= 8)
/// ///
@safe unittest @safe unittest
{ {
import std.stdio;
writeln("Flags unittest");
Flags!("empty", "multiline") flags; Flags!("empty", "multiline") flags;
assert(flags.empty == false && flags.multiline == false); assert(flags.empty == false && flags.multiline == false);
flags.multiline = true; flags.multiline = true;

View file

@ -7,9 +7,6 @@
/// Functionality that may sometimes be needed but allows unsafe or unstandard behavior, and should only be used in specific cases. /// Functionality that may sometimes be needed but allows unsafe or unstandard behavior, and should only be used in specific cases.
module dyaml.hacks; module dyaml.hacks;
import std.stdio;
import dyaml.node; import dyaml.node;
import dyaml.style; import dyaml.style;
@ -41,7 +38,6 @@ ScalarStyle scalarStyleHack(ref const(Node) node) @safe nothrow
} }
@safe unittest @safe unittest
{ {
writeln("D:YAML scalarStyleHack getter unittest");
auto node = Node(5); auto node = Node(5);
assert(node.scalarStyleHack() == ScalarStyle.Invalid); assert(node.scalarStyleHack() == ScalarStyle.Invalid);
} }
@ -59,7 +55,6 @@ CollectionStyle collectionStyleHack(ref const(Node) node) @safe nothrow
} }
@safe unittest @safe unittest
{ {
writeln("D:YAML collectionStyleHack getter unittest");
auto node = Node([1, 2, 3, 4, 5]); auto node = Node([1, 2, 3, 4, 5]);
assert(node.collectionStyleHack() == CollectionStyle.Invalid); assert(node.collectionStyleHack() == CollectionStyle.Invalid);
} }
@ -79,7 +74,6 @@ void scalarStyleHack(ref Node node, const ScalarStyle rhs) @safe nothrow
/// ///
@safe unittest @safe unittest
{ {
writeln("D:YAML scalarStyleHack setter unittest");
auto node = Node(5); auto node = Node(5);
node.scalarStyleHack = ScalarStyle.DoubleQuoted; node.scalarStyleHack = ScalarStyle.DoubleQuoted;
assert(node.scalarStyleHack() == ScalarStyle.DoubleQuoted); assert(node.scalarStyleHack() == ScalarStyle.DoubleQuoted);
@ -99,7 +93,6 @@ void collectionStyleHack(ref Node node, const CollectionStyle rhs) @safe nothrow
/// ///
@safe unittest @safe unittest
{ {
writeln("D:YAML collectionStyleHack setter unittest");
auto node = Node([1, 2, 3, 4, 5]); auto node = Node([1, 2, 3, 4, 5]);
node.collectionStyleHack = CollectionStyle.Block; node.collectionStyleHack = CollectionStyle.Block;
assert(node.collectionStyleHack() == CollectionStyle.Block); assert(node.collectionStyleHack() == CollectionStyle.Block);

View file

@ -359,8 +359,7 @@ struct Loader
foreach(string color, string value; colors) foreach(string color, string value; colors)
{ {
import std.stdio; // Do something with the color and its value...
writeln(color, " is ", value, " in HTML/CSS");
} }
} }

View file

@ -16,7 +16,6 @@ import std.datetime;
import std.exception; import std.exception;
import std.math; import std.math;
import std.range; import std.range;
import std.stdio;
import std.string; import std.string;
import std.traits; import std.traits;
import std.typecons; import std.typecons;
@ -737,7 +736,6 @@ struct Node
/// ///
@safe unittest @safe unittest
{ {
writeln("D:YAML Node opIndex unittest");
alias Node.Value Value; alias Node.Value Value;
alias Node.Pair Pair; alias Node.Pair Pair;
@ -751,7 +749,6 @@ struct Node
} }
@safe unittest @safe unittest
{ {
writeln("D:YAML Node opIndex unittest");
alias Node.Value Value; alias Node.Value Value;
alias Node.Pair Pair; alias Node.Pair Pair;
@ -815,7 +812,6 @@ struct Node
// Unittest for contains() and containsKey(). // Unittest for contains() and containsKey().
@safe unittest @safe unittest
{ {
writeln("D:YAML Node contains/containsKey unittest");
auto seq = Node([1, 2, 3, 4, 5]); auto seq = Node([1, 2, 3, 4, 5]);
assert(seq.contains(3)); assert(seq.contains(3));
assert(seq.contains(5)); assert(seq.contains(5));
@ -946,8 +942,6 @@ struct Node
} }
@safe unittest @safe unittest
{ {
writeln("D:YAML Node opIndexAssign unittest");
with(Node([1, 2, 3, 4, 3])) with(Node([1, 2, 3, 4, 3]))
{ {
opIndexAssign(42, 3); opIndexAssign(42, 3);
@ -1067,8 +1061,6 @@ struct Node
} }
@safe unittest @safe unittest
{ {
writeln("D:YAML Node sequence unittest");
Node n1 = Node([1, 2, 3, 4]); Node n1 = Node([1, 2, 3, 4]);
int[int] array; int[int] array;
Node n2 = Node(array); Node n2 = Node(array);
@ -1159,8 +1151,6 @@ struct Node
} }
@safe unittest @safe unittest
{ {
writeln("D:YAML Node mapping unittest");
int[int] array; int[int] array;
Node n = Node(array); Node n = Node(array);
n[1] = "foo"; n[1] = "foo";
@ -1201,8 +1191,6 @@ struct Node
} }
@safe unittest @safe unittest
{ {
writeln("D:YAML Node mappingKeys unittest");
int[int] array; int[int] array;
Node m1 = Node(array); Node m1 = Node(array);
m1["foo"] = 2; m1["foo"] = 2;
@ -1235,8 +1223,6 @@ struct Node
} }
@safe unittest @safe unittest
{ {
writeln("D:YAML Node mappingValues unittest");
int[int] array; int[int] array;
Node m1 = Node(array); Node m1 = Node(array);
m1["foo"] = 2; m1["foo"] = 2;
@ -1324,8 +1310,6 @@ struct Node
} }
@safe unittest @safe unittest
{ {
writeln("D:YAML Node opApply unittest 1");
Node n1 = Node(11); Node n1 = Node(11);
Node n2 = Node(12); Node n2 = Node(12);
Node n3 = Node(13); Node n3 = Node(13);
@ -1468,8 +1452,6 @@ struct Node
} }
@safe unittest @safe unittest
{ {
writeln("D:YAML Node opApply unittest 2");
alias Node.Value Value; alias Node.Value Value;
alias Node.Pair Pair; alias Node.Pair Pair;
@ -1562,8 +1544,6 @@ struct Node
} }
@safe unittest @safe unittest
{ {
writeln("D:YAML Node add unittest 1");
with(Node([1, 2, 3, 4])) with(Node([1, 2, 3, 4]))
{ {
add(5.0f); add(5.0f);
@ -1599,7 +1579,6 @@ struct Node
} }
@safe unittest @safe unittest
{ {
writeln("D:YAML Node add unittest 2");
with(Node([1, 2], [3, 4])) with(Node([1, 2], [3, 4]))
{ {
add(5, "6"); add(5, "6");
@ -1639,7 +1618,6 @@ struct Node
} }
@safe unittest @safe unittest
{ {
writeln(`D:YAML Node opBinaryRight!"in" unittest`);
auto mapping = Node(["foo", "baz"], ["bar", "qux"]); auto mapping = Node(["foo", "baz"], ["bar", "qux"]);
assert("bad" !in mapping && ("bad" in mapping) is null); assert("bad" !in mapping && ("bad" in mapping) is null);
Node* foo = "foo" in mapping; Node* foo = "foo" in mapping;
@ -1677,7 +1655,6 @@ struct Node
} }
@safe unittest @safe unittest
{ {
writeln("D:YAML Node remove unittest");
with(Node([1, 2, 3, 4, 3])) with(Node([1, 2, 3, 4, 3]))
{ {
remove(3); remove(3);
@ -1725,7 +1702,6 @@ struct Node
} }
@safe unittest @safe unittest
{ {
writeln("D:YAML Node removeAt unittest");
with(Node([1, 2, 3, 4, 3])) with(Node([1, 2, 3, 4, 3]))
{ {
removeAt(3); removeAt(3);
@ -1762,7 +1738,8 @@ struct Node
} }
@safe unittest @safe unittest
{ {
writeln("Node(42).toHash(): ", Node(42).toHash()); assert(Node(42).toHash() != Node(41).toHash());
assert(Node(42).toHash() != Node(42, "some-tag").toHash());
} }
package: package:

View file

@ -15,7 +15,6 @@ import std.algorithm;
import std.array; import std.array;
import std.conv; import std.conv;
import std.exception; import std.exception;
import std.stdio;
import std.string; import std.string;
import std.system; import std.system;
import std.typecons; import std.typecons;
@ -975,7 +974,6 @@ size_t countASCII(const(char)[] buffer) @trusted pure nothrow @nogc
void testEndian(R)() void testEndian(R)()
{ {
writeln(typeid(R).toString() ~ ": endian unittest");
void endian_test(ubyte[] data, Encoding encoding_expected, Endian endian_expected) void endian_test(ubyte[] data, Encoding encoding_expected, Endian endian_expected)
{ {
auto reader = new R(data); auto reader = new R(data);
@ -991,7 +989,6 @@ void testEndian(R)()
void testPeekPrefixForward(R)() void testPeekPrefixForward(R)()
{ {
import std.encoding; import std.encoding;
writeln(typeid(R).toString() ~ ": peek/prefix/forward unittest");
ubyte[] data = bomTable[BOM.utf8].sequence ~ cast(ubyte[])"data"; ubyte[] data = bomTable[BOM.utf8].sequence ~ cast(ubyte[])"data";
auto reader = new R(data); auto reader = new R(data);
assert(reader.peek() == 'd'); assert(reader.peek() == 'd');
@ -1009,7 +1006,6 @@ void testPeekPrefixForward(R)()
void testUTF(R)() void testUTF(R)()
{ {
import std.encoding; import std.encoding;
writeln(typeid(R).toString() ~ ": UTF formats unittest");
dchar[] data = cast(dchar[])"data"; dchar[] data = cast(dchar[])"data";
void utf_test(T)(T[] data, BOM bom) void utf_test(T)(T[] data, BOM bom)
{ {
@ -1028,7 +1024,6 @@ void testUTF(R)()
void test1Byte(R)() void test1Byte(R)()
{ {
writeln(typeid(R).toString() ~ ": 1 byte file unittest");
ubyte[] data = [97]; ubyte[] data = [97];
auto reader = new R(data); auto reader = new R(data);

View file

@ -17,7 +17,6 @@ module dyaml.resolver;
import std.conv; import std.conv;
import std.regex; import std.regex;
import std.stdio;
import std.typecons; import std.typecons;
import std.utf; import std.utf;
@ -169,8 +168,6 @@ final class Resolver
} }
@safe unittest @safe unittest
{ {
writeln("D:YAML Resolver unittest");
auto resolver = new Resolver(); auto resolver = new Resolver();
bool tagMatch(string tag, string[] values) @safe bool tagMatch(string tag, string[] values) @safe

View file

@ -57,9 +57,9 @@ class YFile : YStream
@system unittest @system unittest
{ {
import std.stdio : stdout; import std.stdio : File;
auto stream = new YFile(stdout); auto stream = new YFile(File.tmpfile);
stream.write("Test writing to stdout through YFile stream\n"); stream.write("Test writing to tmpFile through YFile stream\n");
} }
void writeExact(const void* buffer, size_t size) void writeExact(const void* buffer, size_t size)

View file

@ -24,8 +24,18 @@ import std.typecons;
package: package:
debug(verbose) enum verbose = true; debug(verbose)
else enum verbose = false; {
enum verbose = true;
enum quiet = false;
}
else
{
enum verbose = false;
debug(noisy) enum quiet = false;
else enum quiet = true;
}
/** /**
* Run an unittest. * Run an unittest.
* *
@ -75,6 +85,14 @@ void printException(YAMLException e) @trusted
static if(verbose) { writeln(typeid(e).toString(), "\n", e); } static if(verbose) { writeln(typeid(e).toString(), "\n", e); }
} }
void printProgress(T...)(T params) @safe
{
static if(!quiet)
{
writeln(params);
}
}
private: private:
///Unittest status. ///Unittest status.
@ -157,7 +175,7 @@ Result execute(D)(const string testName, D testFunction,
F parameters; F parameters;
stringsToTuple!(F.length - 1, F)(parameters, filenames); stringsToTuple!(F.length - 1, F)(parameters, filenames);
testFunction(parameters); testFunction(parameters);
static if(!verbose){write(".");} static if (!quiet){write(".");}
} }
catch(Throwable e) catch(Throwable e)
{ {
@ -178,7 +196,7 @@ Result execute(D)(const string testName, D testFunction,
*/ */
void display(Result[] results) @safe void display(Result[] results) @safe
{ {
if(results.length > 0 && !verbose){write("\n");} if(results.length > 0 && !verbose && !quiet){write("\n");}
size_t failures = 0; size_t failures = 0;
size_t errors = 0; size_t errors = 0;
@ -205,8 +223,8 @@ void display(Result[] results) @safe
} }
//Totals. //Totals.
writeln("==========================================================================="); printProgress("===========================================================================");
writeln("TESTS: ", results.length); printProgress("TESTS: ", results.length);
if(failures > 0){writeln("FAILURES: ", failures);} if(failures > 0){writeln("FAILURES: ", failures);}
if(errors > 0) {writeln("ERRORS: ", errors);} if(errors > 0) {writeln("ERRORS: ", errors);}
} }

View file

@ -62,7 +62,7 @@ void testLoader(string dataFilename, string canonicalFilename) @safe
@safe unittest @safe unittest
{ {
writeln("D:YAML comparison unittest"); printProgress("D:YAML comparison unittest");
run("testParser", &testParser, ["data", "canonical"]); run("testParser", &testParser, ["data", "canonical"]);
run("testLoader", &testLoader, ["data", "canonical"], ["test_loader_skip"]); run("testLoader", &testLoader, ["data", "canonical"], ["test_loader_skip"]);
} }

View file

@ -437,7 +437,7 @@ void testConstructor(string dataFilename, string codeDummy) @safe
@safe unittest @safe unittest
{ {
writeln("D:YAML Constructor unittest"); printProgress("D:YAML Constructor unittest");
run("testConstructor", &testConstructor, ["data", "code"]); run("testConstructor", &testConstructor, ["data", "code"]);
} }

View file

@ -193,7 +193,7 @@ void testEmitterStyles(string dataFilename, string canonicalFilename) @system
@system unittest @system unittest
{ {
writeln("D:YAML Emitter unittest"); printProgress("D:YAML Emitter unittest");
run("testEmitterOnData", &testEmitterOnData, ["data", "canonical"]); run("testEmitterOnData", &testEmitterOnData, ["data", "canonical"]);
run("testEmitterOnCanonical", &testEmitterOnCanonical, ["canonical"]); run("testEmitterOnCanonical", &testEmitterOnCanonical, ["canonical"]);
run("testEmitterStyles", &testEmitterStyles, ["data", "canonical"]); run("testEmitterStyles", &testEmitterStyles, ["data", "canonical"]);

View file

@ -83,7 +83,7 @@ void testLoaderErrorSingle(string errorFilename) @safe
@safe unittest @safe unittest
{ {
writeln("D:YAML Errors unittest"); printProgress("D:YAML Errors unittest");
run("testLoaderError", &testLoaderError, ["loader-error"]); run("testLoaderError", &testLoaderError, ["loader-error"]);
run("testLoaderErrorString", &testLoaderErrorString, ["loader-error"]); run("testLoaderErrorString", &testLoaderErrorString, ["loader-error"]);
run("testLoaderErrorFilename", &testLoaderErrorFilename, ["loader-error"]); run("testLoaderErrorFilename", &testLoaderErrorFilename, ["loader-error"]);

View file

@ -89,7 +89,7 @@ void testUnicodeInputErrors(string unicodeFilename) @safe
@safe unittest @safe unittest
{ {
writeln("D:YAML I/O unittest"); printProgress("D:YAML I/O unittest");
run("testUnicodeInput", &testUnicodeInput, ["unicode"]); run("testUnicodeInput", &testUnicodeInput, ["unicode"]);
run("testUnicodeInputErrors", &testUnicodeInputErrors, ["unicode"]); run("testUnicodeInputErrors", &testUnicodeInputErrors, ["unicode"]);
} }

View file

@ -50,7 +50,7 @@ ubyte[] readData(string filename) @trusted
@safe unittest @safe unittest
{ {
writeln("D:YAML Reader unittest"); printProgress("D:YAML Reader unittest");
run("testStreamError", &testStreamError, ["stream-error"]); run("testStreamError", &testStreamError, ["stream-error"]);
} }

View file

@ -80,7 +80,7 @@ void testRepresenterTypes(string codeFilename) @safe
@safe unittest @safe unittest
{ {
writeln("D:YAML Representer unittest"); printProgress("D:YAML Representer unittest");
run("testRepresenterTypes", &testRepresenterTypes, ["code"]); run("testRepresenterTypes", &testRepresenterTypes, ["code"]);
} }

View file

@ -49,7 +49,7 @@ void testImplicitResolver(string dataFilename, string detectFilename) @safe
@safe unittest @safe unittest
{ {
writeln("D:YAML Resolver unittest"); printProgress("D:YAML Resolver unittest");
run("testImplicitResolver", &testImplicitResolver, ["data", "detect"]); run("testImplicitResolver", &testImplicitResolver, ["data", "detect"]);
} }

View file

@ -86,7 +86,7 @@ void testScanner(string dataFilename, string canonicalFilename) @safe
@safe unittest @safe unittest
{ {
writeln("D:YAML tokens unittest"); printProgress("D:YAML tokens unittest");
run("testTokens", &testTokens, ["data", "tokens"]); run("testTokens", &testTokens, ["data", "tokens"]);
run("testScanner", &testScanner, ["data", "canonical"]); run("testScanner", &testScanner, ["data", "canonical"]);
} }