RegressionTests__NumberTest.st
author Claus Gittinger <cg@exept.de>
Sun, 01 Dec 2019 16:09:32 +0100
changeset 2450 a284c0898eb8
parent 2447 81b27fbbc2e9
child 2456 081734105794
permissions -rw-r--r--
#QUALITY by exept class: RegressionTests::NumberTest changed: #testPrintf_LargeFloat
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
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   311
    "/ Integers
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   312
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   313
    "/ 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
   314
    "/ 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
   315
    self assert:( (20 printfPrintString:'%d') = '20' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   316
    self assert:( (20 printfPrintString:'% d') = ' 20' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   317
    self assert:( (-20 printfPrintString:'% d') = '-20' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   318
    self assert:( (20 printfPrintString:'%#d') = '20' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   319
    self assert:( (20 printfPrintString:'%#5d') = '   20' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   320
    self assert:( (20 printfPrintString:'% -#5d') = ' 20  ' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   321
    self assert:( (20 printfPrintString:'%- #5d') = ' 20  ' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   322
    self assert:( (20 printfPrintString:'%-# 5d') = ' 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:'%-#05d') = '20   ' ).   "/ NOTICE
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   325
    self assert:( (20 printfPrintString:'%-0#5d') = '20   ' ).   "/ NOTICE
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   326
    self assert:( (20 printfPrintString:'%0-#5d') = '20   ' ).   "/ NOTICE
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   327
    self assert:( (20 printfPrintString:'%0#-5d') = '20   ' ).   "/ NOTICE
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   328
    self assert:( (20 printfPrintString:'%#05d') = '00020' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   329
    self assert:( (20 printfPrintString:'%# 5d') = '   20' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   330
    self assert:( (20 printfPrintString:'%+ 5d') = '  +20' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   331
    self assert:( (20 printfPrintString:'%- 5d') = ' 20  ' ).     
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   332
    self assert:( (-20 printfPrintString:'%- 5d') = '-20  ' ).     
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   333
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   334
    #(
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   335
        '%d'         20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   336
        '%d'        -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   337
        '%D'         20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   338
        '%D'        -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   339
        '%ld'        20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   340
        '%ld'       -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   341
        '%lld'       20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   342
        '%lld'      -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   343
        '%hd'        20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   344
        '%hd'       -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   345
        '%hhd'       20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   346
        '%hhd'      -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   347
        '%lhd'       20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   348
        '%hld'      -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   349
        '% d'        20      ' 20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   350
        '% d'       -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   351
        '%#d'        20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   352
        '%#d'       -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   353
        '%5d'        20      '   20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   354
        '%5d'       -20      '  -20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   355
        '%-5d'       20      '20   '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   356
        '%-5d'      -20      '-20  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   357
        '%05d'       20      '00020'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   358
        '%05d'      -20      '-0020'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   359
        '%-05d'      20      '20   '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   360
        '%-05d'     -20      '-20  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   361
        '% 5d'       20      '   20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   362
        '% 5d'      -20      '  -20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   363
        '%- 5d'      20      ' 20  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   364
        '%- 5d'     -20      '-20  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   365
        '%.0d'       20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   366
        '%.0d'      -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   367
        '%.0d'        0      ''  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   368
        '%x'         20      '14'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   369
        '%x'        255      'ff'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   370
        '%X'        255      'FF'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   371
        '%#x'       255      '0xff'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   372
        '%#X'       255      '0XFF'   "/ printf also uppercases the 'x'
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   373
        '%x'          0      '0'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   374
        '%#x'         0      '0'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   375
        '%#x'        20      '0x14'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   376
        '%5x'        20      '   14'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   377
        '%-5x'       20      '14   '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   378
        '%#5x'       20      ' 0x14'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   379
        '%-#5x'      20      '0x14 '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   380
        '%#-5x'      20      '0x14 '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   381
        '%#-5X'      20      '0X14 '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   382
     "/   '%x'   -20      '-14'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   383
        '%o'         20      '24'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   384
        '%o'          0      '0'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   385
        '%#o'        20      '024'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   386
        '%#o'         0      '0'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   387
        '%5o'        20      '   24'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   388
        '%-5o'       20      '24   '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   389
        '%#5o'       20      '  024'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   390
        '%-#5o'      20      '024  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   391
        '%#-5o'      20      '024  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   392
        '%-#05o'     20      '024  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   393
        '%#05o'      20      '00024'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   394
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   395
        '%2d'      1234      '1234'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   396
     "/   '%2.2d'    1234      '1234'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   397
        '%2x'        10      ' a'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   398
        '%2X'        10      ' A'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   399
        '%02x'       10      '0a'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   400
        '%02X'       10      '0A'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   401
     "/   '%o'   -20      '-24'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   402
        '%#5d'       20      '   20'
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   403
        '%-#5d'     -20      '-20  '
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   404
        '%-#5d'     -20      '-20  '
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   405
        '%-#05d'    -20      '-20  '
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   406
        '%#05d'     -20      '-0020'
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   407
        '%-#5d'      20      '20   '
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   408
        '%-#5d'      20      '20   '
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   409
        '%-#05d'     20      '20   '
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   410
        '%-#05x'     20      '0x14 '
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   411
        '%#05x'      20      '0x014'
2394
168fb84c7806 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2392
diff changeset
   412
168fb84c7806 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2392
diff changeset
   413
        '%.3x'   0xAFFE      'affe'      "/ max length ignored for numbers
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   414
    ) inGroupsOf:3 do:[:fmt :val :expected|
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   415
        |printfGenerated stxGenerated|
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   416
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   417
        printfGenerated := val printfPrintString:fmt.
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   418
        stxGenerated := PrintfScanf printf:fmt argument:val.
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   419
        self assert:(stxGenerated = printfGenerated).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   420
        self assert:(printfGenerated = expected).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   421
    ].
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   422
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   423
    "/ hex
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   424
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   425
    self assert:( (PrintfScanf printf:'%x' argument:-20) = '-14' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   426
    self assert:( (PrintfScanf printf:'%#x' argument:-20) = '-0x14' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   427
    self assert:( (PrintfScanf printf:'%#7x' argument:-20) = '  -0x14' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   428
    self assert:( (PrintfScanf printf:'%-#7x' argument:-20) = '-0x14  ' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   429
    self assert:( (PrintfScanf printf:'%-#07x' argument:-20) = '-0x14  ' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   430
    self assert:( (PrintfScanf printf:'%#07x' argument:-20) = '-0x0014' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   431
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   432
    "/ octal
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   433
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   434
    self assert:( (PrintfScanf printf:'%o' argument:-20) = '-24' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   435
    self assert:( (PrintfScanf printf:'%#o' argument:-20) = '-024' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   436
    self assert:( (PrintfScanf printf:'%#5o' argument:-20) = ' -024' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   437
    self assert:( (PrintfScanf printf:'%-#5o' argument:-20) = '-024 ' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   438
    self assert:( (PrintfScanf printf:'%-#05o' argument:-20) = '-024 ' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   439
    self assert:( (PrintfScanf printf:'%#05o' argument:-20) = '-0024' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   440
!
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   441
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   442
testPrintf_LargeFloat
2267
65cbf58d8983 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   443
    "/ LargeFloat- unfinished
1862
54413f61d192 #BUGFIX by sr
sr
parents: 1776
diff changeset
   444
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   445
    |lf pi|
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   446
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   447
    pi := LargeFloat pi.
2424
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   448
1862
54413f61d192 #BUGFIX by sr
sr
parents: 1776
diff changeset
   449
    self 
2268
360e548237a1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 2267
diff changeset
   450
        skipIf:(Smalltalk isSmalltalkDevelopmentSystem not)
360e548237a1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 2267
diff changeset
   451
        description:'work in progress'.
360e548237a1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 2267
diff changeset
   452
360e548237a1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 2267
diff changeset
   453
    self 
1862
54413f61d192 #BUGFIX by sr
sr
parents: 1776
diff changeset
   454
        skipIf:(Smalltalk at:#LargeFloat) isNil  
54413f61d192 #BUGFIX by sr
sr
parents: 1776
diff changeset
   455
        description:'LargeFloat is not loaded'.
54413f61d192 #BUGFIX by sr
sr
parents: 1776
diff changeset
   456
2450
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   457
    self assert:(pi printString) = '3.141592653590' "'3.141592653589793238462643383280'".
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   458
    self assert:( (PrintfScanf printf:'%.4f' argument:pi)  = '3.1416' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   459
    self assert:( (PrintfScanf printf:'%.8f' argument:pi)  = '3.14159265' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   460
2450
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   461
    self assert:( (PrintfScanf printf:'%f' argument:pi-(LargeFloat readFrom:'3.14159265358979323846264')) = '0.0000000000000000000000033832795028841973206112925254274159' "'0.00000000000000000000000338328'" ).
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   462
    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
   463
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   464
    "/ too small                                              
2450
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   465
    self assert:( (pi printfPrintString:'%4Lf') = '3.14159265359' "'3.141592653589793238462643383280'" ).
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   466
    self assert:( (pi printfPrintString:'%5Lf') = '3.14159265359' "'3.141592653589793238462643383280'" ).
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   467
    self assert:( (pi printfPrintString:'%6Lf') = '3.14159265359' "'3.141592653589793238462643383280'" ).
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   468
    self assert:( (pi printfPrintString:'%7Lf') = '3.14159265359' "'3.141592653589793238462643383280'" ).
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   469
    "/ fit
2450
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   470
    self assert:( (pi printfPrintString:'%8Lf') = '3.14159265359' "'3.141592653589793238462643383280'" ).
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   471
    self assert:( (pi printfPrintString:'%4.2Lf') = '3.14' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   472
    self assert:( (pi printfPrintString:'%4.3Lf') = '3.142' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   473
    self assert:( (pi printfPrintString:'%4.4Lf') = '3.1416' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   474
    self assert:( (pi printfPrintString:'%4.5Lf') = '3.14159' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   475
    self assert:( (pi printfPrintString:'%4.6Lf') = '3.141593' ).
2338
164c3d4cba01 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   476
    
2424
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   477
    "/ left filled                                               
2450
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   478
    self assert:( (pi printfPrintString:'%9Lf') = '3.14159265359' "' 3.141593'" ).
2424
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   479
    "/ right filled
2450
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   480
    self assert:( (pi printfPrintString:'%-9Lf') = '3.14159265359' "'3.141593 '" ).
2424
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   481
2338
164c3d4cba01 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   482
    "/ exact (to 130 digits)  value is:
2267
65cbf58d8983 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   483
    "/ 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
   484
    "/ ((LargeFloat fromString:'3.141592653589793238462643383279') printfPrintString:'%4.20Lf')
2424
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   485
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   486
    lf := 1 asLargeFloat.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   487
    self assert:( (lf printfPrintString:'%4.20Lf') = ' 1.0' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   488
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   489
    self assert:( (lf printfPrintString:'%4.20Lf') = ' 0.1' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   490
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   491
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.01' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   492
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   493
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   494
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   495
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.0001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   496
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   497
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.00001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   498
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   499
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   500
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   501
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.0000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   502
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   503
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.00000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   504
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   505
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.000000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   506
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   507
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.0000000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   508
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   509
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.00000000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   510
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   511
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.000000000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   512
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   513
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.0000000000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   514
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   515
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.00000000000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   516
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   517
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.000000000000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   518
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   519
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.0000000000000001' ).
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.00000000000000001' ).
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.000000000000000001' ).
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.0000000000000000001' ).
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.21Lf') = '0.00000000000000000001' ).
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.22Lf') = '0.000000000000000000001' ).
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   530
    lf := pi.
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   531
    self assert:( (lf printString) = '3.141592653589793238462643383280' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   532
    self assert:( (lf printfPrintString:'%4.20Lf') = '3.14159265358979323846' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   533
    lf := lf - 3.
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   534
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.14159265358979323846' ).
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   535
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   536
    "Created: / 10-10-2017 / 16:25:25 / cg"
2268
360e548237a1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 2267
diff changeset
   537
    "Modified: / 05-06-2019 / 20:15:13 / Claus Gittinger"
2338
164c3d4cba01 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   538
    "Modified (comment): / 22-07-2019 / 19:40:10 / Claus Gittinger"
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   539
!
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   540
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   541
testPrintf_LongFloat
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   542
    "/ LongFloat
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   543
    
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   544
    |pi|
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   545
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   546
    pi := LongFloat pi.
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   547
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   548
    self assert:( (PrintfScanf printf:'%.4f' argument:pi)  = '3.1416' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   549
    self assert:( (PrintfScanf printf:'%.8f' argument:pi)  = '3.14159265' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   550
    self assert:( (PrintfScanf printf:'%f' argument:pi)  = '3.14159265' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   551
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   552
    "/ LongFloat
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   553
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   554
    "/ too small
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   555
    self assert:( (pi printfPrintString:'%4Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   556
    self assert:( (pi printfPrintString:'%5Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   557
    self assert:( (pi printfPrintString:'%6Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   558
    self assert:( (pi printfPrintString:'%7Lf') = '3.141593' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   559
    "/ fit
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   560
    self assert:( (pi printfPrintString:'%8Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   561
    self assert:( (pi printfPrintString:'%4.2Lf') = '3.14' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   562
    "/ left filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   563
    self assert:( (pi printfPrintString:'%9Lf') = ' 3.141593' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   564
    "/ right filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   565
    self assert:( (pi printfPrintString:'%-9Lf') = '3.141593 ' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   566
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   567
    "Created: / 10-10-2017 / 12:35:40 / cg"
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   568
    "Modified: / 10-10-2017 / 16:29:56 / cg"
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   569
!
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   570
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   571
testPrintf_Misc
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   572
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   573
    "/ 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
   574
    "/ 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
   575
    self assert:( (20 printfPrintString:'%%%d') = '%20' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   576
    self assert:( (20 printfPrintString:'%d%%') = '20%' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   577
    self assert:( (20 printfPrintString:'%d%') = '20' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   578
2396
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   579
    {
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   580
        '%f'   .   Float NaN                .  'nan'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   581
        '%F'   .   Float NaN                .  'NAN'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   582
        '%f'   .   Float infinity           .  'inf'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   583
        '%F'   .   Float infinity           .  'INF'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   584
        '%f'   .   Float negativeInfinity   .  '-inf'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   585
        '%F'   .   Float negativeInfinity   .  '-INF'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   586
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   587
        '%+f'  .   Float NaN                .  'nan'  .    
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   588
        '%+F'  .   Float NaN                .  'NAN'  .    
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   589
        '%+f'  .   Float infinity           .  '+inf'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   590
        '%+F'  .   Float infinity           .  '+INF'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   591
        '%+f'  .   Float negativeInfinity   .  '-inf'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   592
        '%+F'  .   Float negativeInfinity   .  '-INF'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   593
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   594
        '% 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
   595
        '% 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
   596
        '% f'  .   Float infinity           .  ' inf'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   597
        '% F'  .   Float infinity           .  ' INF'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   598
        '% f'  .   Float negativeInfinity   .  '-inf'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   599
        '% F'  .   Float negativeInfinity   .  '-INF'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   600
    } inGroupsOf:3 do:[:fmt :val :expected|
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   601
        |printfGenerated stxGenerated|
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   602
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   603
        printfGenerated := val printfPrintString:fmt.
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   604
        stxGenerated := PrintfScanf printf:fmt argument:val.
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   605
        self assert:(stxGenerated = printfGenerated).
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   606
        self assert:(printfGenerated = expected).
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   607
    ].
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   608
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   609
    #(
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   610
        '%r'       1234      'r'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   611
        '%3r'      1234      '  r'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   612
        '%-3r'      1234     'r  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   613
        '%#r'      1234      'r'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   614
      "/  '%v'       1234      'v'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   615
        '%Id'      1234      'Id'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   616
        '%%%d'         20      '%20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   617
        '%d%%'         20      '20%'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   618
        '%d%'          20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   619
        '%%a%%'        20      '%a%'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   620
    ) inGroupsOf:3 do:[:fmt :val :expected|
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   621
        |printfGenerated stxGenerated|
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   622
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   623
        printfGenerated := val printfPrintString:fmt.
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   624
        stxGenerated := PrintfScanf printf:fmt argument:val.
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   625
        self assert:(stxGenerated = printfGenerated).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   626
        self assert:(printfGenerated = expected).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   627
    ].
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   628
!
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   629
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   630
testPrintf_QDouble
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   631
    "/ QDouble
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   632
    |pi|
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   633
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   634
    pi := QDouble pi.
1719
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
   635
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
   636
    self 
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
   637
        skipIf:(OperatingSystem isUNIXlike and:[ExternalAddress pointerSize = 4])
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
   638
        description:'Fails under Linux32'.
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
   639
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   640
    self assert:( (PrintfScanf printf:'%.4f' argument:pi)  = '3.1416' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   641
    self assert:( (PrintfScanf printf:'%.8f' argument:pi)  = '3.14159265' ).
2447
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   642
    self assert:( (PrintfScanf printf:'%f' argument:pi)    = '3.14159265358979323846264338328' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   643
2447
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   644
    self assert:( (pi printfPrintString:'%4Lf') = '3.14159265358979323846264338328' ).
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   645
    self assert:( (pi printfPrintString:'%5Lf') = '3.14159265358979323846264338328' ).
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   646
    self assert:( (pi printfPrintString:'%6Lf') = '3.14159265358979323846264338328' ).
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   647
    self assert:( (pi printfPrintString:'%7Lf') = '3.14159265358979323846264338328' ).
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   648
    self assert:( (pi printfPrintString:'%18Lf') = '3.14159265358979323846264338328' ).
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   649
    self assert:( (pi printfPrintString:'%19Lf') = '3.14159265358979323846264338328' ).
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   650
    self assert:( (pi printfPrintString:'%20Lf') = '3.14159265358979323846264338328' ).
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   651
    self assert:( (pi printfPrintString:'%21Lf') = '3.14159265358979323846264338328' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   652
    "/ fit
2447
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   653
    self assert:( (pi printfPrintString:'%22Lf') = '3.14159265358979323846264338328' ).
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   654
    self assert:( (pi printfPrintString:'%4.2Lf') = '3.14' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   655
    "/ left filled
2447
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   656
    self assert:( (pi printfPrintString:'%23Lf') = '3.14159265358979323846264338328' ).
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   657
    self assert:( (pi printfPrintString:'%30Lf') = '3.14159265358979323846264338328' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   658
    "/ right filled
2447
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   659
    self assert:( (pi printfPrintString:'%-30Lf') = '3.14159265358979323846264338328' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   660
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   661
    "Created: / 10-10-2017 / 12:24:22 / cg"
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   662
    "Modified: / 10-10-2017 / 16:28:51 / cg"
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   663
!
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   664
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   665
testPrintf_ShortFloat
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   666
    |pi|
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   667
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   668
    pi := ShortFloat pi.
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   669
    self assert:( (PrintfScanf printf:'%.4f' argument:pi) = '3.1416' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   670
    self assert:( (PrintfScanf printf:'%f' argument:pi) = '3.14159' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   671
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   672
    "/ ShortFloat
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   673
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   674
    "/ too small
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   675
    self assert:( (pi printfPrintString:'%4f') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   676
    self assert:( (pi printfPrintString:'%5f') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   677
    self assert:( (pi printfPrintString:'%6f') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   678
    self assert:( (pi printfPrintString:'%7f') = '3.141593' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   679
    "/ fit
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   680
    self assert:( (pi printfPrintString:'%8f') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   681
    self assert:( (pi printfPrintString:'%4.2f') = '3.14' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   682
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   683
    "/ left filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   684
    self assert:( (pi printfPrintString:'%9f') = ' 3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   685
    self assert:( (pi printfPrintString:'%8.4f') = '  3.1416' ).
1776
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   686
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   687
    "/ right filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   688
    self assert:( (pi printfPrintString:'%-9f') = '3.141593 ' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   689
    self assert:( (pi printfPrintString:'%-8.4f') = '3.1416  ' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   690
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   691
    "Created: / 10-10-2017 / 12:35:12 / cg"
1776
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   692
    "Modified: / 10-10-2017 / 16:32:31 / cg"
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   693
! !
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   694
309
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   695
!NumberTest methodsFor:'tests-reading'!
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   696
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   697
testReadFrom
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   698
    self assert: 1.0e-14    = (Number readFrom: '1.0e-14').
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   699
315
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   700
    self assert: ('1' asNumber = 1).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   701
    self assert: ('10' asNumber = 10).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   702
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   703
    self assert: ('-1' asNumber = -1).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   704
    self assert: ('-10' asNumber = -10).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   705
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   706
    self assert: ('1e' asNumber = 1).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   707
    self assert: ('1e1' asNumber = 10).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   708
    self assert: ('1e10' asNumber = 10000000000).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   709
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   710
    self assert: ('-1e' asNumber = -1).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   711
    self assert: ('-1e1' asNumber = -10).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   712
    self assert: ('-1e10' asNumber = -10000000000).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   713
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   714
    self assert: ('1.0e' asNumber = 1.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   715
    self assert: ('1.0e1' asNumber = 10.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   716
    self assert: ('1.0e10' asNumber = 10000000000.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   717
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   718
    self assert: ('-1.0e' asNumber = -1.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   719
    self assert: ('-1.0e1' asNumber = -10.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   720
    self assert: ('-1.0e10' asNumber = -10000000000.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   721
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   722
    self assert: ('22.2' asNumber = 22.2).
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   723
    self assert: ('-22.2' asNumber = -22.2).
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   724
309
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   725
    Smalltalk isSmalltalkX ifTrue:[
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   726
        "/ st/x requires this:
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   727
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   728
        self assert: ((Number readSmalltalkSyntaxFrom:'10r22.2') = 22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   729
        self assert: ((Number readSmalltalkSyntaxFrom:'10r22.2s5') = 22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   730
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   731
        self assert: ((Number readSmalltalkSyntaxFrom:'10r-22.2') = -22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   732
        self assert: ((Number readSmalltalkSyntaxFrom:'10r-22.2s5') = -22.2).
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   733
1863
0af9cae4cecb #BUGFIX by sr
sr
parents: 1862
diff changeset
   734
        "/ test fails when stc code, byte code works
1877
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   735
        (Helper 
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   736
            isStcCompiledMethod:#'testReadFrom'
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   737
            in:self) ifTrue:[ 
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   738
                self logSkipped:'2r1e26 is not valid in stc code -> debugger doesNotUnderstand: #e26'.
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   739
            ] ifFalse:[    
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   740
                self assert: 2r1e26     = (Number readSmalltalkSyntaxFrom: '2r1e26').
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   741
            ].
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   742
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   743
        self assert: ('-1q' asNumber = -1).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   744
        self assert: ('-1q' asNumber class == LongFloat).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   745
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   746
        self assert: ('-1q1' asNumber = -10).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   747
        self assert: ('-1q10' asNumber = -10000000000).
309
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   748
    ] ifFalse:[
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   749
        "/ squeak allows this:
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   750
        self assert: 2r1e26     = (Number readFrom: '2r1e26').
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   751
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   752
        self assert: ('10r22.2' asNumber = 22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   753
        self assert: ('10r22.2s5' asNumber = 22.2).
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   754
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   755
        self assert: ('10r-22.2' asNumber = -22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   756
        self assert: ('10r-22.2s5' asNumber = -22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   757
    ].
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   758
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   759
    "Modified: / 20-06-2017 / 14:05:37 / cg"
309
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   760
! !
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   761
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   762
!NumberTest class methodsFor:'documentation'!
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   763
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   764
version
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   765
    ^ '$Header$'
1776
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   766
!
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   767
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   768
version_CVS
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   769
    ^ '$Header$'
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   770
! !
1072
ee32c0daddfb category
Claus Gittinger <cg@exept.de>
parents: 670
diff changeset
   771