@@ -22,11 +22,16 @@ def match(x: str, y: str) -> Tuple[bool, bool]:
2222 return (x.startswith(y), x.endswith(y))
2323def match_tuple(x: str, y: Tuple[str, ...]) -> Tuple[bool, bool]:
2424 return (x.startswith(y), x.endswith(y))
25+ def match_tuple_literal_args(x: str, y: str, z: str) -> Tuple[bool, bool]:
26+ return (x.startswith((y, z)), x.endswith((y, z)))
2527def remove_prefix_suffix(x: str, y: str) -> Tuple[str, str]:
2628 return (x.removeprefix(y), x.removesuffix(y))
2729
2830[file driver.py]
29- from native import f, g, tostr, booltostr, concat, eq, match, match_tuple, remove_prefix_suffix
31+ from native import (
32+ f, g, tostr, booltostr, concat, eq, match, match_tuple,
33+ match_tuple_literal_args, remove_prefix_suffix
34+ )
3035import sys
3136from testutil import assertRaises
3237
@@ -58,6 +63,8 @@ with assertRaises(TypeError, "tuple for startswith must only contain str"):
5863 assert match_tuple('abc', (None,))
5964with assertRaises(TypeError, "tuple for endswith must only contain str"):
6065 assert match_tuple('abc', ('a', None))
66+ assert match_tuple_literal_args('abc', 'z', 'a') == (True, False)
67+ assert match_tuple_literal_args('abc', 'z', 'c') == (False, True)
6168
6269assert remove_prefix_suffix('', '') == ('', '')
6370assert remove_prefix_suffix('abc', 'a') == ('bc', 'abc')
0 commit comments