[Pkg] The Trunk: KernelTests-nice.225.mcz
commits at source.squeak.org
commits at source.squeak.org
Sat Jun 2 23:37:28 UTC 2012
Nicolas Cellier uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-nice.225.mcz
==================== Summary ====================
Name: KernelTests-nice.225
Author: nice
Time: 3 June 2012, 1:36:52.333 am
UUID: 0618f9bc-673f-4402-80a5-209cae160b43
Ancestors: KernelTests-eem.224, KernelTests-nice.222
Merge nice.222 (test for reading Fraction from Stream)
Complete the tests with some error conditions.
=============== Diff against KernelTests-eem.224 ===============
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.
+
+ "Errors"
+ self should: [(Fraction readFrom: '')] raise: Error.
+ self should: [(Fraction readFrom: '.')] raise: Error.
+ self should: [(Fraction readFrom: 'e3')] raise: Error.
+ self should: [(Fraction readFrom: '+e2')] raise: Error.
+ self should: [(Fraction readFrom: '-.e+2')] raise: Error.
+ self should: [(Fraction readFrom: '/2')] raise: Error.!
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