Adding first error test, and error testing framework

This commit is contained in:
Tom MacWright 2011-01-28 11:08:38 -05:00
parent c2931d8983
commit 1782e81407
7 changed files with 29 additions and 3 deletions

View File

@ -302,9 +302,6 @@ mess.Parser = function Parser(env) {
filename: e.filename,
index: e.index,
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,
extract: [
lines[line - 1],

View File

@ -2,6 +2,7 @@
tree.Invalid = function Invalid(chunk, index, message) {
this.chunk = chunk;
this.index = index;
this.type = 'syntax';
this.message = message || "Invalid code: " + this.chunk;
};
})(require('mess/tree'));

View File

@ -14,6 +14,7 @@ tree.Rule.prototype.toXML = function(env) {
return env.error({
message: "Unrecognized selector: " + this.name,
index: this.index,
type: 'syntax',
filename: this.filename
});
}
@ -29,6 +30,7 @@ tree.Rule.prototype.toXML = function(env) {
' is expected. ' + this.value +
' was given.',
index: this.index,
type: 'syntax',
filename: this.filename
});
}

View 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"
}
}]
}

View File

@ -0,0 +1,4 @@
#world[zoom=5] {
polygon-fill: #f00;
polygonopacity: 0.5;
}

View 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;","}"]}]

View File

@ -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) {
(Array.isArray(xml.Style) ? xml.Style : [ xml.Style ]).forEach(function(style) {