MCPcopy
hub / github.com/reflex-dev/reflex / test_string_operations

Function test_string_operations

tests/units/test_var.py:1002–1019  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1000
1001
1002def 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
1022def test_all_number_operations():

Callers

nothing calls this directly

Calls 12

VarClass · 0.90
lowerMethod · 0.80
lstripMethod · 0.80
stripMethod · 0.80
rstripMethod · 0.80
toMethod · 0.80
splitMethod · 0.80
createMethod · 0.45
lengthMethod · 0.45
upperMethod · 0.45
containsMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected