RegressionTests__NumberTest.st
author Claus Gittinger <cg@exept.de>
Tue, 09 Jul 2019 18:53:03 +0200
changeset 2327 bf482d49aeaf
parent 2268 360e548237a1
child 2338 164c3d4cba01
permissions -rw-r--r--
#QUALITY by exept class: RegressionTests::StringTests added: #test82c_expanding
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1072
diff changeset
     1
"{ Package: 'stx:goodies/regression' }"
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"{ NameSpace: RegressionTests }"
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
TestCase subclass:#NumberTest
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
     6
	instanceVariableNames:'a b'
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
     7
	classVariableNames:''
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
     8
	poolDictionaries:''
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
     9
	category:'tests-Regression-Numbers'
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
!
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
!NumberTest methodsFor:'accessing'!
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
a
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
    ^ a
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
!
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
a:something
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
    a := something.
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
b
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
    ^ b
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
b:something
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
    b := something.
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
! !
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
2162
b88079711bb5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1916
diff changeset
    31
!NumberTest methodsFor:'initialize / release'!
327
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
    32
670
4fd7b73a1c19 added: #tearDown
Stefan Vogel <sv@exept.de>
parents: 610
diff changeset
    33
tearDown
4fd7b73a1c19 added: #tearDown
Stefan Vogel <sv@exept.de>
parents: 610
diff changeset
    34
    Class withoutUpdatingChangesDo:[
1719
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
    35
        self class removeSelector:#testEQ
670
4fd7b73a1c19 added: #tearDown
Stefan Vogel <sv@exept.de>
parents: 610
diff changeset
    36
    ].
327
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
    37
! !
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
    38
315
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
    39
!NumberTest methodsFor:'tests-concrete bugs'!
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
test_eqNumberBug
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    "reported 09-09-2004;
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
     stc generated wrong code for some inlined = - compare (shame)."
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    44
2231
3891e2a93a7f #BUGFIX by Stefan Reise
sr
parents: 2227
diff changeset
    45
    self 
3891e2a93a7f #BUGFIX by Stefan Reise
sr
parents: 2227
diff changeset
    46
        skipIf:ExternalAddress pointerSize = 8 
3891e2a93a7f #BUGFIX by Stefan Reise
sr
parents: 2227
diff changeset
    47
        description:'Compile does not work under 64bit'.
3891e2a93a7f #BUGFIX by Stefan Reise
sr
parents: 2227
diff changeset
    48
2227
c0e82b4ad5b9 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2162
diff changeset
    49
    false "(Helper
1883
90e8d12f45d2 #REFACTORING by sr
sr
parents: 1877
diff changeset
    50
        isStcCompiledMethod:#test_eqNumberBug
1916
1054b1b5ccee #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1883
diff changeset
    51
        in:self
2227
c0e82b4ad5b9 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2162
diff changeset
    52
    )" ifTrue:[
1916
1054b1b5ccee #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1883
diff changeset
    53
        self 
1054b1b5ccee #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1883
diff changeset
    54
            skipIf:true
1054b1b5ccee #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1883
diff changeset
    55
            description:'#compile is not available in stand alone apps'.
1054b1b5ccee #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1883
diff changeset
    56
    ].            
