Add optional context property to OpenLayers.Rule, so rules can now be evaluated against diffent contexts than feature.attributes. This changeset also renames Rule.Logical.children to Rule.Logical.rules, to make it more consistent with OL.Style. r=crschmidt (closes #1331)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@6116 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1,41 +1,41 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_Logical_constructor(t) {
|
||||
t.plan(3);
|
||||
|
||||
var options = {'foo': 'bar'};
|
||||
var rule = new OpenLayers.Rule.Logical(options);
|
||||
t.ok(rule instanceof OpenLayers.Rule.Logical,
|
||||
"new OpenLayers.Rule.Logical returns object" );
|
||||
t.eq(rule.foo, "bar", "constructor sets options correctly");
|
||||
t.eq(typeof rule.evaluate, "function", "rule has an evaluate function");
|
||||
}
|
||||
|
||||
function test_Logical_destroy(t) {
|
||||
t.plan(1);
|
||||
|
||||
var rule = new OpenLayers.Rule.Logical();
|
||||
rule.destroy();
|
||||
t.eq(rule.children, null, "children array nulled properly");
|
||||
}
|
||||
|
||||
function test_Logical_evaluate(t) {
|
||||
t.plan(1);
|
||||
|
||||
var rule = new OpenLayers.Rule.Logical({
|
||||
type: OpenLayers.Rule.Logical.NOT});
|
||||
rule.children.push(new OpenLayers.Rule());
|
||||
|
||||
var feature = new OpenLayers.Feature.Vector();
|
||||
|
||||
t.eq(rule.evaluate(feature), false,
|
||||
"feature evaluates to false correctly.");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_Logical_constructor(t) {
|
||||
t.plan(3);
|
||||
|
||||
var options = {'foo': 'bar'};
|
||||
var rule = new OpenLayers.Rule.Logical(options);
|
||||
t.ok(rule instanceof OpenLayers.Rule.Logical,
|
||||
"new OpenLayers.Rule.Logical returns object" );
|
||||
t.eq(rule.foo, "bar", "constructor sets options correctly");
|
||||
t.eq(typeof rule.evaluate, "function", "rule has an evaluate function");
|
||||
}
|
||||
|
||||
function test_Logical_destroy(t) {
|
||||
t.plan(1);
|
||||
|
||||
var rule = new OpenLayers.Rule.Logical();
|
||||
rule.destroy();
|
||||
t.eq(rule.rules, null, "rules array nulled properly");
|
||||
}
|
||||
|
||||
function test_Logical_evaluate(t) {
|
||||
t.plan(1);
|
||||
|
||||
var rule = new OpenLayers.Rule.Logical({
|
||||
type: OpenLayers.Rule.Logical.NOT});
|
||||
rule.rules.push(new OpenLayers.Rule());
|
||||
|
||||
var feature = new OpenLayers.Feature.Vector();
|
||||
|
||||
t.eq(rule.evaluate(feature), false,
|
||||
"feature evaluates to false correctly.");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user