Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TrevouxGrammar
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alice Brenon
TrevouxGrammar
Commits
b282bde7
Commit
b282bde7
authored
4 years ago
by
Alice Brenon
Browse files
Options
Downloads
Patches
Plain Diff
Draft tests
parent
6967dbd4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/ExtractMetadata.hs
+31
-0
31 additions, 0 deletions
test/ExtractMetadata.hs
test/Toolbox.hs
+28
-0
28 additions, 0 deletions
test/Toolbox.hs
trevouxGrammar.cabal
+13
-0
13 additions, 0 deletions
trevouxGrammar.cabal
with
72 additions
and
0 deletions
test/ExtractMetadata.hs
0 → 100644
+
31
−
0
View file @
b282bde7
{-# LANGUAGE OverloadedStrings #-}
module
ExtractMetadata
(
tests
)
where
import
Data.Attoparsec.Text
(
Parser
,
parseOnly
)
import
Data.Text
as
Text
(
Text
,
pack
)
import
Distribution.TestSuite
(
Test
,
testGroup
)
import
Text.Encyclopedia.Article
(
body_
)
import
Toolbox
(
simpleTest
)
import
Text.Printf
(
printf
)
checkAttoparsec
::
(
Show
a
,
Eq
a
)
=>
(
String
,
Parser
a
,
Text
,
Either
String
a
)
->
Test
checkAttoparsec
(
what
,
parser
,
input
,
expected
)
=
simpleTest
(
what
,
parseOnly
parser
input
,
expected
)
testBodyGrammar
::
Test
testBodyGrammar
=
testGroup
"body"
$
checkAttoparsec
<$>
[
(
"Positive"
,
body_
,
positive
,
Right
positive
)
,
(
"Negative"
,
body_
,
Text
.
pack
negative
,
errorMessage
)
]
where
positive
=
"Une phrase commence par une majuscule."
negative
=
"pas par une minuscule"
errorMessage
=
Left
.
printf
"Failed reading: body (got «%s…»)"
$
take
20
negative
tests
::
IO
[
Test
]
tests
=
pure
[
testBodyGrammar
]
This diff is collapsed.
Click to expand it.
test/Toolbox.hs
0 → 100644
+
28
−
0
View file @
b282bde7
{-# LANGUAGE NamedFieldPuns #-}
module
Toolbox
(
SimpleTest
,
simpleTest
)
where
import
Distribution.TestSuite
(
Progress
(
..
),
Result
(
..
),
Test
(
..
),
TestInstance
(
..
)
)
import
Text.Printf
(
printf
)
type
SimpleTest
a
=
(
String
,
a
,
a
)
simpleTest
::
(
Show
a
,
Eq
a
)
=>
SimpleTest
a
->
Test
simpleTest
(
name
,
actual
,
expected
)
=
Test
$
TestInstance
{
run
=
check
name
actual
expected
,
name
,
tags
=
[]
,
options
=
[]
,
setOption
=
\
_
_
->
Left
"No option available in this simple test"
}
check
::
(
Show
a
,
Eq
a
)
=>
String
->
a
->
a
->
IO
Progress
check
name
actual
expected
|
actual
==
expected
=
pure
.
Finished
$
Pass
|
otherwise
=
do
printf
"Expected %s but got %s
\n
"
(
show
expected
)
(
show
actual
)
pure
.
Finished
$
Fail
name
This diff is collapsed.
Click to expand it.
trevouxGrammar.cabal
+
13
−
0
View file @
b282bde7
...
@@ -44,3 +44,16 @@ executable parseTrevoux
...
@@ -44,3 +44,16 @@ executable parseTrevoux
, text
, text
hs-source-dirs: app
hs-source-dirs: app
default-language: Haskell2010
default-language: Haskell2010
test-suite extractMetadata
type: detailed-0.9
test-module: ExtractMetadata
other-modules: Toolbox
build-depends: attoparsec
, base >=4.11 && <4.13
, Cabal
, text
, trevouxGrammar
hs-source-dirs: test
ghc-options: -Wall
default-language: Haskell2010
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