From 211efb5d16c2796a132e5c2900de990eb48720f2 Mon Sep 17 00:00:00 2001 From: Steven Proctor Date: Sun, 11 Jan 2026 16:17:50 -0600 Subject: [PATCH] move form deftype to defrecord for easier set comparison deftype gives different object instances which causes comparisons of sets with different instances to fail, as it check the instance equality instead of value equality, which can be provided by using defrecord instead of deftype --- test/challenge/discrete_value_range_test.clj | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/test/challenge/discrete_value_range_test.clj b/test/challenge/discrete_value_range_test.clj index 3e3badc..5d42c0c 100644 --- a/test/challenge/discrete_value_range_test.clj +++ b/test/challenge/discrete_value_range_test.clj @@ -3,8 +3,8 @@ [clojure.test :refer [deftest testing is]] [challenge.discrete-value-range :as range])) -(deftype IntInclusiveDiscreteValueRange - [^int start ^int end] +(defrecord IntInclusiveDiscreteValueRange + [^int start ^int end] range/DiscreteValueRange (abuts [_this other] (or (= 1 (abs (- start (.end other)))) @@ -29,13 +29,10 @@ Object (toString [_this] - (str start ".." end)) - (equals [_this other] - (and (= start (.start other)) - (= end (.end other))))) + (str start ".." end))) (defn int-range-inclusive [start end] - (assert (<= start end)) + (assert (<= start end) (str "start : " start "; end: " end)) (->IntInclusiveDiscreteValueRange start end)) (defmethod range/->discrete-value-range :int-range-inclusive [_ start end]