🐛 fix(tsl-syntax-reference): prefer ordinary quotes for plain text

This commit is contained in:
csh
2026-08-14 17:12:56 +08:00
parent 3d3036ebe1
commit 5d73964db8
4 changed files with 47 additions and 5 deletions
+18
View File
@@ -336,6 +336,24 @@ class TslSyntaxReferenceTests(unittest.TestCase):
self.assertEqual("03_values_and_literals.md", result.matches[0].section.page.name)
self.assertEqual("核心规则", result.matches[0].section.heading_path[-1])
def test_string_literal_queries_rank_generation_policy_first(self):
for query in ("普通中文字符串", "原始字符串 %%", "字符串 U L 前缀"):
with self.subTest(query=query):
result = lookup.query_sections(query, "explain", limit=1)
self.assertEqual("syntax-03-004", result.matches[0].section.id)
def test_string_literal_generation_policy_is_in_quickstart_and_detail(self):
quickstart = run_lookup("--section", "syntax-01-002")
detail = run_lookup("--section", "syntax-03-004")
self.assertEqual(0, quickstart.returncode, msg=quickstart.stderr)
self.assertEqual(0, detail.returncode, msg=detail.stderr)
for output in (quickstart.stdout, detail.stdout):
self.assertIn("普通单行文本默认使用", output)
self.assertIn("不得因为内容是中文、非 ASCII 或较长", output)
self.assertIn("不能因为内容是中文就自动添加", output)
self.assertIn('普通中文内容优先直接写成 `"中文内容"`', output)
def test_every_curated_page_alias_still_ranks_its_page_first(self):
for page_name, aliases in lookup.PAGE_INTENT_ALIASES.items():
for alias in aliases: