The Trunk: KernelTests-nice.135.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: KernelTests-nice.135.mcz

commits-2
Nicolas Cellier uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-nice.135.mcz

==================== Summary ====================

Name: KernelTests-nice.135
Author: nice
Time: 13 February 2010, 11:33:47.403 pm
UUID: 810f63de-1825-4447-b56a-2c942b012490
Ancestors: KernelTests-nice.134

1) Change the expectations for conversions to ScaledDecimal according to new policy.
2) Add a SqNumberParser testfrom Pharo

=============== Diff against KernelTests-nice.134 ===============

Item was added:
+ ----- Method: ScaledDecimalTest>>testConvertFromIntegerWithScale (in category 'tests') -----
+ testConvertFromIntegerWithScale
+ "Converting an Integer with asScaledDecimal: does now honour the scale passed as message argument."
+
+ | sd |
+ sd := 13 asScaledDecimal: 6.
+ self assert: 6 = sd scale.
+ self assert: ('13.000000s6' = sd printString).
+ sd := -13 asScaledDecimal: 4.
+ self assert: 4 = sd scale.
+ self assert: ('-13.0000s4' = sd printString).
+ sd := 130000000013 asScaledDecimal: 3.
+ self assert: 3 = sd scale.
+ self assert: ('130000000013.000s3' = sd printString).
+ sd := -130000000013 asScaledDecimal: 1.
+ self assert: 1 = sd scale.
+ self assert: ('-130000000013.0s1' = sd printString)
+ !

Item was changed:
  ----- Method: ScaledDecimalTest>>testConvertFromInteger (in category 'tests') -----
  testConvertFromInteger
+ "Converting an Integer with asScaledDecimal use strictly necessary number of decimal places: 0."
- "Converting an Integer to a ScaledDecimal yields a ScaledDecimal with
- scale 0, regardless of the scale specified in the #asScaledDecimal: message."
 
  | sd |
+ sd := 13 asScaledDecimal.
- sd := 13 asScaledDecimal: 6.
  self assert: 0 = sd scale.
  self assert: ('13s0' = sd printString).
+ sd := -13 asScaledDecimal.
- sd := -13 asScaledDecimal: 6.
  self assert: 0 = sd scale.
  self assert: ('-13s0' = sd printString).
+ sd := 130000000013 asScaledDecimal.
- sd := 130000000013 asScaledDecimal: 6.
  self assert: 0 = sd scale.
  self assert: ('130000000013s0' = sd printString).
+ sd := -130000000013 asScaledDecimal.
- sd := -130000000013 asScaledDecimal: 6.
  self assert: 0 = sd scale.
  self assert: ('-130000000013s0' = sd printString)
  !

Item was added:
+ ----- Method: ScaledDecimalTest>>testConvertFromFractionWithScale (in category 'tests') -----
+ testConvertFromFractionWithScale
+
+ | sd |
+ sd := (13 / 11) asScaledDecimal: 6.
+ self assert: ScaledDecimal == sd class.
+ self assert: ('1.181818s6' = sd printString).
+ self assert: 6 == sd scale
+ !

Item was changed:
  ----- Method: ScaledDecimalTest>>testConvertFromFraction (in category 'tests') -----
  testConvertFromFraction
+ "Converting a Fractionwith asScaledDecimal use strictly necessary number of decimal places when possible."
+
+ | defaultNumberOfDecimals |
+ 0 to: 11 do: [:pow2 |
+ 0 to: 11 do: [:pow5 |
+ | fraction sd sd2 |
+ fraction := 13 / (2 raisedTo: pow2) / (5 raisedTo: pow5).
+ sd := fraction asScaledDecimal.
+ self assert: sd scale = (pow2 max: pow5).
+ sd2 := ScaledDecimal readFrom: sd printString.
+ self assert: sd = sd2]].
+
+ defaultNumberOfDecimals := (1/3) asScaledDecimal scale.
+ #(6 7 9 11 12 13 14 17 18 19 21 22 23 24) do: [:den |
+ | sd sd2 |
+ sd := (1/den) asScaledDecimal.
+ self assert: sd scale = defaultNumberOfDecimals.
+ sd2 := ScaledDecimal readFrom: sd printString.
+ self deny: sd = sd2
+ ] !
-
- | sd |
- sd := (13 / 11) asScaledDecimal: 6.
- self assert: ScaledDecimal == sd class.
- self assert: ('1.181818s6' = sd printString).
- self assert: 6 == sd scale
- !

Item was added:
+ ----- Method: SqNumberParserTest>>testFail (in category 'tests - fail') -----
+ testFail
+ "Verify that the value of a failblock is returned."
+ self assert: (SqNumberParser parse: 'blablabla' onError: [42]) equals: 42!