[Pkg] The Trunk: KernelTests-nice.212.mcz
commits at source.squeak.org
commits at source.squeak.org
Sun Jan 22 18:16:37 UTC 2012
Nicolas Cellier uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-nice.212.mcz
==================== Summary ====================
Name: KernelTests-nice.212
Author: nice
Time: 22 January 2012, 7:16:17.891 pm
UUID: aff99548-2cec-423c-8a00-861bc7073606
Ancestors: KernelTests-nice.211
Add a few tests about fraction (denominator is allways positive and arithmetic results are automatically reduced)
=============== Diff against KernelTests-nice.211 ===============
Item was added:
+ ----- Method: FractionTest>>testIntegerWholeDivision (in category 'tests - arithmetic') -----
+ testIntegerWholeDivision
+
+ self assert: 4 / (2/3) classAndValueEquals: 6.
+
+ self assert: 4 / (-2/3) classAndValueEquals: -6.
+
+ self assert: -4 / (-2/3) classAndValueEquals: 6.
+
+ self assert: -4 / (2/3) classAndValueEquals: -6.!
Item was added:
+ ----- Method: FractionTest>>testIntegerWholeMultiplication (in category 'tests - arithmetic') -----
+ testIntegerWholeMultiplication
+
+ self assert: 4 * (3/2) classAndValueEquals: 6.
+
+ self assert: 4 * (-3/2) classAndValueEquals: -6.
+
+ self assert: -4 * (-3/2) classAndValueEquals: 6.
+
+ self assert: -4 * (3/2) classAndValueEquals: -6.!
Item was changed:
+ ----- Method: FractionTest>>testReciprocal (in category 'tests - arithmetic') -----
- ----- Method: FractionTest>>testReciprocal (in category 'tests - sinuses') -----
testReciprocal
self
+ assert: (1/2) reciprocal classAndValueEquals: 2;
+ assert: (3/4) reciprocal equals: (4/3);
+ assert: (-1/3) reciprocal classAndValueEquals: -3;
+ assert: (-3/5) reciprocal equals: (-5/3)!
- assert: (1/2) reciprocal = 2;
- assert: (3/4) reciprocal = (4/3);
- assert: (-1/3) reciprocal = -3;
- assert: (-3/5) reciprocal = (-5/3)!
Item was added:
+ ----- Method: FractionTest>>testThatFractionDenominatorIsPositive (in category 'tests - invariants') -----
+ testThatFractionDenominatorIsPositive
+ self assert: (-3 / 2) numerator negative description: 'a Fraction sign is allways carried by its numerator'.
+ self assert: (-3 / 2) denominator positive description: 'a Fraction denominator is allways positive'.
+
+ self assert: (3 / -2) numerator negative description: 'a Fraction sign is allways carried by its numerator'.
+ self assert: (3 / -2) denominator positive description: 'a Fraction denominator is allways positive'.
+
+ self assert: (-3 / -2) numerator positive description: 'two negative signs are simplified'.
+ self assert: (-3 / -2) denominator positive description: 'a Fraction denominator is allways positive'.!
Item was added:
+ ----- Method: FractionTest>>testThatFractionIsReduced (in category 'tests - invariants') -----
+ testThatFractionIsReduced
+ self assert: (4 / 6) numerator equals: 2.
+ self assert: (4 / 6) denominator equals: 3.
+
+ self assert: (4 / 2) classAndValueEquals: 2.
+
+ "Fraction class>>#numerator:denominator: does not automatically reduce the Fraction.
+ Since it does not guaranty above invariant, it must be used with care."
+ self assert: (Fraction numerator: 4 denominator: 6) numerator equals: 4.
+ self assert: (Fraction numerator: 4 denominator: 6) denominator equals: 6.
+ self assert: (Fraction numerator: 4 denominator: 6) reduced numerator equals: 2.
+ self assert: (Fraction numerator: 4 denominator: 6) reduced denominator equals: 3.!
Item was added:
+ ----- Method: FractionTest>>testWholeDifference (in category 'tests - arithmetic') -----
+ testWholeDifference
+
+ self assert: (2/3) - (5/3) classAndValueEquals: -1.!
Item was added:
+ ----- Method: FractionTest>>testWholeDivision (in category 'tests - arithmetic') -----
+ testWholeDivision
+
+ self assert: (3/2) / (3/4) classAndValueEquals: 2.
+
+ self assert: (3/2) / (-3/4) classAndValueEquals: -2.
+
+ self assert: (-3/2) / (-3/4) classAndValueEquals: 2.
+
+ self assert: (-3/2) / (3/4) classAndValueEquals: -2.!
Item was added:
+ ----- Method: FractionTest>>testWholeMultiplication (in category 'tests - arithmetic') -----
+ testWholeMultiplication
+
+ self assert: (3/2) * (4/3) classAndValueEquals: 2.
+
+ self assert: (3/2) * (-4/3) classAndValueEquals: -2.
+
+ self assert: (-3/2) * (-4/3) classAndValueEquals: 2.
+
+ self assert: (-3/2) * (4/3) classAndValueEquals: -2.!
Item was added:
+ ----- Method: FractionTest>>testWholeSum (in category 'tests - arithmetic') -----
+ testWholeSum
+
+ self assert: (5/3) + (1/3) classAndValueEquals: 2.!
More information about the Packages
mailing list