Last active
June 8, 2017 14:56
-
-
Save bhb/b617354b22cd0508d14ccbab4e6f5585 to your computer and use it in GitHub Desktop.
An case (admittedly, a corner case) where two values are equal, but are not equally valid
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
;; Admittedly, this is a weird spec designed to trigger this case. | |
;; I'm not sure if there are cases where this would realistically happen | |
(require '[clojure.spec.alpha :as s]) | |
(s/def :test/pairs (s/cat :p1 (s/spec (s/cat :k keyword? :v pos-int?)) :p2 any?)) | |
(let [m1 {:b -1 :a 1} | |
m2 {:a 1 :b -1}] | |
{:equal? (= (m1 m2)) | |
:equally-valid? (= | |
(s/valid? :test/pairs m1) | |
(s/valid? :test/pairs m2))}) | |
;; returns | |
;; {:equal? true, :equally-valid? false} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment