def test_var_indexing_str():
    """Test that we can index into str vars."""
    str_var = Var(_js_expr="str").to(str)

    # Test that indexing gives a type of Var[str].
    assert isinstance(str_var[0], Var)
    assert str_var[0]._var_type is str

    # Test basic indexing.
    assert str(str_var[0]) == "str.at(0)"
    assert str(str_var[1]) == "str.at(1)"

    # Test negative indexing.
    assert str(str_var[-1]) == "str.at(-1)"
Test that we can index into str vars.
tests/units/test_var.py