# [Pkg] The Trunk: KernelTests-nice.164.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Sep 21 22:02:26 UTC 2010

```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 ===============

+ ----- 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].!

```