Skip to content

Commit

Permalink
🐛 Fix #35
Browse files Browse the repository at this point in the history
  • Loading branch information
circlespainter committed Feb 14, 2015
1 parent ec77715 commit b031936
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/main/clojure/co/paralleluniverse/pulsar/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,9 @@
clojure.lang.IFn
(invoke
[this x]
(.set dv x)
this))))
(if (.isDone dv)
nil
(do (.set dv x) this))))))
([]
(promise nil)))

Expand Down
9 changes: 5 additions & 4 deletions src/test/clojure/co/paralleluniverse/pulsar/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@
(join fiber)) => [0 1 2 3 4])

(facts "promises-promises"
(fact "When try to set promise twice, then throw exception"
(let [v (promise)]
(deliver v "hi!")
(deliver v "bye!")) => throws IllegalStateException)
(let [v (promise)]
(fact "When try to set promise twice, then return nil and the first value wins"
[(deliver v "hi!")
(deliver v "bye!")
(deref v)] => [v nil "hi!"]))
(fact "This complex promises test passes"
(let [v1 (promise)
v2 (promise)
Expand Down

0 comments on commit b031936

Please sign in to comment.