| 1000 | |
| 1001 | |
| 1002 | def test_string_operations(): |
| 1003 | basic_string = LiteralStringVar.create("Hello, World!") |
| 1004 | |
| 1005 | assert str(basic_string.length()) == '"Hello, World!".split("").length' |
| 1006 | assert str(basic_string.lower()) == '"Hello, World!".toLowerCase()' |
| 1007 | assert str(basic_string.lstrip()) == 'pyLstrip("Hello, World!", null)' |
| 1008 | assert str(basic_string.upper()) == '"Hello, World!".toUpperCase()' |
| 1009 | assert str(basic_string.strip()) == 'pyStrip("Hello, World!", null)' |
| 1010 | assert str(basic_string.rstrip()) == 'pyRstrip("Hello, World!", null)' |
| 1011 | assert str(basic_string.lstrip("!H")) == 'pyLstrip("Hello, World!", "!H")' |
| 1012 | assert str(basic_string.strip("!H")) == 'pyStrip("Hello, World!", "!H")' |
| 1013 | assert str(basic_string.rstrip("!H")) == 'pyRstrip("Hello, World!", "!H")' |
| 1014 | chars_var = Var(_js_expr="state.chars").to(str) |
| 1015 | assert str(basic_string.strip(chars_var)) == 'pyStrip("Hello, World!", state.chars)' |
| 1016 | assert str(basic_string.contains("World")) == '"Hello, World!".includes("World")' |
| 1017 | assert ( |
| 1018 | str(basic_string.split(" ").join(",")) == '"Hello, World!".split(" ").join(",")' |
| 1019 | ) |
| 1020 | |
| 1021 | |
| 1022 | def test_all_number_operations(): |