diff --git a/src/cljc/matcher_combinators/core.cljc b/src/cljc/matcher_combinators/core.cljc index bb83d8f..573063d 100644 --- a/src/cljc/matcher_combinators/core.cljc +++ b/src/cljc/matcher_combinators/core.cljc @@ -246,7 +246,8 @@ (defn- type-preserving-mismatch [base-list values] (let [lst (into base-list values)] - (if (vector? base-list) + (if (or (vector? base-list) + (set? base-list)) lst (reverse lst)))) @@ -397,9 +398,11 @@ {::result/type :match ::result/value elements ::result/weight 0} - (match (->EqualsSeq (concat (:matched result) - (:unmatched result))) - (:elements result))))) + (update (match (->EqualsSeq (concat (:matched result) + (:unmatched result))) + (:elements result)) + ::result/value + #(with-mismatch-meta % :mismatch-sequence))))) (defn- match-any-order [expected actual subset?] (if-not (sequential? actual) @@ -445,7 +448,8 @@ "set"))] issue (update (match-any-order (vec expected) (vec actual) false) - ::result/value set))) + ::result/value + #(with-meta (set %) (meta %))))) (-base-name [_] (if accept-seq? 'set-equals 'equals))) (defrecord Prefix [expected] diff --git a/test/clj/matcher_combinators/config_test.clj b/test/clj/matcher_combinators/config_test.clj index f13b6a9..9296d39 100644 --- a/test/clj/matcher_combinators/config_test.clj +++ b/test/clj/matcher_combinators/config_test.clj @@ -26,6 +26,7 @@ (printer/as-string (list 'unexpected (printer/->ColorTag :red 1))))))) (deftest abbreviated-matched-output-test + (config/disable-abbreviation!) (is (= (str "[1\n 2\n {:a 2,\n :b [4 (mismatch (expected " (colorize/yellow 5) ") (actual " (colorize/red 6) "))],\n :c [2 [3 4]]}]\n") (printer/as-string (:matcher-combinators.result/value @@ -43,4 +44,22 @@ (printer/as-string (:matcher-combinators.result/value (c/match [1 2 {:a 2 :b [4 5] :c [2 [3 4]]}] - [1 2 {:a 2 :b [4 6] :c [2 [3 4]]}])))))) + [1 2 {:a 2 :b [4 6] :c [2 [3 4]]}]))))) + (config/disable-abbreviation!)) + +(deftest abbreviated-set-output-test + (config/disable-abbreviation!) + (is (= (str "[#{(unexpected " (colorize/red 1) ") 2}]\n") + (printer/as-string + (:matcher-combinators.result/value + (c/match [#{2}] [#{1 2}]))))) + + (config/enable-abbreviation!) + ;; TODO PLM: `[#{(unexpected 1)} ...]` feels not completely correct. + ;; shouldn't it be `[#{(unexpected 1) ...}]` or `[#{(unexpected 1)} ...]` + ;; instead? + (is (= (str "[#{(unexpected " (colorize/red 1) ")} ...]\n") + (printer/as-string + (:matcher-combinators.result/value + (c/match [#{2}] [#{1 2}]))))) + (config/disable-abbreviation!))