Skip to content

Commit

Permalink
Add test case for #12689
Browse files Browse the repository at this point in the history
which test a few variants of rules involving constructors, including
nullary constructors, constructors with wrappers, and unsaturated of
constructors.

At the moment, all the rules work as expected, despite GHC’s compile
time warnings when called with -Wall.
  • Loading branch information
nomeata committed Oct 11, 2016
1 parent a6111b8 commit b5be2ec
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
26 changes: 26 additions & 0 deletions testsuite/tests/simplCore/should_run/T12689.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
data T1 = MkT1Bad | MkT1Good deriving Show
data T2 = MkT2Bad Int | MkT2Good Int deriving Show
data T3 = MkT3Bad {-# UNPACK #-} !Int | MkT3Good {-# UNPACK #-} !Int deriving Show
data T4 = MkT4Bad Int | MkT4Good Int deriving Show
data T5 = MkT5Bad {-# UNPACK #-} !Int | MkT5Good {-# UNPACK #-} !Int deriving Show

{-# RULES

"T1" MkT1Bad = MkT1Good
"T2" forall x. MkT2Bad x = MkT2Good x
"T3" forall x. MkT3Bad x = MkT3Good x
"T4" MkT4Bad = MkT4Good
"T5" MkT5Bad = MkT5Good
#-}

app = id
{-# NOINLINE app #-}

main = do
print MkT1Bad
print (MkT2Bad 42)
print (MkT3Bad 42)
print (MkT4Bad 42)
print (app MkT4Bad 42)
print (MkT5Bad 42)
print (app MkT5Bad 42)
7 changes: 7 additions & 0 deletions testsuite/tests/simplCore/should_run/T12689.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MkT1Good
MkT2Good 42
MkT3Good 42
MkT4Good 42
MkT4Good 42
MkT5Good 42
MkT5Good 42
24 changes: 24 additions & 0 deletions testsuite/tests/simplCore/should_run/T12689a.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
data T1 = MkT1Bad | MkT1Good deriving Show
data T2 = MkT2Bad Int | MkT2Good Int deriving Show
data T3 = MkT3Bad {-# UNPACK #-} !Int | MkT3Good {-# UNPACK #-} !Int deriving Show
data T4 = MkT4Bad Int | MkT4Good Int deriving Show
data T5 = MkT5Bad {-# UNPACK #-} !Int | MkT5Good {-# UNPACK #-} !Int deriving Show

{-# RULES

"T1" app MkT1Bad = MkT1Good
"T2" forall x. app (MkT2Bad x) = MkT2Good x
"T3" forall x. app (MkT3Bad x) = MkT3Good x
"T4" app MkT4Bad = MkT4Good
"T5" app MkT5Bad = MkT5Good
#-}

app = id
{-# NOINLINE app #-}

main = do
print (app MkT1Bad)
print (app (MkT2Bad 42))
print (app (MkT3Bad 42))
print (app MkT4Bad 42)
print (app MkT5Bad 42)
5 changes: 5 additions & 0 deletions testsuite/tests/simplCore/should_run/T12689a.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MkT1Good
MkT2Good 42
MkT3Good 42
MkT4Good 42
MkT5Good 42
2 changes: 2 additions & 0 deletions testsuite/tests/simplCore/should_run/all.T
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,5 @@ test('T10830', extra_run_opts('+RTS -K100k -RTS'), compile_and_run, [''])
test('T11172', normal, compile_and_run, [''])
test('T11731', normal, compile_and_run, ['-fspec-constr'])
test('T7611', normal, compile_and_run, [''])
test('T12689', normal, compile_and_run, [''])
test('T12689a', normal, compile_and_run, [''])

0 comments on commit b5be2ec

Please sign in to comment.