Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
parsec
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Glasgow Haskell Compiler
Packages
parsec
Commits
adffce21
Commit
adffce21
authored
1 year ago
by
Oleg Grenrus
Browse files
Options
Downloads
Patches
Plain Diff
Add many-try test
parent
647c5704
Branches
many-try-test
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
parsec.cabal
+1
-0
1 addition, 0 deletions
parsec.cabal
test/Bugs.hs
+2
-0
2 additions, 0 deletions
test/Bugs.hs
test/Bugs/Bug179.hs
+60
-0
60 additions, 0 deletions
test/Bugs/Bug179.hs
with
63 additions
and
0 deletions
parsec.cabal
+
1
−
0
View file @
adffce21
...
...
@@ -114,6 +114,7 @@ test-suite parsec-tests
Bugs.Bug6
Bugs.Bug9
Bugs.Bug35
Bugs.Bug179
Features
Features.Feature80
Features.Feature150
...
...
This diff is collapsed.
Click to expand it.
test/Bugs.hs
+
2
−
0
View file @
adffce21
...
...
@@ -9,10 +9,12 @@ import qualified Bugs.Bug2
import
qualified
Bugs.Bug6
import
qualified
Bugs.Bug9
import
qualified
Bugs.Bug35
import
qualified
Bugs.Bug179
bugs
::
[
TestTree
]
bugs
=
[
Bugs
.
Bug2
.
main
,
Bugs
.
Bug6
.
main
,
Bugs
.
Bug9
.
main
,
Bugs
.
Bug35
.
main
,
Bugs
.
Bug179
.
tests
]
This diff is collapsed.
Click to expand it.
test/Bugs/Bug179.hs
0 → 100644
+
60
−
0
View file @
adffce21
module
Bugs.Bug179
(
tests
)
where
import
Control.Applicative
(
Alternative
(
..
),
liftA2
,
(
<|>
))
import
Test.Tasty
(
testGroup
,
TestTree
)
import
Test.Tasty.HUnit
import
qualified
Control.Applicative
import
qualified
Text.Parsec
as
P
import
qualified
Text.Parsec.String
as
P
tests
::
TestTree
tests
=
testGroup
"many try (#179)"
[
testCase
"manyDefault"
$
examples
parser1
,
testCase
"C.Applicative"
$
examples
parser2
,
testCase
"Parsec"
$
examples
parser3
]
where
examples
p
=
do
res1
<-
parseString
p
$
unlines
[
" "
,
" "
,
"foo"
]
res1
@?=
"foo
\n
"
res2
<-
parseString
p
$
unlines
[
"bar"
]
res2
@?=
"bar
\n
"
res3
<-
parseString
p
$
unlines
[
" "
,
" "
,
" foo"
]
res3
@?=
" foo
\n
"
res4
<-
parseString
p
$
unlines
[
" bar"
]
res4
@?=
" bar
\n
"
parseString
::
P
.
Parser
String
->
String
->
IO
String
parseString
p
input
=
case
P
.
parse
p
""
input
of
Left
err
->
assertFailure
$
show
err
Right
str
->
return
str
parser1
::
P
.
Parser
String
parser1
=
emptyLines
*>
P
.
getInput
where
emptyLines
::
P
.
Parser
String
emptyLines
=
manyDefault
$
P
.
try
$
P
.
skipMany
(
P
.
satisfy
(
==
' '
))
*>
P
.
char
'
\n
'
parser2
::
P
.
Parser
String
parser2
=
emptyLines
*>
P
.
getInput
where
emptyLines
::
P
.
Parser
String
emptyLines
=
Control
.
Applicative
.
many
$
P
.
try
$
P
.
skipMany
(
P
.
satisfy
(
==
' '
))
*>
P
.
char
'
\n
'
parser3
::
P
.
Parser
String
parser3
=
emptyLines
*>
P
.
getInput
where
emptyLines
::
P
.
Parser
String
emptyLines
=
P
.
many
$
P
.
try
$
P
.
skipMany
(
P
.
satisfy
(
==
' '
))
*>
P
.
char
'
\n
'
-- many's default definition
manyDefault
::
Alternative
f
=>
f
a
->
f
[
a
]
manyDefault
v
=
many_v
where
many_v
=
some_v
<|>
pure
[]
some_v
=
liftA2
(
:
)
v
many_v
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment