Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dane Springmeyer
committed
Dec 6, 2011
1 parent
4355b9f
commit ca1447a
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var mapnik = require('mapnik'); | ||
var assert = require('assert'); | ||
|
||
exports['test expression'] = function(beforeExit) { | ||
// no 'new' keyword | ||
assert.throws(function() { mapnik.Expression(); }); | ||
|
||
// invalid args | ||
assert.throws(function() { new mapnik.Expression(); }); | ||
assert.throws(function() { new mapnik.Expression(1); }); | ||
|
||
// valid expression strings | ||
var expr = new mapnik.Expression('[ATTR]'); | ||
var expr = new mapnik.Expression('[ATTR]+2'); | ||
var expr = new mapnik.Expression('[ATTR]/2'); | ||
|
||
var expr = new mapnik.Expression('[ATTR1]/[ATTR2]'); | ||
assert.equal(expr.toString(),'[ATTR1]/[ATTR2]'); | ||
|
||
var expr = new mapnik.Expression('\'literal\''); | ||
assert.equal(expr.toString(),"'literal'"); | ||
}; | ||
|
||
|
||
exports['test expression evaluation'] = function(beforeExit) { | ||
|
||
var expr = new mapnik.Expression("[attr]='value'"); | ||
var feature = new mapnik.Feature(0); | ||
feature.addAttributes({'attr':'value'}); | ||
assert.equal(expr.evaluate(feature),true); | ||
assert.equal(expr.evaluate(feature).toString(),'true'); | ||
|
||
}; |