https://github.com/steenhansen/clojure-text-diff
Colored text diffs for Clojure tests
https://github.com/steenhansen/clojure-text-diff
Last synced: about 1 year ago
JSON representation
Colored text diffs for Clojure tests
- Host: GitHub
- URL: https://github.com/steenhansen/clojure-text-diff
- Owner: steenhansen
- License: mit
- Created: 2019-11-05T05:00:25.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-28T05:44:20.000Z (over 6 years ago)
- Last Synced: 2025-03-25T04:36:13.814Z (over 1 year ago)
- Language: Clojure
- Homepage:
- Size: 227 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### Rational
The Clojure function 'text-diff/are-vars-eq' helps to quickly show small differences during testing with large bodies of html, convoluted maps/sets/lists/vectors, and unordered maps/sets. When unequal actual and expected values are tested, a short description of the similarities and differences are printed in the REPL. First, leading identical sections are displayed, followed by differences, and then finally identical ending sections.
### How to use
```
;; clojure test file
(ns my-test-ns
(:require [clojure.test :refer [is]])
(:require [text-diff :refer [are-vars-eq]]))
(deftest test-html-values []
(let [actual-value "DIFFERENT"
expected-value "different"
[diff-actual diff-expected] (are-vars-eq actual-value expected-value)]
(is (= diff-actual diff-expected)))
)
```
```
;; repl output
|START|""
|DIFF1|"e>DIFFERENT"
|DIFF2|"e>different"
| END|""
expected (= diff-actual diff-expected)
actual (not (= "DIFFERENT" "different"))
false
```
###Examples

---

---

---

---

---

---

---
Odd string behavior that is to be expected from string differences inside maps/sets/lists/vectors. Quote delimiters cause extra blank spaces because variable types are not taken into account.
