mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 21:30:12 +01:00
We've talked about adding the title to the filename several times over the years and it seems really valuable. This requires us to compute a "slug" for the title spelling that can be part of the filename. Beyond that, we crossed 7000 recently, and so it seems likely that we will need to add digits sooner rather than later here, so this goes ahead and moves us to 6 digits so we don't have to adjust again for a reasonable length of time. To implement this and ensure we can sustain it going forward this adds a tool to our pre-commit that validates (and corrects if needed) the filename. In order to update everything and keep links working, there are a _lot_ of changes, but the most interesting for direct review are in `proposals/scripts`. Assisted-by: Antigravity with Gemini --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>
36 lines
1.4 KiB
Python
36 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
|
|
"""Tests for utils.py."""
|
|
|
|
__copyright__ = """
|
|
Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
Exceptions. See /LICENSE for license information.
|
|
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
"""
|
|
|
|
import unittest
|
|
|
|
from proposals.scripts import utils
|
|
|
|
|
|
class TestUtils(unittest.TestCase):
|
|
def test_slugify(self) -> None:
|
|
self.assertEqual(utils.slugify("Hello World"), "hello-world")
|
|
self.assertEqual(utils.slugify("Hello World"), "hello-world")
|
|
self.assertEqual(utils.slugify("Hello World!"), "hello-world")
|
|
self.assertEqual(utils.slugify("123 Hello"), "123-hello")
|
|
self.assertEqual(utils.slugify("Hello-World"), "hello-world")
|
|
self.assertEqual(utils.slugify(" Hello World "), "hello-world")
|
|
self.assertEqual(utils.slugify("Hello_World"), "hello-world")
|
|
self.assertEqual(utils.slugify("Hello 🚀 World"), "hello-world")
|
|
self.assertEqual(utils.slugify("🚀 Hello"), "hello")
|
|
self.assertEqual(utils.slugify("Hello 🚀"), "hello")
|
|
self.assertEqual(utils.slugify("Hello\nWorld"), "hello-world")
|
|
self.assertEqual(utils.slugify("Hello\x01World"), "hello-world")
|
|
self.assertEqual(utils.slugify("Hello\tWorld"), "hello-world")
|
|
self.assertEqual(utils.slugify("Hello \n World"), "hello-world")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|