Ticket #17995: 17995.patch
| File 17995.patch, 2.4 KB (added by , 7 years ago) |
|---|
-
src/org/openstreetmap/josm/gui/mappaint/mapcss/Functions.java
494 494 } 495 495 496 496 /** 497 * Sort an array of strings 498 * @param sortables The array to sort 499 * @return The sorted array 500 */ 501 public static List<String> sort(String... sortables) { 502 Arrays.parallelSort(sortables); 503 return Arrays.asList(sortables); 504 } 505 506 /** 497 507 * Returns the role of current object in parent relation, or role of child if current object is a relation. 498 508 * @param env the environment 499 509 * @return role of current object in parent relation, or role of child if current object is a relation -
test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.java
(this hunk was shorter than expected) 9 9 10 10 import java.awt.Color; 11 11 import java.io.StringReader; 12 import java.util.Arrays; 12 13 import java.util.List; 13 14 14 15 import org.junit.Rule; … … 407 409 } 408 410 409 411 @Test 412 public void testSort() throws Exception { 413 assertEquals(Arrays.asList(new String[] {"alpha", "beta"}), Functions.sort("beta", "alpha")); 414 Way way1 = TestUtils.newWay("highway=residential name=Alpha alt_name=Beta", new Node(new LatLon(0.001, 0.001)), 415 new Node(new LatLon(0.002, 0.002))); 416 417 MapCSSStyleSource source = new MapCSSStyleSource("way[highway] {sorted: join_list(\",\", sort(tag(\"alt_name\"), tag(\"name\")));}"); 418 source.loadStyleSource(); 419 assertEquals(1, source.rules.size()); 420 Environment e = new Environment(way1, new MultiCascade(), Environment.DEFAULT_LAYER, null); 421 assertTrue(source.rules.get(0).selector.matches(e)); 422 source.rules.get(0).declaration.execute(e); 423 assertEquals(Functions.join(",", "Alpha", "Beta"), e.getCascade(Environment.DEFAULT_LAYER).get("sorted", null, String.class)); 424 } 425 426 @Test 410 427 public void testCountRoles() throws Exception { 411 428 DataSet ds = new DataSet(); 412 429 Way way1 = TestUtils.newWay("highway=residential name=1",
