From d10b93f0735d9a8dbe0af0d0fcb1f0fdc638cbe9 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sun, 12 Nov 2023 11:12:47 +0100 Subject: [PATCH] more concise tests --- tests/test_types.py | 209 +++++++++++++++++++++++--------------------- 1 file changed, 107 insertions(+), 102 deletions(-) diff --git a/tests/test_types.py b/tests/test_types.py index f6eee16a6..5b1806cfd 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -147,105 +147,110 @@ def test_pattern_negated_character_range(self) -> None: self.assertFalse(selector.matches(self._make_html_view("example.8"))) self.assertFalse(selector.matches(self._make_html_view("example.9"))) - def test_basescope2languageid(self) -> None: - self.assertEqual(basescope2languageid("source.js.vite"), "javascript") - self.assertEqual(basescope2languageid("source.c++"), "cpp") - self.assertEqual(basescope2languageid("source.coffee.gulpfile"), "coffeescript") - self.assertEqual(basescope2languageid("source.cs"), "csharp") - self.assertEqual(basescope2languageid("source.css.tailwind"), "css") - self.assertEqual(basescope2languageid("source.dosbatch"), "bat") - self.assertEqual(basescope2languageid("source.fixedform-fortran"), "fortran") - self.assertEqual(basescope2languageid("source.groovy.gradle"), "groovy") - self.assertEqual(basescope2languageid("source.groovy.jenkins"), "groovy") - self.assertEqual(basescope2languageid("source.js"), "javascript") - self.assertEqual(basescope2languageid("source.js.eslint"), "javascript") - self.assertEqual(basescope2languageid("source.js.gruntfile"), "javascript") - self.assertEqual(basescope2languageid("source.js.gulpfile"), "javascript") - self.assertEqual(basescope2languageid("source.js.postcss"), "javascript") - self.assertEqual(basescope2languageid("source.js.puglint"), "javascript") - self.assertEqual(basescope2languageid("source.js.react"), "javascriptreact") - self.assertEqual(basescope2languageid("source.js.stylelint"), "javascript") - self.assertEqual(basescope2languageid("sourcet.js.unittest"), "javascript") - self.assertEqual(basescope2languageid("source.js.webpack"), "javascript") - self.assertEqual(basescope2languageid("source.json-tmlanguage"), "jsonc") - self.assertEqual(basescope2languageid("source.json.babel"), "json") - self.assertEqual(basescope2languageid("source.json.bower"), "json") - self.assertEqual(basescope2languageid("source.json.composer"), "json") - self.assertEqual(basescope2languageid("source.json.eslint"), "json") - self.assertEqual(basescope2languageid("source.json.npm"), "json") - self.assertEqual(basescope2languageid("source.json.postcss"), "json") - self.assertEqual(basescope2languageid("source.json.puglint"), "json") - self.assertEqual(basescope2languageid("source.json.settings"), "json") - self.assertEqual(basescope2languageid("source.json.stylelint"), "json") - self.assertEqual(basescope2languageid("source.json.sublime"), "jsonc") - self.assertEqual(basescope2languageid("source.json.sublime.build"), "jsonc") - self.assertEqual(basescope2languageid("source.json.sublime.color-scheme"), "jsonc") - self.assertEqual(basescope2languageid("source.json.sublime.commands"), "jsonc") - self.assertEqual(basescope2languageid("source.json.sublime.completions"), "jsonc") - self.assertEqual(basescope2languageid("source.json.sublime.keymap"), "jsonc") - self.assertEqual(basescope2languageid("source.json.sublime.macro"), "jsonc") - self.assertEqual(basescope2languageid("source.json.sublime.menu"), "jsonc") - self.assertEqual(basescope2languageid("source.json.sublime.mousemap"), "jsonc") - self.assertEqual(basescope2languageid("source.json.sublime.project"), "jsonc") - self.assertEqual(basescope2languageid("source.json.sublime.settings"), "jsonc") - self.assertEqual(basescope2languageid("source.json.sublime.theme"), "jsonc") - self.assertEqual(basescope2languageid("source.json.tern"), "json") - self.assertEqual(basescope2languageid("source.jsx"), "javascriptreact") - self.assertEqual(basescope2languageid("source.jsx.unittest"), "javascriptreact") - self.assertEqual(basescope2languageid("source.Kotlin"), "kotlin") - self.assertEqual(basescope2languageid("source.modern-fortran"), "fortran") - self.assertEqual(basescope2languageid("source.objc"), "objective-c") - self.assertEqual(basescope2languageid("source.objc++"), "objective-cpp") - self.assertEqual(basescope2languageid("source.shader"), "shaderlab") - self.assertEqual(basescope2languageid("source.shell.bash"), "shellscript") - self.assertEqual(basescope2languageid("source.shell.docker"), "shellscript") - self.assertEqual(basescope2languageid("source.shell.eslint"), "shellscript") - self.assertEqual(basescope2languageid("source.shell.npm"), "shellscript") - self.assertEqual(basescope2languageid("source.shell.ruby"), "shellscript") - self.assertEqual(basescope2languageid("source.shell.stylelint"), "shellscript") - self.assertEqual(basescope2languageid("source.ts"), "typescript") - self.assertEqual(basescope2languageid("source.ts.react"), "typescriptreact") - self.assertEqual(basescope2languageid("source.ts.unittest"), "typescript") - self.assertEqual(basescope2languageid("source.tsx"), "typescriptreact") - self.assertEqual(basescope2languageid("source.tsx.unittest"), "typescriptreact") - self.assertEqual(basescope2languageid("source.unity.unity_shader"), "shaderlab") - self.assertEqual(basescope2languageid("source.viml.vimrc"), "viml") - self.assertEqual(basescope2languageid("source.yaml-tmlanguage"), "yaml") - self.assertEqual(basescope2languageid("source.yaml.circleci"), "yaml") - self.assertEqual(basescope2languageid("source.yaml.docker"), "yaml") - self.assertEqual(basescope2languageid("source.yaml.eslint"), "yaml") - self.assertEqual(basescope2languageid("source.yaml.lock"), "yaml") - self.assertEqual(basescope2languageid("source.yaml.procfile"), "yaml") - self.assertEqual(basescope2languageid("source.yaml.stylelint"), "yaml") - self.assertEqual(basescope2languageid("source.yaml.sublime.syntax"), "yaml") - self.assertEqual(basescope2languageid("source.yaml.yarn"), "yaml") - self.assertEqual(basescope2languageid("text.advanced_csv"), "csv") - self.assertEqual(basescope2languageid("text.django"), "html") - self.assertEqual(basescope2languageid("text.html.basic"), "html") - self.assertEqual(basescope2languageid("text.html.elixir"), "html") - self.assertEqual(basescope2languageid("text.html.markdown.academicmarkdown"), "markdown") - self.assertEqual(basescope2languageid("text.html.markdown.license"), "markdown") - self.assertEqual(basescope2languageid("text.html.markdown.rmarkdown"), "r") - self.assertEqual(basescope2languageid("text.html.ngx"), "html") - self.assertEqual(basescope2languageid("text.jinja"), "html") - self.assertEqual(basescope2languageid("text.plain"), "plaintext") - self.assertEqual(basescope2languageid("text.plain.buildpacks"), "plaintext") - self.assertEqual(basescope2languageid("text.plain.eslint"), "plaintext") - self.assertEqual(basescope2languageid("text.plain.fastq"), "plaintext") - self.assertEqual(basescope2languageid("text.plain.license"), "plaintext") - self.assertEqual(basescope2languageid("text.plain.lnk"), "plaintext") - self.assertEqual(basescope2languageid("text.plain.log"), "plaintext") - self.assertEqual(basescope2languageid("text.plain.nodejs"), "plaintext") - self.assertEqual(basescope2languageid("text.plain.pcb"), "plaintext") - self.assertEqual(basescope2languageid("text.plain.ps"), "plaintext") - self.assertEqual(basescope2languageid("text.plain.python"), "plaintext") - self.assertEqual(basescope2languageid("text.plain.readme"), "plaintext") - self.assertEqual(basescope2languageid("text.plain.ruby"), "plaintext") - self.assertEqual(basescope2languageid("text.plain.sketch"), "plaintext") - self.assertEqual(basescope2languageid("text.plain.visualstudio"), "plaintext") - self.assertEqual(basescope2languageid("text.plist"), "xml") - self.assertEqual(basescope2languageid("text.xml.plist"), "xml") - self.assertEqual(basescope2languageid("text.xml.plist.textmate.preferences"), "xml") - self.assertEqual(basescope2languageid("text.xml.sublime.snippet"), "xml") - self.assertEqual(basescope2languageid("text.xml.svg"), "xml") - self.assertEqual(basescope2languageid("text.xml.visualstudio"), "xml") + def test_base_scope_to_language_id_mappings(self) -> None: + scope_test_map = { + "source.js.vite": "javascript", + "source.c++": "cpp", + "source.coffee.gulpfile": "coffeescript", + "source.cs": "csharp", + "source.css.tailwind": "css", + "source.dosbatch": "bat", + "source.fixedform-fortran": "fortran", + "source.groovy.gradle": "groovy", + "source.groovy.jenkins": "groovy", + "source.js": "javascript", + "source.js.eslint": "javascript", + "source.js.gruntfile": "javascript", + "source.js.gulpfile": "javascript", + "source.js.postcss": "javascript", + "source.js.puglint": "javascript", + "source.js.react": "javascriptreact", + "source.js.stylelint": "javascript", + "source.js.unittest": "javascript", + "source.js.webpack": "javascript", + "source.json-tmlanguage": "jsonc", + "source.json.babel": "json", + "source.json.bower": "json", + "source.json.composer": "json", + "source.json.eslint": "json", + "source.json.npm": "json", + "source.json.postcss": "json", + "source.json.puglint": "json", + "source.json.settings": "json", + "source.json.stylelint": "json", + "source.json.sublime": "jsonc", + "source.json.sublime.build": "jsonc", + "source.json.sublime.color-scheme": "jsonc", + "source.json.sublime.commands": "jsonc", + "source.json.sublime.completions": "jsonc", + "source.json.sublime.keymap": "jsonc", + "source.json.sublime.macro": "jsonc", + "source.json.sublime.menu": "jsonc", + "source.json.sublime.mousemap": "jsonc", + "source.json.sublime.project": "jsonc", + "source.json.sublime.settings": "jsonc", + "source.json.sublime.theme": "jsonc", + "source.json.tern": "json", + "source.jsx": "javascriptreact", + "source.jsx.unittest": "javascriptreact", + "source.Kotlin": "kotlin", + "source.modern-fortran": "fortran", + "source.objc": "objective-c", + "source.objc++": "objective-cpp", + "source.shader": "shaderlab", + "source.shell.bash": "shellscript", + "source.shell.docker": "shellscript", + "source.shell.eslint": "shellscript", + "source.shell.npm": "shellscript", + "source.shell.ruby": "shellscript", + "source.shell.stylelint": "shellscript", + "source.ts": "typescript", + "source.ts.react": "typescriptreact", + "source.ts.unittest": "typescript", + "source.tsx": "typescriptreact", + "source.tsx.unittest": "typescriptreact", + "source.unity.unity_shader": "shaderlab", + "source.viml.vimrc": "viml", + "source.yaml-tmlanguage": "yaml", + "source.yaml.circleci": "yaml", + "source.yaml.docker": "yaml", + "source.yaml.eslint": "yaml", + "source.yaml.lock": "yaml", + "source.yaml.procfile": "yaml", + "source.yaml.stylelint": "yaml", + "source.yaml.sublime.syntax": "yaml", + "source.yaml.yarn": "yaml", + "text.advanced_csv": "csv", + "text.django": "html", + "text.html.basic": "html", + "text.html.elixir": "html", + "text.html.markdown.academicmarkdown": "markdown", + "text.html.markdown.license": "markdown", + "text.html.markdown.rmarkdown": "r", + "text.html.ngx": "html", + "text.jinja": "html", + "text.plain": "plaintext", + "text.plain.buildpacks": "plaintext", + "text.plain.eslint": "plaintext", + "text.plain.fastq": "plaintext", + "text.plain.license": "plaintext", + "text.plain.lnk": "plaintext", + "text.plain.log": "plaintext", + "text.plain.nodejs": "plaintext", + "text.plain.pcb": "plaintext", + "text.plain.ps": "plaintext", + "text.plain.python": "plaintext", + "text.plain.readme": "plaintext", + "text.plain.ruby": "plaintext", + "text.plain.sketch": "plaintext", + "text.plain.visualstudio": "plaintext", + "text.plist": "xml", + "text.xml.plist": "xml", + "text.xml.plist.textmate.preferences": "xml", + "text.xml.sublime.snippet": "xml", + "text.xml.svg": "xml", + "text.xml.visualstudio": "xml", + } + + for base_scope, expected_language_id in scope_test_map.items(): + self.assertEqual(basescope2languageid(base_scope), expected_language_id)