Commit 7bb1fde1 authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari
Browse files

testsuite: Add test for #14931

Reviewers: alpmestan

Reviewed By: alpmestan

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14931

Differential Revision:
parent ceb91477
include $(TOP)/mk/
include $(TOP)/mk/
"$(TEST_HC)" $(TEST_HC_OPTS) -v0 -c -O -static -dynamic-too -dynosuf dyn_o -dynhisuf dyn_hi T14931_State.hs
"$(TEST_HC)" $(TEST_HC_OPTS) -v0 -c -O -prof -osuf p_o -hisuf p_hi T14931_State.hs
"$(TEST_HC)" $(TEST_HC_OPTS) -v0 -c -O -prof -osuf p_o -hisuf p_hi T14931_Bug.hs
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TemplateHaskell #-}
module T14931_Bug where
import Prelude (Int, IO, Bool(..), Num(..), Monad(..), not, print)
import qualified Language.Haskell.TH.Syntax as TH
import T14931_State
wat :: IO ()
wat = print $(let playGame [] = do
(_, score) <- get
return score
playGame (x:xs) = do
(on, score) <- get
case x of
'a' | on -> put (on, score + 1)
'b' | on -> put (on, score - 1)
'c' -> put (not on, score)
_ -> put (on, score)
playGame xs
startState :: (Bool, Int)
startState = (False, 0)
in TH.lift (evalState (playGame "abcaaacbbcabbab") startState) )
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE UndecidableInstances #-}
module T14931_State (MonadState(..), Lazy.evalState) where
import qualified Control.Monad.Trans.State.Lazy as Lazy (StateT, get, put, evalState)
class Monad m => MonadState s m | m -> s where
get :: m s
put :: s -> m ()
instance Monad m => MonadState s (Lazy.StateT s m) where
get = Lazy.get
put = Lazy.put
......@@ -6,3 +6,4 @@ test('prof002', [only_ways(['normal']), req_profiling], compile_and_run, ['-prof
test('T2410', [only_ways(['normal']), req_profiling], compile, ['-O2 -prof -fprof-cafs'])
test('T5889', [only_ways(['normal']), req_profiling, extra_files(['T5889/A.hs', 'T5889/B.hs'])], multimod_compile, ['A B', '-O -prof -fno-prof-count-entries -v0'])
test('T12790', [only_ways(['normal']), req_profiling], compile, ['-O -prof'])
test('T14931', [only_ways(['normal']), req_profiling], run_command, ['$MAKE -s --no-print-directory T14931'])
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