Esempio n. 1
0
def test_if_else_node():
    s = "if x\n Do\n  Not Fail\nelse\n A\n  B C"
    toks = StylusParser().parse(s)
    assert isinstance(toks[0], AST.ConditionalNode)

    s = "if x\n Do\n  Not Fail\n\nelse\n   A\n    B C"
    toks = StylusParser().parse(s)
    assert isinstance(toks[0], AST.ConditionalNode)
Esempio n. 2
0
def test_selector_list():
    s = "div,body\n background blue"
    res = StylusParser().parse(s)

    s = "div\nbody\n background blue"
    res = StylusParser().parse(s)
    assert isinstance(res[0], AST.StyleNode)
    assert str(res[0]) == "div, body{background:blue}"
Esempio n. 3
0
def test_if_node():
    s = "if x\n Do\n  Not Fail"
    toks = StylusParser().parse(s)
    assert isinstance(toks[0], AST.ConditionalNode)

    s = "if (x)\n Do\n  Not Fail"
    toks = StylusParser().parse(s)
    assert isinstance(toks[0], AST.ConditionalNode)
Esempio n. 4
0
def test_function_definition():
    s = "foo(a, b,c)\n return a"
    styl = StylusParser()
    styl.parse(s)
    func = styl.stack[0]
    assert type(func) == AST.FunctionNode
    assert func.name == 'foo'
    assert func.args == ['a', 'b', 'c']
Esempio n. 5
0
def test_if_elif_node():
    s = "if x\n Do\n  Not Fail\nelif y\n A\n  B C"
    toks = StylusParser().parse(s)
    assert isinstance(toks[0], AST.ConditionalNode)

    s = "if x\n Do\n  Not Fail\n\nelif (y)\n   A\n    B C"
    toks = StylusParser().parse(s)
    assert isinstance(toks[0], AST.ConditionalNode)

    s = "if x\n Do\n  Not Fail\n\nelif (y)\n   A\n    B C\nelif a\n A\n  B C"
    toks = StylusParser().parse(s)
    assert isinstance(toks[0], AST.ConditionalNode)
    assert len(toks[0].else_ifs) == 2
Esempio n. 6
0
def test_multi_style():
    s = """
div
  color red


body
  margin 0 0 30px 30px
"""
    res = StylusParser().parse(s)
Esempio n. 7
0
def test_constructor():
    styl = StylusParser()
    assert isinstance(styl, StylusParser)
Esempio n. 8
0
def xtest_function_block():
    s = """add(x, y)
    x + y
"""
    styl = StylusParser()
    styl.parse(s)
Esempio n. 9
0
def test_empty_function():
    with pytest.raises(StylusParserError):
        StylusParser().parse("A(a)\n")
Esempio n. 10
0
def test_bad_function_definition():
    with pytest.raises(StylusParserError):
        StylusParser().parse("A (a, b,c)\n return")
Esempio n. 11
0
def test_funcdef_no_args():
    s = 'foo()\n return'
    StylusParser().parse(s)
Esempio n. 12
0
def test_block():
    s = "body\ndiv\n color red"
    styl = StylusParser()
    styl.parse(s)
Esempio n. 13
0
def test_simple_style():
    s = """
div
  color red
"""
    res = StylusParser().parse(s)
Esempio n. 14
0
def test_universal_selector():
    s = "*\n color red"
    res = StylusParser().parse(s)
    assert isinstance(res[0], AST.StyleNode)
    assert res[0].selectors[0] == '*'