Skip to content

Commit 1dbc22c

Browse files
Famlamfrodrigo
authored andcommitted
Add tests
1 parent 7edd2e3 commit 1dbc22c

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

plugins/tests/test_mapcss_parsing_evaluation.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,30 @@ def node(self, data, tags):
727727
# assertMatch:"node x=\"It\\\\'s working\""
728728
err.append({'class': 14, 'subclass': 1474979323, 'text': mapcss.tr('test #2236 - {0} {1}', mapcss._tag_uncapture(capture_tags, '{0.key}'), mapcss._tag_uncapture(capture_tags, '{0.value}'))})
729729

730+
# node[to_int("-3")+to_short("4")*to_long("2")=5]
731+
if True:
732+
match = False
733+
if not match:
734+
capture_tags = {}
735+
try: match = ((mapcss.to_int('-3')+mapcss.to_short('4')*mapcss.to_long('2') == 5))
736+
except mapcss.RuleAbort: pass
737+
if match:
738+
# throwWarning:"test"
739+
# assertMatch:"node x=y"
740+
err.append({'class': 6, 'subclass': 560627145, 'text': {'en': 'test'}})
741+
742+
# node[to_float("3.14e1")=31.4][to_double("3.1415e1")=31.415]
743+
if True:
744+
match = False
745+
if not match:
746+
capture_tags = {}
747+
try: match = ((mapcss.to_float('3.14e1') == 31.4) and (mapcss.to_double('3.1415e1') == 31.415))
748+
except mapcss.RuleAbort: pass
749+
if match:
750+
# throwWarning:"test"
751+
# assertMatch:"node x=y"
752+
err.append({'class': 6, 'subclass': 931844076, 'text': {'en': 'test'}})
753+
730754
return err
731755

732756
def way(self, data, tags, nds):
@@ -1468,6 +1492,8 @@ class father:
14681492
self.check_err(n.node(data, {'x': 'd'}), expected={'class': 14, 'subclass': 877576641})
14691493
self.check_not_err(n.node(data, {'x': 'It\'s working'}), expected={'class': 14, 'subclass': 1474979323})
14701494
self.check_err(n.node(data, {'x': 'It\\\\\'s working'}), expected={'class': 14, 'subclass': 1474979323})
1495+
self.check_err(n.node(data, {'x': 'y'}), expected={'class': 6, 'subclass': 560627145})
1496+
self.check_err(n.node(data, {'x': 'y'}), expected={'class': 6, 'subclass': 931844076})
14711497
self.check_err(n.way(data, {'x': 'C00;C1;C22'}, [0]), expected={'class': 15, 'subclass': 1785050832})
14721498
self.check_err(n.way(data, {'x': 'C1'}, [0]), expected={'class': 15, 'subclass': 1785050832})
14731499
self.check_not_err(n.way(data, {'x': 'C12'}, [0]), expected={'class': 15, 'subclass': 1785050832})

plugins/tests/test_mapcss_parsing_evaluation.validator.mapcss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,3 +551,13 @@ node[x!~/It's\sworking/] {
551551
assertMatch: "node x=\"It\\\\'s working\"";
552552
assertNoMatch: "node x=\"It's working\"";
553553
}
554+
555+
node[to_int("-3") + to_short("4") * to_long("2") = 5] {
556+
throwWarning: "test";
557+
assertMatch: "node x=y";
558+
}
559+
560+
node[to_float("3.14e1") = 31.4][to_double("3.1415e1") = 31.415] {
561+
throwWarning: "test";
562+
assertMatch: "node x=y";
563+
}

0 commit comments

Comments
 (0)