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

commits at source.squeak.org commits at source.squeak.org
Sun Oct 31 20:55:33 UTC 2010

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

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

Name: KernelTests-nice.167
Author: nice
Time: 31 October 2010, 9:55:18.943 pm
UUID: 669b4442-43de-4da0-83d3-649e77bca967
Ancestors: KernelTests-nice.166

Assert that #degreeCos and #degreeSin are exact for any multiple of 90.

This is a nice property to have that radianCos and radianSin cannot afford due to approximate floating point representation of pi.

=============== Diff against KernelTests-nice.166 ===============

+ ----- Method: FloatTest>>testDegreeCos (in category 'test - mathematical functions') -----
+ testDegreeCos
+ 	self shouldnt: [ 45.0 degreeCos] raise: Error.
+ 	"Following tests use approximate equality, because cosine are generally evaluated using inexact Floating point arithmetic"
+ 	self assert: (45.0 degreeCos squared - 0.5) abs <= Float epsilon.
+ 	self assert: (60.0 degreeCos - 0.5) abs <= Float epsilon.
+ 	self assert: (120.0 degreeCos + 0.5) abs <= Float epsilon.
+ 	-360.0 to: 360.0 do: [:i |
+ 		self assert: (i degreeCos closeTo: i degreesToRadians cos)].
+
+ 	"Following tests use strict equality which is a requested property of degreeCos"
+ 	-10.0 to: 10.0 do: [:k |
+ 		self assert: (k*360 + 90) degreeCos = 0.
+ 		self assert: (k*360 - 90) degreeCos = 0.
+ 		self assert: (k*360 + 180) degreeCos + 1 = 0.
+ 		self assert: (k*360) degreeCos - 1 = 0.].!

+ ----- Method: FloatTest>>testDegreeCosForExceptionalValues (in category 'test - mathematical functions') -----
+ testDegreeCosForExceptionalValues
+ 	self assert: Float nan degreeCos isNaN.
+ 	self assert: Float infinity degreeCos isNaN.
+ 	self assert: Float infinity negated degreeCos isNaN.!

+ ----- Method: FloatTest>>testDegreeSin (in category 'test - mathematical functions') -----
+ testDegreeSin
+ 	self shouldnt: [ 45.0 degreeSin] raise: Error.
+ 	"Following tests use approximate equality, because sine are generally evaluated using inexact Floating point arithmetic"
+ 	self assert: (45.0 degreeSin squared - 0.5) abs <= Float epsilon.
+ 	self assert: (30.0 degreeSin - 0.5) abs <= Float epsilon.
+ 	self assert: (-30.0 degreeSin + 0.5) abs <= Float epsilon.
+ 	-360.0 to: 360.0 do: [:i |
+ 		self assert: (i degreeSin closeTo: i degreesToRadians sin)].
+
+ 	"Following tests use strict equality which is a requested property of degreeSin"
+ 	-10.0 to: 10.0 do: [:k |
+ 		self assert: (k*360 + 90) degreeSin - 1 = 0.
+ 		self assert: (k*360 - 90) degreeSin + 1= 0.
+ 		self assert: (k*360 + 180) degreeSin = 0.
+ 		self assert: (k*360) degreeSin = 0.].!

+ ----- Method: FloatTest>>testDegreeSinForExceptionalValues (in category 'test - mathematical functions') -----
+ testDegreeSinForExceptionalValues
+ 	self assert: Float nan degreeSin isNaN.
+ 	self assert: Float infinity degreeSin isNaN.
+ 	self assert: Float infinity negated degreeSin isNaN.!

Item was changed:
+ ----- Method: FractionTest>>testDegreeCos (in category 'tests - mathematical functions') -----
- ----- Method: FractionTest>>testDegreeCos (in category 'tests - sinuses') -----
testDegreeCos
"self run: #testDegreeCos"

self shouldnt: [ (4/3) degreeCos] raise: Error.
+ 	-361/3 to: 359/3 do: [:i |
+ 		self assert: (i degreeCos closeTo: i degreesToRadians cos)].!
- 	self assert: (1/3) degreeCos printString =  '0.999983076857744'!

Item was changed:
+ ----- Method: FractionTest>>testDegreeSin (in category 'tests - mathematical functions') -----
- ----- Method: FractionTest>>testDegreeSin (in category 'tests - sinuses') -----
testDegreeSin
"self run: #testDegreeSin"

self shouldnt: [ (4/3) degreeSin] raise: Error.
+ 	-361/3 to: 359/3 do: [:i |
+ 		self assert: (i degreeSin closeTo: i degreesToRadians sin)].!
- 	self assert: (1/3) degreeSin printString =  '0.005817731354993834'.!

Item was changed:
+ ----- Method: IntegerTest>>testDegreeCos (in category 'tests - mathematical functions') -----
- ----- Method: IntegerTest>>testDegreeCos (in category 'tests - basic') -----
testDegreeCos
"self run: #testDegreeCos"

self shouldnt: [ 45 degreeCos] raise: Error.
+ 	"Following tests use approximate equality, because cosine are generally evaluated using inexact Floating point arithmetic"
+ 	self assert: (45 degreeCos squared - (1/2)) abs <= Float epsilon.
+ 	self assert: (60 degreeCos - (1/2)) abs <= Float epsilon.
+ 	self assert: (120 degreeCos + (1/2)) abs <= Float epsilon.
+ 	-360 to: 360 do: [:i |
+ 		self assert: (i degreeCos closeTo: i degreesToRadians cos)].
+
+ 	"Following tests use strict equality which is a requested property of degreeCos"
+ 	-10 to: 10 do: [:k |
+ 		self assert: (k*360 + 90) degreeCos = 0.
+ 		self assert: (k*360 - 90) degreeCos = 0.
+ 		self assert: (k*360 + 180) degreeCos + 1 = 0.
+ 		self assert: (k*360) degreeCos - 1 = 0.].!
- 	self assert: 45  degreeCos printString =  (2 sqrt / 2) asFloat printString !

+ ----- Method: IntegerTest>>testDegreeSin (in category 'tests - mathematical functions') -----
+ testDegreeSin
+ 	"self run: #testDegreeSin"
+
+ 	self shouldnt: [ 45 degreeSin] raise: Error.
+
+ 	"Following tests use approximate equality, because sine are generally evaluated using inexact Floating point arithmetic"
+ 	self assert: (45 degreeSin squared - (1/2)) abs <= Float epsilon.
+ 	self assert: (30 degreeSin - (1/2)) abs <= Float epsilon.
+ 	self assert: (-30 degreeSin + (1/2)) abs <= Float epsilon.
+ 	-360 to: 360 do: [:i |
+ 		self assert: (i degreeSin closeTo: i degreesToRadians sin)].
+
+ 	"Following tests use strict equality which is a requested property of degreeSin"
+ 	-10 to: 10 do: [:k |
+ 		self assert: (k*360 + 90) degreeSin - 1 = 0.
+ 		self assert: (k*360 - 90) degreeSin + 1= 0.
+ 		self assert: (k*360 + 180) degreeSin = 0.
+ 		self assert: (k*360) degreeSin = 0].!

```