Skip to content

Commit

Permalink
monad: zap a bug with top-level put-state in monad runners
Browse files Browse the repository at this point in the history
  • Loading branch information
neshtea committed May 8, 2024
1 parent 0c05d97 commit 34ce0a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/active/clojure/monad.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@
[state state]

(put-state!? m)
[nil state]
[nil (put-state-state m)]

:else
(let [res (run-command run env state m)]
Expand Down Expand Up @@ -558,7 +558,7 @@
[state state]

(put-state!? m)
[nil state]
[nil (put-state-state m)]

:else
(let [res (run-command run env state m)]
Expand Down
8 changes: 8 additions & 0 deletions test/active/clojure/monad_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,14 @@
(put-state! {:x 'bar})
(return x))))))

(deftest put-state-test
(is (= [nil 42]
(run-free-reader-state-exception (null-monad-command-config {} {})
(put-state! 42))))
(is (= [nil 42]
(run-monadic (null-monad-command-config {} {})
(put-state! 42)))))

(deftest null-config
(let [c (null-monad-command-config nil nil)]
(is (unknown-command? ((monad-command-config-run-command c)
Expand Down

0 comments on commit 34ce0a5

Please sign in to comment.