RegressionTests__NumberTest.st
author Claus Gittinger <cg@exept.de>
Tue, 25 Feb 2020 17:19:49 +0100
changeset 2586 7dc7be5a6f3d
parent 2496 568e830146a8
permissions -rw-r--r--
#OTHER by cg s
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1072
diff changeset
     1
"{ Package: 'stx:goodies/regression' }"
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"{ NameSpace: RegressionTests }"
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
TestCase subclass:#NumberTest
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
     6
	instanceVariableNames:'a b'
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
     7
	classVariableNames:''
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
     8
	poolDictionaries:''
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
     9
	category:'tests-Regression-Numbers'
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
!
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
!NumberTest methodsFor:'accessing'!
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
a
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
    ^ a
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
!
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
a:something
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
    a := something.
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
b
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
    ^ b
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
b:something
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
    b := something.
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
! !
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
2162
b88079711bb5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1916
diff changeset
    31
!NumberTest methodsFor:'initialize / release'!
327
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
    32
670
4fd7b73a1c19 added: #tearDown
Stefan Vogel <sv@exept.de>
parents: 610
diff changeset
    33
tearDown
4fd7b73a1c19 added: #tearDown
Stefan Vogel <sv@exept.de>
parents: 610
diff changeset
    34
    Class withoutUpdatingChangesDo:[
1719
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
    35
        self class removeSelector:#testEQ
670
4fd7b73a1c19 added: #tearDown
Stefan Vogel <sv@exept.de>
parents: 610
diff changeset
    36
    ].
327
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
    37
! !
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
    38
2407
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    39
!NumberTest methodsFor:'tests-comparing'!
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    40
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    41
test_minMax
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    42
    self assert:(0.5 min:1) = 0.5.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    43
    self assert:(1.5 min:1) = 1.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    44
    self assert:(2 min:1) = 1.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    45
    self assert:(-1 min:1) = -1.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    46
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    47
    self assert:(0.5 max:1) = 1.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    48
    self assert:(1.5 max:1) = 1.5.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    49
    self assert:(1.5 max:2) = 2.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    50
    self assert:(2 max:1) = 2.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    51
    self assert:(-1 max:1) = 1.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    52
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    53
    self assert:(0.5 min:1 max:0) = 0.5.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    54
    self assert:(1 min:1 max:0) = 1.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    55
    self assert:(1.5 min:1 max:0) = 1.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    56
    self assert:(2 min:1 max:0) = 1.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    57
    self assert:(0 min:1 max:0) = 0.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    58
    self assert:(0.0 min:1 max:0) = 0.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    59
    self assert:(-1 min:1 max:0) = 0.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    60
! !
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    61
315
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
    62
!NumberTest methodsFor:'tests-concrete bugs'!
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
test_eqNumberBug
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
    "reported 09-09-2004;
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
     stc generated wrong code for some inlined = - compare (shame)."
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    67
2231
3891e2a93a7f #BUGFIX by Stefan Reise
sr
parents: 2227
diff changeset
    68
    self 
3891e2a93a7f #BUGFIX by Stefan Reise
sr
parents: 2227
diff changeset
    69
        skipIf:ExternalAddress pointerSize = 8 
3891e2a93a7f #BUGFIX by Stefan Reise
sr
parents: 2227
diff changeset
    70
        description:'Compile does not work under 64bit'.
3891e2a93a7f #BUGFIX by Stefan Reise
sr
parents: 2227
diff changeset
    71
2227
c0e82b4ad5b9 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2162
diff changeset
    72
    false "(Helper
1883
90e8d12f45d2 #REFACTORING by sr
sr
parents: 1877
diff changeset
    73
        isStcCompiledMethod:#test_eqNumberBug
1916
1054b1b5ccee #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1883
diff changeset
    74
        in:self
2227
c0e82b4ad5b9 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2162
diff changeset
    75
    )" ifTrue:[
1916
1054b1b5ccee #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1883
diff changeset
    76
        self 
1054b1b5ccee #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1883
diff changeset
    77
            skipIf:true
1054b1b5ccee #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1883
diff changeset
    78
            description:'#compile is not available in stand alone apps'.
1054b1b5ccee #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1883
diff changeset
    79
    ].            
