示例#1
0
def test_type_alias_with_new_line():
    type_def = """
type alias Index =
    { x : Float
    , y : Float
    , radius : Float
    }

b : String -> String
b input = huh Index
"""
    location = seeker.find_location_in_source(type_def, 8, 14, "Index")
    assert location == (1, 0)
示例#2
0
def test_comment_should_hide_multiple_defs():
    """
    TODO: failing test, the def is both indented and in a comment

    some of elm-lang/core does this to express how things work in their docs
    while i could filter based on how its indented, that doesn't guarantee
    some docs may not do that. if a def is ingored by the compiler in a comment
    it should be ignored in this tool
    """
    location = seeker.find_location_in_source(
        extra_def_in_comment, 10, 27, "splitter"
    )
    assert location == (10, 0)
示例#3
0
def test_type_with_new_line():
    """
    current bug, not sure how to get around it given it searches things
    linewise...
    maybe i need to write a mini-parser to filter things expressionwise?
    """
    type_def = """
type Boolean
    = Literal Bool
    | Not Boolean
    | And Boolean Boolean
    | Or Boolean Boolean

b : String -> String
b input = huh Boolean
"""
    location = seeker.find_location_in_source(type_def, 8, 14, "Boolean")
    assert location == (1, 0)
示例#4
0
def test_find_type():
    location = seeker.find_location_in_source(with_type, 7, 13, "Donkey")
    assert location == (1, 0)
示例#5
0
def test_find_when_def_has_arg():
    location = seeker.find_location_in_source(with_argument, 8, 27, "splitter")
    assert location == (5, 0)
示例#6
0
def test_simple_missing():
    with pytest.raises(seeker.CannotFindIdentifier):
        location = seeker.find_location_in_source(missing, 4, 27, "splitter")
        assert location == (5, 0)
示例#7
0
def test_find_origin():
    location = seeker.find_location_in_source(regular, 8, 27, "splitter")
    assert location == (5, 0)
示例#8
0
def test_too_many_should_fail():
    with pytest.raises(seeker.SearchError):
        location = seeker.find_location_in_source(too_many, 10, 27, "splitter")
        assert location == (5, 0)