Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
153
Issues
153
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
7e4cff2c
Commit
7e4cff2c
authored
Feb 09, 2018
by
Mael NICOLAS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Arbitrary instance for ParseError
parent
9a19f5e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
0 deletions
+59
-0
Date.hs
src-test/Parsers/Date.hs
+27
-0
Types.hs
src-test/Parsers/Types.hs
+32
-0
No files found.
src-test/Parsers/Date.hs
0 → 100644
View file @
7e4cff2c
{-# LANGUAGE NoImplicitPrelude #-}
module
Parsers.Date
where
import
Gargantext.Prelude
import
Test.Hspec
import
Test.QuickCheck
import
Parsers.Types
import
Data.Either
(
Either
(
..
))
import
Data.Time
(
ZonedTime
(
..
))
import
Data.Text
(
pack
,
Text
)
import
Text.Parsec.Error
(
ParseError
)
import
Duckling.Time.Types
(
toRFC3339
)
import
Gargantext.Parsers.Date
(
fromRFC3339
)
fromRFC3339Inv
::
Either
ParseError
ZonedTime
->
Text
fromRFC3339Inv
(
Right
z
)
=
toRFC3339
z
fromRFC3339Inv
(
Left
pe
)
=
panic
.
pack
$
show
pe
testFromRFC3339
::
IO
()
testFromRFC3339
=
hspec
$
do
describe
"Test fromRFC3339: "
$
do
it
"is the inverse of Duckling's toRFC3339"
$
property
$
\
x
->
(
fromRFC3339
.
fromRFC3339Inv
)
x
==
(
x
::
Either
ParseError
ZonedTime
)
src-test/Parsers/Types.hs
0 → 100644
View file @
7e4cff2c
{-# LANGUAGE NoImplicitPrelude #-}
module
Parsers.Types
where
import
Gargantext.Prelude
import
Test.QuickCheck
import
Text.Parsec.Pos
import
Text.Parsec.Error
(
ParseError
(
..
),
Message
(
..
),
newErrorMessage
)
instance
Arbitrary
Message
where
arbitrary
=
do
msgContent
<-
arbitrary
oneof
$
return
<$>
[
SysUnExpect
msgContent
,
UnExpect
msgContent
,
Expect
msgContent
,
Message
msgContent
]
instance
Arbitrary
SourcePos
where
arbitrary
=
do
sn
<-
arbitrary
l
<-
arbitrary
c
<-
arbitrary
return
$
newPos
sn
l
c
instance
Arbitrary
ParseError
where
arbitrary
=
do
sp
<-
arbitrary
msg
<-
arbitrary
return
$
newErrorMessage
msg
sp
Write
Preview
Markdown
is supported
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