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

rokucommunity / brs / #305

18 Jan 2024 09:05PM UTC coverage: 91.463% (+5.2%) from 86.214%
#305

push

TwitchBronBron
0.45.4

1796 of 2095 branches covered (85.73%)

Branch coverage included in aggregate %.

5275 of 5636 relevant lines covered (93.59%)

8947.19 hits per line

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

95.45
/src/brsTypes/components/RoInt.ts
1
import { BrsComponent } from "./BrsComponent";
139✔
2
import { BrsValue, ValueKind, BrsString, BrsBoolean, BrsInvalid, Comparable } from "../BrsType";
139✔
3
import { Callable, StdlibArgument } from "../Callable";
139✔
4
import { Interpreter } from "../../interpreter";
5
import { BrsType } from "..";
6
import { Unboxable } from "../Boxing";
7
import { Int32 } from "../Int32";
8

9
export class roInt extends BrsComponent implements BrsValue, Unboxable {
139✔
10
    readonly kind = ValueKind.Object;
46✔
11
    private intrinsic: Int32;
12

13
    public getValue(): Int32 {
14
        return this.intrinsic;
4✔
15
    }
16

17
    constructor(initialValue: Int32) {
18
        super("roInt");
46✔
19

20
        this.intrinsic = initialValue;
46✔
21
        this.registerMethods({
46✔
22
            ifInt: [this.getInt, this.setInt],
23
            // Per https://developer.roku.com/docs/references/brightscript/interfaces/ifintops.md,
24
            // ifIntOps _also_ implements toStr()
25
            ifIntOps: [this.toStr],
26
            ifToStr: [this.toStr],
27
        });
28
    }
29

30
    unbox() {
31
        return this.intrinsic;
6✔
32
    }
33

34
    equalTo(other: BrsType): BrsBoolean {
35
        if (other instanceof roInt) {
7✔
36
            return BrsBoolean.from(other.intrinsic.getValue() === this.intrinsic.getValue());
7✔
37
        }
38

39
        return BrsBoolean.False;
×
40
    }
41

42
    toString(_parent?: BrsType): string {
43
        return this.intrinsic.toString();
2✔
44
    }
45

46
    // ---------- ifInt ----------
47

48
    private getInt = new Callable("getInt", {
46✔
49
        signature: {
50
            args: [],
51
            returns: ValueKind.Double,
52
        },
53
        impl: (interpreter: Interpreter) => {
54
            return this.intrinsic;
4✔
55
        },
56
    });
57

58
    private setInt = new Callable("setInt", {
46✔
59
        signature: {
60
            args: [new StdlibArgument("value", ValueKind.Int32)],
61
            returns: ValueKind.Void,
62
        },
63
        impl: (_interpreter, value: Int32) => {
64
            this.intrinsic = value;
2✔
65
            return BrsInvalid.Instance;
2✔
66
        },
67
    });
68

69
    // ---------- ifIntOps, ifToStr ----------
70

71
    private toStr = new Callable("toStr", {
46✔
72
        signature: {
73
            args: [],
74
            returns: ValueKind.String,
75
        },
76
        impl: (interpreter: Interpreter) => {
77
            return new BrsString(this.intrinsic.toString());
20✔
78
        },
79
    });
80
}
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