--- a/RegressionTests__ComplexTest.st Wed Jun 29 21:40:53 2016 +0100
+++ b/RegressionTests__ComplexTest.st Thu Jun 30 09:02:08 2016 +0100
@@ -150,10 +150,10 @@
| c |
false ifTrue:[
- "cg: I dont think this has to be known outside complex"
- "i.e. should it really be allowed to create complex numbers with new ?"
- self should: [ (c := Complex new) realPart = 0 ].
- self should: [ c imaginaryPart = 0 ].
+ "cg: I dont think this has to be known outside complex"
+ "i.e. should it really be allowed to create complex numbers with new ?"
+ self should: [ (c := Complex new) realPart = 0 ].
+ self should: [ c imaginaryPart = 0 ].
].
self should: [ (c := Complex real: 1 imaginary: 2) realPart = 1 ].
self should: [ c imaginaryPart = 2 ].
@@ -167,54 +167,54 @@
self should: [ (c := Complex real: -1 imaginary: -2) realPart = -1 ].
self should: [ c imaginaryPart = -2 ].
- c := (1 % 2).
+ c := (1 % 2).
self assert: (c real = 1).
self assert: (c imaginary = 2).
- c := (-1 % 2).
+ c := (-1 % 2).
self assert: (c real = -1).
self assert: (c imaginary = 2).
- c := (1 % -2).
+ c := (1 % -2).
self assert: (c real = 1).
self assert: (c imaginary = -2).
- c := (-1 % -2).
+ c := (-1 % -2).
self assert: (c real = -1).
self assert: (c imaginary = -2).
- c := (1.0 % 2.0).
+ c := (1.0 % 2.0).
self assert: (c real = 1.0).
self assert: (c imaginary = 2.0).
- c := (-1.0 % 2.0).
+ c := (-1.0 % 2.0).
self assert: (c real = -1.0).
self assert: (c imaginary = 2.0).
- c := (1.0 % -2.0).
+ c := (1.0 % -2.0).
self assert: (c real = 1.0).
self assert: (c imaginary = -2.0).
- c := (-1.0 % -2.0).
+ c := (-1.0 % -2.0).
self assert: (c real = -1.0).
self assert: (c imaginary = -2.0).
c := 5 i.
self assert: (c real = 0).
self assert: (c imaginary = 5).
-
+
c := 6 + 7 i.
self assert: (c real = 6).
self assert: ( c imaginary = 7).
-
+
c := 5.6 - 8 i.
self assert: (c real = 5.6).
self assert: (c imaginary = -8).
-
+
c := Complex real: 10 imaginary: 5.
self assert: (c real = 10).
self assert: (c imaginary = 5).
-
+
c := Complex abs: 5 arg: (Float pi/2).
self assert: (c real rounded = 0).
self assert: (c imaginary = 5).
@@ -324,19 +324,19 @@
!
testRaisedTo
- | c |
+ | c |
- self shouldnt: [ c := Complex real: 3 imaginary: 2 ] raise: Exception.
- self assert: ((c raisedTo: 2) = (c * c)).
- self assert: ((c raisedTo: 3) = (c * c * c)).
- self assert: ((c raisedTo: 4) = (c * c * c * c)).
+ self shouldnt: [ c := Complex real: 3 imaginary: 2 ] raise: Exception.
+ self assert: ((c raisedTo: 2) = (c * c)).
+ self assert: ((c raisedTo: 3) = (c * c * c)).
+ self assert: ((c raisedTo: 4) = (c * c * c * c)).
!
testReciprocal
| c |
c := (2 + 5 i).
self assert: c reciprocal = ((2/29) - (5/29)i).
-
+
"
self run: #testReciprocal
self new testReciprocal
@@ -346,7 +346,7 @@
testReciprocalError
| c |
c := (0 i).
- self should: [c reciprocal] raise: ZeroDivide
+ self should: [c reciprocal] raise: ZeroDivide
"
self run: #testReciprocalError
self new testReciprocalError
@@ -354,31 +354,31 @@
!
testSqrt
- | c w |
+ | c w |
- self shouldnt: [ c := Complex real: 0 imaginary: 0 ] raise: Exception.
- self should: [ c sqrt = 0 ].
+ self shouldnt: [ c := Complex real: 0 imaginary: 0 ] raise: Exception.
+ self should: [ c sqrt = 0 ].
- self shouldnt: [ c := Complex real: 9 imaginary: 4 ] raise: Exception.
- "cg: that cannot be tested easily, due to rounding errors"
- "original" false ifTrue:[
- self should: [ w := 3 * (((1 + (1 + ((4/9) * (4/9))) sqrt) / 2) sqrt).
- c sqrt = (Complex real: w imaginary: 4 / (2 * w)) ].
- ] ifFalse:[
- self should: [ |t1 t2 epsilon|
- w := 3 * (((1 + (1 + ((4/9) * (4/9))) sqrt) / 2) sqrt).
- t1 := c sqrt.
- t2 := (Complex real: w imaginary: 4 / (2 * w)).
- epsilon := 0.0000001.
- (t1 realPart - t2 realPart) < epsilon
- and:[ (t1 imaginaryPart - t2 imaginaryPart) < epsilon ]
- ].
- ].
+ self shouldnt: [ c := Complex real: 9 imaginary: 4 ] raise: Exception.
+ "cg: that cannot be tested easily, due to rounding errors"
+ "original" false ifTrue:[
+ self should: [ w := 3 * (((1 + (1 + ((4/9) * (4/9))) sqrt) / 2) sqrt).
+ c sqrt = (Complex real: w imaginary: 4 / (2 * w)) ].
+ ] ifFalse:[
+ self should: [ |t1 t2 epsilon|
+ w := 3 * (((1 + (1 + ((4/9) * (4/9))) sqrt) / 2) sqrt).
+ t1 := c sqrt.
+ t2 := (Complex real: w imaginary: 4 / (2 * w)).
+ epsilon := 0.0000001.
+ (t1 realPart - t2 realPart) < epsilon
+ and:[ (t1 imaginaryPart - t2 imaginaryPart) < epsilon ]
+ ].
+ ].
- self shouldnt: [ c := Complex imaginary: -2 ] raise: Exception.
- "self should: [ c sqrt = (Complex real: 1 imaginary: -1) ]. Should be true, but rounding bites us..."
- self should: [ (c sqrt realPart - 1) abs < 1.0e-10 ].
- self should: [ (c sqrt imaginaryPart + 1) abs < 1.0e-10 ].
+ self shouldnt: [ c := Complex imaginary: -2 ] raise: Exception.
+ "self should: [ c sqrt = (Complex real: 1 imaginary: -1) ]. Should be true, but rounding bites us..."
+ self should: [ (c sqrt realPart - 1) abs < 1.0e-10 ].
+ self should: [ (c sqrt imaginaryPart + 1) abs < 1.0e-10 ].
!
testSquared
@@ -414,7 +414,7 @@
c1 := 2.0e252 + 3.0e70 i.
c2 := c1.
quotient := c1 divideSecureBy: c2.
- self assert: (quotient - 1) isZero.
+ self assert: (quotient - 1) isZero.
"
self run: #testSecureDivision1