aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java
diff options
context:
space:
mode:
authorGravatar Jon Brandvein <brandjon@google.com>2017-01-12 20:22:07 +0000
committerGravatar Marcel Hlopko <hlopko@google.com>2017-01-13 10:57:33 +0000
commit5b792dc6eafe24728f4da809502668470faf36db (patch)
treeb811dcafca407494c9a0462a02522fe175c4a299 /src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java
parentb7a731189eee8a57c6aee289f7b1bdae91b32d99 (diff)
Refactor SkylarkNestedSet type checks and tests
Moved some tests, fixed formatting, changed to use assertThat(). -- PiperOrigin-RevId: 144356402 MOS_MIGRATED_REVID=144356402
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java54
1 files changed, 2 insertions, 52 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java b/src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java
index b2910a25c0..e0c6c99c24 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java
@@ -15,9 +15,7 @@
package com.google.devtools.build.lib.syntax;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertEquals;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.syntax.SkylarkList.MutableList;
@@ -1410,56 +1408,6 @@ public class MethodLibraryTest extends EvaluationTestCase {
}
@Test
- public void testSetUnionWithList() throws Exception {
- evaluateSet("depset([]).union(['a', 'b', 'c'])", "a", "b", "c");
- evaluateSet("depset(['a']).union(['b', 'c'])", "a", "b", "c");
- evaluateSet("depset(['a', 'b']).union(['c'])", "a", "b", "c");
- evaluateSet("depset(['a', 'b', 'c']).union([])", "a", "b", "c");
- }
-
- @Test
- public void testSetUnionWithSet() throws Exception {
- evaluateSet("depset([]).union(depset(['a', 'b', 'c']))", "a", "b", "c");
- evaluateSet("depset(['a']).union(depset(['b', 'c']))", "a", "b", "c");
- evaluateSet("depset(['a', 'b']).union(depset(['c']))", "a", "b", "c");
- evaluateSet("depset(['a', 'b', 'c']).union(depset([]))", "a", "b", "c");
- }
-
- @Test
- public void testSetUnionDuplicates() throws Exception {
- evaluateSet("depset(['a', 'b', 'c']).union(['a', 'b', 'c'])", "a", "b", "c");
- evaluateSet("depset(['a', 'a', 'a']).union(['a', 'a'])", "a");
-
- evaluateSet("depset(['a', 'b', 'c']).union(depset(['a', 'b', 'c']))", "a", "b", "c");
- evaluateSet("depset(['a', 'a', 'a']).union(depset(['a', 'a']))", "a");
- }
-
- @Test
- public void testSetUnionError() throws Exception {
- new BothModesTest()
- .testIfErrorContains("insufficient arguments received by union", "depset(['a']).union()")
- .testIfErrorContains(
- "method depset.union(new_elements: Iterable) is not applicable for arguments (string): "
- + "'new_elements' is 'string', but should be 'Iterable'",
- "depset(['a']).union('b')");
- }
-
- @Test
- public void testSetUnionSideEffects() throws Exception {
- eval(
- "def func():",
- " n1 = depset(['a'])",
- " n2 = n1.union(['b'])",
- " return n1",
- "n = func()");
- assertEquals(ImmutableList.of("a"), ((SkylarkNestedSet) lookup("n")).toCollection());
- }
-
- private void evaluateSet(String statement, Object... expectedElements) throws Exception {
- new BothModesTest().testCollection(statement, expectedElements);
- }
-
- @Test
public void testListIndexMethod() throws Exception {
new BothModesTest()
.testStatement("['a', 'b', 'c'].index('a')", 0)
@@ -1753,6 +1701,8 @@ public class MethodLibraryTest extends EvaluationTestCase {
.testStatement("type(str)", "function");
}
+ // TODO(bazel-team): Move this into a new BazelLibraryTest.java file, or at least out of
+ // MethodLibraryTest.java.
@Test
public void testSelectFunction() throws Exception {
enableSkylarkMode();