Nicolas Cellier uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-nice.164.mcz ==================== Summary ==================== Name: KernelTests-nice.164 Author: nice Time: 22 September 2010, 12:02:13.329 am UUID: 432cb71f-bfd7-4637-a4c4-1232904319e1 Ancestors: KernelTests-nice.163 Add tests for #sign and #sign: (which means #copySignOf: ) As usual, the case of Float negativeZero is more than tricky... =============== Diff against KernelTests-nice.163 =============== Item was added: + ----- Method: FloatTest>>testSign (in category 'testing') ----- + testSign + + "Set up" + | negatives negz positives strictNegatives strictPositives zero | + strictPositives := {2. 2.5. Float infinity}. + strictNegatives := {-3. -3.25. Float infinity negated}. + zero := 0.0. + negz := Float negativeZero. + positives := strictPositives copyWith: zero. + negatives := strictNegatives copyWith: negz. + + "The sign of non zeros" + strictPositives do: [:aPositive | self assert: aPositive sign = 1]. + strictNegatives do: [:aNegative | self assert: aNegative sign = -1]. + + "The sign of zeros" + self assert: zero sign = 0. + self assert: negz sign = -1. "remark though that negz >= 0.0, and is thus considered positive... Weird" + + "Test the copy sign functions" + positives do: [:aPositiveSign | + positives do: [:aPositive | + self assert: (aPositive sign: aPositiveSign) = aPositive]. + negatives do: [:aNegative | + self assert: (aNegative sign: aPositiveSign) = aNegative negated]. + (0.0 sign: aPositiveSign) sign = 0. + (negz sign: aPositiveSign) sign = 0]. + + negatives do: [:aNegativeSign | + positives do: [:aPositive | + self assert: (aPositive sign: aNegativeSign) = aPositive negated]. + negatives do: [:aNegative | + self assert: (aNegative sign: aNegativeSign) = aNegative]. + (negz sign: aNegativeSign) sign = -1. + (negz sign: aNegativeSign) sign = -1].! |
Nicolas,
I would duplicate this test, testing both the actual objects and the result of SqNumberParser generating them, e.g. testSign self runTestSignOfZero: 0.0 negativeZero: Float negativeZero.
self runTestSignOfZero: (SqNumberParser parse: '0.0') negativeZero: (SqNumberParser parse: '-0.0')runTestSignOfZero: zero negativeZero: negz ....
On Tue, Sep 21, 2010 at 3:02 PM, <[hidden email]> wrote: Nicolas Cellier uploaded a new version of KernelTests to project The Trunk: |
Free forum by Nabble | Edit this page |