[squeak-dev] The Inbox: KernelTests-nice.277.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Jul 24 17:57:21 UTC 2014
A new version of KernelTests was added to project The Inbox:
http://source.squeak.org/inbox/KernelTests-nice.277.mcz
==================== Summary ====================
Name: KernelTests-nice.277
Author: nice
Time: 24 July 2014, 7:57:23.27 pm
UUID: 848d64b4-ce9b-6c43-9045-fd20c3eb3c30
Ancestors: KernelTests-dtl.276
Attempt to minimize cost of testRaisedToModulo for those VM lacking a LargeIntegers plugin.
=============== Diff against KernelTests-dtl.276 ===============
Item was changed:
----- Method: IntegerTest>>testRaisedToModulo (in category 'testing - arithmetic') -----
testRaisedToModulo
+
+ | aBigInt n1 n2 |
+ "try to force loading of the LargeIntegers plugin"
+ aBigInt := SmallInteger maxVal raisedTo: 4.
+ self assert: (aBigInt + 1) * (aBigInt - 1) = aBigInt squared - 1.
+
+ (Smalltalk listLoadedModules anySatisfy: [:e | e beginsWith: #LargeIntegers])
+ ifTrue:
+ ["Yes we have a plugin, use a fine sieve"
+ n1 := 15. n2 := 20]
+ ifFalse:
+ ["Nope, no plugin, just use a very sparse test"
+ n1 := 3. n2 := 4].
+
+ "Apply an adapted sieve"
#(301 2047) do: [:m |
+ 1 to: m - 1 by: (m // n1) do: [:x |
+ 11 to: m - 1 by: (m // n2) do: [:y |
- 1 to: m - 1 by: (m // 30) do: [:x |
- 11 to: m - 1 by: (m // 40) do: [:y |
self assert: (x raisedTo: y) \\ m = (x raisedTo: y modulo: m)]]].
self assert: (8951195 raisedTo: 7742931 modulo: 15485863) = 15485862.!
More information about the Squeak-dev
mailing list
|