Skylark: Unified ListComprehension and DictComprehension.
As a result, complex dict comprehensions (nested + with conditions) can be used.
--
MOS_MIGRATED_REVID=103374493
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java b/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java
index 04746bb..14b26ec 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java
@@ -483,6 +483,13 @@
}
@Test
+ public void testDictComprehension_ManyClauses() throws Exception {
+ new SkylarkTest().testStatement(
+ "{x : x * y for x in range(1, 10) if x % 2 == 0 for y in range(1, 10) if y == x}",
+ ImmutableMap.of(2, 4, 4, 16, 6, 36, 8, 64));
+ }
+
+ @Test
public void testDictComprehensions_MultipleKey() throws Exception {
newTest().testStatement("{x : x for x in [1, 2, 1]}", ImmutableMap.of(1, 1, 2, 2))
.testStatement("{y : y for y in ['ab', 'c', 'a' + 'b']}",