1883
90e8d12f45d2 #REFACTORING by sr
sr
parents: 1877
diff changeset
    57
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    Class withoutUpdatingChangesDo:[
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    59
        self class
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    60
            compile:
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
'testEQ
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    a = b ifTrue:[^ false].
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    ^ true.
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
'
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    65
            classified:'temporary'.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    ].
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    70
           a:0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    71
           b:0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    75
           a:0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    76
           b:0.0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    80
           a:0.0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    81
           b:0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    85
           a:0.0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    86
           b:0.0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    Class withoutUpdatingChangesDo:[
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    89
        Compiler stcCompileMethod:(self class compiledMethodAt:#testEQ).
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    ].
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    94
           a:0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    95
           b:0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
    99
           a:0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   100
           b:0.0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   104
           a:0.0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   105
           b:0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
    self assert: (
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
       (self
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   109
           a:0.0;
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   110
           b:0.0) testEQ ) == false.
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    Class withoutUpdatingChangesDo:[
1713
72bd587b1967 #BUGFIX by sr
sr
parents: 1710
diff changeset
   113
        self class removeSelector:#testEQ
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    ].
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 new test_eqNumberBug
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    "
2227
c0e82b4ad5b9 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2162
diff changeset
   119
c0e82b4ad5b9 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2162
diff changeset
   120
    "Modified (format): / 06-05-2019 / 14:12:55 / Claus Gittinger"
2231
3891e2a93a7f #BUGFIX by Stefan Reise
sr
parents: 2227
diff changeset
   121
    "Modified: / 21-05-2019 / 16:20:50 / Stefan Reise"
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
! !
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
327
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   124
!NumberTest methodsFor:'tests-conversion-rounding'!
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   125
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   126
test_conversion
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   127
    "reported as Bug 388
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   128
     Current implementation neither truncate nor round to nearest Floating point
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   129
     value, it just accumulate round off errors."
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   130
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   131
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   132
    self assert: 16r1FFFFFFFFFFFF0801 asDouble ~= 16r1FFFFFFFFFFFF0800 asDouble.
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   133
    "this test is on 65 bits"
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   134
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   135
    self assert: 16r1FFFFFFFFFFFF0802 asDouble ~= 16r1FFFFFFFFFFFF0800 asDouble.
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   136
    "this test is on 64 bits"
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   137
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   138
    self assert: 16r1FFFFFFFFFFF1F800 asDouble = 16r1FFFFFFFFFFF20000 asDouble.
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   139
    "nearest even is upper"
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   140
    self assert: 16r1FFFFFFFFFFFF0800 asDouble = 16r1FFFFFFFFFFFF0000 asDouble.
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   141
    "nearest even is lower"
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   142
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   143
    "Created: / 24-10-2006 / 15:31:20 / cg"
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   144
! !
05cf0c282e59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   145
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   146
!NumberTest methodsFor:'tests-printing'!
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   147
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   148
testPrintf_FixedPoint
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   149
    "/ FixedPoint
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   150
    
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   151
    self assert:( (PrintfScanf printf:'%.4f' argument:FixedPoint pi) = '3.1416' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   152
    self assert:( (PrintfScanf printf:'%.8f' argument:FixedPoint pi)  = '3.14159265' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   153
    self assert:( (PrintfScanf printf:'%f' argument:FixedPoint pi)    = '3.141593' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   154
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   155
    "/ too small
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   156
    self assert:( (FixedPoint pi printfPrintString:'%4Lf') = '3.141593' ).
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   157
    self assert:( (FixedPoint pi printfPrintString:'%5Lf') = '3.141593' ).
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   158
    self assert:( (FixedPoint pi printfPrintString:'%6Lf') = '3.141593' ).
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   159
    self assert:( (FixedPoint pi printfPrintString:'%7Lf') = '3.141593' ).
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   160
    "/ fit
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   161
    self assert:( (FixedPoint pi printfPrintString:'%8Lf') = '3.141593' ).
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   162
    self assert:( (FixedPoint pi printfPrintString:'%4.2Lf') = '3.14' ).
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   163
    "/ left filled
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   164
    self assert:( (FixedPoint pi printfPrintString:'%9Lf') = ' 3.141593' ).
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   165
    "/ right filled
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   166
    self assert:( (FixedPoint pi printfPrintString:'%-9Lf') = '3.141593 ' ).
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   167
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   168
    "Created: / 10-10-2017 / 12:36:21 / cg"
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   169
    "Modified: / 10-10-2017 / 16:29:20 / cg"
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   170
!
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   171
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   172
testPrintf_Float
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   173
    "/ Float
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   174
    
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   175
    self assert:( (PrintfScanf printf:'%.4f' argument:Float pi)      = '3.1416' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   176
    self assert:( (PrintfScanf printf:'%.8f' argument:Float pi)  = '3.14159265' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   177
    self assert:( (PrintfScanf printf:'%f' argument:Float pi)    = '3.141593' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   178
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   179
    "/ too small
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   180
    self assert:( (Float pi printfPrintString:'%4f') = '3.141593' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   181
    self assert:( (Float pi printfPrintString:'%5f') = '3.141593' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   182
    self assert:( (Float pi printfPrintString:'%6f') = '3.141593' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   183
    self assert:( (Float pi printfPrintString:'%7f') = '3.141593' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   184
    "/ fit
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   185
    self assert:( (Float pi printfPrintString:'%8f') = '3.141593' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   186
    self assert:( (Float pi printfPrintString:'%4.2f') = '3.14' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   187
    "/ left filled
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   188
    self assert:( (Float pi printfPrintString:'%9f') = ' 3.141593' ).
1776
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   189
    self assert:( (Float pi printfPrintString:'%8.4f') = '  3.1416' ).
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   190
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   191
    "/ right filled
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   192
    self assert:( (Float pi printfPrintString:'%-9f') = '3.141593 ' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   193
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   194
    "Created: / 10-10-2017 / 12:34:51 / cg"
1776
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   195
    "Modified: / 10-10-2017 / 16:32:01 / cg"
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   196
!
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   197
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   198
testPrintf_Fraction
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   199
    "/ Fraction
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   200
    
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   201
    self assert:( (PrintfScanf printf:'%.4f' argument:Fraction pi) = '3.1416' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   202
    self assert:( (PrintfScanf printf:'%.8f' argument:Fraction pi)  = '3.14159265' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   203
    self assert:( (PrintfScanf printf:'%f' argument:Fraction pi)    = '3.141593' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   204
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   205
    "/ too small
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   206
    self assert:( (Fraction pi printfPrintString:'%4Lf') = '3.141593' ).
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   207
    self assert:( (Fraction pi printfPrintString:'%5Lf') = '3.141593' ).
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   208
    self assert:( (Fraction pi printfPrintString:'%6Lf') = '3.141593' ).
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   209
    self assert:( (Fraction pi printfPrintString:'%7Lf') = '3.141593' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   210
    "/ fit
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   211
    self assert:( (Fraction pi printfPrintString:'%8Lf') = '3.141593' ).
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   212
    self assert:( (Fraction pi printfPrintString:'%4.2Lf') = '3.14' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   213
    "/ left filled
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   214
    self assert:( (Fraction pi printfPrintString:'%9Lf') = ' 3.141593' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   215
    "/ right filled
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   216
    self assert:( (Fraction pi printfPrintString:'%-9Lf') = '3.141593 ' ).
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   217
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   218
    "Created: / 10-10-2017 / 12:37:25 / cg"
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   219
    "Modified: / 10-10-2017 / 16:29:27 / cg"
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   220
!
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   221
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   222
testPrintf_LargeFloat
2267
65cbf58d8983 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   223
    "/ LargeFloat- unfinished
1862
54413f61d192 #BUGFIX by sr
sr
parents: 1776
diff changeset
   224
54413f61d192 #BUGFIX by sr
sr
parents: 1776
diff changeset
   225
    self 
2268
360e548237a1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 2267
diff changeset
   226
        skipIf:(Smalltalk isSmalltalkDevelopmentSystem not)
360e548237a1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 2267
diff changeset
   227
        description:'work in progress'.
360e548237a1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 2267
diff changeset
   228
360e548237a1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 2267
diff changeset
   229
    self 
1862
54413f61d192 #BUGFIX by sr
sr
parents: 1776
diff changeset
   230
        skipIf:(Smalltalk at:#LargeFloat) isNil  
54413f61d192 #BUGFIX by sr
sr
parents: 1776
diff changeset
   231
        description:'LargeFloat is not loaded'.
54413f61d192 #BUGFIX by sr
sr
parents: 1776
diff changeset
   232
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   233
    self assert:( (PrintfScanf printf:'%.4f' argument:LargeFloat pi)  = '3.1416' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   234
    self assert:( (PrintfScanf printf:'%.8f' argument:LargeFloat pi)  = '3.14159265' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   235
    self assert:( (PrintfScanf printf:'%f' argument:LargeFloat pi)  = '3.141593' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   236
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   237
    "/ too small
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   238
    self assert:( (LargeFloat pi printfPrintString:'%4Lf') = '3.141593' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   239
    self assert:( (LargeFloat pi printfPrintString:'%5Lf') = '3.141593' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   240
    self assert:( (LargeFloat pi printfPrintString:'%6Lf') = '3.141593' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   241
    self assert:( (LargeFloat pi printfPrintString:'%7Lf') = '3.141593' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   242
    "/ fit
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   243
    self assert:( (LargeFloat pi printfPrintString:'%8Lf') = '3.141593' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   244
    self assert:( (LargeFloat pi printfPrintString:'%4.2Lf') = '3.14' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   245
    self assert:( (LargeFloat pi printfPrintString:'%4.3Lf') = '3.142' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   246
    self assert:( (LargeFloat pi printfPrintString:'%4.4Lf') = '3.1416' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   247
    self assert:( (LargeFloat pi printfPrintString:'%4.5Lf') = '3.14159' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   248
    self assert:( (LargeFloat pi printfPrintString:'%4.6Lf') = '3.141593' ).
2267
65cbf58d8983 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   249
    "/ exact is:
65cbf58d8983 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   250
    "/ 3.1415926535 8979323846 2643383279 5028841971 6939937510 5820974944 5923078164 0628620899 8628034825 3421170679 8214808651 3282306647 
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   251
    self assert:( (LargeFloat pi printfPrintString:'%4.20Lf') = '3.14159265358979323846' ).
2267
65cbf58d8983 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   252
    "/ left filled                                              
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   253
    self assert:( (LargeFloat pi printfPrintString:'%9Lf') = ' 3.141593' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   254
    "/ right filled
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   255
    self assert:( (LargeFloat pi printfPrintString:'%-9Lf') = '3.141593 ' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   256
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   257
    "Created: / 10-10-2017 / 16:25:25 / cg"
2268
360e548237a1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 2267
diff changeset
   258
    "Modified: / 05-06-2019 / 20:15:13 / Claus Gittinger"
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   259
!
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   260
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   261
testPrintf_LongFloat
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   262
    "/ LongFloat
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   263
    
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   264
    self assert:( (PrintfScanf printf:'%.4f' argument:LongFloat pi)  = '3.1416' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   265
    self assert:( (PrintfScanf printf:'%.8f' argument:LongFloat pi)  = '3.14159265' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   266
    self assert:( (PrintfScanf printf:'%f' argument:LongFloat pi)  = '3.14159265' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   267
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   268
    "/ LongFloat
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   269
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   270
    "/ too small
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   271
    self assert:( (LongFloat pi printfPrintString:'%4Lf') = '3.141593' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   272
    self assert:( (LongFloat pi printfPrintString:'%5Lf') = '3.141593' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   273
    self assert:( (LongFloat pi printfPrintString:'%6Lf') = '3.141593' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   274
    self assert:( (LongFloat pi printfPrintString:'%7Lf') = '3.141593' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   275
    "/ fit
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   276
    self assert:( (LongFloat pi printfPrintString:'%8Lf') = '3.141593' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   277
    self assert:( (LongFloat pi printfPrintString:'%4.2Lf') = '3.14' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   278
    "/ left filled
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   279
    self assert:( (LongFloat pi printfPrintString:'%9Lf') = ' 3.141593' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   280
    "/ right filled
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   281
    self assert:( (LongFloat pi printfPrintString:'%-9Lf') = '3.141593 ' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   282
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   283
    "Created: / 10-10-2017 / 12:35:40 / cg"
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   284
    "Modified: / 10-10-2017 / 16:29:56 / cg"
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   285
!
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   286
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   287
testPrintf_QDouble
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   288
    "/ QDouble
1719
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
   289
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
   290
    self 
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
   291
        skipIf:(OperatingSystem isUNIXlike and:[ExternalAddress pointerSize = 4])
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
   292
        description:'Fails under Linux32'.
824a2964db3a #BUGFIX by sr
sr
parents: 1718
diff changeset
   293
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   294
    self assert:( (PrintfScanf printf:'%.4f' argument:QDouble pi)  = '3.1416' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   295
    self assert:( (PrintfScanf printf:'%.8f' argument:QDouble pi)  = '3.14159265' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   296
    self assert:( (PrintfScanf printf:'%f' argument:QDouble pi)    = '3.14159265358979323846' ).
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   297
    "/ QuadDouble
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   298
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   299
    "/ too small
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   300
    self assert:( (QDouble pi printfPrintString:'%4Lf') = '3.14159265358979323846' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   301
    self assert:( (QDouble pi printfPrintString:'%5Lf') = '3.14159265358979323846' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   302
    self assert:( (QDouble pi printfPrintString:'%6Lf') = '3.14159265358979323846' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   303
    self assert:( (QDouble pi printfPrintString:'%7Lf') = '3.14159265358979323846' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   304
    self assert:( (QDouble pi printfPrintString:'%18Lf') = '3.14159265358979323846' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   305
    self assert:( (QDouble pi printfPrintString:'%19Lf') = '3.14159265358979323846' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   306
    self assert:( (QDouble pi printfPrintString:'%20Lf') = '3.14159265358979323846' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   307
    self assert:( (QDouble pi printfPrintString:'%21Lf') = '3.14159265358979323846' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   308
    "/ fit
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   309
    self assert:( (QDouble pi printfPrintString:'%22Lf') = '3.14159265358979323846' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   310
    self assert:( (QDouble pi printfPrintString:'%4.2Lf') = '3.14' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   311
    "/ left filled
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   312
    self assert:( (QDouble pi printfPrintString:'%23Lf') = ' 3.14159265358979323846' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   313
    self assert:( (QDouble pi printfPrintString:'%30Lf') = '        3.14159265358979323846' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   314
    "/ right filled
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   315
    self assert:( (QDouble pi printfPrintString:'%-30Lf') = '3.14159265358979323846        ' ).
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   316
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   317
    "Created: / 10-10-2017 / 12:24:22 / cg"
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   318
    "Modified: / 10-10-2017 / 16:28:51 / cg"
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   319
!
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   320
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   321
testPrintf_ShortFloat
1774
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   322
    self assert:( (PrintfScanf printf:'%.4f' argument:ShortFloat pi) = '3.1416' ).
e4366b272224 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1719
diff changeset
   323
    self assert:( (PrintfScanf printf:'%f' argument:ShortFloat pi) = '3.14159' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   324
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   325
    "/ ShortFloat
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   326
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   327
    "/ too small
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   328
    self assert:( (ShortFloat pi printfPrintString:'%4f') = '3.141593' ).
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   329
    self assert:( (ShortFloat pi printfPrintString:'%5f') = '3.141593' ).
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   330
    self assert:( (ShortFloat pi printfPrintString:'%6f') = '3.141593' ).
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   331
    self assert:( (ShortFloat pi printfPrintString:'%7f') = '3.141593' ).
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   332
    "/ fit
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   333
    self assert:( (ShortFloat pi printfPrintString:'%8f') = '3.141593' ).
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   334
    self assert:( (ShortFloat pi printfPrintString:'%4.2f') = '3.14' ).
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   335
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   336
    "/ left filled
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   337
    self assert:( (ShortFloat pi printfPrintString:'%9f') = ' 3.141593' ).
1776
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   338
    self assert:( (ShortFloat pi printfPrintString:'%8.4f') = '  3.1416' ).
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   339
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   340
    "/ right filled
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   341
    self assert:( (ShortFloat pi printfPrintString:'%-9f') = '3.141593 ' ).
1776
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   342
    self assert:( (ShortFloat pi printfPrintString:'%-8.4f') = '3.1416  ' ).
1718
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   343
4b7eaecbbbae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
   344
    "Created: / 10-10-2017 / 12:35:12 / cg"
1776
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   345
    "Modified: / 10-10-2017 / 16:32:31 / cg"
1628
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   346
! !
27b3c920623a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
   347
309
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   348
!NumberTest methodsFor:'tests-reading'!
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   349
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   350
testReadFrom
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   351
    self assert: 1.0e-14    = (Number readFrom: '1.0e-14').
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   352
315
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   353
    self assert: ('1' asNumber = 1).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   354
    self assert: ('10' asNumber = 10).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   355
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   356
    self assert: ('-1' asNumber = -1).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   357
    self assert: ('-10' asNumber = -10).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   358
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   359
    self assert: ('1e' asNumber = 1).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   360
    self assert: ('1e1' asNumber = 10).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   361
    self assert: ('1e10' asNumber = 10000000000).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   362
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   363
    self assert: ('-1e' asNumber = -1).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   364
    self assert: ('-1e1' asNumber = -10).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   365
    self assert: ('-1e10' asNumber = -10000000000).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   366
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   367
    self assert: ('1.0e' asNumber = 1.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   368
    self assert: ('1.0e1' asNumber = 10.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   369
    self assert: ('1.0e10' asNumber = 10000000000.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   370
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   371
    self assert: ('-1.0e' asNumber = -1.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   372
    self assert: ('-1.0e1' asNumber = -10.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   373
    self assert: ('-1.0e10' asNumber = -10000000000.0).
dca04b42fcf3 read checks
Claus Gittinger <cg@exept.de>
parents: 311
diff changeset
   374
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   375
    self assert: ('22.2' asNumber = 22.2).
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   376
    self assert: ('-22.2' asNumber = -22.2).
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   377
309
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   378
    Smalltalk isSmalltalkX ifTrue:[
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   379
        "/ st/x requires this:
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   380
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   381
        self assert: ((Number readSmalltalkSyntaxFrom:'10r22.2') = 22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   382
        self assert: ((Number readSmalltalkSyntaxFrom:'10r22.2s5') = 22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   383
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   384
        self assert: ((Number readSmalltalkSyntaxFrom:'10r-22.2') = -22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   385
        self assert: ((Number readSmalltalkSyntaxFrom:'10r-22.2s5') = -22.2).
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   386
1863
0af9cae4cecb #BUGFIX by sr
sr
parents: 1862
diff changeset
   387
        "/ test fails when stc code, byte code works
1877
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   388
        (Helper 
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   389
            isStcCompiledMethod:#'testReadFrom'
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   390
            in:self) ifTrue:[ 
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   391
                self logSkipped:'2r1e26 is not valid in stc code -> debugger doesNotUnderstand: #e26'.
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   392
            ] ifFalse:[    
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   393
                self assert: 2r1e26     = (Number readSmalltalkSyntaxFrom: '2r1e26').
1c54a7a05eab #REFACTORING by sr
sr
parents: 1863
diff changeset
   394
            ].
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   395
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   396
        self assert: ('-1q' asNumber = -1).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   397
        self assert: ('-1q' asNumber class == LongFloat).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   398
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   399
        self assert: ('-1q1' asNumber = -10).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   400
        self assert: ('-1q10' asNumber = -10000000000).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   401
309
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   402
    ] ifFalse:[
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   403
        "/ squeak allows this:
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   404
        self assert: 2r1e26     = (Number readFrom: '2r1e26').
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   405
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   406
        self assert: ('10r22.2' asNumber = 22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   407
        self assert: ('10r22.2s5' asNumber = 22.2).
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   408
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   409
        self assert: ('10r-22.2' asNumber = -22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   410
        self assert: ('10r-22.2s5' asNumber = -22.2).
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   411
    ].
311
097badcf10ec more tests
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   412
1622
ced5fda31c2e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   413
    "Modified: / 20-06-2017 / 14:05:37 / cg"
309
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   414
! !
f5c2d68a0ad2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   415
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
!NumberTest class methodsFor:'documentation'!
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
version
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
    ^ '$Header$'
1776
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   420
!
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   421
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   422
version_CVS
c9bf0d2e2c92 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1774
diff changeset
   423
    ^ '$Header$'
242
43a9bab802ff initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
! !
1072
ee32c0daddfb category
Claus Gittinger <cg@exept.de>
parents: 670
diff changeset
   425