Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (s/def ::obj-type #{:a :b})
- (s/def ::attribute int?)
- (s/def ::base-obj (s/keys :req-un [::obj-type ::attribute]))
- (s/def ::only-in-a #{"a"})
- (s/def ::only-in-b #{"b"})
- (defmulti obj-type :obj-type)
- (defmethod obj-type :a [_]
- (s/merge ::base-obj (s/keys :req-un [::only-in-a])))
- (defmethod obj-type :b [_]
- (s/merge ::base-obj (s/keys :req-un [::only-in-b])))
- (s/def ::obj (s/multi-spec obj-type :obj-type))
- (s/exercise ::obj 20 {::obj-type #(gen/return :a)})
- ; returns maps with both ":a" and ":b"
- (s/exercise ::base-obj 20 {::obj-type #(gen/return :a)})
- ; returns maps with only ":a"
- ; why does the generator work in the second example?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement