Tests: Stricter pattern for nice-token-names test (#2588)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
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`