czan / stateful-check

Stateful generative testing in clojure
MIT License
122 stars 11 forks source link

Implement toString method on root and lookup vars #17

Closed r0man closed 1 year ago

r0man commented 1 year ago

Hi @czan,

At the moment root and lookup vars are shown a bit cryptic in the CIDER Inspector.

{:x (sv/->RootVar "1")
 :y (get (sv/->RootVar "1") :abc)}

The above map with a root and a lookup var is shown in the following way:

Class: clojure.lang.PersistentArrayMap

--- Contents:
  :x = stateful_check.symbolic_values.RootVar@31
  :y = stateful_check.symbolic_values.LookupVar@5cb567e4

This is because there is no toString method defined for these custom types. CIDER uses the Orchard library to inspect values and root and lookup vars end up being printed here:

https://github.com/clojure-emacs/orchard/blob/master/src/orchard/inspect.clj#L299

With the toString method implemented in the RootVar and LookupVar types, instances of those types are now shown in the following way in the CIDER Inspector:

Class: clojure.lang.PersistentArrayMap

--- Contents:
  :x = #<1>
  :y = (get #<1> :abc)

An alternative would be specialize the inspect-value multi method of Orchard for those types, but I think the toString is good enough and generally useful.

czan commented 1 year ago

Sorry for the delay looking at this, @r0man. It looks good! You made the right decision to not add to inspect-value. :+1:

r0man commented 1 year ago

Hi @czan, no worries. Thanks for merging it.