RegressionTests__TimeDurationTest.st
author Claus Gittinger <cg@exept.de>
Tue, 09 Jul 2019 18:53:03 +0200
changeset 2327 bf482d49aeaf
parent 2245 bfbf845df5cf
permissions -rw-r--r--
#QUALITY by exept class: RegressionTests::StringTests added: #test82c_expanding
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1918
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
     1
"{ Encoding: utf8 }"
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
     2
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
     3
"{ Package: 'stx:goodies/regression' }"
333
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
"{ NameSpace: RegressionTests }"
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
TestCase subclass:#TimeDurationTest
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
	instanceVariableNames:''
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
	classVariableNames:''
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
	poolDictionaries:''
1078
a4829ce2f3f1 category change
Claus Gittinger <cg@exept.de>
parents: 678
diff changeset
    11
	category:'tests-Regression-DateAndTime'
333
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
!
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
!TimeDurationTest methodsFor:'Testing'!
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    17
test_00_Basic
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    18
    |t|
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    19
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    20
    t := TimeDuration fromSeconds:1.
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    21
    self assert:(t asSeconds = 1).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    22
    self assert:(t asMilliseconds == 1000).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    23
    self assert:(t asMicroseconds = 1000000).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    24
    self assert:(t asNanoseconds = 1000000000).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    25
    self assert:(t asPicoseconds = 1000000000000).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    26
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    27
    t := TimeDuration fromSeconds:1.5.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    28
    self assert:(t asSeconds = 1).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    29
    self assert:(t asTruncatedSeconds == 1).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    30
    self assert:(t asExactSeconds = 1.5).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    31
    self assert:(t asMilliseconds == 1500).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    32
    self assert:(t asMicroseconds = 1500000).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    33
    self assert:(t asNanoseconds = 1500000000).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    34
    self assert:(t asPicoseconds = 1500000000000).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    35
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    36
    t := TimeDuration fromMilliseconds:345.
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    37
    self assert:(t asSeconds = 0).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    38
    self assert:(t asExactSeconds = 0.345).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    39
    self assert:(t asTruncatedSeconds = 0).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    40
    self assert:(t asMilliseconds == 345).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    41
    self assert:(t asMicroseconds = 345000).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    42
    self assert:(t asNanoseconds = 345000000).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    43
    self assert:(t asPicoseconds = 345000000000).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    44
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    45
    t := TimeDuration fromMicroseconds:345.
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    46
    self assert:(t asExactSeconds = 0.000345).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    47
    self assert:(t asTruncatedSeconds = 0).
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    48
    self assert:(t asExactMilliseconds = 0.345).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    49
    self assert:(t asTruncatedMilliseconds == 0).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    50
    self assert:(t asMicroseconds = 345).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    51
    self assert:(t asNanoseconds = 345000).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    52
    self assert:(t asPicoseconds = 345000000).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    53
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    54
    t := TimeDuration fromNanoseconds:345.
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    55
    self assert:(t asExactSeconds = 0.000000345).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    56
    self assert:(t asTruncatedSeconds = 0).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    57
    self assert:(t asTruncatedMilliseconds == 0).
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    58
    self assert:(t asExactMilliseconds = 0.000345).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    59
    self assert:(t asTruncatedMicroseconds = 0).
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    60
    self assert:(t asExactMicroseconds = 0.345).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    61
    self assert:(t asNanoseconds = 345).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    62
    self assert:(t asPicoseconds = 345000).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    63
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    64
    t := TimeDuration fromPicoseconds:345.
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    65
    self assert:(t asExactSeconds = 0.000000000345).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    66
    self assert:(t asTruncatedSeconds = 0).
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    67
    self assert:(t asExactMilliseconds = 0.000000345).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    68
    self assert:(t asTruncatedMilliseconds == 0).
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    69
    self assert:(t asExactMicroseconds = 0.000345).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    70
    self assert:(t asTruncatedMicroseconds = 0).
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    71
    self assert:(t asExactNanoseconds = 0.345).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    72
    self assert:(t asTruncatedNanoseconds = 0).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    73
    self assert:(t asPicoseconds = 345).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    74
1923
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
    75
    t := TimeDuration fromMicroseconds:-10001.
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
    76
    self assert:(t asExactMicroseconds = -10001).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
    77
