Changeset 8415 in josm for trunk/test/unit/org
- Timestamp:
- 2015-05-22T21:15:05+02:00 (9 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ChildOrParentSelectorTest.groovy
r7081 r8415 140 140 r.addMember(new RelationMember("another role", w3)) 141 141 142 Environment e = new Environment( ).withPrimitive(r)142 Environment e = new Environment(r) 143 143 assert selector.matches(e) 144 144 } … … 165 165 r.addMember(new RelationMember("another role", w3)) 166 166 167 Environment e = new Environment( ).withPrimitive(w1)167 Environment e = new Environment(w1) 168 168 assert !selector.matches(e) 169 169 170 e = new Environment( ).withPrimitive(w2)170 e = new Environment(w2) 171 171 assert !selector.matches(e) 172 172 173 e = new Environment( ).withPrimitive(w3)173 e = new Environment(w3) 174 174 assert selector.matches(e) 175 175 } -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/KeyConditionTest.groovy
r8206 r8415 77 77 r.addMember(new RelationMember("my_role", n)) 78 78 79 Environment e = new Environment( ).withPrimitive(n).withParent(r).withIndex(0, r.membersCount).withLinkContext()79 Environment e = new Environment(n).withParent(r).withIndex(0, r.membersCount).withLinkContext() 80 80 81 81 Condition cond = Condition.createKeyCondition("my_role", false, null, Context.LINK) … … 92 92 r.addMember(new RelationMember("my_role", n)) 93 93 94 Environment e = new Environment( ).withPrimitive(n).withParent(r).withIndex(0, r.membersCount).withLinkContext()94 Environment e = new Environment(n).withParent(r).withIndex(0, r.membersCount).withLinkContext() 95 95 96 96 Condition cond = Condition.createKeyCondition("another_role", false, null, Context.LINK) -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/KeyValueConditionTest.groovy
r8206 r8415 63 63 r.addMember(new RelationMember("my_role", n)) 64 64 65 Environment e = new Environment( ).withPrimitive(n).withParent(r).withLinkContext().withIndex(0, r.membersCount)65 Environment e = new Environment(n).withParent(r).withLinkContext().withIndex(0, r.membersCount) 66 66 67 67 Condition cond = new Condition.RoleCondition("my_role", Op.EQ) … … 78 78 r.addMember(new RelationMember("my_role", n)) 79 79 80 Environment e = new Environment( ).withPrimitive(n).withParent(r).withIndex(0, r.membersCount).withLinkContext()80 Environment e = new Environment(n).withParent(r).withIndex(0, r.membersCount).withLinkContext() 81 81 82 82 Condition cond = Condition.createKeyValueCondition("role", "my_role", Op.NEQ, Context.LINK, false) -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.groovy
r7938 r8415 19 19 20 20 protected static Environment getEnvironment(String key, String value) { 21 return new Environment( ).withPrimitive(OsmUtils.createPrimitive("way " + key + "=" + value))21 return new Environment(OsmUtils.createPrimitive("way " + key + "=" + value)) 22 22 } 23 23 … … 192 192 public void testNRegexKeyConditionSelector() throws Exception { 193 193 def s1 = getParser("*[sport][tourism != hotel]").selector() 194 assert s1.matches(new Environment( ).withPrimitive(OsmUtils.createPrimitive("node sport=foobar")))195 assert !s1.matches(new Environment( ).withPrimitive(OsmUtils.createPrimitive("node sport=foobar tourism=hotel")))194 assert s1.matches(new Environment(OsmUtils.createPrimitive("node sport=foobar"))) 195 assert !s1.matches(new Environment(OsmUtils.createPrimitive("node sport=foobar tourism=hotel"))) 196 196 def s2 = getParser("*[sport][tourism != hotel][leisure !~ /^(sports_centre|stadium|)\$/]").selector() 197 assert s2.matches(new Environment( ).withPrimitive(OsmUtils.createPrimitive("node sport=foobar")))198 assert !s2.matches(new Environment( ).withPrimitive(OsmUtils.createPrimitive("node sport=foobar tourism=hotel")))199 assert !s2.matches(new Environment( ).withPrimitive(OsmUtils.createPrimitive("node sport=foobar leisure=stadium")))197 assert s2.matches(new Environment(OsmUtils.createPrimitive("node sport=foobar"))) 198 assert !s2.matches(new Environment(OsmUtils.createPrimitive("node sport=foobar tourism=hotel"))) 199 assert !s2.matches(new Environment(OsmUtils.createPrimitive("node sport=foobar leisure=stadium"))) 200 200 } 201 201 … … 206 206 w1.put("foo", "123") 207 207 w1.put("bar", "456") 208 assert !c1.applies(new Environment( ).withPrimitive(w1))208 assert !c1.applies(new Environment(w1)) 209 209 w1.put("bar", "123") 210 assert c1.applies(new Environment( ).withPrimitive(w1))210 assert c1.applies(new Environment(w1)) 211 211 def c2 = (Condition.KeyValueCondition) getParser("[foo =~ */bar/]").condition(Condition.Context.PRIMITIVE) 212 212 def w2 = new Way(w1) 213 213 w2.put("bar", "[0-9]{3}") 214 assert c2.applies(new Environment( ).withPrimitive(w2))214 assert c2.applies(new Environment(w2)) 215 215 w2.put("bar", "[0-9]") 216 assert c2.applies(new Environment( ).withPrimitive(w2))216 assert c2.applies(new Environment(w2)) 217 217 w2.put("bar", "^[0-9]\$") 218 assert !c2.applies(new Environment( ).withPrimitive(w2))218 assert !c2.applies(new Environment(w2)) 219 219 } 220 220 … … 301 301 w.addNode(n2) 302 302 303 def e = new Environment( ).withPrimitive(n2)303 def e = new Environment(n2) 304 304 assert s1.matches(e) 305 305 assert e.osm == n2 306 306 assert e.child == n1 307 307 assert e.parent == w 308 assert !s1.matches(new Environment( ).withPrimitive(n1))309 assert !s1.matches(new Environment( ).withPrimitive(w))308 assert !s1.matches(new Environment(n1)) 309 assert !s1.matches(new Environment(w)) 310 310 } 311 311 … … 332 332 w.addNode(n3) 333 333 334 assert s1.right.matches(new Environment( ).withPrimitive(n3))335 assert s1.left.matches(new Environment( ).withPrimitive(n2).withChild(n3).withParent(w))336 assert s1.matches(new Environment( ).withPrimitive(n3))337 assert !s1.matches(new Environment( ).withPrimitive(n1))338 assert !s1.matches(new Environment( ).withPrimitive(n2))339 assert !s1.matches(new Environment( ).withPrimitive(w))334 assert s1.right.matches(new Environment(n3)) 335 assert s1.left.matches(new Environment(n2).withChild(n3).withParent(w)) 336 assert s1.matches(new Environment(n3)) 337 assert !s1.matches(new Environment(n1)) 338 assert !s1.matches(new Environment(n2)) 339 assert !s1.matches(new Environment(w)) 340 340 } 341 341
Note:
See TracChangeset
for help on using the changeset viewer.