• 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

94.87
/boa3/internal/model/operation/binary/arithmetic/strbytesmultiplication.py
1
from typing import List
3✔
2

3
from boa3.internal.model.operation.binary.binaryoperation import BinaryOperation
3✔
4
from boa3.internal.model.operation.operator import Operator
3✔
5
from boa3.internal.model.type.type import IType, Type
3✔
6
from boa3.internal.neo.vm.opcode.Opcode import Opcode
3✔
7

8

9
class StrBytesMultiplication(BinaryOperation):
3✔
10
    """
11
    A class used to represent a string or bytes concatenation operation
12

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

20
    def __init__(self, left: IType = Type.str, right: IType = Type.int):
3✔
21
        self.operator: Operator = Operator.Mult
3✔
22
        super().__init__(left, right)
3✔
23

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

30
        return any(_type.is_type_of(left) for _type in self._valid_types) and Type.int.is_type_of(right)
3✔
31

32
    def _get_result(self, left: IType, right: IType) -> IType:
3✔
33
        if self.validate_type(left, right):
3✔
34
            return left
3✔
35
        else:
36
            return Type.none
×
37

38
    def generate_internal_opcodes(self, code_generator):
3✔
UNCOV
39
        from boa3.internal.model.operation.binaryop import BinaryOp
2✔
40

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

47
        # while argInt > 0:
UNCOV
48
        concat_start = code_generator.convert_begin_while()
2✔
49

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

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

65
        # clear stack
UNCOV
66
        code_generator.remove_stack_top_item()
2✔
UNCOV
67
        code_generator.remove_stack_top_item()
2✔
68

UNCOV
69
        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