Commit d4b548ef authored by niteria's avatar niteria
Browse files

Add some determinism tests

These are the tests that I accumulated fixing real issues.
Each test is a separate thing that was broken and they are
relatively small.

GHC Trac: #4012
parent f5f5a8a7
......@@ -188,7 +188,17 @@ extra_src_files = {
'determ003': ['A.hs'],
'determ005': ['A.hs'],
'determ006': ['spec-inline-determ.hs'],
'determ007': ['A.hs'],
'determ008': ['A.hs'],
'determ009': ['A.hs'],
'determ010': ['A.hs'],
'determ011': ['A.hs'],
'determ012': ['A.hs'],
'determ013': ['A.hs'],
'determ014': ['A.hs'],
'determ015': ['A.hs'],
'determ016': ['A.hs'],
'determ017': ['A.hs'],
'determ018': ['A.hs'],
'determ019': ['A.hs'],
'dodgy': ['DodgyA.hs'],
......
module A where
data ADT a b = Z a b deriving Eq
TOP=../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
TEST_HC_OPTS_NO_RECOMP = $(filter-out -fforce-recomp,$(TEST_HC_OPTS))
determ007:
$(RM) A.hi A.o
'$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -O A.hs
$(CP) A.hi A.normal.hi
$(RM) A.hi A.o
'$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -O -dinitial-unique=16777215 -dunique-increment=-1 A.hs
diff A.hi A.normal.hi
test('determ007',
extra_clean(['A.o', 'A.hi', 'A.normal.hi']),
run_command,
['$MAKE -s --no-print-directory determ007'])
[1 of 1] Compiling A ( A.hs, A.o )
[1 of 1] Compiling A ( A.hs, A.o )
module A where
data F a b = F { x :: !Int, y :: !(Float,Float), z :: !(a,b) }
TOP=../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
TEST_HC_OPTS_NO_RECOMP = $(filter-out -fforce-recomp,$(TEST_HC_OPTS))
determ008:
$(RM) A.hi A.o
'$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -O A.hs
$(CP) A.hi A.normal.hi
$(RM) A.hi A.o
'$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -O -dinitial-unique=16777215 -dunique-increment=-1 A.hs
diff A.hi A.normal.hi
test('determ008',
extra_clean(['A.o', 'A.hi', 'A.normal.hi']),
run_command,
['$MAKE -s --no-print-directory determ008'])
[1 of 1] Compiling A ( A.hs, A.o )
[1 of 1] Compiling A ( A.hs, A.o )
module A where
newtype Pair1 f g a = Pair1 {unPair1 :: (f a, g a)}
deriving Eq
TOP=../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
TEST_HC_OPTS_NO_RECOMP = $(filter-out -fforce-recomp,$(TEST_HC_OPTS))
determ009:
$(RM) A.hi A.o
'$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -dinitial-unique=0 -dunique-increment=1 A.hs
$(CP) A.hi A.normal.hi
$(RM) A.hi A.o
'$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -dinitial-unique=16777215 -dunique-increment=-1 A.hs
diff A.hi A.normal.hi
test('determ009',
extra_clean(['A.o', 'A.hi', 'A.normal.hi']),
run_command,
['$MAKE -s --no-print-directory determ009'])
[1 of 1] Compiling A ( A.hs, A.o )
[1 of 1] Compiling A ( A.hs, A.o )
module A where
-- Reproduces an issue where rules would abstract over typeclass dictionaries
-- non-deterministically.
--
-- Compare:
--
-- RULES: "SPECLOL $csize" [ALWAYS]
-- forall ($dOrd_a1sc :: Ord Int) ($dNum_a1sd :: Num Int).
-- $csize_a1sg @ Int $dOrd_a1sc $dNum_a1sd
-- = $s$csize_d1zr]
-- with:
--
-- RULES: "SPEC $csize" [ALWAYS]
-- forall ($dNum_a18n42 :: Num Int) ($dOrd_a18n43 :: Ord Int).
-- $csize_a18n3Z @ Int $dOrd_a18n43 $dNum_a18n42
-- = $s$csize_d18mWO]
class Size t where
size :: t -> t -> Int
instance (Ord a, Num a) => Size [a] where
{-# SPECIALISE instance Size [Int] #-}
size (x:xs) (y:ys) | x+y > 4 = size xs ys
| otherwise = size xs ys
size _ _ = 0
TOP=../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
TEST_HC_OPTS_NO_RECOMP = $(filter-out -fforce-recomp,$(TEST_HC_OPTS))
determ011:
$(RM) A.hi A.o
'$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -dinitial-unique=0 -dunique-increment=1 -O A.hs
$(CP) A.hi A.normal.hi
$(RM) A.hi A.o
'$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -dinitial-unique=16777215 -dunique-increment=-1 -O A.hs
diff A.hi A.normal.hi
test('determ011',
extra_clean(['A.o', 'A.hi', 'A.normal.hi']),
run_command,
['$MAKE -s --no-print-directory determ011'])
[1 of 1] Compiling A ( A.hs, A.o )
[1 of 1] Compiling A ( A.hs, A.o )
{-# LANGUAGE PolyKinds, MultiParamTypeClasses, FunctionalDependencies,
UndecidableInstances, FlexibleInstances #-}
module T10109 where
data Succ a
class Add (a :: k1) (b :: k2) (ab :: k3) | a b -> ab
instance (Add a b ab) => Add (Succ a) b (Succ ab)
TOP=../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
TEST_HC_OPTS_NO_RECOMP = $(filter-out -fforce-recomp,$(TEST_HC_OPTS))
determ012:
$(RM) A.hi A.o
'$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -dinitial-unique=0 -dunique-increment=1 -O A.hs
$(CP) A.hi A.normal.hi
$(RM) A.hi A.o
'$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -dinitial-unique=16777215 -dunique-increment=-1 -O A.hs
diff A.hi A.normal.hi
test('determ012',
extra_clean(['A.o', 'A.hi', 'A.normal.hi']),
run_command,
['$MAKE -s --no-print-directory determ012'])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment