Make two doctest assertions property-order-insensitive for Emacs 28

Emacs 28 stores/prints text-property plists in a different order than
29+; the S-mystyle and L-paramgroup assertions compared whole prin1
strings and failed on 28.1 only. Compare per property instead (face,
tp-name, tp-layers — the stack order inside tp-layers is stable), and
note the version-dependent print order beside both README examples.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Kinneyzhang 2026-07-26 23:58:12 +08:00
parent ca405f977d
commit b454cbb061
3 changed files with 39 additions and 21 deletions

View File

@ -597,6 +597,8 @@ LAYER-NAME can be a symbol representing a layer defined by `define-tp` or a grou
:data '((my-color . "blue")))
(tp-set " " 'my-style)
;; => #(" " 0 1 (face (:foreground "blue") tp-name my-style))
;; (the printed ORDER of properties may differ across Emacs
;; versions; the values are identical)
;; Merge multiple faces in a single call (duplicate properties auto-merged)
(tp-set "emacs"
@ -1827,6 +1829,8 @@ The first layer in the definition is the top layer (visible by default).
;; => #("emacs" 0 5 (face (:foreground "orange") tp-name tp-test-l1
;; tp-layers ((face (:foreground "red") tp-name tp-test-l2)
;; (face (:background "green") tp-name tp-test-l3))))
;; (top-level property print order may differ across Emacs versions;
;; the tp-layers stack order itself is stable)
```
---

View File

@ -587,6 +587,7 @@ LAYER-NAME 可以是通过 `define-tp` 定义的自定义文本属性名称或
:data '((my-color . "blue")))
(tp-set " " 'my-style)
;; => #(" " 0 1 (face (:foreground "blue") tp-name my-style))
;; (属性的打印顺序在不同 Emacs 版本间可能不同,值本身一致)
;; 单次调用中合并多个 face重复属性自动合并
(tp-set "emacs"
@ -1813,6 +1814,8 @@ Emacs 的 `text-property-search-forward` 和 `text-property-search-backward` 的
;; => #("emacs" 0 5 (face (:foreground "orange") tp-name tp-test-l1
;; tp-layers ((face (:foreground "red") tp-name tp-test-l2)
;; (face (:background "green") tp-name tp-test-l3))))
;; (顶层属性的打印顺序在不同 Emacs 版本间可能不同,
;; tp-layers 栈内顺序本身是稳定的)
```
---

View File

@ -98,12 +98,15 @@
(tp-layer-props 'full-name-layer)))
;; ---- tp-set my-style ----
(chk-str "S-mystyle" "#(\" \" 0 1 (face (:foreground \"blue\") tp-name my-style))"
(progn
(define-tp my-style ()
:props '(face (:foreground $my-color))
:data '((my-color . "blue")))
(tp-set " " 'my-style)))
;; Compared per property: the ORDER properties print in varies across
;; Emacs versions (28 vs 29+), the values do not.
(chk "S-mystyle" '((:foreground "blue") my-style)
(progn
(define-tp my-style ()
:props '(face (:foreground $my-color))
:data '((my-color . "blue")))
(let ((r (tp-set " " 'my-style)))
(list (tp-at 0 'face r) (tp-at 0 'tp-name r)))))
;; ---- tp-member ----
(chk "M-member-str" '((face nil) nil)
@ -232,21 +235,29 @@
'("first-quarter" . (display "🌓"))
'("full" . (display "🌕")))
(tp-layer-props 'moon-phases-full)))
(chk-str "L-paramgroup"
"#(\"emacs\" 0 5 (face (:foreground \"orange\") tp-name tp-test-l1 tp-layers ((face (:foreground \"red\") tp-name tp-test-l2) (face (:background \"green\") tp-name tp-test-l3))))"
(progn
(tp-layer-reset)
(define-tp tp-test-l1 (color)
`(face (:foreground ,color)))
(define-tp tp-test-l2 (color)
`(face (:foreground ,color)))
(define-tp tp-test-l3 ()
'(face (:background "green")))
(define-tps tp-test-group1 (color)
`(tp-test-l1 ,color)
'(tp-test-l2 "red")
'tp-test-l3)
(tp-set "emacs" 'tp-test-group1 "orange")))
;; Compared per property (print order of the top-level plist varies
;; across Emacs versions; the tp-layers stack order itself is stable).
(chk "L-paramgroup"
'((:foreground "orange")
tp-test-l1
((face (:foreground "red") tp-name tp-test-l2)
(face (:background "green") tp-name tp-test-l3)))
(progn
(tp-layer-reset)
(define-tp tp-test-l1 (color)
`(face (:foreground ,color)))
(define-tp tp-test-l2 (color)
`(face (:foreground ,color)))
(define-tp tp-test-l3 ()
'(face (:background "green")))
(define-tps tp-test-group1 (color)
`(tp-test-l1 ,color)
'(tp-test-l2 "red")
'tp-test-l3)
(let ((r (tp-set "emacs" 'tp-test-group1 "orange")))
(list (tp-at 0 'face r)
(tp-at 0 'tp-name r)
(tp-at 0 'tp-layers r)))))
(chk "L-props" '((face bold help-echo "tip")
(face bold help-echo "tip" tp-name my-layer))
(progn