diff options
Diffstat (limited to 'testsuite/tests/numeric/should_compile')
-rw-r--r-- | testsuite/tests/numeric/should_compile/Makefile | 8 | ||||
-rw-r--r-- | testsuite/tests/numeric/should_compile/T14170.hs | 12 | ||||
-rw-r--r-- | testsuite/tests/numeric/should_compile/T14170.stdout | 59 | ||||
-rw-r--r-- | testsuite/tests/numeric/should_compile/T14465.hs | 26 | ||||
-rw-r--r-- | testsuite/tests/numeric/should_compile/T14465.stderr | 3 | ||||
-rw-r--r-- | testsuite/tests/numeric/should_compile/T14465.stdout | 104 | ||||
-rw-r--r-- | testsuite/tests/numeric/should_compile/T7116.stdout | 4 | ||||
-rw-r--r-- | testsuite/tests/numeric/should_compile/all.T | 7 |
8 files changed, 220 insertions, 3 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, ['']) |