Commit 5db5edb1 authored by simonmar's avatar simonmar
Browse files

[project @ 2003-07-23 11:40:31 by simonmar]

Copy some GHCi tests over from fptools/ghc/tests/ghci
parent 6c2bb842
module Main where
import B
main = print ("hello world" ++ show (f 42))
module B (module B, module C) where
import C
k x = x `mod` 11
module C (f, g, h) where
import D
g x = f x + 1
h x = x `div` 2
data C = C {x :: Int}
module D where
data T = A Int | B Float deriving Eq
f x = x + x
module D where
data T = A Int | B Float deriving Eq
f x = x + x
module D where
data T = A Int | B Float deriving Eq
f x = x + 1
TOP=../../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
test('prog001', normal, ghci_script, ['prog001.script'])
:unset +s
-- first, tidy up:
:! rm -f *.hi *.o *~
:! cp D1.hs D.hs
-- load the program (all interpreted)
:load A
-- reloading should do nothing
:reload
-- make sure `main' works
main
-- touch a module + recompile
:! sleep 1
:! touch C.hs
:reload
-- make sure `main' still works
main
-- compile D & reload
:! $HC $HC_OPTS -no-recomp -c D.hs
:reload
main
-- change D, recompile & reload
:! cp D2.hs D.hs
:! $HC $HC_OPTS -no-recomp -c D.hs
:reload
:load A
-- make sure we're picking up the new D, via B
:module B
g 42
Compiling D ( D.hs, interpreted )
Compiling C ( C.hs, interpreted )
Compiling B ( B.hs, interpreted )
Compiling Main ( A.hs, interpreted )
Compiling C ( C.hs, interpreted )
Skipping B ( B.hs, interpreted )
Skipping Main ( A.hs, interpreted )
Compiling D ( D.hs, interpreted )
Skipping C ( C.hs, interpreted )
Skipping B ( B.hs, interpreted )
Skipping Main ( A.hs, interpreted )
Skipping D ( D.hs, D.o )
Compiling C ( C.hs, interpreted )
Compiling B ( B.hs, interpreted )
Compiling Main ( A.hs, interpreted )
"hello world84"
"hello world84"
"hello world84"
44
module A where
data T = A Int | B Float deriving Eq
f :: Int -> Int
f x = x + 3
module A where
data T = A Int | B Float deriving Eq
f :: Double -> Double
f x = x + x
module A where
data T = A Int | B Float deriving Eq
f :: Int -> Int
f x = x + 3
module B (f, g, h) where
import A
g x = f x + 1
h x = x `div` 2
module C (module B, module C) where
import B
k x = x `mod` 11
module Main where
import C
main = print ("hello world" ++ show (f 42))
TOP=../../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
test('prog002', normal, ghci_script, ['prog002.script'])
:unset +s
:unset +t
-- first, clean up:
:! rm -f *.hi *.o *~
:! cp A1.hs A.hs
:load D
-- compile A & reload
:! $HC $HC_OPTS -no-recomp -c A.hs
:reload
B.g 42
B.g 42
B.g 42
-- swap A2 for A, compile & reload
:! cp A2.hs A.hs
:! $HC $HC_OPTS -no-recomp -c A.hs
:reload
-- the system should ignore the compiled version and compile its own.
B.g 42
B.g 42
B.g 42
-- pick up newly compiled A
:load D
B.g 42
B.g 42
B.g 42
-- remove A.o: system should recompile A
:! rm A.o
:reload
B.g 42
B.g 42
B.g 42
Supports Markdown
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