diff options
Diffstat (limited to 'scripts/theme-studio/test_generate.py')
| -rw-r--r-- | scripts/theme-studio/test_generate.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/scripts/theme-studio/test_generate.py b/scripts/theme-studio/test_generate.py index 125f0c9ab..40956917e 100644 --- a/scripts/theme-studio/test_generate.py +++ b/scripts/theme-studio/test_generate.py @@ -10,6 +10,7 @@ Run: python3 -m unittest test_generate (from scripts/theme-studio/) """ import os import io +import json import tempfile import runpy import unittest @@ -82,13 +83,25 @@ class AssembledPage(unittest.TestCase): "PALETTE_ACTIONS_J", "BROWSER_GATES_J", "COLORMATH_J", "SAMPLES_J", "PALETTE_J", "CATS_J", "UIFACES_J", "UIMAP_J", "APPS_J", "SYNTAX_J", "MAP_J", - "COLOR_NAMES_J", + "COLOR_NAMES_J", "FACE_DOCS_J", "SYNTAX_DOCS_J", ] def test_every_placeholder_is_substituted(self): for token in self.PLACEHOLDERS: self.assertNotIn(token, generate.HTML, f"{token} left unsubstituted") + def test_face_docs_maps_embed_a_known_docstring(self): + # The face/syntax docstring maps inline so element hovers can show them. + # default is always present; its first line is stable across Emacs builds. + self.assertIn("Basic default face.", generate.FACE_DOCS["default"]) + self.assertIn(json.dumps(generate.FACE_DOCS), generate.HTML) + + def test_syntax_docs_resolve_categories_to_face_docstrings(self): + # The syntax table is keyed by category (kw, doc, ...); each resolves to + # its font-lock face's docstring via build-theme's canonical map. + self.assertIn("keyword", generate.SYNTAX_DOCS["kw"].lower()) + self.assertIn(json.dumps(generate.SYNTAX_DOCS), generate.HTML) + def test_page_carries_the_colormath_body_verbatim(self): # Python-side inline-integrity: the same guarantee the JS test asserts, but # checked at the point the page is built rather than after a round-trip. @@ -164,6 +177,20 @@ class LanguageSamples(unittest.TestCase): self.assertIn("@import", text) self.assertIn("error.MissingColor", text) + def test_expanded_language_set_is_registered_and_renders(self): + # Every added language is selectable and renders a non-trivial sample that + # exercises keywords and carries a comment. + added = ["Racket", "Scheme", "Haskell", "OCaml", "Scala", "Kotlin", + "Swift", "Lua", "Ruby", "Perl", "R", "Erlang", "SQL", "PHP", + "Ada", "Fortran", "MATLAB", "Assembly"] + for lang in added: + self.assertIn(lang, generate.SAMPLES, f"{lang} not in the language selector") + tokens = self._tokens(lang) + cats = {k for k, _ in tokens} + self.assertGreater(len(tokens), 40, f"{lang} sample is too short") + self.assertIn("kw", cats, f"{lang} sample has no keywords") + self.assertIn("cmd", cats, f"{lang} sample has no comment") + class FacesHelper(unittest.TestCase): def test_strips_prefix_and_derives_label_and_merges_seed(self): |
