Exemple #1
0
def test_lexer_peek():
    lexer = Lexer("abc:\n  color: #11223311\n", {})
    abc = Token("ident", Ident("abc", null), lineno=1, column=1)
    assert lexer.peek() == abc
    assert lexer.peek() == abc
    assert lexer.next() == abc
    colon = Token(":", ":", "", lineno=1, column=4)
    assert lexer.peek() == Token(":", ":", "", lineno=1, column=4)
    assert lexer.next() == colon
Exemple #2
0
def test_lexer_is_part_of_selector():
    lexer = Lexer("^if.null,[bar],abc  color: black\n", {})
    assert lexer.next() == Token("selector", "^", lineno=1, column=1)
    assert lexer.next() == Token("if", "if", lineno=1, column=2)
    assert lexer.next() == Token(".", ".", "", lineno=1, column=4)
    assert lexer.next() == Token("ident", Ident("null"), lineno=1, column=5)
    lexer = Lexer("^#fif: black\n", {})
    assert lexer.next() == Token("selector", "^", lineno=1, column=1)
    assert lexer.next() == Token(
        "color", RGBA(255, 255, 255, 1), lineno=1, column=2
    )
    assert lexer.next() == Token("ident", Ident("if"), lineno=1, column=4)