• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CityOfZion / neo3-boa / 30ae3248-fada-4b8d-8735-31794b222593

17 Jan 2024 01:43PM UTC coverage: 92.103%. Remained the same
30ae3248-fada-4b8d-8735-31794b222593

push

circleci

web-flow
Merge pull request #1170 from CityOfZion/CU-86a1hepnw

CU-86a1hepnw - Fix tests using Python 3.12 (parsing manifest JSON)

1 of 1 new or added line in 1 file covered. (100.0%)

253 existing lines in 51 files now uncovered.

20773 of 22554 relevant lines covered (92.1%)

2.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.59
/boa3/internal/model/operation/binaryop.py
1
from typing import List, Optional
3✔
2

3
from boa3.internal.model.operation.binary.additional import *
3✔
4
from boa3.internal.model.operation.binary.arithmetic import *
3✔
5
from boa3.internal.model.operation.binary.binaryoperation import BinaryOperation
3✔
6
from boa3.internal.model.operation.binary.logical import *
3✔
7
from boa3.internal.model.operation.binary.relational import *
3✔
8
from boa3.internal.model.operation.operation import IOperation
3✔
9
from boa3.internal.model.operation.operator import Operator
3✔
10
from boa3.internal.model.operation.unary.noneidentity import NoneIdentity
3✔
11
from boa3.internal.model.operation.unary.nonenotidentity import NoneNotIdentity
3✔
12
from boa3.internal.model.type.itype import IType
3✔
13

14

15
class BinaryOp:
3✔
16
    # Arithmetic operations
17
    Add = Addition()
3✔
18
    Sub = Subtraction()
3✔
19
    Mul = Multiplication()
3✔
20
    Div = Division()
3✔
21
    IntDiv = FloorDivision()
3✔
22
    ListAdd = ListAddition()
3✔
23
    Mod = Modulo()
3✔
24
    Pow = Power()
3✔
25
    Concat = Concat()
3✔
26
    StrBytesMul = StrBytesMultiplication()
3✔
27

28
    # Relational operations
29
    NumEq = NumericEquality()
3✔
30
    NumNotEq = NumericInequality()
3✔
31
    Lt = LessThan()
3✔
32
    LtE = LessThanOrEqual()
3✔
33
    Gt = GreaterThan()
3✔
34
    GtE = GreaterThanOrEqual()
3✔
35
    IsNone = NoneIdentity()
3✔
36
    IsNotNone = NoneNotIdentity()
3✔
37
    Is = Identity()
3✔
38
    IsNot = NotIdentity()
3✔
39
    Eq = ObjectEquality()
3✔
40
    NotEq = ObjectInequality()
3✔
41

42
    # Logical operations
43
    And = BooleanAnd()
3✔
44
    Or = BooleanOr()
3✔
45
    ElvisOperatorOr = ElvisOperatorOr()
3✔
46
    BitAnd = LogicAnd()
3✔
47
    BitOr = LogicOr()
3✔
48
    Xor = LogicXor()
3✔
49
    LShift = LeftShift()
3✔
50
    RShift = RightShift()
3✔
51

52
    # Other operations
53
    In = CollectionMembership()
3✔
54
    NotIn = CollectionNotMembership()
3✔
55

56
    @classmethod
3✔
57
    def validate_type(cls, operator: Operator, left: IType, right: IType) -> Optional[BinaryOperation]:
3✔
58
        """
59
        Gets a binary operation given the operator and the operands types.
60

61
        :param operator: binary operator
62
        :param left: type of the left operand
63
        :param right: type of the right operand
64
        :return: The operation if exists. None otherwise;
65
        :rtype: BinaryOperation or None
66
        """
67
        for id, op in vars(cls).items():
3✔
68
            if isinstance(op, IOperation) and op.is_valid(operator, left, right):
3✔
69
                if isinstance(op, BinaryOperation):
3✔
70
                    return op.build(left, right)
3✔
71
                else:
72
                    from boa3.internal.model.type.type import Type
3✔
73
                    operand = right if left is Type.none else left
3✔
74
                    return op.build(operand)
3✔
75

76
    @classmethod
3✔
77
    def get_operation_by_operator(cls, operator: Operator, left_operand: IType,
3✔
78
                                  right_operand: Optional[IType] = None) -> Optional[BinaryOperation]:
79
        """
80
        Gets a binary operation given the operator.
81

82
        :param operator: binary operator
83
        :param left_operand: left operand of the operator
84
        :param right_operand: right operand of the operator
85
        :return: The operation if exists. If exists more than one operation with the same operator, returns the one with
86
        the same left operand. If none has the same left operand, returns the first found. None otherwise;
87
        :rtype: BinaryOperation or None
88
        """
89
        valid_operations: List[BinaryOperation] = []
3✔
90
        for id, op in vars(cls).items():
3✔
91
            if isinstance(op, BinaryOperation) and op.operator is operator:
3✔
92
                left, right = op.get_valid_operand_for_validation(left_operand, right_operand)
3✔
93
                if left is not None:
3✔
94
                    return op.build(left_operand if right_operand is None else left, right)
3✔
95
                else:
UNCOV
96
                    valid_operations.append(op)
2✔
97

UNCOV
98
        return valid_operations[0] if len(valid_operations) > 0 else None
2✔
99

100
    @classmethod
3✔
101
    def get_operation(cls, operation: BinaryOperation) -> Optional[BinaryOperation]:
3✔
102
        """
103
        Gets a binary operation given another operation.
104

105
        :param operation: binary operation
106
        :return: The operation if exists. None otherwise;
107
        :rtype: BinaryOperation or None
108
        """
109
        for id, op in vars(cls).items():
×
110
            if type(operation) == type(op):
×
111
                return op
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc