all tests are working now
This commit is contained in:
parent
fa4d88830c
commit
97c24a7769
5 changed files with 118 additions and 96 deletions
|
|
@ -64,7 +64,8 @@ JavaScriptHighlightRules = function() {
|
||||||
// regexps are ordered -> the first match is used
|
// regexps are ordered -> the first match is used
|
||||||
|
|
||||||
this.$rules = {
|
this.$rules = {
|
||||||
"start" : [ {
|
"start" : [
|
||||||
|
{
|
||||||
token : "comment",
|
token : "comment",
|
||||||
regex : "\\/\\/.*$"
|
regex : "\\/\\/.*$"
|
||||||
},
|
},
|
||||||
|
|
@ -129,31 +130,38 @@ JavaScriptHighlightRules = function() {
|
||||||
}, {
|
}, {
|
||||||
token : "text",
|
token : "text",
|
||||||
regex : "\\s+"
|
regex : "\\s+"
|
||||||
} ],
|
}
|
||||||
"comment" : [ {
|
],
|
||||||
|
"comment" : [
|
||||||
|
{
|
||||||
token : "comment", // closing comment
|
token : "comment", // closing comment
|
||||||
regex : ".*?\\*\\/",
|
regex : ".*?\\*\\/",
|
||||||
next : "start"
|
next : "start"
|
||||||
}, {
|
}, {
|
||||||
token : "comment", // comment spanning whole line
|
token : "comment", // comment spanning whole line
|
||||||
regex : ".+"
|
regex : ".+"
|
||||||
} ],
|
}
|
||||||
"qqstring" : [ {
|
],
|
||||||
|
"qqstring" : [
|
||||||
|
{
|
||||||
token : "string",
|
token : "string",
|
||||||
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
|
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
|
||||||
next : "start"
|
next : "start"
|
||||||
}, {
|
}, {
|
||||||
token : "string",
|
token : "string",
|
||||||
regex : '.+'
|
regex : '.+'
|
||||||
} ],
|
}
|
||||||
"qstring" : [ {
|
],
|
||||||
|
"qstring" : [
|
||||||
|
{
|
||||||
token : "string",
|
token : "string",
|
||||||
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
|
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
|
||||||
next : "start"
|
next : "start"
|
||||||
}, {
|
}, {
|
||||||
token : "string",
|
token : "string",
|
||||||
regex : '.+'
|
regex : '.+'
|
||||||
} ]
|
}
|
||||||
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
this.addRules(docComment.getRules(), "doc-");
|
this.addRules(docComment.getRules(), "doc-");
|
||||||
|
|
|
||||||
|
|
@ -74,10 +74,17 @@ var Test = {
|
||||||
assert.equal("lparen", tokens[0].type);
|
assert.equal("lparen", tokens[0].type);
|
||||||
assert.equal("text", tokens[1].type);
|
assert.equal("text", tokens[1].type);
|
||||||
assert.equal("rparen", tokens[2].type);
|
assert.equal("rparen", tokens[2].type);
|
||||||
|
},
|
||||||
|
|
||||||
|
"test for last rule in ruleset to catch capturing group bugs" : function() {
|
||||||
|
var tokens = this.tokenizer.getLineTokens("top", "start").tokens;
|
||||||
|
|
||||||
|
assert.equal(1, tokens.length);
|
||||||
|
assert.equal("support.type", tokens[0].type);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = require("async/test").testcase(Test);
|
module.exports = require("async/test").testcase(Test, "css tokenizer");
|
||||||
|
|
||||||
if (module === require.main)
|
if (module === require.main)
|
||||||
module.exports.exec()
|
module.exports.exec()
|
||||||
|
|
@ -125,10 +125,10 @@ var Test = {
|
||||||
|
|
||||||
"test: trigger outdent if line is space and new text starts with closing brace" : function() {
|
"test: trigger outdent if line is space and new text starts with closing brace" : function() {
|
||||||
assert.ok(this.mode.checkOutdent("start", " ", " }"));
|
assert.ok(this.mode.checkOutdent("start", " ", " }"));
|
||||||
assert.equal(this.mode.checkOutdent("start", " a ", " }"));
|
assert.ok(!this.mode.checkOutdent("start", " a ", " }"));
|
||||||
assert.equal(this.mode.checkOutdent("start", "", "}"));
|
assert.ok(!this.mode.checkOutdent("start", "", "}"));
|
||||||
assert.equal(this.mode.checkOutdent("start", " ", "a }"));
|
assert.ok(!this.mode.checkOutdent("start", " ", "a }"));
|
||||||
assert.equal(this.mode.checkOutdent("start", " }", "}"));
|
assert.ok(!this.mode.checkOutdent("start", " }", "}"));
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: auto outdent should indent the line with the same indent as the line with the matching opening brace" : function() {
|
"test: auto outdent should indent the line with the same indent as the line with the matching opening brace" : function() {
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,13 @@ var Test = {
|
||||||
assert.equal("lparen", tokens[0].type);
|
assert.equal("lparen", tokens[0].type);
|
||||||
assert.equal("text", tokens[1].type);
|
assert.equal("text", tokens[1].type);
|
||||||
assert.equal("rparen", tokens[2].type);
|
assert.equal("rparen", tokens[2].type);
|
||||||
|
},
|
||||||
|
|
||||||
|
"test for last rule in ruleset to catch capturing group bugs" : function() {
|
||||||
|
var tokens = this.tokenizer.getLineTokens("}", "start").tokens;
|
||||||
|
|
||||||
|
assert.equal(1, tokens.length);
|
||||||
|
assert.equal("rparen", tokens[0].type);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue