minor refactor: move tests to dyaml.test.*, remove spaces at ends of lines (#91)

minor refactor: move tests to dyaml.test.*, remove spaces at ends of lines
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
This commit is contained in:
Cameron Ross 2018-02-27 20:24:05 -04:00 committed by The Dlang Bot
parent e7ea38652b
commit 5ad4c3c435
11 changed files with 94 additions and 94 deletions

View file

@ -39,16 +39,16 @@ dyaml_src = [
'source/dyaml/style.d',
'source/dyaml/tag.d',
'source/dyaml/tagdirective.d',
'source/dyaml/testcommon.d',
'source/dyaml/testcompare.d',
'source/dyaml/testconstructor.d',
'source/dyaml/testemitter.d',
'source/dyaml/testerrors.d',
'source/dyaml/testinputoutput.d',
'source/dyaml/testreader.d',
'source/dyaml/testrepresenter.d',
'source/dyaml/testresolver.d',
'source/dyaml/testtokens.d',
'source/dyaml/test/common.d',
'source/dyaml/test/compare.d',
'source/dyaml/test/constructor.d',
'source/dyaml/test/emitter.d',
'source/dyaml/test/errors.d',
'source/dyaml/test/inputoutput.d',
'source/dyaml/test/reader.d',
'source/dyaml/test/representer.d',
'source/dyaml/test/resolver.d',
'source/dyaml/test/tokens.d',
'source/dyaml/token.d',
'source/dyaml/unused.d',
'source/dyaml/zerostring.d',

View file

@ -4,7 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
module dyaml.testcommon;
module dyaml.test.common;
version(unittest)
{
@ -31,10 +31,10 @@ package:
* unittestExt = Extensions of data files needed for the unittest.
* skipExt = Extensions that must not be used for the unittest.
*/
void run(F ...)(string testName, void function(bool, F) testFunction,
void run(F ...)(string testName, void function(bool, F) testFunction,
string[] unittestExt, string[] skipExt = [])
{
immutable string dataDir = __FILE_FULL_PATH__.dirName ~ "/../../test/data";
immutable string dataDir = __FILE_FULL_PATH__.dirName ~ "/../../../test/data";
auto testFilenames = findTestFilenames(dataDir);
bool verbose = false;
@ -130,7 +130,7 @@ body
*
* Returns: Information about the results of the unittest.
*/
Result execute(F ...)(const string testName, void function(bool, F) testFunction,
Result execute(F ...)(const string testName, void function(bool, F) testFunction,
string[] filenames, const bool verbose)
{
if(verbose)
@ -155,7 +155,7 @@ Result execute(F ...)(const string testName, void function(bool, F) testFunction
kind = (typeid(e) is typeid(AssertError)) ? TestStatus.Failure : TestStatus.Error;
write((verbose ? to!string(e) : to!string(kind)) ~ " ");
}
stdout.flush();
return Result(testName, filenames, kind, info);
@ -165,7 +165,7 @@ Result execute(F ...)(const string testName, void function(bool, F) testFunction
* Display unittest results.
*
* Params: results = Unittest results.
* verbose = Print verbose output?
* verbose = Print verbose output?
*/
void display(Result[] results, const bool verbose)
{
@ -183,7 +183,7 @@ void display(Result[] results, const bool verbose)
{
if(verbose)
{
writeln(result.name, "(" ~ result.filenames.join(", ") ~ "): ",
writeln(result.name, "(" ~ result.filenames.join(", ") ~ "): ",
to!string(result.kind));
}

View file

@ -4,18 +4,18 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
module dyaml.testcompare;
module dyaml.test.compare;
version(unittest)
{
import dyaml.testcommon;
import dyaml.test.common;
import dyaml.token;
/// Test parser by comparing output from parsing two equivalent YAML files.
///
///
/// Params: verbose = Print verbose output?
/// dataFilename = YAML file to parse.
/// canonicalFilename = Another file to parse, in canonical YAML format.
@ -34,7 +34,7 @@ void testParser(bool verbose, string dataFilename, string canonicalFilename)
/// Test loader by comparing output from loading two equivalent YAML files.
///
///
/// Params: verbose = Print verbose output?
/// dataFilename = YAML file to load.
/// canonicalFilename = Another file to load, in canonical YAML format.

View file

@ -4,7 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
module dyaml.testconstructor;
module dyaml.test.constructor;
version(unittest)
@ -17,7 +17,7 @@ import std.string;
import std.typecons;
import dyaml.tag;
import dyaml.testcommon;
import dyaml.test.common;
///Expected results of loading test inputs.
@ -100,7 +100,7 @@ Node[] constructBool()
Node[] constructCustom()
{
return [Node([Node(new TestClass(1, 2, 3)),
return [Node([Node(new TestClass(1, 2, 3)),
Node(TestStruct(10))])];
}
@ -126,36 +126,36 @@ Node[] constructInt()
Node[] constructMap()
{
return [Node([pair("Block style",
[pair("Clark", "Evans"),
pair("Brian", "Ingerson"),
return [Node([pair("Block style",
[pair("Clark", "Evans"),
pair("Brian", "Ingerson"),
pair("Oren", "Ben-Kiki")]),
pair("Flow style",
[pair("Clark", "Evans"),
pair("Brian", "Ingerson"),
[pair("Clark", "Evans"),
pair("Brian", "Ingerson"),
pair("Oren", "Ben-Kiki")])])];
}
Node[] constructMerge()
{
return [Node([Node([pair("x", 1L), pair("y", 2L)]),
Node([pair("x", 0L), pair("y", 2L)]),
Node([pair("r", 10L)]),
Node([pair("r", 1L)]),
Node([pair("x", 1L), pair("y", 2L), pair("r", 10L), pair("label", "center/big")]),
Node([pair("r", 10L), pair("label", "center/big"), pair("x", 1L), pair("y", 2L)]),
Node([pair("label", "center/big"), pair("x", 1L), pair("y", 2L), pair("r", 10L)]),
Node([pair("x", 0L), pair("y", 2L)]),
Node([pair("r", 10L)]),
Node([pair("r", 1L)]),
Node([pair("x", 1L), pair("y", 2L), pair("r", 10L), pair("label", "center/big")]),
Node([pair("r", 10L), pair("label", "center/big"), pair("x", 1L), pair("y", 2L)]),
Node([pair("label", "center/big"), pair("x", 1L), pair("y", 2L), pair("r", 10L)]),
Node([pair("x", 1L), pair("label", "center/big"), pair("r", 10L), pair("y", 2L)])])];
}
Node[] constructNull()
{
return [Node(YAMLNull()),
Node([pair("empty", YAMLNull()),
pair("canonical", YAMLNull()),
pair("english", YAMLNull()),
Node([pair("empty", YAMLNull()),
pair("canonical", YAMLNull()),
pair("english", YAMLNull()),
pair(YAMLNull(), "null key")]),
Node([pair("sparse",
Node([pair("sparse",
[Node(YAMLNull()),
Node("2nd entry"),
Node(YAMLNull()),
@ -165,33 +165,33 @@ Node[] constructNull()
Node[] constructOMap()
{
return [Node([pair("Bestiary",
[pair("aardvark", "African pig-like ant eater. Ugly."),
pair("anteater", "South-American ant eater. Two species."),
pair("anaconda", "South-American constrictor snake. Scaly.")]),
pair("Numbers",[pair("one", 1L),
pair("two", 2L),
return [Node([pair("Bestiary",
[pair("aardvark", "African pig-like ant eater. Ugly."),
pair("anteater", "South-American ant eater. Two species."),
pair("anaconda", "South-American constrictor snake. Scaly.")]),
pair("Numbers",[pair("one", 1L),
pair("two", 2L),
pair("three", 3L)])])];
}
Node[] constructPairs()
{
return [Node([pair("Block tasks",
return [Node([pair("Block tasks",
Node([pair("meeting", "with team."),
pair("meeting", "with boss."),
pair("break", "lunch."),
pair("meeting", "with client.")], "tag:yaml.org,2002:pairs")),
pair("Flow tasks",
pair("Flow tasks",
Node([pair("meeting", "with team"),
pair("meeting", "with boss")], "tag:yaml.org,2002:pairs"))])];
}
Node[] constructSeq()
{
return [Node([pair("Block style",
return [Node([pair("Block style",
[Node("Mercury"), Node("Venus"), Node("Earth"), Node("Mars"),
Node("Jupiter"), Node("Saturn"), Node("Uranus"), Node("Neptune"),
Node("Pluto")]),
Node("Pluto")]),
pair("Flow style",
[Node("Mercury"), Node("Venus"), Node("Earth"), Node("Mars"),
Node("Jupiter"), Node("Saturn"), Node("Uranus"), Node("Neptune"),
@ -201,8 +201,8 @@ Node[] constructSeq()
Node[] constructSet()
{
return [Node([pair("baseball players",
[Node("Mark McGwire"), Node("Sammy Sosa"), Node("Ken Griffey")]),
pair("baseball teams",
[Node("Mark McGwire"), Node("Sammy Sosa"), Node("Ken Griffey")]),
pair("baseball teams",
[Node("Boston Red Sox"), Node("Detroit Tigers"), Node("New York Yankees")])])];
}
@ -225,7 +225,7 @@ Node[] constructTimestamp()
{
alias DT = DateTime;
alias ST = SysTime;
return [Node([pair("canonical", ST(DT(2001, 12, 15, 2, 59, 43), 1000000.dur!"hnsecs", UTC())),
return [Node([pair("canonical", ST(DT(2001, 12, 15, 2, 59, 43), 1000000.dur!"hnsecs", UTC())),
pair("valid iso8601", ST(DT(2001, 12, 15, 2, 59, 43), 1000000.dur!"hnsecs", UTC())),
pair("space separated", ST(DT(2001, 12, 15, 2, 59, 43), 1000000.dur!"hnsecs", UTC())),
pair("no time zone (Z)", ST(DT(2001, 12, 15, 2, 59, 43), 1000000.dur!"hnsecs", UTC())),
@ -234,26 +234,26 @@ Node[] constructTimestamp()
Node[] constructValue()
{
return[Node([pair("link with",
return[Node([pair("link with",
[Node("library1.dll"), Node("library2.dll")])]),
Node([pair("link with",
[Node([pair("=", "library1.dll"), pair("version", cast(real)1.2)]),
Node([pair("link with",
[Node([pair("=", "library1.dll"), pair("version", cast(real)1.2)]),
Node([pair("=", "library2.dll"), pair("version", cast(real)2.3)])])])];
}
Node[] duplicateMergeKey()
{
return [Node([pair("foo", "bar"),
pair("x", 1L),
pair("y", 2L),
pair("z", 3L),
return [Node([pair("foo", "bar"),
pair("x", 1L),
pair("y", 2L),
pair("z", 3L),
pair("t", 4L)])];
}
Node[] floatRepresenterBug()
{
return [Node([pair(cast(real)1.0, 1L),
pair(real.infinity, 10L),
pair(real.infinity, 10L),
pair(-real.infinity, -10L),
pair(real.nan, 100L)])];
}
@ -289,10 +289,10 @@ Node[] timestampBugs()
alias DT = DateTime;
alias ST = SysTime;
alias STZ = immutable SimpleTimeZone;
return [Node([Node(ST(DT(2001, 12, 15, 3, 29, 43), 1000000.dur!"hnsecs", UTC())),
Node(ST(DT(2001, 12, 14, 16, 29, 43), 1000000.dur!"hnsecs", UTC())),
Node(ST(DT(2001, 12, 14, 21, 59, 43), 10100.dur!"hnsecs", UTC())),
Node(ST(DT(2001, 12, 14, 21, 59, 43), new STZ(60.dur!"minutes"))),
return [Node([Node(ST(DT(2001, 12, 15, 3, 29, 43), 1000000.dur!"hnsecs", UTC())),
Node(ST(DT(2001, 12, 14, 16, 29, 43), 1000000.dur!"hnsecs", UTC())),
Node(ST(DT(2001, 12, 14, 21, 59, 43), 10100.dur!"hnsecs", UTC())),
Node(ST(DT(2001, 12, 14, 21, 59, 43), new STZ(60.dur!"minutes"))),
Node(ST(DT(2001, 12, 14, 21, 59, 43), new STZ(-90.dur!"minutes"))),
Node(ST(DT(2005, 7, 8, 17, 35, 4), 5176000.dur!"hnsecs", UTC()))])];
}
@ -324,8 +324,8 @@ class TestClass
this(int x, int y, int z)
{
this.x = x;
this.y = y;
this.x = x;
this.y = y;
this.z = z;
}
@ -357,7 +357,7 @@ struct TestStruct
const int opCmp(ref const TestStruct s)
{
return value - s.value;
}
}
}
///Constructor function for TestClass.
@ -367,16 +367,16 @@ TestClass constructClass(ref Node node)
}
Node representClass(ref Node node, Representer representer)
{
{
auto value = node.as!TestClass;
auto pairs = [Node.Pair("x", value.x),
Node.Pair("y", value.y),
auto pairs = [Node.Pair("x", value.x),
Node.Pair("y", value.y),
Node.Pair("z", value.z)];
auto result = representer.representMapping("!tag1", pairs);
return result;
}
///Constructor function for TestStruct.
TestStruct constructStruct(ref Node node)
{

View file

@ -4,7 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
module dyaml.testemitter;
module dyaml.test.emitter;
version(unittest)
@ -18,7 +18,7 @@ import std.typecons;
import dyaml.stream;
import dyaml.dumper;
import dyaml.event;
import dyaml.testcommon;
import dyaml.test.common;
import dyaml.token;

View file

@ -4,7 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
module dyaml.testerrors;
module dyaml.test.errors;
version(unittest)
@ -12,7 +12,7 @@ version(unittest)
import std.file;
import dyaml.testcommon;
import dyaml.test.common;
/// Loader error unittest from file stream.

View file

@ -4,7 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
module dyaml.testinputoutput;
module dyaml.test.inputoutput;
version(unittest)
@ -14,16 +14,16 @@ import std.array;
import std.file;
import std.system;
import dyaml.testcommon;
import dyaml.test.common;
import dyaml.stream;
alias std.system.endian endian;
/// Get an UTF-16 byte order mark.
///
///
/// Params: wrong = Get the incorrect BOM for this system.
///
///
/// Returns: UTF-16 byte order mark.
wchar bom16(bool wrong = false) pure
{
@ -34,9 +34,9 @@ wchar bom16(bool wrong = false) pure
}
/// Get an UTF-32 byte order mark.
///
///
/// Params: wrong = Get the incorrect BOM for this system.
///
///
/// Returns: UTF-32 byte order mark.
dchar bom32(bool wrong = false) pure
{
@ -47,7 +47,7 @@ dchar bom32(bool wrong = false) pure
}
/// Unicode input unittest. Tests various encodings.
///
///
/// Params: verbose = Print verbose output?
/// unicodeFilename = File name to read from.
void testUnicodeInput(bool verbose, string unicodeFilename)
@ -58,7 +58,7 @@ void testUnicodeInput(bool verbose, string unicodeFilename)
Node output = Loader(cast(void[])data.to!(char[])).load();
assert(output.as!string == expected);
foreach(buffer; [cast(void[])(bom16() ~ data.to!(wchar[])),
foreach(buffer; [cast(void[])(bom16() ~ data.to!(wchar[])),
cast(void[])(bom32() ~ data.to!(dchar[]))])
{
output = Loader(buffer).load();
@ -67,7 +67,7 @@ void testUnicodeInput(bool verbose, string unicodeFilename)
}
/// Unicode input error unittest. Tests various encodings with incorrect BOMs.
///
///
/// Params: verbose = Print verbose output?
/// unicodeFilename = File name to read from.
void testUnicodeInputErrors(bool verbose, string unicodeFilename)

View file

@ -4,13 +4,13 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
module dyaml.testreader;
module dyaml.test.reader;
version(unittest)
{
import dyaml.testcommon;
import dyaml.test.common;
import dyaml.reader;

View file

@ -4,7 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
module dyaml.testrepresenter;
module dyaml.test.representer;
version(unittest)
@ -14,8 +14,8 @@ import std.path;
import std.exception;
import std.typecons;
import dyaml.testcommon;
import dyaml.testconstructor;
import dyaml.test.common;
import dyaml.test.constructor;
/// Representer unittest.
@ -27,7 +27,7 @@ import dyaml.testconstructor;
void testRepresenterTypes(bool verbose, string codeFilename)
{
string baseName = codeFilename.baseName.stripExtension;
enforce((baseName in dyaml.testconstructor.expected) !is null,
enforce((baseName in dyaml.test.constructor.expected) !is null,
new Exception("Unimplemented representer test: " ~ baseName));
Node[] expectedNodes = expected[baseName];

View file

@ -4,7 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
module dyaml.testresolver;
module dyaml.test.resolver;
version(unittest)
@ -13,7 +13,7 @@ version(unittest)
import std.file;
import std.string;
import dyaml.testcommon;
import dyaml.test.common;
/**

View file

@ -4,7 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
module dyaml.testtokens;
module dyaml.test.tokens;
version(unittest)
@ -13,7 +13,7 @@ version(unittest)
import std.array;
import std.file;
import dyaml.testcommon;
import dyaml.test.common;
import dyaml.token;