build/tests/test_expressionparser.txt
author Marco Bonardo <mbonardo@mozilla.com>
Tue, 07 Feb 2012 15:59:09 +0100
changeset 88398 96584d3595fa876146da89d8fbe7eabc33d18fdf
parent 72474 4edf5956780be0ab7bc2268adea9c87034c265e7
permissions -rw-r--r--
Bug 723044 - Don't trigger moz_hosts frecency update when updating frecency on idle. r=dietrich a=akeybl

Test Expressionparser
=====================

Test the conditional expression parser.

Boilerplate::

    >>> from manifestparser import parse

Test basic values::

    >>> parse("1")
    1
    >>> parse("100")
    100
    >>> parse("true")
    True
    >>> parse("false")
    False
    >>> '' == parse('""')
    True
    >>> parse('"foo bar"')
    'foo bar'
    >>> parse("'foo bar'")
    'foo bar'
    >>> parse("foo", foo=1)
    1
    >>> parse("bar", bar=True)
    True
    >>> parse("abc123", abc123="xyz")
    'xyz'

Test equality::

    >>> parse("true == true")
    True
    >>> parse("false == false")
    True
    >>> parse("false == false")
    True
    >>> parse("1 == 1")
    True
    >>> parse("100 == 100")
    True
    >>> parse('"some text" == "some text"')
    True
    >>> parse("true != false")
    True
    >>> parse("1 != 2")
    True
    >>> parse('"text" != "other text"')
    True
    >>> parse("foo == true", foo=True)
    True
    >>> parse("foo == 1", foo=1)
    True
    >>> parse('foo == "bar"', foo='bar')
    True
    >>> parse("foo == bar", foo=True, bar=True)
    True
    >>> parse("true == foo", foo=True)
    True
    >>> parse("foo != true", foo=False)
    True
    >>> parse("foo != 2", foo=1)
    True
    >>> parse('foo != "bar"', foo='abc')
    True
    >>> parse("foo != bar", foo=True, bar=False)
    True
    >>> parse("true != foo", foo=False)
    True
    >>> parse("!false")
    True

Test conjunctions::
    
    >>> parse("true && true")
    True
    >>> parse("true || false")
    True
    >>> parse("false || false")
    False
    >>> parse("true && false")
    False
    >>> parse("true || false && false")
    True

Test parentheses::
    
    >>> parse("(true)")
    True
    >>> parse("(10)")
    10
    >>> parse('("foo")')
    'foo'
    >>> parse("(foo)", foo=1)
    1
    >>> parse("(true == true)")
    True
    >>> parse("(true != false)")
    True
    >>> parse("(true && true)")
    True
    >>> parse("(true || false)")
    True
    >>> parse("(true && true || false)")
    True
    >>> parse("(true || false) && false")
    False
    >>> parse("(true || false) && true")
    True
    >>> parse("true && (true || false)")
    True
    >>> parse("true && (true || false)")
    True
    >>> parse("(true && false) || (true && (true || false))")
    True