RegressionTests__FractionTest.st
author Claus Gittinger <cg@exept.de>
Tue, 09 Jul 2019 18:53:03 +0200
changeset 2327 bf482d49aeaf
parent 2266 43ebfa6688a1
child 2452 88407e46d054
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: 1068
diff changeset
     1
"{ Package: 'stx:goodies/regression' }"
159
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"{ NameSpace: RegressionTests }"
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
TestCase subclass:#FractionTest
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
	instanceVariableNames:''
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
	classVariableNames:''
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
	poolDictionaries:''
1068
8c5c3ab780b6 category
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
     9
	category:'tests-Regression-Numbers'
159
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
!
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
!FractionTest methodsFor:'tests'!
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
314
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
    15
testDegreeCos
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
    16
    "self run: #testDegreeCos"
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
    17
314
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
    18
    self shouldnt: [ (4/3) degreeCos] raise: Error.
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
    19
    Smalltalk isSmalltalkX ifTrue:[
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
    20
	self assert: ((1/3) degreeCos printString startsWith:'0.999983')
314
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
    21
    ] ifFalse:[
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
    22
	self assert: (1/3) degreeCos printString =  '0.999983076857744'
314
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
    23
    ]
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
    24
!
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
    25
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
    26
testDegreeSin
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
    27
    "self run: #testDegreeSin"
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
    28
314
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
    29
    self shouldnt: [ (4/3) degreeSin] raise: Error.
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
    30
    Smalltalk isSmalltalkX ifTrue:[
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
    31
	self assert: ((1/3) degreeSin printString startsWith:'0.005817')
314
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
    32
    ] ifFalse:[
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
    33
	self assert: (1/3) degreeSin printString =  '0.005817731354993834'
314
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
    34
    ]
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
    35
!
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
    36
2266
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    37
testDivisionResult
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    38
    |a b rslt|
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    39
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    40
    "/ 45 gcd:18 -> 9 
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    41
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    42
    rslt := Fraction numerator:45 denominator:18.
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    43
    self assert:(rslt isFraction).
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    44
    self assert:(rslt numerator = 5).
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    45
    self assert:(rslt denominator = 2).
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    46
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    47
    a := 45.
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    48
    b := 18.
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    49
    rslt := Fraction numerator:a denominator:b.
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    50
    self assert:(rslt isFraction).
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    51
    self assert:(rslt numerator = 5).
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    52
    self assert:(rslt denominator = 2).
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    53
    
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    54
    rslt := a / b.
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    55
    self assert:(rslt isFraction).
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    56
    self assert:(rslt numerator = 5).
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    57
    self assert:(rslt denominator = 2).
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    58
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    59
    rslt := Fraction numerator:6 denominator:3.
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    60
    self assert:(rslt isInteger).
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    61
    self assert:(rslt == 2).
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    62
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    63
    a := 6.
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    64
    b := 3.
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    65
    rslt := Fraction numerator:a denominator:b.
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    66
    self assert:(rslt isInteger).
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    67
    self assert:(rslt == 2).
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    68
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    69
    rslt := a / b.
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    70
    self assert:(rslt isInteger).
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    71
    self assert:(rslt == 2).
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    72
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    73
    "Created: / 05-06-2019 / 18:57:26 / Claus Gittinger"
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    74
!
43ebfa6688a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
    75
314
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
    76
testFractionPrinting
1824
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
    77
        self assert: (353 / 359) printString = '(353/359)'.
314
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
    78
1824
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
    79
        self assert: (-2 / 3) printString = '(-2/3)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
    80
        self assert: (-2 / 3) storeString = '(-2/3)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
    81
        self assert: (5 / -7) printString = '(-5/7)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
    82
        self assert: (5 / -7) storeString = '(-5/7)'.
314
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
    83
