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

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

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

Name: KernelTests-nice.160
Author: nice
Time: 6 September 2010, 9:53:58.797 pm
UUID: 65ab4bf0-1383-431e-bbd7-b2c7bca0eade
Ancestors: KernelTests-ar.159

Provide tests for #reciprocalModulo:

=============== Diff against KernelTests-ar.159 ===============

Item was added:
+ ----- Method: IntegerTest>>testReciprocalModulo (in category 'testing - arithmetic') -----
+ testReciprocalModulo
+ 1 to: 512 do: [:a |
+ a + 1 to: 512 do: [:b |
+ | c |
+ (a gcd: b) = 1
+ ifTrue:
+ [c := a reciprocalModulo: b.
+ self assert: (a * c) \\ b = 1]
+ ifFalse: [self should: [ a reciprocalModulo: b ] raise: Error]]].!

Item was added:
+ ----- Method: LargePositiveIntegerTest>>testReciprocalModulo (in category 'tests') -----
+ testReciprocalModulo
+ | large r |
+ large := 1 bitShift: 48.
+ r := Random seed: 46912151.
+ 4691 timesRepeat:
+ [| a b c t |
+ a := (r nextInt: large) + 1.
+ b := (r nextInt: large) + 1.
+ a > b ifTrue: [t := a. a:= b. b := t].
+ (a gcd: b) = 1
+ ifTrue:
+ [c := a reciprocalModulo: b.
+ self assert: (a * c) \\ b = 1.]
+ ifFalse: [self should: [ a reciprocalModulo: b ] raise: Error]].!