[Pkg] The Trunk: KernelTests-nice.222.mcz
commits at source.squeak.org
commits at source.squeak.org
Sat Jun 2 23:20:04 UTC 2012
Nicolas Cellier uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-nice.222.mcz
==================== Summary ====================
Name: KernelTests-nice.222
Author: nice
Time: 22 May 2012, 10:59:50.142 pm
UUID: bf545579-1414-4840-b6b3-a846c58251b5
Ancestors: KernelTests-nice.221
Provides tests for Fraction readFrom:
=============== Diff against KernelTests-nice.221 ===============
Item was added:
+ ----- Method: FractionTest>>testFractionReading (in category 'tests - printing') -----
+ testFractionReading
+ "Numerator literal syntax"
+ self assert: (Fraction readFrom: '4') equals: 4.
+ self assert: (Fraction readFrom: '45') equals: 45.
+ self assert: (Fraction readFrom: '-45') equals: -45.
+ self assert: (Fraction readFrom: '4e2') equals: 400.
+ self assert: (Fraction readFrom: '33e-2') equals: 33/100.
+ self assert: (Fraction readFrom: '4r123') equals: 1 * 4 + 2 * 4 + 3.
+ self assert: (Fraction readFrom: '-4r123e5') equals: 1 * 4 + 2 * 4 + 3 * (4 raisedTo: 5) negated.
+
+ "Numerator/Denominator literals syntax"
+ self assert: (Fraction readFrom: '23/17') equals: 23/17.
+ self assert: (Fraction readFrom: '-122/17') equals: -122/17.
+ self assert: (Fraction readFrom: '-3r21e4/8r57e6') equals: (2 * 3 + 1 * (3 raisedTo: 4)) negated /(5 * 8 + 7 * (8 raisedTo: 6)).
+
+ "Decimal integer part.fraction part literal syntax"
+ self assert: (Fraction readFrom: '0.1') equals: 1/10.
+ self assert: (Fraction readFrom: '0.071') equals: 71/1000.
+ self assert: (Fraction readFrom: '-0.071e2') equals: -71/10.
+ self assert: (Fraction readFrom: '0.07100e-2') equals: 71/100000.
+
+ "Extended syntax"
+ self assert: (Fraction readFrom: '+4') equals: 4.
+ self assert: (Fraction readFrom: '.13') equals: 13/100.
+ self assert: (Fraction readFrom: '30.e-2') equals: 3/10.
+ self assert: (Fraction readFrom: '+30.e+4') equals: 300000.!
Item was added:
+ ----- Method: FractionTest>>testFractionReadingBase (in category 'tests - printing') -----
+ testFractionReadingBase
+ {17/25. -132/271. 127. -1000} do: [:fraction |
+ #(2 3 8 10 16) do: [:base |
+ | printed |
+ printed := (fraction printStringBase: base) copyWithoutAll: '()'.
+ self assert: (Fraction readFrom: printed base: base) equals: fraction]].!
More information about the Packages
mailing list