1824
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
    84
        Smalltalk isSmalltalkX ifFalse:[
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
    85
            self assert: ((2/3) printStringBase: 2) = '(10/11)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
    86
            self assert: ((2/3) storeStringBase: 2) = '(2r10/2r11)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
    87
            self assert: ((5/7) printStringBase: 3) = '(12/21)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
    88
            self assert: ((5/7) storeStringBase: 3) = '(3r12/3r21)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
    89
            self assert: ((11/13) printStringBase: 4) = '(23/31)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
    90
            self assert: ((11/13) storeStringBase: 4) = '(4r23/4r31)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
    91
            self assert: ((17/19) printStringBase: 5) = '(32/34)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
    92
            self assert: ((17/19) storeStringBase: 5) = '(5r32/5r34)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
    93
            self assert: ((23/29) printStringBase: 6) = '(35/45)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
    94
            self assert: ((23/29) storeStringBase: 6) = '(6r35/6r45)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
    95
            self assert: ((31/37) printStringBase: 7) = '(43/52)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
    96
            self assert: ((31/37) storeStringBase: 7) = '(7r43/7r52)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
    97
            self assert: ((41/43) printStringBase: 8) = '(51/53)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
    98
            self assert: ((41/43) storeStringBase: 8) = '(8r51/8r53)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
    99
            self assert: ((47/53) printStringBase: 9) = '(52/58)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   100
            self assert: ((47/53) storeStringBase: 9) = '(9r52/9r58)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   101
            self assert: ((59/61) printStringBase: 10) = '(59/61)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   102
            self assert: ((59/61) storeStringBase: 10) = '(59/61)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   103
            self assert: ((67/71) printStringBase: 11) = '(61/65)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   104
            self assert: ((67/71) storeStringBase: 11) = '(11r61/11r65)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   105
            self assert: ((73/79) printStringBase: 12) = '(61/67)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   106
            self assert: ((73/79) storeStringBase: 12) = '(12r61/12r67)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   107
            self assert: ((83/89) printStringBase: 13) = '(65/6B)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   108
            self assert: ((83/89) storeStringBase: 13) = '(13r65/13r6B)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   109
            self assert: ((97/101) printStringBase: 14) = '(6D/73)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   110
            self assert: ((97/101) storeStringBase: 14) = '(14r6D/14r73)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   111
            self assert: ((103/107) printStringBase: 15) = '(6D/72)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   112
            self assert: ((103/107) storeStringBase: 15) = '(15r6D/15r72)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   113
            self assert: ((109/113) printStringBase: 16) = '(6D/71)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   114
            self assert: ((109/113) storeStringBase: 16) = '(16r6D/16r71)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   115
            self assert: ((127/131) printStringBase: 17) = '(78/7C)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   116
            self assert: ((127/131) storeStringBase: 17) = '(17r78/17r7C)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   117
            self assert: ((137/139) printStringBase: 18) = '(7B/7D)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   118
            self assert: ((137/139) storeStringBase: 18) = '(18r7B/18r7D)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   119
            self assert: ((149/151) printStringBase: 19) = '(7G/7I)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   120
            self assert: ((149/151) storeStringBase: 19) = '(19r7G/19r7I)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   121
            self assert: ((157/163) printStringBase: 20) = '(7H/83)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   122
            self assert: ((157/163) storeStringBase: 20) = '(20r7H/20r83)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   123
            self assert: ((167/173) printStringBase: 21) = '(7K/85)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   124
            self assert: ((167/173) storeStringBase: 21) = '(21r7K/21r85)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   125
            self assert: ((179/181) printStringBase: 22) = '(83/85)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   126
            self assert: ((179/181) storeStringBase: 22) = '(22r83/22r85)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   127
            self assert: ((191/193) printStringBase: 23) = '(87/89)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   128
            self assert: ((191/193) storeStringBase: 23) = '(23r87/23r89)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   129
            self assert: ((197/199) printStringBase: 24) = '(85/87)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   130
            self assert: ((197/199) storeStringBase: 24) = '(24r85/24r87)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   131
            self assert: ((211/223) printStringBase: 25) = '(8B/8N)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   132
            self assert: ((211/223) storeStringBase: 25) = '(25r8B/25r8N)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   133
            self assert: ((227/229) printStringBase: 26) = '(8J/8L)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   134
            self assert: ((227/229) storeStringBase: 26) = '(26r8J/26r8L)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   135
            self assert: ((233/239) printStringBase: 27) = '(8H/8N)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   136
            self assert: ((233/239) storeStringBase: 27) = '(27r8H/27r8N)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   137
            self assert: ((241/251) printStringBase: 28) = '(8H/8R)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   138
            self assert: ((241/251) storeStringBase: 28) = '(28r8H/28r8R)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   139
            self assert: ((257/263) printStringBase: 29) = '(8P/92)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   140
            self assert: ((257/263) storeStringBase: 29) = '(29r8P/29r92)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   141
            self assert: ((269/271) printStringBase: 30) = '(8T/91)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   142
            self assert: ((269/271) storeStringBase: 30) = '(30r8T/30r91)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   143
            self assert: ((277/281) printStringBase: 31) = '(8T/92)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   144
            self assert: ((277/281) storeStringBase: 31) = '(31r8T/31r92)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   145
            self assert: ((283/293) printStringBase: 32) = '(8R/95)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   146
            self assert: ((283/293) storeStringBase: 32) = '(32r8R/32r95)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   147
            self assert: ((307/311) printStringBase: 33) = '(9A/9E)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   148
            self assert: ((307/311) storeStringBase: 33) = '(33r9A/33r9E)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   149
            self assert: ((313/317) printStringBase: 34) = '(97/9B)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   150
            self assert: ((313/317) storeStringBase: 34) = '(34r97/34r9B)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   151
            self assert: ((331/337) printStringBase: 35) = '(9G/9M)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   152
            self assert: ((331/337) storeStringBase: 35) = '(35r9G/35r9M)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   153
            self assert: ((347/349) printStringBase: 36) = '(9N/9P)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   154
            self assert: ((347/349) storeStringBase: 36) = '(36r9N/36r9P)'.
314
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
   155
1824
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   156
            self assert: ((-2/3) printStringBase: 2) = '(-10/11)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   157
            self assert: ((-2/3) storeStringBase: 2) = '(-2r10/2r11)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   158
            self assert: ((5/-7) printStringBase: 3) = '(-12/21)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   159
            self assert: ((5/-7) storeStringBase: 3) = '(-3r12/3r21)'.
8c9ff08eee5d #BUGFIX by sr
sr
parents: 1447
diff changeset
   160
        ].
