Commit 412c310b authored by Ian Lynagh's avatar Ian Lynagh

Move tests out of h98; directory now removed

parent 0ad3cf34
......@@ -88,3 +88,4 @@ test('DoAndIfThenElse', normal, compile, [''])
test('NondecreasingIndentation', normal, compile, [''])
test('mc15', normal, compile, [''])
test('mc16', expect_broken_for(4370, ['ghci','hpc']), compile, [''])
test('EmptyDecls', normal, compile, [''])
......@@ -49,6 +49,7 @@ test('readFail042', normal, compile_fail, [''])
test('readFail043', normal, compile_fail, [''])
test('readFail044', normal, compile_fail, [''])
test('readFail046', normal, compile_fail, [''])
test('readFail047', normal, compile_fail, [''])
test('T3095', normal, compile_fail, [''])
test('T3153', normal, compile_fail, [''])
test('T3751', normal, compile_fail, [''])
......
readFail047.hs:6:5: parse error (possibly incorrect indentation)
......@@ -3,3 +3,5 @@ test('readRun002', normal, compile_and_run, [''])
test('readRun003', normal, compile_and_run, [''])
test('readRun004', expect_broken_for(1257, ['ghci']), compile_and_run, [''])
test('T1344', normal, compile_and_run, [''])
test('operator', normal, compile_and_run, [''])
test('operator2', normal, compile_and_run, [''])
module Main where
data Hash = Hash { (#) :: Int }
deriving (Show,Read)
main = do
let h = Hash 3
s = show h
x = read s :: Hash
y = show x
print h
putStrLn s
print x
putStrLn y
let h' = Hash { (#) = 3 }
s' = show h'
x' = read s' :: Hash
y' = show x'
print h'
putStrLn s'
print x'
putStrLn y'
Hash {(#) = 3}
Hash {(#) = 3}
Hash {(#) = 3}
Hash {(#) = 3}
Hash {(#) = 3}
Hash {(#) = 3}
Hash {(#) = 3}
Hash {(#) = 3}
TOP=../../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
test('queens',
[skip_if_fast,
extra_clean(['Main.hi', 'Main.o'])],
compile_and_run,
[''])
......@@ -345,3 +345,4 @@ test('T4969', normal, compile, [''])
test('T5120', normal, compile, [''])
test('mc18', expect_broken_for(4370, ['hpc']), compile, [''])
test('tc249', normal, compile, [''])
......@@ -236,4 +236,5 @@ test('mc24', normal, compile_fail, [''])
test('mc25', normal, compile_fail, [''])
test('tcfail207', normal, compile_fail, [''])
test('T5084', normal, compile_fail, [''])
test('tcfail208', normal, compile_fail, [''])
tcfail208.hs:4:19:
Could not deduce (Eq (m a)) arising from a use of `=='
from the context (Monad m, Eq a)
bound by the type signature for
f :: (Monad m, Eq a) => a -> m a -> Bool
at tcfail208.hs:4:1-23
Possible fix:
add (Eq (m a)) to the context of
the type signature for f :: (Monad m, Eq a) => a -> m a -> Bool
or add an instance declaration for (Eq (m a))
In the expression: (return x == y)
In an equation for `f': f x y = (return x == y)
include ($confdir ++ "/../singlefile-macros.T")
test "largeArray" {
expect pass
pretest_cleanup()
simple_build_Main()
$res = simple_run_main_no_stdin()
pass when contents(qualify("run.stdout"))
== contents(qualify("expect.stdout"))
fail when otherwise
}
import Array
main = print (((!1).inc.inc.inc.inc.inc.inc.inc.inc.inc.inc) a)
size = 60
a :: Array Int Integer
a = listArray (1,size) [1..]
inc a = accum (+) a [(i,1) | i <- [1..size]]
include ($confdir ++ "/../singlefile-macros.T")
test "getDCs" {
expect pass
pretest_cleanup()
simple_build_Main()
$res = simple_run_main_no_stdin()
-- sigh
$stuff = contents(qualify("run.stdout"))
pass when
$stuff contains "bin" &&
$stuff contains "lib" &&
$stuff contains "include"
fail when otherwise
}
import Directory
main = do
-- We can no longer first ask what the current dir is and
-- then read its contents, because the results thereof depend
-- on the current directory at the time the test run was
-- started, and that can't be assumed to be any particular value.
fs <- getDirectoryContents "/usr"
mapM_ (\f-> putStrLn (" "++f)) fs
include ($confdir ++ "/../singlefile-macros.T")
test "edecls" {
expect pass
pretest_cleanup()
simple_build_Main()
$res = simple_run_main_no_stdin()
pass when contents(qualify("run.stdout"))
== contents(qualify("expect.stdout"))
fail when otherwise
}
\ No newline at end of file
include ($confdir ++ "/../singlefile-macros.T")
test "list" {
expect pass
pretest_cleanup()
simple_build_Main()
$res = simple_run_main_no_stdin()
pass when contents(qualify("run.stdout"))
== contents(qualify("expected.stdout"))
fail when otherwise
}
test "succ" {
expect pass
pretest_cleanup()
simple_build_Main()
$res = simple_run_main_no_stdin()
pass when contents(qualify("run.stdout"))
== contents(qualify("expect.stdout"))
fail when otherwise
}
import Ratio
main = print [ 1, 4%(3::Int) .. 1 ]
main = print (succ (1.0e20))
include ($confdir ++ "/../singlefile-macros.T")
test "nplusk" {
expect pass
pretest_cleanup()
simple_build_Main()
$res = simple_run_main_no_stdin()
pass when contents(qualify("run.stdout"))
== contents(qualify("expect.stdout"))
fail when otherwise
}
import System
fib :: Integer -> Integer
fib 0 = 1
fib 1 = 1
fib (n+2) = fib (n+1) + fib n
--fib n = fib (n-1) + fib (n-2)
main = do args <- getArgs
if null args then
putStrLn ("fib 10 = " ++ show (fib 10))
else
mapM_ (\arg-> putStrLn ("fib "++arg++" = " ++ show (fib (read arg))))
args
include ($confdir ++ "/../singlefile-macros.T")
test "queens" {
expect pass
pretest_cleanup()
simple_build_Main()
$res = simple_run_main_no_stdin()
pass when contents(qualify("run.stdout"))
== contents(qualify("expect.stdout"))
fail when otherwise
}
include ($confdir ++ "/../singlefile-macros.T")
test "chr1" {
expect pass
pretest_cleanup()
simple_build_Main()
$res = simple_run_main_no_stdin()
pass when contents(qualify("run.stdout"))
== contents(qualify("expected.stdout"))
fail when otherwise
}
module Main where
main = let zzz = (toEnum (qqq 256)) :: Char
in putStrLn (show (zzz == zzz))
-- Only here to defeat potential compile-time evaluation of
-- toEnum applied to literal arg, in excessively clever compilers
qqq :: Int -> Int
qqq 0 = 0
qqq n = 1 + qqq (n-1)
include ($confdir ++ "/../std-macros.T")
expect pass
pretest_cleanup()
simple_build_Main()
$res = simple_run_main_no_stdin()
pass when
contents("run.stdout") contains "True"
fail when otherwise
include ($confdir ++ "/../singlefile-macros.T")
test "ok1" {
expect pass
pretest_cleanup()
$res = simple_compile_Main()
pass when contents(qualify("comp.stdout")) == ""
fail when otherwise
}
test "bad1" {
expect pass
pretest_cleanup()
$res = simple_compile_Main()
pass when
$tool contains "ghc"
&& contents(qualify("comp.stdout")) contains "Could not deduce"
pass when
$tool contains "nhc"
&& contents(qualify("comp.stdout")) contains "Couldn't simplify the context"
fail when otherwise
}
include ($confdir ++ "/../std-macros.T")
expect pass
pretest_cleanup()
$res = simple_compile_Main()
pass when
$tool contains "ghc"
&& contents("comp.stdout") contains "Could not deduce"
pass when
$tool contains "nhc"
&& contents("comp.stdout") contains "Couldn't simplify the context"
fail when otherwise
include ($confdir ++ "/../singlefile-macros.T")
test "empty" {
expect pass
pretest_cleanup()
simple_build_Main()
$res = simple_run_main_no_stdin()
pass when contents(qualify("run.stdout")) == "True\n"
fail when otherwise
}
test "operator" {
expect pass
pretest_cleanup()
simple_build_Main()
$res = simple_run_main_no_stdin()
pass when contents(qualify("run.stdout"))
== contents(qualify("expected.stdout"))
fail when otherwise
}
test "puns" {
expect pass
pretest_cleanup()
$res = simple_compile_Main()
pass when
$tool contains "ghc"
&& contents(qualify("comp.stdout")) contains "parse error on input"
pass when
$tool contains "nhc"
&& contents(qualify("comp.stdout")) contains "Named field puns"
fail when otherwise
}
test "showread" {
expect pass
pretest_cleanup()
simple_build_Main()
$res = simple_run_main_no_stdin()
pass when contents(qualify("run.stdout"))
== contents(qualify("expect.stdout"))
fail when otherwise
}
test "type" {
expect pass
pretest_cleanup()
simple_build_Main()
$res = simple_run_main_no_stdin()
pass when contents(qualify("run.stdout"))
== contents(qualify("expect.stdout"))
fail when otherwise
}
module Main where
data T = T1 Int Int Int
| T2 Float Float Float
f (T1 {}) = True
f (T2 {}) = False
main = print (f (T1 1 2 3))
module Main where
data Hash = Hash { (#) :: Int }
deriving (Show,Read)
main = do
putStrLn s
print (read s :: Hash)
where
s = show (Hash 3)
data Point = Point { x,y :: Int } deriving Show
f (Point {x,y}) = Point {x, y=y+1}
main = print (f (Point {x=0,y=0}))
include ($confdir ++ "/../std-macros.T")
expect pass
pretest_cleanup()
$res = simple_compile_Main()
pass when
$tool contains "ghc"
&& contents("comp.stdout") contains "parse error on input"
pass when
$tool contains "nhc"
&& contents("comp.stdout") contains "Named field puns"
fail when otherwise
(Foo{foo=1,bar=99},Foo{foo=(),bar=99},Foo{foo=True,bar=99})
(Foo{foo=1,bar=99},Foo{foo=(),bar=99},Foo{foo=True,bar=99})
data Foo a = Foo { foo :: a
, bar :: Int
} deriving (Show,Read)
up s t = s { foo = t }
obj = Foo { foo = 1 :: Int
, bar = 99
}
main = let expr = ( obj
, up obj ()
, obj {foo=True}
)
in do
print expr
print (((read.show) expr) `asTypeOf` expr)
(Foo{foo=1,bar=99},Foo{foo=(),bar=99},Foo{foo=True,bar=99})
data Foo a = Foo { foo :: a
, bar :: Int
} deriving Show
up s t = s { foo = t }
obj = Foo { foo = 1 :: Int
, bar = 99
}
main = print ( obj
, up obj ()
, obj {foo=True}
)
include ($confdir ++ "/../singlefile-macros.T")
test "show" {
expect pass
pretest_cleanup()
simple_build_Main()
$res = simple_run_main_no_stdin()
pass when contents(qualify("run.stderr"))
contains "Prelude.read: no parse"
fail when otherwise
}
import Numeric
main = do
s <- return ""
putStrLn (showFloat ((read s)::Float) "")
include ($confdir ++ "/../singlefile-macros.T")
test "qual" {
expect pass
pretest_cleanup()
$res = simple_compile_Main()
pass when contents(qualify("comp.stdout")) == ""
fail when otherwise
}
test "twiddle" {
expect pass
pretest_cleanup()
$res = simple_compile_Main()
pass when contents(qualify("comp.stdout")) == ""
fail when otherwise
}
\ No newline at end of file
module Test where
f = Just.let x = id in x
module Twiddle where
main = let foo@(~(x,y)) = (1,2)
in print foo
include ($confdir ++ "/../singlefile-macros.T")
test "fndecl" {
expect pass
pretest_cleanup()
simple_build_Main()
$res = simple_run_main()
pass when contents(qualify("run.stdout"))
== contents(qualify("expected.stdout"))
fail when otherwise
}
test "infix" {
expect pass
pretest_cleanup()
simple_build_Main()
$res = simple_run_main_no_stdin()
pass when contents(qualify("run.stdout"))
== contents(qualify("expect.stdout"))
fail when otherwise
}
test "local" {
expect pass
pretest_cleanup()
simple_build_Main()
$res = simple_run_main_no_stdin()
pass when contents(qualify("run.stdout"))
== contents(qualify("expect.stdout"))
fail when otherwise
}
test "minus" {
expect unknown -- should this compile or not?
pretest_cleanup()
simple_build_Main()
$res = simple_run_main_no_stdin()
pass when contents(qualify("run.stdout"))
== contents(qualify("expect.stdout"))
fail when otherwise
}
test "operator" {
expect pass
pretest_cleanup()
simple_build_Main()
$res = simple_run_main_no_stdin()
pass when contents(qualify("run.stdout"))
== contents(qualify("expect.stdout"))
fail when otherwise
}
module Main where
infixr 5 <>
(<>) :: (a -> Maybe b) -> (b -> Maybe c) -> (a -> Maybe c)
(m1 <> m2) a1 = case m1 a1 of
Nothing ->