From c6e4e4fa1daec79f6b0862089e9fb1db4815347e Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 18 Apr 2013 18:07:14 +0400 Subject: [PATCH] add more tests --- lib/ace/mode/coffee/parser_test.js | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/lib/ace/mode/coffee/parser_test.js b/lib/ace/mode/coffee/parser_test.js index c71f6552..a3082bd6 100644 --- a/lib/ace/mode/coffee/parser_test.js +++ b/lib/ace/mode/coffee/parser_test.js @@ -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); } } };