1926
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    78
    (4 to:4000000000000000000 byFactor:1000) do:[:v |
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    79
        self assert:(t := TimeDuration new setPicoseconds:v) asPicoseconds = v.
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    80
        self assert:(t := TimeDuration fromPicoseconds:v) asPicoseconds = v.
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    81
        self assert:(t := v picoseconds) asPicoseconds = v.
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    82
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    83
        self assert:(t := TimeDuration new setNanoseconds:v) asNanoseconds = v.
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    84
        self assert:(t := TimeDuration fromNanoseconds:v) asNanoseconds = v.
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    85
        self assert:(t := v nanoseconds) asNanoseconds = v.
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    86
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    87
    ].
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    88
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    89
    self assert:(t := 4 picoseconds) printString = ('4ps').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    90
    self assert:(t := 40 picoseconds) printString = ('40ps').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    91
    self assert:(t := 400 picoseconds) printString = ('400ps').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    92
    self assert:(t := 4000 picoseconds) printString = ('4ns').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    93
    self assert:(4000 picoseconds = 4 nanoseconds).
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    94
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    95
    self assert:(t := 4 nanoseconds) printString = ('4ns').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    96
    self assert:(t := 40 nanoseconds) printString = ('40ns').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    97
    self assert:(t := 400 nanoseconds) printString = ('400ns').
1941
0ae2e86f50cf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1926
diff changeset
    98
    self assert:(t := 4000 nanoseconds) printString = ('4µs').
1926
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    99
    self assert:(4000 nanoseconds = 4 microseconds).
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
   100
1941
0ae2e86f50cf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1926
diff changeset
   101
    self assert:(t := 4 microseconds) printString = ('4µs').
0ae2e86f50cf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1926
diff changeset
   102
    self assert:(t := 40 microseconds) printString = ('40µs').
0ae2e86f50cf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1926
diff changeset
   103
    self assert:(t := 400 microseconds) printString = ('400µs').
1926
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
   104
    self assert:(t := 4000 microseconds) printString = ('4ms').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
   105
    self assert:(4000 microseconds = 4 milliseconds).
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
   106
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
   107
    self assert:(t := 4 milliseconds) printString = ('4ms').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
   108
    self assert:(t := 40 milliseconds) printString = ('40ms').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
   109
    self assert:(t := 400 milliseconds) printString = ('400ms').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
   110
    self assert:(t := 4000 milliseconds) printString = ('4s').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
   111
    self assert:(4000 milliseconds = 4 seconds).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   112
    "
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   113
     self new test_00_Basic
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   114
    "
1941
0ae2e86f50cf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1926
diff changeset
   115
0ae2e86f50cf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1926
diff changeset
   116
    "Modified: / 24-05-2018 / 17:42:49 / Claus Gittinger"
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   117
!
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   118
1922
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   119
test_01_Addition
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   120
    |t1 t2 sum|
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   121
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   122
    t1 := TimeDuration fromSeconds:1.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   123
    t2 := TimeDuration fromMilliseconds:1.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   124
    sum := t1 + t2.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   125
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   126
    self assert:(sum asMilliseconds == 1001).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   127
    self assert:(sum asMicroseconds = 1001000).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   128
    self assert:(sum asNanoseconds = 1001000000).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   129
    self assert:(sum asPicoseconds = 1001000000000).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   130
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   131
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   132
    t1 := TimeDuration fromSeconds:1.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   133
    t2 := TimeDuration fromMicroseconds:1.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   134
    sum := t1 + t2.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   135
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   136
    self assert:(sum asMilliseconds == 1000).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   137
    self assert:(sum asMicroseconds = 1000001).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   138
    self assert:(sum asNanoseconds = 1000001000).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   139
    self assert:(sum asPicoseconds = 1000001000000).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   140
1921
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   141
    t1 := TimeDuration fromNanoseconds:100.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   142
    t2 := TimeDuration fromNanoseconds:15.5.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   143
    sum := t1 + t2.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   144
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   145
    self assert:(sum asNanoseconds = 115).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   146
    self assert:(sum asPicoseconds = 115500).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   147
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   148
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   149
    "
1922
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   150
     self new test_01_Addition
