Add new tests, tree.Filter fix.
This commit is contained in:
parent
80b88d4ba8
commit
70cc208e62
@ -19,6 +19,10 @@ tree.Filter = function Filter(key, op, val, index, filename) {
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
if (this.op !== '=' && this.op !== '!=') {
|
||||
this.val = 1 * this.val;
|
||||
}
|
||||
|
||||
this.id = this.key + this.op + this.val;
|
||||
};
|
||||
|
||||
@ -34,15 +38,12 @@ var opXML = {
|
||||
};
|
||||
|
||||
tree.Filter.prototype.toXML = function(env) {
|
||||
if (this.op !== '=' && this.op !== '!=') {
|
||||
this.val = 1 * this.val;
|
||||
if (isNaN(this.val)) {
|
||||
env.error({
|
||||
message: 'Cannot use operator "' + this.op + '" with value ' + this.val,
|
||||
index: this.index,
|
||||
filename: this.filename
|
||||
});
|
||||
}
|
||||
if (this.op !== '=' && this.op !== '!=' && isNaN(this.val)) {
|
||||
env.error({
|
||||
message: 'Cannot use operator "' + this.op + '" with value ' + this.val,
|
||||
index: this.index,
|
||||
filename: this.filename
|
||||
});
|
||||
}
|
||||
if (this.val.eval) this._val = this.val.eval(env);
|
||||
if (this.key.eval) this._key = this.key.eval(env);
|
||||
|
@ -23,7 +23,7 @@ helper.files('errorhandling', 'mml', function(file) {
|
||||
// @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) {
|
||||
assert.deepEqual(output, data.substr(0, data.length - 1));
|
||||
if (!err) assert.deepEqual(output, data.substr(0, data.length - 1));
|
||||
});
|
||||
});
|
||||
|
||||
|
16
test/errorhandling/multi_stylesheets.mml
Normal file
16
test/errorhandling/multi_stylesheets.mml
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"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 +wktext +no_defs +over",
|
||||
"Stylesheet": [
|
||||
"multi_stylesheets_b.mss",
|
||||
"multi_stylesheets_a.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 +wktext +no_defs +over",
|
||||
"Datasource": {
|
||||
"file": "http://tilemill-data.s3.amazonaws.com/test_data/shape_demo.zip",
|
||||
"type": "shape"
|
||||
}
|
||||
}]
|
||||
}
|
6
test/errorhandling/multi_stylesheets_a.mss
Normal file
6
test/errorhandling/multi_stylesheets_a.mss
Normal file
@ -0,0 +1,6 @@
|
||||
#world {
|
||||
polygon-opacity: 0.5;
|
||||
line-width:4;
|
||||
line-color:#fff;
|
||||
line-opacity:0.3;
|
||||
}
|
3
test/errorhandling/multi_stylesheets_b.mss
Normal file
3
test/errorhandling/multi_stylesheets_b.mss
Normal file
@ -0,0 +1,3 @@
|
||||
#world {
|
||||
polygonopacity: 0.5;
|
||||
}
|
14
test/rendering/nominzoom.mml
Normal file
14
test/rendering/nominzoom.mml
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"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 +wktext +no_defs +over",
|
||||
"Stylesheet": [
|
||||
"nominzoom.mss"
|
||||
],
|
||||
"Layer": [{
|
||||
"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 +wktext +no_defs +over",
|
||||
"Datasource": {
|
||||
"file": "http://tilemill-data.s3.amazonaws.com/test_data/shape_demo.zip",
|
||||
"type": "shape"
|
||||
}
|
||||
}]
|
||||
}
|
3
test/rendering/nominzoom.mss
Normal file
3
test/rendering/nominzoom.mss
Normal file
@ -0,0 +1,3 @@
|
||||
#world[zoom < 5] {
|
||||
polygon-fill: #000;
|
||||
}
|
21
test/rendering/nominzoom.result
Normal file
21
test/rendering/nominzoom.result
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE Map[]>
|
||||
<Map 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 +wktext +no_defs +over">
|
||||
|
||||
|
||||
<Style name="world" filter-mode="first">
|
||||
<Rule>
|
||||
<MinScaleDenominator>25000000</MinScaleDenominator>
|
||||
<PolygonSymbolizer fill="#000000" />
|
||||
</Rule>
|
||||
</Style>
|
||||
<Layer 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 +wktext +no_defs +over">
|
||||
<StyleName>world</StyleName>
|
||||
<Datasource>
|
||||
<Parameter name="file"><![CDATA[[absolute path]]]></Parameter>
|
||||
<Parameter name="type"><![CDATA[shape]]></Parameter>
|
||||
</Datasource>
|
||||
</Layer>
|
||||
|
||||
</Map>
|
Loading…
Reference in New Issue
Block a user