Commit 25f7d5d5 authored by sewardj's avatar sewardj
Browse files

[project @ 2001-06-26 12:04:32 by sewardj]

Add deriving/ tests.
parent ca8f2364
include ($confdir ++ "/../vanilla-test.T")
-- Args to vtc are: extra compile flags
test "drv001" { vtc("") }
test "drv002" { vtc("") }
test "drv003" { vtc("") }
test "drv004" { vtc("") }
test "drv005" { vtc("") }
test "drv006" { vtc("") }
test "drv007" { vtc("") }
test "drv008" { vtc("") }
test "drv009" { vtc("") }
test "drv010" { vtc("") }
test "drv011" { vtc("") }
-- !!! canonical weird example for "deriving"
module ShouldSucceed where
data X a b
= C1 (T a)
| C2 (Y b)
| C3 (X b a)
deriving (Read, Show)
data Y b
= D1
| D2 (X Int b)
deriving (Read, Show)
data T a
= E1
instance Eq a => Show (T a) where
showsPrec = error "show"
instance Eq a => Read (T a) where
readsPrec = error "read"
module ShouldSucceed where
data Z a b
= C1 (T a)
| C2 (Z [a] [b])
deriving (Show, Read)
data T a
= E1
instance Eq a => Show (T a) where
showsPrec = error "show"
instance Eq a => Read (T a) where
readsPrec = error "read"
-- !!! This is the example given in TcDeriv
--
module ShouldSucceed where
data T a b
= C1 (Foo a) (Bar b)
| C2 Int (T b a)
| C3 (T a a)
deriving Eq
data Foo a = MkFoo Double a deriving ()
instance (Eq a) => Eq (Foo a)
data Bar a = MkBar Int Int deriving ()
instance (Ping b) => Eq (Bar b)
class Ping a
-- !!! simple example of deriving Ord and Eq simultaneously
--
module ShouldSucceed where
data Foo a b c
= C1 a Int
| C2 b Double
| C3 c String
deriving (Eq, Ord)
-- !!! simple example of deriving Enum
--
module ShouldSucceed where
data Foo = Foo1 | Foo2 | Foo3 | Foo4 | Foo5 | Foo6 | Foo7 | Foo8
deriving Enum
-- !!! simple examples of deriving Ix
--
module ShouldSucceed where
import Ix
data Foo = Foo1 | Foo2 | Foo3 | Foo4 | Foo5 | Foo6 | Foo7 | Foo8
deriving (Eq, Ord, Ix, Show)
data Bar a b = MkBar a Int b Integer a
-- !!! deriving Ord on d. type with a single nullary constructor.
-- (from ghc-2.10 panic - as reported by Sergey Mechveliani <mechvel@botik.ru>)
--
module ShouldSucceed where
data D = D deriving (Eq,Ord)
-- !!! deriving Ix on d. type with nullary constructors
module ShouldSucceed where
import Ix
data AD = A | B | C | D deriving (Show, Ord, Eq, Ix)
-- !!! deriving Ix on d. type with one constructor
module ShouldSucceed where
import Ix
data Pair a b = Pair a b deriving (Show, Ord, Eq, Ix)
-- !!! deriving Enum on d. type with nullary constructors
module ShouldSucceed where
data AD = A | B | C | D deriving (Enum)
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