Permalink
Browse files

added failing future-fact around the thunked =streams=> work

  • Loading branch information...
1 parent a881a95 commit 33e5ee1b46a7c59ce43069bc33105fc115e2a3f3 @AlexBaranosky AlexBaranosky committed Apr 1, 2012
Showing with 19 additions and 3 deletions.
  1. +3 −3 src/midje/internal_ideas/fakes.clj
  2. +16 −0 test/as_documentation/t_streaming_prerequisites.clj
View
6 src/midje/internal_ideas/fakes.clj
@@ -38,7 +38,7 @@
;;; Potential transformations of the right-hand-side of fakes
-(defn on-demand
+(defn- on-demand
"Produce value of next thunk on each successive call."
[thunks]
(let [the-stream (atom thunks)]
@@ -56,8 +56,8 @@
(defmethod updated-rhs (name =streams=>) [arrow rhs]
(pred-cond rhs
- vector? `(repeatedly (on-demand (to-thunks ~rhs)))
- quoted-list-form? `(repeatedly (on-demand (to-thunks ~(second rhs))))
+ vector? `(repeatedly (#'on-demand (to-thunks ~rhs)))
+ quoted-list-form? `(repeatedly (#'on-demand (to-thunks ~(second rhs))))
seq rhs
:else (throw (user-error
"This form doesn't look like a valid right-hand-side for =streams=>:"
View
16 test/as_documentation/t_streaming_prerequisites.clj
@@ -175,3 +175,19 @@
(throw (Exception. "shorter"))
(throw (Exception. "i am long")) ]))
+
+;; Seems like a simpler way to get a similar failure as the above
+
+;; -- is this related to the way Clojure wraps exceptions in Runtime exceptions?
+;; -- I'm not sure under which circumstances said wrapping happens
+
+(defn a [])
+(defn b [] (a) (a) (a))
+
+(future-fact "prerequisites can throw throwables using =streams=>"
+ (b) => (throws Exception "foo")
+ (provided
+ (a) =streams=> [:no-problem
+ :fine
+ (throw (Exception. "foo"))
+ (throw (Exception. "bar"))]))

0 comments on commit 33e5ee1

Please sign in to comment.