add more tests
This commit is contained in:
parent
4dd3475fd9
commit
c6e4e4fa1d
1 changed files with 24 additions and 5 deletions
|
|
@ -38,9 +38,14 @@ define(function(require, exports, module) {
|
|||
var assert = require("../../test/assertions");
|
||||
var coffee = require("../coffee/coffee-script");
|
||||
|
||||
function assertLocation(e, sl, sc, el, ec) {
|
||||
assert.equal(e.location.first_line, sl);
|
||||
assert.equal(e.location.first_column, sc);
|
||||
assert.equal(e.location.last_line, el);
|
||||
assert.equal(e.location.last_column, ec);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
"test parse valid coffee script": function() {
|
||||
coffee.parse("square = (x) -> x * x");
|
||||
},
|
||||
|
|
@ -50,10 +55,24 @@ module.exports = {
|
|||
coffee.parse("a = 12 f");
|
||||
} catch (e) {
|
||||
assert.equal(e.message, "Unexpected 'IDENTIFIER'");
|
||||
assert.equal(e.location.first_line, 0);
|
||||
assert.equal(e.location.first_column, 7);
|
||||
assert.equal(e.location.last_line, 0);
|
||||
assert.equal(e.location.last_column, 7);
|
||||
assertLocation(e, 0, 4, 0, 5);
|
||||
}
|
||||
},
|
||||
|
||||
"test parse missing bracket": function() {
|
||||
try {
|
||||
coffee.parse("a = 12 f {\n\n");
|
||||
} catch (e) {
|
||||
assert.equal(e.message, "missing }");
|
||||
assertLocation(e, 0, 10, 0, 10);
|
||||
}
|
||||
},
|
||||
"test unexpected indent": function() {
|
||||
try {
|
||||
coffee.parse("a\n a\n");
|
||||
} catch (e) {
|
||||
assert.equal(e.message, "Unexpected 'INDENT'");
|
||||
assertLocation(e, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue