The Inbox: Chronology-Tests-dtl.24.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: Chronology-Tests-dtl.24.mcz

commits-2
A new version of Chronology-Tests was added to project The Inbox:
http://source.squeak.org/inbox/Chronology-Tests-dtl.24.mcz

==================== Summary ====================

Name: Chronology-Tests-dtl.24
Author: dtl
Time: 8 September 2020, 7:41:58.606243 pm
UUID: b399c1e6-4dfe-4240-b44e-19ec5abf3a74
Ancestors: Chronology-Tests-mt.23

Add tests for Time>>addSeconds: to ensure that nanosecond values are preserved.

=============== Diff against Chronology-Tests-mt.23 ===============

Item was added:
+ ----- Method: TimeTest>>testAddSecondsNanoSecondRollover (in category 'testing') -----
+ testAddSecondsNanoSecondRollover
+
+ | time1 time2 time3 time4 time5 time6 time7 time8 |
+ time1 := Time fromSeconds: 1.2s.
+ time2 := time1 addSeconds: 1.3s.
+ "n.b. use ticks second to access seconds instvar because #asSeconds is
+ questionable and possibly subject to future change -dtl"
+ self assert: 2 equals: time2 ticks second.
+ self assert: 500000000 equals: time2 nanoSecond.
+ time3 := Time fromSeconds: 1.9s.
+ time4 := time3 addSeconds: 1.2s.
+ self assert: 3 equals: time4 ticks second.
+ self assert: 100000000 equals: time4 nanoSecond.
+ time5 := Time fromSeconds: 0.9s.
+ time6 := time5 addSeconds: 0.2s.
+ self assert: 1 equals: time6 ticks second.
+ self assert: 100000000 equals: time6 nanoSecond.
+ time7 := time5 addSeconds: 1.
+ self assert: 1 equals: time7 ticks second.
+ self assert: 900000000 equals: time7 nanoSecond.
+ "midnight rollover"
+ time8 := '11:59:59.505 pm' asTime addSeconds: 1.0101.
+ self assert: 0 equals: time8 ticks second.
+ self assert: 515100000 equals: time8 nanoSecond.
+ !

Item was added:
+ ----- Method: TimeTest>>testAddSecondsWithNanos (in category 'testing') -----
+ testAddSecondsWithNanos
+ self assert: (timeWithNanos addSeconds: 1) = (Time readFromString: '4:02:48.42 am').
+ self assert: (timeWithNanos addSeconds: 60) = (Time readFromString: '4:03:47.42 am').
+ self assert: (timeWithNanos addSeconds: 3600) = (Time readFromString: '5:02:47.42 am').
+ self assert: (timeWithNanos addSeconds: 24*60*60) = (Time readFromString: '4:02:47.42 am').
+ "rollover after midnight"
+ self assert: (timeWithNanos addSeconds: 71832) = (Time readFromString: '11:59:59.42 pm').
+ self assert: (timeWithNanos addSeconds: 71833) = (Time readFromString: '00:00:00.42 am').
+ !