The Trunk: KernelTests-nice.143.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.143.mcz

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

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

Name: KernelTests-nice.143
Author: nice
Time: 14 March 2010, 11:15:33.7 pm
UUID: 945be389-6e83-4e8e-b675-fcfcdcce6e4e
Ancestors: KernelTests-cmm.142

Let NumberParser test auto-detect whether lowercase digit letters are allowed or not, and then disbale non-10-based floating point tests.
This make the tests green again.

=============== Diff against KernelTests-cmm.142 ===============

Item was changed:
  ----- Method: SqNumberParserTest>>testFloatGradualUnderflow (in category 'tests - Float') -----
  testFloatGradualUnderflow
  "Gradual underflow are tricky.
  This is a non regression test for http://bugs.squeak.org/view.php?id=6976"
 
  | float trueFraction str |
 
  "as a preamble, use a base 16 representation to avoid round off error and check that number parsing is correct"
- float := SqNumberParser parse: '16r2.D2593D58B4FC4e-256'.
  trueFraction := 16r2D2593D58B4FC4 / (16 raisedTo: 256+13).
+ "Parse the number in base 16 if possible - it is impossible if lowercase letter are allowed digits due to exponent letter ambiguity."
+ float := self areLowercaseDigitsAllowed
+ ifNil: [SqNumberParser parse: '16r2.D2593D58B4FC4e-256']
+ ifNotNil: [trueFraction asFloat]..
  self assert: float asTrueFraction = trueFraction.
  self assert: float = trueFraction asFloat.
 
  "now print in base 10"
  str := (String new: 32) writeStream.
  float absPrintExactlyOn: str base: 10.
 
  "verify if SqNumberParser can read it back"
  self assert: (SqNumberParser parse: str contents) = float. !

Item was added:
+ ----- Method: SqNumberParserTest>>areLowercaseDigitsAllowed (in category 'utility') -----
+ areLowercaseDigitsAllowed
+ "Answer true if lowercase letter are allowed digits."
+
+ ^(SqNumberParser parse: '16re' onError: [-1]) = 16rE!

Item was changed:
  ----- Method: SqNumberParserTest>>testFloatPrintString (in category 'tests - Float') -----
  testFloatPrintString
  "self debug: #testFloatPrintString"
 
+ | f r bases |
- | f r |
  f := Float basicNew: 2.
  r := Random new seed: 1234567.
+ "printing a Float in base other than 10 is broken if lowercase digits are allowed"
+ bases := self areLowercaseDigitsAllowed
+ ifTrue: [#(10)]
+ ifFalse: [#(2 8 10 16)].
  100
  timesRepeat: [f basicAt: 1 put: (r nextInt: 16r100000000)- 1.
  f basicAt: 2 put: (r nextInt: 16r100000000) - 1.
+ bases
- #(2 8 10 16)
  do: [:base | | str |
  str := (String new: 64) writeStream.
  f negative ifTrue: [str nextPut: $-].
  str print: base; nextPut: $r.
  f absPrintExactlyOn: str base: base.
  self assert: (SqNumberParser parse: str contents) = f]].
  "test big num near infinity"
  10
  timesRepeat: [f basicAt: 1 put: 16r7FE00000 + ((r nextInt: 16r100000) - 1).
  f basicAt: 2 put: (r nextInt: 16r100000000) - 1.
+ bases
- #(2 8 10 16)
  do: [:base | | str |
  str := (String new: 64) writeStream.
  f negative ifTrue: [str nextPut: $-].
  str print: base; nextPut: $r.
  f absPrintExactlyOn: str base: base.
  self assert: (SqNumberParser parse: str contents) = f]].
  "test infinitesimal (gradual underflow)"
  10
  timesRepeat: [f basicAt: 1 put: 0 + ((r nextInt: 16r100000) - 1).
  f basicAt: 2 put: (r nextInt: 16r100000000) - 1.
+ bases
- #(2 8 10 16)
  do: [:base | | str |
  str := (String new: 64) writeStream.
  f negative ifTrue: [str nextPut: $-].
  str print: base; nextPut: $r.
  f absPrintExactlyOn: str base: base.
  self assert: (SqNumberParser parse: str contents) = f]].!