diff options
Diffstat (limited to 'src/test/java/com')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java | 2 | ||||
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/syntax/SkylarkNestedSetTest.java | 20 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java b/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java index 714f197f38..05d5a3e74e 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java +++ b/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java @@ -117,6 +117,7 @@ public class SkylarkSemanticsConsistencyTest { "--incompatible_checked_arithmetic=" + rand.nextBoolean(), "--incompatible_comprehension_variables_do_not_leak=" + rand.nextBoolean(), "--incompatible_depset_is_not_iterable=" + rand.nextBoolean(), + "--incompatible_depset_union=" + rand.nextBoolean(), "--incompatible_dict_literal_has_no_duplicates=" + rand.nextBoolean(), "--incompatible_disallow_dict_plus=" + rand.nextBoolean(), "--incompatible_disallow_keyword_only_args=" + rand.nextBoolean(), @@ -142,6 +143,7 @@ public class SkylarkSemanticsConsistencyTest { .incompatibleCheckedArithmetic(rand.nextBoolean()) .incompatibleComprehensionVariablesDoNotLeak(rand.nextBoolean()) .incompatibleDepsetIsNotIterable(rand.nextBoolean()) + .incompatibleDepsetUnion(rand.nextBoolean()) .incompatibleDictLiteralHasNoDuplicates(rand.nextBoolean()) .incompatibleDisallowDictPlus(rand.nextBoolean()) .incompatibleDisallowKeywordOnlyArgs(rand.nextBoolean()) diff --git a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkNestedSetTest.java b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkNestedSetTest.java index 3ba85635d2..9c8f4de230 100644 --- a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkNestedSetTest.java +++ b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkNestedSetTest.java @@ -295,7 +295,21 @@ public class SkylarkNestedSetTest extends EvaluationTestCase { } @Test + public void testIncompatibleUnion() throws Exception { + new BothModesTest("--incompatible_depset_union=true") + .testIfErrorContains( + "depset method `.union` has been removed", "depset([]).union(['a', 'b', 'c'])"); + + new BothModesTest("--incompatible_depset_union=true") + .testIfErrorContains("`+` operator on a depset is forbidden", "depset([]) + ['a']"); + + new BothModesTest("--incompatible_depset_union=true") + .testIfErrorContains("`|` operator on a depset is forbidden", "depset([]) | ['a']"); + } + + @Test public void testUnionWithList() throws Exception { + env = newEnvironmentWithSkylarkOptions("--incompatible_depset_union=false"); assertContainsInOrder("depset([]).union(['a', 'b', 'c'])", "a", "b", "c"); assertContainsInOrder("depset(['a']).union(['b', 'c'])", "a", "b", "c"); assertContainsInOrder("depset(['a', 'b']).union(['c'])", "a", "b", "c"); @@ -304,6 +318,7 @@ public class SkylarkNestedSetTest extends EvaluationTestCase { @Test public void testUnionWithDepset() throws Exception { + env = newEnvironmentWithSkylarkOptions("--incompatible_depset_union=false"); assertContainsInOrder("depset([]).union(depset(['a', 'b', 'c']))", "a", "b", "c"); assertContainsInOrder("depset(['a']).union(depset(['b', 'c']))", "b", "c", "a"); assertContainsInOrder("depset(['a', 'b']).union(depset(['c']))", "c", "a", "b"); @@ -312,6 +327,7 @@ public class SkylarkNestedSetTest extends EvaluationTestCase { @Test public void testUnionDuplicates() throws Exception { + env = newEnvironmentWithSkylarkOptions("--incompatible_depset_union=false"); assertContainsInOrder("depset(['a', 'b', 'c']).union(['a', 'b', 'c'])", "a", "b", "c"); assertContainsInOrder("depset(['a', 'a', 'a']).union(['a', 'a'])", "a"); @@ -329,6 +345,7 @@ public class SkylarkNestedSetTest extends EvaluationTestCase { @Test public void testUnionOrder() throws Exception { + env = newEnvironmentWithSkylarkOptions("--incompatible_depset_union=false"); eval( "def func():", " s1 = depset()", @@ -455,6 +472,7 @@ public class SkylarkNestedSetTest extends EvaluationTestCase { @Test public void testToString() throws Exception { + env = newEnvironmentWithSkylarkOptions("--incompatible_depset_union=false"); eval( "s = depset() + [2, 4, 6] + [3, 4, 5]", "x = str(s)"); @@ -463,6 +481,7 @@ public class SkylarkNestedSetTest extends EvaluationTestCase { @Test public void testToStringWithOrder() throws Exception { + env = newEnvironmentWithSkylarkOptions("--incompatible_depset_union=false"); eval( "s = depset(order = 'topological') + [2, 4, 6] + [3, 4, 5]", "x = str(s)"); @@ -476,6 +495,7 @@ public class SkylarkNestedSetTest extends EvaluationTestCase { @Test public void testToList() throws Exception { + env = newEnvironmentWithSkylarkOptions("--incompatible_depset_union=false"); eval( "s = depset() + [2, 4, 6] + [3, 4, 5]", "x = s.to_list()"); |