aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/syntax
diff options
context:
space:
mode:
authorGravatar laurentlb <laurentlb@google.com>2017-11-27 05:43:36 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2017-11-27 05:45:34 -0800
commitc83c12db5052a4be4bed29f8a9344c17a51aff3f (patch)
treed3e90cc6bd862075999dcea0749627186c4b99fd /src/test/java/com/google/devtools/build/lib/syntax
parent0838aeeb545013c8261f0ae438f6027a78aea603 (diff)
Migrate some Skylark tests outside of Blaze.
RELNOTES: None. PiperOrigin-RevId: 177004853
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/syntax')
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java353
1 files changed, 0 insertions, 353 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 e57d8c8f79..a9a4b3861d 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
@@ -38,207 +38,6 @@ public class MethodLibraryTest extends EvaluationTestCase {
}
@Test
- public void testSplitLines_EmptyLine() throws Exception {
- new BothModesTest().testEval("''.splitlines()", "[]").testEval("'\\n'.splitlines()", "['']");
- }
-
- @Test
- public void testSplitLines_StartsWithLineBreak() throws Exception {
- new BothModesTest().testEval("'\\ntest'.splitlines()", "['', 'test']");
- }
-
- @Test
- public void testSplitLines_EndsWithLineBreak() throws Exception {
- new BothModesTest().testEval("'test\\n'.splitlines()", "['test']");
- }
-
- @Test
- public void testSplitLines_DifferentLineBreaks() throws Exception {
- new BothModesTest()
- .testEval("'this\\nis\\na\\ntest'.splitlines()", "['this', 'is', 'a', 'test']");
- }
-
- @Test
- public void testSplitLines_OnlyLineBreaks() throws Exception {
- new BothModesTest()
- .testEval("'\\n\\n\\n'.splitlines()", "['', '', '']")
- .testEval("'\\r\\r\\r'.splitlines()", "['', '', '']")
- .testEval("'\\n\\r\\n\\r'.splitlines()", "['', '', '']")
- .testEval("'\\r\\n\\r\\n\\r\\n'.splitlines()", "['', '', '']");
- }
-
- @Test
- public void testSplitLines_EscapedSequences() throws Exception {
- new BothModesTest().testEval("'\\n\\\\n\\\\\\n'.splitlines()", "['', '\\\\n\\\\']");
- }
-
- @Test
- public void testSplitLines_KeepEnds() throws Exception {
- new BothModesTest()
- .testEval("''.splitlines(True)", "[]")
- .testEval("'\\n'.splitlines(True)", "['\\n']")
- .testEval(
- "'this\\nis\\r\\na\\rtest'.splitlines(True)", "['this\\n', 'is\\r\\n', 'a\\r', 'test']")
- .testEval("'\\ntest'.splitlines(True)", "['\\n', 'test']")
- .testEval("'test\\n'.splitlines(True)", "['test\\n']")
- .testEval("'\\n\\\\n\\\\\\n'.splitlines(True)", "['\\n', '\\\\n\\\\\\n']");
- }
-
- @Test
- public void testStringIsAlnum() throws Exception {
- new BothModesTest()
- .testStatement("''.isalnum()", false)
- .testStatement("'a0 33'.isalnum()", false)
- .testStatement("'1'.isalnum()", true)
- .testStatement("'a033'.isalnum()", true);
- }
-
- @Test
- public void testStringIsDigit() throws Exception {
- new BothModesTest()
- .testStatement("''.isdigit()", false)
- .testStatement("' '.isdigit()", false)
- .testStatement("'a'.isdigit()", false)
- .testStatement("'0234325.33'.isdigit()", false)
- .testStatement("'1'.isdigit()", true)
- .testStatement("'033'.isdigit()", true);
- }
-
- @Test
- public void testStringIsSpace() throws Exception {
- new BothModesTest()
- .testStatement("''.isspace()", false)
- .testStatement("'a'.isspace()", false)
- .testStatement("'1'.isspace()", false)
- .testStatement("'\\ta\\n'.isspace()", false)
- .testStatement("' '.isspace()", true)
- .testStatement("'\\t\\n'.isspace()", true);
- }
-
- @Test
- public void testStringIsLower() throws Exception {
- new BothModesTest()
- .testStatement("''.islower()", false)
- .testStatement("' '.islower()", false)
- .testStatement("'1'.islower()", false)
- .testStatement("'Almost'.islower()", false)
- .testStatement("'abc'.islower()", true)
- .testStatement("' \\nabc'.islower()", true)
- .testStatement("'abc def\\n'.islower()", true)
- .testStatement("'\\ta\\n'.islower()", true);
- }
-
- @Test
- public void testStringIsUpper() throws Exception {
- new BothModesTest()
- .testStatement("''.isupper()", false)
- .testStatement("' '.isupper()", false)
- .testStatement("'1'.isupper()", false)
- .testStatement("'aLMOST'.isupper()", false)
- .testStatement("'ABC'.isupper()", true)
- .testStatement("' \\nABC'.isupper()", true)
- .testStatement("'ABC DEF\\n'.isupper()", true)
- .testStatement("'\\tA\\n'.isupper()", true);
- }
-
- @Test
- public void testStringIsTitle() throws Exception {
- new BothModesTest()
- .testStatement("''.istitle()", false)
- .testStatement("' '.istitle()", false)
- .testStatement("'134'.istitle()", false)
- .testStatement("'almost Correct'.istitle()", false)
- .testStatement("'1nope Nope Nope'.istitle()", false)
- .testStatement("'NO Way'.istitle()", false)
- .testStatement("'T'.istitle()", true)
- .testStatement("'Correct'.istitle()", true)
- .testStatement("'Very Correct! Yes\\nIndeed1X'.istitle()", true)
- .testStatement("'1234Ab Ab'.istitle()", true)
- .testStatement("'\\tA\\n'.istitle()", true);
- }
-
- @Test
- public void testAllWithEmptyValue() throws Exception {
- new BothModesTest()
- .testStatement("all('')", true)
- .testStatement("all([])", true)
- .testIfExactError("type 'NoneType' is not iterable", "any(None)");
- }
-
- @Test
- public void testAllWithPrimitiveType() throws Exception {
- new BothModesTest().testStatement("all('test')", true).testIfErrorContains("", "all(1)");
- }
-
- @Test
- public void testAllWithList() throws Exception {
- new BothModesTest()
- .testStatement("all([False])", false)
- .testStatement("all([True, False])", false)
- .testStatement("all([False, False])", false)
- .testStatement("all([False, True])", false)
- .testStatement("all(['', True])", false)
- .testStatement("all([0, True])", false)
- .testStatement("all([[], True])", false)
- .testStatement("all([True, 't', 1])", true);
- }
-
- @Test
- public void testAllWithSet() throws Exception {
- new BothModesTest()
- .testStatement("all(depset([0]))", false)
- .testStatement("all(depset([1, 0]))", false)
- .testStatement("all(depset([1]))", true);
- }
-
- @Test
- public void testAllWithDict() throws Exception {
- new BothModesTest()
- .testStatement("all({1 : None})", true)
- .testStatement("all({None : 1})", false);
- }
-
- @Test
- public void testAnyWithEmptyValue() throws Exception {
- new BothModesTest()
- .testStatement("any('')", false)
- .testStatement("any([])", false)
- .testIfExactError("type 'NoneType' is not iterable", "any(None)");
- }
-
- @Test
- public void testAnyWithPrimitiveType() throws Exception {
- new BothModesTest().testStatement("any('test')", true).testIfErrorContains("", "any(1)");
- }
-
- @Test
- public void testAnyWithList() throws Exception {
- new BothModesTest()
- .testStatement("any([False])", false)
- .testStatement("any([0])", false)
- .testStatement("any([''])", false)
- .testStatement("any([[]])", false)
- .testStatement("any([True, False])", true)
- .testStatement("any([False, False])", false)
- .testStatement("any([False, '', 0])", false)
- .testStatement("any([False, '', 42])", true);
- }
-
- @Test
- public void testAnyWithSet() throws Exception {
- new BothModesTest()
- .testStatement("any(depset([0]))", false)
- .testStatement("any(depset([1, 0]))", true);
- }
-
- @Test
- public void testAnyWithDict() throws Exception {
- new BothModesTest()
- .testStatement("any({1 : None, '' : None})", true)
- .testStatement("any({None : 1, '' : 2})", false);
- }
-
- @Test
public void testStackTraceLocation() throws Exception {
new SkylarkTest()
.testIfErrorContains(
@@ -456,158 +255,6 @@ public class MethodLibraryTest extends EvaluationTestCase {
}
@Test
- public void testPyStringSplit() throws Exception {
- new BothModesTest().testEval("'h i'.split(' ')", "['h', 'i']");
- }
-
- @Test
- public void testPyStringSplit2() throws Exception {
- new BothModesTest().testEval("'h i p'.split(' ')", "['h', 'i', 'p']");
- }
-
- @Test
- public void testPyStringSplit3() throws Exception {
- new BothModesTest().testEval("'a,e,i,o,u'.split(',', 2)", "['a', 'e', 'i,o,u']");
- }
-
- @Test
- public void testPyStringSplitNoSep() throws Exception {
- new BothModesTest()
- .testEval("' 1 2 3 '.split(' ')", "['', '', '1', '', '2', '', '3', '', '']");
- }
-
- @Test
- public void testPyStringRSplitRegex() throws Exception {
- new BothModesTest()
- .testEval("'foo/bar.lisp'.rsplit('.')", "['foo/bar', 'lisp']")
- .testEval("'foo/bar.?lisp'.rsplit('.?')", "['foo/bar', 'lisp']")
- .testEval("'fwe$foo'.rsplit('$')", "['fwe', 'foo']")
- .testEval("'windows'.rsplit('\\w')", "['windows']");
- }
-
- @Test
- public void testPyStringRSplitNoMatch() throws Exception {
- new BothModesTest()
- .testEval("''.rsplit('o')", "['']")
- .testEval("'google'.rsplit('x')", "['google']");
- }
-
- @Test
- public void testPyStringRSplitSeparator() throws Exception {
- new BothModesTest()
- .testEval("'xxxxxx'.rsplit('x')", "['', '', '', '', '', '', '']")
- .testEval("'xxxxxx'.rsplit('x', 1)", "['xxxxx', '']")
- .testEval("'xxxxxx'.rsplit('x', 2)", "['xxxx', '', '']")
- .testEval("'xxxxxx'.rsplit('x', 3)", "['xxx', '', '', '']")
- .testEval("'xxxxxx'.rsplit('x', 4)", "['xx', '', '', '', '']")
- .testEval("'xxxxxx'.rsplit('x', 5)", "['x', '', '', '', '', '']")
- .testEval("'xxxxxx'.rsplit('x', 6)", "['', '', '', '', '', '', '']")
- .testEval("'xxxxxx'.rsplit('x', 7)", "['', '', '', '', '', '', '']");
- }
-
- @Test
- public void testPyStringRSplitLongerSep() throws Exception {
- new BothModesTest()
- .testEval("'abcdabef'.rsplit('ab')", "['', 'cd', 'ef']")
- .testEval("'google_or_gogol'.rsplit('go')", "['', 'ogle_or_', '', 'l']");
- }
-
- @Test
- public void testPyStringRSplitMaxSplit() throws Exception {
- new BothModesTest()
- .testEval("'google'.rsplit('o')", "['g', '', 'gle']")
- .testEval("'google'.rsplit('o')", "['g', '', 'gle']")
- .testEval("'google'.rsplit('o', 1)", "['go', 'gle']")
- .testEval("'google'.rsplit('o', 2)", "['g', '', 'gle']")
- .testEval("'google'.rsplit('o', 3)", "['g', '', 'gle']")
- .testEval("'ogooglo'.rsplit('o')", "['', 'g', '', 'gl', '']")
- .testEval("'ogooglo'.rsplit('o', 1)", "['ogoogl', '']")
- .testEval("'ogooglo'.rsplit('o', 2)", "['ogo', 'gl', '']")
- .testEval("'ogooglo'.rsplit('o', 3)", "['og', '', 'gl', '']")
- .testEval("'ogooglo'.rsplit('o', 4)", "['', 'g', '', 'gl', '']")
- .testEval("'ogooglo'.rsplit('o', 5)", "['', 'g', '', 'gl', '']")
- .testEval("'google'.rsplit('google')", "['', '']")
- .testEval("'google'.rsplit('google', 1)", "['', '']")
- .testEval("'google'.rsplit('google', 2)", "['', '']");
- }
-
- @Test
- public void testPyStringPartitionEasy() throws Exception {
- new BothModesTest()
- .testEval("'lawl'.partition('a')", "('l', 'a', 'wl')")
- .testEval("'lawl'.rpartition('a')", "('l', 'a', 'wl')");
- }
-
- @Test
- public void testPyStringPartitionMultipleSep() throws Exception {
- new BothModesTest()
- .testEval("'google'.partition('o')", "('g', 'o', 'ogle')")
- .testEval("'google'.rpartition('o')", "('go', 'o', 'gle')")
- .testEval("'xxx'.partition('x')", "('', 'x', 'xx')")
- .testEval("'xxx'.rpartition('x')", "('xx', 'x', '')");
- }
-
- @Test
- public void testPyStringPartitionEmptyInput() throws Exception {
- new BothModesTest()
- .testEval("''.partition('a')", "('', '', '')")
- .testEval("''.rpartition('a')", "('', '', '')");
- }
-
- @Test
- public void testPyStringPartitionEmptySeparator() throws Exception {
- new BothModesTest()
- .testIfErrorContains("Empty separator", "'google'.partition('')")
- .testIfErrorContains("Empty separator", "'google'.rpartition('')");
- }
-
- @Test
- public void testPyStringPartitionDefaultSep() throws Exception {
- new BothModesTest()
- .testEval("'hi this is a test'.partition()", "('hi', ' ', 'this is a test')")
- .testEval("'hi this is a test'.rpartition()", "('hi this is a', ' ', 'test')")
- .testEval("'google'.partition()", "('google', '', '')")
- .testEval("'google'.rpartition()", "('', '', 'google')");
- }
-
- @Test
- public void testPyStringPartitionNoMatch() throws Exception {
- new BothModesTest()
- .testEval("'google'.partition('x')", "('google', '', '')")
- .testEval("'google'.rpartition('x')", "('', '', 'google')");
- }
-
- @Test
- public void testPyStringPartitionWordBoundaries() throws Exception {
- new BothModesTest()
- .testEval("'goog'.partition('g')", "('', 'g', 'oog')")
- .testEval("'goog'.rpartition('g')", "('goo', 'g', '')")
- .testEval("'plex'.partition('p')", "('', 'p', 'lex')")
- .testEval("'plex'.rpartition('p')", "('', 'p', 'lex')")
- .testEval("'plex'.partition('x')", "('ple', 'x', '')")
- .testEval("'plex'.rpartition('x')", "('ple', 'x', '')");
- }
-
- @Test
- public void testPyStringPartitionLongSep() throws Exception {
- new BothModesTest()
- .testEval("'google'.partition('oog')", "('g', 'oog', 'le')")
- .testEval("'google'.rpartition('oog')", "('g', 'oog', 'le')")
- .testEval(
- "'lolgooglolgooglolgooglol'.partition('goog')", "('lol', 'goog', 'lolgooglolgooglol')")
- .testEval(
- "'lolgooglolgooglolgooglol'.rpartition('goog')",
- "('lolgooglolgooglol', 'goog', 'lol')");
- }
-
- @Test
- public void testPyStringPartitionCompleteString() throws Exception {
- new BothModesTest()
- .testEval("'google'.partition('google')", "('', 'google', '')")
- .testEval("'google'.rpartition('google')", "('', 'google', '')");
- }
-
- @Test
public void testPyStringTitle() throws Exception {
new BothModesTest()
.testStatement("'this is a very simple test'.title()", "This Is A Very Simple Test");