[squeak-dev] The Trunk: KernelTests-nice.206.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Oct 19 19:06:11 UTC 2011


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

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

Name: KernelTests-nice.206
Author: nice
Time: 19 October 2011, 9:05:49.567 pm
UUID: f0d273b9-8a0e-4689-8c36-ecd3b6c75f33
Ancestors: KernelTests-nice.205

More tests for #nthRoot: and #nthRootTruncated:

=============== Diff against KernelTests-nice.205 ===============

Item was added:
+ ----- Method: FractionTest>>testNthRoot (in category 'tests - mathematical functions') -----
+ testNthRoot
+ 	self assert: ((-2 raisedTo: 35) / (3 raisedTo: 20) raisedTo: 1/5) equals: (-2 raisedTo: 7) / (3 raisedTo: 4).
+ 	self assert: (1 / (1 << 2000) raisedTo: 1/100) equals: 1 / (1 << 20)!

Item was added:
+ ----- Method: IntegerTest>>testNthRoot (in category 'tests - mathematical functions') -----
+ testNthRoot
+ 	
+ 	self shouldnt: [ (1 << 2000 nthRoot: 100) ] raise: ArithmeticError.
+ 	self assert: (1 << 2000 nthRoot: 100) equals: 1 << 20!

Item was added:
+ ----- Method: IntegerTest>>testNthRootTruncated (in category 'tests - mathematical functions') -----
+ testNthRootTruncated
+ 	<timeout:  5 "seconds">
+ 	| tooBigToBeAFloat large |
+ 	tooBigToBeAFloat := 1 << 2000.
+ 	self assert: (tooBigToBeAFloat nthRootTruncated: 100) equals: 1 << 20.
+ 	self assert: (tooBigToBeAFloat + 1 nthRootTruncated: 100) equals: 1 << 20.
+ 	self assert: (tooBigToBeAFloat - 1 nthRootTruncated: 100) equals: 1 << 20 - 1.
+ 	
+ 	large := -3 raisedTo: 255.
+ 	self assert: (large nthRootTruncated: 17) equals: (-3 raisedTo: 15).
+ 	self assert: (large + 11 nthRootTruncated: 17) equals: (-3 raisedTo: 15) + 1.
+ 	self assert: (large - 11 nthRootTruncated: 17) equals: (-3 raisedTo: 15).
+ 	
+ 	2 to: 10 do: [:thePower |
+ 		1 to: 10000 do: [:n |
+ 			| theTruncatedRoot |
+ 			theTruncatedRoot := n nthRootTruncated: thePower.
+ 			self assert: (theTruncatedRoot raisedTo: thePower) <= n.
+ 			self assert: (theTruncatedRoot + 1 raisedTo: thePower) > n]]!




More information about the Squeak-dev mailing list