Finishing the last commit, which traded a simpler definition for noisier call
sites: deleting the arity ladders left `(symbol/resolver sym st pal/index-of
nil nil)` at twenty-odd places, and two trailing nils tell a reader nothing
except to go and count positions.
The ladder was a symptom. The disease is five positional parameters, and the
split that matters is which of them are OPTIONAL:
store, palette positional, because neither is optional. A dense channel
cannot be read without the store it names — that is the
crash two commits ago — and every op carries a colour.
pose-tracks one call site, in `clip/resolver`'s own recursion
source/picture-fps two call sites
So the last three become one `opts` map, and the common call loses a nil. The
point is not the nil: it is that the sixth option, whenever it arrives, is a
key at one call site rather than a nil at fifty.
`clip/resolver` also had `sid` FOURTH, behind two arguments that say nothing
about which symbol is being resolved. It is second now, beside the clip it is
in: `(clip/resolver c :main store pal/index-of nil)`.
62 call sites rewritten by parsing the forms rather than by regex, because
`clip/resolver`'s arguments move past each other and a regex cannot see that.
An earlier attempt at this dropped `palette` on the floor and still compiled
at 62 sites — it only surfaced as an arity error, so if that had been a
same-arity mistake the tests would have been the last line of defence.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
35 lines
1.7 KiB
Clojure
35 lines
1.7 KiB
Clojure
(ns arthur.domain.paint-test
|
|
(:require [cljs.test :refer [deftest is]]
|
|
[arthur.demo :as demo]
|
|
[arthur.domain.channel :as channel]
|
|
[arthur.domain.leaf :as leaf]
|
|
[arthur.domain.node :as node]
|
|
[arthur.domain.paint :as paint]
|
|
[arthur.domain.palette :as pal]
|
|
[arthur.domain.symbol :as symbol]))
|
|
|
|
(defn- geometry [clip]
|
|
(get-in clip [:symbols :main :nodes :paint-test :channels paint/geometry]))
|
|
|
|
(deftest drawing-keys-hold-and-tween-on-the-symbol-clock
|
|
(let [a [10 10 30 10 20 30]
|
|
c0 (paint/new-shape demo/clip :main :paint-test 3 a :brow)
|
|
c1 (paint/add-key c0 :main :paint-test 9)
|
|
c2 (paint/set-vertex c1 :main :paint-test 9 0 [22 10])
|
|
c3 (paint/add-key c2 :main :paint-test 15)
|
|
c4 (paint/set-vertex c3 :main :paint-test 15 0 [34 10])
|
|
held (geometry c4)
|
|
mixed-clip (update-in c4 [:symbols :main :nodes :paint-test]
|
|
node/set-segment-interp paint/geometry 9 :linear)
|
|
mixed (geometry mixed-clip)]
|
|
(is (= [3 229] (get-in c2 [:symbols :main :nodes :paint-test :span])))
|
|
(is (= a (channel/value-at held 8 nil)))
|
|
(is (= 10 (first (channel/value-at held 8 nil))))
|
|
(is (= 22 (first (channel/value-at held 9 nil))))
|
|
(is (= 10 (first (channel/value-at mixed 6 nil))) "the first gap cuts")
|
|
(is (= 28 (first (channel/value-at mixed 12 nil))) "the second gap tweens")
|
|
(is (empty? (channel/problems mixed)))
|
|
;; The demo's root is exposed on 2s. Paint at frame 3 must still appear at 3.
|
|
(is (some #(= :paint-test (:node %))
|
|
(symbol/eval-frame (get-in c2 [:symbols :main]) 3 nil pal/index-of nil)))
|
|
(is (= mixed-clip (leaf/clip :c1 (leaf/leaves :c1 mixed-clip))))))
|