From a409cceeff9ad69869637a50c7bf05bfaf831e15 Mon Sep 17 00:00:00 2001 From: Kiith-Sa Date: Thu, 23 May 2013 14:33:34 +0200 Subject: [PATCH] DMD 2.053 compatibility. --- source/dyaml/constructor.d | 8 ++++---- source/dyaml/node.d | 18 ++++++++++-------- test/src/constructor.d | 4 ++-- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/source/dyaml/constructor.d b/source/dyaml/constructor.d index a92100c..1072c9c 100644 --- a/source/dyaml/constructor.d +++ b/source/dyaml/constructor.d @@ -618,7 +618,7 @@ SysTime constructTimestamp(ref Node node) value = matches.front.post; matches = match(value, TZRegexp); if(matches.empty || matches.front.captures[0] == "Z") - { + { return SysTime(DateTime(year, month, day, hour, minute, second), FracSec.from!"hnsecs"(hectonanosecond), UTC()); } @@ -631,12 +631,12 @@ SysTime constructTimestamp(ref Node node) if(captures[1][0] == '-'){sign = -1;} tzHours = to!int(captures[1][1 .. $]); } - const tzMinutes = (!captures[2].empty) ? to!int(captures[2][1 .. $]) : 0; - const tzOffset = sign * (60 * tzHours + tzMinutes); + auto tzMinutes = (!captures[2].empty) ? to!int(captures[2][1 .. $]) : 0; + auto tzOffset = sign * (60 * tzHours + tzMinutes); return SysTime(DateTime(year, month, day, hour, minute, second), FracSec.from!"hnsecs"(hectonanosecond), - new SimpleTimeZone(tzOffset)); + new immutable SimpleTimeZone(tzOffset)); } catch(ConvException e) { diff --git a/source/dyaml/node.d b/source/dyaml/node.d index 2d4258e..f8bbd92 100644 --- a/source/dyaml/node.d +++ b/source/dyaml/node.d @@ -259,15 +259,17 @@ struct Node } unittest { - with(Node(42)) { - assert(isScalar() && !isSequence && !isMapping && !isUserType); - assert(as!int == 42 && as!float == 42.0f && as!string == "42"); - assert(!isUserType()); + auto node = Node(42); + assert(node.isScalar && !node.isSequence && + !node.isMapping && !node.isUserType); + assert(node.as!int == 42 && node.as!float == 42.0f && node.as!string == "42"); + assert(!node.isUserType); } - with(Node(new class{int a = 5;})) + { - assert(isUserType()); + auto node = Node(new class{int a = 5;}); + assert(node.isUserType); } } @@ -1677,9 +1679,9 @@ struct Node { static long getIndex(ref Node node, ref T rhs) { - foreach(idx, ref elem; node.get!(Node[])) with(elem) + foreach(idx, ref elem; node.get!(Node[])) { - if(convertsTo!T && as!(T, No.stringConversion) == rhs) + if(elem.convertsTo!T && elem.as!(T, No.stringConversion) == rhs) { return idx; } diff --git a/test/src/constructor.d b/test/src/constructor.d index fca147c..c8f58be 100644 --- a/test/src/constructor.d +++ b/test/src/constructor.d @@ -276,8 +276,8 @@ Node[] timestampBugs() return [Node([Node(SysTime(DateTime(2001, 12, 15, 3, 29, 43), FracSec.from!"hnsecs"(1000000), UTC())), Node(SysTime(DateTime(2001, 12, 14, 16, 29, 43), FracSec.from!"hnsecs"(1000000), UTC())), Node(SysTime(DateTime(2001, 12, 14, 21, 59, 43), FracSec.from!"hnsecs"(10100), UTC())), - Node(SysTime(DateTime(2001, 12, 14, 21, 59, 43), new SimpleTimeZone(60))), - Node(SysTime(DateTime(2001, 12, 14, 21, 59, 43), new SimpleTimeZone(-90))), + Node(SysTime(DateTime(2001, 12, 14, 21, 59, 43), new immutable SimpleTimeZone(60))), + Node(SysTime(DateTime(2001, 12, 14, 21, 59, 43), new immutable SimpleTimeZone(-90))), Node(SysTime(DateTime(2005, 7, 8, 17, 35, 4), FracSec.from!"hnsecs"(5176000), UTC()))])]; }