コード例 #1
0
def test_functions_cannot_be_redeclared():
    with pytest.raises(TypeErrors):
        parse(
            """
              fn getUserIds() [Int]
              fn getUserIds() [Int]
            """
        )
コード例 #2
0
def test_unknown_types_are_rejected():
    with pytest.raises(TypeErrors):
        parse(
            """
              record A {
                a Idontexist
              }
            """
        )
コード例 #3
0
def test_dict_keys_must_be_strings():
    with pytest.raises(TypeErrors):
        parse(
            """
              record A {
                d {Int: Float}
              }
            """
        )
コード例 #4
0
def test_types_cannot_be_redeclared():
    with pytest.raises(TypeErrors):
        parse(
            """
              record A {
                a Idontexist
              }

              enum A { }
            """
        )
コード例 #5
0
def test_type_errors_are_accumulated():
    with pytest.raises(TypeErrors) as e:
        parse(
            """
              union Resource { A, B }

              record Resource {
              }
            """
        )

    assert len(e.value.errors) == 3
コード例 #6
0
ファイル: common.py プロジェクト: Bogdanp/cedar
def table(tests, typecheck=False):
    for string, expected_result in tests:
        if isinstance(string, list):
            return table([(s, expected_result) for s in string])

        if not isinstance(expected_result, ast.Module):
            expected_result = Module([expected_result])

        assert parse(string, typecheck=False) == expected_result
コード例 #7
0
def test_unexpected_tokens_raise_errors():
    with pytest.raises(ParseError) as e:
        parse("record A! {}")

    assert e.value.message == "unexpected '!'"
コード例 #8
0
def test_tabs_are_not_allowed():
    with pytest.raises(ParseError) as e:
        parse("record A {\n\ta Int\n}")

    assert e.value.message == r"unexpected '\t'"
コード例 #9
0
ファイル: test_parser.py プロジェクト: Bogdanp/cedar
def test_unions_cannot_be_empty():
    with pytest.raises(ParseError):
        parse("union A {}")
コード例 #10
0
ファイル: test_parser.py プロジェクト: Bogdanp/cedar
def test_enums_cannnot_have_many_dangling_commas():
    with pytest.raises(ParseError) as e:
        parse("enum A {B, C,,}")

    assert e.value.line == 1
    assert e.value.column == 13
コード例 #11
0
ファイル: test_parser.py プロジェクト: Bogdanp/cedar
def test_only_toplevel_declarations_are_allowed_in_a_module():
    with pytest.raises(ParseError) as e:
        parse("User")

    assert e.value.line == 1
    assert e.value.column == 4
コード例 #12
0
def test_unions_cannot_be_empty():
    with pytest.raises(ParseError):
        parse("union A {}")
コード例 #13
0
ファイル: test_parser.py プロジェクト: Bogdanp/cedar
def test_parse_errors_can_halt_execution():
    with pytest.raises(ParseError) as e:
        parse("record!")

    with pytest.raises(SystemExit):
        e.value.print_and_halt()
コード例 #14
0
def test_type_errors_can_halt_execution():
    with pytest.raises(TypeErrors) as e:
        parse("union A { B, C }")

    with pytest.raises(SystemExit):
        e.value.print_and_halt()
コード例 #15
0
def test_only_toplevel_declarations_are_allowed_in_a_module():
    with pytest.raises(ParseError) as e:
        parse("User")

    assert e.value.line == 1
    assert e.value.column == 4
コード例 #16
0
def test_enums_cannnot_have_many_dangling_commas():
    with pytest.raises(ParseError) as e:
        parse("enum A {B, C,,}")

    assert e.value.line == 1
    assert e.value.column == 13
コード例 #17
0
ファイル: test_parser.py プロジェクト: Bogdanp/cedar
def test_tabs_are_not_allowed():
    with pytest.raises(ParseError) as e:
        parse("record A {\n\ta Int\n}")

    assert e.value.message == r"unexpected '\t'"
コード例 #18
0
def test_parse_errors_can_halt_execution():
    with pytest.raises(ParseError) as e:
        parse("record!")

    with pytest.raises(SystemExit):
        e.value.print_and_halt()
コード例 #19
0
ファイル: test_parser.py プロジェクト: Bogdanp/cedar
def test_unexpected_tokens_raise_errors():
    with pytest.raises(ParseError) as e:
        parse("record A! {}")

    assert e.value.message == "unexpected '!'"