RegressionTests__NumberTest.st
author Claus Gittinger <cg@exept.de>
Tue, 03 Dec 2019 11:53:56 +0100
changeset 2456 081734105794
parent 2450 a284c0898eb8
child 2457 37ef73c45abb
permissions -rw-r--r--
#QUALITY by cg class: RegressionTests::NumberTest changed: #testReadFrom more radix floats
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2456
081734105794 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2450
diff changeset
     1
"{ Encoding: utf8 }"
081734105794 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2450
diff changeset
     2
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1072
diff changeset
     3
"{ Package: 'stx:goodies/regression' }"
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
"{ NameSpace: RegressionTests }"
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
TestCase subclass:#NumberTest
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
     8
	instanceVariableNames:'a b'
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
     9
	classVariableNames:''
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
    10
	poolDictionaries:''
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
    11
	category:'tests-Regression-Numbers'
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
!
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
!NumberTest methodsFor:'accessing'!
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
a
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
    ^ a
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
a:something
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
    a := something.
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
b
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
    ^ b
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
!
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
b:something
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
    b := something.
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
! !
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
2162
b88079711bb5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1916
diff changeset
    33
!NumberTest methodsFor:'initialize / release'!
327
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
    34
670
4fd7b73a1c19 added: #tearDown
Stefan Vogel <sv@exept.de>
parents: 610
diff changeset
    35
tearDown
4fd7b73a1c19 added: #tearDown
Stefan Vogel <sv@exept.de>
parents: 610
diff changeset
    36
    Class withoutUpdatingChangesDo:[
1719
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
    37
        self class removeSelector:#testEQ
670
4fd7b73a1c19 added: #tearDown
Stefan Vogel <sv@exept.de>
parents: 610
diff changeset
    38
    ].
327
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
    39
! !
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
    40
2407
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    41
!NumberTest methodsFor:'tests-comparing'!
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    42
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    43
test_minMax
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    44
    self assert:(0.5 min:1) = 0.5.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    45
    self assert:(1.5 min:1) = 1.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    46
    self assert:(2 min:1) = 1.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    47
    self assert:(-1 min:1) = -1.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    48
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    49
    self assert:(0.5 max:1) = 1.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    50
    self assert:(1.5 max:1) = 1.5.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    51
    self assert:(1.5 max:2) = 2.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    52
    self assert:(2 max:1) = 2.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    53
    self assert:(-1 max:1) = 1.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    54
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    55
    self assert:(0.5 min:1 max:0) = 0.5.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    56
    self assert:(1 min:1 max:0) = 1.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    57
    self assert:(1.5 min:1 max:0) = 1.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    58
    self assert:(2 min:1 max:0) = 1.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    59
    self assert:(0 min:1 max:0) = 0.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    60
    self assert:(0.0 min:1 max:0) = 0.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    61
    self assert:(-1 min:1 max:0) = 0.
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    62
! !
74a7f4e15ade #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    63
315
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
    64
!NumberTest methodsFor:'tests-concrete bugs'!
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
test_eqNumberBug
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    "reported 09-09-2004;
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
     stc generated wrong code for some inlined = - compare (shame)."
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    69
2231
3891e2a93a7f #BUGFIX by Stefan Reise
sr
parents: 2227
diff changeset
    70
    self 
3891e2a93a7f #BUGFIX by Stefan Reise
sr
parents: 2227
diff changeset
    71
        skipIf:ExternalAddress pointerSize = 8 
3891e2a93a7f #BUGFIX by Stefan Reise
sr
parents: 2227
diff changeset
    72
        description:'Compile does not work under 64bit'.
3891e2a93a7f #BUGFIX by Stefan Reise
sr
parents: 2227
diff changeset
    73
2227
c0e82b4ad5b9 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2162
diff changeset
    74
    false "(Helper
1883
90e8d12f45d2 #REFACTORING by sr
sr
parents: 1877
diff changeset
    75
        isStcCompiledMethod:#test_eqNumberBug
1916
1054b1b5ccee #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1883
diff changeset
    76
        in:self
2227
c0e82b4ad5b9 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2162
diff changeset
    77
    )" ifTrue:[
1916
1054b1b5ccee #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1883
diff changeset
    78
        self 
1054b1b5ccee #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1883
diff changeset
    79
            skipIf:true
1054b1b5ccee #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1883
diff changeset
    80
            description:'#compile is not available in stand alone apps'.
1054b1b5ccee #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1883
diff changeset
    81
    ].            
