Commit 0df60be1377e12953e16faf7eb84c04088245b1e

Michael Schmidt 2020-11-04T17:18:23

Tests: Stricter pattern for nice-token-names test (#2588)

diff --git a/components/prism-elm.js b/components/prism-elm.js
index 2e4a5fb..ba712f9 100644
--- a/components/prism-elm.js
+++ b/components/prism-elm.js
@@ -1,10 +1,10 @@
 Prism.languages.elm = {
-	comment: /--.*|{-[\s\S]*?-}/,
-	char: {
+	'comment': /--.*|{-[\s\S]*?-}/,
+	'char': {
 		pattern: /'(?:[^\\'\r\n]|\\(?:[abfnrtv\\']|\d+|x[0-9a-fA-F]+))'/,
 		greedy: true
 	},
-	string: [
+	'string': [
 		{
 			// Multiline strings are wrapped in triple ". Quotes may appear unescaped.
 			pattern: /"""[\s\S]*?"""/,
@@ -15,20 +15,20 @@ Prism.languages.elm = {
 			greedy: true
 		}
 	],
-	import_statement: {
+	'import-statement': {
 		// The imported or hidden names are not included in this import
 		// statement. This is because we want to highlight those exactly like
 		// we do for the names in the program.
 		pattern: /^\s*import\s+[A-Z]\w*(?:\.[A-Z]\w*)*(?:\s+as\s+(?:[A-Z]\w*)(?:\.[A-Z]\w*)*)?(?:\s+exposing\s+)?/m,
 		inside: {
-			keyword: /\b(?:import|as|exposing)\b/
+			'keyword': /\b(?:import|as|exposing)\b/
 		}
 	},
-	keyword: /\b(?:alias|as|case|else|exposing|if|in|infixl|infixr|let|module|of|then|type)\b/,
+	'keyword': /\b(?:alias|as|case|else|exposing|if|in|infixl|infixr|let|module|of|then|type)\b/,
 	// These are builtin variables only. Constructors are highlighted later as a constant.
-	builtin: /\b(?:abs|acos|always|asin|atan|atan2|ceiling|clamp|compare|cos|curry|degrees|e|flip|floor|fromPolar|identity|isInfinite|isNaN|logBase|max|min|negate|never|not|pi|radians|rem|round|sin|sqrt|tan|toFloat|toPolar|toString|truncate|turns|uncurry|xor)\b/,
+	'builtin': /\b(?:abs|acos|always|asin|atan|atan2|ceiling|clamp|compare|cos|curry|degrees|e|flip|floor|fromPolar|identity|isInfinite|isNaN|logBase|max|min|negate|never|not|pi|radians|rem|round|sin|sqrt|tan|toFloat|toPolar|toString|truncate|turns|uncurry|xor)\b/,
 	// decimal integers and floating point numbers | hexadecimal integers
-	number: /\b(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?|0x[0-9a-f]+)\b/i,
+	'number': /\b(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?|0x[0-9a-f]+)\b/i,
 	// Most of this is needed because of the meaning of a single '.'.
 	// If it stands alone freely, it is the function composition.
 	// It may also be a separator between a module name and an identifier => no
@@ -36,9 +36,9 @@ Prism.languages.elm = {
 	// operator too.
 	// Valid operator characters in 0.18: +-/*=.$<>:&|^?%#@~!
 	// Ref: https://groups.google.com/forum/#!msg/elm-dev/0AHSnDdkSkQ/E0SVU70JEQAJ
-	operator: /\s\.\s|[+\-/*=.$<>:&|^?%#@~!]{2,}|[+\-/*=$<>:&|^?%#@~!]/,
+	'operator': /\s\.\s|[+\-/*=.$<>:&|^?%#@~!]{2,}|[+\-/*=$<>:&|^?%#@~!]/,
 	// In Elm, nearly everything is a variable, do not highlight these.
-	hvariable: /\b(?:[A-Z]\w*\.)*[a-z]\w*\b/,
-	constant: /\b(?:[A-Z]\w*\.)*[A-Z]\w*\b/,
-	punctuation: /[{}[\]|(),.:]/
+	'hvariable': /\b(?:[A-Z]\w*\.)*[a-z]\w*\b/,
+	'constant': /\b(?:[A-Z]\w*\.)*[A-Z]\w*\b/,
+	'punctuation': /[{}[\]|(),.:]/
 };
diff --git a/components/prism-elm.min.js b/components/prism-elm.min.js
index ee9d8e8..b574bf8 100644
--- a/components/prism-elm.min.js
+++ b/components/prism-elm.min.js
@@ -1 +1 @@
-Prism.languages.elm={comment:/--.*|{-[\s\S]*?-}/,char:{pattern:/'(?:[^\\'\r\n]|\\(?:[abfnrtv\\']|\d+|x[0-9a-fA-F]+))'/,greedy:!0},string:[{pattern:/"""[\s\S]*?"""/,greedy:!0},{pattern:/"(?:[^\\"\r\n]|\\.)*"/,greedy:!0}],import_statement:{pattern:/^\s*import\s+[A-Z]\w*(?:\.[A-Z]\w*)*(?:\s+as\s+(?:[A-Z]\w*)(?:\.[A-Z]\w*)*)?(?:\s+exposing\s+)?/m,inside:{keyword:/\b(?:import|as|exposing)\b/}},keyword:/\b(?:alias|as|case|else|exposing|if|in|infixl|infixr|let|module|of|then|type)\b/,builtin:/\b(?:abs|acos|always|asin|atan|atan2|ceiling|clamp|compare|cos|curry|degrees|e|flip|floor|fromPolar|identity|isInfinite|isNaN|logBase|max|min|negate|never|not|pi|radians|rem|round|sin|sqrt|tan|toFloat|toPolar|toString|truncate|turns|uncurry|xor)\b/,number:/\b(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?|0x[0-9a-f]+)\b/i,operator:/\s\.\s|[+\-/*=.$<>:&|^?%#@~!]{2,}|[+\-/*=$<>:&|^?%#@~!]/,hvariable:/\b(?:[A-Z]\w*\.)*[a-z]\w*\b/,constant:/\b(?:[A-Z]\w*\.)*[A-Z]\w*\b/,punctuation:/[{}[\]|(),.:]/};
\ No newline at end of file
+Prism.languages.elm={comment:/--.*|{-[\s\S]*?-}/,char:{pattern:/'(?:[^\\'\r\n]|\\(?:[abfnrtv\\']|\d+|x[0-9a-fA-F]+))'/,greedy:!0},string:[{pattern:/"""[\s\S]*?"""/,greedy:!0},{pattern:/"(?:[^\\"\r\n]|\\.)*"/,greedy:!0}],"import-statement":{pattern:/^\s*import\s+[A-Z]\w*(?:\.[A-Z]\w*)*(?:\s+as\s+(?:[A-Z]\w*)(?:\.[A-Z]\w*)*)?(?:\s+exposing\s+)?/m,inside:{keyword:/\b(?:import|as|exposing)\b/}},keyword:/\b(?:alias|as|case|else|exposing|if|in|infixl|infixr|let|module|of|then|type)\b/,builtin:/\b(?:abs|acos|always|asin|atan|atan2|ceiling|clamp|compare|cos|curry|degrees|e|flip|floor|fromPolar|identity|isInfinite|isNaN|logBase|max|min|negate|never|not|pi|radians|rem|round|sin|sqrt|tan|toFloat|toPolar|toString|truncate|turns|uncurry|xor)\b/,number:/\b(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?|0x[0-9a-f]+)\b/i,operator:/\s\.\s|[+\-/*=.$<>:&|^?%#@~!]{2,}|[+\-/*=$<>:&|^?%#@~!]/,hvariable:/\b(?:[A-Z]\w*\.)*[a-z]\w*\b/,constant:/\b(?:[A-Z]\w*\.)*[A-Z]\w*\b/,punctuation:/[{}[\]|(),.:]/};
\ No newline at end of file
diff --git a/components/prism-git.js b/components/prism-git.js
index 54f5ea7..d9bee8f 100644
--- a/components/prism-git.js
+++ b/components/prism-git.js
@@ -64,5 +64,5 @@ Prism.languages.git = {
 	 *
 	 *     Add of a new line
 	 */
-	'commit_sha1': /^commit \w{40}$/m
+	'commit-sha1': /^commit \w{40}$/m
 };
diff --git a/components/prism-git.min.js b/components/prism-git.min.js
index 8166591..3d5831a 100644
--- a/components/prism-git.min.js
+++ b/components/prism-git.min.js
@@ -1 +1 @@
-Prism.languages.git={comment:/^#.*/m,deleted:/^[-–].*/m,inserted:/^\+.*/m,string:/("|')(?:\\.|(?!\1)[^\\\r\n])*\1/m,command:{pattern:/^.*\$ git .*$/m,inside:{parameter:/\s--?\w+/m}},coord:/^@@.*@@$/m,commit_sha1:/^commit \w{40}$/m};
\ No newline at end of file
+Prism.languages.git={comment:/^#.*/m,deleted:/^[-–].*/m,inserted:/^\+.*/m,string:/("|')(?:\\.|(?!\1)[^\\\r\n])*\1/m,command:{pattern:/^.*\$ git .*$/m,inside:{parameter:/\s--?\w+/m}},coord:/^@@.*@@$/m,"commit-sha1":/^commit \w{40}$/m};
\ No newline at end of file
diff --git a/components/prism-ocaml.js b/components/prism-ocaml.js
index a13ded0..101c82b 100644
--- a/components/prism-ocaml.js
+++ b/components/prism-ocaml.js
@@ -19,7 +19,7 @@ Prism.languages.ocaml = {
 		pattern: /\B~\w+/,
 		alias: 'function'
 	},
-	'type_variable': {
+	'type-variable': {
 		pattern: /\B'\w+/,
 		alias: 'function'
 	},
diff --git a/components/prism-ocaml.min.js b/components/prism-ocaml.min.js
index b4ea3c5..016c477 100644
--- a/components/prism-ocaml.min.js
+++ b/components/prism-ocaml.min.js
@@ -1 +1 @@
-Prism.languages.ocaml={comment:/\(\*[\s\S]*?\*\)/,string:[{pattern:/"(?:\\.|[^\\\r\n"])*"/,greedy:!0},{pattern:/(['`])(?:\\(?:\d+|x[\da-f]+|.)|(?!\1)[^\\\r\n])\1/i,greedy:!0}],number:/\b(?:0x[\da-f][\da-f_]+|(?:0[bo])?\d[\d_]*\.?[\d_]*(?:e[+-]?[\d_]+)?)/i,directive:{pattern:/\B#\w+/,alias:"important"},label:{pattern:/\B~\w+/,alias:"function"},type_variable:{pattern:/\B'\w+/,alias:"function"},variant:{pattern:/`\w+/,alias:"variable"},module:{pattern:/\b[A-Z]\w+/,alias:"variable"},keyword:/\b(?:as|assert|begin|class|constraint|do|done|downto|else|end|exception|external|for|fun|function|functor|if|in|include|inherit|initializer|lazy|let|match|method|module|mutable|new|nonrec|object|of|open|private|rec|sig|struct|then|to|try|type|val|value|virtual|when|where|while|with)\b/,boolean:/\b(?:false|true)\b/,operator:/:=|[=<>@^|&+\-*\/$%!?~][!$%&*+\-.\/:<=>?@^|~]*|\b(?:and|asr|land|lor|lsl|lsr|lxor|mod|or)\b/,punctuation:/[(){}\[\]|.,:;]|\b_\b/};
\ No newline at end of file
+Prism.languages.ocaml={comment:/\(\*[\s\S]*?\*\)/,string:[{pattern:/"(?:\\.|[^\\\r\n"])*"/,greedy:!0},{pattern:/(['`])(?:\\(?:\d+|x[\da-f]+|.)|(?!\1)[^\\\r\n])\1/i,greedy:!0}],number:/\b(?:0x[\da-f][\da-f_]+|(?:0[bo])?\d[\d_]*\.?[\d_]*(?:e[+-]?[\d_]+)?)/i,directive:{pattern:/\B#\w+/,alias:"important"},label:{pattern:/\B~\w+/,alias:"function"},"type-variable":{pattern:/\B'\w+/,alias:"function"},variant:{pattern:/`\w+/,alias:"variable"},module:{pattern:/\b[A-Z]\w+/,alias:"variable"},keyword:/\b(?:as|assert|begin|class|constraint|do|done|downto|else|end|exception|external|for|fun|function|functor|if|in|include|inherit|initializer|lazy|let|match|method|module|mutable|new|nonrec|object|of|open|private|rec|sig|struct|then|to|try|type|val|value|virtual|when|where|while|with)\b/,boolean:/\b(?:false|true)\b/,operator:/:=|[=<>@^|&+\-*\/$%!?~][!$%&*+\-.\/:<=>?@^|~]*|\b(?:and|asr|land|lor|lsl|lsr|lxor|mod|or)\b/,punctuation:/[(){}\[\]|.,:;]|\b_\b/};
\ No newline at end of file
diff --git a/tests/languages/elm/import-statement_feature.test b/tests/languages/elm/import-statement_feature.test
new file mode 100644
index 0000000..467d25f
--- /dev/null
+++ b/tests/languages/elm/import-statement_feature.test
@@ -0,0 +1,48 @@
+import Foo
+import Foo_42.Bar as Foobar
+import Foo.Bar as Foo.Baz
+import List exposing (map)
+import Json.Decode as Json exposing (Decoder)
+
+----------------------------------------------------
+
+[
+	["import-statement", [
+		["keyword", "import"],
+		" Foo"
+	]],
+	["import-statement", [
+		["keyword", "import"],
+		" Foo_42.Bar ",
+		["keyword", "as"],
+		" Foobar"
+	]],
+	["import-statement", [
+		["keyword", "import"],
+		" Foo.Bar ",
+		["keyword", "as"],
+		" Foo.Baz"
+	]],
+	["import-statement", [
+		["keyword", "import"],
+		" List ",
+		["keyword", "exposing"]
+	]],
+	["punctuation", "("],
+	["hvariable", "map"],
+	["punctuation", ")"],
+	["import-statement", [
+		["keyword", "import"],
+		" Json.Decode ",
+		["keyword", "as"],
+		" Json ",
+		["keyword", "exposing"]
+	]],
+	["punctuation", "("],
+	["constant", "Decoder"],
+	["punctuation", ")"]
+]
+
+----------------------------------------------------
+
+Checks for import statement.
diff --git a/tests/languages/elm/import_statement_feature.test b/tests/languages/elm/import_statement_feature.test
deleted file mode 100644
index c294036..0000000
--- a/tests/languages/elm/import_statement_feature.test
+++ /dev/null
@@ -1,48 +0,0 @@
-import Foo
-import Foo_42.Bar as Foobar
-import Foo.Bar as Foo.Baz
-import List exposing (map)
-import Json.Decode as Json exposing (Decoder)
-
-----------------------------------------------------
-
-[
-	["import_statement", [
-		["keyword", "import"],
-		" Foo"
-	]],
-	["import_statement", [
-		["keyword", "import"],
-		" Foo_42.Bar ",
-		["keyword", "as"],
-		" Foobar"
-	]],
-	["import_statement", [
-		["keyword", "import"],
-		" Foo.Bar ",
-		["keyword", "as"],
-		" Foo.Baz"
-	]],
-	["import_statement", [
-		["keyword", "import"],
-		" List ",
-		["keyword", "exposing"]
-	]],
-	["punctuation", "("],
-	["hvariable", "map"],
-	["punctuation", ")"],
-	["import_statement", [
-		["keyword", "import"],
-		" Json.Decode ",
-		["keyword", "as"],
-		" Json ",
-		["keyword", "exposing"]
-	]],
-	["punctuation", "("],
-	["constant", "Decoder"],
-	["punctuation", ")"]
-]
-
-----------------------------------------------------
-
-Checks for import statement.
diff --git a/tests/languages/git/commit-sha1_feature.test b/tests/languages/git/commit-sha1_feature.test
new file mode 100644
index 0000000..62f3e02
--- /dev/null
+++ b/tests/languages/git/commit-sha1_feature.test
@@ -0,0 +1,15 @@
+commit a11a14ef7e26f2ca62d4b35eac455ce636d0dc09
+commit 87edc4ad8c71b95f6e46f736eb98b742859abd95
+commit 3102416a90c431400d2e2a14e707fb7fd6d9e06d
+
+----------------------------------------------------
+
+[
+	["commit-sha1", "commit a11a14ef7e26f2ca62d4b35eac455ce636d0dc09"],
+	["commit-sha1", "commit 87edc4ad8c71b95f6e46f736eb98b742859abd95"],
+	["commit-sha1", "commit 3102416a90c431400d2e2a14e707fb7fd6d9e06d"]
+]
+
+----------------------------------------------------
+
+Checks for commit SHA1.
diff --git a/tests/languages/git/commit_sha1_feature.test b/tests/languages/git/commit_sha1_feature.test
deleted file mode 100644
index fbc58ed..0000000
--- a/tests/languages/git/commit_sha1_feature.test
+++ /dev/null
@@ -1,15 +0,0 @@
-commit a11a14ef7e26f2ca62d4b35eac455ce636d0dc09
-commit 87edc4ad8c71b95f6e46f736eb98b742859abd95
-commit 3102416a90c431400d2e2a14e707fb7fd6d9e06d
-
-----------------------------------------------------
-
-[
-	["commit_sha1", "commit a11a14ef7e26f2ca62d4b35eac455ce636d0dc09"],
-	["commit_sha1", "commit 87edc4ad8c71b95f6e46f736eb98b742859abd95"],
-	["commit_sha1", "commit 3102416a90c431400d2e2a14e707fb7fd6d9e06d"]
-]
-
-----------------------------------------------------
-
-Checks for commit SHA1.
\ No newline at end of file
diff --git a/tests/languages/ocaml/type-variable_feature.test b/tests/languages/ocaml/type-variable_feature.test
new file mode 100644
index 0000000..9c89b8a
--- /dev/null
+++ b/tests/languages/ocaml/type-variable_feature.test
@@ -0,0 +1,13 @@
+'Foo
+'bar_42
+
+----------------------------------------------------
+
+[
+	["type-variable", "'Foo"],
+	["type-variable", "'bar_42"]
+]
+
+----------------------------------------------------
+
+Checks for type variables.
diff --git a/tests/languages/ocaml/type_variable_feature.test b/tests/languages/ocaml/type_variable_feature.test
deleted file mode 100644
index 7f680e4..0000000
--- a/tests/languages/ocaml/type_variable_feature.test
+++ /dev/null
@@ -1,13 +0,0 @@
-'Foo
-'bar_42
-
-----------------------------------------------------
-
-[
-	["type_variable", "'Foo"],
-	["type_variable", "'bar_42"]
-]
-
-----------------------------------------------------
-
-Checks for type variables.
\ No newline at end of file
diff --git a/tests/pattern-tests.js b/tests/pattern-tests.js
index cbf1d54..15272c9 100644
--- a/tests/pattern-tests.js
+++ b/tests/pattern-tests.js
@@ -291,7 +291,7 @@ function testPatterns(Prism) {
 	});
 
 	it('- should have nice names and aliases', function () {
-		const niceName = /^[a-z][a-z\d]*(?:[-_][a-z\d]+)*$/;
+		const niceName = /^[a-z][a-z\d]*(?:-[a-z\d]+)*$/;
 		function testName(name, desc = 'token name') {
 			if (!niceName.test(name)) {
 				assert.fail(`The ${desc} '${name}' does not match ${niceName}.\n\n`