<div dir="ltr">This changes adds test for things like<div>DateAndTime now + 2 days</div><div>and</div><div>DateAndTime now + 2</div><div>(the later of which adds two nanoSeconds - who would have guessed?)</div><div><br></div><div>IT mostly tests to the current results of the most current Trunk, with a few exceptions:</div><div>1&gt; Tests adding Months and Years, which currenty isn&#39;t supported (causes 13 errors), which are fixed in additional changes (covered in another email).  If those changes are not acceptable, I can remove them....</div><div>2&gt; And error on TestSubtractString.  Currently, it treats adding strings as if they were durations, but since String responds to #asDateAndTime, it treats them as if they were DateAndTime strings.  I&#39;d rather see them as durations in both cases, so expected to see it as a duration for subtracting, which causes an error.  If this is wrong and the general expectation is that they should be DateAndTimes for subtracting and Durations for adding, I can change the test.  (But it is really confusing and not clear!)</div><div>3&gt; A failure in TestSubtractTime.  Currently, Squeak treats adding a time as adding the time to the DateAndTime; but it treats subtracting a time as trying to figure out the difference between the DateAndTime and a a DateAndTime of the current date with the time portion set to the time.  This is conterintuitive - does anyone expect this (or see any reason it would make sense)?  I have setup the test to treat it as if we wanted to jut subtract whatever the time is from the DateAndTime.</div><div>4&gt; A failure in TestSubtractTimespan.  Currently, Squeak treats adding a Timespan to the DateAndTime as adding the span of time represented by Timespan to the DateAndTime.  It treats subtracting the same as if you wanted the difference between the DateAndTime and the first (starting) dateAndTime of the TimeSpan.  I would assume what is really wanted would be to subract the space of time from the DateAndTime instead.  Does anyone dissagree with this desire?</div><div><br></div><div>If these tests are acceptable, I can modify the behaviour to match the tests.  If the current behaviour is correct, however, I can alter the tests to match that behaviour.  What is the consensus?</div><div><br></div><div>In either case, I would like to see these tests (possibly sanitized) added to Trunk, please.</div><div><br></div><div>-cbc</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 13, 2014 at 10:00 PM,  <span dir="ltr">&lt;<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">A new version of KernelTests was added to project The Inbox:<br>
<a href="http://source.squeak.org/inbox/KernelTests-cbc.277.mcz" target="_blank">http://source.squeak.org/inbox/KernelTests-cbc.277.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: KernelTests-cbc.277<br>
Author: cbc<br>
Time: 13 September 2014, 9:58:54.543 pm<br>
UUID: 035509c9-a60f-b44f-b55b-a17428783aa9<br>
Ancestors: KernelTests-dtl.276<br>
<br>
Added DateAndTimeArithmeticTest - to test adding things to DateAndTime instances.  This includes things like: DateAndTime now + 3 days.<br>
Test convering adding various durations (like above) as well as addint strings, numbers, Timespans, Times, and DatAndTimes.<br>
Also tests subtracting the same.<br>
<br>
=============== Diff against KernelTests-dtl.276 ===============<br>
<br>
Item was added:<br>
+ TestCase subclass: #DateAndTimeArithmeticTest<br>
+       instanceVariableNames: &#39;&#39;<br>
+       classVariableNames: &#39;&#39;<br>
+       poolDictionaries: &#39;&#39;<br>
+       category: &#39;KernelTests-Chronology&#39;!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testAddDateAndTime1 (in category &#39;testing&#39;) -----<br>
+ testAddDateAndTime1<br>
+       self assert: ((DateAndTime year: 2014 month: 1 day: 31) + (DateAndTime year: 2014 month: 3 day: 31)) = (DateAndTime year: 2014 month: 1 day: 31)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testAddDateAndTime2 (in category &#39;testing&#39;) -----<br>
+ testAddDateAndTime2<br>
+       self assert: ((DateAndTime year: 2014 month: 3 day: 31) + (DateAndTime year: 2014 month: 1 day: 31)) = (DateAndTime year: 2014 month: 3 day: 31)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testAddDays (in category &#39;testing&#39;) -----<br>
+ testAddDays<br>
+       self assert: ((DateAndTime year: 2014 month: 1 day: 31) + 2 days) = (DateAndTime year: 2014 month: 2 day: 2)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testAddHours (in category &#39;testing&#39;) -----<br>
+ testAddHours<br>
+       self assert: ((DateAndTime year: 2014 month: 1 day: 31) + 2 hours) = (DateAndTime year: 2014 month: 1 day: 31 hour: 2 minute: 0)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testAddIntegers (in category &#39;testing&#39;) -----<br>
+ testAddIntegers<br>
+       self assert: ((DateAndTime year: 2014 month: 1 day: 31) + 2) = (DateAndTime year: 2014 month: 1 day: 31 hour: 0 minute: 0 second: 0 nanoSecond: 000000002 offset: DateAndTime localOffset)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testAddMinutes (in category &#39;testing&#39;) -----<br>
+ testAddMinutes<br>
+       self assert: ((DateAndTime year: 2014 month: 1 day: 31) + 2 minutes) = (DateAndTime year: 2014 month: 1 day: 31 hour: 0 minute: 2)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testAddMonths1 (in category &#39;testing&#39;) -----<br>
+ testAddMonths1<br>
+       self assert: ((DateAndTime year: 2014 month: 1 day: 31) + 1 month) = (DateAndTime year: 2014 month: 2 day: 28)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testAddMonths2 (in category &#39;testing&#39;) -----<br>
+ testAddMonths2<br>
+       self assert: ((DateAndTime year: 2014 month: 1 day: 31) + 2 months) = (DateAndTime year: 2014 month: 3 day: 31)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testAddMonths4 (in category &#39;testing&#39;) -----<br>
+ testAddMonths4<br>
+       self assert: ((DateAndTime year: 2004 month: 1 day: 31) + 1 month) = (DateAndTime year: 2004 month: 2 day: 29)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testAddNanoSeconds (in category &#39;testing&#39;) -----<br>
+ testAddNanoSeconds<br>
+       self assert: ((DateAndTime year: 2014 month: 1 day: 31) + 2 nanoSeconds) = (DateAndTime year: 2014 month: 1 day: 31 hour: 0 minute: 0 second: 0 nanoSecond: 000000002 offset: DateAndTime localOffset)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testAddSeconds (in category &#39;testing&#39;) -----<br>
+ testAddSeconds<br>
+       self assert: ((DateAndTime year: 2014 month: 1 day: 31) + 2 seconds) = (DateAndTime year: 2014 month: 1 day: 31 hour: 0 minute: 0 second: 2)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testAddStrings (in category &#39;testing&#39;) -----<br>
+ testAddStrings<br>
+       self assert: ((DateAndTime year: 2014 month: 1 day: 31) + &#39;02:00:00:00&#39;) = (DateAndTime year: 2014 month: 2 day: 2)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testAddTime (in category &#39;testing&#39;) -----<br>
+ testAddTime<br>
+       self assert: ((DateAndTime year: 2014 month: 1 day: 31) + (&#39;02:00:00&#39; asTime)) = (DateAndTime year: 2014 month: 1 day: 31 hour: 2 minute: 0)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testAddTimespan (in category &#39;testing&#39;) -----<br>
+ testAddTimespan<br>
+       self assert: ((DateAndTime year: 2014 month: 1 day: 31)<br>
+               + ((DateAndTime year: 2014 month: 1 day: 1) to: (DateAndTime year: 2014 month: 1 day: 3)))<br>
+               = (DateAndTime year: 2014 month: 2 day: 2 hour: 0 minute: 0)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testAddWeeks (in category &#39;testing&#39;) -----<br>
+ testAddWeeks<br>
+       self assert: ((DateAndTime year: 2014 month: 1 day: 31) + 2 weeks) = (DateAndTime year: 2014 month: 2 day: 14)<br>
+<br>
+ !<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testAddYears1 (in category &#39;testing&#39;) -----<br>
+ testAddYears1<br>
+       self assert: ((DateAndTime year: 2006 month: 1 day: 31) + 2 years) = (DateAndTime year: 2008 month: 1 day: 31)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testAddYears2 (in category &#39;testing&#39;) -----<br>
+ testAddYears2<br>
+       self assert: ((DateAndTime year: 2007 month: 1 day: 31) + 2 years) = (DateAndTime year: 2009 month: 1 day: 31)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testAddYears3 (in category &#39;testing&#39;) -----<br>
+ testAddYears3<br>
+       self assert: ((DateAndTime year: 2004 month: 2 day: 29) + 1 year) = (DateAndTime year: 2005 month: 2 day: 28)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testSubtractDateAndTime1 (in category &#39;testing&#39;) -----<br>
+ testSubtractDateAndTime1<br>
+       self assert: ((DateAndTime year: 2014 month: 3 day: 31) - (DateAndTime year: 2014 month: 1 day: 31)) = 59 days!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testSubtractDateAndTime2 (in category &#39;testing&#39;) -----<br>
+ testSubtractDateAndTime2<br>
+       self assert: ((DateAndTime year: 2014 month: 1 day: 31) - (DateAndTime year: 2014 month: 3 day: 31)) = 59 days negated!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testSubtractDays (in category &#39;testing&#39;) -----<br>
+ testSubtractDays<br>
+       self assert: ((DateAndTime year: 2014 month: 3 day: 31) - 2 days) = (DateAndTime year: 2014 month: 3 day: 29)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testSubtractHours (in category &#39;testing&#39;) -----<br>
+ testSubtractHours<br>
+       self assert: ((DateAndTime year: 2014 month: 3 day: 31) - 2 hours) = (DateAndTime year: 2014 month: 3 day: 30 hour: 22 minute: 0)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testSubtractIntegers (in category &#39;testing&#39;) -----<br>
+ testSubtractIntegers<br>
+       self assert: ((DateAndTime year: 2014 month: 3 day: 31) - 2) = (DateAndTime year: 2014 month: 3 day: 30 hour: 23 minute: 59 second: 59 nanoSecond: 999999998 offset: DateAndTime localOffset)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testSubtractMinutes (in category &#39;testing&#39;) -----<br>
+ testSubtractMinutes<br>
+       self assert: ((DateAndTime year: 2014 month: 3 day: 31) - 2 minutes) = (DateAndTime year: 2014 month: 3 day: 30 hour: 23 minute: 58)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testSubtractMonths1 (in category &#39;testing&#39;) -----<br>
+ testSubtractMonths1<br>
+       self assert: ((DateAndTime year: 2014 month: 3 day: 31) - 1 month) = (DateAndTime year: 2014 month: 2 day: 28)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testSubtractMonths2 (in category &#39;testing&#39;) -----<br>
+ testSubtractMonths2<br>
+       self assert: ((DateAndTime year: 2014 month: 3 day: 31) - 2 months) = (DateAndTime year: 2014 month: 1 day: 31)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testSubtractMonths3 (in category &#39;testing&#39;) -----<br>
+ testSubtractMonths3<br>
+       self assert: ((DateAndTime year: 2014 month: 3 day: 14) - 1 month) = (DateAndTime year: 2014 month: 2 day: 14)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testSubtractMonths4 (in category &#39;testing&#39;) -----<br>
+ testSubtractMonths4<br>
+       self assert: ((DateAndTime year: 2004 month: 3 day: 31) - 1 month) = (DateAndTime year: 2004 month: 2 day: 29)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testSubtractNanoSeconds (in category &#39;testing&#39;) -----<br>
+ testSubtractNanoSeconds<br>
+       self assert: ((DateAndTime year: 2014 month: 3 day: 31) - 2 nanoSeconds) = (DateAndTime year: 2014 month: 3 day: 30 hour: 23 minute: 59 second: 59 nanoSecond: 999999998 offset: DateAndTime localOffset)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testSubtractSeconds (in category &#39;testing&#39;) -----<br>
+ testSubtractSeconds<br>
+       self assert: ((DateAndTime year: 2014 month: 3 day: 31) - 2 seconds) = (DateAndTime year: 2014 month: 3 day: 30 hour: 23 minute: 59 second: 58)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testSubtractStrings (in category &#39;testing&#39;) -----<br>
+ testSubtractStrings<br>
+       self assert: ((DateAndTime year: 2014 month: 1 day: 31) - &#39;02:00:00:00&#39;) = (DateAndTime year: 2014 month: 3 day: 29)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testSubtractTime (in category &#39;testing&#39;) -----<br>
+ testSubtractTime<br>
+       self assert: ((DateAndTime year: 2014 month: 3 day: 31) - (&#39;02:00:00&#39; asTime)) = (DateAndTime year: 2014 month: 3 day: 30 hour: 22 minute: 0)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testSubtractTimespan (in category &#39;testing&#39;) -----<br>
+ testSubtractTimespan<br>
+       self assert: ((DateAndTime year: 2014 month: 3 day: 31)<br>
+               - ((DateAndTime year: 2014 month: 1 day: 1) to: (DateAndTime year: 2014 month: 1 day: 3)))<br>
+               = (DateAndTime year: 2014 month: 3 day: 29)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testSubtractWeeks (in category &#39;testing&#39;) -----<br>
+ testSubtractWeeks<br>
+       self assert: ((DateAndTime year: 2014 month: 3 day: 31) - 2 weeks) = (DateAndTime year: 2014 month: 3 day: 17)<br>
+<br>
+ !<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testSubtractYears1 (in category &#39;testing&#39;) -----<br>
+ testSubtractYears1<br>
+       self assert: ((DateAndTime year: 2008 month: 1 day: 31) - 2 years) = (DateAndTime year: 2006 month: 1 day: 31)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testSubtractYears2 (in category &#39;testing&#39;) -----<br>
+ testSubtractYears2<br>
+       self assert: ((DateAndTime year: 2009 month: 1 day: 31) - 2 years) = (DateAndTime year: 2007 month: 1 day: 31)!<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTimeArithmeticTest&gt;&gt;testSubtractYears3 (in category &#39;testing&#39;) -----<br>
+ testSubtractYears3<br>
+       self assert: ((DateAndTime year: 2005 month: 2 day: 28) - 1 year) = (DateAndTime year: 2004 month: 2 day: 28)!<br>
<br>
<br>
</blockquote></div><br></div>