From bf51f313cd83ffe43132a115f5c1d1ce64f9d2b3 Mon Sep 17 00:00:00 2001 From: Thomas Gazagnaire Date: Sun, 13 Sep 2026 17:32:48 +0200 Subject: [PATCH] test: hold the zero spacing steps to whole declarations The affix was [property ^ ":0"] and tw emits padding:0px, so it matched on a prefix: the assertion named "p-0 emits zero" would have passed on 0.5rem, 0vh or any value starting with the digit. The CLI writes 0px here and so does tw, which the list now says. The --spacing check beside it stays a search over the sheet. It asserts the carrier is absent from the theme layer, and declarations_of_class leaves :root bindings out by design, so no list of the class's own declarations can express it. --- test/test_build.ml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/test_build.ml b/test/test_build.ml index 106ae436b..de2091b7d 100644 --- a/test/test_build.ml +++ b/test/test_build.ml @@ -1118,14 +1118,18 @@ let check_spacing_zero_prune () = Tw.Build.to_css ~config [ utility ] |> Css.to_string ~minify:true in let check_zero name property utility = - let css = css utility in - Alcotest.(check bool) - (name ^ " emits zero") true - (Astring.String.is_infix ~affix:(property ^ ":0") css); + (* The whole list. The substring this replaces was [property ^ ":0"], which + matched [padding:0px] on its prefix, so it could not have told a zero + length from any value starting with one. The CLI writes [0px] and so does + tw. *) + Test_helpers.check_declarations name [ property ^ ":0px" ]; + (* The carrier is a [:root] binding, which [declarations_of_class] leaves + out by design, so its absence cannot be read off the list above and this + one stays a search over the sheet. *) Alcotest.(check bool) (name ^ " omits unused --spacing") false - (Astring.String.is_infix ~affix:"--spacing" css) + (Astring.String.is_infix ~affix:"--spacing" (css utility)) in check_zero "p-0" "padding" (p 0); check_zero "mb-0" "margin-bottom" (mb 0);