Exemplo n.º 1
0
    def test_mult_number_boolean(self):
        expr = TypeOperations.mult(self.number1, self.boolean_true)
        self.assertEqual(3, expr.value)
        self.assertEqual("3 * True", expr.name)

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

        expr2 = TypeOperations.mult(self.boolean_true, self.boolean_false)
        self.assertEqual(0, expr2.value)
        self.assertEqual("True * False", expr2.name)
Exemplo n.º 3
0
    def test_mult_number_string(self):
        with self.assertRaises(OperationNotSupported):
            TypeOperations.mult(self.number1, self.string1)

        with self.assertRaises(OperationNotSupported):
            TypeOperations.mult(self.string2, self.number1)
Exemplo n.º 4
0
    def test_mult_two_numbers(self):
        expr = TypeOperations.mult(self.number1, self.number2)

        self.assertEqual(15, expr.value)
        self.assertEqual("3 * 5", expr.name)
Exemplo n.º 5
0
 def test_mult_first_argument_not_expression(self):
     with self.assertRaises(AttributeError):
         TypeOperations.mult(self.string2, 3)
Exemplo n.º 6
0
    def test_mult_string_boolean(self):
        with self.assertRaises(OperationNotSupported):
            TypeOperations.mult(self.boolean_true, self.string1)

        with self.assertRaises(OperationNotSupported):
            TypeOperations.mult(self.string2, self.boolean_false)
Exemplo n.º 7
0
 def multiplication(self, expr1: BasicExpression, expr2: BasicExpression,
                    line):
     try:
         return TypeOperations.mult(expr1, expr2)
     except ConfprolException as e:
         raise RuntimeException(line, e)