diff options
author | David Terei <davidterei@gmail.com> | 2011-07-20 11:09:03 -0700 |
---|---|---|
committer | David Terei <davidterei@gmail.com> | 2011-07-20 11:26:35 -0700 |
commit | 16514f272fb42af6e9c7674a9bd6c9dce369231f (patch) | |
tree | e4f332b45fe65e2a7a2451be5674f887b42bf199 /testsuite/tests/cpranal | |
parent | ebd422aed41048476aa61dd4c520d43becd78682 (diff) | |
download | haskell-16514f272fb42af6e9c7674a9bd6c9dce369231f.tar.gz |
Move tests from tests/ghc-regress/* to just tests/*
Diffstat (limited to 'testsuite/tests/cpranal')
-rw-r--r-- | testsuite/tests/cpranal/Makefile | 3 | ||||
-rw-r--r-- | testsuite/tests/cpranal/should_compile/Cpr001.hs | 16 | ||||
-rw-r--r-- | testsuite/tests/cpranal/should_compile/Cpr001_imp.hs | 55 | ||||
-rw-r--r-- | testsuite/tests/cpranal/should_compile/Makefile | 3 | ||||
-rw-r--r-- | testsuite/tests/cpranal/should_compile/all.T | 10 |
5 files changed, 87 insertions, 0 deletions
diff --git a/testsuite/tests/cpranal/Makefile b/testsuite/tests/cpranal/Makefile new file mode 100644 index 0000000000..9a36a1c5fe --- /dev/null +++ b/testsuite/tests/cpranal/Makefile @@ -0,0 +1,3 @@ +TOP=../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk diff --git a/testsuite/tests/cpranal/should_compile/Cpr001.hs b/testsuite/tests/cpranal/should_compile/Cpr001.hs new file mode 100644 index 0000000000..0871205bb7 --- /dev/null +++ b/testsuite/tests/cpranal/should_compile/Cpr001.hs @@ -0,0 +1,16 @@ +module Cpr001 + (intpInstr) where + +import Cpr001_imp + +-- ------------------------------------------------------------------- + +intpInstr :: Instr -> MST () + +intpInstr (SysCall "exit") + = setMTerminated + +intpInstr (SysCall call) + = setMSvc call + +-- ------------------------------------------------------------------- diff --git a/testsuite/tests/cpranal/should_compile/Cpr001_imp.hs b/testsuite/tests/cpranal/should_compile/Cpr001_imp.hs new file mode 100644 index 0000000000..5b2586127b --- /dev/null +++ b/testsuite/tests/cpranal/should_compile/Cpr001_imp.hs @@ -0,0 +1,55 @@ +-- $Id: Cpr001_imp.hs,v 1.1 2001/08/22 12:21:15 simonmar Exp $ + +module Cpr001_imp where + +data MS = MS { instr :: String + , pc :: Int + , mem :: String + , stack :: String + , frames :: [String] + , status :: Maybe String + } + + +newtype StateTrans s a = ST ( s -> (s, Maybe a)) + +-- state monad with error handling +-- in case of an error, the state remains +-- as it is and Nothing is returned as value +-- else execution continues + +instance Monad (StateTrans s) where + (ST p) >>= k + = ST (\s0 -> let + (s1, r0) = p s0 + in + case r0 of + Just v -> let + (ST q) = k v + in + q s1 + Nothing -> (s1, Nothing) + ) + return v + = ST (\s -> (s, Just v)) + + +-- machine state transitions + +type MachineStateTrans = StateTrans MS + +type MST = MachineStateTrans + +{-# NOINLINE setMTerminated #-} +setMTerminated + = ST (\ms -> (ms { status = Just "Terminated" }, Just ())) + +setMSvc call + = ST (\ms -> (ms { status = Just "Service" }, Just ())) + +-- ------------------------------------------------------------------- + +data Instr + = LoadI Int -- load int const + | SysCall String -- system call (svc) + diff --git a/testsuite/tests/cpranal/should_compile/Makefile b/testsuite/tests/cpranal/should_compile/Makefile new file mode 100644 index 0000000000..9101fbd40a --- /dev/null +++ b/testsuite/tests/cpranal/should_compile/Makefile @@ -0,0 +1,3 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk diff --git a/testsuite/tests/cpranal/should_compile/all.T b/testsuite/tests/cpranal/should_compile/all.T new file mode 100644 index 0000000000..99ffed997f --- /dev/null +++ b/testsuite/tests/cpranal/should_compile/all.T @@ -0,0 +1,10 @@ +# Just do the opt way... +def f( opts ): + opts.only_ways = ['optasm'] + +setTestOpts(f) + +test('Cpr001', + extra_clean(['Cpr001_imp.hi', 'Cpr001_imp.o', 'Cpr001_imp.comp.stderr']), + multimod_compile, + ['Cpr001', '-v0']) |