diff options
author | Kavon Farvardin <kavon@farvard.in> | 2018-09-23 15:29:37 -0500 |
---|---|---|
committer | Kavon Farvardin <kavon@farvard.in> | 2018-09-23 15:29:37 -0500 |
commit | 84c2ad99582391005b5e873198b15e9e9eb4f78d (patch) | |
tree | caa8c2f2ec7e97fbb4977263c6817c9af5025cf4 /testsuite/tests/numeric | |
parent | 8ddb47cfcf5776e9a3c55fd37947c8a95e00fa12 (diff) | |
parent | e68b439fe5de61b9a2ca51af472185c62ccb8b46 (diff) | |
download | haskell-wip/T13904.tar.gz |
update to current master againwip/T13904
Diffstat (limited to 'testsuite/tests/numeric')
21 files changed, 1691 insertions, 15 deletions
diff --git a/testsuite/tests/numeric/should_compile/Makefile b/testsuite/tests/numeric/should_compile/Makefile index 34dbe5a51f..522e703b50 100644 --- a/testsuite/tests/numeric/should_compile/Makefile +++ b/testsuite/tests/numeric/should_compile/Makefile @@ -5,3 +5,11 @@ include $(TOP)/mk/test.mk T7116: $(RM) -f T7116.o T7116.hi '$(TEST_HC)' $(TEST_HC_OPTS) -O2 -c -ddump-simpl -dsuppress-uniques T7116.hs + +T14170: + $(RM) -f T14170.o T14170.hi + '$(TEST_HC)' $(TEST_HC_OPTS) -O2 -c -ddump-simpl -dsuppress-uniques T14170.hs + +T14465: + $(RM) -f T14465.o T14465.hi + '$(TEST_HC)' $(TEST_HC_OPTS) -O2 -c -ddump-simpl -dsuppress-uniques T14465.hs diff --git a/testsuite/tests/numeric/should_compile/T14170.hs b/testsuite/tests/numeric/should_compile/T14170.hs new file mode 100644 index 0000000000..b7e854d805 --- /dev/null +++ b/testsuite/tests/numeric/should_compile/T14170.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeInType #-} + +module NatVal where + +import Data.Proxy +import GHC.TypeLits + +-- test that Nat type literals are statically converted into Integer literals + +foo :: Integer +foo = natVal $ Proxy @0 diff --git a/testsuite/tests/numeric/should_compile/T14170.stdout b/testsuite/tests/numeric/should_compile/T14170.stdout new file mode 100644 index 0000000000..46a86214a5 --- /dev/null +++ b/testsuite/tests/numeric/should_compile/T14170.stdout @@ -0,0 +1,59 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 16, types: 6, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +NatVal.$trModule4 :: GHC.Prim.Addr# +[GblId, + Caf=NoCafRefs, + Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] +NatVal.$trModule4 = "main"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +NatVal.$trModule3 :: GHC.Types.TrName +[GblId, + Caf=NoCafRefs, + Str=m1, + Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] +NatVal.$trModule3 = GHC.Types.TrNameS NatVal.$trModule4 + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +NatVal.$trModule2 :: GHC.Prim.Addr# +[GblId, + Caf=NoCafRefs, + Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] +NatVal.$trModule2 = "NatVal"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +NatVal.$trModule1 :: GHC.Types.TrName +[GblId, + Caf=NoCafRefs, + Str=m1, + Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] +NatVal.$trModule1 = GHC.Types.TrNameS NatVal.$trModule2 + +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} +NatVal.$trModule :: GHC.Types.Module +[GblId, + Caf=NoCafRefs, + Str=m, + Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] +NatVal.$trModule + = GHC.Types.Module NatVal.$trModule3 NatVal.$trModule1 + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +foo :: Integer +[GblId, + Caf=NoCafRefs, + Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 100 0}] +foo = 0 + + + diff --git a/testsuite/tests/numeric/should_compile/T14465.hs b/testsuite/tests/numeric/should_compile/T14465.hs new file mode 100644 index 0000000000..314aa89c56 --- /dev/null +++ b/testsuite/tests/numeric/should_compile/T14465.hs @@ -0,0 +1,26 @@ +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeInType #-} + +module M where + +import Numeric.Natural +import GHC.Natural + +-- test Natural literals +one :: Natural +one = fromInteger 1 + +plusOne :: Natural -> Natural +plusOne n = n + 1 + +-- a built-in rule should convert this unfolding into a Natural literal in Core +ten :: Natural +ten = wordToNatural 10 + +-- test basic constant folding for Natural +twoTimesTwo :: Natural +twoTimesTwo = 2 * 2 + +-- test the overflow warning +minusOne :: Natural +minusOne = -1 diff --git a/testsuite/tests/numeric/should_compile/T14465.stderr b/testsuite/tests/numeric/should_compile/T14465.stderr new file mode 100644 index 0000000000..c21e4a0269 --- /dev/null +++ b/testsuite/tests/numeric/should_compile/T14465.stderr @@ -0,0 +1,3 @@ + +T14465.hs:26:13: warning: [-Woverflowed-literals (in -Wdefault)] + Literal -1 is negative but Natural only supports positive numbers diff --git a/testsuite/tests/numeric/should_compile/T14465.stdout b/testsuite/tests/numeric/should_compile/T14465.stdout new file mode 100644 index 0000000000..e6dfa5fc6c --- /dev/null +++ b/testsuite/tests/numeric/should_compile/T14465.stdout @@ -0,0 +1,104 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 34, types: 14, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +ten :: Natural +[GblId, + Caf=NoCafRefs, + Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 100 0}] +ten = 10 + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +M.$trModule4 :: GHC.Prim.Addr# +[GblId, + Caf=NoCafRefs, + Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] +M.$trModule4 = "main"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +M.$trModule3 :: GHC.Types.TrName +[GblId, + Caf=NoCafRefs, + Str=m1, + Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] +M.$trModule3 = GHC.Types.TrNameS M.$trModule4 + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +M.$trModule2 :: GHC.Prim.Addr# +[GblId, + Caf=NoCafRefs, + Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] +M.$trModule2 = "M"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +M.$trModule1 :: GHC.Types.TrName +[GblId, + Caf=NoCafRefs, + Str=m1, + Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] +M.$trModule1 = GHC.Types.TrNameS M.$trModule2 + +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} +M.$trModule :: GHC.Types.Module +[GblId, + Caf=NoCafRefs, + Str=m, + Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] +M.$trModule = GHC.Types.Module M.$trModule3 M.$trModule1 + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +M.minusOne1 :: Natural +[GblId, + Caf=NoCafRefs, + Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 100 0}] +M.minusOne1 = 1 + +-- RHS size: {terms: 6, types: 1, coercions: 0, joins: 0/0} +minusOne :: Natural +[GblId, + Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False, + WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 40 20}] +minusOne + = case GHC.Natural.$wnegateNatural M.minusOne1 of ww { __DEFAULT -> + GHC.Natural.NatS# ww + } + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +twoTimesTwo :: Natural +[GblId, + Caf=NoCafRefs, + Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 100 0}] +twoTimesTwo = 4 + +-- RHS size: {terms: 4, types: 1, coercions: 0, joins: 0/0} +plusOne :: Natural -> Natural +[GblId, + Arity=1, + Caf=NoCafRefs, + Str=<S,U>, + Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) + Tmpl= \ (n [Occ=Once] :: Natural) -> plusNatural n M.minusOne1}] +plusOne = \ (n :: Natural) -> plusNatural n M.minusOne1 + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +one [InlPrag=NOUSERINLINE[2]] :: Natural +[GblId, + Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=True)}] +one = M.minusOne1 + + + diff --git a/testsuite/tests/numeric/should_compile/T7116.stdout b/testsuite/tests/numeric/should_compile/T7116.stdout index 681d171350..fc0159a1ec 100644 --- a/testsuite/tests/numeric/should_compile/T7116.stdout +++ b/testsuite/tests/numeric/should_compile/T7116.stdout @@ -65,7 +65,7 @@ dr case x of { GHC.Types.D# x1 -> GHC.Types.D# (GHC.Prim.+## x1 x1) } -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} -dl :: Double -> Double +dl [InlPrag=NOUSERINLINE[2]] :: Double -> Double [GblId, Arity=1, Caf=NoCafRefs, @@ -97,7 +97,7 @@ fr } -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} -fl :: Float -> Float +fl [InlPrag=NOUSERINLINE[2]] :: Float -> Float [GblId, Arity=1, Caf=NoCafRefs, diff --git a/testsuite/tests/numeric/should_compile/all.T b/testsuite/tests/numeric/should_compile/all.T index ea42aad5d8..5011627407 100644 --- a/testsuite/tests/numeric/should_compile/all.T +++ b/testsuite/tests/numeric/should_compile/all.T @@ -1,5 +1,10 @@ test('T7116', normal, run_command, ['$MAKE -s --no-print-directory T7116']) +test('T14170', normal, run_command, ['$MAKE -s --no-print-directory T14170']) +test('T14465', normal, run_command, ['$MAKE -s --no-print-directory T14465']) test('T7895', normal, compile, ['']) test('T7881', normal, compile, ['']) -test('T8542', normal, compile, ['']) +# For T8542, the hpc way adds extra annotations that prevent +# the appropriate expression to be detected, after +# desugaring, so we don't get the warning we expect. +test('T8542', omit_ways(['hpc']), compile, ['']) test('T10929', normal, compile, ['']) diff --git a/testsuite/tests/numeric/should_run/FloatFnInverses.hs b/testsuite/tests/numeric/should_run/FloatFnInverses.hs new file mode 100644 index 0000000000..13bf873407 --- /dev/null +++ b/testsuite/tests/numeric/should_run/FloatFnInverses.hs @@ -0,0 +1,56 @@ +{-# LANGUAGE TypeApplications #-} + +-- Check that the standard analytic functions are correctly +-- inverted by the corresponding inverse functions. + +main :: IO () +main = mapM_ print + [ -- @recip@ is self-inverse on @ℝ\\{0}@. + invDeviation @Double recip recip <$> [-1e20, -1e3, -1, -1e-40, 1e-40, 1e90] + , invDeviation @Float recip recip <$> [-1e10, -10, -1, -1e-20, 1e-20, 1e30] + , -- @exp@ is invertible on @ℝ <-> [0…∞[@, but grows very fast. + invDeviation @Double exp log <$> [-10, -5 .. 300] + , invDeviation @Float exp log <$> [-10 .. 60] + -- @sin@ is only invertible on @[-π/2…π/2] <-> [-1…1]@. + , invDeviation @Double sin asin <$> [-1.5, -1.4 .. 1.5] + , invDeviation @Float sin asin <$> [-1.5, -1.4 .. 1.5] + -- @cos@ is invertible on @[0…π] <-> [-1…1]@. + , invDeviation @Double cos acos <$> [0, 0.1 .. 3] + , invDeviation @Float cos acos <$> [0, 0.1 .. 3] + -- @tan@ is invertible on @]-π/4…π/4[ <-> ]-∞…∞[@. + , invDeviation @Double tan atan <$> [-0.7, -0.6 .. 0.7] + , invDeviation @Float tan atan <$> [-0.7, -0.6 .. 0.7] + -- @sinh@ is invertible on @ℝ <-> ℝ@, but grows very fast. + , invDeviation @Double sinh asinh <$> [-700, -672 .. 700] + , invDeviation @Float sinh asinh <$> [-80, -71 .. 80] + -- @cosh@ is invertible on @[0…∞[ <-> [1…∞[@, but grows fast + , invDeviation @Double cosh acosh <$> [0, 15 .. 700] + , invDeviation @Float cosh acosh <$> [0, 15 .. 80] + -- @tanh@ is invertible on @ℝ <-> ]-1…1[@. + , invDeviation @Double atanh tanh <$> [-0.99, -0.87 .. 0.9] + , invDeviation @Float atanh tanh <$> [-0.99, -0.87 .. 0.9] + ] + +invDeviation :: KnownNumDeviation a + => (a -> a) -- ^ Some numerical function @f@. + -> (a -> a) -- ^ Inverse @g = f⁻¹@ of that function. + -> a -- ^ Value @x@ which to compare with @g (f x)@. + -> Double -- ^ Relative discrepancy between original/expected + -- value and actual function result. +invDeviation f g 0 = rmNumericDeviation (g (f 0) + 1) - 1 +invDeviation f g x = rmNumericDeviation (g (f x) / x) - 1 + +-- | We need to round results to some sensible precision, +-- because floating-point arithmetic generally makes +-- it impossible to /exactly/ invert functions. +-- What precision this is depends on the type. The bounds +-- here are rather generous; the functions should usually +-- perform substantially better than that. +class (Floating a, Eq a) => KnownNumDeviation a where + rmNumericDeviation :: a -> Double + +instance KnownNumDeviation Double where + rmNumericDeviation x = fromIntegral (round $ x * 2^36) / 2^36 + +instance KnownNumDeviation Float where + rmNumericDeviation x = fromIntegral (round $ x * 2^16) / 2^16 diff --git a/testsuite/tests/numeric/should_run/FloatFnInverses.stdout b/testsuite/tests/numeric/should_run/FloatFnInverses.stdout new file mode 100644 index 0000000000..2d019b8434 --- /dev/null +++ b/testsuite/tests/numeric/should_run/FloatFnInverses.stdout @@ -0,0 +1,16 @@ +[0.0,0.0,0.0,0.0,0.0,0.0] +[0.0,0.0,0.0,0.0,0.0,0.0] +[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0] +[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0] +[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0] +[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0] +[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0] +[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0] +[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0] +[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0] +[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0] +[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0] +[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0] +[0.0,0.0,0.0,0.0,0.0,0.0] +[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0] +[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0] diff --git a/testsuite/tests/numeric/should_run/T10962.hs b/testsuite/tests/numeric/should_run/T10962.hs index 896c9e987f..435f3637d7 100644 --- a/testsuite/tests/numeric/should_run/T10962.hs +++ b/testsuite/tests/numeric/should_run/T10962.hs @@ -1,16 +1,32 @@ {-# LANGUAGE MagicHash #-} {-# LANGUAGE UnboxedTuples #-} -module Main where +module Main (main) where import GHC.Base +unW# :: Word -> Word# +unW# (W# w) = w + +type WordOpC = Word# -> Word# -> (# Word#, Int# #) + +check :: WordOpC -> Word# -> Word# -> IO () +check op a b = do + let (# w, c #) = op a b + print (W# w, I# c) + +checkSubInlNoInl :: WordOpC -> Word# -> Word# -> IO () +checkSubInlNoInl op a b = do + inline check op a b -- constant folding + noinline check op a b -- lowering of PrimOp +{-# INLINE checkSubInlNoInl #-} + main :: IO () main = do -- Overflow. - let (# w1, i1 #) = subWordC# 1## 3## - print (W# w1, I# i1) + checkSubInlNoInl subWordC# 1## 3## + checkSubInlNoInl addWordC# (unW# (inline maxBound)) 3## -- No overflow. - let (# w2, i2 #) = subWordC# 3## 1## - print (W# w2, I# i2) + checkSubInlNoInl subWordC# 5## 2## + checkSubInlNoInl addWordC# (unW# (inline maxBound-1)) 1## diff --git a/testsuite/tests/numeric/should_run/T10962.stdout-ws-32 b/testsuite/tests/numeric/should_run/T10962.stdout-ws-32 index a1dec8410a..605265305d 100644 --- a/testsuite/tests/numeric/should_run/T10962.stdout-ws-32 +++ b/testsuite/tests/numeric/should_run/T10962.stdout-ws-32 @@ -1,2 +1,8 @@ (4294967294,1) -(2,0) +(4294967294,1) +(2,1) +(2,1) +(3,0) +(3,0) +(4294967295,0) +(4294967295,0) diff --git a/testsuite/tests/numeric/should_run/T10962.stdout-ws-64 b/testsuite/tests/numeric/should_run/T10962.stdout-ws-64 index 853bf94a61..d36f660eb1 100644 --- a/testsuite/tests/numeric/should_run/T10962.stdout-ws-64 +++ b/testsuite/tests/numeric/should_run/T10962.stdout-ws-64 @@ -1,2 +1,8 @@ (18446744073709551614,1) -(2,0) +(18446744073709551614,1) +(2,1) +(2,1) +(3,0) +(3,0) +(18446744073709551615,0) +(18446744073709551615,0) diff --git a/testsuite/tests/numeric/should_run/T15301.hs b/testsuite/tests/numeric/should_run/T15301.hs new file mode 100644 index 0000000000..6efbce4334 --- /dev/null +++ b/testsuite/tests/numeric/should_run/T15301.hs @@ -0,0 +1,7 @@ +import Numeric +import GHC.Natural + +main = do + -- test that GHC correctly compiles big Natural literals + let x = 0xffffffffffffffffffffffff :: Natural + print (showHex x "" == "ffffffffffffffffffffffff") diff --git a/testsuite/tests/numeric/should_run/T15301.stdout b/testsuite/tests/numeric/should_run/T15301.stdout new file mode 100644 index 0000000000..0ca95142bb --- /dev/null +++ b/testsuite/tests/numeric/should_run/T15301.stdout @@ -0,0 +1 @@ +True diff --git a/testsuite/tests/numeric/should_run/all.T b/testsuite/tests/numeric/should_run/all.T index 2d2353bd8a..140fa6c50b 100644 --- a/testsuite/tests/numeric/should_run/all.T +++ b/testsuite/tests/numeric/should_run/all.T @@ -34,12 +34,15 @@ test('numrun012', normal, compile_and_run, ['']) test('numrun013', normal, compile_and_run, ['']) test('numrun014', normal, compile_and_run, ['']) test('numrun015', normal, compile_and_run, ['']) +test('numrun016', normal, compile_and_run, ['']) test('arith016', normal, compile_and_run, ['']) test('arith017', normal, compile_and_run, ['']) test('arith018', normal, compile_and_run, ['']) test('arith019', normal, compile_and_run, ['']) test('expfloat', normal, compile_and_run, ['']) +test('FloatFnInverses', normal, compile_and_run, ['']) + test('T1603', skip, compile_and_run, ['']) test('T3676', expect_broken(3676), compile_and_run, ['']) test('T4381', normal, compile_and_run, ['']) @@ -59,6 +62,7 @@ test('CarryOverflow', omit_ways(['ghci']), compile_and_run, ['']) test('T9407', normal, compile_and_run, ['']) test('T9810', normal, compile_and_run, ['']) test('T10011', normal, compile_and_run, ['']) -test('T10962', omit_ways(['ghci']), compile_and_run, ['']) +test('T10962', omit_ways(['ghci']), compile_and_run, ['-O2']) test('T11702', extra_ways(['optasm']), compile_and_run, ['']) test('T12136', normal, compile_and_run, ['']) +test('T15301', normal, compile_and_run, ['-O2']) diff --git a/testsuite/tests/numeric/should_run/arith011.hs b/testsuite/tests/numeric/should_run/arith011.hs index 4e23a8d99d..e00caad19a 100644 --- a/testsuite/tests/numeric/should_run/arith011.hs +++ b/testsuite/tests/numeric/should_run/arith011.hs @@ -5,6 +5,8 @@ import Data.Word import Data.Bits import Data.Ix -- added SOF import Control.Exception +import Control.Monad +import Numeric.Natural main :: IO () main = test @@ -21,6 +23,7 @@ test = do testIntlike "Word32" (0::Word32) testIntlike "Word64" (0::Word64) testInteger + testNatural testIntlike :: (Bounded a, Integral a, Ix a, Show a, Read a, Bits a) => String -> a -> IO () testIntlike name zero = do @@ -52,6 +55,20 @@ testInteger = do testIntegral zero testBits zero False +testNatural = do + let zero = 0 :: Natural + putStrLn $ "--------------------------------" + putStrLn $ "--Testing Natural" + putStrLn $ "--------------------------------" + testEnum zero + testReadShow zero + testEq zero + testOrd zero + testNum zero + testReal zero + testIntegral zero + testBits zero False + -- In all these tests, zero is a dummy element used to get -- the overloading to work @@ -81,8 +98,13 @@ testConversions zero = do putStr "Word64 : " >> print (map fromIntegral numbers :: [Word64]) where numbers = [minBound, 0, maxBound] `asTypeOf` [zero] -samples :: (Num a) => a -> [a] -samples zero = map fromInteger ([-3 .. -1]++[0 .. 3]) +isNatural :: (Bits n) => n -> Bool +isNatural zero = not (isSigned zero) && bitSizeMaybe zero == Nothing + +samples :: (Bits a, Num a) => a -> [a] +samples zero + | isNatural zero = map fromInteger [0 .. 3] + | otherwise = map fromInteger ([-3 .. -1]++[0 .. 3]) table1 :: (Show a, Show b) => String -> (a -> b) -> [a] -> IO () table1 nm f xs = do @@ -133,7 +155,9 @@ testNum zero = do table2 "+" (+) xs xs table2 "-" (-) xs xs table2 "*" (*) xs xs - table1 "negate" negate xs + if (isNatural zero) + then table1 "negate" negate [0 `asTypeOf` zero] + else table1 "negate" negate xs where xs = samples zero @@ -159,7 +183,8 @@ testBits zero do_bitsize = do table2 ".&. " (.&.) xs xs table2 ".|. " (.|.) xs xs table2 "`xor`" xor xs xs - table1 "complement" complement xs + unless (isNatural zero) $ + table1 "complement" complement xs table2 "`shiftL`" shiftL xs ([0..3] ++ [32,64]) table2 "`shiftR`" shiftR xs ([0..3] ++ [32,64]) table2 "`rotate`" rotate xs ([-3..3] ++ [-64,-32,32,64]) diff --git a/testsuite/tests/numeric/should_run/arith011.stdout b/testsuite/tests/numeric/should_run/arith011.stdout index 7404c4b353..8a74164f19 100644 --- a/testsuite/tests/numeric/should_run/arith011.stdout +++ b/testsuite/tests/numeric/should_run/arith011.stdout @@ -15416,3 +15416,659 @@ isSigned 1 = True isSigned 2 = True isSigned 3 = True # +-------------------------------- +--Testing Natural +-------------------------------- +testEnum +[0,1,2,3,4,5,6,7,8,9] +[0,2,4,6,8,10,12,14,16,18] +[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20] +[0,2,4,6,8,10,12,14,16,18,20] +testReadShow +[0,1,2,3] +[0,1,2,3] +testEq +0 == 0 = True +0 == 1 = False +0 == 2 = False +0 == 3 = False + +1 == 0 = False +1 == 1 = True +1 == 2 = False +1 == 3 = False + +2 == 0 = False +2 == 1 = False +2 == 2 = True +2 == 3 = False + +3 == 0 = False +3 == 1 = False +3 == 2 = False +3 == 3 = True + +# +0 /= 0 = False +0 /= 1 = True +0 /= 2 = True +0 /= 3 = True + +1 /= 0 = True +1 /= 1 = False +1 /= 2 = True +1 /= 3 = True + +2 /= 0 = True +2 /= 1 = True +2 /= 2 = False +2 /= 3 = True + +3 /= 0 = True +3 /= 1 = True +3 /= 2 = True +3 /= 3 = False + +# +testOrd +0 <= 0 = True +0 <= 1 = True +0 <= 2 = True +0 <= 3 = True + +1 <= 0 = False +1 <= 1 = True +1 <= 2 = True +1 <= 3 = True + +2 <= 0 = False +2 <= 1 = False +2 <= 2 = True +2 <= 3 = True + +3 <= 0 = False +3 <= 1 = False +3 <= 2 = False +3 <= 3 = True + +# +0 < 0 = False +0 < 1 = True +0 < 2 = True +0 < 3 = True + +1 < 0 = False +1 < 1 = False +1 < 2 = True +1 < 3 = True + +2 < 0 = False +2 < 1 = False +2 < 2 = False +2 < 3 = True + +3 < 0 = False +3 < 1 = False +3 < 2 = False +3 < 3 = False + +# +0 > 0 = False +0 > 1 = False +0 > 2 = False +0 > 3 = False + +1 > 0 = True +1 > 1 = False +1 > 2 = False +1 > 3 = False + +2 > 0 = True +2 > 1 = True +2 > 2 = False +2 > 3 = False + +3 > 0 = True +3 > 1 = True +3 > 2 = True +3 > 3 = False + +# +0 >= 0 = True +0 >= 1 = False +0 >= 2 = False +0 >= 3 = False + +1 >= 0 = True +1 >= 1 = True +1 >= 2 = False +1 >= 3 = False + +2 >= 0 = True +2 >= 1 = True +2 >= 2 = True +2 >= 3 = False + +3 >= 0 = True +3 >= 1 = True +3 >= 2 = True +3 >= 3 = True + +# +0 `compare` 0 = EQ +0 `compare` 1 = LT +0 `compare` 2 = LT +0 `compare` 3 = LT + +1 `compare` 0 = GT +1 `compare` 1 = EQ +1 `compare` 2 = LT +1 `compare` 3 = LT + +2 `compare` 0 = GT +2 `compare` 1 = GT +2 `compare` 2 = EQ +2 `compare` 3 = LT + +3 `compare` 0 = GT +3 `compare` 1 = GT +3 `compare` 2 = GT +3 `compare` 3 = EQ + +# +testNum +0 + 0 = 0 +0 + 1 = 1 +0 + 2 = 2 +0 + 3 = 3 + +1 + 0 = 1 +1 + 1 = 2 +1 + 2 = 3 +1 + 3 = 4 + +2 + 0 = 2 +2 + 1 = 3 +2 + 2 = 4 +2 + 3 = 5 + +3 + 0 = 3 +3 + 1 = 4 +3 + 2 = 5 +3 + 3 = 6 + +# +0 - 0 = 0 +0 - 1 = arithmetic underflow +0 - 2 = arithmetic underflow +0 - 3 = arithmetic underflow + +1 - 0 = 1 +1 - 1 = 0 +1 - 2 = arithmetic underflow +1 - 3 = arithmetic underflow + +2 - 0 = 2 +2 - 1 = 1 +2 - 2 = 0 +2 - 3 = arithmetic underflow + +3 - 0 = 3 +3 - 1 = 2 +3 - 2 = 1 +3 - 3 = 0 + +# +0 * 0 = 0 +0 * 1 = 0 +0 * 2 = 0 +0 * 3 = 0 + +1 * 0 = 0 +1 * 1 = 1 +1 * 2 = 2 +1 * 3 = 3 + +2 * 0 = 0 +2 * 1 = 2 +2 * 2 = 4 +2 * 3 = 6 + +3 * 0 = 0 +3 * 1 = 3 +3 * 2 = 6 +3 * 3 = 9 + +# +negate 0 = 0 +# +testReal +toRational 0 = 0 % 1 +toRational 1 = 1 % 1 +toRational 2 = 2 % 1 +toRational 3 = 3 % 1 +# +testIntegral +0 `divMod` 0 = divide by zero +0 `divMod` 1 = (0,0) +0 `divMod` 2 = (0,0) +0 `divMod` 3 = (0,0) + +1 `divMod` 0 = divide by zero +1 `divMod` 1 = (1,0) +1 `divMod` 2 = (0,1) +1 `divMod` 3 = (0,1) + +2 `divMod` 0 = divide by zero +2 `divMod` 1 = (2,0) +2 `divMod` 2 = (1,0) +2 `divMod` 3 = (0,2) + +3 `divMod` 0 = divide by zero +3 `divMod` 1 = (3,0) +3 `divMod` 2 = (1,1) +3 `divMod` 3 = (1,0) + +# +0 `div` 0 = divide by zero +0 `div` 1 = 0 +0 `div` 2 = 0 +0 `div` 3 = 0 + +1 `div` 0 = divide by zero +1 `div` 1 = 1 +1 `div` 2 = 0 +1 `div` 3 = 0 + +2 `div` 0 = divide by zero +2 `div` 1 = 2 +2 `div` 2 = 1 +2 `div` 3 = 0 + +3 `div` 0 = divide by zero +3 `div` 1 = 3 +3 `div` 2 = 1 +3 `div` 3 = 1 + +# +0 `mod` 0 = divide by zero +0 `mod` 1 = 0 +0 `mod` 2 = 0 +0 `mod` 3 = 0 + +1 `mod` 0 = divide by zero +1 `mod` 1 = 0 +1 `mod` 2 = 1 +1 `mod` 3 = 1 + +2 `mod` 0 = divide by zero +2 `mod` 1 = 0 +2 `mod` 2 = 0 +2 `mod` 3 = 2 + +3 `mod` 0 = divide by zero +3 `mod` 1 = 0 +3 `mod` 2 = 1 +3 `mod` 3 = 0 + +# +0 `quotRem` 0 = divide by zero +0 `quotRem` 1 = (0,0) +0 `quotRem` 2 = (0,0) +0 `quotRem` 3 = (0,0) + +1 `quotRem` 0 = divide by zero +1 `quotRem` 1 = (1,0) +1 `quotRem` 2 = (0,1) +1 `quotRem` 3 = (0,1) + +2 `quotRem` 0 = divide by zero +2 `quotRem` 1 = (2,0) +2 `quotRem` 2 = (1,0) +2 `quotRem` 3 = (0,2) + +3 `quotRem` 0 = divide by zero +3 `quotRem` 1 = (3,0) +3 `quotRem` 2 = (1,1) +3 `quotRem` 3 = (1,0) + +# +0 `quot` 0 = divide by zero +0 `quot` 1 = 0 +0 `quot` 2 = 0 +0 `quot` 3 = 0 + +1 `quot` 0 = divide by zero +1 `quot` 1 = 1 +1 `quot` 2 = 0 +1 `quot` 3 = 0 + +2 `quot` 0 = divide by zero +2 `quot` 1 = 2 +2 `quot` 2 = 1 +2 `quot` 3 = 0 + +3 `quot` 0 = divide by zero +3 `quot` 1 = 3 +3 `quot` 2 = 1 +3 `quot` 3 = 1 + +# +0 `rem` 0 = divide by zero +0 `rem` 1 = 0 +0 `rem` 2 = 0 +0 `rem` 3 = 0 + +1 `rem` 0 = divide by zero +1 `rem` 1 = 0 +1 `rem` 2 = 1 +1 `rem` 3 = 1 + +2 `rem` 0 = divide by zero +2 `rem` 1 = 0 +2 `rem` 2 = 0 +2 `rem` 3 = 2 + +3 `rem` 0 = divide by zero +3 `rem` 1 = 0 +3 `rem` 2 = 1 +3 `rem` 3 = 0 + +# +testBits +0 .&. 0 = 0 +0 .&. 1 = 0 +0 .&. 2 = 0 +0 .&. 3 = 0 + +1 .&. 0 = 0 +1 .&. 1 = 1 +1 .&. 2 = 0 +1 .&. 3 = 1 + +2 .&. 0 = 0 +2 .&. 1 = 0 +2 .&. 2 = 2 +2 .&. 3 = 2 + +3 .&. 0 = 0 +3 .&. 1 = 1 +3 .&. 2 = 2 +3 .&. 3 = 3 + +# +0 .|. 0 = 0 +0 .|. 1 = 1 +0 .|. 2 = 2 +0 .|. 3 = 3 + +1 .|. 0 = 1 +1 .|. 1 = 1 +1 .|. 2 = 3 +1 .|. 3 = 3 + +2 .|. 0 = 2 +2 .|. 1 = 3 +2 .|. 2 = 2 +2 .|. 3 = 3 + +3 .|. 0 = 3 +3 .|. 1 = 3 +3 .|. 2 = 3 +3 .|. 3 = 3 + +# +0 `xor` 0 = 0 +0 `xor` 1 = 1 +0 `xor` 2 = 2 +0 `xor` 3 = 3 + +1 `xor` 0 = 1 +1 `xor` 1 = 0 +1 `xor` 2 = 3 +1 `xor` 3 = 2 + +2 `xor` 0 = 2 +2 `xor` 1 = 3 +2 `xor` 2 = 0 +2 `xor` 3 = 1 + +3 `xor` 0 = 3 +3 `xor` 1 = 2 +3 `xor` 2 = 1 +3 `xor` 3 = 0 + +# +0 `shiftL` 0 = 0 +0 `shiftL` 1 = 0 +0 `shiftL` 2 = 0 +0 `shiftL` 3 = 0 +0 `shiftL` 32 = 0 +0 `shiftL` 64 = 0 + +1 `shiftL` 0 = 1 +1 `shiftL` 1 = 2 +1 `shiftL` 2 = 4 +1 `shiftL` 3 = 8 +1 `shiftL` 32 = 4294967296 +1 `shiftL` 64 = 18446744073709551616 + +2 `shiftL` 0 = 2 +2 `shiftL` 1 = 4 +2 `shiftL` 2 = 8 +2 `shiftL` 3 = 16 +2 `shiftL` 32 = 8589934592 +2 `shiftL` 64 = 36893488147419103232 + +3 `shiftL` 0 = 3 +3 `shiftL` 1 = 6 +3 `shiftL` 2 = 12 +3 `shiftL` 3 = 24 +3 `shiftL` 32 = 12884901888 +3 `shiftL` 64 = 55340232221128654848 + +# +0 `shiftR` 0 = 0 +0 `shiftR` 1 = 0 +0 `shiftR` 2 = 0 +0 `shiftR` 3 = 0 +0 `shiftR` 32 = 0 +0 `shiftR` 64 = 0 + +1 `shiftR` 0 = 1 +1 `shiftR` 1 = 0 +1 `shiftR` 2 = 0 +1 `shiftR` 3 = 0 +1 `shiftR` 32 = 0 +1 `shiftR` 64 = 0 + +2 `shiftR` 0 = 2 +2 `shiftR` 1 = 1 +2 `shiftR` 2 = 0 +2 `shiftR` 3 = 0 +2 `shiftR` 32 = 0 +2 `shiftR` 64 = 0 + +3 `shiftR` 0 = 3 +3 `shiftR` 1 = 1 +3 `shiftR` 2 = 0 +3 `shiftR` 3 = 0 +3 `shiftR` 32 = 0 +3 `shiftR` 64 = 0 + +# +0 `rotate` -3 = 0 +0 `rotate` -2 = 0 +0 `rotate` -1 = 0 +0 `rotate` 0 = 0 +0 `rotate` 1 = 0 +0 `rotate` 2 = 0 +0 `rotate` 3 = 0 +0 `rotate` -64 = 0 +0 `rotate` -32 = 0 +0 `rotate` 32 = 0 +0 `rotate` 64 = 0 + +1 `rotate` -3 = 0 +1 `rotate` -2 = 0 +1 `rotate` -1 = 0 +1 `rotate` 0 = 1 +1 `rotate` 1 = 2 +1 `rotate` 2 = 4 +1 `rotate` 3 = 8 +1 `rotate` -64 = 0 +1 `rotate` -32 = 0 +1 `rotate` 32 = 4294967296 +1 `rotate` 64 = 18446744073709551616 + +2 `rotate` -3 = 0 +2 `rotate` -2 = 0 +2 `rotate` -1 = 1 +2 `rotate` 0 = 2 +2 `rotate` 1 = 4 +2 `rotate` 2 = 8 +2 `rotate` 3 = 16 +2 `rotate` -64 = 0 +2 `rotate` -32 = 0 +2 `rotate` 32 = 8589934592 +2 `rotate` 64 = 36893488147419103232 + +3 `rotate` -3 = 0 +3 `rotate` -2 = 0 +3 `rotate` -1 = 1 +3 `rotate` 0 = 3 +3 `rotate` 1 = 6 +3 `rotate` 2 = 12 +3 `rotate` 3 = 24 +3 `rotate` -64 = 0 +3 `rotate` -32 = 0 +3 `rotate` 32 = 12884901888 +3 `rotate` 64 = 55340232221128654848 + +# +bit 0 = 1 +bit 1 = 2 +bit 2 = 4 +bit 3 = 8 +# +0 `setBit` 0 = 1 +0 `setBit` 1 = 2 +0 `setBit` 2 = 4 +0 `setBit` 3 = 8 +0 `setBit` 32 = 4294967296 +0 `setBit` 64 = 18446744073709551616 + +1 `setBit` 0 = 1 +1 `setBit` 1 = 3 +1 `setBit` 2 = 5 +1 `setBit` 3 = 9 +1 `setBit` 32 = 4294967297 +1 `setBit` 64 = 18446744073709551617 + +2 `setBit` 0 = 3 +2 `setBit` 1 = 2 +2 `setBit` 2 = 6 +2 `setBit` 3 = 10 +2 `setBit` 32 = 4294967298 +2 `setBit` 64 = 18446744073709551618 + +3 `setBit` 0 = 3 +3 `setBit` 1 = 3 +3 `setBit` 2 = 7 +3 `setBit` 3 = 11 +3 `setBit` 32 = 4294967299 +3 `setBit` 64 = 18446744073709551619 + +# +0 `clearBit` 0 = 0 +0 `clearBit` 1 = 0 +0 `clearBit` 2 = 0 +0 `clearBit` 3 = 0 +0 `clearBit` 32 = 0 +0 `clearBit` 64 = 0 + +1 `clearBit` 0 = 0 +1 `clearBit` 1 = 1 +1 `clearBit` 2 = 1 +1 `clearBit` 3 = 1 +1 `clearBit` 32 = 1 +1 `clearBit` 64 = 1 + +2 `clearBit` 0 = 2 +2 `clearBit` 1 = 0 +2 `clearBit` 2 = 2 +2 `clearBit` 3 = 2 +2 `clearBit` 32 = 2 +2 `clearBit` 64 = 2 + +3 `clearBit` 0 = 2 +3 `clearBit` 1 = 1 +3 `clearBit` 2 = 3 +3 `clearBit` 3 = 3 +3 `clearBit` 32 = 3 +3 `clearBit` 64 = 3 + +# +0 `complementBit` 0 = 1 +0 `complementBit` 1 = 2 +0 `complementBit` 2 = 4 +0 `complementBit` 3 = 8 +0 `complementBit` 32 = 4294967296 +0 `complementBit` 64 = 18446744073709551616 + +1 `complementBit` 0 = 0 +1 `complementBit` 1 = 3 +1 `complementBit` 2 = 5 +1 `complementBit` 3 = 9 +1 `complementBit` 32 = 4294967297 +1 `complementBit` 64 = 18446744073709551617 + +2 `complementBit` 0 = 3 +2 `complementBit` 1 = 0 +2 `complementBit` 2 = 6 +2 `complementBit` 3 = 10 +2 `complementBit` 32 = 4294967298 +2 `complementBit` 64 = 18446744073709551618 + +3 `complementBit` 0 = 2 +3 `complementBit` 1 = 1 +3 `complementBit` 2 = 7 +3 `complementBit` 3 = 11 +3 `complementBit` 32 = 4294967299 +3 `complementBit` 64 = 18446744073709551619 + +# +0 `testBit` 0 = False +0 `testBit` 1 = False +0 `testBit` 2 = False +0 `testBit` 3 = False +0 `testBit` 32 = False +0 `testBit` 64 = False + +1 `testBit` 0 = True +1 `testBit` 1 = False +1 `testBit` 2 = False +1 `testBit` 3 = False +1 `testBit` 32 = False +1 `testBit` 64 = False + +2 `testBit` 0 = False +2 `testBit` 1 = True +2 `testBit` 2 = False +2 `testBit` 3 = False +2 `testBit` 32 = False +2 `testBit` 64 = False + +3 `testBit` 0 = True +3 `testBit` 1 = True +3 `testBit` 2 = False +3 `testBit` 3 = False +3 `testBit` 32 = False +3 `testBit` 64 = False + +# +isSigned 0 = False +isSigned 1 = False +isSigned 2 = False +isSigned 3 = False +# diff --git a/testsuite/tests/numeric/should_run/arith011.stdout-ws-64 b/testsuite/tests/numeric/should_run/arith011.stdout-ws-64 index ff064a071d..cd2e23bd63 100644 --- a/testsuite/tests/numeric/should_run/arith011.stdout-ws-64 +++ b/testsuite/tests/numeric/should_run/arith011.stdout-ws-64 @@ -15416,3 +15416,659 @@ isSigned 1 = True isSigned 2 = True isSigned 3 = True # +-------------------------------- +--Testing Natural +-------------------------------- +testEnum +[0,1,2,3,4,5,6,7,8,9] +[0,2,4,6,8,10,12,14,16,18] +[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20] +[0,2,4,6,8,10,12,14,16,18,20] +testReadShow +[0,1,2,3] +[0,1,2,3] +testEq +0 == 0 = True +0 == 1 = False +0 == 2 = False +0 == 3 = False + +1 == 0 = False +1 == 1 = True +1 == 2 = False +1 == 3 = False + +2 == 0 = False +2 == 1 = False +2 == 2 = True +2 == 3 = False + +3 == 0 = False +3 == 1 = False +3 == 2 = False +3 == 3 = True + +# +0 /= 0 = False +0 /= 1 = True +0 /= 2 = True +0 /= 3 = True + +1 /= 0 = True +1 /= 1 = False +1 /= 2 = True +1 /= 3 = True + +2 /= 0 = True +2 /= 1 = True +2 /= 2 = False +2 /= 3 = True + +3 /= 0 = True +3 /= 1 = True +3 /= 2 = True +3 /= 3 = False + +# +testOrd +0 <= 0 = True +0 <= 1 = True +0 <= 2 = True +0 <= 3 = True + +1 <= 0 = False +1 <= 1 = True +1 <= 2 = True +1 <= 3 = True + +2 <= 0 = False +2 <= 1 = False +2 <= 2 = True +2 <= 3 = True + +3 <= 0 = False +3 <= 1 = False +3 <= 2 = False +3 <= 3 = True + +# +0 < 0 = False +0 < 1 = True +0 < 2 = True +0 < 3 = True + +1 < 0 = False +1 < 1 = False +1 < 2 = True +1 < 3 = True + +2 < 0 = False +2 < 1 = False +2 < 2 = False +2 < 3 = True + +3 < 0 = False +3 < 1 = False +3 < 2 = False +3 < 3 = False + +# +0 > 0 = False +0 > 1 = False +0 > 2 = False +0 > 3 = False + +1 > 0 = True +1 > 1 = False +1 > 2 = False +1 > 3 = False + +2 > 0 = True +2 > 1 = True +2 > 2 = False +2 > 3 = False + +3 > 0 = True +3 > 1 = True +3 > 2 = True +3 > 3 = False + +# +0 >= 0 = True +0 >= 1 = False +0 >= 2 = False +0 >= 3 = False + +1 >= 0 = True +1 >= 1 = True +1 >= 2 = False +1 >= 3 = False + +2 >= 0 = True +2 >= 1 = True +2 >= 2 = True +2 >= 3 = False + +3 >= 0 = True +3 >= 1 = True +3 >= 2 = True +3 >= 3 = True + +# +0 `compare` 0 = EQ +0 `compare` 1 = LT +0 `compare` 2 = LT +0 `compare` 3 = LT + +1 `compare` 0 = GT +1 `compare` 1 = EQ +1 `compare` 2 = LT +1 `compare` 3 = LT + +2 `compare` 0 = GT +2 `compare` 1 = GT +2 `compare` 2 = EQ +2 `compare` 3 = LT + +3 `compare` 0 = GT +3 `compare` 1 = GT +3 `compare` 2 = GT +3 `compare` 3 = EQ + +# +testNum +0 + 0 = 0 +0 + 1 = 1 +0 + 2 = 2 +0 + 3 = 3 + +1 + 0 = 1 +1 + 1 = 2 +1 + 2 = 3 +1 + 3 = 4 + +2 + 0 = 2 +2 + 1 = 3 +2 + 2 = 4 +2 + 3 = 5 + +3 + 0 = 3 +3 + 1 = 4 +3 + 2 = 5 +3 + 3 = 6 + +# +0 - 0 = 0 +0 - 1 = arithmetic underflow +0 - 2 = arithmetic underflow +0 - 3 = arithmetic underflow + +1 - 0 = 1 +1 - 1 = 0 +1 - 2 = arithmetic underflow +1 - 3 = arithmetic underflow + +2 - 0 = 2 +2 - 1 = 1 +2 - 2 = 0 +2 - 3 = arithmetic underflow + +3 - 0 = 3 +3 - 1 = 2 +3 - 2 = 1 +3 - 3 = 0 + +# +0 * 0 = 0 +0 * 1 = 0 +0 * 2 = 0 +0 * 3 = 0 + +1 * 0 = 0 +1 * 1 = 1 +1 * 2 = 2 +1 * 3 = 3 + +2 * 0 = 0 +2 * 1 = 2 +2 * 2 = 4 +2 * 3 = 6 + +3 * 0 = 0 +3 * 1 = 3 +3 * 2 = 6 +3 * 3 = 9 + +# +negate 0 = 0 +# +testReal +toRational 0 = 0 % 1 +toRational 1 = 1 % 1 +toRational 2 = 2 % 1 +toRational 3 = 3 % 1 +# +testIntegral +0 `divMod` 0 = divide by zero +0 `divMod` 1 = (0,0) +0 `divMod` 2 = (0,0) +0 `divMod` 3 = (0,0) + +1 `divMod` 0 = divide by zero +1 `divMod` 1 = (1,0) +1 `divMod` 2 = (0,1) +1 `divMod` 3 = (0,1) + +2 `divMod` 0 = divide by zero +2 `divMod` 1 = (2,0) +2 `divMod` 2 = (1,0) +2 `divMod` 3 = (0,2) + +3 `divMod` 0 = divide by zero +3 `divMod` 1 = (3,0) +3 `divMod` 2 = (1,1) +3 `divMod` 3 = (1,0) + +# +0 `div` 0 = divide by zero +0 `div` 1 = 0 +0 `div` 2 = 0 +0 `div` 3 = 0 + +1 `div` 0 = divide by zero +1 `div` 1 = 1 +1 `div` 2 = 0 +1 `div` 3 = 0 + +2 `div` 0 = divide by zero +2 `div` 1 = 2 +2 `div` 2 = 1 +2 `div` 3 = 0 + +3 `div` 0 = divide by zero +3 `div` 1 = 3 +3 `div` 2 = 1 +3 `div` 3 = 1 + +# +0 `mod` 0 = divide by zero +0 `mod` 1 = 0 +0 `mod` 2 = 0 +0 `mod` 3 = 0 + +1 `mod` 0 = divide by zero +1 `mod` 1 = 0 +1 `mod` 2 = 1 +1 `mod` 3 = 1 + +2 `mod` 0 = divide by zero +2 `mod` 1 = 0 +2 `mod` 2 = 0 +2 `mod` 3 = 2 + +3 `mod` 0 = divide by zero +3 `mod` 1 = 0 +3 `mod` 2 = 1 +3 `mod` 3 = 0 + +# +0 `quotRem` 0 = divide by zero +0 `quotRem` 1 = (0,0) +0 `quotRem` 2 = (0,0) +0 `quotRem` 3 = (0,0) + +1 `quotRem` 0 = divide by zero +1 `quotRem` 1 = (1,0) +1 `quotRem` 2 = (0,1) +1 `quotRem` 3 = (0,1) + +2 `quotRem` 0 = divide by zero +2 `quotRem` 1 = (2,0) +2 `quotRem` 2 = (1,0) +2 `quotRem` 3 = (0,2) + +3 `quotRem` 0 = divide by zero +3 `quotRem` 1 = (3,0) +3 `quotRem` 2 = (1,1) +3 `quotRem` 3 = (1,0) + +# +0 `quot` 0 = divide by zero +0 `quot` 1 = 0 +0 `quot` 2 = 0 +0 `quot` 3 = 0 + +1 `quot` 0 = divide by zero +1 `quot` 1 = 1 +1 `quot` 2 = 0 +1 `quot` 3 = 0 + +2 `quot` 0 = divide by zero +2 `quot` 1 = 2 +2 `quot` 2 = 1 +2 `quot` 3 = 0 + +3 `quot` 0 = divide by zero +3 `quot` 1 = 3 +3 `quot` 2 = 1 +3 `quot` 3 = 1 + +# +0 `rem` 0 = divide by zero +0 `rem` 1 = 0 +0 `rem` 2 = 0 +0 `rem` 3 = 0 + +1 `rem` 0 = divide by zero +1 `rem` 1 = 0 +1 `rem` 2 = 1 +1 `rem` 3 = 1 + +2 `rem` 0 = divide by zero +2 `rem` 1 = 0 +2 `rem` 2 = 0 +2 `rem` 3 = 2 + +3 `rem` 0 = divide by zero +3 `rem` 1 = 0 +3 `rem` 2 = 1 +3 `rem` 3 = 0 + +# +testBits +0 .&. 0 = 0 +0 .&. 1 = 0 +0 .&. 2 = 0 +0 .&. 3 = 0 + +1 .&. 0 = 0 +1 .&. 1 = 1 +1 .&. 2 = 0 +1 .&. 3 = 1 + +2 .&. 0 = 0 +2 .&. 1 = 0 +2 .&. 2 = 2 +2 .&. 3 = 2 + +3 .&. 0 = 0 +3 .&. 1 = 1 +3 .&. 2 = 2 +3 .&. 3 = 3 + +# +0 .|. 0 = 0 +0 .|. 1 = 1 +0 .|. 2 = 2 +0 .|. 3 = 3 + +1 .|. 0 = 1 +1 .|. 1 = 1 +1 .|. 2 = 3 +1 .|. 3 = 3 + +2 .|. 0 = 2 +2 .|. 1 = 3 +2 .|. 2 = 2 +2 .|. 3 = 3 + +3 .|. 0 = 3 +3 .|. 1 = 3 +3 .|. 2 = 3 +3 .|. 3 = 3 + +# +0 `xor` 0 = 0 +0 `xor` 1 = 1 +0 `xor` 2 = 2 +0 `xor` 3 = 3 + +1 `xor` 0 = 1 +1 `xor` 1 = 0 +1 `xor` 2 = 3 +1 `xor` 3 = 2 + +2 `xor` 0 = 2 +2 `xor` 1 = 3 +2 `xor` 2 = 0 +2 `xor` 3 = 1 + +3 `xor` 0 = 3 +3 `xor` 1 = 2 +3 `xor` 2 = 1 +3 `xor` 3 = 0 + +# +0 `shiftL` 0 = 0 +0 `shiftL` 1 = 0 +0 `shiftL` 2 = 0 +0 `shiftL` 3 = 0 +0 `shiftL` 32 = 0 +0 `shiftL` 64 = 0 + +1 `shiftL` 0 = 1 +1 `shiftL` 1 = 2 +1 `shiftL` 2 = 4 +1 `shiftL` 3 = 8 +1 `shiftL` 32 = 4294967296 +1 `shiftL` 64 = 18446744073709551616 + +2 `shiftL` 0 = 2 +2 `shiftL` 1 = 4 +2 `shiftL` 2 = 8 +2 `shiftL` 3 = 16 +2 `shiftL` 32 = 8589934592 +2 `shiftL` 64 = 36893488147419103232 + +3 `shiftL` 0 = 3 +3 `shiftL` 1 = 6 +3 `shiftL` 2 = 12 +3 `shiftL` 3 = 24 +3 `shiftL` 32 = 12884901888 +3 `shiftL` 64 = 55340232221128654848 + +# +0 `shiftR` 0 = 0 +0 `shiftR` 1 = 0 +0 `shiftR` 2 = 0 +0 `shiftR` 3 = 0 +0 `shiftR` 32 = 0 +0 `shiftR` 64 = 0 + +1 `shiftR` 0 = 1 +1 `shiftR` 1 = 0 +1 `shiftR` 2 = 0 +1 `shiftR` 3 = 0 +1 `shiftR` 32 = 0 +1 `shiftR` 64 = 0 + +2 `shiftR` 0 = 2 +2 `shiftR` 1 = 1 +2 `shiftR` 2 = 0 +2 `shiftR` 3 = 0 +2 `shiftR` 32 = 0 +2 `shiftR` 64 = 0 + +3 `shiftR` 0 = 3 +3 `shiftR` 1 = 1 +3 `shiftR` 2 = 0 +3 `shiftR` 3 = 0 +3 `shiftR` 32 = 0 +3 `shiftR` 64 = 0 + +# +0 `rotate` -3 = 0 +0 `rotate` -2 = 0 +0 `rotate` -1 = 0 +0 `rotate` 0 = 0 +0 `rotate` 1 = 0 +0 `rotate` 2 = 0 +0 `rotate` 3 = 0 +0 `rotate` -64 = 0 +0 `rotate` -32 = 0 +0 `rotate` 32 = 0 +0 `rotate` 64 = 0 + +1 `rotate` -3 = 0 +1 `rotate` -2 = 0 +1 `rotate` -1 = 0 +1 `rotate` 0 = 1 +1 `rotate` 1 = 2 +1 `rotate` 2 = 4 +1 `rotate` 3 = 8 +1 `rotate` -64 = 0 +1 `rotate` -32 = 0 +1 `rotate` 32 = 4294967296 +1 `rotate` 64 = 18446744073709551616 + +2 `rotate` -3 = 0 +2 `rotate` -2 = 0 +2 `rotate` -1 = 1 +2 `rotate` 0 = 2 +2 `rotate` 1 = 4 +2 `rotate` 2 = 8 +2 `rotate` 3 = 16 +2 `rotate` -64 = 0 +2 `rotate` -32 = 0 +2 `rotate` 32 = 8589934592 +2 `rotate` 64 = 36893488147419103232 + +3 `rotate` -3 = 0 +3 `rotate` -2 = 0 +3 `rotate` -1 = 1 +3 `rotate` 0 = 3 +3 `rotate` 1 = 6 +3 `rotate` 2 = 12 +3 `rotate` 3 = 24 +3 `rotate` -64 = 0 +3 `rotate` -32 = 0 +3 `rotate` 32 = 12884901888 +3 `rotate` 64 = 55340232221128654848 + +# +bit 0 = 1 +bit 1 = 2 +bit 2 = 4 +bit 3 = 8 +# +0 `setBit` 0 = 1 +0 `setBit` 1 = 2 +0 `setBit` 2 = 4 +0 `setBit` 3 = 8 +0 `setBit` 32 = 4294967296 +0 `setBit` 64 = 18446744073709551616 + +1 `setBit` 0 = 1 +1 `setBit` 1 = 3 +1 `setBit` 2 = 5 +1 `setBit` 3 = 9 +1 `setBit` 32 = 4294967297 +1 `setBit` 64 = 18446744073709551617 + +2 `setBit` 0 = 3 +2 `setBit` 1 = 2 +2 `setBit` 2 = 6 +2 `setBit` 3 = 10 +2 `setBit` 32 = 4294967298 +2 `setBit` 64 = 18446744073709551618 + +3 `setBit` 0 = 3 +3 `setBit` 1 = 3 +3 `setBit` 2 = 7 +3 `setBit` 3 = 11 +3 `setBit` 32 = 4294967299 +3 `setBit` 64 = 18446744073709551619 + +# +0 `clearBit` 0 = 0 +0 `clearBit` 1 = 0 +0 `clearBit` 2 = 0 +0 `clearBit` 3 = 0 +0 `clearBit` 32 = 0 +0 `clearBit` 64 = 0 + +1 `clearBit` 0 = 0 +1 `clearBit` 1 = 1 +1 `clearBit` 2 = 1 +1 `clearBit` 3 = 1 +1 `clearBit` 32 = 1 +1 `clearBit` 64 = 1 + +2 `clearBit` 0 = 2 +2 `clearBit` 1 = 0 +2 `clearBit` 2 = 2 +2 `clearBit` 3 = 2 +2 `clearBit` 32 = 2 +2 `clearBit` 64 = 2 + +3 `clearBit` 0 = 2 +3 `clearBit` 1 = 1 +3 `clearBit` 2 = 3 +3 `clearBit` 3 = 3 +3 `clearBit` 32 = 3 +3 `clearBit` 64 = 3 + +# +0 `complementBit` 0 = 1 +0 `complementBit` 1 = 2 +0 `complementBit` 2 = 4 +0 `complementBit` 3 = 8 +0 `complementBit` 32 = 4294967296 +0 `complementBit` 64 = 18446744073709551616 + +1 `complementBit` 0 = 0 +1 `complementBit` 1 = 3 +1 `complementBit` 2 = 5 +1 `complementBit` 3 = 9 +1 `complementBit` 32 = 4294967297 +1 `complementBit` 64 = 18446744073709551617 + +2 `complementBit` 0 = 3 +2 `complementBit` 1 = 0 +2 `complementBit` 2 = 6 +2 `complementBit` 3 = 10 +2 `complementBit` 32 = 4294967298 +2 `complementBit` 64 = 18446744073709551618 + +3 `complementBit` 0 = 2 +3 `complementBit` 1 = 1 +3 `complementBit` 2 = 7 +3 `complementBit` 3 = 11 +3 `complementBit` 32 = 4294967299 +3 `complementBit` 64 = 18446744073709551619 + +# +0 `testBit` 0 = False +0 `testBit` 1 = False +0 `testBit` 2 = False +0 `testBit` 3 = False +0 `testBit` 32 = False +0 `testBit` 64 = False + +1 `testBit` 0 = True +1 `testBit` 1 = False +1 `testBit` 2 = False +1 `testBit` 3 = False +1 `testBit` 32 = False +1 `testBit` 64 = False + +2 `testBit` 0 = False +2 `testBit` 1 = True +2 `testBit` 2 = False +2 `testBit` 3 = False +2 `testBit` 32 = False +2 `testBit` 64 = False + +3 `testBit` 0 = True +3 `testBit` 1 = True +3 `testBit` 2 = False +3 `testBit` 3 = False +3 `testBit` 32 = False +3 `testBit` 64 = False + +# +isSigned 0 = False +isSigned 1 = False +isSigned 2 = False +isSigned 3 = False +# diff --git a/testsuite/tests/numeric/should_run/numrun016.hs b/testsuite/tests/numeric/should_run/numrun016.hs new file mode 100644 index 0000000000..c45e322030 --- /dev/null +++ b/testsuite/tests/numeric/should_run/numrun016.hs @@ -0,0 +1,8 @@ +-- test for trac #8532 + +import Data.Complex + +main :: IO () +main = do + print $ acosh ((-1)::Complex Double) + print $ acosh ((-1)::Complex Float) diff --git a/testsuite/tests/numeric/should_run/numrun016.stdout b/testsuite/tests/numeric/should_run/numrun016.stdout new file mode 100644 index 0000000000..25676f77dc --- /dev/null +++ b/testsuite/tests/numeric/should_run/numrun016.stdout @@ -0,0 +1,2 @@ +0.0 :+ 3.141592653589793 +0.0 :+ 3.1415927
\ No newline at end of file |