rastrillo / fiesta Public

Spell out the ring refinements' names and wrap them at 80 columns

The six changes are written once as railRingChange entries and refined in both spellings; refines holds the shared test of file, context, selector and property.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 2e3ad9e286e8118321139aaca055fca2ab701488 parent 382fb82
1 file changed, +92 −52
  • check/baseline_test.go +92 −52
diff --git a/check/baseline_test.go b/check/baseline_test.go
index 72041a5..841446e 100644
--- a/check/baseline_test.go
+++ b/check/baseline_test.go
@@ -175,62 +175,95 @@ type refinement struct {
Why string
}
-// The console rail's nav, in both spellings, under the rule that puts
-// the rail beside the page.
+// The console rail's nav in its two spellings, under the media query
+// that puts the rail beside the page.
const (
- railWide = "@media (min-width: 800px)"
- railNav = ".rst-shell-console > .rst-shell__rail > .rst-shell__nav"
- railNavAttrs = "[rst-shell-console] > [rst-shell-rail] > [rst-shell-nav]"
+ wideRail = "@media (min-width: 800px)"
+ railNavClasses = ".rst-shell-console > .rst-shell__rail > .rst-shell__nav"
+ railNavAttributes = "[rst-shell-console] > [rst-shell-rail] > [rst-shell-nav]"
)
-// railRing is why each of the console rail's refinements is there.
-const railRing = "1.2.0 takes Rastrillo cc7c9c69: a nav that scrolls clips " +
- "at its padding box, so 1.0's console rail cut its current item's " +
- "ring and contact shadow off at its edges. 5px of padding gives " +
- "them room, and the negative margins, the smaller sticky inset and " +
- "the larger cap give it back, so no item moves (consoleRailRing in " +
- "parity_browser_test.go photographs it)"
+// railRingReason is why each of the console rail's refinements is there.
+const railRingReason = "1.2.0 takes Rastrillo cc7c9c69: a nav that " +
+ "scrolls clips at its padding box, so 1.0's console rail cut its " +
+ "current item's ring and contact shadow off at its edges. 5px of " +
+ "padding gives them room, and the negative margins, the smaller " +
+ "sticky inset and the larger cap give it back, so no item moves " +
+ "(consoleRailRing in rendering_exception_browser_test.go " +
+ "photographs it)"
+
+// railRingChange is one declaration the ring fix changes or adds,
+// written once and refined in both spellings.
+type railRingChange struct{ Property, Was, Now string }
+
+var railRingChanges = []railRingChange{
+ {
+ Property: "inset-block-start",
+ Was: "var(--rst-sp-4)",
+ Now: "calc(var(--rst-sp-4) - 5px)",
+ },
+ {Property: "margin-block", Now: "-5px"},
+ {Property: "margin-inline", Now: "-5px"},
+ {
+ Property: "max-block-size",
+ Was: "calc(100dvh - 2 * var(--rst-sp-4))",
+ Now: "calc(100dvh - 2 * var(--rst-sp-4) + 10px)",
+ },
+ {Property: "padding-block", Now: "5px"},
+ {Property: "padding-inline", Now: "5px"},
+}
// refinedDeclarations is every refinement 1.x makes, in file order.
-var refinedDeclarations = func() []refinement {
- var out []refinement
- for _, nav := range []string{railNav, railNavAttrs} {
- for _, d := range [][3]string{
- {"inset-block-start", "var(--rst-sp-4)", "calc(var(--rst-sp-4) - 5px)"},
- {"margin-block", "", "-5px"},
- {"margin-inline", "", "-5px"},
- {"max-block-size", "calc(100dvh - 2 * var(--rst-sp-4))", "calc(100dvh - 2 * var(--rst-sp-4) + 10px)"},
- {"padding-block", "", "5px"},
- {"padding-inline", "", "5px"},
- } {
- out = append(out, refinement{File: "css/tokens.css", Context: railWide, Selector: nav, Property: d[0], Was: d[1], Now: d[2], Why: railRing})
+var refinedDeclarations = railRingRefinements()
+
+func railRingRefinements() []refinement {
+ var refinements []refinement
+ for _, selector := range []string{railNavClasses, railNavAttributes} {
+ for _, change := range railRingChanges {
+ refinements = append(refinements, refinement{
+ File: "css/tokens.css",
+ Context: wideRail,
+ Selector: selector,
+ Property: change.Property,
+ Was: change.Was,
+ Now: change.Now,
+ Why: railRingReason,
+ })
}
}
- return out
-}()
+ return refinements
+}
+
+// refines reports whether entry names record's file, context, selector
+// and property, with record not !important.
+func refines(entry refinement, record declaration) bool {
+ return record.Context == entry.Context &&
+ record.Selector == entry.Selector &&
+ record.Property == entry.Property && !record.Important
+}
-// refined reports which refinement turns was into is, if one does: the
-// same file, context, selector and property, neither !important, was's
-// value the entry's Was and is's its Now.
+// refined reports which refinement turns was into is, if one does:
+// was is 1.0.0's declaration with the entry's Was, and is the tree's
+// with its Now, both where the entry says.
func refined(was, is declaration) (int, bool) {
- for i, r := range refinedDeclarations {
- if r.Was != "" && was.File == "check/testdata/seed/"+baseline[strings.TrimPrefix(r.File, "css/")] &&
- is.File == r.File && was.Context == r.Context && is.Context == r.Context &&
- was.Selector == r.Selector && is.Selector == r.Selector &&
- was.Property == r.Property && is.Property == r.Property &&
- was.Value == r.Was && is.Value == r.Now && !was.Important && !is.Important {
- return i, true
+ for index, entry := range refinedDeclarations {
+ seed := "check/testdata/seed/" +
+ baseline[strings.TrimPrefix(entry.File, "css/")]
+ if entry.Was != "" && was.File == seed && is.File == entry.File &&
+ refines(entry, was) && refines(entry, is) &&
+ was.Value == entry.Was && is.Value == entry.Now {
+ return index, true
}
}
return 0, false
}
-// addedByRefinement reports which refinement adds d, if one does.
-func addedByRefinement(d declaration) (int, bool) {
- for i, r := range refinedDeclarations {
- if r.Was == "" && d.File == r.File && d.Context == r.Context && d.Selector == r.Selector &&
- d.Property == r.Property && d.Value == r.Now && !d.Important {
- return i, true
+// addedByRefinement reports which refinement adds record, if one does.
+func addedByRefinement(record declaration) (int, bool) {
+ for index, entry := range refinedDeclarations {
+ if entry.Was == "" && record.File == entry.File &&
+ refines(entry, record) && record.Value == entry.Now {
+ return index, true
}
}
return 0, false
@@ -632,8 +665,8 @@ func TestEveryOneOhDeclarationStillApplies(t *testing.T) {
if was.Selector != f.is[found].Selector {
used[was.Selector] = true
}
- if i, ok := refined(was, f.is[found]); ok {
- refinedUsed[i] = true
+ if index, ok := refined(was, f.is[found]); ok {
+ refinedUsed[index] = true
}
continue
}
@@ -669,9 +702,13 @@ func TestEveryOneOhDeclarationStillApplies(t *testing.T) {
}
}
- for i, r := range refinedDeclarations {
- if r.Was != "" && !refinedUsed[i] {
- t.Errorf("refinedDeclarations: no 1.0 declaration %s { %s { %s: %s } } became %s in %s; a refinement of nothing is a hole waiting to be used", r.Context, r.Selector, r.Property, r.Was, r.Now, r.File)
+ for index, entry := range refinedDeclarations {
+ if entry.Was != "" && !refinedUsed[index] {
+ t.Errorf("refinedDeclarations: no 1.0 declaration "+
+ "%s { %s { %s: %s } } became %s in %s; a refinement of "+
+ "nothing is a hole waiting to be used", entry.Context,
+ entry.Selector, entry.Property, entry.Was, entry.Now,
+ entry.File)
}
}
@@ -876,8 +913,8 @@ func refusedAdditions(t *testing.T, files []sideBySide) []string {
if taken[j] {
continue
}
- if i, ok := addedByRefinement(d); ok {
- added[i] = true
+ if index, ok := addedByRefinement(d); ok {
+ added[index] = true
continue
}
if why := newRecordRefused(d, names, oldProps, oldAtRules, exceptions, used); why != "" {
@@ -890,9 +927,12 @@ func refusedAdditions(t *testing.T, files []sideBySide) []string {
refused = append(refused, fmt.Sprintf("newOnOldMarkup[%q] is used by no new declaration; an exception for nothing is a hole waiting to be used", sel))
}
}
- for i, r := range refinedDeclarations {
- if r.Was == "" && !added[i] {
- refused = append(refused, fmt.Sprintf("refinedDeclarations: nothing adds %s { %s { %s: %s } } to %s; an exception for nothing is a hole waiting to be used", r.Context, r.Selector, r.Property, r.Now, r.File))
+ for index, entry := range refinedDeclarations {
+ if entry.Was == "" && !added[index] {
+ refused = append(refused, fmt.Sprintf("refinedDeclarations: "+
+ "nothing adds %s { %s { %s: %s } } to %s; an exception "+
+ "for nothing is a hole waiting to be used", entry.Context,
+ entry.Selector, entry.Property, entry.Now, entry.File))
}
}
return refused