Permalink
Browse files

add support for sorted-maps

  • Loading branch information...
Jay Fields
Jay Fields committed Jun 4, 2012
1 parent d4029af commit 57f2db83261e1e599e47e619450df75daf1bdea3
Showing with 12 additions and 2 deletions.
  1. +9 −2 src/clojure/expectations.clj
  2. +3 −0 test/clojure/success/success_examples.clj
@@ -282,8 +282,15 @@
:message (when-let [messages (map-diff-message e a "")] (string-join "\n " messages))})))
(defmulti compare-expr (fn [e a str-e str-a]
- (cond
- (isa? e Throwable) ::expect-exception (instance? Throwable e) ::expected-exception (instance? Throwable a) ::actual-exception (fn? e) ::fn (::in-flag a) ::in (::interaction-flag e) ::interaction :default [(class e) (class a)])))
+
+ (cond
+ (isa? e Throwable) ::expect-exception
+ (instance? Throwable e) ::expected-exception
+ (instance? Throwable a) ::actual-exception
+ (fn? e) ::fn
+ (and (not (sorted? a)) (::in-flag a)) ::in
+ (and (not (sorted? e)) (::interaction-flag e)) ::interaction
+ :default [(class e) (class a)])))
(defmethod compare-expr :default [e a str-e str-a]
(if (= e a)
@@ -60,6 +60,9 @@
;; allow Double/NaN equality with in fn and list
(expect Double/NaN (in [1 Double/NaN]))
+;; sorted map equality
+(expect (sorted-map-by > 1 :a 2 :b) (sorted-map-by > 1 :a 2 :b))
+
;; macro expansion
(expect '(clojure.core/println 1 2 (println 100) 3)
(expanding (a-macro 1 2 (println 100) 3)))

0 comments on commit 57f2db8

Please sign in to comment.