Exemplo n.º 1
0
    def test_minus_two_booleans(self):
        expr = TypeOperations.minus(self.boolean_true, self.boolean_true)
        self.assertEqual(0, expr.value)
        self.assertEqual("True - True", expr.name)

        expr2 = TypeOperations.minus(self.boolean_false, self.boolean_true)
        self.assertEqual(-1, expr2.value)
        self.assertEqual("False - True", expr2.name)
Exemplo n.º 2
0
    def test_minus_number_boolean(self):
        expr = TypeOperations.minus(self.number1, self.boolean_true)
        self.assertEqual(2, expr.value)
        self.assertEqual("3 - True", expr.name)

        expr2 = TypeOperations.minus(self.boolean_false, self.number1)
        self.assertEqual(-3, expr2.value)
        self.assertEqual("False - 3", expr2.name)
Exemplo n.º 3
0
 def test_minus_first_argument_not_expression(self):
     with self.assertRaises(AttributeError):
         TypeOperations.minus(self.string2, 3)
Exemplo n.º 4
0
 def test_minus_two_string(self):
     with self.assertRaises(OperationNotSupported):
         TypeOperations.minus(self.string2, self.string1)
Exemplo n.º 5
0
    def test_minus_two_numbers(self):
        expr = TypeOperations.minus(self.number1, self.number2)

        self.assertEqual(-2, expr.value)
        self.assertEqual("3 - 5", expr.name)
Exemplo n.º 6
0
 def minus(self, expr1: BasicExpression, expr2: BasicExpression, line):
     try:
         return TypeOperations.minus(expr1, expr2)
     except ConfprolException as e:
         raise RuntimeException(line, e)