diff --git a/integration_tests/test_builtin_str_02.py b/integration_tests/test_builtin_str_02.py index 0bc9162197..6498a631b7 100644 --- a/integration_tests/test_builtin_str_02.py +++ b/integration_tests/test_builtin_str_02.py @@ -1,3 +1,5 @@ +from ltypes import i32 + def _lpython_strcmp_eq(a: str, b: str) -> bool: if len(a) != len(b): return False @@ -38,6 +40,14 @@ def _lpython_strcmp_gt(a: str, b: str) -> bool: def _lpython_strcmp_gteq(a: str, b: str) -> bool: return _lpython_strcmp_eq(a, b) or _lpython_strcmp_gt(a, b) +def _lpython_str_repeat(a: str, n: i32) -> str: + s: str + s = "" + i: i32 + for i in range(n): + s += a + return s + def f(): assert _lpython_strcmp_eq("a", "a") assert not _lpython_strcmp_eq("a2", "a") @@ -80,4 +90,7 @@ def f(): assert _lpython_strcmp_gteq("bg", "abc") assert _lpython_strcmp_gteq(a, b) + assert _lpython_str_repeat("abc", 3) == "abcabcabc" + assert _lpython_str_repeat("", -1) == "" + f()