Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: Added test for nice token names #1911

Merged
merged 2 commits into from
Sep 3, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -7,10 +7,10 @@
"scripts": {
"test:aliases": "mocha tests/aliases-test.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:languages && npm run test:plugins && npm run test:aliases && npm run test:regex"
"test": "npm run test:runner && 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