Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
e94c75ae
Commit
e94c75ae
authored
Mar 30, 2009
by
simonpj
Browse files
Add tests for Trac
#246
and
#3126
parent
4e3058dc
Changes
5
Hide whitespace changes
Inline
Side-by-side
testsuite/tests/ghc-regress/deSugar/should_run/T246.hs
0 → 100644
View file @
e94c75ae
{-# LANGUAGE ScopedTypeVariables #-}
-- Test Trac #246
module
Main
where
import
Control.Exception
data
T
=
T
{
x
::
Bool
,
y
::
Bool
}
f
(
T
{
y
=
True
,
x
=
True
})
=
"Odd"
f
_
=
"OK"
g
(
T
{
x
=
True
,
y
=
True
})
=
"Odd2"
g
_
=
"Odd3"
funny
=
T
{
x
=
undefined
,
y
=
False
}
main
=
do
{
print
(
f
funny
)
-- Should work, because we test
-- y first, which fails, and falls
-- through to "OK"
;
Control
.
Exception
.
catch
(
print
(
g
funny
))
-- Should fail, because we test
(
\
(
_
::
SomeException
)
->
print
"caught"
)
-- x first, and hit "undefined"
}
testsuite/tests/ghc-regress/deSugar/should_run/T246.stdout
0 → 100644
View file @
e94c75ae
"OK"
"caught"
testsuite/tests/ghc-regress/deSugar/should_run/T3126.hs
0 → 100644
View file @
e94c75ae
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE OverloadedStrings #-}
module
Main
where
import
Data.String
-- {{{ Num literals
newtype
N
=
N
Int
deriving
(
Show
,
Eq
)
instance
Num
N
where
fromInteger
0
=
error
"0"
fromInteger
1
=
N
0
fromInteger
_
=
N
1
f
x
=
case
x
of
1
->
False
0
->
True
g
x
=
case
x
of
1
->
False
_
->
case
x
of
0
->
True
_
->
error
"No match"
testNum
=
do
print
$
g
(
N
0
)
print
$
f
(
N
0
)
-- }}}
-- {{{ IsString literals
newtype
S
=
S
String
deriving
Eq
instance
IsString
S
where
fromString
[]
=
error
"[]"
fromString
(
_
:
_
)
=
S
"."
fs
x
=
case
x
of
"."
->
False
""
->
True
gs
x
=
case
x
of
"."
->
False
_
->
case
x
of
""
->
True
_
->
error
"No match"
testIsString
=
do
print
$
gs
(
S
"."
)
print
$
fs
(
S
"."
)
-- }}}
main
=
do
{
testNum
;
testIsString
}
testsuite/tests/ghc-regress/deSugar/should_run/T3126.stdout
0 → 100644
View file @
e94c75ae
False
False
False
False
testsuite/tests/ghc-regress/deSugar/should_run/all.T
View file @
e94c75ae
...
...
@@ -26,3 +26,5 @@ test('dsrun020', normal, compile_and_run, [''])
test
('
dsrun021
',
normal
,
compile_and_run
,
[''])
test
('
dsrun022
',
normal
,
compile_and_run
,
[''])
test
('
dsrun023
',
normal
,
compile_and_run
,
[''])
test
('
T246
',
normal
,
compile_and_run
,
[''])
test
('
T3126
',
normal
,
compile_and_run
,
[''])
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment