mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 09:42:01 +00:00
♻️ Reindent the harness undo check and transform op
Whitespace only, as the formatter wants it after the last changes to same-state? and the transform op of the generator. Harness only; the benchmark is not run. Also in this commit: - Record the frontend golden master of case AY again. The undo and redo checks compare the tokens library by its exported content, so the golden master writes it key by key; the JVM golden master of case AY was recorded again for that, and the frontend one is now too. Same values, written differently. - The harness changes that check the next commit, "Grow a track for a grid copy's new child and keep it at sync". AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
33a8b09362
commit
65f548e437
@ -204,22 +204,22 @@
|
||||
(and (#{:flip-x :flip-y} key) (#{:group :bool} (:type expected))
|
||||
(contains? expected :parent-id))
|
||||
(same-state? (cond-> (get expected key)
|
||||
(and (= :points key) (= :bool (:type expected)) (contains? expected :parent-id))
|
||||
corner-order)
|
||||
(cond-> (get actual key)
|
||||
(and (= :points key) (= :bool (:type expected)) (contains? expected :parent-id))
|
||||
corner-order)
|
||||
;; a bool or path stores its segments in single precision, and
|
||||
;; a bool or group computes its bounds again from its children
|
||||
(if (and (contains? expected :parent-id) (#{:bool :path :group} (:type expected)))
|
||||
(max tolerance 1e-4)
|
||||
tolerance)
|
||||
(or geometry?
|
||||
(and (contains? expected :parent-id)
|
||||
(or (contains? #{:x :y :width :height :rotation :points
|
||||
:selrect :transform :transform-inverse} key)
|
||||
;; the segments of a bool or path are its geometry
|
||||
(and (= :content key) (#{:bool :path} (:type expected)))))))))
|
||||
(and (= :points key) (= :bool (:type expected)) (contains? expected :parent-id))
|
||||
corner-order)
|
||||
(cond-> (get actual key)
|
||||
(and (= :points key) (= :bool (:type expected)) (contains? expected :parent-id))
|
||||
corner-order)
|
||||
;; a bool or path stores its segments in single precision, and
|
||||
;; a bool or group computes its bounds again from its children
|
||||
(if (and (contains? expected :parent-id) (#{:bool :path :group} (:type expected)))
|
||||
(max tolerance 1e-4)
|
||||
tolerance)
|
||||
(or geometry?
|
||||
(and (contains? expected :parent-id)
|
||||
(or (contains? #{:x :y :width :height :rotation :points
|
||||
:selrect :transform :transform-inverse} key)
|
||||
;; the segments of a bool or path are its geometry
|
||||
(and (= :content key) (#{:bool :path} (:type expected)))))))))
|
||||
(keys expected))
|
||||
|
||||
(and (sequential? expected) (sequential? actual) (= (count expected) (count actual)))
|
||||
|
||||
@ -821,11 +821,11 @@
|
||||
(when-not (and (#{:width :height} action)
|
||||
(= :bool (:type shape)) (:shape-ref shape))
|
||||
(n/transform-shape target action
|
||||
(case action
|
||||
:move [(* 5 (inc (mod value 4))) (* -3 (inc (mod value 3)))]
|
||||
(:width :height) (+ 80 (* 20 (mod value 6)))
|
||||
:rotate (* 45 (inc (mod value 4)))
|
||||
nil))))
|
||||
(case action
|
||||
:move [(* 5 (inc (mod value 4))) (* -3 (inc (mod value 3)))]
|
||||
(:width :height) (+ 80 (* 20 (mod value 6)))
|
||||
:rotate (* 45 (inc (mod value 4)))
|
||||
nil))))
|
||||
:library-edit (n/change-property target property value)
|
||||
:library-add-child (n/add-child target (keyword (str "library-generated-" (count (:applied situation))))
|
||||
:width 20 :height 20 :x 10 :y 10)
|
||||
@ -1287,7 +1287,7 @@
|
||||
nil))
|
||||
(case kind
|
||||
:apply-token (when-not (n/has-token? (tm/shape-by-id after (get-in resolved [:shape :id]))
|
||||
(:token-name resolved) (:token-value resolved))
|
||||
(:token-name resolved) (:token-value resolved))
|
||||
(oracle/fail :I9 {:phase :requested-token :token (:token-name resolved)}))
|
||||
:unapply-token (when (seq (n/token-corners (tm/shape-by-id after (get-in resolved [:shape :id]))
|
||||
(:token-name resolved)))
|
||||
|
||||
@ -270,8 +270,16 @@
|
||||
;; inherited tracks that shrink move or shorten the cells
|
||||
shrunk? (and prior context
|
||||
(or (< (:rows context) (:rows prior)) (< (:columns context) (:columns prior))))
|
||||
;; a default cell past the shrunk tracks gives its children back, to
|
||||
;; take a free cell or a grown track; the others are fitted
|
||||
beyond? (fn [cell]
|
||||
(and (= :auto (:position cell))
|
||||
(= 1 (:row-span cell) (:column-span cell))
|
||||
(contains? #{nil :auto} (:align-self cell))
|
||||
(contains? #{nil :auto} (:justify-self cell))
|
||||
(or (> (:row cell) (:rows context)) (> (:column cell) (:columns context)))))
|
||||
cells (cond
|
||||
shrunk? (fit-cells trimmed (:rows context) (:columns context)
|
||||
shrunk? (fit-cells (into [] (remove beyond?) trimmed) (:rows context) (:columns context)
|
||||
(or (:direction context) (:layout-grid-dir shape) :row))
|
||||
context (extend-cells trimmed prior context)
|
||||
:else trimmed)
|
||||
|
||||
@ -825,8 +825,18 @@
|
||||
(or (ctf/find-ref-shape file container libraries shape :include-deleted? true) main)
|
||||
main)
|
||||
expected (comparable-values source shape group)
|
||||
actual (comparable-values shape shape group)]]
|
||||
(when-not (= expected actual)
|
||||
actual (comparable-values shape shape group)
|
||||
;; a grid grows default tracks after its last along its flow
|
||||
;; to hold children without a free slot
|
||||
grown? (and (= group (if (= :column (:layout-grid-dir shape))
|
||||
:layout-grid-rows :layout-grid-columns))
|
||||
(let [wanted (vec (get expected group))
|
||||
tracks (vec (get actual group))]
|
||||
(and (> (count tracks) (count wanted))
|
||||
(= wanted (subvec tracks 0 (count wanted)))
|
||||
(every? #(= {:type :flex :value 1} %)
|
||||
(subvec tracks (count wanted))))))]]
|
||||
(when-not (or (= expected actual) grown?)
|
||||
(fail :I4 {:shape (:name shape) :group group
|
||||
:expected expected :actual actual})))
|
||||
(when (= :text (:type shape))
|
||||
|
||||
@ -77,10 +77,10 @@
|
||||
{:transcript " {:component \"main\", :id sync-main-component}\n {:variant-set \"vset\", :variant-id sync-vset-vcontainer, :count 2}\n {:component \"main\", :level 0, :outer sync-main-outercomp-0}\n {:component \"main\", :copy sync-main-copyhead-0}\n {:target #fn, :property :fills, :value \"#00ff00\"}\n {:action :shortcut, :params {:kind :create-component, :targets [#fn #fn]}, :component-ids [9 10]}", :states ["df9a042b9d59d699" "cc394d17823fd4a0" "c3e08163f30218ee"]}
|
||||
{:transcript " {:component \"main\", :id sync-main-component}\n {:variant-set \"vset\", :variant-id sync-vset-vcontainer, :count 2}\n {:component \"main\", :level 0, :outer sync-main-outercomp-0}\n {:component \"main\", :copy sync-main-copyhead-0}\n {:target #fn, :property :fills, :value \"#00ff00\"}\n {:action :shortcut, :params {:kind :duplicate, :targets [#fn #fn]}, :component-ids [9 10]}", :states ["df9a042b9d59d699" "cc394d17823fd4a0" "c3e08163f30218ee"]}]
|
||||
:case-ay-token-on-a-main-reaches-copies
|
||||
[{:transcript " {:component \"main\", :id sync-main-component}\n {:tokens [[\"radius.s\" 10] [\"radius.l\" 30]]}\n {:component \"main\", :copy sync-main-copyhead-0}\n {:target #fn, :token-name \"radius.s\", :value 10}\n {:target #fn, :token-name \"radius.l\", :value 30}\n \n {:target #fn, :token-name \"radius.l\"}", :states ["04cddffca776d7fb" "24756b13d210f3a5" "8e8c0c21d4a0638b" "f656f9c8188793cf"]}
|
||||
{:transcript " {:component \"main\", :id sync-main-component}\n {:tokens [[\"radius.s\" 10] [\"radius.l\" 30]]}\n {:component \"main\", :copy sync-main-copyhead-0}\n {:target #fn, :token-name \"radius.s\", :value 10}\n {:target #fn, :token-name \"radius.l\", :value 30}\n \n one-of -> ", :states ["04cddffca776d7fb" "24756b13d210f3a5" "8fb17ce46cb883c8"]}
|
||||
{:transcript " {:component \"main\", :id sync-main-component}\n {:tokens [[\"radius.s\" 10] [\"radius.l\" 30]]}\n {:component \"main\", :copy sync-main-copyhead-0}\n one-of -> \n {:target #fn, :token-name \"radius.l\", :value 30}\n \n {:target #fn, :token-name \"radius.l\"}", :states ["d943d9831136267d" "ae544068bc050c2a" "458ba8e9225d9ae7"]}
|
||||
{:transcript " {:component \"main\", :id sync-main-component}\n {:tokens [[\"radius.s\" 10] [\"radius.l\" 30]]}\n {:component \"main\", :copy sync-main-copyhead-0}\n one-of -> \n {:target #fn, :token-name \"radius.l\", :value 30}\n \n one-of -> ", :states ["d943d9831136267d" "b97f65e9e0e4e3c7"]}]
|
||||
[{:transcript " {:component \"main\", :id sync-main-component}\n {:tokens [[\"radius.s\" 10] [\"radius.l\" 30]]}\n {:component \"main\", :copy sync-main-copyhead-0}\n {:target #fn, :token-name \"radius.s\", :value 10}\n {:target #fn, :token-name \"radius.l\", :value 30}\n \n {:target #fn, :token-name \"radius.l\"}", :states ["714499b0038839d0" "3a7ae19f94a1835f" "06863f9adb06ec18" "f9c768297020b176"]}
|
||||
{:transcript " {:component \"main\", :id sync-main-component}\n {:tokens [[\"radius.s\" 10] [\"radius.l\" 30]]}\n {:component \"main\", :copy sync-main-copyhead-0}\n {:target #fn, :token-name \"radius.s\", :value 10}\n {:target #fn, :token-name \"radius.l\", :value 30}\n \n one-of -> ", :states ["714499b0038839d0" "3a7ae19f94a1835f" "4f5db495e35227e5"]}
|
||||
{:transcript " {:component \"main\", :id sync-main-component}\n {:tokens [[\"radius.s\" 10] [\"radius.l\" 30]]}\n {:component \"main\", :copy sync-main-copyhead-0}\n one-of -> \n {:target #fn, :token-name \"radius.l\", :value 30}\n \n {:target #fn, :token-name \"radius.l\"}", :states ["d0de1c63d1e2913a" "8e2ae96c4495f143" "608fefc00332c877"]}
|
||||
{:transcript " {:component \"main\", :id sync-main-component}\n {:tokens [[\"radius.s\" 10] [\"radius.l\" 30]]}\n {:component \"main\", :copy sync-main-copyhead-0}\n one-of -> \n {:target #fn, :token-name \"radius.l\", :value 30}\n \n one-of -> ", :states ["d0de1c63d1e2913a" "a3e49f56de0aaf82"]}]
|
||||
:case-az-copy-moved-out-of-its-main-keeps-inherited-overrides
|
||||
[{:transcript " {:component \"main\", :id sync-main-component}\n {:component \"main\", :level 0, :outer sync-main-outercomp-0}\n {:target #fn, :property :fills, :value \"#00ff00\"}\n {:component \"main\", :level 1, :outer sync-main-outercomp-1}\n {:target #fn, :new-head 5}\n \n {:target #fn, :property :fills, :value \"#ff0000\"}", :states ["d6802c2361c4f48a" "09526a373b2bf78d" "f6588d21ee3f82ea" "89696ef8abcbb71d"]}
|
||||
{:transcript " {:component \"main\", :id sync-main-component}\n {:component \"main\", :level 0, :outer sync-main-outercomp-0}\n {:target #fn, :property :fills, :value \"#00ff00\"}\n one-of -> \n {:target #fn, :new-head 3}\n \n {:target #fn, :property :fills, :value \"#ff0000\"}", :states ["d6802c2361c4f48a" "7443c8f4406f3704" "78edc4e41925495c" "62c32614a4d51244"]}]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user