From d607326cc702a8bb379afec1d34713ccb6855799 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Thu, 13 Oct 2011 11:12:50 -0400 Subject: [PATCH] Don't tolerate no-selector elements, tolerate Map, adds tests --- lib/carto/parser.js | 2 +- test/errorhandling.test.js | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/carto/parser.js b/lib/carto/parser.js index 2ce1f36..31ecfcb 100644 --- a/lib/carto/parser.js +++ b/lib/carto/parser.js @@ -721,7 +721,7 @@ carto.Parser = function Parser(env) { // element: function() { var e; - if (e = $("^(?:(?:[.#][\w-]+|\*|Map))")) { + if (e = $(/^(?:[.#][\w-]+|\*|Map)/)) { return new tree.Element(e); } }, diff --git a/test/errorhandling.test.js b/test/errorhandling.test.js index cf2c118..1c9a81c 100644 --- a/test/errorhandling.test.js +++ b/test/errorhandling.test.js @@ -12,12 +12,22 @@ helper.files('errorhandling', 'mml', function(file) { var completed = false; var renderResult; var mml = helper.mml(file); - new carto.Renderer({ - paths: [ path.dirname(file) ], - data_dir: path.join(__dirname, '../data'), - local_data_dir: path.join(__dirname, 'rendering'), - filename: file - }).render(mml, function (err) { + try { + new carto.Renderer({ + paths: [ path.dirname(file) ], + data_dir: path.join(__dirname, '../data'), + local_data_dir: path.join(__dirname, 'rendering'), + filename: file + }).render(mml, function (err) { + var result = helper.resultFile(file); + var output = err.message; + // @TODO for some reason, fs.readFile includes an additional \n + // at the end of read files. Determine why. + fs.readFile(helper.resultFile(file), 'utf8', function(err, data) { + if (!err) assert.deepEqual(output, data.substr(0, data.length - 1)); + }); + }); + } catch(err) { var result = helper.resultFile(file); var output = err.message; // @TODO for some reason, fs.readFile includes an additional \n @@ -25,7 +35,8 @@ helper.files('errorhandling', 'mml', function(file) { fs.readFile(helper.resultFile(file), 'utf8', function(err, data) { if (!err) assert.deepEqual(output, data.substr(0, data.length - 1)); }); - }); + } + beforeExit(function() { /*