summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghci/prog002
diff options
context:
space:
mode:
authorDavid Terei <davidterei@gmail.com>2011-07-20 11:09:03 -0700
committerDavid Terei <davidterei@gmail.com>2011-07-20 11:26:35 -0700
commit16514f272fb42af6e9c7674a9bd6c9dce369231f (patch)
treee4f332b45fe65e2a7a2451be5674f887b42bf199 /testsuite/tests/ghci/prog002
parentebd422aed41048476aa61dd4c520d43becd78682 (diff)
downloadhaskell-16514f272fb42af6e9c7674a9bd6c9dce369231f.tar.gz
Move tests from tests/ghc-regress/* to just tests/*
Diffstat (limited to 'testsuite/tests/ghci/prog002')
-rw-r--r--testsuite/tests/ghci/prog002/A.hs6
-rw-r--r--testsuite/tests/ghci/prog002/A1.hs6
-rw-r--r--testsuite/tests/ghci/prog002/A2.hs6
-rw-r--r--testsuite/tests/ghci/prog002/B.hs7
-rw-r--r--testsuite/tests/ghci/prog002/C.hs5
-rw-r--r--testsuite/tests/ghci/prog002/D.hs5
-rw-r--r--testsuite/tests/ghci/prog002/Makefile3
-rw-r--r--testsuite/tests/ghci/prog002/prog002.T2
-rw-r--r--testsuite/tests/ghci/prog002/prog002.script45
-rw-r--r--testsuite/tests/ghci/prog002/prog002.stdout12
10 files changed, 97 insertions, 0 deletions
diff --git a/testsuite/tests/ghci/prog002/A.hs b/testsuite/tests/ghci/prog002/A.hs
new file mode 100644
index 0000000000..6dc493aaa2
--- /dev/null
+++ b/testsuite/tests/ghci/prog002/A.hs
@@ -0,0 +1,6 @@
+module A where
+
+data T = A Int | B Float deriving Eq
+
+f :: Int -> Int
+f x = x + 3
diff --git a/testsuite/tests/ghci/prog002/A1.hs b/testsuite/tests/ghci/prog002/A1.hs
new file mode 100644
index 0000000000..069e8ef07a
--- /dev/null
+++ b/testsuite/tests/ghci/prog002/A1.hs
@@ -0,0 +1,6 @@
+module A where
+
+data T = A Int | B Float deriving Eq
+
+f :: Double -> Double
+f x = x + x
diff --git a/testsuite/tests/ghci/prog002/A2.hs b/testsuite/tests/ghci/prog002/A2.hs
new file mode 100644
index 0000000000..6dc493aaa2
--- /dev/null
+++ b/testsuite/tests/ghci/prog002/A2.hs
@@ -0,0 +1,6 @@
+module A where
+
+data T = A Int | B Float deriving Eq
+
+f :: Int -> Int
+f x = x + 3
diff --git a/testsuite/tests/ghci/prog002/B.hs b/testsuite/tests/ghci/prog002/B.hs
new file mode 100644
index 0000000000..6aced23415
--- /dev/null
+++ b/testsuite/tests/ghci/prog002/B.hs
@@ -0,0 +1,7 @@
+module B (f, g, h) where
+
+import A
+
+g x = f x + 1
+
+h x = x `div` 2
diff --git a/testsuite/tests/ghci/prog002/C.hs b/testsuite/tests/ghci/prog002/C.hs
new file mode 100644
index 0000000000..b3baac2979
--- /dev/null
+++ b/testsuite/tests/ghci/prog002/C.hs
@@ -0,0 +1,5 @@
+module C (module B, module C) where
+
+import B
+
+k x = x `mod` 11
diff --git a/testsuite/tests/ghci/prog002/D.hs b/testsuite/tests/ghci/prog002/D.hs
new file mode 100644
index 0000000000..35672bd88c
--- /dev/null
+++ b/testsuite/tests/ghci/prog002/D.hs
@@ -0,0 +1,5 @@
+module Main where
+
+import C
+
+main = print ("hello world" ++ show (f 42))
diff --git a/testsuite/tests/ghci/prog002/Makefile b/testsuite/tests/ghci/prog002/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/ghci/prog002/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/ghci/prog002/prog002.T b/testsuite/tests/ghci/prog002/prog002.T
new file mode 100644
index 0000000000..ea39005f6f
--- /dev/null
+++ b/testsuite/tests/ghci/prog002/prog002.T
@@ -0,0 +1,2 @@
+test('prog002', extra_clean(['A.hi']), ghci_script, ['prog002.script'])
+
diff --git a/testsuite/tests/ghci/prog002/prog002.script b/testsuite/tests/ghci/prog002/prog002.script
new file mode 100644
index 0000000000..cecbe4091a
--- /dev/null
+++ b/testsuite/tests/ghci/prog002/prog002.script
@@ -0,0 +1,45 @@
+:unset +s
+:unset +t
+
+:l ../shell.hs
+:def shell (\s -> do shell s; return "")
+
+-- first, clean up:
+:shell rm -f *.hi *.o *~
+:shell cp A1.hs A.hs
+
+:load D.hs
+
+-- compile A & reload
+:shell "$HC" $HC_OPTS -fforce-recomp -c A.hs
+:reload
+
+B.g 42
+B.g 42
+B.g 42
+
+-- swap A2 for A, compile & reload
+:shell sleep 1
+:shell cp A2.hs A.hs
+:shell "$HC" $HC_OPTS -fforce-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.hs
+
+B.g 42
+B.g 42
+B.g 42
+
+-- remove A.o: system should recompile A
+:shell rm A.o
+:reload
+
+B.g 42
+B.g 42
+B.g 42
diff --git a/testsuite/tests/ghci/prog002/prog002.stdout b/testsuite/tests/ghci/prog002/prog002.stdout
new file mode 100644
index 0000000000..aece15514e
--- /dev/null
+++ b/testsuite/tests/ghci/prog002/prog002.stdout
@@ -0,0 +1,12 @@
+85.0
+85.0
+85.0
+46
+46
+46
+46
+46
+46
+46
+46
+46