Ejemplo n.º 1
0
def test_rest_error():
    with pytest.raises(p.ParseError) as e:
        get_default_export(data_dir / "errors/rest.dn.js")
    assert str(e.value).splitlines()[1:] == dedent("""
        must be of type: {
            ...foo,
        _______^
    """).strip().splitlines()
Ejemplo n.º 2
0
def test_scope_error():
    with pytest.raises(p.ParseError) as e:
        get_default_export(data_dir / "errors/scope.dn.js")
    assert str(e.value).splitlines()[1:] == dedent("""
        variable bar is not in scope
        export default bar
        _______________^
    """).strip().splitlines()
Ejemplo n.º 3
0
def test_parser_add_assignments_reference_and_rest():
    actual = get_default_export(data_dir / "rest.dn.js")
    expected = {
        "key": ["item0", "item1", 3.14, 42, 43, True, {
            "bar": [42, 43]
        }],
        "bar": [42, 43],
    }
    assert actual == expected
Ejemplo n.º 4
0
def test_imported_functions():
    actual = get_default_export(data_dir / "functionCall.dn.js")
    expected = {"hello": 42}
    assert actual == expected
Ejemplo n.º 5
0
def test_imports():
    actual = get_default_export(data_dir / "thisImports.dn.js")
    expected = {"foo": ["DEFAULT", [{"A": 1}], "B"]}
    assert actual == expected