[project @ 1999-08-04 10:07:50 by simonmar]
authorsimonmar <unknown>
Wed, 4 Aug 1999 10:07:50 +0000 (10:07 +0000)
committersimonmar <unknown>
Wed, 4 Aug 1999 10:07:50 +0000 (10:07 +0000)
Add a test for a rather misguided use of the Memo library, but which
showed up a bug nevertheless :)

ghc/tests/lib/should_run/Makefile
ghc/tests/lib/should_run/memo002.hs [new file with mode: 0644]
ghc/tests/lib/should_run/memo002.stdout [new file with mode: 0644]

index b65b4d9..4785fc1 100644 (file)
@@ -1,5 +1,5 @@
 #-----------------------------------------------------------------------------
-# $Id: Makefile,v 1.12 1999/06/09 09:35:58 simonpj Exp $
+# $Id: Makefile,v 1.13 1999/08/04 10:07:50 simonmar Exp $
 
 TOP = ../..
 include $(TOP)/mk/boilerplate.mk
@@ -29,6 +29,9 @@ memo001_HC_OPTS               = -syslib misc
 # finalized properly, and stable names are GC'd etc.
 memo001_RUNTEST_OPTS    = +RTS -A10k -G1
 
+memo002_HC_OPTS                = -syslib misc
+memo002_RUNTEST_OPTS   = 20
+
 SRC_MKDEPENDHS_OPTS += -syslib misc -syslib exts 
 
 include $(TOP)/mk/target.mk
diff --git a/ghc/tests/lib/should_run/memo002.hs b/ghc/tests/lib/should_run/memo002.hs
new file mode 100644 (file)
index 0000000..d441c0a
--- /dev/null
@@ -0,0 +1,25 @@
+module Main
+where
+
+import Memo
+import System(getArgs)
+
+main = do (arg:_) <- getArgs
+         mapM_ printTriple [ (i,fib i,mfib i) | i <- [10..read arg] ]
+  where printTriple (i,fi,mfi) = do print i
+                                   print fi
+                                   print mfi
+                                   putStrLn ""
+
+mfib :: Integer -> Integer
+mfib = memo ufib
+
+ufib :: Integer -> Integer
+ufib 0 = 1
+ufib 1 = 1
+ufib n = mfib (n-1) + mfib (n-2)
+
+fib :: Integer -> Integer
+fib 0 = 1
+fib 1 = 1
+fib n = fib (n-1) + fib (n-2)
diff --git a/ghc/tests/lib/should_run/memo002.stdout b/ghc/tests/lib/should_run/memo002.stdout
new file mode 100644 (file)
index 0000000..e69de29