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

CityOfZion / neo3-boa / 0aff654d-b027-49a1-9d97-558d9a2a52ff

05 Mar 2024 04:57PM UTC coverage: 91.985% (-0.1%) from 92.106%
0aff654d-b027-49a1-9d97-558d9a2a52ff

push

circleci

web-flow
Merge pull request #1215 from CityOfZion/CU-86drpndkk

CU-86drpndkk - Refactor test_interop/test_blockchain.py to use BoaTestConstructor

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

658 existing lines in 143 files now uncovered.

20635 of 22433 relevant lines covered (91.99%)

1.84 hits per line

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

94.74
/boa3/internal/model/operation/binary/arithmetic/strbytesmultiplication.py
1
from boa3.internal.model.operation.binary.binaryoperation import BinaryOperation
2✔
2
from boa3.internal.model.operation.operator import Operator
2✔
3
from boa3.internal.model.type.type import IType, Type
2✔
4
from boa3.internal.neo.vm.opcode.Opcode import Opcode
2✔
5

6

7
class StrBytesMultiplication(BinaryOperation):
2✔
8
    """
9
    A class used to represent a string or bytes concatenation operation
10

11
    :ivar operator: the operator of the operation. Inherited from :class:`IOperation`
12
    :ivar left: the left operand type. Inherited from :class:`BinaryOperation`
13
    :ivar right: the left operand type. Inherited from :class:`BinaryOperation`
14
    :ivar result: the result type of the operation.  Inherited from :class:`IOperation`
15
    """
16
    _valid_types: list[IType] = [Type.str, Type.bytes]
2✔
17

18
    def __init__(self, left: IType = Type.str, right: IType = Type.int):
2✔
19
        self.operator: Operator = Operator.Mult
2✔
20
        super().__init__(left, right)
2✔
21

22
    def validate_type(self, *types: IType) -> bool:
2✔
23
        if len(types) != self.number_of_operands:
2✔
UNCOV
24
            return False
×
25
        left: IType = types[0]
2✔
26
        right: IType = types[1]
2✔
27

28
        return any(_type.is_type_of(left) for _type in self._valid_types) and Type.int.is_type_of(right)
2✔
29

30
    def _get_result(self, left: IType, right: IType) -> IType:
2✔
31
        if self.validate_type(left, right):
2✔
32
            return left
2✔
33
        else:
UNCOV
34
            return Type.none
×
35

36
    def generate_internal_opcodes(self, code_generator):
2✔
37
        from boa3.internal.model.operation.binaryop import BinaryOp
2✔
38

39
        # concatString = ''
40
        code_generator.convert_literal('')
2✔
41
        # reorganize stack
42
        code_generator.swap_reverse_stack_items(3, rotate=True)
2✔
43
        code_generator.swap_reverse_stack_items(3, rotate=True)
2✔
44

45
        # while argInt > 0:
46
        concat_start = code_generator.convert_begin_while()
2✔
47

48
        #   concatString += argString
49
        code_generator.swap_reverse_stack_items(3)
2✔
50
        code_generator.duplicate_stack_item(2)
2✔
51
        code_generator.convert_operation(BinaryOp.Concat, is_internal=True)
2✔
52
        #   argInt -= 1
53
        code_generator.swap_reverse_stack_items(3)
2✔
54
        code_generator.insert_opcode(Opcode.DEC)
2✔
55

56
        # while condition
57
        condition_start = code_generator.bytecode_size
2✔
58
        code_generator.duplicate_stack_top_item()
2✔
59
        code_generator.convert_literal(0)
2✔
60
        code_generator.convert_operation(BinaryOp.Gt, is_internal=True)
2✔
61
        code_generator.convert_end_while(concat_start, condition_start, is_internal=True)
2✔
62

63
        # clear stack
64
        code_generator.remove_stack_top_item()
2✔
65
        code_generator.remove_stack_top_item()
2✔
66

67
        code_generator.convert_cast(self.left_type, is_internal=True)
2✔
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