[commit: testsuite] master: Add tests for new internal GMP primitives (60c7688)
git at git.haskell.org
git at git.haskell.org
Mon Oct 28 21:12:40 UTC 2013
Repository : ssh://git@git.haskell.org/testsuite
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/60c7688350c9c3d5672c17c21184346f2a785a23/testsuite
>---------------------------------------------------------------
commit 60c7688350c9c3d5672c17c21184346f2a785a23
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date: Mon Oct 28 21:46:16 2013 +0100
Add tests for new internal GMP primitives
This adds some simple tests for the primitives introduced
in [4d7cd68b/integer-gmp] and [d466dfc8/integer-gmp].
Signed-off-by: Herbert Valerio Riedel <hvr at gnu.org>
>---------------------------------------------------------------
60c7688350c9c3d5672c17c21184346f2a785a23
tests/lib/integer/integerGmpInternals.hs | 11 +++++++++++
tests/lib/integer/integerGmpInternals.stdout | 7 +++++++
2 files changed, 18 insertions(+)
diff --git a/tests/lib/integer/integerGmpInternals.hs b/tests/lib/integer/integerGmpInternals.hs
index 48bdc34..b6b90d7 100644
--- a/tests/lib/integer/integerGmpInternals.hs
+++ b/tests/lib/integer/integerGmpInternals.hs
@@ -2,6 +2,8 @@
module Main (main) where
+import Data.List (group)
+
import GHC.Base
import GHC.Integer
import GHC.Integer.GMP.Internals
@@ -32,6 +34,8 @@ powModIntegerHs b0 e0 m
main :: IO ()
main = do
print $ powModInteger b e m
+ print $ powModInteger b e (m-1)
+ print $ powModSecInteger b e (m-1)
print $ gcdExtInteger' b e
print $ gcdExtInteger' e b
print $ gcdExtInteger' x y
@@ -40,6 +44,11 @@ main = do
print $ powInteger' 12345 1
print $ powInteger' 12345 30
print $ [ (x,i) | x <- [0..71], let i = recipModInteger x (2*3*11*11*17*17), i /= 0 ]
+ print $ nextPrimeInteger b
+ print $ nextPrimeInteger e
+ print $ [ k | k <- [ 0 .. 200 ], S# (testPrimeInteger k 25#) `elem` [1,2] ]
+ print $ rle [ S# (testPrimeInteger k 25#) | k <- [ x .. x + 1000 ] ]
+ print $ rle [ S# (testPrimeInteger k 25#) | k <- [ e .. e + 1000 ] ]
return ()
where
b = 2988348162058574136915891421498819466320163312926952423791023078876139
@@ -48,3 +57,5 @@ main = do
x = 5328841272400314897981163497728751426
y = 32052182750761975518649228050096851724
+
+ rle = map (\x -> (length x, head x)) . group
diff --git a/tests/lib/integer/integerGmpInternals.stdout b/tests/lib/integer/integerGmpInternals.stdout
index 5a490ba..be0caab 100644
--- a/tests/lib/integer/integerGmpInternals.stdout
+++ b/tests/lib/integer/integerGmpInternals.stdout
@@ -1,4 +1,6 @@
1527229998585248450016808958343740453059
+682382427572745901624116300491295556924
+682382427572745901624116300491295556924
(1,-238164827888328100873319793437342927637138278785737103723156342382925)
(1,302679100340807588460107986194035692812415103244388831792688023418704)
(92889294,115110207004456909698806038261)
@@ -7,3 +9,8 @@
12345
555562377826831043419246079513769804614412256811161773362797946971665712715296306339052301636736176350153982639312744140625
[(1,1),(5,41963),(7,59947),(13,177535),(19,143557),(23,182447),(25,134281),(29,7235),(31,33841),(35,95915),(37,113413),(41,61409),(43,24397),(47,174101),(49,158431),(53,193979),(59,188477),(61,185737),(65,35507),(67,118999),(71,186173)]
+2988348162058574136915891421498819466320163312926952423791023078876343
+2351399303373464486466122544523690094744975233415544072992656881240451
+[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199]
+[(25,0),(1,1),(261,0),(1,1),(107,0),(1,1),(49,0),(1,1),(27,0),(1,1),(137,0),(1,1),(49,0),(1,1),(53,0),(1,1),(29,0),(1,1),(39,0),(1,1),(89,0),(1,1),(37,0),(1,1),(21,0),(1,1),(65,0)]
+[(132,0),(1,1),(75,0),(1,1),(551,0),(1,1),(240,0)]
More information about the ghc-commits
mailing list