1883
90e8d12f45d2 #REFACTORING by sr
sr
parents: 1877
diff changeset
    80
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    Class withoutUpdatingChangesDo:[
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    82
        self class
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    83
            compile:
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
'testEQ
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
    a = b ifTrue:[^ false].
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    ^ true.
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
'
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    88
            classified:'temporary'.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    ].
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    93
           a:0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    94
           b:0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    98
           a:0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    99
           b:0.0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   103
           a:0.0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   104
           b:0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   108
           a:0.0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   109
           b:0.0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    Class withoutUpdatingChangesDo:[
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   112
        Compiler stcCompileMethod:(self class compiledMethodAt:#testEQ).
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    ].
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   117
           a:0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   118
           b:0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   122
           a:0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   123
           b:0.0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   127
           a:0.0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   128
           b:0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   132
           a:0.0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   133
           b:0.0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
    Class withoutUpdatingChangesDo:[
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   136
        self class removeSelector:#testEQ
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    ].
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    "
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
     self new test_eqNumberBug
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    "
2227
c0e82b4ad5b9 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2162
diff changeset
   142
c0e82b4ad5b9 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2162
diff changeset
   143
    "Modified (format): / 06-05-2019 / 14:12:55 / Claus Gittinger"
2231
3891e2a93a7f #BUGFIX by Stefan Reise
sr
parents: 2227
diff changeset
   144
    "Modified: / 21-05-2019 / 16:20:50 / Stefan Reise"
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
! !
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
327
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   147
!NumberTest methodsFor:'tests-conversion-rounding'!
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   148
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   149
test_conversion
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   150
    "reported as Bug 388
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   151
     Current implementation neither truncate nor round to nearest Floating point
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   152
     value, it just accumulate round off errors."
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   153
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   154
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   155
    self assert: 16r1FFFFFFFFFFFF0801 asDouble ~= 16r1FFFFFFFFFFFF0800 asDouble.
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   156
    "this test is on 65 bits"
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   157
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   158
    self assert: 16r1FFFFFFFFFFFF0802 asDouble ~= 16r1FFFFFFFFFFFF0800 asDouble.
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   159
    "this test is on 64 bits"
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   160
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   161
    self assert: 16r1FFFFFFFFFFF1F800 asDouble = 16r1FFFFFFFFFFF20000 asDouble.
2424
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   162
    "nearest even is higher"
327
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   163
    self assert: 16r1FFFFFFFFFFFF0800 asDouble = 16r1FFFFFFFFFFFF0000 asDouble.
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   164
    "nearest even is lower"
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   165
2424
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   166
    self assert: 16r1FFFFFFFFFFF1F800 asLongFloat ~= 16r1FFFFFFFFFFF20000 asLongFloat.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   167
    self assert: 16r1FFFFFFFFFFFF0800 asLongFloat ~= 16r1FFFFFFFFFFFF0000 asLongFloat.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   168
327
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   169
    "Created: / 24-10-2006 / 15:31:20 / cg"
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   170
! !
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   171
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   172
!NumberTest methodsFor:'tests-printing'!
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   173
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   174
testPrintf_FixedPoint
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   175
    "/ FixedPoint
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   176
    
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   177
    |pi|
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   178
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   179
    pi := FixedPoint pi.
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   180
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   181
    self assert:( (PrintfScanf printf:'%.4f' argument:pi) = '3.1416' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   182
    self assert:( (PrintfScanf printf:'%.8f' argument:pi)  = '3.14159265' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   183
    self assert:( (PrintfScanf printf:'%f' argument:pi)    = '3.141593' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   184
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   185
    "/ too small
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   186
    self assert:( (pi printfPrintString:'%4Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   187
    self assert:( (pi printfPrintString:'%5Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   188
    self assert:( (pi printfPrintString:'%6Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   189
    self assert:( (pi printfPrintString:'%7Lf') = '3.141593' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   190
    "/ fit
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   191
    self assert:( (pi printfPrintString:'%8Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   192
    self assert:( (pi printfPrintString:'%4.2Lf') = '3.14' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   193
    "/ left filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   194
    self assert:( (pi printfPrintString:'%9Lf') = ' 3.141593' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   195
    "/ right filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   196
    self assert:( (pi printfPrintString:'%-9Lf') = '3.141593 ' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   197
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   198
    "Created: / 10-10-2017 / 12:36:21 / cg"
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   199
    "Modified: / 10-10-2017 / 16:29:20 / cg"
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   200
!
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   201
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   202
testPrintf_Float
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   203
    "/ Float
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   204
    
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   205
    |pi|
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   206
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   207
    pi := Float pi.
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   208
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   209
    self assert:( (PrintfScanf printf:'%.0f' argument:pi)  = '3' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   210
    self assert:( (PrintfScanf printf:'%#.0f' argument:pi) = '3.0' ).  "/ hash forces print of '.0'
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   211
    self assert:( (PrintfScanf printf:'%.1f' argument:pi)  = '3.1' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   212
    self assert:( (PrintfScanf printf:'%#.1f' argument:pi) = '3.1' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   213
    self assert:( (PrintfScanf printf:'%.2f' argument:pi)  = '3.14' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   214
    self assert:( (PrintfScanf printf:'%.3f' argument:pi)  = '3.142' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   215
    self assert:( (PrintfScanf printf:'%.4f' argument:pi)  = '3.1416' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   216
    self assert:( (PrintfScanf printf:'%.8f' argument:pi)  = '3.14159265' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   217
    self assert:( (PrintfScanf printf:'%f' argument:pi)    = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   218
    self assert:( (PrintfScanf printf:'%4f' argument:pi)   = '3.141593' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   219
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   220
    "/ too small
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   221
    self assert:( (pi printfPrintString:'%4f') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   222
    self assert:( (pi printfPrintString:'%5f') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   223
    self assert:( (pi printfPrintString:'%6f') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   224
    self assert:( (pi printfPrintString:'%7f') = '3.141593' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   225
    "/ fit
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   226
    self assert:( (pi printfPrintString:'%8f')   = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   227
    self assert:( (pi printfPrintString:'%4.2f') = '3.14' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   228
    "/ left filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   229
    self assert:( (pi printfPrintString:'%9f')   = ' 3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   230
    self assert:( (pi printfPrintString:'%8.4f') = '  3.1416' ).
1776
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   231
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   232
    "/ right filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   233
    self assert:( (pi printfPrintString:'%-9f') = '3.141593 ' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   234
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   235
false ifTrue:[
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   236
    #(
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   237
        '%.3f'       1.0      '1.0'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   238
    ) inGroupsOf:3 do:[:fmt :val :expected|
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   239
        |printfGenerated stxGenerated|
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   240
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   241
        printfGenerated := val printfPrintString:fmt.
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   242
        stxGenerated := PrintfScanf printf:fmt argument:val.
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   243
        self assert:(stxGenerated = printfGenerated).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   244
        self assert:(printfGenerated = expected).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   245
    ].
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   246
].
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   247
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   248
    self assert:( (1.0 printfPrintString:'%4f') = '1.000000' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   249
    self assert:( (1.0 printfPrintString:'%5f') = '1.000000' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   250
    self assert:( (1.0 printfPrintString:'%6f') = '1.000000' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   251
    self assert:( (1.0 printfPrintString:'%7f') = '1.000000' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   252
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   253
    self assert:( (1.0 printfPrintString:'%.0f') = '1' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   254
    self assert:( (1.0 printfPrintString:'%#.0f') = '1.' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   255
    self assert:( (1.0 printfPrintString:'%#.0g') = '1.' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   256
    self assert:( (1.0 printfPrintString:'%#.1f') = '1.0' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   257
    self assert:( (1.0 printfPrintString:'%#.1g') = '1.' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   258
    self assert:( (1.0 printfPrintString:'%.1f') = '1.0' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   259
    self assert:( (1.0 printfPrintString:'%.2f') = '1.00' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   260
    self assert:( (1.0 printfPrintString:'%.3f') = '1.000' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   261
    self assert:( (1.0 printfPrintString:'%.4f') = '1.0000' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   262
    self assert:( (1.0 printfPrintString:'%.5f') = '1.00000' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   263
    self assert:( (1.0 printfPrintString:'%.6f') = '1.000000' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   264
    self assert:( (1.0 printfPrintString:'%.7f') = '1.0000000' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   265
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   266
    self assert:( (PrintfScanf printf:'%.0f' argument:1.0)  = '1' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   267
false ifTrue:[
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   268
    self assert:( (PrintfScanf printf:'%#.0f' argument:1.0) = '3.0' ).  "/ hash forces print of '.0'
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   269
].
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   270
    self assert:( (PrintfScanf printf:'%.1f' argument:1.0)  = '1.0' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   271
    self assert:( (PrintfScanf printf:'%#.1f' argument:1.0) = '1.0' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   272
    self assert:( (PrintfScanf printf:'%.2f' argument:1.0)  = '1.0' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   273
    self assert:( (PrintfScanf printf:'%.3f' argument:1.0)  = '1.0' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   274
    self assert:( (PrintfScanf printf:'%.4f' argument:1.0)  = '1.0' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   275
    self assert:( (PrintfScanf printf:'%.8f' argument:1.0)  = '1.0' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   276
    self assert:( (PrintfScanf printf:'%f' argument:1.0)    = '1.0' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   277
    self assert:( (PrintfScanf printf:'%4f' argument:1.0)   = ' 1.0' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   278
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   279
    "Created: / 10-10-2017 / 12:34:51 / cg"
1776
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   280
    "Modified: / 10-10-2017 / 16:32:01 / cg"
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   281
!
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   282
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   283
testPrintf_Fraction
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   284
    "/ Fraction
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   285
    |pi|
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   286
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   287
    pi := Fraction pi.
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   288
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   289
self assert:( (PrintfScanf printf:'%.4f' argument:pi) = '3.1416' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   290
    self assert:( (PrintfScanf printf:'%.8f' argument:pi)  = '3.14159265' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   291
    self assert:( (PrintfScanf printf:'%f' argument:pi)    = '3.141593' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   292
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   293
    "/ too small
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   294
    self assert:( (pi printfPrintString:'%4Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   295
    self assert:( (pi printfPrintString:'%5Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   296
    self assert:( (pi printfPrintString:'%6Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   297
    self assert:( (pi printfPrintString:'%7Lf') = '3.141593' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   298
    "/ fit
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   299
    self assert:( (pi printfPrintString:'%8Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   300
    self assert:( (pi printfPrintString:'%4.2Lf') = '3.14' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   301
    "/ left filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   302
    self assert:( (pi printfPrintString:'%9Lf') = ' 3.141593' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   303
    "/ right filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   304
    self assert:( (pi printfPrintString:'%-9Lf') = '3.141593 ' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   305
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   306
    "Created: / 10-10-2017 / 12:37:25 / cg"
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   307
    "Modified: / 10-10-2017 / 16:29:27 / cg"
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   308
!
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   309
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   310
testPrintf_Integer
2457
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   311
    |skipB systemIsWin32Bit|
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   312
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   313
    systemIsWin32Bit := OperatingSystem isMSWINDOWSlike and:[ ExternalAddress pointerSize == 4 ].
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   314
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   315
    "/ Integers
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   316
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   317
    "/ verify that our printf generates the same string as the system-printf.
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   318
    "/ Checks of printfPrintString: are here to make sure, that the system's printf is doing it right...)
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   319
    self assert:( (20 printfPrintString:'%d') = '20' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   320
    self assert:( (20 printfPrintString:'% d') = ' 20' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   321
    self assert:( (-20 printfPrintString:'% d') = '-20' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   322
    self assert:( (20 printfPrintString:'%#d') = '20' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   323
    self assert:( (20 printfPrintString:'%#5d') = '   20' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   324
    self assert:( (20 printfPrintString:'% -#5d') = ' 20  ' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   325
    self assert:( (20 printfPrintString:'%- #5d') = ' 20  ' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   326
    self assert:( (20 printfPrintString:'%-# 5d') = ' 20  ' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   327
    self assert:( (20 printfPrintString:'%-#5d') = '20   ' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   328
    self assert:( (20 printfPrintString:'%-#05d') = '20   ' ).   "/ NOTICE
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   329
    self assert:( (20 printfPrintString:'%-0#5d') = '20   ' ).   "/ NOTICE
2457
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   330
    "/ borland printf is wrong here
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   331
    (OperatingSystem isMSWINDOWSlike and:[ ExternalAddress pointerSize == 4]) ifTrue:[
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   332
        "/ skip
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   333
    ] ifFalse:[
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   334
        self assert:( (20 printfPrintString:'%0-#5d') = '20   ' ).   "/ NOTICE - some printf's dont do this correctly
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   335
        self assert:( (20 printfPrintString:'%0#-5d') = '20   ' ).   "/ NOTICE
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   336
    ].
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   337
    self assert:( (20 printfPrintString:'%#05d') = '00020' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   338
    self assert:( (20 printfPrintString:'%+ 5d') = '  +20' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   339
    self assert:( (20 printfPrintString:'%- 5d') = ' 20  ' ).     
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   340
    self assert:( (-20 printfPrintString:'%- 5d') = '-20  ' ).     
2457
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   341
    self assert:( ( 20 printfPrintString:'%-+ 5d') = '+20  ' ).     
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   342
    self assert:( (-20 printfPrintString:'%-+ 5d') = '-20  ' ).     
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   343
    self assert:( ( 20 printfPrintString:'%+ 5d') = '  +20' ).     
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   344
    self assert:( (-20 printfPrintString:'%+ 5d') = '  -20' ).     
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   345
    self assert:( ( 0 printfPrintString:'%+ 5d') = '   +0' ).     
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   346
    self assert:( ( 0 printfPrintString:'%-+ 5d') = '+0   ' ).     
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   347
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   348
    self assert:( (20 printfPrintString:'%# 5d') = '   20' ).
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   349
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   350
    "/ skip with borland (that printf is wrong):
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   351
    skipB := #( 
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   352
                ('%D'  nil)     "/ not supported at all
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   353
                ('%#x' 0  )     "/ printf is wrong: always prepending 0x - even for 0 value
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   354
                ('%#o' 0  )     "/ printf is wrong: always prepending 0 - even for 0 value
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   355
             ).
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   356
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   357
    #(
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   358
        '%d'         20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   359
        '%d'        -20      '-20'  
2496
568e830146a8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2495
diff changeset
   360
        "/ '%D'         20      '20'      "/ works in ST/X and OSX-print, but not Win32-printf
568e830146a8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2495
diff changeset
   361
        "/ '%D'        -20      '-20'     "/ works in ST/X and OSX-print, but not Win32-printf
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   362
        '%ld'        20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   363
        '%ld'       -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   364
        '%lld'       20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   365
        '%lld'      -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   366
        '%hd'        20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   367
        '%hd'       -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   368
        '%hhd'       20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   369
        '%hhd'      -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   370
        '%lhd'       20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   371
        '%hld'      -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   372
        '% d'        20      ' 20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   373
        '% d'       -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   374
        '%#d'        20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   375
        '%#d'       -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   376
        '%5d'        20      '   20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   377
        '%5d'       -20      '  -20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   378
        '%-5d'       20      '20   '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   379
        '%-5d'      -20      '-20  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   380
        '%05d'       20      '00020'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   381
        '%05d'      -20      '-0020'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   382
        '%-05d'      20      '20   '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   383
        '%-05d'     -20      '-20  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   384
        '% 5d'       20      '   20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   385
        '% 5d'      -20      '  -20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   386
        '%- 5d'      20      ' 20  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   387
        '%- 5d'     -20      '-20  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   388
        '%.0d'       20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   389
        '%.0d'      -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   390
        '%.0d'        0      ''  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   391
        '%x'         20      '14'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   392
        '%x'        255      'ff'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   393
        '%X'        255      'FF'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   394
        '%#x'       255      '0xff'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   395
        '%#X'       255      '0XFF'   "/ printf also uppercases the 'x'
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   396
        '%x'          0      '0'  
2457
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   397
        '%#x'         0      '0'      "/ with zero, no 0x should be prepended
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   398
        '%#x'        20      '0x14'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   399
        '%5x'        20      '   14'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   400
        '%-5x'       20      '14   '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   401
        '%#5x'       20      ' 0x14'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   402
        '%-#5x'      20      '0x14 '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   403
        '%#-5x'      20      '0x14 '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   404
        '%#-5X'      20      '0X14 '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   405
     "/   '%x'   -20      '-14'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   406
        '%o'         20      '24'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   407
        '%o'          0      '0'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   408
        '%#o'        20      '024'  
2457
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   409
        '%#o'         0      '0'        "/ with zero, no 0 should be prepended
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   410
        '%5o'        20      '   24'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   411
        '%-5o'       20      '24   '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   412
        '%#5o'       20      '  024'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   413
        '%-#5o'      20      '024  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   414
        '%#-5o'      20      '024  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   415
        '%-#05o'     20      '024  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   416
        '%#05o'      20      '00024'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   417
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   418
        '%2d'      1234      '1234'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   419
     "/   '%2.2d'    1234      '1234'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   420
        '%2x'        10      ' a'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   421
        '%2X'        10      ' A'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   422
        '%02x'       10      '0a'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   423
        '%02X'       10      '0A'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   424
     "/   '%o'   -20      '-24'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   425
        '%#5d'       20      '   20'
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   426
        '%-#5d'     -20      '-20  '
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   427
        '%-#5d'     -20      '-20  '
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   428
        '%-#05d'    -20      '-20  '
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   429
        '%#05d'     -20      '-0020'
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   430
        '%-#5d'      20      '20   '
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   431
        '%-#5d'      20      '20   '
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   432
        '%-#05d'     20      '20   '
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   433
        '%-#05x'     20      '0x14 '
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   434
        '%#05x'      20      '0x014'
2394
168fb84c7806 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2392
diff changeset
   435
168fb84c7806 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2392
diff changeset
   436
        '%.3x'   0xAFFE      'affe'      "/ max length ignored for numbers
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   437
    ) inGroupsOf:3 do:[:fmt :val :expected|
2457
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   438
        |skip printfGenerated stxGenerated|
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   439
2457
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   440
        skip := false.
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   441
        systemIsWin32Bit ifTrue:[
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   442
            skip := skipB contains:[:pair | (pair first = fmt) and:[(pair second ? val) = val]].
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   443
        ].
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   444
        skip ifTrue:[
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   445
            Transcript showCR:'skipped check for %1 (borland printf does not handle it correctly)' with:fmt
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   446
        ] ifFalse:[
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   447
            printfGenerated := val printfPrintString:fmt.
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   448
            stxGenerated := PrintfScanf printf:fmt argument:val.
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   449
            self assert:(stxGenerated = printfGenerated).
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   450
            self assert:(printfGenerated = expected).
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   451
        ]
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   452
    ].
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   453
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   454
    "/ hex
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   455
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   456
    self assert:( (PrintfScanf printf:'%x' argument:-20) = '-14' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   457
    self assert:( (PrintfScanf printf:'%#x' argument:-20) = '-0x14' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   458
    self assert:( (PrintfScanf printf:'%#7x' argument:-20) = '  -0x14' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   459
    self assert:( (PrintfScanf printf:'%-#7x' argument:-20) = '-0x14  ' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   460
    self assert:( (PrintfScanf printf:'%-#07x' argument:-20) = '-0x14  ' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   461
    self assert:( (PrintfScanf printf:'%#07x' argument:-20) = '-0x0014' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   462
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   463
    "/ octal
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   464
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   465
    self assert:( (PrintfScanf printf:'%o' argument:-20) = '-24' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   466
    self assert:( (PrintfScanf printf:'%#o' argument:-20) = '-024' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   467
    self assert:( (PrintfScanf printf:'%#5o' argument:-20) = ' -024' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   468
    self assert:( (PrintfScanf printf:'%-#5o' argument:-20) = '-024 ' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   469
    self assert:( (PrintfScanf printf:'%-#05o' argument:-20) = '-024 ' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   470
    self assert:( (PrintfScanf printf:'%#05o' argument:-20) = '-0024' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   471
!
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   472
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   473
testPrintf_LargeFloat
2267
65cbf58d8983 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   474
    "/ LargeFloat- unfinished
1862
54413f61d192 #BUGFIX by sr
sr
parents: 1776
diff changeset
   475
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   476
    |lf pi|
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   477
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   478
    pi := LargeFloat pi.
2424
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   479
1862
54413f61d192 #BUGFIX by sr
sr
parents: 1776
diff changeset
   480
    self 
2268
360e548237a1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 2267
diff changeset
   481
        skipIf:(Smalltalk isSmalltalkDevelopmentSystem not)
360e548237a1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 2267
diff changeset
   482
        description:'work in progress'.
360e548237a1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 2267
diff changeset
   483
360e548237a1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 2267
diff changeset
   484
    self 
1862
54413f61d192 #BUGFIX by sr
sr
parents: 1776
diff changeset
   485
        skipIf:(Smalltalk at:#LargeFloat) isNil  
54413f61d192 #BUGFIX by sr
sr
parents: 1776
diff changeset
   486
        description:'LargeFloat is not loaded'.
54413f61d192 #BUGFIX by sr
sr
parents: 1776
diff changeset
   487
2450
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   488
    self assert:(pi printString) = '3.141592653590' "'3.141592653589793238462643383280'".
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   489
    self assert:( (PrintfScanf printf:'%.4f' argument:pi)  = '3.1416' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   490
    self assert:( (PrintfScanf printf:'%.8f' argument:pi)  = '3.14159265' ).
2496
568e830146a8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2495
diff changeset
   491
    "/ disabled, as we currently get different results on different machines
568e830146a8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2495
diff changeset
   492
    "/                                                                                                         0.0000000000000000000000033832795028841888829163053742377087
568e830146a8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2495
diff changeset
   493
    "/ self assert:( (PrintfScanf printf:'%f' argument:pi-(LargeFloat readFrom:'3.14159265358979323846264')) = '0.0000000000000000000000033832795028841973206112925254274159' "'0.00000000000000000000000338328'" ).
2450
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   494
    self assert:( (PrintfScanf printf:'%f' argument:pi)    = '3.14159265359' "'3.141592653589793238462643383280'" ).
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   495
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   496
    "/ too small                                              
2450
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   497
    self assert:( (pi printfPrintString:'%4Lf') = '3.14159265359' "'3.141592653589793238462643383280'" ).
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   498
    self assert:( (pi printfPrintString:'%5Lf') = '3.14159265359' "'3.141592653589793238462643383280'" ).
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   499
    self assert:( (pi printfPrintString:'%6Lf') = '3.14159265359' "'3.141592653589793238462643383280'" ).
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   500
    self assert:( (pi printfPrintString:'%7Lf') = '3.14159265359' "'3.141592653589793238462643383280'" ).
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   501
    "/ fit
2450
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   502
    self assert:( (pi printfPrintString:'%8Lf') = '3.14159265359' "'3.141592653589793238462643383280'" ).
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   503
    self assert:( (pi printfPrintString:'%4.2Lf') = '3.14' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   504
    self assert:( (pi printfPrintString:'%4.3Lf') = '3.142' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   505
    self assert:( (pi printfPrintString:'%4.4Lf') = '3.1416' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   506
    self assert:( (pi printfPrintString:'%4.5Lf') = '3.14159' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   507
    self assert:( (pi printfPrintString:'%4.6Lf') = '3.141593' ).
2338
164c3d4cba01 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   508
    
2424
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   509
    "/ left filled                                               
2450
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   510
    self assert:( (pi printfPrintString:'%9Lf') = '3.14159265359' "' 3.141593'" ).
2424
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   511
    "/ right filled
2450
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   512
    self assert:( (pi printfPrintString:'%-9Lf') = '3.14159265359' "'3.141593 '" ).
2424
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   513
2338
164c3d4cba01 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   514
    "/ exact (to 130 digits)  value is:
2267
65cbf58d8983 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   515
    "/ 3.1415926535 8979323846 2643383279 5028841971 6939937510 5820974944 5923078164 0628620899 8628034825 3421170679 8214808651 3282306647 
2338
164c3d4cba01 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   516
    "/ ((LargeFloat fromString:'3.141592653589793238462643383279') printfPrintString:'%4.20Lf')
2424
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   517
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   518
    lf := 1 asLargeFloat.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   519
    self assert:( (lf printfPrintString:'%4.20Lf') = ' 1.0' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   520
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   521
    self assert:( (lf printfPrintString:'%4.20Lf') = ' 0.1' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   522
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   523
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.01' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   524
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   525
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   526
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   527
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.0001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   528
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   529
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.00001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   530
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   531
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   532
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   533
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.0000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   534
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   535
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.00000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   536
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   537
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.000000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   538
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   539
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.0000000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   540
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   541
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.00000000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   542
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   543
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.000000000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   544
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   545
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.0000000000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   546
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   547
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.00000000000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   548
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   549
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.000000000000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   550
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   551
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.0000000000000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   552
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   553
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.00000000000000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   554
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   555
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.000000000000000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   556
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   557
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.0000000000000000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   558
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   559
    self assert:( (lf printfPrintString:'%4.21Lf') = '0.00000000000000000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   560
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   561
    self assert:( (lf printfPrintString:'%4.22Lf') = '0.000000000000000000001' ).
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   562
    lf := pi.
2467
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   563
    self assert:( (lf printString) = '3.141592653590' ).
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   564
    self assert:( (lf printfPrintString:'%4.20Lf') = '3.14159265358979323846' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   565
    lf := lf - 3.
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   566
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.14159265358979323846' ).
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   567
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   568
    "Created: / 10-10-2017 / 16:25:25 / cg"
2268
360e548237a1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 2267
diff changeset
   569
    "Modified: / 05-06-2019 / 20:15:13 / Claus Gittinger"
2338
164c3d4cba01 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   570
    "Modified (comment): / 22-07-2019 / 19:40:10 / Claus Gittinger"
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   571
!
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   572
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   573
testPrintf_LongFloat
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   574
    "/ LongFloat
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   575
    
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   576
    |pi|
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   577
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   578
    pi := LongFloat pi.
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   579
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   580
    self assert:( (PrintfScanf printf:'%.4f' argument:pi)  = '3.1416' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   581
    self assert:( (PrintfScanf printf:'%.8f' argument:pi)  = '3.14159265' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   582
    self assert:( (PrintfScanf printf:'%f' argument:pi)  = '3.14159265' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   583
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   584
    "/ LongFloat
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   585
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   586
    "/ too small
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   587
    self assert:( (pi printfPrintString:'%4Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   588
    self assert:( (pi printfPrintString:'%5Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   589
    self assert:( (pi printfPrintString:'%6Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   590
    self assert:( (pi printfPrintString:'%7Lf') = '3.141593' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   591
    "/ fit
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   592
    self assert:( (pi printfPrintString:'%8Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   593
    self assert:( (pi printfPrintString:'%4.2Lf') = '3.14' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   594
    "/ left filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   595
    self assert:( (pi printfPrintString:'%9Lf') = ' 3.141593' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   596
    "/ right filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   597
    self assert:( (pi printfPrintString:'%-9Lf') = '3.141593 ' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   598
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   599
    "Created: / 10-10-2017 / 12:35:40 / cg"
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   600
    "Modified: / 10-10-2017 / 16:29:56 / cg"
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   601
!
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   602
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   603
testPrintf_Misc
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   604
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   605
    "/ verify that our printf generates the same string as the system-printf.
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   606
    "/ Checks of printfPrintString: are here to make sure, that the system's printf is doing it right...)
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   607
    self assert:( (20 printfPrintString:'%%%d') = '%20' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   608
    self assert:( (20 printfPrintString:'%d%%') = '20%' ).
2457
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   609
    "/ borland is wrong here
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   610
    (OperatingSystem isMSWINDOWSlike and:[ExternalAddress pointerSize == 4]) ifFalse:[
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   611
        self assert:( (20 printfPrintString:'%d%') = '20' ).
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   612
    ].
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   613
    self assert:( PrintfScanf printf:'%d%' argument:20 ) = '20' .
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   614
2457
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   615
    self assert:( (20 printfPrintString:'%%') = '%' ).
2469
650a6bea83d7 #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 2467
diff changeset
   616
    "/ nobody knows what should happen...
650a6bea83d7 #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 2467
diff changeset
   617
    "/ self assert:( (20 printfPrintString:'\%\') = '\' ).
650a6bea83d7 #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 2467
diff changeset
   618
    "/ self assert:( (20 printfPrintString:'\%') = '%' ).
2457
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   619
    
2396
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   620
    {
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   621
        '%f'   .   Float NaN                .  'nan'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   622
        '%F'   .   Float NaN                .  'NAN'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   623
        '%f'   .   Float infinity           .  'inf'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   624
        '%F'   .   Float infinity           .  'INF'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   625
        '%f'   .   Float negativeInfinity   .  '-inf'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   626
        '%F'   .   Float negativeInfinity   .  '-INF'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   627
2470
0048e48a9057 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2469
diff changeset
   628
        '%+f'  .   Float NaN                .  'nan'  .    
0048e48a9057 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2469
diff changeset
   629
        '%+F'  .   Float NaN                .  'NAN'  .    
0048e48a9057 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2469
diff changeset
   630
        '%+f'  .   Float NaN negated        .  'nan'  .    
0048e48a9057 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2469
diff changeset
   631
        '%+F'  .   Float NaN negated        .  'NAN'  .    
2396
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   632
        '%+f'  .   Float infinity           .  '+inf'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   633
        '%+F'  .   Float infinity           .  '+INF'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   634
        '%+f'  .   Float negativeInfinity   .  '-inf'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   635
        '%+F'  .   Float negativeInfinity   .  '-INF'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   636
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   637
        '% f'  .   Float NaN                .  'nan'  .    "/ not sure if that is reasonable (but printf does the same) 
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   638
        '% F'  .   Float NaN                .  'NAN'  .    "/ not sure if that is reasonable (but printf does the same)
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   639
        '% f'  .   Float infinity           .  ' inf'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   640
        '% F'  .   Float infinity           .  ' INF'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   641
        '% f'  .   Float negativeInfinity   .  '-inf'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   642
        '% F'  .   Float negativeInfinity   .  '-INF'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   643
    } inGroupsOf:3 do:[:fmt :val :expected|
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   644
        |printfGenerated stxGenerated|
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   645
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   646
        printfGenerated := val printfPrintString:fmt.
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   647
        stxGenerated := PrintfScanf printf:fmt argument:val.
2467
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   648
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   649
        self assert:(stxGenerated = expected).
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   650
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   651
        "/ borland printf generates uppercase 'NAN' for %f
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   652
        ((fmt = '%f') and:[ stxGenerated = printfGenerated asLowercase]) ifFalse:[
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   653
            "/ borland printf does not handle %F
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   654
            ((fmt = '%F') and:[ printfGenerated = '%F']) ifFalse:[
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   655
                "/ borland printf is completely wrong with %+f
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   656
                ((fmt = '%+f') and:[ printfGenerated = '++NAN']) ifFalse:[
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   657
                    self assert:(stxGenerated = printfGenerated).
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   658
                ].
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   659
            ].
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   660
        ].
2396
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   661
    ].
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   662
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   663
    #(
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   664
        '%r'       1234      'r'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   665
        '%3r'      1234      '  r'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   666
        '%-3r'      1234     'r  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   667
        '%#r'      1234      'r'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   668
      "/  '%v'       1234      'v'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   669
        '%Id'      1234      'Id'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   670
        '%%%d'         20      '%20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   671
        '%d%%'         20      '20%'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   672
        '%d%'          20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   673
        '%%a%%'        20      '%a%'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   674
    ) inGroupsOf:3 do:[:fmt :val :expected|
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   675
        |printfGenerated stxGenerated|
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   676
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   677
        printfGenerated := val printfPrintString:fmt.
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   678
        stxGenerated := PrintfScanf printf:fmt argument:val.
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   679
        self assert:(stxGenerated = printfGenerated).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   680
        self assert:(printfGenerated = expected).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   681
    ].
2457
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   682
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   683
    "/ more examples from "Secretes of printf"
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   684
    self assert:( (0 printfPrintString:'%d') = '0' ).
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   685
    self assert:( (-7 printfPrintString:'%d') = '-7' ).
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   686
    self assert:( (1560133635 printfPrintString:'%d') = '1560133635' ).
37ef73c45abb #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
   687
    self assert:( (-2035065302 printfPrintString:'%d') = '-2035065302' ).
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   688
!
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   689
2466
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   690
testPrintf_More2
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   691
    "/ additional test patterns from secrets of printf
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   692
    "/ https://www.cypress.com/file/54441/download
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   693
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   694
    {
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   695
        '%d'  .            0       . '0'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   696
        '%d'  .           -7       . '-7'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   697
        '%d'  .   1560133635       . '1560133635'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   698
        '%d'  .  -2035065302       . '-2035065302'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   699
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   700
        '%5d'  .           0       . '    0'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   701
        '%5d'  .          -7       . '   -7'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   702
        '%5d'  .  1560133635       . '1560133635'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   703
        '%5d'  . -2035065302       . '-2035065302'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   704
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   705
        '%-5d'  .           0       . '0    '     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   706
        '%-5d'  .          -7       . '-7   '     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   707
        '%-5d'  .  1560133635       . '1560133635'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   708
        '%-5d'  . -2035065302       . '-2035065302'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   709
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   710
        '%05d'  .           0       . '00000'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   711
        '%05d'  .          -7       . '-0007'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   712
        '%05d'  .  1560133635       . '1560133635'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   713
        '%05d'  . -2035065302       . '-2035065302'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   714
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   715
        '%+5d'  .           0       . '   +0'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   716
        '%+5d'  .          -7       . '   -7'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   717
        '%+5d'  .  1560133635       . '+1560133635'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   718
        '%+5d'  . -2035065302       . '-2035065302'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   719
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   720
        '%+-5d'  .           0       . '+0   '     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   721
        '%+-5d'  .          -7       . '-7   '     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   722
        '%+-5d'  .  1560133635       . '+1560133635'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   723
        '%+-5d'  . -2035065302       . '-2035065302'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   724
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   725
        '% -5d'  .           0       . ' 0   '     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   726
        '% -5d'  .          -7       . '-7   '     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   727
        '% -5d'  .  1560133635       . ' 1560133635'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   728
        '% -5d'  . -2035065302       . '-2035065302'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   729
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   730
        '% 05d'  .           0       . ' 0000'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   731
        '% 05d'  .          -7       . '-0007'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   732
        '% 05d'  .  1560133635       . ' 1560133635'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   733
        '% 05d'  . -2035065302       . '-2035065302'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   734
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   735
        '%+05d'  .           0       . '+0000'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   736
        '%+05d'  .          -7       . '-0007'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   737
        '%+05d'  .  1560133635       . '+1560133635'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   738
        '%+05d'  . -2035065302       . '-2035065302'     .
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   739
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   740
    } inGroupsOf:3 do:[:fmt :val :expected|
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   741
        |printfGenerated stxGenerated|
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   742
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   743
        printfGenerated := val printfPrintString:fmt.
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   744
        stxGenerated := PrintfScanf printf:fmt argument:val.
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   745
        self assert:(stxGenerated = printfGenerated).
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   746
        self assert:(printfGenerated = expected).
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   747
    ].
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   748
!
07d66b1b14d1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2457
diff changeset
   749
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   750
testPrintf_QDouble
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   751
    "/ QDouble
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   752
    |pi|
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   753
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   754
    pi := QDouble pi.
1719
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
   755
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
   756
    self 
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
   757
        skipIf:(OperatingSystem isUNIXlike and:[ExternalAddress pointerSize = 4])
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
   758
        description:'Fails under Linux32'.
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
   759
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   760
    self assert:( (PrintfScanf printf:'%.4f' argument:pi)  = '3.1416' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   761
    self assert:( (PrintfScanf printf:'%.8f' argument:pi)  = '3.14159265' ).
2467
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   762
    self assert:( (PrintfScanf printf:'%f' argument:pi)    = '3.1415926536' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   763
2467
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   764
    self assert:( (pi printfPrintString:'%4Lf') = '3.1415926536' ).
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   765
    self assert:( (pi printfPrintString:'%5Lf') = '3.1415926536' ).
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   766
    self assert:( (pi printfPrintString:'%6Lf') = '3.1415926536' ).
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   767
    self assert:( (pi printfPrintString:'%7Lf') = '3.1415926536' ).
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   768
    self assert:( (pi printfPrintString:'%10Lf') = '3.1415926536' ).
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   769
    self assert:( (pi printfPrintString:'%11Lf') = '3.1415926536' ).
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   770
    self assert:( (pi printfPrintString:'%12Lf') = '3.1415926536' ).
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   771
    "/ left filled
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   772
    self assert:( (pi printfPrintString:'%13Lf') = ' 3.1415926536' ).
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   773
    self assert:( (pi printfPrintString:'%18Lf') = '      3.1415926536' ).
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   774
    self assert:( (pi printfPrintString:'%19Lf') = '       3.1415926536' ).
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   775
    self assert:( (pi printfPrintString:'%20Lf') = '        3.1415926536' ).
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   776
    self assert:( (pi printfPrintString:'%21Lf') = '         3.1415926536' ).
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   777
    self assert:( (pi printfPrintString:'%4.2Lf') = '3.14' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   778
    "/ right filled
2467
fba4f50d625d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
   779
    self assert:( (pi printfPrintString:'%-20Lf') = '3.1415926536        ' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   780
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   781
    "Created: / 10-10-2017 / 12:24:22 / cg"
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   782
    "Modified: / 10-10-2017 / 16:28:51 / cg"
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   783
!
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   784
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   785
testPrintf_ShortFloat
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   786
    |pi|
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   787
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   788
    pi := ShortFloat pi.
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   789
    self assert:( (PrintfScanf printf:'%.4f' argument:pi) = '3.1416' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   790
    self assert:( (PrintfScanf printf:'%f' argument:pi) = '3.14159' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   791
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   792
    "/ ShortFloat
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   793
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   794
    "/ too small
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   795
    self assert:( (pi printfPrintString:'%4f') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   796
    self assert:( (pi printfPrintString:'%5f') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   797
    self assert:( (pi printfPrintString:'%6f') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   798
    self assert:( (pi printfPrintString:'%7f') = '3.141593' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   799
    "/ fit
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   800
    self assert:( (pi printfPrintString:'%8f') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   801
    self assert:( (pi printfPrintString:'%4.2f') = '3.14' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   802
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   803
    "/ left filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   804
    self assert:( (pi printfPrintString:'%9f') = ' 3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   805
    self assert:( (pi printfPrintString:'%8.4f') = '  3.1416' ).
1776
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   806
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   807
    "/ right filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   808
    self assert:( (pi printfPrintString:'%-9f') = '3.141593 ' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   809
    self assert:( (pi printfPrintString:'%-8.4f') = '3.1416  ' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   810
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   811
    "Created: / 10-10-2017 / 12:35:12 / cg"
1776
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   812
    "Modified: / 10-10-2017 / 16:32:31 / cg"
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   813
! !
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   814
309
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   815
!NumberTest methodsFor:'tests-reading'!
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   816
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   817
testReadFrom
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   818
    self assert: 1.0e-14    = (Number readFrom: '1.0e-14').
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   819
2494
296ddcb358f1 #QUALITY by Stefan Reise
sr
parents: 2491
diff changeset
   820
    #(
2495
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   821
        '0.8'                 0.8                 '0.8' 
2494
296ddcb358f1 #QUALITY by Stefan Reise
sr
parents: 2491
diff changeset
   822
        '0'                   0                   '0' 
296ddcb358f1 #QUALITY by Stefan Reise
sr
parents: 2491
diff changeset
   823
        '-0'                  0                   '0' 
296ddcb358f1 #QUALITY by Stefan Reise
sr
parents: 2491
diff changeset
   824
        '00'                  0                   '0' 
296ddcb358f1 #QUALITY by Stefan Reise
sr
parents: 2491
diff changeset
   825
        '000'                 0                   '0' 
296ddcb358f1 #QUALITY by Stefan Reise
sr
parents: 2491
diff changeset
   826
        '0x0'                 0                   '0' 
296ddcb358f1 #QUALITY by Stefan Reise
sr
parents: 2491
diff changeset
   827
        '0b0'                 0                   '0' 
296ddcb358f1 #QUALITY by Stefan Reise
sr
parents: 2491
diff changeset
   828
        '16r0'                0                   '0' 
296ddcb358f1 #QUALITY by Stefan Reise
sr
parents: 2491
diff changeset
   829
        '4865804016353280000' 4865804016353280000 '4865804016353280000'
296ddcb358f1 #QUALITY by Stefan Reise
sr
parents: 2491
diff changeset
   830
    ) inGroupsOf:3 do:[:str :expected :expectedPrintString|
2495
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   831
        |gotVal|
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   832
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   833
        self assert:(gotVal := Number readFrom:str) = expected.
2494
296ddcb358f1 #QUALITY by Stefan Reise
sr
parents: 2491
diff changeset
   834
        self assert:expected printString = expectedPrintString.
296ddcb358f1 #QUALITY by Stefan Reise
sr
parents: 2491
diff changeset
   835
    ].
296ddcb358f1 #QUALITY by Stefan Reise
sr
parents: 2491
diff changeset
   836
315
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   837
    self assert: ('1' asNumber = 1).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   838
    self assert: ('10' asNumber = 10).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   839
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   840
    self assert: ('-1' asNumber = -1).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   841
    self assert: ('-10' asNumber = -10).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   842
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   843
    self assert: ('1e' asNumber = 1).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   844
    self assert: ('1e1' asNumber = 10).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   845
    self assert: ('1e10' asNumber = 10000000000).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   846
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   847
    self assert: ('-1e' asNumber = -1).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   848
    self assert: ('-1e1' asNumber = -10).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   849
    self assert: ('-1e10' asNumber = -10000000000).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   850
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   851
    self assert: ('1.0e' asNumber = 1.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   852
    self assert: ('1.0e1' asNumber = 10.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   853
    self assert: ('1.0e10' asNumber = 10000000000.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   854
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   855
    self assert: ('-1.0e' asNumber = -1.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   856
    self assert: ('-1.0e1' asNumber = -10.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   857
    self assert: ('-1.0e10' asNumber = -10000000000.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   858
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   859
    self assert: ('22.2' asNumber = 22.2).
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   860
    self assert: ('-22.2' asNumber = -22.2).
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   861
2491
3cea4cd3b8fb #QUALITY by Stefan Reise
sr
parents: 2470
diff changeset
   862
    self assert: ((Number readFrom:'0xaffe') = 45054).
3cea4cd3b8fb #QUALITY by Stefan Reise
sr
parents: 2470
diff changeset
   863
    self assert: ((Number readFrom:'0b1010') = 10).
3cea4cd3b8fb #QUALITY by Stefan Reise
sr
parents: 2470
diff changeset
   864
    self assert: ((Number readFrom:'0o177') = 127).
3cea4cd3b8fb #QUALITY by Stefan Reise
sr
parents: 2470
diff changeset
   865
    self assert: ((Number readFrom:'0Xaffe') = 45054).
3cea4cd3b8fb #QUALITY by Stefan Reise
sr
parents: 2470
diff changeset
   866
    self assert: ((Number readFrom:'0B1010') = 10).
3cea4cd3b8fb #QUALITY by Stefan Reise
sr
parents: 2470
diff changeset
   867
    self assert: ((Number readFrom:'0O177') = 127).
3cea4cd3b8fb #QUALITY by Stefan Reise
sr
parents: 2470
diff changeset
   868
3cea4cd3b8fb #QUALITY by Stefan Reise
sr
parents: 2470
diff changeset
   869
    self assert: ((Number readFrom:'-0xaffe') = -45054).
3cea4cd3b8fb #QUALITY by Stefan Reise
sr
parents: 2470
diff changeset
   870
    self assert: ((Number readFrom:'-0b1010') = -10).
3cea4cd3b8fb #QUALITY by Stefan Reise
sr
parents: 2470
diff changeset
   871
    self assert: ((Number readFrom:'-0o177') = -127).
3cea4cd3b8fb #QUALITY by Stefan Reise
sr
parents: 2470
diff changeset
   872
    self assert: ((Number readFrom:'-0Xaffe') = -45054).
3cea4cd3b8fb #QUALITY by Stefan Reise
sr
parents: 2470
diff changeset
   873
    self assert: ((Number readFrom:'-0B1010') = -10).
3cea4cd3b8fb #QUALITY by Stefan Reise
sr
parents: 2470
diff changeset
   874
    self assert: ((Number readFrom:'-0O177') = -127).
3cea4cd3b8fb #QUALITY by Stefan Reise
sr
parents: 2470
diff changeset
   875
3cea4cd3b8fb #QUALITY by Stefan Reise
sr
parents: 2470
diff changeset
   876
    self assert: ((Integer readFrom:'0x-affe') = -45054).
2495
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   877
    self should: [ Number readFrom:'0x-affe' ] raise:Error.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   878
    self should: [ Number readFrom:'0b-1010' ] raise:Error.  
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   879
    self should: [ Number readFrom:'0o-177' ] raise:Error.  
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   880
    self should: [ Number readFrom:'0X-affe' ] raise:Error.  
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   881
    self should: [ Number readFrom:'0B-1010' ] raise:Error.  
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   882
    self should: [ Number readFrom:'0O-177' ] raise:Error.  
2491
3cea4cd3b8fb #QUALITY by Stefan Reise
sr
parents: 2470
diff changeset
   883
309
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   884
    Smalltalk isSmalltalkX ifTrue:[
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   885
        "/ st/x requires this:
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   886
2456
081734105794 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2450
diff changeset
   887
        self assert: ((Number readSmalltalkSyntaxFrom:'10r5.5') = 5.5).
081734105794 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2450
diff changeset
   888
        self assert: ((Number readSmalltalkSyntaxFrom:'16r5.5') = 5.3125).
081734105794 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2450
diff changeset
   889
        self assert: ((Number readSmalltalkSyntaxFrom:'3r1.1e2') = 12).
081734105794 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2450
diff changeset
   890
        self assert: ((Number readSmalltalkSyntaxFrom:'3r1.1e10') = 78732.0).
081734105794 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2450
diff changeset
   891
        self assert: ((Number readSmalltalkSyntaxFrom:'16r10.1e10') = 16.117431640625).
081734105794 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2450
diff changeset
   892
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   893
        self assert: ((Number readSmalltalkSyntaxFrom:'10r22.2') = 22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   894
        self assert: ((Number readSmalltalkSyntaxFrom:'10r22.2s5') = 22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   895
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   896
        self assert: ((Number readSmalltalkSyntaxFrom:'10r-22.2') = -22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   897
        self assert: ((Number readSmalltalkSyntaxFrom:'10r-22.2s5') = -22.2).
2491
3cea4cd3b8fb #QUALITY by Stefan Reise
sr
parents: 2470
diff changeset
   898
        self assert: ((Number readSmalltalkSyntaxFrom:'0xaffe') = 45054).
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   899
1863
0af9cae4cecb #BUGFIX by sr
sr
parents: 1862
diff changeset
   900
        "/ test fails when stc code, byte code works
1877
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   901
        (Helper 
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   902
            isStcCompiledMethod:#'testReadFrom'
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   903
            in:self) ifTrue:[ 
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   904
                self logSkipped:'2r1e26 is not valid in stc code -> debugger doesNotUnderstand: #e26'.
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   905
            ] ifFalse:[    
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   906
                self assert: 2r1e26     = (Number readSmalltalkSyntaxFrom: '2r1e26').
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   907
            ].
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   908
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   909
        self assert: ('-1q' asNumber = -1).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   910
        self assert: ('-1q' asNumber class == LongFloat).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   911
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   912
        self assert: ('-1q1' asNumber = -10).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   913
        self assert: ('-1q10' asNumber = -10000000000).
309
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   914
    ] ifFalse:[
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   915
        "/ squeak allows this:
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   916
        self assert: 2r1e26     = (Number readFrom: '2r1e26').
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   917
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   918
        self assert: ('10r22.2' asNumber = 22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   919
        self assert: ('10r22.2s5' asNumber = 22.2).
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   920
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   921
        self assert: ('10r-22.2' asNumber = -22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   922
        self assert: ('10r-22.2s5' asNumber = -22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   923
    ].
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   924
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   925
    "Modified: / 20-06-2017 / 14:05:37 / cg"
2494
296ddcb358f1 #QUALITY by Stefan Reise
sr
parents: 2491
diff changeset
   926
    "Modified: / 17-12-2019 / 14:39:17 / Stefan Reise"
2495
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   927
!
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   928
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   929
testReadFrom2
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   930
    |n|
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   931
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   932
     n := Number readFrom:(ReadStream on:'54.32e-01') decimalPointCharacters:'.' onError:[self halt].
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   933
     self assert:(n = 5.432).
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   934
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   935
     n := Number readFrom:(ReadStream on:'12345') decimalPointCharacters:'.' onError:[self halt].
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   936
     self assert:(n = 12345).
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   937
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   938
     n := Number readFrom:(ReadStream on:'12345.0') decimalPointCharacters:'.' onError:[self halt].
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   939
     self assert:(n = 12345.0).
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   940
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   941
     n := Number readFrom:(ReadStream on:'12345.0f') decimalPointCharacters:'.' onError:[self halt].
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   942
     self assert:(n = 12345.0).
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   943
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   944
     n := Number readFrom:(ReadStream on:'12345.0e') decimalPointCharacters:'.' onError:[self halt].
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   945
     self assert:(n = 12345.0).
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   946
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   947
     n := Number readFrom:(ReadStream on:'12345.0q') decimalPointCharacters:'.' onError:[self halt].
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   948
     self assert:(n = 12345.0).
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   949
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   950
     n := Number readFrom:(ReadStream on:'12345.0d') decimalPointCharacters:'.' onError:[self halt].
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   951
     self assert:(n = 12345.0).
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   952
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   953
     n := Number readFrom:(ReadStream on:'12345.0s') decimalPointCharacters:'.' onError:[self halt].
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   954
     self assert:(n = 12345.0).
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   955
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   956
     n := Number readFrom:(ReadStream on:'12345.01s') decimalPointCharacters:'.' onError:[self halt].
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   957
     self assert:(n = 12345.01).
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   958
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   959
     n := Float readFrom:(ReadStream on:'12345') decimalPointCharacters:'.' onError:[self halt].
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   960
     self assert:(n = 12345.0).
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   961
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   962
     n := Number readFrom:(ReadStream on:'12345678901234567890').
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   963
     self assert:(n = 12345678901234567890).
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   964
     n := Number readFrom:(ReadStream on:'12345678901234567890.0').
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   965
     self assert:(n = 12345678901234567890.0).
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   966
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   967
     n := Number readFrom:(ReadStream on:'12345678901234567890.012345678901234567890').
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   968
     self assert:(n closeTo: 12345678901234567890.012345678901234567890).
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   969
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   970
     n := Number readFrom:(ReadStream on:'16rAAAAFFFFAAAAFFFF').
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   971
     self assert:(n = 16rAAAAFFFFAAAAFFFF).
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   972
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   973
     n := Number readFrom:'16rAAAAFFFFAAAAFFFF'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   974
     self assert:(n = 16rAAAAFFFFAAAAFFFF).
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   975
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   976
     n := Number readFrom:'16r100A'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   977
     self assert:(n = 16r100A).
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   978
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   979
     n := Number readFrom:'16r100a'.  
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   980
     self assert:(n = 16r100A).
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   981
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   982
     n := Number readFrom:'16r-100A'.      
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   983
     self assert:(n = -16r100A).
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   984
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   985
     n := Number readFrom:'-16r100A'.      
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   986
     self assert:(n = -16r100A).
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   987
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   988
     n := Number readFrom:'0x100A'.      
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   989
     self assert:(n = 16r100A).
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   990
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   991
     n := Number readFrom:'-0x100A'.      
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   992
     self assert:(n = -16r100A).
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   993
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   994
     self should:[ n := Number readFrom:'0x-100A' ] raise:Error.      
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   995
     n := Number readFrom:'0.000001'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   996
     n := '+00000123.45' asNumber.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   997
     n := Number readFrom:'(1/3)'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   998
     n := Number readFrom:'(-1/3)'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   999
     n := Number readFrom:'(1/-3)'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1000
     n := Number readFrom:'-(1/3)'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1001
     n := Number readFrom:'-(-1/3)'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1002
     self should:[ n := Number readFrom:'(-1/3' ] raise:Error. 
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1003
     n := Number readFrom:'99s'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1004
     n := Number readFrom:'99.00s'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1005
     n := Number readFrom:'99.0000000s'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1006
     n := Number readFrom:'.0000000s'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1007
     n := Number readFrom:'.0000000q'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1008
     n := Number readFrom:'.0000000f'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1009
     n := Number readFrom:'.0000000e'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1010
     n := Number readFrom:'.0000000s1'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1011
     n := Number readFrom:'.0000000q1'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1012
     n := Number readFrom:'.0000000f1'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1013
     n := Number readFrom:'.0000000e1'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1014
     n := LongFloat readFrom:'.00000001'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1015
     n := Number readFrom:'.00000000000001'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1016
     n := Number readFrom:'.001'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1017
     n := ShortFloat readFrom:'.001'.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1018
     n := Number readFrom:'123garbage'. "/      -> returns 123
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1019
     self should:[ n := Number fromString:'123garbage'] raise:Error.
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1020
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1021
     n := Number readFrom:'99,00' decimalPointCharacters:#( $. $, ). 
55bc2f4b7ac4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1022
     n := Number readFrom:'99,00' decimalPointCharacters:#( $. ).    
309
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
  1023
! !
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
  1024
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1025
!NumberTest class methodsFor:'documentation'!
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1026
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1027
version
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1028
    ^ '$Header$'
1776
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
  1029
!
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
  1030
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
  1031
version_CVS
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
  1032
    ^ '$Header$'
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1033
! !
1072
ee32c0daddfb category
Claus Gittinger <cg@exept.de>
parents: 670
diff changeset
  1034