Skip to content

Commit 0df60be

Browse files
Tests: Stricter pattern for nice-token-names test (#2588)
1 parent 25bdb49 commit 0df60be

10 files changed

+30
-30
lines changed

components/prism-elm.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Prism.languages.elm = {
2-
comment: /--.*|{-[\s\S]*?-}/,
3-
char: {
2+
'comment': /--.*|{-[\s\S]*?-}/,
3+
'char': {
44
pattern: /'(?:[^\\'\r\n]|\\(?:[abfnrtv\\']|\d+|x[0-9a-fA-F]+))'/,
55
greedy: true
66
},
7-
string: [
7+
'string': [
88
{
99
// Multiline strings are wrapped in triple ". Quotes may appear unescaped.
1010
pattern: /"""[\s\S]*?"""/,
@@ -15,30 +15,30 @@ Prism.languages.elm = {
1515
greedy: true
1616
}
1717
],
18-
import_statement: {
18+
'import-statement': {
1919
// The imported or hidden names are not included in this import
2020
// statement. This is because we want to highlight those exactly like
2121
// we do for the names in the program.
2222
pattern: /^\s*import\s+[A-Z]\w*(?:\.[A-Z]\w*)*(?:\s+as\s+(?:[A-Z]\w*)(?:\.[A-Z]\w*)*)?(?:\s+exposing\s+)?/m,
2323
inside: {
24-
keyword: /\b(?:import|as|exposing)\b/
24+
'keyword': /\b(?:import|as|exposing)\b/
2525
}
2626
},
27-
keyword: /\b(?:alias|as|case|else|exposing|if|in|infixl|infixr|let|module|of|then|type)\b/,
27+
'keyword': /\b(?:alias|as|case|else|exposing|if|in|infixl|infixr|let|module|of|then|type)\b/,
2828
// These are builtin variables only. Constructors are highlighted later as a constant.
29-
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/,
29+
'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/,
3030
// decimal integers and floating point numbers | hexadecimal integers
31-
number: /\b(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?|0x[0-9a-f]+)\b/i,
31+
'number': /\b(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?|0x[0-9a-f]+)\b/i,
3232
// Most of this is needed because of the meaning of a single '.'.
3333
// If it stands alone freely, it is the function composition.
3434
// It may also be a separator between a module name and an identifier => no
3535
// operator. If it comes together with other special characters it is an
3636
// operator too.
3737
// Valid operator characters in 0.18: +-/*=.$<>:&|^?%#@~!
3838
// Ref: https://groups.google.com/forum/#!msg/elm-dev/0AHSnDdkSkQ/E0SVU70JEQAJ
39-
operator: /\s\.\s|[+\-/*=.$<>:&|^?%#@~!]{2,}|[+\-/*=$<>:&|^?%#@~!]/,
39+
'operator': /\s\.\s|[+\-/*=.$<>:&|^?%#@~!]{2,}|[+\-/*=$<>:&|^?%#@~!]/,
4040
// In Elm, nearly everything is a variable, do not highlight these.
41-
hvariable: /\b(?:[A-Z]\w*\.)*[a-z]\w*\b/,
42-
constant: /\b(?:[A-Z]\w*\.)*[A-Z]\w*\b/,
43-
punctuation: /[{}[\]|(),.:]/
41+
'hvariable': /\b(?:[A-Z]\w*\.)*[a-z]\w*\b/,
42+
'constant': /\b(?:[A-Z]\w*\.)*[A-Z]\w*\b/,
43+
'punctuation': /[{}[\]|(),.:]/
4444
};

components/prism-elm.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/prism-git.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ Prism.languages.git = {
6464
*
6565
* Add of a new line
6666
*/
67-
'commit_sha1': /^commit \w{40}$/m
67+
'commit-sha1': /^commit \w{40}$/m
6868
};

components/prism-git.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/prism-ocaml.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Prism.languages.ocaml = {
1919
pattern: /\B~\w+/,
2020
alias: 'function'
2121
},
22-
'type_variable': {
22+
'type-variable': {
2323
pattern: /\B'\w+/,
2424
alias: 'function'
2525
},

components/prism-ocaml.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/languages/elm/import_statement_feature.test tests/languages/elm/import-statement_feature.test

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,31 @@ import Json.Decode as Json exposing (Decoder)
77
----------------------------------------------------
88

99
[
10-
["import_statement", [
10+
["import-statement", [
1111
["keyword", "import"],
1212
" Foo"
1313
]],
14-
["import_statement", [
14+
["import-statement", [
1515
["keyword", "import"],
1616
" Foo_42.Bar ",
1717
["keyword", "as"],
1818
" Foobar"
1919
]],
20-
["import_statement", [
20+
["import-statement", [
2121
["keyword", "import"],
2222
" Foo.Bar ",
2323
["keyword", "as"],
2424
" Foo.Baz"
2525
]],
26-
["import_statement", [
26+
["import-statement", [
2727
["keyword", "import"],
2828
" List ",
2929
["keyword", "exposing"]
3030
]],
3131
["punctuation", "("],
3232
["hvariable", "map"],
3333
["punctuation", ")"],
34-
["import_statement", [
34+
["import-statement", [
3535
["keyword", "import"],
3636
" Json.Decode ",
3737
["keyword", "as"],

tests/languages/git/commit_sha1_feature.test tests/languages/git/commit-sha1_feature.test

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ commit 3102416a90c431400d2e2a14e707fb7fd6d9e06d
55
----------------------------------------------------
66

77
[
8-
["commit_sha1", "commit a11a14ef7e26f2ca62d4b35eac455ce636d0dc09"],
9-
["commit_sha1", "commit 87edc4ad8c71b95f6e46f736eb98b742859abd95"],
10-
["commit_sha1", "commit 3102416a90c431400d2e2a14e707fb7fd6d9e06d"]
8+
["commit-sha1", "commit a11a14ef7e26f2ca62d4b35eac455ce636d0dc09"],
9+
["commit-sha1", "commit 87edc4ad8c71b95f6e46f736eb98b742859abd95"],
10+
["commit-sha1", "commit 3102416a90c431400d2e2a14e707fb7fd6d9e06d"]
1111
]
1212

1313
----------------------------------------------------
1414

15-
Checks for commit SHA1.
15+
Checks for commit SHA1.

tests/languages/ocaml/type_variable_feature.test tests/languages/ocaml/type-variable_feature.test

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
----------------------------------------------------
55

66
[
7-
["type_variable", "'Foo"],
8-
["type_variable", "'bar_42"]
7+
["type-variable", "'Foo"],
8+
["type-variable", "'bar_42"]
99
]
1010

1111
----------------------------------------------------
1212

13-
Checks for type variables.
13+
Checks for type variables.

tests/pattern-tests.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ function testPatterns(Prism) {
291291
});
292292

293293
it('- should have nice names and aliases', function () {
294-
const niceName = /^[a-z][a-z\d]*(?:[-_][a-z\d]+)*$/;
294+
const niceName = /^[a-z][a-z\d]*(?:-[a-z\d]+)*$/;
295295
function testName(name, desc = 'token name') {
296296
if (!niceName.test(name)) {
297297
assert.fail(`The ${desc} '${name}' does not match ${niceName}.\n\n`

0 commit comments

Comments
 (0)