summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghci/prog003
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/prog003
parentebd422aed41048476aa61dd4c520d43becd78682 (diff)
downloadhaskell-16514f272fb42af6e9c7674a9bd6c9dce369231f.tar.gz
Move tests from tests/ghc-regress/* to just tests/*
Diffstat (limited to 'testsuite/tests/ghci/prog003')
-rw-r--r--testsuite/tests/ghci/prog003/A.hs8
-rw-r--r--testsuite/tests/ghci/prog003/B.hs5
-rw-r--r--testsuite/tests/ghci/prog003/C.hs6
-rw-r--r--testsuite/tests/ghci/prog003/D.hs13
-rw-r--r--testsuite/tests/ghci/prog003/D1.hs13
-rw-r--r--testsuite/tests/ghci/prog003/D2.hs13
-rw-r--r--testsuite/tests/ghci/prog003/Makefile3
-rw-r--r--testsuite/tests/ghci/prog003/prog003.T6
-rw-r--r--testsuite/tests/ghci/prog003/prog003.script90
-rw-r--r--testsuite/tests/ghci/prog003/prog003.stdout43
10 files changed, 200 insertions, 0 deletions
diff --git a/testsuite/tests/ghci/prog003/A.hs b/testsuite/tests/ghci/prog003/A.hs
new file mode 100644
index 0000000000..6e9351c066
--- /dev/null
+++ b/testsuite/tests/ghci/prog003/A.hs
@@ -0,0 +1,8 @@
+module A(main,a) where
+
+import B
+import C(c)
+
+main = print (a 42)
+
+a x = b x + c x
diff --git a/testsuite/tests/ghci/prog003/B.hs b/testsuite/tests/ghci/prog003/B.hs
new file mode 100644
index 0000000000..cd579657fb
--- /dev/null
+++ b/testsuite/tests/ghci/prog003/B.hs
@@ -0,0 +1,5 @@
+module B where
+
+import D
+
+b x = d x
diff --git a/testsuite/tests/ghci/prog003/C.hs b/testsuite/tests/ghci/prog003/C.hs
new file mode 100644
index 0000000000..f26067c78a
--- /dev/null
+++ b/testsuite/tests/ghci/prog003/C.hs
@@ -0,0 +1,6 @@
+module C where
+
+import D
+
+c x = d x
+
diff --git a/testsuite/tests/ghci/prog003/D.hs b/testsuite/tests/ghci/prog003/D.hs
new file mode 100644
index 0000000000..a53a8c3da6
--- /dev/null
+++ b/testsuite/tests/ghci/prog003/D.hs
@@ -0,0 +1,13 @@
+module D where
+
+-- data types and an instance
+data D a = A Int | B Float deriving Eq
+newtype N a = N Double
+type T a = (Int,Double)
+
+-- a class
+class C a where c :: a -> Int
+
+-- a function
+d :: Float -> Float
+d x = x / 3
diff --git a/testsuite/tests/ghci/prog003/D1.hs b/testsuite/tests/ghci/prog003/D1.hs
new file mode 100644
index 0000000000..4414d65d2a
--- /dev/null
+++ b/testsuite/tests/ghci/prog003/D1.hs
@@ -0,0 +1,13 @@
+module D where
+
+-- data types and an instance
+data D a = A Int | B Float deriving Eq
+newtype N a = N Double
+type T a = (Int,Double)
+
+-- a class
+class C a where c :: a -> Int
+
+-- a function
+d :: Int -> Int
+d x = x * 2
diff --git a/testsuite/tests/ghci/prog003/D2.hs b/testsuite/tests/ghci/prog003/D2.hs
new file mode 100644
index 0000000000..a53a8c3da6
--- /dev/null
+++ b/testsuite/tests/ghci/prog003/D2.hs
@@ -0,0 +1,13 @@
+module D where
+
+-- data types and an instance
+data D a = A Int | B Float deriving Eq
+newtype N a = N Double
+type T a = (Int,Double)
+
+-- a class
+class C a where c :: a -> Int
+
+-- a function
+d :: Float -> Float
+d x = x / 3
diff --git a/testsuite/tests/ghci/prog003/Makefile b/testsuite/tests/ghci/prog003/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/ghci/prog003/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/ghci/prog003/prog003.T b/testsuite/tests/ghci/prog003/prog003.T
new file mode 100644
index 0000000000..c87bc90597
--- /dev/null
+++ b/testsuite/tests/ghci/prog003/prog003.T
@@ -0,0 +1,6 @@
+test('prog003',
+ extra_clean(['D.hi', 'C.hi', 'C.o', 'B.hi', 'B.o', 'A', 'A.hi', 'A.o',
+ 'a.out']),
+ ghci_script,
+ ['prog003.script'])
+
diff --git a/testsuite/tests/ghci/prog003/prog003.script b/testsuite/tests/ghci/prog003/prog003.script
new file mode 100644
index 0000000000..9cdf484a59
--- /dev/null
+++ b/testsuite/tests/ghci/prog003/prog003.script
@@ -0,0 +1,90 @@
+:unset +s
+:unset +t
+-- A small multi-module program, with 4 modules, A, B, C, D. B & C
+-- depend on D, and A depends on B & C.
+--
+-- This test will try various combinations of compiled and interpreted
+-- versions of each module, and make sure each combination behaves
+-- sensibly.
+
+:l ../shell.hs
+:def shell (\s -> do shell s; return "")
+
+-- clean up
+:shell rm -f *.o *.hi
+:shell cp D1.hs D.hs
+
+putStrLn "Run 1"
+:load A
+:type a
+a 42
+
+putStrLn "Run 2"
+-- sigh; sleep 1, because the filesystem only stores times in seconds
+:shell sleep 1; cp D2.hs D.hs
+:reload
+:type (A.a,B.b,C.c,D.d)
+a 42
+
+putStrLn "Run 3"
+-- compile D, check that :reload doesn't pick it up
+:shell "$HC" $HC_OPTS -c D.hs
+:reload
+:type (A.a,B.b,C.c,D.d)
+a 42
+
+putStrLn "Run 4"
+-- pick up the compiled D now, with :load
+:load A
+:type (A.a,B.b,C.c,D.d)
+a 42
+
+putStrLn "Run 5"
+-- D,C compiled
+:shell "$HC" $HC_OPTS -c C.hs
+:load A
+:type (A.a,B.b,C.c,D.d)
+a 42
+
+putStrLn "Run 6"
+-- D,C,B compiled
+:shell "$HC" $HC_OPTS -c B.hs
+:load A
+:type (A.a,B.b,C.c,D.d)
+a 42
+
+putStrLn "Run 7"
+-- D,C,B,A compiled
+:shell "$HC" $HC_OPTS -c A.hs
+:load A
+:type (A.a,B.b,C.c,D.d)
+a 42
+
+putStrLn "Run 8"
+-- D,C,A compiled (better not use A.o)
+:shell rm B.o
+:load A
+:type (A.a,B.b,C.c,D.d)
+a 42
+
+putStrLn "Run 9"
+-- D,A compiled (better not use A.o)
+:shell rm C.o
+:load A
+:type (A.a,B.b,C.c,D.d)
+a 42
+
+putStrLn "Run 10"
+-- A compiled (better not use A.o)
+:shell rm D.o
+:load A
+:type (A.a,B.b,C.c,D.d)
+a 42
+
+putStrLn "Run 11"
+-- A,B,C compiled (better not use A.o, B.o, C.o)
+:shell "$HC" $HC_OPTS --make -v0 A
+:shell rm D.o
+:load A
+:type (A.a,B.b,C.c,D.d)
+a 42
diff --git a/testsuite/tests/ghci/prog003/prog003.stdout b/testsuite/tests/ghci/prog003/prog003.stdout
new file mode 100644
index 0000000000..dd299f34c8
--- /dev/null
+++ b/testsuite/tests/ghci/prog003/prog003.stdout
@@ -0,0 +1,43 @@
+Run 1
+a :: Int -> Int
+168
+Run 2
+(A.a,B.b,C.c,D.d)
+ :: (Float -> Float, Float -> Float, Float -> Float, Float -> Float)
+28.0
+Run 3
+(A.a,B.b,C.c,D.d)
+ :: (Float -> Float, Float -> Float, Float -> Float, Float -> Float)
+28.0
+Run 4
+(A.a,B.b,C.c,D.d)
+ :: (Float -> Float, Float -> Float, Float -> Float, Float -> Float)
+28.0
+Run 5
+(A.a,B.b,C.c,D.d)
+ :: (Float -> Float, Float -> Float, Float -> Float, Float -> Float)
+28.0
+Run 6
+(A.a,B.b,C.c,D.d)
+ :: (Float -> Float, Float -> Float, Float -> Float, Float -> Float)
+28.0
+Run 7
+(A.a,B.b,C.c,D.d)
+ :: (Float -> Float, Float -> Float, Float -> Float, Float -> Float)
+28.0
+Run 8
+(A.a,B.b,C.c,D.d)
+ :: (Float -> Float, Float -> Float, Float -> Float, Float -> Float)
+28.0
+Run 9
+(A.a,B.b,C.c,D.d)
+ :: (Float -> Float, Float -> Float, Float -> Float, Float -> Float)
+28.0
+Run 10
+(A.a,B.b,C.c,D.d)
+ :: (Float -> Float, Float -> Float, Float -> Float, Float -> Float)
+28.0
+Run 11
+(A.a,B.b,C.c,D.d)
+ :: (Float -> Float, Float -> Float, Float -> Float, Float -> Float)
+28.0