Ejemplo n.º 1
0
    def __eq__(self, other):
        if isinstance(other, QLDate):
            return QLBoolean(self.day == other.day
                             and self.month == other.month
                             and self.year == other.year)

        return QLBoolean(False)
Ejemplo n.º 2
0
    def test_file(self, file):
        ast = self.__parser.parse(file, self.__lexer.lexer)

        if not self.__parser.errors:
            TypeVisitor(extract_identifier_types(ast)).visit(ast)
            model = extract_gui_model(ast)
            result_type, result_value = file.split('\n')[0].split()[-2:]
            correct_result = None

            if result_type == 'QLBoolean' and result_value == 'True':
                correct_result = QLBoolean(True)
            elif result_type == 'QLBoolean':
                correct_result = QLBoolean()
            elif result_type == 'QLDate':
                day, month, year = loads(result_value)
                correct_result = QLDate(day, month, year)
            elif result_type == 'QLDecimal':
                correct_result = QLDecimal(result_value)
            elif result_type == 'QLInteger':
                correct_result = QLInteger(result_value)
            elif result_type == 'QLMoney':
                correct_result = QLMoney(result_value)
            elif result_type == 'QLString':
                correct_result = QLString(result_value)

            expression_evaluator = ExpressionEvaluator(model)
            expression_evaluator.visit(ast.block[0].answer)
            return bool(expression_evaluator.result == correct_result)
Ejemplo n.º 3
0
 def __ne__(self, other):
     return QLBoolean(not self == other)
Ejemplo n.º 4
0
    def __eq__(self, other):
        if isinstance(other, QLInteger):
            return QLBoolean(self.value == other.value)

        return QLBoolean(False)
Ejemplo n.º 5
0
 def __ge__(self, other):
     return QLBoolean(len(self.value) >= len(other.value))
Ejemplo n.º 6
0
 def __lt__(self, other):
     return QLBoolean(len(self.value) < len(other.value))
Ejemplo n.º 7
0
 def __init__(self):
     self.form = None
     self.condition = QLBoolean.get_literal_node(True)
Ejemplo n.º 8
0
 def __ge__(self, other):
     return QLBoolean(self.value >= other.value
                      and self.currency == other.currency)
Ejemplo n.º 9
0
 def __ge__(self, other):
     return QLBoolean(self > other or self == other)
Ejemplo n.º 10
0
 def __le__(self, other):
     return QLBoolean(self < other or self == other)
Ejemplo n.º 11
0
 def __gt__(self, other):
     return QLBoolean(self.year > other.year or
                      (self.month > other.month and self.year == other.year)
                      or (self.day > other.day and self.month == other.month
                          and self.year == other.year))
Ejemplo n.º 12
0
 def __lt__(self, other):
     return QLBoolean(self.year < other.year or
                      (self.month < other.month and self.year == other.year)
                      or (self.day < other.day and self.month == other.month
                          and self.year == other.year))
Ejemplo n.º 13
0
 def evaluate(self):
     self.value = QLBoolean(not self.expression.value)
Ejemplo n.º 14
0
 def __le__(self, other):
     return QLBoolean(self.value <= other.value)
Ejemplo n.º 15
0
 def p_boolean_literal(production):
     """expression   : FALSE
                     | TRUE"""
     production[0] = BooleanNode(Metadata(production.lineno(1)), QLBoolean,
                                 QLBoolean(production[1]))
Ejemplo n.º 16
0
 def __ge__(self, other):
     return QLBoolean(self.value >= other.value)
Ejemplo n.º 17
0
    def __eq__(self, other):
        if isinstance(other, QLMoney):
            return QLBoolean(self.value == other.value
                             and self.currency == other.currency)

        return QLBoolean(False)