test(spec): state, multimethods, protocols — fix reify, get-method, hierarchies
Add spec suites for stateful refs (atoms/volatiles/delays/promises), multimethods (dispatch + hierarchies), and protocols/types/records. Bugs caught and fixed: - reify with multiple methods registered only the first (stepped i by 2 over one-element specs); now collects every method spec - get-method/methods/remove-method evaluated their arg to the dispatch fn, but a multimethod's methods live on its var — now resolve the var (get-method and methods are special forms; remove-method fixed). get-method/methods added. - no global hierarchy: 2-arg derive modified a throwaway, isa? was hardcoded false, parents missing, ancestors/descendants returned arrays (so contains? failed), and dispatch ignored derive. Now a global hierarchy backs the 1/2-arg derive/isa?/parents/ancestors/descendants (returning sets) and multimethod dispatch falls back to it. Corrected a phase5 port assertion that encoded the old isa? bug. conformance 218/218, jpm test green.
This commit is contained in:
parent
50d63d896f
commit
a24e9bfba0
7 changed files with 174 additions and 29 deletions
|
|
@ -6,9 +6,10 @@
|
|||
(print "22: hierarchy...")
|
||||
(let [ctx (init)]
|
||||
(assert (= true (ct-eval ctx "(map? (make-hierarchy))")) "make-hierarchy returns map")
|
||||
# 2-arity derive/isa? just returns nil/false (no global hierarchy)
|
||||
# 2-arity derive/isa? use the global hierarchy
|
||||
(ct-eval ctx "(derive ::square ::shape)")
|
||||
(assert (= false (ct-eval ctx "(isa? ::square ::shape)")) "isa? 2-arity always false"))
|
||||
(assert (= true (ct-eval ctx "(isa? ::square ::shape)")) "isa? 2-arity via global hierarchy")
|
||||
(assert (= true (ct-eval ctx "(isa? ::square ::square)")) "isa? reflexive"))
|
||||
(print " passed")
|
||||
|
||||
# 23. Multimethods — basic dispatch
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue