aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google
diff options
context:
space:
mode:
authorGravatar Florian Weikert <fwe@google.com>2015-09-18 11:51:01 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2015-09-21 08:56:57 +0000
commitffd8a5a17d20762d299f293574711cf592dec2e1 (patch)
tree357c0c9e12a6a9cbd5ba21b85cb0924e06a6de72 /src/test/java/com/google
parentffa73addaf80ab7a9cf9f98e5d4414b152ae6cb6 (diff)
Skylark: Unified ListComprehension and DictComprehension.
As a result, complex dict comprehensions (nested + with conditions) can be used. -- MOS_MIGRATED_REVID=103374493
Diffstat (limited to 'src/test/java/com/google')
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java7
1 files changed, 7 insertions, 0 deletions
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 04746bb509..14b26ec218 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 @@ public class EvaluationTest extends EvaluationTestCase {
}
@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']}",