314
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
   161
!
cd0e47be2a25 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 196
diff changeset
   162
701
8e6f93fb198a added: #testFractionReduction
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   163
testFractionReduction
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1068
diff changeset
   164
	self assert: (100 factorial / 99 factorial) == 100.
701
8e6f93fb198a added: #testFractionReduction
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   165
!
8e6f93fb198a added: #testFractionReduction
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   166
159
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
testMixedAddition
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
    self assert:(((1/2) + (1/2)) = 1).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
    self assert:(((1/2) + 0.5) = 1).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
    self assert:(((1/2) + (0.5 asFixedPoint:2)) = 1).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
    self assert:(((1/2) + (0.5 asDouble)) = 1).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
    self assert:(((1/2) + (0.5 asFloat)) = 1).
196
3c28a4e5daa5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   173
    self assert:(((1/2) + (0.5 asLongFloat)) = 1).
3c28a4e5daa5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   174
    self assert:(((1/2) + (0.5 asShortFloat)) = 1).
159
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    self assert:(((1/2) + ((1/2) asFixedPoint:2)) = 1).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
    self assert:(((1/2) + ((1/2) asDouble)) = 1).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
    self assert:(((1/2) + ((1/2) asFloat)) = 1).
196
3c28a4e5daa5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   179
    self assert:(((1/2) + ((1/2) asLongFloat)) = 1).
3c28a4e5daa5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   180
    self assert:(((1/2) + ((1/2) asShortFloat)) = 1).
159
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
    self assert:(((1/2) + (1/2)) = 1.0).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
    self assert:(((1/2) + 0.5) = 1.0).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
    self assert:(((1/2) + (0.5 asFixedPoint:2)) = 1.0).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
    self assert:(((1/2) + (0.5 asDouble)) = 1.0).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
    self assert:(((1/2) + (0.5 asFloat)) = 1.0).
196
3c28a4e5daa5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   188
    self assert:(((1/2) + (0.5 asLongFloat)) = 1.0).
