Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
quasar
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
Package Registry
Container 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
Jens Nolte
quasar
Commits
d34bd2d7
Commit
d34bd2d7
authored
4 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Add test for ObservablePriority
parent
7bcfa0ee
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/Qd/Observable/ObservablePrioritySpec.hs
+43
-0
43 additions, 0 deletions
test/Qd/Observable/ObservablePrioritySpec.hs
test/Spec.hs
+1
-2
1 addition, 2 deletions
test/Spec.hs
with
44 additions
and
2 deletions
test/Qd/Observable/ObservablePrioritySpec.hs
0 → 100644
+
43
−
0
View file @
d34bd2d7
module
Qd.Observable.ObservablePrioritySpec
where
import
Qd.Observable
import
Qd.Observable.ObservablePriority
(
ObservablePriority
)
import
qualified
Qd.Observable.ObservablePriority
as
OP
import
Control.Monad
(
void
)
import
Data.IORef
import
Test.Hspec
spec
::
Spec
spec
=
do
describe
"ObservablePriority"
$
parallel
$
do
it
"can be created"
$
do
void
$
OP
.
create
specify
"getValue returns the value with the highest priority"
$
do
(
op
::
ObservablePriority
Int
String
)
<-
OP
.
create
p2
<-
OP
.
insertValue
op
2
"p2"
getValue
op
`
shouldReturn
`
(
Just
"p2"
)
p1
<-
OP
.
insertValue
op
1
"p1"
getValue
op
`
shouldReturn
`
(
Just
"p2"
)
deregister
p2
getValue
op
`
shouldReturn
`
(
Just
"p1"
)
deregister
p1
getValue
op
`
shouldReturn
`
(
Nothing
)
it
"sends updates when its value changes"
$
do
result
<-
newIORef
[]
let
mostRecentShouldBe
=
(
head
<$>
readIORef
result
`
shouldReturn
`)
(
op
::
ObservablePriority
Int
String
)
<-
OP
.
create
_s
<-
subscribe
op
(
modifyIORef
result
.
(
:
))
readIORef
result
`
shouldReturn
`
([(
Current
,
Nothing
)])
p2
<-
OP
.
insertValue
op
2
"p2"
mostRecentShouldBe
(
Update
,
Just
"p2"
)
p1
<-
OP
.
insertValue
op
1
"p1"
mostRecentShouldBe
(
Update
,
Just
"p2"
)
deregister
p2
mostRecentShouldBe
(
Update
,
Just
"p1"
)
deregister
p1
mostRecentShouldBe
(
Update
,
Nothing
)
length
<$>
readIORef
result
`
shouldReturn
`
4
This diff is collapsed.
Click to expand it.
test/Spec.hs
+
1
−
2
View file @
d34bd2d7
main
::
IO
()
main
=
putStrLn
"Test suite not yet implemented"
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
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