aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/syntax/PrinterTest.java
diff options
context:
space:
mode:
authorGravatar Florian Weikert <fwe@google.com>2015-08-04 16:36:58 +0000
committerGravatar John Field <jfield@google.com>2015-08-04 20:26:55 +0000
commitf31b947420070b161e1cab4c9ff9e346ee81b65a (patch)
tree9b574320c79122be714dd5a3933897b4ae883d9f /src/test/java/com/google/devtools/build/lib/syntax/PrinterTest.java
parent7d57154cda1c500d70ff5134e8ee2892ce60050d (diff)
Changes related to the order of Skylark dictionaries:
- Objects of different types can now be compared. - Printer now prints dictionaries in a deterministic order, even when the keys have different types. - testEval() in EvaluationTestCases evaluates both expressions instead of comparing expression strings. Consequently, if a statement describes a collection, its order does no longer matter when doing the comparison. -- MOS_MIGRATED_REVID=99829458
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/syntax/PrinterTest.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/PrinterTest.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/PrinterTest.java b/src/test/java/com/google/devtools/build/lib/syntax/PrinterTest.java
index 3dbcfb1e9a..baa1fcb847 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/PrinterTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/PrinterTest.java
@@ -27,6 +27,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.IllegalFormatException;
import java.util.List;
import java.util.Map;
@@ -109,6 +110,17 @@ public class PrinterTest {
}
@Test
+ public void testSortedOutputOfUnsortedMap() throws Exception {
+ Map<Integer, Integer> map = new HashMap<>();
+ int[] data = {5, 7, 3};
+
+ for (int current : data) {
+ map.put(current, current);
+ }
+ assertThat(Printer.str(map)).isEqualTo("{3: 3, 5: 5, 7: 7}");
+ }
+
+ @Test
public void testFormatPositional() throws Exception {
assertEquals("foo 3", Printer.formatString("%s %d", makeTuple("foo", 3)));
assertEquals("foo 3", Printer.format("%s %d", "foo", 3));