1921
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   151
    "
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   152
!
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   153
1922
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   154
test_02_Subtraction
1921
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   155
    |t1 t2 sum|
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   156
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   157
    t1 := TimeDuration fromSeconds:1.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   158
    t2 := TimeDuration fromMilliseconds:1.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   159
    sum := t1 - t2.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   160
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   161
    self assert:(sum asMilliseconds == 999).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   162
    self assert:(sum asMicroseconds = 999000).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   163
    self assert:(sum asNanoseconds = 999000000).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   164
    self assert:(sum asPicoseconds = 999000000000).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   165
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   166
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   167
    t1 := TimeDuration fromSeconds:1.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   168
    t2 := TimeDuration fromMicroseconds:1.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   169
    sum := t1 - t2.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   170
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   171
    self assert:(sum asMilliseconds == 999).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   172
    self assert:(sum asMicroseconds = 999999).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   173
    self assert:(sum asNanoseconds = 999999000).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   174
    self assert:(sum asPicoseconds = 999999000000).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   175
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   176
    t1 := TimeDuration fromNanoseconds:100.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   177
    t2 := TimeDuration fromNanoseconds:15.5.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   178
    sum := t1 - t2.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   179
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   180
    self assert:(sum asNanoseconds = 84).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   181
    self assert:(sum asPicoseconds = 84500).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   182
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   183
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   184
    "
