From e6ba32bc07eb443973168d68d412b1129de47e63 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Wed, 1 Feb 2017 10:44:42 +0100 Subject: [PATCH 01/21] Revert "Throw an error when not valid ccss" --- lib/carto/renderer_js.js | 18 +--- test/rendering_js-strict.test.js | 142 ------------------------------- test/rendering_js.test.js | 3 +- 3 files changed, 5 insertions(+), 158 deletions(-) delete mode 100644 test/rendering_js-strict.test.js diff --git a/lib/carto/renderer_js.js b/lib/carto/renderer_js.js index 57adb8d..dd88cee 100644 --- a/lib/carto/renderer_js.js +++ b/lib/carto/renderer_js.js @@ -202,21 +202,12 @@ CartoCSS.prototype = { var layer = layers[key] = (layers[key] || { symbolizers: [] }); - for(var u = 0; u Date: Wed, 1 Feb 2017 11:16:03 +0100 Subject: [PATCH 02/21] Set tree data just before render happens --- lib/carto/renderer_js.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/carto/renderer_js.js b/lib/carto/renderer_js.js index 57adb8d..ae840c4 100644 --- a/lib/carto/renderer_js.js +++ b/lib/carto/renderer_js.js @@ -279,14 +279,14 @@ CartoCSS.prototype = { carto.RendererJS = function (options) { this.options = options || {}; - var reference = this.options.reference || require('./torque-reference').version.latest; - tree.Reference.setData(reference); this.options.mapnik_version = this.options.mapnik_version || 'latest'; + this.reference = this.options.reference || require('./torque-reference').version.latest; this.options.strict = this.options.hasOwnProperty('strict') ? this.options.strict : false; }; // Prepare a javascript object which contains the layers carto.RendererJS.prototype.render = function render(cartocss, callback) { + tree.Reference.setData(this.reference); return new CartoCSS(cartocss, this.options); } From 515fbd0991a8edd2563e05e108befd8cff9e9f8c Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Wed, 1 Feb 2017 11:23:39 +0100 Subject: [PATCH 03/21] Only set previous reference if it existed --- test/rendering_js-strict.test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/rendering_js-strict.test.js b/test/rendering_js-strict.test.js index 1247a2a..3339a8c 100644 --- a/test/rendering_js-strict.test.js +++ b/test/rendering_js-strict.test.js @@ -106,7 +106,9 @@ describe('RendererJS Strict Mode', function() { }); after(function() { - tree.Reference.setData(this.referenceData); + if (this.referenceData) { + tree.Reference.setData(this.referenceData); + } }); it('should fail if a feature is not supported and strict is turned on', function () { From 73154280794dda0d4177db9279713b909773e2bd Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Wed, 1 Feb 2017 12:15:46 +0100 Subject: [PATCH 04/21] Adds test to validate supported features are validated and work --- test/rendering_js-strict.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/rendering_js-strict.test.js b/test/rendering_js-strict.test.js index 3339a8c..3a530f4 100644 --- a/test/rendering_js-strict.test.js +++ b/test/rendering_js-strict.test.js @@ -141,4 +141,11 @@ describe('RendererJS Strict Mode', function() { new carto.RendererJS({reference: reference, mapnik_version: '1.0.0', strict: false }) )); + it('should pass if a feature is supported and strict is turned on', function () { + var RendererJS = new carto.RendererJS({reference: reference, mapnik_version: '1.0.0', strict: true }); + var cartocss = '#layer { line-width: 10 }'; + var shader = RendererJS.render(cartocss); + assert.ok(shader); + }); + }); From 510847a3b228c04ba0872a163d4dca71ebf395e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20L=C3=B3pez?= Date: Fri, 3 Feb 2017 15:58:56 +0100 Subject: [PATCH 05/21] Make the validation in the correct place --- lib/carto/renderer_js.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/carto/renderer_js.js b/lib/carto/renderer_js.js index ae840c4..ac4fea5 100644 --- a/lib/carto/renderer_js.js +++ b/lib/carto/renderer_js.js @@ -57,7 +57,7 @@ CartoCSS.Layer.prototype = { }, /** - * return the symbolizers that need to be rendered with + * return the symbolizers that need to be rendered with * this style. The order is the rendering order. * @returns a list with 3 possible values 'line', 'marker', 'polygon' */ @@ -99,7 +99,7 @@ CartoCSS.Layer.prototype = { // // given a geoemtry type returns the transformed one acording the CartoCSS - // For points there are two kind of types: point and sprite, the first one + // For points there are two kind of types: point and sprite, the first one // is a circle, second one is an image sprite // // the other geometry types are the same than geojson (polygon, linestring...) @@ -209,12 +209,6 @@ CartoCSS.prototype = { var value = rule.value.value[0].value[0].value.value; this.imageURLs.push(value); } - - rule.toXML(parse_env, {}); - } - - if (this.options.strict && parse_env.errors.message) { - throw new Error(parse_env.errors.message); } layer.frames = []; @@ -244,6 +238,13 @@ CartoCSS.prototype = { var done = {}; for(var i = 0; i < defs.length; ++i) { var def = defs[i]; + + def.toXML(parse_env, {}); + + if (this.options.strict && parse_env.errors.message) { + throw new Error(parse_env.errors.message); + } + var k = defKey(def); var layer = layers[k]; if(!done[k]) { From 0063ddba7f8c55535b617669062b0eec8349e441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Fri, 3 Mar 2017 14:36:14 +0100 Subject: [PATCH 06/21] Support '=~' operator --- lib/carto/tree/filterset.js | 3 +++ test/rendering_js.test.js | 41 ++++++++++++++++++++++++------------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/lib/carto/tree/filterset.js b/lib/carto/tree/filterset.js index 563bf3d..b02f706 100644 --- a/lib/carto/tree/filterset.js +++ b/lib/carto/tree/filterset.js @@ -92,6 +92,9 @@ tree.Filterset.prototype.toJS = function(env) { val = filter._val.toString(true); } var attrs = "data"; + if (op === '=~') { + return attrs + "['" + filter.key.value + "'].match(" + (val.is === 'string' ? "'" + val.toString().replace(/'/g, "\\'") + "'" : val) + ")"; + } return attrs + "['" + filter.key.value + "'] " + op + " " + (val.is === 'string' ? "'" + val.toString().replace(/'/g, "\\'") + "'" : val); }).join(' && '); }; diff --git a/test/rendering_js.test.js b/test/rendering_js.test.js index 5e5694b..e6e5939 100644 --- a/test/rendering_js.test.js +++ b/test/rendering_js.test.js @@ -4,24 +4,24 @@ var carto = require('../lib/carto'); describe('RenderingJS', function() { var shader; var style = [ - '#world {', - 'line-width: 2;', - 'line-color: #f00;', - '[frame-offset = 1] {', - 'line-width: 3;', - '}', - '[frame-offset = 2] {', - 'line-width: 3;', - '}', - '}', - '', - '#worls[frame-offset = 10] {', - 'line-width: 4;', + '#world {', + 'line-width: 2;', + 'line-color: #f00;', + '[frame-offset = 1] {', + 'line-width: 3;', + '}', + '[frame-offset = 2] {', + 'line-width: 3;', + '}', + '}', + '', + '#worls[frame-offset = 10] {', + 'line-width: 4;', '}' ].join('\n'); beforeEach(function() { - shader = (new carto.RendererJS({ debug: true })).render(style); + shader = (new carto.RendererJS({ debug: false })).render(style); }); it ("shold render layers", function() { @@ -183,4 +183,17 @@ describe('RenderingJS', function() { assert.equal(st.args[2].args[0].value, 10); }); + it("should not throw `ReferenceError`", function(){ + var css = [ + '#layer[name=~".*Cairo*"] {', + ' marker-width: 14;', + '}' + ].join('\n'); + + assert.doesNotThrow(function () { + var shader = (new carto.RendererJS({})).render(css); + var layer = shader.getLayers()[0]; + var value = layer.shader['marker-width'].style({ name: 'wadus' }, { zoom: 1 }); + }); + }); }); From c780998dc82b56cd71c33a1de3cb86a861400f66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Fri, 3 Mar 2017 15:27:42 +0100 Subject: [PATCH 07/21] Prevent TypeError when parsing '=~' operator --- lib/carto/tree/filterset.js | 2 +- test/rendering_js.test.js | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/carto/tree/filterset.js b/lib/carto/tree/filterset.js index b02f706..168816f 100644 --- a/lib/carto/tree/filterset.js +++ b/lib/carto/tree/filterset.js @@ -93,7 +93,7 @@ tree.Filterset.prototype.toJS = function(env) { } var attrs = "data"; if (op === '=~') { - return attrs + "['" + filter.key.value + "'].match(" + (val.is === 'string' ? "'" + val.toString().replace(/'/g, "\\'") + "'" : val) + ")"; + return "(typeof " + attrs + "['" + filter.key.value + "'] === 'string') && " + attrs + "['" + filter.key.value + "'].match(" + (val.is === 'string' ? "'" + val.toString().replace(/'/g, "\\'") + "'" : val) + ")"; } return attrs + "['" + filter.key.value + "'] " + op + " " + (val.is === 'string' ? "'" + val.toString().replace(/'/g, "\\'") + "'" : val); }).join(' && '); diff --git a/test/rendering_js.test.js b/test/rendering_js.test.js index e6e5939..597998b 100644 --- a/test/rendering_js.test.js +++ b/test/rendering_js.test.js @@ -183,7 +183,7 @@ describe('RenderingJS', function() { assert.equal(st.args[2].args[0].value, 10); }); - it("should not throw `ReferenceError`", function(){ + it("should not throw `ReferenceError` with `=~` operator", function(){ var css = [ '#layer[name=~".*Cairo*"] {', ' marker-width: 14;', @@ -196,4 +196,21 @@ describe('RenderingJS', function() { var value = layer.shader['marker-width'].style({ name: 'wadus' }, { zoom: 1 }); }); }); + + it("should not throw `TypeError` if left operand is not a `string` with operator `=~`", function(){ + var css = [ + '#layer[name=~1] {', + ' marker-width: 14;', + '}' + ].join('\n'); + + assert.doesNotThrow(function () { + var shader = (new carto.RendererJS({})).render(css); + var layer = shader.getLayers()[0]; + var value = layer.shader['marker-width'].style({ name: 1 }, { zoom: 1 }); + value = layer.shader['marker-width'].style({ name: null }, { zoom: 1 }); + value = layer.shader['marker-width'].style({ name: undefined }, { zoom: 1 }); + value = layer.shader['marker-width'].style({ name: true }, { zoom: 1 }); + }); + }); }); From cc2104eb4995da3a9f03c7af55abef137ac397eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Fri, 3 Mar 2017 15:35:57 +0100 Subject: [PATCH 08/21] Fix typo --- test/rendering_js.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/rendering_js.test.js b/test/rendering_js.test.js index 597998b..cd0895b 100644 --- a/test/rendering_js.test.js +++ b/test/rendering_js.test.js @@ -32,7 +32,7 @@ describe('RenderingJS', function() { var layer = shader.getLayers()[0]; assert( layer.frames()[0] === 0); assert( layer.frames()[1] === 1); - + layer = shader.getLayers()[1]; assert( layer.frames()[0] === 10); }); @@ -185,7 +185,7 @@ describe('RenderingJS', function() { it("should not throw `ReferenceError` with `=~` operator", function(){ var css = [ - '#layer[name=~".*Cairo*"] {', + '#layer[name=~".*wadus*"] {', ' marker-width: 14;', '}' ].join('\n'); @@ -199,7 +199,7 @@ describe('RenderingJS', function() { it("should not throw `TypeError` if left operand is not a `string` with operator `=~`", function(){ var css = [ - '#layer[name=~1] {', + '#layer[name=~".*wadus*"] {', ' marker-width: 14;', '}' ].join('\n'); From 2c092f6b39807871fc687e52dc673c0f0c156dff Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Sun, 5 Mar 2017 23:31:32 +0100 Subject: [PATCH 09/21] Support multiple values/operands --- lib/carto/tree/value.js | 4 +++- test/rendering_js.test.js | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/carto/tree/value.js b/lib/carto/tree/value.js index 7e74e76..e12619b 100644 --- a/lib/carto/tree/value.js +++ b/lib/carto/tree/value.js @@ -36,7 +36,9 @@ tree.Value.prototype = { v = "'" + v + "'"; } else if (val.is === 'field') { // replace [variable] by ctx['variable'] - v = v.replace(/\[(.*)\]/g, "data['$1']"); + v = v.replace(/\[([^\]]*)\]/g, function(matched) { + return matched.replace(/\[(.*)\]/g, "data['$1']"); + }); }else if (val.is === 'call') { v = JSON.stringify({ name: val.name, diff --git a/test/rendering_js.test.js b/test/rendering_js.test.js index 5e5694b..b716c63 100644 --- a/test/rendering_js.test.js +++ b/test/rendering_js.test.js @@ -183,4 +183,16 @@ describe('RenderingJS', function() { assert.equal(st.args[2].args[0].value, 10); }); + it("should work with multiple operands", function(){ + var css = [ + '#layer {', + ' marker-width: [value] * [value] * 0.5;', + '}' + ].join('\n'); + var shader = (new carto.RendererJS({ debug: false })).render(css); + var layer = shader.getLayers()[0]; + var width = layer.shader['marker-width'].style({value: 4}, {zoom: 1}); + assert.equal(width, 8); + }); + }); From 5c4bed9593c69be52e14dd4737d05395761949ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Mon, 6 Mar 2017 11:38:59 +0100 Subject: [PATCH 10/21] Keep spaces --- test/rendering_js.test.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/rendering_js.test.js b/test/rendering_js.test.js index cd0895b..e546a3b 100644 --- a/test/rendering_js.test.js +++ b/test/rendering_js.test.js @@ -4,24 +4,24 @@ var carto = require('../lib/carto'); describe('RenderingJS', function() { var shader; var style = [ - '#world {', - 'line-width: 2;', - 'line-color: #f00;', - '[frame-offset = 1] {', - 'line-width: 3;', - '}', - '[frame-offset = 2] {', - 'line-width: 3;', - '}', - '}', - '', - '#worls[frame-offset = 10] {', - 'line-width: 4;', + '#world {', + 'line-width: 2;', + 'line-color: #f00;', + '[frame-offset = 1] {', + 'line-width: 3;', + '}', + '[frame-offset = 2] {', + 'line-width: 3;', + '}', + '}', + '', + '#worls[frame-offset = 10] {', + 'line-width: 4;', '}' ].join('\n'); beforeEach(function() { - shader = (new carto.RendererJS({ debug: false })).render(style); + shader = (new carto.RendererJS({ debug: true })).render(style); }); it ("shold render layers", function() { From fd94fbd2e69ce2e338929f07aa0d94cf263eb19d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Mon, 6 Mar 2017 11:57:07 +0100 Subject: [PATCH 11/21] Support numbers for '=~' operator --- lib/carto/tree/filterset.js | 2 +- test/rendering_js.test.js | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/carto/tree/filterset.js b/lib/carto/tree/filterset.js index 168816f..2866959 100644 --- a/lib/carto/tree/filterset.js +++ b/lib/carto/tree/filterset.js @@ -93,7 +93,7 @@ tree.Filterset.prototype.toJS = function(env) { } var attrs = "data"; if (op === '=~') { - return "(typeof " + attrs + "['" + filter.key.value + "'] === 'string') && " + attrs + "['" + filter.key.value + "'].match(" + (val.is === 'string' ? "'" + val.toString().replace(/'/g, "\\'") + "'" : val) + ")"; + return "(" + attrs + "['" + filter.key.value + "'] + '').match(" + (val.is === 'string' ? "'" + val.toString().replace(/'/g, "\\'") + "'" : val) + ")"; } return attrs + "['" + filter.key.value + "'] " + op + " " + (val.is === 'string' ? "'" + val.toString().replace(/'/g, "\\'") + "'" : val); }).join(' && '); diff --git a/test/rendering_js.test.js b/test/rendering_js.test.js index e546a3b..f68cfe8 100644 --- a/test/rendering_js.test.js +++ b/test/rendering_js.test.js @@ -196,10 +196,10 @@ describe('RenderingJS', function() { var value = layer.shader['marker-width'].style({ name: 'wadus' }, { zoom: 1 }); }); }); - - it("should not throw `TypeError` if left operand is not a `string` with operator `=~`", function(){ + + it("`=~` operator should support numbers", function(){ var css = [ - '#layer[name=~".*wadus*"] {', + '#layer[value=~"^10"] {', ' marker-width: 14;', '}' ].join('\n'); @@ -207,10 +207,7 @@ describe('RenderingJS', function() { assert.doesNotThrow(function () { var shader = (new carto.RendererJS({})).render(css); var layer = shader.getLayers()[0]; - var value = layer.shader['marker-width'].style({ name: 1 }, { zoom: 1 }); - value = layer.shader['marker-width'].style({ name: null }, { zoom: 1 }); - value = layer.shader['marker-width'].style({ name: undefined }, { zoom: 1 }); - value = layer.shader['marker-width'].style({ name: true }, { zoom: 1 }); - }); + var value = layer.shader['marker-width'].style({ value: 10 }, { zoom: 1 }); + }, Error); }); }); From 8c75b4b0c67fb44ff479e3fbe7f62bd5185bbc9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Mon, 6 Mar 2017 11:59:41 +0100 Subject: [PATCH 12/21] Remove spaces --- test/rendering_js.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/rendering_js.test.js b/test/rendering_js.test.js index f68cfe8..f351f46 100644 --- a/test/rendering_js.test.js +++ b/test/rendering_js.test.js @@ -32,7 +32,7 @@ describe('RenderingJS', function() { var layer = shader.getLayers()[0]; assert( layer.frames()[0] === 0); assert( layer.frames()[1] === 1); - + layer = shader.getLayers()[1]; assert( layer.frames()[0] === 10); }); From 410ecfd3c7f59ac2620db722476dff7bdb5872da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Mon, 6 Mar 2017 12:04:29 +0100 Subject: [PATCH 13/21] Use constructor for test validation --- test/rendering_js.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/rendering_js.test.js b/test/rendering_js.test.js index f351f46..22c4b15 100644 --- a/test/rendering_js.test.js +++ b/test/rendering_js.test.js @@ -194,7 +194,7 @@ describe('RenderingJS', function() { var shader = (new carto.RendererJS({})).render(css); var layer = shader.getLayers()[0]; var value = layer.shader['marker-width'].style({ name: 'wadus' }, { zoom: 1 }); - }); + }, ReferenceError); }); it("`=~` operator should support numbers", function(){ From a42afef5a83217abcdabcec354bfacd6b5188436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Mon, 6 Mar 2017 19:20:01 +0100 Subject: [PATCH 14/21] Add assertions --- test/rendering_js.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/rendering_js.test.js b/test/rendering_js.test.js index 22c4b15..e09ea9d 100644 --- a/test/rendering_js.test.js +++ b/test/rendering_js.test.js @@ -194,6 +194,7 @@ describe('RenderingJS', function() { var shader = (new carto.RendererJS({})).render(css); var layer = shader.getLayers()[0]; var value = layer.shader['marker-width'].style({ name: 'wadus' }, { zoom: 1 }); + assert.equal(value, 14); }, ReferenceError); }); @@ -208,6 +209,7 @@ describe('RenderingJS', function() { var shader = (new carto.RendererJS({})).render(css); var layer = shader.getLayers()[0]; var value = layer.shader['marker-width'].style({ value: 10 }, { zoom: 1 }); + assert.equal(value, 14); }, Error); }); }); From 945f5efb74fd1af1f5e1f69f409f9567f94fb5a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Tue, 7 Mar 2017 11:10:29 +0100 Subject: [PATCH 15/21] Release 0.15.1-cdb3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ce8d265..1dafd9d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "carto", - "version": "0.15.1-cdb1", + "version": "0.15.1-cdb3", "description": "CartoCSS Stylesheet Compiler", "url": "https://github.com/cartodb/carto", "repository": { From 9b5fb6a4085d7ffcb2b5d4b633bd43ddc51a934e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20L=C3=B3pez?= Date: Mon, 17 Apr 2017 15:48:55 +0200 Subject: [PATCH 16/21] Make the error flag more strict --- lib/carto/renderer_js.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/carto/renderer_js.js b/lib/carto/renderer_js.js index ac4fea5..b4c2b1f 100644 --- a/lib/carto/renderer_js.js +++ b/lib/carto/renderer_js.js @@ -239,10 +239,11 @@ CartoCSS.prototype = { for(var i = 0; i < defs.length; ++i) { var def = defs[i]; - def.toXML(parse_env, {}); - - if (this.options.strict && parse_env.errors.message) { - throw new Error(parse_env.errors.message); + if (this.options.strict) { + def.toXML(parse_env, {}); + if (parse_env.errors.message) { + throw new Error(parse_env.errors.message); + } } var k = defKey(def); From 59c0208caa25294e460f4baaaa600ce226e3fcfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20L=C3=B3pez?= Date: Mon, 17 Apr 2017 16:00:07 +0200 Subject: [PATCH 17/21] Fix tests. Now we don't run the parser so there is no errors, we can't look for errors. --- test/editor/editor.test.js | 8 ++++++++ test/rendering_js-strict.test.js | 3 --- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 test/editor/editor.test.js diff --git a/test/editor/editor.test.js b/test/editor/editor.test.js new file mode 100644 index 0000000..a2bb5ac --- /dev/null +++ b/test/editor/editor.test.js @@ -0,0 +1,8 @@ +var ref = require('./reference.json'); +var carto = require('../../lib/carto/index.js'); + + +var ccss = new carto.RendererJS({ + reference: ref, + strict: true +}).render("#layer { polygon-fill: #abcdef; }"); diff --git a/test/rendering_js-strict.test.js b/test/rendering_js-strict.test.js index 3a530f4..9628e9b 100644 --- a/test/rendering_js-strict.test.js +++ b/test/rendering_js-strict.test.js @@ -124,9 +124,6 @@ describe('RendererJS Strict Mode', function() { function rendererStrictModeOffTest(RendererJS) { return function () { var shader = RendererJS.render(style); - assert.ok(shader.parse_env); - assert.ok(shader.parse_env.errors); - assert.ok(shader.parse_env.errors.message.match(expectedErrorMessageRegex)); assert.ok(shader.layers); assert.equal(shader.layers.length, 2); From 7974fb0a053c3f3cf198fdd462f6bf7248eba85f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20L=C3=B3pez?= Date: Fri, 19 May 2017 12:20:22 +0200 Subject: [PATCH 18/21] Remove editor.test.js --- test/editor/editor.test.js | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 test/editor/editor.test.js diff --git a/test/editor/editor.test.js b/test/editor/editor.test.js deleted file mode 100644 index a2bb5ac..0000000 --- a/test/editor/editor.test.js +++ /dev/null @@ -1,8 +0,0 @@ -var ref = require('./reference.json'); -var carto = require('../../lib/carto/index.js'); - - -var ccss = new carto.RendererJS({ - reference: ref, - strict: true -}).render("#layer { polygon-fill: #abcdef; }"); From ab412165b2f37ae279eacd6c227721899eae02e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20L=C3=B3pez?= Date: Fri, 19 May 2017 12:21:00 +0200 Subject: [PATCH 19/21] Set correct indentation --- lib/carto/renderer_js.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/carto/renderer_js.js b/lib/carto/renderer_js.js index b4c2b1f..906086b 100644 --- a/lib/carto/renderer_js.js +++ b/lib/carto/renderer_js.js @@ -206,8 +206,8 @@ CartoCSS.prototype = { for(var u = 0; u Date: Fri, 19 May 2017 12:24:50 +0200 Subject: [PATCH 20/21] Check throw --- test/rendering_js-strict.test.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/rendering_js-strict.test.js b/test/rendering_js-strict.test.js index 9628e9b..07df548 100644 --- a/test/rendering_js-strict.test.js +++ b/test/rendering_js-strict.test.js @@ -134,9 +134,14 @@ describe('RendererJS Strict Mode', function() { new carto.RendererJS({reference: reference, mapnik_version: '1.0.0' }) )); - it('should pass if a feature is not supported but strict is turned off', rendererStrictModeOffTest( - new carto.RendererJS({reference: reference, mapnik_version: '1.0.0', strict: false }) - )); + it('should pass if a feature is not supported but strict is turned off', function () { + assert.doesNotThrow( + function () { + var RendererJS = new carto.RendererJS({reference: reference, mapnik_version: '1.0.0', strict: false }); + var shader = RendererJS.render(style); + } + ); + }); it('should pass if a feature is supported and strict is turned on', function () { var RendererJS = new carto.RendererJS({reference: reference, mapnik_version: '1.0.0', strict: true }); From b051ae284e16d1f7e8b2b1a5dcaf21b5bf4efe44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20L=C3=B3pez?= Date: Fri, 19 May 2017 13:51:27 +0200 Subject: [PATCH 21/21] Remove throw check --- test/rendering_js-strict.test.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/rendering_js-strict.test.js b/test/rendering_js-strict.test.js index 07df548..4e15de9 100644 --- a/test/rendering_js-strict.test.js +++ b/test/rendering_js-strict.test.js @@ -135,12 +135,7 @@ describe('RendererJS Strict Mode', function() { )); it('should pass if a feature is not supported but strict is turned off', function () { - assert.doesNotThrow( - function () { - var RendererJS = new carto.RendererJS({reference: reference, mapnik_version: '1.0.0', strict: false }); - var shader = RendererJS.render(style); - } - ); + new carto.RendererJS({reference: reference, mapnik_version: '1.0.0', strict: false }) }); it('should pass if a feature is supported and strict is turned on', function () {