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