Skip to content

Commit

Permalink
cleaned up expected numberSequence error message grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate Young committed Apr 8, 2010
1 parent ad238d1 commit a6b6326
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion QuickPietJS/lib/validations.js
Expand Up @@ -23,7 +23,8 @@ Validations = {
results.push(parseInt(value));
});
if(length && results.length != length) {
throw new SyntaxError("Expected " + length + " integers, but found " + results.length);
var clause = length == 1 ? (length + " integer,") : (length + " integers,");
throw new SyntaxError("Expected " + clause + " but found " + results.length);
}
return results;
},
Expand Down
4 changes: 4 additions & 0 deletions QuickPietJS/spec/unit/validations.spec.js
Expand Up @@ -38,6 +38,10 @@ describe 'Validations'
-{ Validations.numberSequence('9 3 2', 2)}.should.throw_error SyntaxError, "Expected 2 integers, but found 3"
Validations.numberSequence('9 3', 2).should.eql [9, 3]
end

it 'should use proper grammar in exception message'
-{ Validations.numberSequence('9 1', 1)}.should.throw_error SyntaxError, "Expected 1 integer, but found 2"
end
end

describe 'positive'
Expand Down

0 comments on commit a6b6326

Please sign in to comment.