Commit 10830b3a authored by simonmar's avatar simonmar
Browse files

[project @ 2003-07-23 10:55:28 by simonmar]

Add some GHCi tests (found 2 bugs in the HEAD in the process!)
parent 8cb98436
TOP=../../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
test('ghci001', normal, ghci_script, ['ghci001.script'])
test('ghci002', normal, ghci_script, ['ghci002.script'])
test('ghci003', normal, ghci_script, ['ghci003.script'])
test('ghci004', normal, ghci_script, ['ghci004.script'])
test('ghci005', normal, ghci_script, ['ghci005.script'])
test('ghci006', normal, ghci_script, ['ghci006.script'])
test('ghci007', normal, ghci_script, ['ghci007.script'])
test('ghci008', normal, ghci_script, ['ghci008.script'])
test('ghci009', normal, ghci_script, ['ghci009.script'])
# Skip this test: deadlock can't be detected now, because we wait for
# signals to arrive if there are signal handlers installed, and GHCi
# has a ^C handler installed.
test('ghci010', skip, ghci_script, ['ghci010.script'])
# Expect failure: this test should list both the type constructor and the data
# constructor for each of the builtin identifiers ([], (), (,), etc.), but
# currently only gives the data constructor.
test('ghci011', expect_fail, ghci_script, ['ghci011.script'])
-- bug: shouldn't be defaulting these expressions
:type (+)
:type enumFromTo
(+) :: forall a. (Num a) => a -> a -> a
enumFromTo :: forall a. (Enum a) => a -> a -> [a]
-- bug: we used to throw away the instance accidentally here
:m GHC.Base
1 == (2 :: Int)
1 == (2 :: Int)
-- check that 'it' works
1
it
print it
return 42
it
print it
import List
main = print (sort [100,99..1])
:unset +s +t
-- test importing a module from a package
:l ghci004
main
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100]
:unset +s +t
-- tests for :def, :undef
let void m = m >> return ""
let echo s = void (putStrLn s)
:def echo echo
:echo hello, world!
let echo s = return (":! echo " ++ map Char.toUpper s)
:echo hello, world!
:def echo echo
:undef echo
:def echo echo
:echo hello, world!
___ ___ _
/ _ \ /\ /\/ __(_)
/ /_\// /_/ / / | | GHC Interactive, version 5.03, for Haskell 98.
/ /_\\/ __ / /___| | http://www.haskell.org/ghc/
\____/\/ /_/\____/|_| Type :? for help.
Loading package std ... linking ... done.
Prelude> :unset +s +t
Prelude> -- tests for :def, :undef
Prelude> let void m = m >> return ""
Prelude> let echo s = void (putStrLn s)
Prelude> :def echo echo
Prelude> :echo hello, world!
hello, world!
Prelude>
Prelude> let echo s = return (":! echo " ++ map Char.toUpper s)
Prelude> :echo hello, world!
hello, world!
Prelude> :def echo echo
command `echo' is already defined
Prelude> :undef echo
Prelude> :def echo echo
Prelude> :echo hello, world!
HELLO, WORLD!
Prelude> Leaving GHCi.
module Ghci006 where
data Q = forall x . Show x => Q x
showQ (Q x) = show x
-- associated bug is that at the interpreter command line,
-- showQ (Q "foo") crashed the interpreter.
:unset +s +t
:set -fglasgow-exts
-- test for contexts on existential types crashing the interpreter
:l ghci006
showQ (Q "foo")
-- bug: shouldn't kill the whole system
System.exitFailure
Markdown is supported
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