1883
90e8d12f45d2 #REFACTORING by sr
sr
parents: 1877
diff changeset
    82
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
    Class withoutUpdatingChangesDo:[
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    84
        self class
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    85
            compile:
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
'testEQ
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    a = b ifTrue:[^ false].
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    ^ true.
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
'
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    90
            classified:'temporary'.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    ].
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    95
           a:0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    96
           b:0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   100
           a:0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   101
           b:0.0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   105
           a:0.0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   106
           b:0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   110
           a:0.0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   111
           b:0.0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    Class withoutUpdatingChangesDo:[
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   114
        Compiler stcCompileMethod:(self class compiledMethodAt:#testEQ).
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    ].
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   119
           a:0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   120
           b:0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   124
           a:0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   125
           b:0.0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   129
           a:0.0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   130
           b:0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   134
           a:0.0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   135
           b:0.0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    Class withoutUpdatingChangesDo:[
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   138
        self class removeSelector:#testEQ
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    ].
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    "
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
     self new test_eqNumberBug
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
    "
2227
c0e82b4ad5b9 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2162
diff changeset
   144
c0e82b4ad5b9 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2162
diff changeset
   145
    "Modified (format): / 06-05-2019 / 14:12:55 / Claus Gittinger"
2231
3891e2a93a7f #BUGFIX by Stefan Reise
sr
parents: 2227
diff changeset
   146
    "Modified: / 21-05-2019 / 16:20:50 / Stefan Reise"
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
! !
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
327
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   149
!NumberTest methodsFor:'tests-conversion-rounding'!
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   150
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   151
test_conversion
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   152
    "reported as Bug 388
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   153
     Current implementation neither truncate nor round to nearest Floating point
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   154
     value, it just accumulate round off errors."
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   155
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   156
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   157
    self assert: 16r1FFFFFFFFFFFF0801 asDouble ~= 16r1FFFFFFFFFFFF0800 asDouble.
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   158
    "this test is on 65 bits"
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   159
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   160
    self assert: 16r1FFFFFFFFFFFF0802 asDouble ~= 16r1FFFFFFFFFFFF0800 asDouble.
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   161
    "this test is on 64 bits"
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   162
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   163
    self assert: 16r1FFFFFFFFFFF1F800 asDouble = 16r1FFFFFFFFFFF20000 asDouble.
2424
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   164
    "nearest even is higher"
327
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   165
    self assert: 16r1FFFFFFFFFFFF0800 asDouble = 16r1FFFFFFFFFFFF0000 asDouble.
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   166
    "nearest even is lower"
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   167
2424
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   168
    self assert: 16r1FFFFFFFFFFF1F800 asLongFloat ~= 16r1FFFFFFFFFFF20000 asLongFloat.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   169
    self assert: 16r1FFFFFFFFFFFF0800 asLongFloat ~= 16r1FFFFFFFFFFFF0000 asLongFloat.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   170
327
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   171
    "Created: / 24-10-2006 / 15:31:20 / cg"
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   172
! !
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   173
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   174
!NumberTest methodsFor:'tests-printing'!
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   175
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   176
testPrintf_FixedPoint
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   177
    "/ FixedPoint
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   178
    
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   179
    |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
    pi := FixedPoint pi.
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   182
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   183
    self assert:( (PrintfScanf printf:'%.4f' argument:pi) = '3.1416' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   184
    self assert:( (PrintfScanf printf:'%.8f' argument:pi)  = '3.14159265' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   185
    self assert:( (PrintfScanf printf:'%f' argument:pi)    = '3.141593' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   186
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   187
    "/ too small
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   188
    self assert:( (pi printfPrintString:'%4Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   189
    self assert:( (pi printfPrintString:'%5Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   190
    self assert:( (pi printfPrintString:'%6Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   191
    self assert:( (pi printfPrintString:'%7Lf') = '3.141593' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   192
    "/ fit
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   193
    self assert:( (pi printfPrintString:'%8Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   194
    self assert:( (pi printfPrintString:'%4.2Lf') = '3.14' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   195
    "/ left 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
    "/ right filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   198
    self assert:( (pi printfPrintString:'%-9Lf') = '3.141593 ' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   199
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   200
    "Created: / 10-10-2017 / 12:36:21 / cg"
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   201
    "Modified: / 10-10-2017 / 16:29:20 / cg"
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   202
!
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   203
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   204
testPrintf_Float
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   205
    "/ Float
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   206
    
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   207
    |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
    pi := Float pi.
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   210
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   211
    self assert:( (PrintfScanf printf:'%.0f' argument:pi)  = '3' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   212
    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
   213
    self assert:( (PrintfScanf printf:'%.1f' argument:pi)  = '3.1' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   214
    self assert:( (PrintfScanf printf:'%#.1f' argument:pi) = '3.1' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   215
    self assert:( (PrintfScanf printf:'%.2f' argument:pi)  = '3.14' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   216
    self assert:( (PrintfScanf printf:'%.3f' argument:pi)  = '3.142' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   217
    self assert:( (PrintfScanf printf:'%.4f' argument:pi)  = '3.1416' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   218
    self assert:( (PrintfScanf printf:'%.8f' argument:pi)  = '3.14159265' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   219
    self assert:( (PrintfScanf printf:'%f' argument:pi)    = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   220
    self assert:( (PrintfScanf printf:'%4f' argument:pi)   = '3.141593' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   221
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   222
    "/ too small
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   223
    self assert:( (pi printfPrintString:'%4f') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   224
    self assert:( (pi printfPrintString:'%5f') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   225
    self assert:( (pi printfPrintString:'%6f') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   226
    self assert:( (pi printfPrintString:'%7f') = '3.141593' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   227
    "/ fit
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   228
    self assert:( (pi printfPrintString:'%8f')   = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   229
    self assert:( (pi printfPrintString:'%4.2f') = '3.14' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   230
    "/ left filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   231
    self assert:( (pi printfPrintString:'%9f')   = ' 3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   232
    self assert:( (pi printfPrintString:'%8.4f') = '  3.1416' ).
1776
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   233
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   234
    "/ right filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   235
    self assert:( (pi printfPrintString:'%-9f') = '3.141593 ' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   236
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   237
false ifTrue:[
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   238
    #(
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   239
        '%.3f'       1.0      '1.0'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   240
    ) inGroupsOf:3 do:[:fmt :val :expected|
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   241
        |printfGenerated stxGenerated|
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   242
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   243
        printfGenerated := val printfPrintString:fmt.
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   244
        stxGenerated := PrintfScanf printf:fmt argument:val.
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   245
        self assert:(stxGenerated = printfGenerated).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   246
        self assert:(printfGenerated = expected).
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
].
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   249
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   250
    self assert:( (1.0 printfPrintString:'%4f') = '1.000000' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   251
    self assert:( (1.0 printfPrintString:'%5f') = '1.000000' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   252
    self assert:( (1.0 printfPrintString:'%6f') = '1.000000' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   253
    self assert:( (1.0 printfPrintString:'%7f') = '1.000000' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   254
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   255
    self assert:( (1.0 printfPrintString:'%.0f') = '1' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   256
    self assert:( (1.0 printfPrintString:'%#.0f') = '1.' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   257
    self assert:( (1.0 printfPrintString:'%#.0g') = '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:'%#.1g') = '1.' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   260
    self assert:( (1.0 printfPrintString:'%.1f') = '1.0' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   261
    self assert:( (1.0 printfPrintString:'%.2f') = '1.00' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   262
    self assert:( (1.0 printfPrintString:'%.3f') = '1.000' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   263
    self assert:( (1.0 printfPrintString:'%.4f') = '1.0000' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   264
    self assert:( (1.0 printfPrintString:'%.5f') = '1.00000' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   265
    self assert:( (1.0 printfPrintString:'%.6f') = '1.000000' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   266
    self assert:( (1.0 printfPrintString:'%.7f') = '1.0000000' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   267
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   268
    self assert:( (PrintfScanf printf:'%.0f' argument:1.0)  = '1' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   269
false ifTrue:[
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   270
    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
   271
].
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   272
    self assert:( (PrintfScanf printf:'%.1f' argument:1.0)  = '1.0' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   273
    self assert:( (PrintfScanf printf:'%#.1f' argument:1.0) = '1.0' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   274
    self assert:( (PrintfScanf printf:'%.2f' argument:1.0)  = '1.0' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   275
    self assert:( (PrintfScanf printf:'%.3f' argument:1.0)  = '1.0' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   276
    self assert:( (PrintfScanf printf:'%.4f' argument:1.0)  = '1.0' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   277
    self assert:( (PrintfScanf printf:'%.8f' argument:1.0)  = '1.0' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   278
    self assert:( (PrintfScanf printf:'%f' argument:1.0)    = '1.0' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   279
    self assert:( (PrintfScanf printf:'%4f' argument:1.0)   = ' 1.0' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   280
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   281
    "Created: / 10-10-2017 / 12:34:51 / cg"
1776
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   282
    "Modified: / 10-10-2017 / 16:32:01 / cg"
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   283
!
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   284
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   285
testPrintf_Fraction
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   286
    "/ Fraction
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   287
    |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
    pi := Fraction pi.
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   290
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   291
self assert:( (PrintfScanf printf:'%.4f' argument:pi) = '3.1416' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   292
    self assert:( (PrintfScanf printf:'%.8f' argument:pi)  = '3.14159265' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   293
    self assert:( (PrintfScanf printf:'%f' argument:pi)    = '3.141593' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   294
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   295
    "/ too small
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   296
    self assert:( (pi printfPrintString:'%4Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   297
    self assert:( (pi printfPrintString:'%5Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   298
    self assert:( (pi printfPrintString:'%6Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   299
    self assert:( (pi printfPrintString:'%7Lf') = '3.141593' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   300
    "/ fit
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   301
    self assert:( (pi printfPrintString:'%8Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   302
    self assert:( (pi printfPrintString:'%4.2Lf') = '3.14' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   303
    "/ left filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   304
    self assert:( (pi printfPrintString:'%9Lf') = ' 3.141593' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   305
    "/ right filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   306
    self assert:( (pi printfPrintString:'%-9Lf') = '3.141593 ' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   307
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   308
    "Created: / 10-10-2017 / 12:37:25 / cg"
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   309
    "Modified: / 10-10-2017 / 16:29:27 / cg"
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   310
!
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   311
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   312
testPrintf_Integer
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   313
    "/ Integers
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   314
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   315
    "/ 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
   316
    "/ 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
   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:'% d') = '-20' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   320
    self assert:( (20 printfPrintString:'%#d') = '20' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   321
    self assert:( (20 printfPrintString:'%#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:'%-# 5d') = ' 20  ' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   325
    self assert:( (20 printfPrintString:'%-#5d') = '20   ' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   326
    self assert:( (20 printfPrintString:'%-#05d') = '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:'%0-#5d') = '20   ' ).   "/ NOTICE
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   329
    self assert:( (20 printfPrintString:'%0#-5d') = '20   ' ).   "/ NOTICE
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   330
    self assert:( (20 printfPrintString:'%#05d') = '00020' ).
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
    self assert:( (20 printfPrintString:'%- 5d') = ' 20  ' ).     
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   334
    self assert:( (-20 printfPrintString:'%- 5d') = '-20  ' ).     
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   335
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   336
    #(
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
        '%D'         20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   340
        '%D'        -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   341
        '%ld'        20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   342
        '%ld'       -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   343
        '%lld'       20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   344
        '%lld'      -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   345
        '%hd'        20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   346
        '%hd'       -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   347
        '%hhd'       20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   348
        '%hhd'      -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   349
        '%lhd'       20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   350
        '%hld'      -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
        '%#d'        20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   354
        '%#d'       -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
        '%-5d'       20      '20   '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   358
        '%-5d'      -20      '-20  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   359
        '%05d'       20      '00020'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   360
        '%05d'      -20      '-0020'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   361
        '%-05d'      20      '20   '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   362
        '%-05d'     -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
        '%- 5d'      20      ' 20  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   366
        '%- 5d'     -20      '-20  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   367
        '%.0d'       20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   368
        '%.0d'      -20      '-20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   369
        '%.0d'        0      ''  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   370
        '%x'         20      '14'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   371
        '%x'        255      'ff'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   372
        '%X'        255      'FF'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   373
        '%#x'       255      '0xff'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   374
        '%#X'       255      '0XFF'   "/ printf also uppercases the 'x'
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   375
        '%x'          0      '0'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   376
        '%#x'         0      '0'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   377
        '%#x'        20      '0x14'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   378
        '%5x'        20      '   14'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   379
        '%-5x'       20      '14   '  
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
        '%#-5x'      20      '0x14 '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   383
        '%#-5X'      20      '0X14 '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   384
     "/   '%x'   -20      '-14'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   385
        '%o'         20      '24'  
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
        '%#o'        20      '024'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   388
        '%#o'         0      '0'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   389
        '%5o'        20      '   24'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   390
        '%-5o'       20      '24   '  
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
        '%-#5o'      20      '024  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   393
        '%#-5o'      20      '024  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   394
        '%-#05o'     20      '024  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   395
        '%#05o'      20      '00024'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   396
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   397
        '%2d'      1234      '1234'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   398
     "/   '%2.2d'    1234      '1234'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   399
        '%2x'        10      ' a'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   400
        '%2X'        10      ' A'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   401
        '%02x'       10      '0a'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   402
        '%02X'       10      '0A'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   403
     "/   '%o'   -20      '-24'  
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
        '%-#5d'     -20      '-20  '
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   406
        '%-#5d'     -20      '-20  '
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   407
        '%-#05d'    -20      '-20  '
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   408
        '%#05d'     -20      '-0020'
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   409
        '%-#5d'      20      '20   '
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   410
        '%-#5d'      20      '20   '
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   411
        '%-#05d'     20      '20   '
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   412
        '%-#05x'     20      '0x14 '
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   413
        '%#05x'      20      '0x014'
2394
168fb84c7806 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2392
diff changeset
   414
168fb84c7806 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2392
diff changeset
   415
        '%.3x'   0xAFFE      'affe'      "/ max length ignored for numbers
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   416
    ) inGroupsOf:3 do:[:fmt :val :expected|
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   417
        |printfGenerated stxGenerated|
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   418
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   419
        printfGenerated := val printfPrintString:fmt.
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   420
        stxGenerated := PrintfScanf printf:fmt argument:val.
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   421
        self assert:(stxGenerated = printfGenerated).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   422
        self assert:(printfGenerated = expected).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   423
    ].
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
    "/ hex
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   426
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   427
    self assert:( (PrintfScanf printf:'%x' argument:-20) = '-14' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   428
    self assert:( (PrintfScanf printf:'%#x' argument:-20) = '-0x14' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   429
    self assert:( (PrintfScanf printf:'%#7x' argument:-20) = '  -0x14' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   430
    self assert:( (PrintfScanf printf:'%-#7x' argument:-20) = '-0x14  ' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   431
    self assert:( (PrintfScanf printf:'%-#07x' argument:-20) = '-0x14  ' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   432
    self assert:( (PrintfScanf printf:'%#07x' argument:-20) = '-0x0014' ).
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
    "/ octal
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   435
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   436
    self assert:( (PrintfScanf printf:'%o' argument:-20) = '-24' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   437
    self assert:( (PrintfScanf printf:'%#o' argument:-20) = '-024' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   438
    self assert:( (PrintfScanf printf:'%#5o' argument:-20) = ' -024' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   439
    self assert:( (PrintfScanf printf:'%-#5o' argument:-20) = '-024 ' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   440
    self assert:( (PrintfScanf printf:'%-#05o' argument:-20) = '-024 ' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   441
    self assert:( (PrintfScanf printf:'%#05o' argument:-20) = '-0024' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   442
!
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   443
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   444
testPrintf_LargeFloat
2267
65cbf58d8983 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   445
    "/ LargeFloat- unfinished
1862
54413f61d192 #BUGFIX by sr
sr
parents: 1776
diff changeset
   446
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   447
    |lf pi|
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   448
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   449
    pi := LargeFloat pi.
2424
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   450
1862
54413f61d192 #BUGFIX by sr
sr
parents: 1776
diff changeset
   451
    self 
2268
360e548237a1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 2267
diff changeset
   452
        skipIf:(Smalltalk isSmalltalkDevelopmentSystem not)
360e548237a1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 2267
diff changeset
   453
        description:'work in progress'.
360e548237a1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 2267
diff changeset
   454
360e548237a1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 2267
diff changeset
   455
    self 
1862
54413f61d192 #BUGFIX by sr
sr
parents: 1776
diff changeset
   456
        skipIf:(Smalltalk at:#LargeFloat) isNil  
54413f61d192 #BUGFIX by sr
sr
parents: 1776
diff changeset
   457
        description:'LargeFloat is not loaded'.
54413f61d192 #BUGFIX by sr
sr
parents: 1776
diff changeset
   458
2450
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   459
    self assert:(pi printString) = '3.141592653590' "'3.141592653589793238462643383280'".
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   460
    self assert:( (PrintfScanf printf:'%.4f' argument:pi)  = '3.1416' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   461
    self assert:( (PrintfScanf printf:'%.8f' argument:pi)  = '3.14159265' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   462
2450
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   463
    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
   464
    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
   465
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   466
    "/ too small                                              
2450
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   467
    self assert:( (pi printfPrintString:'%4Lf') = '3.14159265359' "'3.141592653589793238462643383280'" ).
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   468
    self assert:( (pi printfPrintString:'%5Lf') = '3.14159265359' "'3.141592653589793238462643383280'" ).
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   469
    self assert:( (pi printfPrintString:'%6Lf') = '3.14159265359' "'3.141592653589793238462643383280'" ).
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   470
    self assert:( (pi printfPrintString:'%7Lf') = '3.14159265359' "'3.141592653589793238462643383280'" ).
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   471
    "/ fit
2450
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   472
    self assert:( (pi printfPrintString:'%8Lf') = '3.14159265359' "'3.141592653589793238462643383280'" ).
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   473
    self assert:( (pi printfPrintString:'%4.2Lf') = '3.14' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   474
    self assert:( (pi printfPrintString:'%4.3Lf') = '3.142' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   475
    self assert:( (pi printfPrintString:'%4.4Lf') = '3.1416' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   476
    self assert:( (pi printfPrintString:'%4.5Lf') = '3.14159' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   477
    self assert:( (pi printfPrintString:'%4.6Lf') = '3.141593' ).
2338
164c3d4cba01 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   478
    
2424
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   479
    "/ left 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
    "/ right filled
2450
a284c0898eb8 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2447
diff changeset
   482
    self assert:( (pi printfPrintString:'%-9Lf') = '3.14159265359' "'3.141593 '" ).
2424
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   483
2338
164c3d4cba01 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   484
    "/ exact (to 130 digits)  value is:
2267
65cbf58d8983 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   485
    "/ 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
   486
    "/ ((LargeFloat fromString:'3.141592653589793238462643383279') printfPrintString:'%4.20Lf')
2424
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   487
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   488
    lf := 1 asLargeFloat.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   489
    self assert:( (lf printfPrintString:'%4.20Lf') = ' 1.0' ).
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.1' ).
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.01' ).
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.001' ).
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.0001' ).
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.00001' ).
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.000001' ).
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.0000001' ).
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.00000001' ).
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.000000001' ).
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.0000000001' ).
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.00000000001' ).
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.000000000001' ).
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.0000000000001' ).
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.00000000000001' ).
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.000000000000001' ).
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.0000000000000001' ).
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.00000000000000001' ).
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.000000000000000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   526
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   527
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.0000000000000000001' ).
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.21Lf') = '0.00000000000000000001' ).
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   530
    lf := lf / 10.
da9ee5df3c43 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
   531
    self assert:( (lf printfPrintString:'%4.22Lf') = '0.000000000000000000001' ).
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   532
    lf := pi.
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   533
    self assert:( (lf printString) = '3.141592653589793238462643383280' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   534
    self assert:( (lf printfPrintString:'%4.20Lf') = '3.14159265358979323846' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   535
    lf := lf - 3.
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   536
    self assert:( (lf printfPrintString:'%4.20Lf') = '0.14159265358979323846' ).
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   537
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   538
    "Created: / 10-10-2017 / 16:25:25 / cg"
2268
360e548237a1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 2267
diff changeset
   539
    "Modified: / 05-06-2019 / 20:15:13 / Claus Gittinger"
2338
164c3d4cba01 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   540
    "Modified (comment): / 22-07-2019 / 19:40:10 / Claus Gittinger"
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   541
!
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   542
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   543
testPrintf_LongFloat
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   544
    "/ LongFloat
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   545
    
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   546
    |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
    pi := LongFloat pi.
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   549
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   550
    self assert:( (PrintfScanf printf:'%.4f' argument:pi)  = '3.1416' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   551
    self assert:( (PrintfScanf printf:'%.8f' argument:pi)  = '3.14159265' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   552
    self assert:( (PrintfScanf printf:'%f' argument:pi)  = '3.14159265' ).
1628
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
    "/ LongFloat
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   555
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   556
    "/ too small
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   557
    self assert:( (pi printfPrintString:'%4Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   558
    self assert:( (pi printfPrintString:'%5Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   559
    self assert:( (pi printfPrintString:'%6Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   560
    self assert:( (pi printfPrintString:'%7Lf') = '3.141593' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   561
    "/ fit
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   562
    self assert:( (pi printfPrintString:'%8Lf') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   563
    self assert:( (pi printfPrintString:'%4.2Lf') = '3.14' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   564
    "/ left 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
    "/ right filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   567
    self assert:( (pi printfPrintString:'%-9Lf') = '3.141593 ' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   568
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   569
    "Created: / 10-10-2017 / 12:35:40 / cg"
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   570
    "Modified: / 10-10-2017 / 16:29:56 / cg"
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   571
!
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   572
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   573
testPrintf_Misc
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   574
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   575
    "/ 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
   576
    "/ 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
   577
    self assert:( (20 printfPrintString:'%%%d') = '%20' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   578
    self assert:( (20 printfPrintString:'%d%%') = '20%' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   579
    self assert:( (20 printfPrintString:'%d%') = '20' ).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   580
2396
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   581
    {
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   582
        '%f'   .   Float NaN                .  'nan'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   583
        '%F'   .   Float NaN                .  'NAN'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   584
        '%f'   .   Float infinity           .  'inf'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   585
        '%F'   .   Float infinity           .  'INF'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   586
        '%f'   .   Float negativeInfinity   .  '-inf'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   587
        '%F'   .   Float negativeInfinity   .  '-INF'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   588
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   589
        '%+f'  .   Float NaN                .  'nan'  .    
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   590
        '%+F'  .   Float NaN                .  'NAN'  .    
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   591
        '%+f'  .   Float infinity           .  '+inf'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   592
        '%+F'  .   Float infinity           .  '+INF'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   593
        '%+f'  .   Float negativeInfinity   .  '-inf'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   594
        '%+F'  .   Float negativeInfinity   .  '-INF'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   595
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   596
        '% 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
   597
        '% 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
   598
        '% f'  .   Float infinity           .  ' inf'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   599
        '% F'  .   Float infinity           .  ' INF'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   600
        '% f'  .   Float negativeInfinity   .  '-inf'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   601
        '% F'  .   Float negativeInfinity   .  '-INF'  .
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   602
    } inGroupsOf:3 do:[:fmt :val :expected|
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   603
        |printfGenerated stxGenerated|
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   604
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   605
        printfGenerated := val printfPrintString:fmt.
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   606
        stxGenerated := PrintfScanf printf:fmt argument:val.
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   607
        self assert:(stxGenerated = printfGenerated).
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   608
        self assert:(printfGenerated = expected).
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   609
    ].
86b690d8f903 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2394
diff changeset
   610
2392
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   611
    #(
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   612
        '%r'       1234      'r'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   613
        '%3r'      1234      '  r'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   614
        '%-3r'      1234     'r  '  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   615
        '%#r'      1234      'r'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   616
      "/  '%v'       1234      'v'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   617
        '%Id'      1234      'Id'  
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
        '%d%%'         20      '20%'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   620
        '%d%'          20      '20'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   621
        '%%a%%'        20      '%a%'  
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   622
    ) inGroupsOf:3 do:[:fmt :val :expected|
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   623
        |printfGenerated stxGenerated|
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   624
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   625
        printfGenerated := val printfPrintString:fmt.
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   626
        stxGenerated := PrintfScanf printf:fmt argument:val.
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   627
        self assert:(stxGenerated = printfGenerated).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   628
        self assert:(printfGenerated = expected).
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   629
    ].
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   630
!
17e6138f5686 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2338
diff changeset
   631
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   632
testPrintf_QDouble
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   633
    "/ QDouble
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   634
    |pi|
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   635
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   636
    pi := QDouble pi.
1719
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
   637
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
   638
    self 
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
   639
        skipIf:(OperatingSystem isUNIXlike and:[ExternalAddress pointerSize = 4])
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
   640
        description:'Fails under Linux32'.
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
   641
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   642
    self assert:( (PrintfScanf printf:'%.4f' argument:pi)  = '3.1416' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   643
    self assert:( (PrintfScanf printf:'%.8f' argument:pi)  = '3.14159265' ).
2447
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   644
    self assert:( (PrintfScanf printf:'%f' argument:pi)    = '3.14159265358979323846264338328' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   645
2447
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   646
    self assert:( (pi printfPrintString:'%4Lf') = '3.14159265358979323846264338328' ).
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   647
    self assert:( (pi printfPrintString:'%5Lf') = '3.14159265358979323846264338328' ).
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   648
    self assert:( (pi printfPrintString:'%6Lf') = '3.14159265358979323846264338328' ).
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   649
    self assert:( (pi printfPrintString:'%7Lf') = '3.14159265358979323846264338328' ).
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   650
    self assert:( (pi printfPrintString:'%18Lf') = '3.14159265358979323846264338328' ).
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   651
    self assert:( (pi printfPrintString:'%19Lf') = '3.14159265358979323846264338328' ).
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   652
    self assert:( (pi printfPrintString:'%20Lf') = '3.14159265358979323846264338328' ).
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   653
    self assert:( (pi printfPrintString:'%21Lf') = '3.14159265358979323846264338328' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   654
    "/ fit
2447
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   655
    self assert:( (pi printfPrintString:'%22Lf') = '3.14159265358979323846264338328' ).
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   656
    self assert:( (pi printfPrintString:'%4.2Lf') = '3.14' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   657
    "/ left filled
2447
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   658
    self assert:( (pi printfPrintString:'%23Lf') = '3.14159265358979323846264338328' ).
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
    "/ right filled
2447
81b27fbbc2e9 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
   661
    self assert:( (pi printfPrintString:'%-30Lf') = '3.14159265358979323846264338328' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   662
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   663
    "Created: / 10-10-2017 / 12:24:22 / cg"
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   664
    "Modified: / 10-10-2017 / 16:28:51 / cg"
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   665
!
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   666
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   667
testPrintf_ShortFloat
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   668
    |pi|
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   669
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   670
    pi := ShortFloat pi.
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   671
    self assert:( (PrintfScanf printf:'%.4f' argument:pi) = '3.1416' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   672
    self assert:( (PrintfScanf printf:'%f' argument:pi) = '3.14159' ).
1718
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
    "/ ShortFloat
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   675
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   676
    "/ too small
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   677
    self assert:( (pi printfPrintString:'%4f') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   678
    self assert:( (pi printfPrintString:'%5f') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   679
    self assert:( (pi printfPrintString:'%6f') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   680
    self assert:( (pi printfPrintString:'%7f') = '3.141593' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   681
    "/ fit
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   682
    self assert:( (pi printfPrintString:'%8f') = '3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   683
    self assert:( (pi printfPrintString:'%4.2f') = '3.14' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   684
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   685
    "/ left filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   686
    self assert:( (pi printfPrintString:'%9f') = ' 3.141593' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   687
    self assert:( (pi printfPrintString:'%8.4f') = '  3.1416' ).
1776
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   688
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   689
    "/ right filled
2427
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   690
    self assert:( (pi printfPrintString:'%-9f') = '3.141593 ' ).
7d730212d1f0 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2424
diff changeset
   691
    self assert:( (pi printfPrintString:'%-8.4f') = '3.1416  ' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   692
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   693
    "Created: / 10-10-2017 / 12:35:12 / cg"
1776
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   694
    "Modified: / 10-10-2017 / 16:32:31 / cg"
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   695
! !
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   696
309
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   697
!NumberTest methodsFor:'tests-reading'!
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   698
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   699
testReadFrom
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   700
    self assert: 1.0e-14    = (Number readFrom: '1.0e-14').
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   701
315
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   702
    self assert: ('1' asNumber = 1).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   703
    self assert: ('10' asNumber = 10).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   704
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   705
    self assert: ('-1' asNumber = -1).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   706
    self assert: ('-10' asNumber = -10).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   707
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   708
    self assert: ('1e' asNumber = 1).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   709
    self assert: ('1e1' asNumber = 10).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   710
    self assert: ('1e10' asNumber = 10000000000).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   711
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   712
    self assert: ('-1e' asNumber = -1).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   713
    self assert: ('-1e1' asNumber = -10).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   714
    self assert: ('-1e10' asNumber = -10000000000).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   715
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   716
    self assert: ('1.0e' asNumber = 1.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   717
    self assert: ('1.0e1' asNumber = 10.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   718
    self assert: ('1.0e10' asNumber = 10000000000.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   719
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   720
    self assert: ('-1.0e' asNumber = -1.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   721
    self assert: ('-1.0e1' asNumber = -10.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   722
    self assert: ('-1.0e10' asNumber = -10000000000.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   723
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   724
    self assert: ('22.2' asNumber = 22.2).
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   725
    self assert: ('-22.2' asNumber = -22.2).
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   726
309
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   727
    Smalltalk isSmalltalkX ifTrue:[
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   728
        "/ st/x requires this:
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   729
2456
081734105794 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2450
diff changeset
   730
        self assert: ((Number readSmalltalkSyntaxFrom:'10r5.5') = 5.5).
081734105794 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2450
diff changeset
   731
        self assert: ((Number readSmalltalkSyntaxFrom:'16r5.5') = 5.3125).
081734105794 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2450
diff changeset
   732
        self assert: ((Number readSmalltalkSyntaxFrom:'3r1.1e2') = 12).
081734105794 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2450
diff changeset
   733
        self assert: ((Number readSmalltalkSyntaxFrom:'3r1.1e10') = 78732.0).
081734105794 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2450
diff changeset
   734
        self assert: ((Number readSmalltalkSyntaxFrom:'16r10.1e10') = 16.117431640625).
081734105794 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2450
diff changeset
   735
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   736
        self assert: ((Number readSmalltalkSyntaxFrom:'10r22.2') = 22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   737
        self assert: ((Number readSmalltalkSyntaxFrom:'10r22.2s5') = 22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   738
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   739
        self assert: ((Number readSmalltalkSyntaxFrom:'10r-22.2') = -22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   740
        self assert: ((Number readSmalltalkSyntaxFrom:'10r-22.2s5') = -22.2).
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   741
1863
0af9cae4cecb #BUGFIX by sr
sr
parents: 1862
diff changeset
   742
        "/ test fails when stc code, byte code works
1877
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   743
        (Helper 
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   744
            isStcCompiledMethod:#'testReadFrom'
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   745
            in:self) ifTrue:[ 
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   746
                self logSkipped:'2r1e26 is not valid in stc code -> debugger doesNotUnderstand: #e26'.
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   747
            ] ifFalse:[    
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   748
                self assert: 2r1e26     = (Number readSmalltalkSyntaxFrom: '2r1e26').
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   749
            ].
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   750
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   751
        self assert: ('-1q' asNumber = -1).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   752
        self assert: ('-1q' asNumber class == LongFloat).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   753
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   754
        self assert: ('-1q1' asNumber = -10).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   755
        self assert: ('-1q10' asNumber = -10000000000).
309
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   756
    ] ifFalse:[
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   757
        "/ squeak allows this:
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   758
        self assert: 2r1e26     = (Number readFrom: '2r1e26').
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   759
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   760
        self assert: ('10r22.2' asNumber = 22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   761
        self assert: ('10r22.2s5' asNumber = 22.2).
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   762
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   763
        self assert: ('10r-22.2' asNumber = -22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   764
        self assert: ('10r-22.2s5' asNumber = -22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   765
    ].
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   766
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   767
    "Modified: / 20-06-2017 / 14:05:37 / cg"
309
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   768
! !
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   769
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   770
!NumberTest class methodsFor:'documentation'!
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   771
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   772
version
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   773
    ^ '$Header$'
1776
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   774
!
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   775
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   776
version_CVS
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   777
    ^ '$Header$'
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   778
! !
1072
ee32c0daddfb category
Claus Gittinger <cg@exept.de>
parents: 670
diff changeset
   779