Adding first error test, and error testing framework
This commit is contained in:
parent
c2931d8983
commit
1782e81407
@ -302,9 +302,6 @@ mess.Parser = function Parser(env) {
|
|||||||
filename: e.filename,
|
filename: e.filename,
|
||||||
index: e.index,
|
index: e.index,
|
||||||
line: typeof(line) === 'number' ? line + 1 : null,
|
line: typeof(line) === 'number' ? line + 1 : null,
|
||||||
callLine: e.call && (root.getLine(e.call) + 1),
|
|
||||||
callExtract: lines[root.getLine(e.call)],
|
|
||||||
stack: e.stack,
|
|
||||||
column: column,
|
column: column,
|
||||||
extract: [
|
extract: [
|
||||||
lines[line - 1],
|
lines[line - 1],
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
tree.Invalid = function Invalid(chunk, index, message) {
|
tree.Invalid = function Invalid(chunk, index, message) {
|
||||||
this.chunk = chunk;
|
this.chunk = chunk;
|
||||||
this.index = index;
|
this.index = index;
|
||||||
|
this.type = 'syntax';
|
||||||
this.message = message || "Invalid code: " + this.chunk;
|
this.message = message || "Invalid code: " + this.chunk;
|
||||||
};
|
};
|
||||||
})(require('mess/tree'));
|
})(require('mess/tree'));
|
||||||
|
@ -14,6 +14,7 @@ tree.Rule.prototype.toXML = function(env) {
|
|||||||
return env.error({
|
return env.error({
|
||||||
message: "Unrecognized selector: " + this.name,
|
message: "Unrecognized selector: " + this.name,
|
||||||
index: this.index,
|
index: this.index,
|
||||||
|
type: 'syntax',
|
||||||
filename: this.filename
|
filename: this.filename
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -29,6 +30,7 @@ tree.Rule.prototype.toXML = function(env) {
|
|||||||
' is expected. ' + this.value +
|
' is expected. ' + this.value +
|
||||||
' was given.',
|
' was given.',
|
||||||
index: this.index,
|
index: this.index,
|
||||||
|
type: 'syntax',
|
||||||
filename: this.filename
|
filename: this.filename
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
15
test/errorhandling/invalid_property.mml
Normal file
15
test/errorhandling/invalid_property.mml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs",
|
||||||
|
"Stylesheet": [
|
||||||
|
"invalid_property.mss"
|
||||||
|
],
|
||||||
|
"Layer": [{
|
||||||
|
"id": "world",
|
||||||
|
"name": "world",
|
||||||
|
"srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs",
|
||||||
|
"Datasource": {
|
||||||
|
"file": "http://tilemill-data.s3.amazonaws.com/test_data/shape_demo.zip",
|
||||||
|
"type": "shape"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
4
test/errorhandling/invalid_property.mss
Normal file
4
test/errorhandling/invalid_property.mss
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#world[zoom=5] {
|
||||||
|
polygon-fill: #f00;
|
||||||
|
polygonopacity: 0.5;
|
||||||
|
}
|
1
test/errorhandling/invalid_property.result
Normal file
1
test/errorhandling/invalid_property.result
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"message":"Unrecognized selector: polygonopacity","index":41,"type":"syntax","filename":"[absolute path]","line":3,"column":2,"extract":[" polygon-fill: #f00;"," polygonopacity: 0.5;","}"]}]
|
@ -143,6 +143,12 @@ exports.md5File = function(file, md5, context) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
helper.removeErrorFilename = function(error) {
|
||||||
|
error.forEach(function(e) {
|
||||||
|
e.filename = "[absolute path]";
|
||||||
|
});
|
||||||
|
return error;
|
||||||
|
};
|
||||||
|
|
||||||
helper.removeAbsoluteImages = function(xml) {
|
helper.removeAbsoluteImages = function(xml) {
|
||||||
(Array.isArray(xml.Style) ? xml.Style : [ xml.Style ]).forEach(function(style) {
|
(Array.isArray(xml.Style) ? xml.Style : [ xml.Style ]).forEach(function(style) {
|
||||||
|
Loading…
Reference in New Issue
Block a user