[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

sunit[s8] arithmetic tests

TestCase 
   subclass: #TestArithmetic
   instanceVariableNames: ''
   category: 'sunit-s8'!

! TestArithmetic methodsFor: 'test'!
testRemainder1
"a > 0 and b > 0"
"a \\ b (a > b, a integer, b not integer)"
   self assert: (5 \\ 1.5 = (5 - (5 // 1.5 * 1.5)))! !

! TestArithmetic methodsFor: 'test'!
testRemainder2
"a > 0 and b > 0"
"a \\ b (a < b, a integer, b integer)"
   self assert: (5 \\ 7 = (5 - (5 // 7 * 7)))! !

! TestArithmetic methodsFor: 'test'!
testRemainder3
"a > 0 and b > 0"
"a \\ b (a < b, a integer, b not integer)"
   self assert: (5 \\ 8.5 = (5 - (5 // 8.5 * 8.5)))! !

! TestArithmetic methodsFor: 'test'!
testRemainder4
"a > 0 and b > 0"
"a \\ b (a > b, a integer, b integer)"
   self assert: (5 \\ 2 = (5 - (5 // 2 * 2)))! !

! TestArithmetic methodsFor: 'test'!
testRemainder5
"a > 0 and b < 0"
"a \\ b (a > b, a integer, b not integer)"
   self assert: (5 \\ -1.5 = (5 - (5 // -1.5 * -1.5)))! !

! TestArithmetic methodsFor: 'test'!
testRemainder6
"a < 0 and b > 0"
"a \\ b (a < b, a integer, b integer)"
   self assert: (-5 \\ 7 = (-5 - (-5 // 7 * 7)))! !

! TestArithmetic methodsFor: 'test'!
testRemainder7
"a < 0 and b > 0"
"a \\ b (a < b, a integer, b not integer)"
   self assert: (-5 \\ 8.5 = (-5 - (-5 // 8.5 * 8.5)))! !

! TestArithmetic methodsFor: 'test'!
testRemainder8
"a > 0 and b < 0"
"a \\ b (a > b, a integer, b integer)"
   self assert: (5 \\ -2 = (5 - (5 // -2 * -2)))! !

! TestArithmetic methodsFor: 'test'!
testRemainder9
"a > 0 and b > 0"
"a \\ b (a > b, a not integer, b integer)"
   self assert: (5.5 \\ 2 = (5.5 - (5.5 // 2 * 2)))! !

! TestArithmetic methodsFor: 'test'!
testRemainderError
   self assert: (([5 \\ 0] on: [:ex | ] do: [true]) == true)! !

! TestArithmetic methodsFor: 'test'!
testIntDivError
   self assert: (([5 // 0] on: [:ex | ] do: [true]) == true)! !

! TestArithmetic methodsFor: 'test'!
testIntDiv1
   self assert: (5 // 2 = 2)! !

! TestArithmetic methodsFor: 'test'!
testIntDiv2
   self assert: (2 // 5 = 0)! !

! TestArithmetic methodsFor: 'test'!
testIntDiv3
   self assert: (5.5 // -2.2 = -3)! !

! TestArithmetic methodsFor: 'test'!
testIntDiv3
   self assert: (-5.5 // -2.2 = 2)! !