Using non-Stream Loader ctor in Representer test.

This commit is contained in:
Ferdinand Majerech 2014-07-31 03:12:02 +02:00
parent 21700fdb5d
commit c5b7987e68

View file

@ -15,14 +15,12 @@ import dyaml.testcommon;
import dyaml.testconstructor; import dyaml.testconstructor;
/** /// Representer unittest.
* Representer unittest. ///
* /// Params: verbose = Print verbose output?
* Params: verbose = Print verbose output? /// codeFilename = File name to determine test case from.
* codeFilename = File name to determine test case from. /// Nothing is read from this file, it only exists
* Nothing is read from this file, it only exists /// to specify that we need a matching unittest.
* to specify that we need a matching unittest.
*/
void testRepresenterTypes(bool verbose, string codeFilename) void testRepresenterTypes(bool verbose, string codeFilename)
{ {
string baseName = codeFilename.baseName.stripExtension; string baseName = codeFilename.baseName.stripExtension;
@ -57,12 +55,11 @@ void testRepresenterTypes(bool verbose, string codeFilename)
dumper.dump(expectedNodes); dumper.dump(expectedNodes);
output = cast(string)emitStream.data; output = cast(string)emitStream.data;
auto loadStream = new MemoryStream(emitStream.data);
auto constructor = new Constructor; auto constructor = new Constructor;
constructor.addConstructorMapping("!tag1", &constructClass); constructor.addConstructorMapping("!tag1", &constructClass);
constructor.addConstructorScalar("!tag2", &constructStruct); constructor.addConstructorScalar("!tag2", &constructStruct);
auto loader = Loader(loadStream); auto loader = Loader(emitStream.data.dup);
loader.name = "TEST"; loader.name = "TEST";
loader.constructor = constructor; loader.constructor = constructor;
readNodes = loader.loadAll(); readNodes = loader.loadAll();