diff --git a/lib/ace/mode/coffee/parser_test.js b/lib/ace/mode/coffee/parser_test.js index a3082bd6..e4ccf1bb 100644 --- a/lib/ace/mode/coffee/parser_test.js +++ b/lib/ace/mode/coffee/parser_test.js @@ -45,35 +45,39 @@ function assertLocation(e, sl, sc, el, ec) { assert.equal(e.location.last_column, ec); } +function parse(str) { + try { + coffee.parse(str).compile(); + } catch (e) { + return e; + } +} + module.exports = { "test parse valid coffee script": function() { coffee.parse("square = (x) -> x * x"); }, "test parse invalid coffee script": function() { - try { - coffee.parse("a = 12 f"); - } catch (e) { - assert.equal(e.message, "Unexpected 'IDENTIFIER'"); - assertLocation(e, 0, 4, 0, 5); - } + var e = parse("a = 12 f"); + assert.equal(e.message, "Unexpected 'IDENTIFIER'"); + 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); - } + var e = parse("a = 12 f {\n\n"); + 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); - } + var e = parse("a\n a\n"); + assert.equal(e.message, "Unexpected 'INDENT'"); + assertLocation(e, 0, 0, 0, 0); + }, + "test invalid destructuring": function() { + var e = parse("\n{b: 5} = {}"); + assert.equal(e.message, '"5" cannot be assigned'); + assertLocation(e, 1, 4, 1, 4); } }; diff --git a/lib/ace/mode/coffee_worker.js b/lib/ace/mode/coffee_worker.js index f22640de..a5f700f8 100644 --- a/lib/ace/mode/coffee_worker.js +++ b/lib/ace/mode/coffee_worker.js @@ -40,7 +40,7 @@ window.addEventListener = function() {}; var Worker = exports.Worker = function(sender) { Mirror.call(this, sender); - this.setTimeout(200); + this.setTimeout(250); }; oop.inherits(Worker, Mirror); @@ -51,7 +51,7 @@ oop.inherits(Worker, Mirror); var value = this.doc.getValue(); try { - coffee.parse(value); + coffee.parse(value).compile(); } catch(e) { var loc = e.location; if (loc) {