diff --git a/plugins/tests/test_mapcss_parsing_evalutation.py b/plugins/tests/test_mapcss_parsing_evalutation.py index 317994f31..3e824f79a 100644 --- a/plugins/tests/test_mapcss_parsing_evalutation.py +++ b/plugins/tests/test_mapcss_parsing_evalutation.py @@ -23,15 +23,16 @@ def init(self, logger): self.errors[8] = self.def_class(item = 0, level = 2, tags = [], title = mapcss.tr('test #1882 - {0}', mapcss._tag_uncapture(capture_tags, '{0.tag}'))) self.errors[9] = self.def_class(item = 0, level = 3, tags = [], title = mapcss.tr('test area rule {0}', mapcss._tag_uncapture(capture_tags, '{0.tag}'))) self.errors[10] = self.def_class(item = 0, level = 3, tags = [], title = mapcss.tr('test closed rewrite {0}', mapcss._tag_uncapture(capture_tags, '{0.tag}'))) - self.errors[11] = self.def_class(item = 0, level = 3, tags = [], title = {'en': 'test #1610'}) - self.errors[12] = self.def_class(item = 0, level = 3, tags = [], title = mapcss.tr('test #1603 - {0}{1}', mapcss._tag_uncapture(capture_tags, '{0.tag}'), mapcss._tag_uncapture(capture_tags, '{1.tag}'))) - self.errors[13] = self.def_class(item = 0, level = 3, tags = [], title = mapcss.tr('test righthandtraffic')) - self.errors[14] = self.def_class(item = 0, level = 3, tags = [], title = mapcss.tr('test lefthandtraffic')) - self.errors[15] = self.def_class(item = 0, level = 3, tags = [], title = mapcss.tr('test {0}', mapcss._tag_uncapture(capture_tags, '{0.tag}'))) - self.errors[16] = self.def_class(item = 0, level = 3, tags = [], title = mapcss.tr('test #1303, #1742 {0}', mapcss._tag_uncapture(capture_tags, '{2.key}'))) - self.errors[17] = self.def_class(item = 0, level = 3, tags = [], title = mapcss.tr('test #1303 {0}', mapcss._tag_uncapture(capture_tags, '{2.key}'))) - self.errors[18] = self.def_class(item = 0, level = 3, tags = [], title = mapcss.tr('test #1742 - {0}', mapcss._tag_uncapture(capture_tags, '{1.tag}'))) - self.errors[19] = self.def_class(item = 0, level = 3, tags = [], title = mapcss.tr('test {0}{1}', 'text', mapcss._tag_uncapture(capture_tags, '{0.key}'))) + self.errors[11] = self.def_class(item = 0, level = 3, tags = [], title = mapcss.tr('test any {0} {1}', mapcss.any_(mapcss.tag(tags, 'b'), ''), mapcss.any_(mapcss.tag(tags, 'c'), mapcss.tag(tags, 'd'), ''))) + self.errors[12] = self.def_class(item = 0, level = 3, tags = [], title = {'en': 'test #1610'}) + self.errors[13] = self.def_class(item = 0, level = 3, tags = [], title = mapcss.tr('test #1603 - {0}{1}', mapcss._tag_uncapture(capture_tags, '{0.tag}'), mapcss._tag_uncapture(capture_tags, '{1.tag}'))) + self.errors[14] = self.def_class(item = 0, level = 3, tags = [], title = mapcss.tr('test righthandtraffic')) + self.errors[15] = self.def_class(item = 0, level = 3, tags = [], title = mapcss.tr('test lefthandtraffic')) + self.errors[16] = self.def_class(item = 0, level = 3, tags = [], title = mapcss.tr('test {0}', mapcss._tag_uncapture(capture_tags, '{0.tag}'))) + self.errors[17] = self.def_class(item = 0, level = 3, tags = [], title = mapcss.tr('test #1303, #1742 {0}', mapcss._tag_uncapture(capture_tags, '{2.key}'))) + self.errors[18] = self.def_class(item = 0, level = 3, tags = [], title = mapcss.tr('test #1303 {0}', mapcss._tag_uncapture(capture_tags, '{2.key}'))) + self.errors[19] = self.def_class(item = 0, level = 3, tags = [], title = mapcss.tr('test #1742 - {0}', mapcss._tag_uncapture(capture_tags, '{1.tag}'))) + self.errors[20] = self.def_class(item = 0, level = 3, tags = [], title = mapcss.tr('test {0}{1}', 'text', mapcss._tag_uncapture(capture_tags, '{0.key}'))) self.errors[97] = self.def_class(item = 4, level = 1, tags = mapcss.list_('osmose_rules'), title = mapcss.tr('test'), trap = mapcss.tr('Don\'t do this!'), detail = mapcss.tr('More {0}.', '`info`'), example = {"en": 'Look at me, I haven\'t lost my apostrophe'}, fix = {"en": 'This may fix it.'}, resource = 'https://wiki.openstreetmap.org/wiki/Useful_Page') self.errors[98] = self.def_class(item = 4030, level = 2, tags = mapcss.list_('fix:survey'), title = {'en': 'test #1740'}) self.errors[99] = self.def_class(item = 4, level = 1, tags = mapcss.list_('osmose_rules'), title = mapcss.tr('test'), trap = mapcss.tr('Don\'t do this!'), detail = mapcss.tr('More {0}.', '`info`'), example = {"en": 'Look at me, I haven\'t lost my apostrophe'}, fix = {"en": 'This may fix it.'}, resource = 'https://wiki.openstreetmap.org/wiki/Useful_Page') @@ -382,6 +383,31 @@ def node(self, data, tags): # assertMatch:"node x=yes" err.append({'class': 10, 'subclass': 2047373107, 'text': mapcss.tr('test closed rewrite {0}', mapcss._tag_uncapture(capture_tags, '{0.tag}'))}) + # node[any(tag("x"),"")==any(tag("y"),"hello")] + # node[a] + if True: + match = False + if not match: + capture_tags = {} + try: match = ((mapcss.any_(mapcss.tag(tags, 'x'), '') == mapcss.any_(mapcss.tag(tags, 'y'), 'hello'))) + except mapcss.RuleAbort: pass + if not match: + capture_tags = {} + try: match = ((mapcss._tag_capture(capture_tags, 0, tags, 'a'))) + except mapcss.RuleAbort: pass + if match: + # throwWarning:tr("test any {0} {1}",any(tag("b"),""),any(tag("c"),tag("d"),"")) + # assertMatch:"node a=1 b=2 c=3 d=four" + # assertMatch:"node a=1 b=2 d=four" + # assertMatch:"node a=1" + # assertNoMatch:"node unknownkey=yes" + # assertNoMatch:"node x=bye y=world" + # assertMatch:"node x=hello y=hello" + # assertNoMatch:"node x=hello y=world" + # assertMatch:"node x=hello" + # assertNoMatch:"node y=world" + err.append({'class': 11, 'subclass': 1778220616, 'text': mapcss.tr('test any {0} {1}', mapcss.any_(mapcss.tag(tags, 'b'), ''), mapcss.any_(mapcss.tag(tags, 'c'), mapcss.tag(tags, 'd'), ''))}) + return err def way(self, data, tags, nds): @@ -402,7 +428,7 @@ def way(self, data, tags, nds): # assertMatch:"way x=C00;C1;C22" # assertMatch:"way x=C1" # assertNoMatch:"way x=C12" - err.append({'class': 11, 'subclass': 1785050832, 'text': {'en': 'test #1610'}}) + err.append({'class': 12, 'subclass': 1785050832, 'text': {'en': 'test #1610'}}) # way:righthandtraffic[x=y][z?] if ('x' in keys and 'z' in keys): @@ -414,7 +440,7 @@ def way(self, data, tags, nds): if match: # throwWarning:tr("test #1603 - {0}{1}","{1.tag}","{2.tag}") # -osmoseAssertMatchWithContext:list("way x=y z=yes","inside=NL") - err.append({'class': 12, 'subclass': 169712264, 'text': mapcss.tr('test #1603 - {0}{1}', mapcss._tag_uncapture(capture_tags, '{1.tag}'), mapcss._tag_uncapture(capture_tags, '{2.tag}'))}) + err.append({'class': 13, 'subclass': 169712264, 'text': mapcss.tr('test #1603 - {0}{1}', mapcss._tag_uncapture(capture_tags, '{1.tag}'), mapcss._tag_uncapture(capture_tags, '{2.tag}'))}) # way[x=y][z?]:righthandtraffic if ('x' in keys and 'z' in keys): @@ -426,7 +452,7 @@ def way(self, data, tags, nds): if match: # throwWarning:tr("test #1603 - {0}{1}","{0.tag}","{1.tag}") # -osmoseAssertMatchWithContext:list("way x=y z=yes","inside=NL") - err.append({'class': 12, 'subclass': 2074848923, 'text': mapcss.tr('test #1603 - {0}{1}', mapcss._tag_uncapture(capture_tags, '{0.tag}'), mapcss._tag_uncapture(capture_tags, '{1.tag}'))}) + err.append({'class': 13, 'subclass': 2074848923, 'text': mapcss.tr('test #1603 - {0}{1}', mapcss._tag_uncapture(capture_tags, '{0.tag}'), mapcss._tag_uncapture(capture_tags, '{1.tag}'))}) # *[parking][amenity!~/^(parking|motorcycle_parking)$/] if ('parking' in keys): @@ -492,7 +518,7 @@ def way(self, data, tags, nds): # throwWarning:tr("test righthandtraffic") # -osmoseAssertNoMatchWithContext:list("way","driving_side=left") # -osmoseAssertMatchWithContext:list("way","driving_side=right") - err.append({'class': 13, 'subclass': 529680562, 'text': mapcss.tr('test righthandtraffic')}) + err.append({'class': 14, 'subclass': 529680562, 'text': mapcss.tr('test righthandtraffic')}) # way!:righthandtraffic if True: @@ -505,7 +531,7 @@ def way(self, data, tags, nds): # throwWarning:tr("test lefthandtraffic") # -osmoseAssertMatchWithContext:list("way","driving_side=left") # -osmoseAssertNoMatchWithContext:list("way","driving_side=right") - err.append({'class': 14, 'subclass': 877255184, 'text': mapcss.tr('test lefthandtraffic')}) + err.append({'class': 15, 'subclass': 877255184, 'text': mapcss.tr('test lefthandtraffic')}) # way[count(uniq_list(tag_regex("abc")))==2] if True: @@ -551,7 +577,7 @@ def way(self, data, tags, nds): # assertNoMatch:"way oneway=no" # assertMatch:"way oneway=yes" # assertNoMatch:"way x=y" - err.append({'class': 15, 'subclass': 1489464739, 'text': mapcss.tr('test {0}', mapcss._tag_uncapture(capture_tags, '{0.tag}'))}) + err.append({'class': 16, 'subclass': 1489464739, 'text': mapcss.tr('test {0}', mapcss._tag_uncapture(capture_tags, '{0.tag}'))}) # way[oneway?!] if ('oneway' in keys): @@ -566,7 +592,7 @@ def way(self, data, tags, nds): # assertMatch:"way oneway=no" # assertNoMatch:"way oneway=yes" # assertNoMatch:"way x=y" - err.append({'class': 15, 'subclass': 722694187, 'text': mapcss.tr('test {0}', mapcss._tag_uncapture(capture_tags, '{0.tag}'))}) + err.append({'class': 16, 'subclass': 722694187, 'text': mapcss.tr('test {0}', mapcss._tag_uncapture(capture_tags, '{0.tag}'))}) # way[name*=Trigger][tag("building")=="chapel"||tag("amenity")=="place_of_worship"][x] if ('name' in keys and 'x' in keys): @@ -581,7 +607,7 @@ def way(self, data, tags, nds): # assertMatch:"way amenity=place_of_worship name=OsmoseRuleTrigger x=yes" # assertNoMatch:"way amenity=place_of_worship name=Westminster x=yes" # assertMatch:"way building=chapel name=OsmoseRuleTrigger x=yes" - err.append({'class': 16, 'subclass': 1095325051, 'text': mapcss.tr('test #1303, #1742 {0}', mapcss._tag_uncapture(capture_tags, '{2.key}'))}) + err.append({'class': 17, 'subclass': 1095325051, 'text': mapcss.tr('test #1303, #1742 {0}', mapcss._tag_uncapture(capture_tags, '{2.key}'))}) # way[name*=Trigger][tag("building")=="chapel"&&tag("amenity")=="place_of_worship"][x] if ('name' in keys and 'x' in keys): @@ -596,7 +622,7 @@ def way(self, data, tags, nds): # assertNoMatch:"way amenity=place_of_worship building=chapel name=Westminster x=yes" # assertNoMatch:"way amenity=place_of_worship name=OsmoseRuleTrigger x=yes" # assertNoMatch:"way building=chapel name=OsmoseRuleTrigger x=yes" - err.append({'class': 17, 'subclass': 1140742172, 'text': mapcss.tr('test #1303 {0}', mapcss._tag_uncapture(capture_tags, '{2.key}'))}) + err.append({'class': 18, 'subclass': 1140742172, 'text': mapcss.tr('test #1303 {0}', mapcss._tag_uncapture(capture_tags, '{2.key}'))}) # way[inside(FR)][x] if ('x' in keys): @@ -608,7 +634,7 @@ def way(self, data, tags, nds): if match: # throwWarning:tr("test #1742 - {0}","{1.tag}") # -osmoseAssertMatchWithContext:list("way x=y","inside=FR") - err.append({'class': 18, 'subclass': 1132689531, 'text': mapcss.tr('test #1742 - {0}', mapcss._tag_uncapture(capture_tags, '{1.tag}'))}) + err.append({'class': 19, 'subclass': 1132689531, 'text': mapcss.tr('test #1742 - {0}', mapcss._tag_uncapture(capture_tags, '{1.tag}'))}) # *[a][a=*b] if ('a' in keys): @@ -690,7 +716,7 @@ def way(self, data, tags, nds): # assertNoMatch:"way maxspeed=5000" # assertNoMatch:"way maxspeed=default" # assertNoMatch:"way" - err.append({'class': 19, 'subclass': 2063115534, 'text': mapcss.tr('test {0}{1}', 'text', mapcss._tag_uncapture(capture_tags, '{0.key}'))}) + err.append({'class': 20, 'subclass': 2063115534, 'text': mapcss.tr('test {0}{1}', 'text', mapcss._tag_uncapture(capture_tags, '{0.key}'))}) # way[tag(a)>tag(b)] if True: @@ -1064,25 +1090,34 @@ class father: self.check_not_err(n.node(data, {'building': 'yes'}), expected={'class': 9, 'subclass': 555657026}) self.check_err(n.node(data, {'x': 'z'}), expected={'class': 9, 'subclass': 555657026}) self.check_err(n.node(data, {'x': 'yes'}), expected={'class': 10, 'subclass': 2047373107}) - self.check_err(n.way(data, {'x': 'C00;C1;C22'}, [0]), expected={'class': 11, 'subclass': 1785050832}) - self.check_err(n.way(data, {'x': 'C1'}, [0]), expected={'class': 11, 'subclass': 1785050832}) - self.check_not_err(n.way(data, {'x': 'C12'}, [0]), expected={'class': 11, 'subclass': 1785050832}) + self.check_err(n.node(data, {'a': '1', 'b': '2', 'c': '3', 'd': 'four'}), expected={'class': 11, 'subclass': 1778220616}) + self.check_err(n.node(data, {'a': '1', 'b': '2', 'd': 'four'}), expected={'class': 11, 'subclass': 1778220616}) + self.check_err(n.node(data, {'a': '1'}), expected={'class': 11, 'subclass': 1778220616}) + self.check_not_err(n.node(data, {'unknownkey': 'yes'}), expected={'class': 11, 'subclass': 1778220616}) + self.check_not_err(n.node(data, {'x': 'bye', 'y': 'world'}), expected={'class': 11, 'subclass': 1778220616}) + self.check_err(n.node(data, {'x': 'hello', 'y': 'hello'}), expected={'class': 11, 'subclass': 1778220616}) + self.check_not_err(n.node(data, {'x': 'hello', 'y': 'world'}), expected={'class': 11, 'subclass': 1778220616}) + self.check_err(n.node(data, {'x': 'hello'}), expected={'class': 11, 'subclass': 1778220616}) + self.check_not_err(n.node(data, {'y': 'world'}), expected={'class': 11, 'subclass': 1778220616}) + self.check_err(n.way(data, {'x': 'C00;C1;C22'}, [0]), expected={'class': 12, 'subclass': 1785050832}) + self.check_err(n.way(data, {'x': 'C1'}, [0]), expected={'class': 12, 'subclass': 1785050832}) + self.check_not_err(n.way(data, {'x': 'C12'}, [0]), expected={'class': 12, 'subclass': 1785050832}) with with_options(n, {'country': 'NL'}): - self.check_err(n.way(data, {'x': 'y', 'z': 'yes'}, [0]), expected={'class': 12, 'subclass': 169712264}) + self.check_err(n.way(data, {'x': 'y', 'z': 'yes'}, [0]), expected={'class': 13, 'subclass': 169712264}) with with_options(n, {'country': 'NL'}): - self.check_err(n.way(data, {'x': 'y', 'z': 'yes'}, [0]), expected={'class': 12, 'subclass': 2074848923}) + self.check_err(n.way(data, {'x': 'y', 'z': 'yes'}, [0]), expected={'class': 13, 'subclass': 2074848923}) self.check_not_err(n.way(data, {'a': 'b', 'c': 'd'}, [0]), expected={'class': 3, 'subclass': 1004069731}) self.check_err(n.way(data, {'a': 'b'}, [0]), expected={'class': 3, 'subclass': 1004069731}) self.check_not_err(n.way(data, {'b': 'a', 'd': 'c'}, [0]), expected={'class': 3, 'subclass': 1004069731}) self.check_err(n.way(data, {'b': 'c'}, [0]), expected={'class': 3, 'subclass': 1004069731}) with with_options(n, {'driving_side': 'left'}): - self.check_not_err(n.way(data, {}, [0]), expected={'class': 13, 'subclass': 529680562}) + self.check_not_err(n.way(data, {}, [0]), expected={'class': 14, 'subclass': 529680562}) with with_options(n, {'driving_side': 'right'}): - self.check_err(n.way(data, {}, [0]), expected={'class': 13, 'subclass': 529680562}) + self.check_err(n.way(data, {}, [0]), expected={'class': 14, 'subclass': 529680562}) with with_options(n, {'driving_side': 'left'}): - self.check_err(n.way(data, {}, [0]), expected={'class': 14, 'subclass': 877255184}) + self.check_err(n.way(data, {}, [0]), expected={'class': 15, 'subclass': 877255184}) with with_options(n, {'driving_side': 'right'}): - self.check_not_err(n.way(data, {}, [0]), expected={'class': 14, 'subclass': 877255184}) + self.check_not_err(n.way(data, {}, [0]), expected={'class': 15, 'subclass': 877255184}) self.check_not_err(n.way(data, {'abc': 'def', 'abcdef': 'def'}, [0]), expected={'class': 6, 'subclass': 346020981}) self.check_err(n.way(data, {'abc': 'def', 'abcd': 'ghi', 'abcdef': 'ghi'}, [0]), expected={'class': 6, 'subclass': 346020981}) self.check_err(n.way(data, {'abc': 'def', 'abcdef': 'ghi'}, [0]), expected={'class': 6, 'subclass': 346020981}) @@ -1091,33 +1126,33 @@ class father: self.check_err(n.way(data, {'abc': 'def', 'abcd': 'ghi', 'abcdef': 'ghi'}, [0]), expected={'class': 6, 'subclass': 57938147}) self.check_err(n.way(data, {'abc': 'def', 'abcdef': 'ghi'}, [0]), expected={'class': 6, 'subclass': 57938147}) self.check_not_err(n.way(data, {'abc': 'def', 'def': 'def'}, [0]), expected={'class': 6, 'subclass': 57938147}) - self.check_err(n.way(data, {'oneway': '1'}, [0]), expected={'class': 15, 'subclass': 1489464739}) - self.check_not_err(n.way(data, {'oneway': '4.0'}, [0]), expected={'class': 15, 'subclass': 1489464739}) - self.check_not_err(n.way(data, {'oneway': 'no'}, [0]), expected={'class': 15, 'subclass': 1489464739}) - self.check_err(n.way(data, {'oneway': 'yes'}, [0]), expected={'class': 15, 'subclass': 1489464739}) - self.check_not_err(n.way(data, {'x': 'y'}, [0]), expected={'class': 15, 'subclass': 1489464739}) - self.check_err(n.way(data, {'oneway': '0'}, [0]), expected={'class': 15, 'subclass': 722694187}) - self.check_err(n.way(data, {'oneway': 'no'}, [0]), expected={'class': 15, 'subclass': 722694187}) - self.check_not_err(n.way(data, {'oneway': 'yes'}, [0]), expected={'class': 15, 'subclass': 722694187}) - self.check_not_err(n.way(data, {'x': 'y'}, [0]), expected={'class': 15, 'subclass': 722694187}) - self.check_err(n.way(data, {'amenity': 'place_of_worship', 'building': 'chapel', 'name': 'OsmoseRuleTrigger', 'x': 'yes'}, [0]), expected={'class': 16, 'subclass': 1095325051}) - self.check_err(n.way(data, {'amenity': 'place_of_worship', 'name': 'OsmoseRuleTrigger', 'x': 'yes'}, [0]), expected={'class': 16, 'subclass': 1095325051}) - self.check_not_err(n.way(data, {'amenity': 'place_of_worship', 'name': 'Westminster', 'x': 'yes'}, [0]), expected={'class': 16, 'subclass': 1095325051}) - self.check_err(n.way(data, {'building': 'chapel', 'name': 'OsmoseRuleTrigger', 'x': 'yes'}, [0]), expected={'class': 16, 'subclass': 1095325051}) - self.check_err(n.way(data, {'amenity': 'place_of_worship', 'building': 'chapel', 'name': 'OsmoseRuleTrigger', 'x': 'yes'}, [0]), expected={'class': 17, 'subclass': 1140742172}) - self.check_not_err(n.way(data, {'amenity': 'place_of_worship', 'building': 'chapel', 'name': 'Westminster', 'x': 'yes'}, [0]), expected={'class': 17, 'subclass': 1140742172}) - self.check_not_err(n.way(data, {'amenity': 'place_of_worship', 'name': 'OsmoseRuleTrigger', 'x': 'yes'}, [0]), expected={'class': 17, 'subclass': 1140742172}) - self.check_not_err(n.way(data, {'building': 'chapel', 'name': 'OsmoseRuleTrigger', 'x': 'yes'}, [0]), expected={'class': 17, 'subclass': 1140742172}) + self.check_err(n.way(data, {'oneway': '1'}, [0]), expected={'class': 16, 'subclass': 1489464739}) + self.check_not_err(n.way(data, {'oneway': '4.0'}, [0]), expected={'class': 16, 'subclass': 1489464739}) + self.check_not_err(n.way(data, {'oneway': 'no'}, [0]), expected={'class': 16, 'subclass': 1489464739}) + self.check_err(n.way(data, {'oneway': 'yes'}, [0]), expected={'class': 16, 'subclass': 1489464739}) + self.check_not_err(n.way(data, {'x': 'y'}, [0]), expected={'class': 16, 'subclass': 1489464739}) + self.check_err(n.way(data, {'oneway': '0'}, [0]), expected={'class': 16, 'subclass': 722694187}) + self.check_err(n.way(data, {'oneway': 'no'}, [0]), expected={'class': 16, 'subclass': 722694187}) + self.check_not_err(n.way(data, {'oneway': 'yes'}, [0]), expected={'class': 16, 'subclass': 722694187}) + self.check_not_err(n.way(data, {'x': 'y'}, [0]), expected={'class': 16, 'subclass': 722694187}) + self.check_err(n.way(data, {'amenity': 'place_of_worship', 'building': 'chapel', 'name': 'OsmoseRuleTrigger', 'x': 'yes'}, [0]), expected={'class': 17, 'subclass': 1095325051}) + self.check_err(n.way(data, {'amenity': 'place_of_worship', 'name': 'OsmoseRuleTrigger', 'x': 'yes'}, [0]), expected={'class': 17, 'subclass': 1095325051}) + self.check_not_err(n.way(data, {'amenity': 'place_of_worship', 'name': 'Westminster', 'x': 'yes'}, [0]), expected={'class': 17, 'subclass': 1095325051}) + self.check_err(n.way(data, {'building': 'chapel', 'name': 'OsmoseRuleTrigger', 'x': 'yes'}, [0]), expected={'class': 17, 'subclass': 1095325051}) + self.check_err(n.way(data, {'amenity': 'place_of_worship', 'building': 'chapel', 'name': 'OsmoseRuleTrigger', 'x': 'yes'}, [0]), expected={'class': 18, 'subclass': 1140742172}) + self.check_not_err(n.way(data, {'amenity': 'place_of_worship', 'building': 'chapel', 'name': 'Westminster', 'x': 'yes'}, [0]), expected={'class': 18, 'subclass': 1140742172}) + self.check_not_err(n.way(data, {'amenity': 'place_of_worship', 'name': 'OsmoseRuleTrigger', 'x': 'yes'}, [0]), expected={'class': 18, 'subclass': 1140742172}) + self.check_not_err(n.way(data, {'building': 'chapel', 'name': 'OsmoseRuleTrigger', 'x': 'yes'}, [0]), expected={'class': 18, 'subclass': 1140742172}) with with_options(n, {'country': 'FR'}): - self.check_err(n.way(data, {'x': 'y'}, [0]), expected={'class': 18, 'subclass': 1132689531}) + self.check_err(n.way(data, {'x': 'y'}, [0]), expected={'class': 19, 'subclass': 1132689531}) self.check_err(n.way(data, {'x': 'yes'}, [0]), expected={'class': 97, 'subclass': 2}) self.check_not_err(n.way(data, {'y': 'yes'}, [0]), expected={'class': 97, 'subclass': 2}) self.check_err(n.way(data, {'x': 'yes'}, [0]), expected={'class': 99, 'subclass': 2}) self.check_not_err(n.way(data, {'y': 'yes'}, [0]), expected={'class': 99, 'subclass': 2}) - self.check_err(n.way(data, {'maxspeed': '10000'}, [0]), expected={'class': 19, 'subclass': 2063115534}) - self.check_not_err(n.way(data, {'maxspeed': '5000'}, [0]), expected={'class': 19, 'subclass': 2063115534}) - self.check_not_err(n.way(data, {'maxspeed': 'default'}, [0]), expected={'class': 19, 'subclass': 2063115534}) - self.check_not_err(n.way(data, {}, [0]), expected={'class': 19, 'subclass': 2063115534}) + self.check_err(n.way(data, {'maxspeed': '10000'}, [0]), expected={'class': 20, 'subclass': 2063115534}) + self.check_not_err(n.way(data, {'maxspeed': '5000'}, [0]), expected={'class': 20, 'subclass': 2063115534}) + self.check_not_err(n.way(data, {'maxspeed': 'default'}, [0]), expected={'class': 20, 'subclass': 2063115534}) + self.check_not_err(n.way(data, {}, [0]), expected={'class': 20, 'subclass': 2063115534}) self.check_not_err(n.way(data, {'a': '0', 'b': '1'}, [0]), expected={'class': 6, 'subclass': 384294833}) self.check_not_err(n.way(data, {'a': '0', 'b': 'yes'}, [0]), expected={'class': 6, 'subclass': 384294833}) self.check_err(n.way(data, {'a': '1', 'b': '0'}, [0]), expected={'class': 6, 'subclass': 384294833}) diff --git a/plugins/tests/test_mapcss_parsing_evalutation.validator.mapcss b/plugins/tests/test_mapcss_parsing_evalutation.validator.mapcss index bc72f5329..ca5ef5675 100644 --- a/plugins/tests/test_mapcss_parsing_evalutation.validator.mapcss +++ b/plugins/tests/test_mapcss_parsing_evalutation.validator.mapcss @@ -388,3 +388,18 @@ relation[z]!:closed2 { assertNoMatch: "relation type=multipolygon z=yes"; assertMatch: "relation type=other z=yes"; } + + +node[any(tag("x"), "") == any(tag("y"), "hello")], +node[a] { + throwWarning: tr("test any {0} {1}", any(tag("b"), ""), any(tag("c"), tag("d"), "")); + assertMatch: "node a=1 b=2 c=3 d=four"; + assertMatch: "node a=1 b=2 d=four"; + assertMatch: "node a=1"; + assertMatch: "node x=hello"; + assertMatch: "node x=hello y=hello"; + assertNoMatch: "node x=hello y=world"; + assertNoMatch: "node x=bye y=world"; + assertNoMatch: "node y=world"; + assertNoMatch: "node unknownkey=yes"; +}