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
8b263600
Commit
8b263600
authored
3 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Add more tests
parent
c0372cc5
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
src/Quasar/Disposable.hs
+2
-1
2 additions, 1 deletion
src/Quasar/Disposable.hs
test/Quasar/DisposableSpec.hs
+31
-0
31 additions, 0 deletions
test/Quasar/DisposableSpec.hs
with
33 additions
and
1 deletion
src/Quasar/Disposable.hs
+
2
−
1
View file @
8b263600
...
...
@@ -273,7 +273,8 @@ collectGarbage resourceManager = go >> traceIO "gc: completed"
traceIO
"gc: change detected"
-- Check entries for completion. Completion will be queried with `entryIsEmpty` during the next STM transaction.
-- Checking entries for completion has to be done in IO.
-- Completion is then queried with `entryIsEmpty` during the following STM transaction.
checkEntries
=<<
atomically
(
readTVar
entriesVar'
)
traceIO
"gc: entries checked"
...
...
This diff is collapsed.
Click to expand it.
test/Quasar/DisposableSpec.hs
+
31
−
0
View file @
8b263600
module
Quasar.DisposableSpec
(
spec
)
where
import
Control.Exception
import
Control.Concurrent
import
Control.Monad
(
void
)
import
Prelude
...
...
@@ -7,6 +8,11 @@ import Test.Hspec
import
Quasar.Awaitable
import
Quasar.Disposable
data
TestException
=
TestException
deriving
(
Eq
,
Show
)
instance
Exception
TestException
spec
::
Spec
spec
=
parallel
$
do
describe
"Disposable"
$
do
...
...
@@ -36,6 +42,13 @@ spec = parallel $ do
withResourceManager
\
resourceManager
->
do
attachDisposable
resourceManager
noDisposable
it
"can attach an disposable"
$
do
withResourceManager
\
resourceManager
->
do
avar
<-
newAsyncVar
::
IO
(
AsyncVar
()
)
attachDisposable
resourceManager
$
alreadyDisposing
avar
putAsyncVar_
avar
()
pure
()
::
IO
()
it
"can dispose an awaitable that is completed asynchronously"
$
do
avar
<-
newAsyncVar
::
IO
(
AsyncVar
()
)
void
$
forkIO
$
do
...
...
@@ -44,3 +57,21 @@ spec = parallel $ do
withResourceManager
\
resourceManager
->
do
attachDisposable
resourceManager
(
alreadyDisposing
avar
)
it
"can call a trivial dispose action"
$
do
withResourceManager
\
resourceManager
->
attachDisposeAction
resourceManager
$
pure
$
pure
()
pure
()
::
IO
()
it
"can call a dispose action"
$
do
withResourceManager
\
resourceManager
->
do
avar
<-
newAsyncVar
::
IO
(
AsyncVar
()
)
attachDisposeAction
resourceManager
$
toAwaitable
avar
<$
putAsyncVar_
avar
()
pure
()
::
IO
()
it
"re-throws an exception from a dispose action"
$
do
shouldThrow
do
withResourceManager
\
resourceManager
->
attachDisposeAction
resourceManager
$
throwIO
$
TestException
\
TestException
->
True
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