예제 #1
0
def test_from_expression():
    expression = Expression()
    expression.append(Unit(10, "mm"))
    expression.append(true)
    expression.lineno = 42
    expression.column = 13
    expression.is_list = True
    arguments = Arguments.from_expression(expression)
    assert arguments.nodes == expression.nodes
    assert arguments.lineno == expression.lineno
    assert arguments.column == expression.column
    assert arguments.is_list == expression.is_list
예제 #2
0
def test_expression_string_first_boolean():
    from stilus.nodes.boolean import true
    from stilus.nodes.boolean import false
    from stilus.nodes.null import null

    expression = Expression()
    expression.append(true)
    expression.append(false)
    expression.append(null)
    assert str(expression) == "(true false null)"
    expression.is_list = True
    assert str(expression) == "(true, false, null)"
    assert expression.first() is true
    assert expression.to_boolean().value is True
예제 #3
0
def test_property_expression():
    from stilus.nodes.boolean import true
    from stilus.nodes.boolean import false
    from stilus.nodes.null import null

    expression = Expression()
    expression.append(true)
    expression.append(false)
    expression.append(null)
    property = Property(["foo", "bar"], expression)
    assert property.node_name == "property"
    assert len(property.segments) == 2
    assert property.expr is expression
    assert f"{property}" == "property(foobar, (true false null))"
    expression.is_list = True
    assert f"{property}" == "property(foobar, (true, false, null))"
예제 #4
0
def test_expression_make_is_list_and_preserve():
    expression = Expression()
    expression.is_list = True
    expression.preserve = True
    assert expression.is_list
    assert expression.preserve