Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mockup-generator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dosek-verification
mockup-generator
Commits
bdbe53d5
Commit
bdbe53d5
authored
Feb 1, 2017
by
Hans-Peter Deifel
Browse files
Options
Downloads
Patches
Plain Diff
compare: Add tests for json import
parent
ed4ebb32
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
osek-verification.cabal
+2
-0
2 additions, 0 deletions
osek-verification.cabal
src/Compare/JSON.hs
+3
-3
3 additions, 3 deletions
src/Compare/JSON.hs
test/Compare/JSONSpec.hs
+54
-0
54 additions, 0 deletions
test/Compare/JSONSpec.hs
test/Compare/MatchingSpec.hs
+1
-1
1 addition, 1 deletion
test/Compare/MatchingSpec.hs
with
60 additions
and
4 deletions
osek-verification.cabal
+
2
−
0
View file @
bdbe53d5
...
@@ -67,6 +67,7 @@ test-suite spec
...
@@ -67,6 +67,7 @@ test-suite spec
, ProtocolSpec
, ProtocolSpec
, Search.EpsilonEliminationSpec
, Search.EpsilonEliminationSpec
, Compare.MatchingSpec
, Compare.MatchingSpec
, Compare.JSONSpec
build-depends: base >= 4.8 && <4.10
build-depends: base >= 4.8 && <4.10
, osek-verification
, osek-verification
, hspec >= 2.2.3 && <2.3
, hspec >= 2.2.3 && <2.3
...
@@ -81,5 +82,6 @@ test-suite spec
...
@@ -81,5 +82,6 @@ test-suite spec
, here >= 1.2 && < 1.3
, here >= 1.2 && < 1.3
, mtl >= 2.2 && <2.3
, mtl >= 2.2 && <2.3
, utf8-string >= 1.0 && <1.1
, utf8-string >= 1.0 && <1.1
, fgl >= 5.5 && < 5.6
default-language: Haskell2010
default-language: Haskell2010
ghc-options: -Wall -fdefer-typed-holes -fno-warn-name-shadowing
ghc-options: -Wall -fdefer-typed-holes -fno-warn-name-shadowing
This diff is collapsed.
Click to expand it.
src/Compare/JSON.hs
+
3
−
3
View file @
bdbe53d5
...
@@ -4,9 +4,7 @@
...
@@ -4,9 +4,7 @@
{-# OPTIONS_GHC -Wno-orphans #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module
Compare.JSON
module
Compare.JSON
(
Graph
(
parseFile
)
where
,
parseFile
)
where
import
Data.Aeson
import
Data.Aeson
import
Data.Aeson.Types
(
typeMismatch
)
import
Data.Aeson.Types
(
typeMismatch
)
...
@@ -44,6 +42,8 @@ instance FromJSON E where
...
@@ -44,6 +42,8 @@ instance FromJSON E where
E
<$>
((
\
a
b
c
->
(
a
,
b
,
c
))
<$>
v
.:
"from"
<*>
v
.:
"to"
<*>
v
.:
"label"
)
E
<$>
((
\
a
b
c
->
(
a
,
b
,
c
))
<$>
v
.:
"from"
<*>
v
.:
"to"
<*>
v
.:
"label"
)
parseJSON
invalid
=
typeMismatch
"Edge"
invalid
parseJSON
invalid
=
typeMismatch
"Edge"
invalid
-- TODO Make more robust against input errors
-- E.g unknown notes in edges
mkGraph
::
[
NodeLabel
]
->
[(
NodeLabel
,
NodeLabel
,
EdgeLabel
)]
->
NodeLabel
->
Graph
NodeLabel
EdgeLabel
mkGraph
::
[
NodeLabel
]
->
[(
NodeLabel
,
NodeLabel
,
EdgeLabel
)]
->
NodeLabel
->
Graph
NodeLabel
EdgeLabel
mkGraph
nodes
labels
entry
=
mkGraph
nodes
labels
entry
=
let
let
...
...
This diff is collapsed.
Click to expand it.
test/Compare/JSONSpec.hs
0 → 100644
+
54
−
0
View file @
bdbe53d5
{-# LANGUAGE OverloadedStrings #-}
module
Compare.JSONSpec
(
spec
)
where
import
Test.Hspec
import
qualified
Codec.Binary.UTF8.String
as
UTF8
import
qualified
Data.ByteString.Lazy
as
BS
import
qualified
Data.Graph.Inductive
as
G
import
Data.Text
(
Text
)
import
qualified
Data.Set
as
S
import
Compare.JSON
import
Compare.Types
exampleJson
::
BS
.
ByteString
exampleJson
=
BS
.
pack
$
UTF8
.
encode
$
unlines
[
"{"
,
"
\"
nodes
\"
: ["
,
" {"
,
"
\"
id
\"
:
\"
ABB15
\"
,"
,
"
\"
runnable
\"
:
\"
TaskA
\"
"
,
" },"
,
" {"
,
"
\"
id
\"
:
\"
ABB42
\"
,"
,
"
\"
runnable
\"
:
\"
TaskB
\"
"
,
" }"
,
" ],"
,
"
\"
edges
\"
: ["
,
" {"
,
"
\"
from
\"
:
\"
ABB15
\"
,"
,
"
\"
to
\"
:
\"
ABB42
\"
,"
,
"
\"
label
\"
:
\"
syscall_a
\"
"
,
" }"
,
" ],"
,
"
\"
entry
\"
:
\"
ABB15
\"
"
,
"}"
]
spec
::
Spec
spec
=
describe
"parseFile"
$
it
"parses an example"
$
case
parseFile
exampleJson
::
Either
String
(
Graph
Text
Text
)
of
Left
err
->
expectationFailure
err
Right
g
->
let
nodes
=
S
.
fromList
$
map
snd
$
G
.
labNodes
(
graph
g
)
edges
=
map
(
\
(
n1
,
n2
,
l
)
->
(
G
.
lab
(
graph
g
)
n1
,
G
.
lab
(
graph
g
)
n2
,
l
))
$
G
.
labEdges
(
graph
g
)
entry
=
G
.
lab
(
graph
g
)
(
point
g
)
in
do
nodes
`
shouldBe
`
(
S
.
fromList
[
"ABB15"
,
"ABB42"
])
edges
`
shouldBe
`
[(
Just
"ABB15"
,
Just
"ABB42"
,
"syscall_a"
)]
entry
`
shouldBe
`
Just
"ABB15"
This diff is collapsed.
Click to expand it.
test/Compare/MatchingSpec.hs
+
1
−
1
View file @
bdbe53d5
...
@@ -6,7 +6,7 @@ import Test.QuickCheck
...
@@ -6,7 +6,7 @@ import Test.QuickCheck
import
qualified
Compare.Matching
as
M
import
qualified
Compare.Matching
as
M
spec
::
Spec
spec
::
Spec
spec
=
describe
"Matching"
$
do
spec
=
do
emptySpec
emptySpec
lookupSpec
lookupSpec
...
...
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