1922
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   185
     self new test_01_Subtraction
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   186
    "
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   187
!
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   188
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   189
test_03_Multiplication
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   190
    |t rslt|
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   191
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   192
    t := TimeDuration fromSeconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   193
    rslt := t * 5.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   194
    self assert:(rslt asMilliseconds == 5000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   195
    self assert:(rslt asPicoseconds = 5000000000000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   196
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   197
    rslt := 5 * t.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   198
    self assert:(rslt asMilliseconds == 5000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   199
    self assert:(rslt asPicoseconds = 5000000000000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   200
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   201
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   202
    t := TimeDuration fromSeconds:1.1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   203
    rslt := t * 2.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   204
    self assert:(rslt asMilliseconds == 2200).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   205
    self assert:(rslt asPicoseconds = 2200000000000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   206
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   207
    rslt := 2 * t.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   208
    self assert:(rslt asMilliseconds == 2200).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   209
    self assert:(rslt asPicoseconds = 2200000000000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   210
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   211
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   212
    t := TimeDuration fromNanoseconds:100.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   213
    rslt := t * 4.5.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   214
    self assert:(rslt asNanoseconds = 450).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   215
    self assert:(rslt asPicoseconds = 450000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   216
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   217
    rslt := 4.5 * t.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   218
    self assert:(rslt asNanoseconds = 450).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   219
    self assert:(rslt asPicoseconds = 450000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   220
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   221
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   222
    t := TimeDuration fromMilliseconds:100.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   223
    t := t + 50 nanoseconds.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   224
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   225
    rslt := t * 5.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   226
    self assert:(rslt asNanoseconds = 500000250).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   227
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   228
    rslt := 5 * t.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   229
    self assert:(rslt asNanoseconds = 500000250).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   230
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   231
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   232
    "
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   233
     self new test_03_Multiplication
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   234
    "
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   235
!
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   236
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   237
test_04_Division
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   238
    |t rslt|
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   239
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   240
    t := TimeDuration fromSeconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   241
    rslt := t / 5.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   242
    self assert:(rslt asMilliseconds == 200).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   243
    self assert:(rslt asPicoseconds = 200000000000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   244
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   245
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   246
    t := TimeDuration fromSeconds:2.2.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   247
    rslt := t / 2.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   248
    self assert:(rslt asMilliseconds == 1100).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   249
    self assert:(rslt asPicoseconds = 1100000000000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   250
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   251
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   252
    t := TimeDuration fromNanoseconds:450.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   253
    rslt := t / 4.5.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   254
    self assert:(rslt asNanoseconds = 100).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   255
    self assert:(rslt asPicoseconds = 100000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   256
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   257
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   258
    t := TimeDuration fromMilliseconds:100.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   259
    t := t + 50 nanoseconds.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   260
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   261
    rslt := t / 5.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   262
    self assert:(rslt asNanoseconds = 20000010).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   263
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   264
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   265
    "
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   266
     self new test_04_Division
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   267
    "
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   268
!
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   269
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   270
test_05_Division    
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   271
    "dividing two timeDurations gives a numeric quotient"
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   272
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   273
    |t1 t2 rslt|
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   274
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   275
    t1 := TimeDuration fromSeconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   276
    t2 := TimeDuration fromSeconds:2.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   277
    rslt := t1 / t2.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   278
    self assert:(rslt isNumber).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   279
    self assert:(rslt = 0.5).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   280
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   281
    t1 := TimeDuration fromSeconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   282
    t2 := TimeDuration fromMilliseconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   283
    rslt := t1 / t2.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   284
    self assert:(rslt isNumber).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   285
    self assert:(rslt = 1000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   286
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   287
    t1 := TimeDuration fromMilliseconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   288
    t2 := TimeDuration fromMicroseconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   289
    rslt := t1 / t2.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   290
    self assert:(rslt isNumber).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   291
    self assert:(rslt = 1000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   292
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   293
    t1 := TimeDuration fromMicroseconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   294
    t2 := TimeDuration fromNanoseconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   295
    rslt := t1 / t2.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   296
    self assert:(rslt isNumber).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   297
    self assert:(rslt = 1000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   298
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   299
    t1 := TimeDuration fromSeconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   300
    t2 := TimeDuration fromNanoseconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   301
    rslt := t1 / t2.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   302
    self assert:(rslt isNumber).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   303
    self assert:(rslt = 1000000000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   304
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   305
    t1 := TimeDuration fromSeconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   306
    t2 := TimeDuration fromNanoseconds:50.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   307
    rslt := t1 / t2.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   308
    self assert:(rslt isNumber).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   309
    self assert:(rslt = 20000000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   310
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   311
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   312
    "
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   313
     self new test_05_Division
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   314
    "
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   315
!
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   316
1923
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   317
test_06_miscArithmetic    
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   318
    |t rslt|
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   319
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   320
    t := TimeDuration fromSeconds:1.
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   321
    rslt := t negated.
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   322
    self assert:(rslt asSeconds = -1).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   323
    self assert:(rslt = (TimeDuration fromSeconds:-1)).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   324
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   325
    t := TimeDuration fromMicroseconds:1.
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   326
    rslt := t negated.
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   327
    self assert:(rslt asMicroseconds = -1).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   328
    self assert:(rslt = (TimeDuration fromMicroseconds:-1)).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   329
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   330
    t := TimeDuration fromMicroseconds:10001.
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   331
    rslt := t negated.
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   332
    self assert:(rslt asMicroseconds = -10001).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   333
    self assert:(rslt = (TimeDuration fromMicroseconds:-10001)).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   334
    rslt := rslt negated.
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   335
    self assert:(rslt asMicroseconds = 10001).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   336
    self assert:(rslt = (TimeDuration fromMicroseconds:10001)).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   337
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   338
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   339
    t := TimeDuration fromMicroseconds:-10001.
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   340
    rslt := t abs.
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   341
    self assert:(rslt asMicroseconds = 10001).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   342
    self assert:(rslt = (TimeDuration fromMicroseconds:10001)).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   343
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   344
    "
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   345
     self new test_06_miscArithmetic
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   346
    "
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   347
!
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   348
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   349
test_09_Reading
1918
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   350
    |t1 t2|
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   351
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   352
    t2 := TimeDuration fromString:'1.001s'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   353
    self assert:(t2 asMilliseconds == 1001).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   354
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   355
    t1 := TimeDuration fromString:'1001ms'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   356
    self assert:(t1 asMilliseconds = 1001).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   357
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   358
    t1 := TimeDuration fromString:'1001ns'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   359
    self assert:(t1 asNanoseconds = 1001).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   360
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   361
    t1 := TimeDuration fromString:'1001us'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   362
    self assert:(t1 asMicroseconds = 1001).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   363
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   364
    t1 := TimeDuration fromString:'1001ps'.
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   365
    self assert:(t1 asPicoseconds = 1001).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   366
1918
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   367
    t1 := TimeDuration fromString:'1s 30us'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   368
    self assert:(t1 asMicroseconds = 1000030).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   369
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   370
    t1 := TimeDuration fromString:'0.1s'.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   371
    self assert:(t1 asMilliseconds = 100).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   372
    t1 := TimeDuration fromString:'0.1ms'.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   373
    self assert:(t1 asMicroseconds = 100).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   374
    t1 := TimeDuration fromString:'0.1us'.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   375
    self assert:(t1 asNanoseconds = 100).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   376
    t1 := TimeDuration fromString:'0.1ns'.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   377
    self assert:(t1 asPicoseconds = 100).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   378
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   379
    t1 := TimeDuration fromString:'0,1ns'.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   380
    self assert:(t1 asPicoseconds = 100).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   381
1918
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   382
    t1 := TimeDuration fromString:'01:30:33'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   383
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   384
    self assert:(t1 asMilliseconds = (((1*3600)+(30*60)+33)*1000)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   385
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   386
    t1 := TimeDuration fromString:'01:30:33.5'.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   387
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   388
    self assert:(t1 asMilliseconds = ((((1*3600)+(30*60)+33)*1000)+500)).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   389
1918
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   390
    t1 := TimeDuration fromString:'01:30:33,5'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   391
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   392
    self assert:(t1 asMilliseconds = ((((1*3600)+(30*60)+33)*1000)+500)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   393
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   394
    t1 := TimeDuration fromString:'01:30:33,05'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   395
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   396
    self assert:(t1 asMilliseconds = ((((1*3600)+(30*60)+33)*1000)+50)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   397
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   398
    t1 := TimeDuration fromString:'01:30:33,005'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   399
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   400
    self assert:(t1 asMilliseconds = ((((1*3600)+(30*60)+33)*1000)+5)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   401
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   402
    t1 := TimeDuration fromString:'01:30:33,0005'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   403
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   404
    self assert:(t1 asMicroseconds = ((((1*3600)+(30*60)+33)*1000*1000)+500)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   405
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   406
    t1 := TimeDuration fromString:'01:30:33,00005'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   407
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   408
    self assert:(t1 asMicroseconds = ((((1*3600)+(30*60)+33)*1000*1000)+50)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   409
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   410
    t1 := TimeDuration fromString:'01:30:33,000005'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   411
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   412
    self assert:(t1 asMicroseconds = ((((1*3600)+(30*60)+33)*1000*1000)+5)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   413
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   414
    t1 := TimeDuration fromString:'01:30:33,0000005'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   415
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   416
    self assert:(t1 asNanoseconds = ((((1*3600)+(30*60)+33)*1000*1000*1000)+500)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   417
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   418
    t1 := TimeDuration fromString:'01:30:33,00000005'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   419
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   420
    self assert:(t1 asNanoseconds = ((((1*3600)+(30*60)+33)*1000*1000*1000)+50)).
333
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
1918
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   422
    t1 := TimeDuration fromString:'01:30:33,000000005'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   423
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   424
    self assert:(t1 asNanoseconds = ((((1*3600)+(30*60)+33)*1000*1000*1000)+5)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   425
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   426
    t1 := TimeDuration fromString:'0.000000005'.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   427
    self assert:(t1 asNanoseconds = 5).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   428
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   429
    t1 := TimeDuration fromString:'0.000000005s'.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   430
    self assert:(t1 asNanoseconds = 5).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   431
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   432
    t1 := TimeDuration fromString:'1d 5h'.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   433
    self assert:(t1 asTruncatedHours = 29).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   434
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   435
    t1 := TimeDuration fromString:'1d 5h 30m'.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   436
    self assert:(t1 asTruncatedHours = 29).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   437
    self assert:(t1 asExactHours = 29.5).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   438
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   439
    "
1923
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   440
     self new test_09_Reading
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   441
    "
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   442
!
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   443
1918
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   444
test_10_PrintingReading
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   445
     #(
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   446
        "/ hours minutes seconds millis
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   447
        (0 0 0 0)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   448
        (0 0 0 1)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   449
        (0 0 0 9)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   450
        (0 0 0 10)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   451
        (0 0 0 11)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   452
        (0 0 0 99)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   453
        (0 0 0 100)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   454
        (0 0 0 101)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   455
        (0 0 0 999)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   456
        (0 0 0 1000)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   457
        (0 0 0 1001)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   458
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   459
        (0 33 0 123)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   460
        (2 0 0 123)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   461
        (2 33 0 123)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   462
        (100 33 0 123)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   463
        (10000 33 0 123)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   464
        (1000000 33 0 123)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   465
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   466
        (2 33 0 0)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   467
        (2 0 0 0)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   468
        (24 0 0 0)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   469
        (0 0 0 123)
333
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
    ) do:[:hmsms |
1918
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   471
        |h m s ms d1 d2 s1 s2|
333
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
1918
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   473
        h := hmsms first.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   474
        m := hmsms second.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   475
        s := hmsms third.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   476
        ms := hmsms fourth.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   477
        "/ generate a duration
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   478
        d1 := TimeDuration hours:h minutes:m seconds:s milliseconds:ms.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   479
        "/ print it
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   480
        s1 := d1 printString.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   481
        "/ read it back
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   482
        d2 := TimeDuration readFrom:s1.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   483
        s2 := d2 printString.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   484
        "/ same time?
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   485
        self assert:(d1 = d2).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   486
        self assert:(d1 timeEncoding = d2 timeEncoding).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   487
        "/ same string?
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   488
        self assert:(s1 = s2).
333
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   489
     ].
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   490
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
   492
"/     (TimeDuration hours:0 minutes:0 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
   493
"/     (TimeDuration hours:0 minutes:0 seconds:10 milliseconds:123) printStringFormat:'%h:%m:%s'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
   494
"/     (TimeDuration hours:0 minutes:33 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
   495
"/     (TimeDuration hours:2 minutes:33 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
   496
"/     (TimeDuration hours:100 minutes:33 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
   497
"/     (TimeDuration hours:10000 minutes:33 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
   498
"/     (TimeDuration hours:1000000 minutes:33 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s'
333
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   499
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
    "
1918
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   501
     self new test_10_PrintingReading
333
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   502
    "
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   503
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   504
    "Created: / 18-07-2007 / 14:02:01 / cg"
1925
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   505
!
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   506
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   507
test_11_Comparing
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   508
    |t1 t2|
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   509
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   510
    t1 := TimeDuration fromSeconds:1.
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   511
    t2 := t1 + 1 picoseconds.
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   512
    self assert:(t2 > t1).
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   513
    self assert:(t2 >= t1).
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   514
    self assert:(t2 = t1) not.
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   515
    self assert:(t2 <= t1) not.
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   516
    self assert:(t2 < t1) not.
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   517
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   518
    t1 := TimeDuration fromSeconds:1.
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   519
    t2 := t1 - 1 picoseconds.
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   520
    self assert:(t2 < t1).
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   521
    self assert:(t2 <= t1).
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   522
    self assert:(t2 = t1) not.
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   523
    self assert:(t2 >= t1) not.
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   524
    self assert:(t2 > t1) not.
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   525
2244
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   526
    t1 := TimeDuration fromSeconds:0.001.   "/ 1 milli
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   527
    t2 := TimeDuration fromSeconds:0.0009.  "/ 900 micros
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   528
    self assert:(t2 < t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   529
    self assert:(t2 <= t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   530
    self assert:(t2 = t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   531
    self assert:(t2 >= t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   532
    self assert:(t2 > t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   533
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   534
    t1 := TimeDuration fromSeconds:0.0001.   "/ 100 micros
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   535
    t2 := TimeDuration fromSeconds:0.00009.  "/ 90 micros
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   536
    self assert:(t2 < t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   537
    self assert:(t2 <= t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   538
    self assert:(t2 = t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   539
    self assert:(t2 >= t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   540
    self assert:(t2 > t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   541
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   542
    t1 := TimeDuration fromSeconds:0.00001.   "/ 10 micros
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   543
    t2 := TimeDuration fromSeconds:0.000009.  "/ 9 micros
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   544
    self assert:(t2 < t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   545
    self assert:(t2 <= t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   546
    self assert:(t2 = t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   547
    self assert:(t2 >= t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   548
    self assert:(t2 > t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   549
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   550
    t1 := TimeDuration fromSeconds:0.000001.   "/ 1 micros
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   551
    t2 := TimeDuration fromSeconds:0.0000009.  "/ 900 nanos
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   552
    self assert:(t2 < t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   553
    self assert:(t2 <= t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   554
    self assert:(t2 = t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   555
    self assert:(t2 >= t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   556
    self assert:(t2 > t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   557
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   558
    t1 := TimeDuration fromSeconds:0.0000001.   "/ 100 nanos
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   559
    t2 := TimeDuration fromSeconds:0.00000009.  "/ 90 nanos
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   560
    self assert:(t2 < t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   561
    self assert:(t2 <= t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   562
    self assert:(t2 = t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   563
    self assert:(t2 >= t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   564
    self assert:(t2 > t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   565
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   566
    t1 := TimeDuration fromSeconds:0.00000001.   "/ 10 nanos
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   567
    t2 := TimeDuration fromSeconds:0.000000009.  "/ 9 nanos
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   568
    self assert:(t2 < t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   569
    self assert:(t2 <= t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   570
    self assert:(t2 = t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   571
    self assert:(t2 >= t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   572
    self assert:(t2 > t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   573
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   574
    t1 := TimeDuration fromSeconds:0.000000001.   "/ 1 nanos
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   575
    t2 := TimeDuration fromSeconds:0.0000000009.  "/ 900 picos
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   576
    self assert:(t2 < t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   577
    self assert:(t2 <= t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   578
    self assert:(t2 = t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   579
    self assert:(t2 >= t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   580
    self assert:(t2 > t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   581
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   582
    t1 := TimeDuration fromSeconds:0.0000000001.   "/ 100 picos
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   583
    t2 := TimeDuration fromSeconds:0.00000000009.  "/ 90 picos
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   584
    self assert:(t2 < t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   585
    self assert:(t2 <= t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   586
    self assert:(t2 = t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   587
    self assert:(t2 >= t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   588
    self assert:(t2 > t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   589
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   590
    t1 := TimeDuration fromSeconds:0.00000000001.   "/ 10 picos
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   591
    t2 := TimeDuration fromSeconds:0.000000000009.  "/ 9 picos
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   592
    self assert:(t2 < t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   593
    self assert:(t2 <= t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   594
    self assert:(t2 = t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   595
    self assert:(t2 >= t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   596
    self assert:(t2 > t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   597
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   598
    t1 := TimeDuration fromSeconds:0.000000000001.   "/ 1 picos
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   599
    t2 := TimeDuration fromSeconds:0.0000000000009.  "/ 0.9 picos
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   600
    self assert:(t2 < t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   601
    self assert:(t2 <= t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   602
    self assert:(t2 = t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   603
    self assert:(t2 >= t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   604
    self assert:(t2 > t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   605
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   606
    "/ below the picosecond resolution
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   607
    "/ these will compare as equal
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   608
    "/ t1 := TimeDuration fromSeconds:0.0000000000001.   "/ 0.1 picos
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   609
    "/ t2 := TimeDuration fromSeconds:0.00000000000009.  "/ 0.09 picos
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   610
    "/ self assert:(t2 < t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   611
    "/ self assert:(t2 <= t1).
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   612
    "/ self assert:(t2 = t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   613
    "/ self assert:(t2 >= t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   614
    "/ self assert:(t2 > t1) not.
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   615
1925
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   616
    "
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   617
     self new test_11_Comparing
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   618
    "
2244
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   619
7eeff5b74e84 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   620
    "Modified: / 26-05-2019 / 10:14:30 / Claus Gittinger"
2245
bfbf845df5cf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   621
!
bfbf845df5cf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   622
bfbf845df5cf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   623
test_12_Creation
bfbf845df5cf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   624
    |t1 t2|
bfbf845df5cf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   625
bfbf845df5cf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   626
    t1 := TimeDuration fromSeconds:0.001.
bfbf845df5cf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   627
    t2 := TimeDuration fromMilliseconds:1.
bfbf845df5cf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   628
    self assert:(t2 = t1).
bfbf845df5cf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   629
bfbf845df5cf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   630
    "
bfbf845df5cf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   631
     self new test_12_Creation
bfbf845df5cf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   632
    "
bfbf845df5cf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   633
bfbf845df5cf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2244
diff changeset
   634
    "Created: / 26-05-2019 / 10:15:50 / Claus Gittinger"
333
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   635
! !
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   637
!TimeDurationTest class methodsFor:'documentation'!
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   638
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   639
version
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   640
    ^ '$Header$'
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   641
!
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   642
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   643
version_CVS
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   644
    ^ '$Header$'
333
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   645
! !
1078
a4829ce2f3f1 category change
Claus Gittinger <cg@exept.de>
parents: 678
diff changeset
   646