diff options
author | 2018-06-28 16:40:58 -0700 | |
---|---|---|
committer | 2018-06-28 16:42:48 -0700 | |
commit | a39e2feec8b8cb431f5457453e40a56633a9caed (patch) | |
tree | b53372473768c98196c656360eb01c70b9c37bfb /src/test/skylark | |
parent | c90764ddf8abf78dc43c65d2043e01a76e4e98e5 (diff) |
[Skylark] Allow tuples as first argument of str.{starts,ends}with
Closes #5307
Closes #5455.
PiperOrigin-RevId: 202567483
Diffstat (limited to 'src/test/skylark')
-rw-r--r-- | src/test/skylark/testdata/string_misc.sky | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/test/skylark/testdata/string_misc.sky b/src/test/skylark/testdata/string_misc.sky index 901d7f3091..87708f9fae 100644 --- a/src/test/skylark/testdata/string_misc.sky +++ b/src/test/skylark/testdata/string_misc.sky @@ -62,6 +62,26 @@ assert_eq('Apricot'.endswith('co', -1), False) assert_eq('abcd'.endswith('c', -2, -1), True) assert_eq('abcd'.endswith('c', 1, 8), False) assert_eq('abcd'.endswith('d', 1, 8), True) +assert_eq('Apricot'.endswith(('cot', 'toc')), True) +assert_eq('Apricot'.endswith(('toc', 'cot')), True) +assert_eq('a'.endswith(('', '')), True) +assert_eq('a'.endswith(('', 'a')), True) +assert_eq('a'.endswith(('a', 'a')), True) +assert_eq(''.endswith(('a', '')), True) +assert_eq(''.endswith(('', '')), True) +assert_eq(''.endswith(('a', 'a')), False) +assert_eq('a'.endswith(('a')), True) +assert_eq('a'.endswith(('a',)), True) +assert_eq('a'.endswith(('b',)), False) +assert_eq('a'.endswith(()), False) +assert_eq(''.endswith(()), False) +--- +'a'.endswith(['a']) ### expected value of type 'string or tuple of strings' for parameter 'sub', in method call endswith(list) of 'string' +--- +'1'.endswith((1,)) ### expected type 'string' for 'string' element but got type 'int' instead +--- +'a'.endswith(('1', 1)) ### expected type 'string' for 'string' element but got type 'int' instead +--- # startswith assert_eq('Apricot'.startswith('Apr'), True) @@ -70,6 +90,26 @@ assert_eq('Apricot'.startswith(''), True) assert_eq('Apricot'.startswith('z'), False) assert_eq(''.startswith(''), True) assert_eq(''.startswith('a'), False) +assert_eq('Apricot'.startswith(('Apr', 'rpA')), True) +assert_eq('Apricot'.startswith(('rpA', 'Apr')), True) +assert_eq('a'.startswith(('', '')), True) +assert_eq('a'.startswith(('', 'a')), True) +assert_eq('a'.startswith(('a', 'a')), True) +assert_eq(''.startswith(('a', '')), True) +assert_eq(''.startswith(('', '')), True) +assert_eq(''.startswith(('a', 'a')), False) +assert_eq('a'.startswith(('a')), True) +assert_eq('a'.startswith(('a',)), True) +assert_eq('a'.startswith(('b',)), False) +assert_eq('a'.startswith(()), False) +assert_eq(''.startswith(()), False) +--- +'a'.startswith(['a']) ### expected value of type 'string or tuple of strings' for parameter 'sub', in method call startswith(list) of 'string' +--- +'1'.startswith((1,)) ### expected type 'string' for 'string' element but got type 'int' instead +--- +'a'.startswith(('1', 1)) ### expected type 'string' for 'string' element but got type 'int' instead +--- # substring assert_eq('012345678'[0:-1], "01234567") |