Skip to content

Commit

Permalink
Added test for nice names (#1911)
Browse files Browse the repository at this point in the history
This adds a test which requires every token name to match a strict pattern to avoid inconsistent naming styles.
  • Loading branch information
RunDevelopment authored Sep 3, 2019
1 parent 5c68a55 commit 3fda5c9
Show file tree
Hide file tree
Showing 21 changed files with 515 additions and 412 deletions.
28 changes: 20 additions & 8 deletions components/prism-aspnet.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
Prism.languages.aspnet = Prism.languages.extend('markup', {
'page-directive tag': {
'page-directive': {
pattern: /<%\s*@.*%>/i,
alias: 'tag',
inside: {
'page-directive tag': /<%\s*@\s*(?:Assembly|Control|Implements|Import|Master(?:Type)?|OutputCache|Page|PreviousPageType|Reference|Register)?|%>/i,
'page-directive': {
pattern: /<%\s*@\s*(?:Assembly|Control|Implements|Import|Master(?:Type)?|OutputCache|Page|PreviousPageType|Reference|Register)?|%>/i,
alias: 'tag'
},
rest: Prism.languages.markup.tag.inside
}
},
'directive tag': {
'directive': {
pattern: /<%.*%>/i,
alias: 'tag',
inside: {
'directive tag': /<%\s*?[$=%#:]{0,2}|%>/i,
'directive': {
pattern: /<%\s*?[$=%#:]{0,2}|%>/i,
alias: 'tag'
},
rest: Prism.languages.csharp
}
}
Expand All @@ -19,18 +27,22 @@ Prism.languages.aspnet.tag.pattern = /<(?!%)\/?[^\s>\/]+(?:\s+[^\s>\/=]+(?:=(?:(

// match directives of attribute value foo="<% Bar %>"
Prism.languages.insertBefore('inside', 'punctuation', {
'directive tag': Prism.languages.aspnet['directive tag']
'directive': Prism.languages.aspnet['directive']
}, Prism.languages.aspnet.tag.inside["attr-value"]);

Prism.languages.insertBefore('aspnet', 'comment', {
'asp comment': /<%--[\s\S]*?--%>/
'asp-comment': {
pattern: /<%--[\s\S]*?--%>/,
alias: ['asp', 'comment']
}
});

// script runat="server" contains csharp, not javascript
Prism.languages.insertBefore('aspnet', Prism.languages.javascript ? 'script' : 'tag', {
'asp script': {
'asp-script': {
pattern: /(<script(?=.*runat=['"]?server['"]?)[\s\S]*?>)[\s\S]*?(?=<\/script>)/i,
lookbehind: true,
alias: ['asp', 'script'],
inside: Prism.languages.csharp || {}
}
});
});
2 changes: 1 addition & 1 deletion components/prism-aspnet.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions components/prism-jolie.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Prism.languages.insertBefore( 'jolie', 'keyword', {
pattern: /(\bAggregates\s*:\s*)(?:\w+(?:\s+with\s+\w+)?\s*,\s*)*\w+(?:\s+with\s+\w+)?/,
lookbehind: true,
inside: {
'withExtension': {
'with-extension': {
pattern: /\bwith\s+\w+/,
inside: {
'keyword' : /\bwith\b/
Expand Down Expand Up @@ -52,4 +52,4 @@ Prism.languages.insertBefore( 'jolie', 'keyword', {
}
}
}
});
});
2 changes: 1 addition & 1 deletion components/prism-jolie.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/prism-opencl.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/prism-opencl.min.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions components/prism-wiki.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ Prism.languages.wiki = Prism.languages.extend('markup', {
// TODO Multi-line
pattern: /('{2,5}).+?\1/,
inside: {
'bold italic': {
'bold-italic': {
pattern: /(''''').+?(?=\1)/,
lookbehind: true
lookbehind: true,
alias: ['bold', 'italic']
},
'bold': {
pattern: /(''')[^'](?:.*?[^'])?(?=\1)/,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-wiki.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"test:aliases": "mocha tests/aliases-test.js",
"test:core": "mocha tests/core/**/*.js",
"test:languages": "mocha tests/run.js",
"test:pattern": "mocha tests/pattern-tests.js",
"test:plugins": "mocha tests/plugins/**/*.js",
"test:regex": "mocha tests/regex-tests.js",
"test:runner": "mocha tests/testrunner-tests.js",
"test": "npm run test:runner && npm run test:core && npm run test:languages && npm run test:plugins && npm run test:aliases && npm run test:regex"
"test": "npm run test:runner && npm run test:core && npm run test:languages && npm run test:plugins && npm run test:aliases && npm run test:pattern"
},
"repository": {
"type": "git",
Expand Down
8 changes: 4 additions & 4 deletions tests/languages/aspnet/comment_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ bar --%>
----------------------------------------------------

[
["asp comment", "<%----%>"],
["asp comment", "<%--foo--%>"],
["asp comment", "<%-- foo\r\nbar --%>"]
["asp-comment", "<%----%>"],
["asp-comment", "<%--foo--%>"],
["asp-comment", "<%-- foo\r\nbar --%>"]
]

----------------------------------------------------

Checks for comments.
Checks for comments.
106 changes: 53 additions & 53 deletions tests/languages/aspnet/page-directive_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
----------------------------------------------------

[
["page-directive tag", [
["page-directive tag", "<%@Assembly"],
["page-directive", [
["page-directive", "<%@Assembly"],
["attr-name", [
"foo"
]],
Expand All @@ -24,69 +24,69 @@
"bar",
["punctuation", "\""]
]],
["page-directive tag", "%>"]
["page-directive", "%>"]
]],

["page-directive tag", [
["page-directive tag", "<% @Control"],
["attr-name", [
"foo"
]],
["attr-value", [
["punctuation", "="],
["punctuation", "\""],
"bar",
["punctuation", "\""]
]],
["page-directive tag", "%>"]
]],
["page-directive", [
["page-directive", "<% @Control"],
["attr-name", [
"foo"
]],
["attr-value", [
["punctuation", "="],
["punctuation", "\""],
"bar",
["punctuation", "\""]
]],
["page-directive", "%>"]
]],

["page-directive tag", [
["page-directive tag", "<%@ Implements"],
["page-directive tag", "%>"]
]],
["page-directive", [
["page-directive", "<%@ Implements"],
["page-directive", "%>"]
]],

["page-directive tag", [
["page-directive tag", "<%@Import"],
["page-directive tag", "%>"]
]],
["page-directive", [
["page-directive", "<%@Import"],
["page-directive", "%>"]
]],

["page-directive tag", [
["page-directive tag", "<%@Master"],
["page-directive tag", "%>"]
]],
["page-directive", [
["page-directive", "<%@Master"],
["page-directive", "%>"]
]],

["page-directive tag", [
["page-directive tag", "<%@MasterType"],
["page-directive tag", "%>"]
]],
["page-directive", [
["page-directive", "<%@MasterType"],
["page-directive", "%>"]
]],

["page-directive tag", [
["page-directive tag", "<%@OutputCache"],
["page-directive tag", "%>"]
]],
["page-directive", [
["page-directive", "<%@OutputCache"],
["page-directive", "%>"]
]],

["page-directive tag", [
["page-directive tag", "<%@Page"],
["page-directive tag", "%>"]
]],
["page-directive", [
["page-directive", "<%@Page"],
["page-directive", "%>"]
]],

["page-directive tag", [
["page-directive tag", "<%@PreviousPageType"],
["page-directive tag", "%>"]
]],
["page-directive", [
["page-directive", "<%@PreviousPageType"],
["page-directive", "%>"]
]],

["page-directive tag", [
["page-directive tag", "<%@Reference"],
["page-directive tag", "%>"]
]],
["page-directive", [
["page-directive", "<%@Reference"],
["page-directive", "%>"]
]],

["page-directive tag", [
["page-directive tag", "<%@Register"],
["page-directive tag", "%>"]
]]
["page-directive", [
["page-directive", "<%@Register"],
["page-directive", "%>"]
]]
]

----------------------------------------------------

Checks for all page directives.
Checks for all page directives.
98 changes: 49 additions & 49 deletions tests/languages/csharp+aspnet/directive_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,63 +8,63 @@
----------------------------------------------------

[
["directive tag", [
["directive tag", "<%:"],
["directive", [
["directive", "<%:"],
" Page",
["punctuation", "."],
"Title ",
["directive tag", "%>"]
["directive", "%>"]
]],

["directive tag", [
["directive tag", "<%#:"],
"Item",
["punctuation", "."],
"ProductID",
["directive tag", "%>"]
]],
["directive", [
["directive", "<%#:"],
"Item",
["punctuation", "."],
"ProductID",
["directive", "%>"]
]],

["tag", [
["tag", [
["punctuation", "<"],
"a"
]],
["attr-name", [
"href"
]],
["attr-value", [
["punctuation", "="],
["punctuation", "\""],
"ProductDetails.aspx?productID=",
["directive tag", [
["directive tag", "<%#:"],
"Item",
["punctuation", "."],
"ProductID",
["directive tag", "%>"]
]],
["punctuation", "\""]
]],
["punctuation", ">"]
]],
["tag", [
["tag", [
["punctuation", "<"],
"a"
]],
["attr-name", [
"href"
]],
["attr-value", [
["punctuation", "="],
["punctuation", "\""],
"ProductDetails.aspx?productID=",
["directive", [
["directive", "<%#:"],
"Item",
["punctuation", "."],
"ProductID",
["directive", "%>"]
]],
["punctuation", "\""]
]],
["punctuation", ">"]
]],

["directive tag", [
["directive tag", "<%"],
["keyword", "if"],
["punctuation", "("],
"foo",
["punctuation", ")"],
["punctuation", "{"],
["directive tag", "%>"]
]],
"\r\n\tfoobar\r\n",
["directive tag", [
["directive tag", "<%"],
["punctuation", "}"],
["directive tag", "%>"]
]]
["directive", [
["directive", "<%"],
["keyword", "if"],
["punctuation", "("],
"foo",
["punctuation", ")"],
["punctuation", "{"],
["directive", "%>"]
]],
"\r\n\tfoobar\r\n",
["directive", [
["directive", "<%"],
["punctuation", "}"],
["directive", "%>"]
]]
]

----------------------------------------------------

Checks for directives.
Checks for directives.
Loading

0 comments on commit 3fda5c9

Please sign in to comment.