aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/syntax
diff options
context:
space:
mode:
authorGravatar cparsons <cparsons@google.com>2018-04-11 14:24:00 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-04-11 14:25:21 -0700
commit0fcad77c50290a66bdf3870eda7ec7656549c2eb (patch)
tree7f4b94876149f7e10382998de63d4789166f5ad0 /src/test/java/com/google/devtools/build/lib/syntax
parent7f09a6cec5dd819f65b1c31802481f8a6b140ee7 (diff)
Migrate StringModule methods to SkylarkCallable from SkylarkSignature.
StringModule is a special case in a number of places because it represents effectively methods which should be annotated on String.class. However, String may not be subclassed in Java. StringModule thus serves as a proxy module for String. RELNOTES: None. PiperOrigin-RevId: 192508607
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/syntax')
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java6
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java12
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/RuntimeTest.java9
3 files changed, 9 insertions, 18 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 c0bd4a46fe..a69563a73f 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
@@ -693,8 +693,8 @@ public class EvaluationTest extends EvaluationTestCase {
@Test
public void testArgBothPosKey() throws Exception {
newTest().testIfErrorContains(
- "arguments 'old', 'new' passed both by position and by name "
- + "in call to replace(self: string, ",
- "'banana'.replace('a', 'o', 3, old='a', new=4)");
+ "got multiple values for keyword argument 'old', "
+ + "in method call replace(string, string, int, string old) of 'string'",
+ "'banana'.replace('a', 'o', 3, old='a')");
}
}
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 2c353d6fc9..d487eff0d2 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
@@ -106,8 +106,8 @@ public class MethodLibraryTest extends EvaluationTestCase {
// only one built-in function.
new BothModesTest()
.testIfExactError(
- "argument 'sub' has type 'int', but should be 'string'\n"
- + "in call to builtin method string.index(sub, start, end)",
+ "expected value of type 'string' for parameter 'sub', "
+ + "in method call index(int) of 'string'",
"'test'.index(1)");
}
@@ -131,8 +131,8 @@ public class MethodLibraryTest extends EvaluationTestCase {
+ LINE_SEPARATOR
+ "\t\t\"test\".index(x)"
+ LINE_SEPARATOR
- + "argument 'sub' has type 'int', but should be 'string'\n"
- + "in call to builtin method string.index(sub, start, end)",
+ + "expected value of type 'string' for parameter 'sub', "
+ + "in method call index(int) of 'string'",
"def foo():",
" bar(1)",
"def bar(x):",
@@ -146,8 +146,8 @@ public class MethodLibraryTest extends EvaluationTestCase {
new BothModesTest()
.testIfErrorContains("substring \"z\" not found in \"abc\"", "'abc'.index('z')")
.testIfErrorContains(
- "argument 'sub' has type 'int', but should be 'string'\n"
- + "in call to builtin method string.startswith(sub, start, end)",
+ "expected value of type 'string' for parameter 'sub', "
+ + "in method call startswith(int) of 'string'",
"'test'.startswith(1)")
.testIfErrorContains(
"expected value of type 'list(object)' for parameter args in dict(), "
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/RuntimeTest.java b/src/test/java/com/google/devtools/build/lib/syntax/RuntimeTest.java
index 9da686707a..e2fc1e65d4 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/RuntimeTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/RuntimeTest.java
@@ -108,15 +108,6 @@ public final class RuntimeTest {
}
@Test
- public void checkStaticallyRegistered_Method() throws Exception {
- Field splitField = MethodLibrary.class.getDeclaredField("split");
- splitField.setAccessible(true);
- Object splitFieldValue = splitField.get(null);
- Object splitFunc = Runtime.getBuiltinRegistry().getFunction(String.class, "split");
- assertThat(splitFunc).isSameAs(splitFieldValue);
- }
-
- @Test
public void checkStaticallyRegistered_Global() throws Exception {
Field lenField = MethodLibrary.class.getDeclaredField("len");
lenField.setAccessible(true);