-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add high-level helper for relaxing find
- Loading branch information
1 parent
5e7fe7b
commit 99b50ab
Showing
3 changed files
with
54 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
(ns macaw.util-test | ||
(:require | ||
[clojure.test :refer :all] | ||
[macaw.util :as u])) | ||
|
||
(def ^:private haystack | ||
{{:a 3 :b 2 :c 1} 2 | ||
{:a 3 :b nil :c 1} 3 | ||
{:a 1 :b 2 :c 3} 1}) | ||
|
||
(deftest cascading-find-test | ||
(testing "We ignore any suffix of degenerate keys" | ||
(doseq [x [{:a 1} | ||
{:a 1 :b 2} | ||
{:a 1 :b 2 :c 3} | ||
{:a 1 :b 2 :c 3 :d 4}]] | ||
(is (= [{:a 1 :b 2 :c 3} 1] | ||
(u/cascading-find haystack x [:a :b :c]))))) | ||
|
||
(testing "We need at least one non-degenerate key" | ||
(is (nil? (u/cascading-find haystack {} [:a :b :c])))) | ||
|
||
(testing "We don't ignore non-suffix degenerate keys" | ||
(doseq [x [{:a nil :b 2} | ||
{:a 1 :b nil :c 3} | ||
{:a nil :b 2 :c 3}]] | ||
(is (nil? | ||
(u/cascading-find haystack x [:a :b :c])))))) |