From 3cfdd7ba56744f10d6458451bf6b4c8af80138a9 Mon Sep 17 00:00:00 2001 From: Cameron Ross Date: Fri, 23 Mar 2018 21:05:50 -0300 Subject: [PATCH] allow dyaml.test.representer.testRepresenterTypes to be @safe --- source/dyaml/test/representer.d | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/dyaml/test/representer.d b/source/dyaml/test/representer.d index 969b53f..a29acfc 100644 --- a/source/dyaml/test/representer.d +++ b/source/dyaml/test/representer.d @@ -24,7 +24,7 @@ import dyaml.test.constructor; /// codeFilename = File name to determine test case from. /// Nothing is read from this file, it only exists /// to specify that we need a matching unittest. -void testRepresenterTypes(bool verbose, string codeFilename) @trusted +void testRepresenterTypes(bool verbose, string codeFilename) @safe { string baseName = codeFilename.baseName.stripExtension; enforce((baseName in dyaml.test.constructor.expected) !is null, @@ -33,7 +33,7 @@ void testRepresenterTypes(bool verbose, string codeFilename) @trusted Node[] expectedNodes = expected[baseName]; foreach(encoding; [Encoding.UTF_8, Encoding.UTF_16, Encoding.UTF_32]) { - string output; + ubyte[] output; Node[] readNodes; scope(failure) @@ -44,7 +44,9 @@ void testRepresenterTypes(bool verbose, string codeFilename) @trusted foreach(ref n; expectedNodes){writeln(n.debugString, "\n---\n");} writeln("Read nodes:"); foreach(ref n; readNodes){writeln(n.debugString, "\n---\n");} - writeln("OUTPUT:\n", output); + () @trusted { + writeln("OUTPUT:\n", cast(string)output); + }(); } } @@ -59,7 +61,7 @@ void testRepresenterTypes(bool verbose, string codeFilename) @trusted dumper.encoding = encoding; dumper.dump(expectedNodes); - output = cast(string)emitStream.data; + output = emitStream.data; auto constructor = new Constructor; constructor.addConstructorMapping("!tag1", &constructClass); constructor.addConstructorScalar("!tag2", &constructStruct);