Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'goatslacker-coffee-script'
  • Loading branch information
WolfgangKluge committed Mar 3, 2012
2 parents 40b7213 + 91de559 commit d9e6d7f
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 13 deletions.
4 changes: 4 additions & 0 deletions jshint.js
Expand Up @@ -2413,6 +2413,10 @@ loop: for (;;) {
warning("Do not use 'new' for side effects.");
}

if (nexttoken.id === ',') {
return comma();
}

if (nexttoken.id !== ';') {
if (!option.asi) {
// If this is the last statement in a block that ends on
Expand Down
22 changes: 9 additions & 13 deletions tests/regression/prototype.js
Expand Up @@ -26,9 +26,6 @@ exports.prototype_1_7 = function () {
.addError(451, "Missing semicolon.")
.addError(482, "Unescaped '^'.")
.addError(482, "Unescaped '['.")
.addError(563, "Missing semicolon.")
.addError(563, "Expected an identifier and instead saw ','.")
.addError(563, "Missing semicolon.")
.addError(633, "Use '!==' to compare with 'undefined'.")
.addError(737, "Use '===' to compare with ''.")
.addError(741, "Wrap the /regexp/ literal in parens to disambiguate the slash operator.")
Expand All @@ -40,15 +37,6 @@ exports.prototype_1_7 = function () {
.addError(1224, "Unnecessary semicolon.")
.addError(1916, "Missing semicolon.")
.addError(2034, "Missing semicolon.")
.addError(2210, "Missing semicolon.")
.addError(2210, "Expected an identifier and instead saw ','.")
.addError(2210, "Missing semicolon.")
.addError(2222, "Missing semicolon.")
.addError(2222, "Expected an identifier and instead saw ','.")
.addError(2222, "Missing semicolon.")
.addError(2345, "Missing semicolon.")
.addError(2345, "Expected an identifier and instead saw ','.")
.addError(2345, "Missing semicolon.")
.addError(2662, "Missing semicolon.")
.addError(2735, "Missing semicolon.")
.addError(2924, "Missing semicolon.")
Expand All @@ -59,6 +47,13 @@ exports.prototype_1_7 = function () {
.addError(3844, "'positionedOffset' is a function.")
.addError(3860, "'cumulativeOffset' is a function.")
.addError(3974, "Unescaped '['.")
.addError(3987, "Variable context was not declared correctly.")
.addError(4000, "Expected ')' to match '(' from line 4000 and instead saw ','.")
.addError(4000, "Expected ')' to match '(' from line 4000 and instead saw 'm'.")
.addError(4000, "Expected an identifier and instead saw '='.")
.addError(4000, "Missing semicolon.")
.addError(4000, "Missing semicolon.")
.addError(4000, "Expected an identifier and instead saw ')'.")
.test(src, {
sub: true,
lastsemic: true,
Expand All @@ -67,6 +62,7 @@ exports.prototype_1_7 = function () {
eqnull: true,
laxbreak: true,
boss: true,
expr: true
expr: true,
maxerr: 9001
});
};
31 changes: 31 additions & 0 deletions tests/unit/fixtures/comma.js
@@ -0,0 +1,31 @@
var _ref, count, starts, compact, last;
_ref = test, count = _ref.count, starts = _ref.starts, compact = _ref.compact, last = _ref.last;


var channels = [{ 'one': 'channel' }];
for ( var i = 0, channel, len = channels.length; channel = channels[i], i < len; i++ ) {
// Doing stuff
}


// !!
// see parser.js [exports.comma]
// comma operator breaks jshint...
// the next line should result in an error (parser or jshint)
func tion Model(data, block) {
// ...
}
Model.create = function(base, options) {
// If options is falsy, base wasn't provided so args need shuffling.
options || (options = base, base = Model); // <-- massive amount of JSHint complaining here!
console.log(base, options);
// ...
};


function gh56() {
var args = Array.prototype.slice.call( arguments );
args[0] = error( args[0] );

callback && callback.apply( commit, (args.push( commit ), args) );
}
21 changes: 21 additions & 0 deletions tests/unit/parser.js
Expand Up @@ -316,3 +316,24 @@ exports.jsonMode = function () {
.addError(7, "Avoid 0x-. '0x332'.")
.test(code, {multistr: true});
};

exports.comma = function () {
var src = fs.readFileSync(__dirname + "/fixtures/comma.js", "utf8");

// !!
// there are more errors in comma.js
// but comma-operator isn't finished, yet - so jshint currently breaks at line 8
TestRun()
.addError(6, 'Expected a conditional expression and instead saw an assignment.')
.addError(6, 'Expected \';\' and instead saw \',\'.')
.addError(6, 'Expected \')\' to match \'(\' from line 6 and instead saw \';\'.')
.addError(6, 'Missing semicolon.')
.addError(6, 'Expected an identifier and instead saw \')\'.')
.addError(6, 'Expected an assignment or function call and instead saw an expression.')
.addError(6, 'Missing semicolon.')
.addError(6, 'Expected to see a statement and instead saw a block.')
.addError(6, 'Expected an assignment or function call and instead saw an expression.')
.addError(6, 'Missing semicolon.')
.addError(8, 'Expected \'(end)\' and instead saw \'}\'.')
.test(src);
};

0 comments on commit d9e6d7f

Please sign in to comment.