Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
lambdaisland.deep-diff POC
  • Loading branch information
TristeFigure committed Oct 30, 2018
commit 8fe43bc4f1cd40b15147346ca8fa3927cfb006a5
7 changes: 5 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:deploy-repositories [["releases" :clojars]]
:plugins [[lein-localrepo "0.5.4"]]
:test-selectors
{:default (complement :intentionally-failing)
:yes-i-know-the-tests-are-supposed-to-fail :intentionally-failing}
:profiles {:dev {:dependencies [[org.clojure/clojure "1.8.0"]
:profiles {:dev {:dependencies [[org.clojure/clojure "1.9.0"]
[org.clojure/clojurescript "1.7.228"]
[org.seleniumhq.selenium/selenium-java "2.52.0"]
[com.codeborne/phantomjsdriver "1.2.1"]]
[com.codeborne/phantomjsdriver "1.2.1"]
[org.clojure/spec.alpha "0.2.176"]
[lambdaisland/deep-diff "0.0-8"]]
:plugins [[lein-cljsbuild "1.1.2"]]
:cljsbuild {:test-commands {"test" ["phantomjs" "dev-resources/test/phantom/run.js" "dev-resources/test/test.html"]}
:builds [{:id "test"
Expand Down
8 changes: 3 additions & 5 deletions src/pjstadig/humane_test_output.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns pjstadig.humane-test-output
(:use [clojure.test]
[pjstadig.util])
(:require [clojure.data :as data]
(:require [lambdaisland.deep-diff :as deep]
[clojure.pprint :as pp]))

(defn =-body
Expand All @@ -15,10 +15,8 @@
:expected a#, :actual more#})
(do-report {:type :fail, :message ~msg,
:expected a#, :actual more#,
:diffs (map vector
more#
(map #(take 2 (data/diff a# %))
more#))}))
:diffs (map #(vector % (deep/diff a# %))
more#)}))
result#)
`(throw (Exception. "= expects more than one argument"))))

Expand Down
18 changes: 7 additions & 11 deletions src/pjstadig/util.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#?(:clj (:use [clojure.test]))
(:require
#?@(:clj [[clojure.pprint :as pp]
[pjstadig.print :as p]]
[pjstadig.print :as p]
[lambdaisland.deep-diff :as deep]]
:cljs [[cljs.pprint :as pp :include-macros true]
[pjstadig.print :as p]
[cljs.test :refer [inc-report-counter! testing-vars-str testing-contexts-str get-current-env]]]))
Expand Down Expand Up @@ -45,21 +46,16 @@
(p/with-pretty-writer (fn []
(let [print-expected (fn [actual]
(p/rprint "expected: ")
(pp/pprint expected *out*)
(deep/pretty-print expected)
(p/rprint " actual: ")
(pp/pprint actual *out*)
(deep/pretty-print actual)
(p/clear))]
(if (seq diffs)
(doseq [[actual [a b]] diffs]
(doseq [[actual diff] diffs]
(print-expected actual)
(p/rprint " diff:")
(if a
(do (p/rprint " - ")
(pp/pprint a *out*)
(p/rprint " + "))
(p/rprint " + "))
(when b
(pp/pprint b *out*))
(p/rprint " ")
(deep/pretty-print diff)
(p/clear))
(print-expected actual))))))

Expand Down
5 changes: 5 additions & 0 deletions test/pjstadig/humane_test_output/formatting_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@

#?(:clj (deftest ^:intentionally-failing non-seq-actual
(clojure.test/report {:type :fail :expected 4 :actual 5} )))

(deftest test-deep-diff
(let [a [1 2 {:a 1 :b 2}]
b [1 0 {:a 1 :b 0 :c 3}]]
(is (= a b))))