tp/tests/tp-architecture-tests.el
Kinneyzhang 0d35358e05 refactor(tp)!: implement retained reactive runtime
Replace the legacy managed layer renderer with one independent retained/reactive text runtime. TP now owns exact dependencies, stable objects, marker-backed mounts, property contribution composition, atomic publication, rollback, and direct text-property facades without ECSS or Ebox dependencies.\n\nBREAKING CHANGE: remove tp-render, tp-stack, scan-driven managed layers, inline runtime metadata, TP-owned CSS cascade APIs, and dollar-variable declarations.\n\nVerified: 290/290 ERT, shuffled 290/290 (seed 20260806), 8/8 doctests, WERROR compile-all, checkdoc, package-lint, diff-check, and isolated TP-only load.
2026-08-07 00:39:50 +08:00

94 lines
3.6 KiB
EmacsLisp

;;; tp-architecture-tests.el --- TP 1.0 boundary tests -*- lexical-binding: t; -*-
;; Copyright (C) 2026 Geekinney
;; SPDX-License-Identifier: GPL-3.0-or-later
;;; Commentary:
;; Structural contracts for the single retained/reactive TP runtime.
;;; Code:
(require 'ert)
(require 'tp)
(defconst tp-architecture-tests--root
(file-name-directory
(directory-file-name
(file-name-directory (or load-file-name buffer-file-name))))
"Absolute path to the TP repository root.")
(ert-deftest tp-architecture-test-legacy-runtime-modules-are-absent ()
"The removed scan renderer and inline stack runtime are not shipped."
(dolist (file '("tp-render.el" "tp-stack.el"))
(should-not
(file-exists-p (expand-file-name file tp-architecture-tests--root))))
(should-not (featurep 'tp-render))
(should-not (featurep 'tp-stack)))
(ert-deftest tp-architecture-test-legacy-runtime-symbols-are-absent ()
"The public runtime exposes no scan registry or inline identity API."
(dolist (symbol '(tp-reactive-deps
tp-layer-watchers
tp-layer-computed
tp-layer-data
tp--layer-buffers))
(should-not (boundp symbol)))
(dolist (symbol '(tp-reactive-layer-buffers
tp-reactive-track-buffer
tp--map-layer-buffers
tp-push-layer
tp-put-layer
tp-hide-layer
tp-show-layer
tp-move-layer
tp-merge-layers))
(should-not (fboundp symbol))))
(ert-deftest tp-architecture-test-production-has-no-legacy-scan-path ()
"Production sources contain no scan registry or inline identity access."
(let ((forbidden
(regexp-opt '("(buffer-list)"
"tp-reactive-deps"
"tp--layer-buffers"
"tp--map-layer-buffers"
"'tp-name"
"'tp-layers"
"'tp-meta"))))
(dolist (file (directory-files tp-architecture-tests--root t
"\\`tp-.*\\.el\\'"))
(with-temp-buffer
(insert-file-contents file)
(goto-char (point-min))
(should-not (re-search-forward forbidden nil t))))))
(ert-deftest tp-architecture-test-recipes-do-not-publish-runtime-metadata ()
"Named declaration recipes expand without inline runtime identity."
(unwind-protect
(progn
(define-tp tp-architecture-test-recipe ()
'(face bold help-echo "recipe"))
(let ((value (tp-set "text" 'tp-architecture-test-recipe)))
(dolist (property '(tp-name tp-layers tp-meta tp-hidden tp-text))
(should-not (plist-member (text-properties-at 0 value) property)))))
(tp-undefine-layer 'tp-architecture-test-recipe)))
(ert-deftest tp-architecture-test-stateless-facade-does-not-touch-runtime-counters ()
"One-shot public property APIs do not create retained/reactive work."
(with-temp-buffer
(insert "text")
(let ((counters (tp-reactive-counters))
(surfaces tp--buffer-surfaces))
(tp-set 1 5 '(face bold))
(should (equal (tp-reactive-counters) counters))
(should (eq tp--buffer-surfaces surfaces)))))
(ert-deftest tp-architecture-test-loading-tp-does-not-advise-theme-lifecycle ()
"Loading TP does not install global theme lifecycle advice."
(dolist (symbol '(tp--palette-after-enable-theme
tp--palette-after-disable-theme))
(should-not (fboundp symbol))))
(provide 'tp-architecture-tests)
;;; tp-architecture-tests.el ends here