3c28a4e5daa5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   189
    self assert:(((1/2) + (0.5 asShortFloat)) = 1.0).
159
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
    self assert:(((1/2) + ((1/2) asFixedPoint:2)) = 1.0).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
    self assert:(((1/2) + ((1/2) asDouble)) = 1.0).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
    self assert:(((1/2) + ((1/2) asFloat)) = 1.0).
196
3c28a4e5daa5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   194
    self assert:(((1/2) + ((1/2) asLongFloat)) = 1.0).
3c28a4e5daa5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   195
    self assert:(((1/2) + ((1/2) asShortFloat)) = 1.0).
159
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
    self assert:((0.5 + (1/2)) = 1).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
    self assert:(((0.5 asFixedPoint:2) + (1/2)) = 1).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
    self assert:((((0.5 asFloat) asDouble) + (1/2)) = 1).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
    self assert:((1 + (1/2)) = (3/2)).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
    self assert:((1.0 + (1/2)) = (3/2)).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    self assert:(((1 asFixedPoint:2) + (1/2)) = (3/2)).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
    self assert:((((1 asFloat) asDouble) + (1/2)) = (3/2)).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
!
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
testMixedAddition2
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
    |fix1 fix2|
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    fix1 := (1/2) asFixedPoint:2.
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
    fix2 := (1/2) asFixedPoint:2.
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
    self assert:((fix1 + (1/2)) = 1).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
    self assert:((fix1 + 0.5) = 1).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
    self assert:((fix1 + (0.5 asFixedPoint:2)) = 1).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
    self assert:((fix1 + (0.5 asDouble)) = 1).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
    self assert:((fix1 + (0.5 asFloat)) = 1).
196
3c28a4e5daa5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   218
    self assert:((fix1 + (0.5 asLongFloat)) = 1).
3c28a4e5daa5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   219
    self assert:((fix1 + (0.5 asShortFloat)) = 1).
159
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
    self assert:((fix1 + ((1/2) asFixedPoint:2)) = 1).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
    self assert:((fix1 + ((1/2) asDouble)) = 1).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
    self assert:((fix1 + ((1/2) asFloat)) = 1).
196
3c28a4e5daa5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   224
    self assert:((fix1 + ((1/2) asLongFloat)) = 1).
3c28a4e5daa5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   225
    self assert:((fix1 + ((1/2) asShortFloat)) = 1).
159
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
    self assert:((fix1 + (1/2)) = 1.0).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
    self assert:((fix1 + 0.5) = 1.0).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
    self assert:((fix1 + (0.5 asFixedPoint:2)) = 1.0).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
    self assert:((fix1 + (0.5 asDouble)) = 1.0).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
    self assert:((fix1 + (0.5 asFloat)) = 1.0).
196
3c28a4e5daa5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   233
    self assert:((fix1 + (0.5 asLongFloat)) = 1.0).
3c28a4e5daa5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   234
    self assert:((fix1 + (0.5 asShortFloat)) = 1.0).
159
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
    self assert:((fix1 + ((1/2) asFixedPoint:2)) = 1.0).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
    self assert:((fix1 + ((1/2) asDouble)) = 1.0).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
    self assert:((fix1 + ((1/2) asFloat)) = 1.0).
196
3c28a4e5daa5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   239
    self assert:((fix1 + ((1/2) asLongFloat)) = 1.0).
3c28a4e5daa5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   240
    self assert:((fix1 + ((1/2) asShortFloat)) = 1.0).
159
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
    self assert:((0.5 + (fix1)) = 1).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
    self assert:(((0.5 asFixedPoint:2) + fix1) = 1).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
    self assert:((((0.5 asFloat) asDouble) + (fix1)) = 1).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
    self assert:((1 + fix1) = (3/2)).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
    self assert:((1.0 + fix1) = (3/2)).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
    self assert:(((1 asFixedPoint:2) + fix1) = (3/2)).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    self assert:((((1 asFloat) asDouble) + fix1) = (3/2)).
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
! !
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
!FractionTest class methodsFor:'documentation'!
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
version
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
    ^ '$Header$'
4864967123ca initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
! !
1068
8c5c3ab780b6 category
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   257