Skip to content

Commit

Permalink
adjusts #'eagerly so record types are preserved - breaks an assertion…
Browse files Browse the repository at this point in the history
… as well

Per the discussion on the mailing list, the broken assertion is not a true
failure and can be resolved by rewriting it:
http://groups.google.com/group/midje/msg/2d6a8f21c8f55a01
  • Loading branch information
bmabey committed Jan 19, 2011
1 parent 01fce4d commit 9feb252
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/midje/util/laziness.clj
Expand Up @@ -16,9 +16,9 @@

(vector? form)
(m (vec (map eagerly form)))

(map? form)
(m (into (if (sorted? form) (sorted-map) {}) (map eagerly form)))
(m (into form (map eagerly form)))

(set? form)
(m (into (if (sorted? form) (sorted-set) #{}) (map eagerly form)))
Expand Down
5 changes: 5 additions & 0 deletions test/midje/util/t_laziness.clj
Expand Up @@ -42,6 +42,11 @@
eagered => #(identical? % odd?)
(:name (meta eagered)) => #(identical? % (:name (meta odd?)))))

(defrecord Foo [x y])
(fact "preserves record types"
(class (eagerly (Foo. 4 5))) => Foo
(Foo. 4 5) => (Foo. 4 5))

(fact "eagerly does NOT preserve identical? for collections even if they had no lazy seqs"
(let [lazied (with-meta '(1 2 3) {:original :metadata})
eagered (eagerly lazied)]
Expand Down

0 comments on commit 9feb252

Please sign in to comment.