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

wurstscript / WurstScript / 203

18 Oct 2023 02:20PM UTC coverage: 63.758% (+0.3%) from 63.447%
203

push

circleci

web-flow
Update deps, improve performance, JHCR fixes (#1080)

- update dependencies
- update stdlib verison for unit tests
- only apply nullsetting when `-opt` is enabled to save some build time for testing
- minor performance improvements
- make build deterministic
- apply build map config before compilation
- hot code reload now more reliable

17246 of 27049 relevant lines covered (63.76%)

0.64 hits per line

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

57.63
de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/intermediatelang/ILconstInt.java
1
package de.peeeq.wurstscript.intermediatelang;
2

3
import de.peeeq.wurstscript.types.WurstType;
4
import de.peeeq.wurstscript.types.WurstTypeInt;
5

6
import java.util.Objects;
7

8
public class ILconstInt extends ILconstAbstract implements ILconstNum {
9

10
    private int val;
11

12
    public ILconstInt(int intVal) {
1✔
13
        this.val = intVal;
1✔
14
    }
1✔
15

16

17
    @Override
18
    public String print() {
19
        return val + "";
1✔
20
    }
21

22
    public WurstType getType() {
23
        return WurstTypeInt.instance();
×
24
    }
25

26
    @Override
27
    public ILconstNum negate() {
28
        return create(-val);
1✔
29
    }
30

31
    public static ILconstInt create(int i) {
32
        return new ILconstInt(i);
1✔
33
    }
34

35

36
    @Override
37
    public ILconstNum add(ILconstAddable other) {
38
        if (other instanceof ILconstInt) {
1✔
39
            return create(val + ((ILconstInt) other).getVal());
1✔
40
        } else if (other instanceof ILconstReal) {
×
41
            return ILconstReal.create(val + ((ILconstReal) other).getVal());
×
42
        } else {
43
            throw new Error();
×
44
        }
45
    }
46

47
    @Override
48
    public ILconstNum sub(ILconstNum other) {
49
        if (other instanceof ILconstInt) {
1✔
50
            return create(val - ((ILconstInt) other).getVal());
1✔
51
        } else if (other instanceof ILconstReal) {
×
52
            return ILconstReal.create(val - ((ILconstReal) other).getVal());
×
53
        } else {
54
            throw new Error();
×
55
        }
56
    }
57

58
    @Override
59
    public ILconstNum mul(ILconstNum other) {
60
        if (other instanceof ILconstInt) {
1✔
61
            return create(val * ((ILconstInt) other).getVal());
1✔
62
        } else if (other instanceof ILconstReal) {
1✔
63
            return ILconstReal.create(val * ((ILconstReal) other).getVal());
1✔
64
        } else {
65
            throw new Error();
×
66
        }
67
    }
68

69
    @Override
70
    public ILconstNum div(ILconstNum other) {
71
        if (other instanceof ILconstInt) {
1✔
72
            return create(val / ((ILconstInt) other).getVal());
1✔
73
        } else if (other instanceof ILconstReal) {
1✔
74
            return ILconstReal.create(val / ((ILconstReal) other).getVal());
1✔
75
        } else {
76
            throw new Error();
×
77
        }
78
    }
79

80

81
    public int getVal() {
82
        return val;
1✔
83
    }
84

85

86
    @Override
87
    public ILconstBool less(ILconstNum other) {
88
        if (other instanceof ILconstInt) {
1✔
89
            return ILconstBool.instance(val < ((ILconstInt) other).getVal());
1✔
90
        } else if (other instanceof ILconstReal) {
×
91
            return ILconstBool.instance(val < ((ILconstReal) other).getVal());
×
92
        } else {
93
            throw new Error();
×
94
        }
95
    }
96

97

98
    @Override
99
    public ILconstBool lessEq(ILconstNum other) {
100
        if (other instanceof ILconstInt) {
1✔
101
            return ILconstBool.instance(val <= ((ILconstInt) other).getVal());
1✔
102
        } else if (other instanceof ILconstReal) {
×
103
            return ILconstBool.instance(val <= ((ILconstReal) other).getVal());
×
104
        } else {
105
            throw new Error();
×
106
        }
107
    }
108

109

110
    @Override
111
    public ILconstBool greater(ILconstNum other) {
112
        if (other instanceof ILconstInt) {
1✔
113
            return ILconstBool.instance(val > ((ILconstInt) other).getVal());
1✔
114
        } else if (other instanceof ILconstReal) {
×
115
            return ILconstBool.instance(val > ((ILconstReal) other).getVal());
×
116
        } else {
117
            throw new Error();
×
118
        }
119
    }
120

121

122
    @Override
123
    public ILconstBool greaterEq(ILconstNum other) {
124
        if (other instanceof ILconstInt) {
1✔
125
            return ILconstBool.instance(val >= ((ILconstInt) other).getVal());
1✔
126
        } else if (other instanceof ILconstReal) {
×
127
            return ILconstBool.instance(val >= ((ILconstReal) other).getVal());
×
128
        } else {
129
            throw new Error();
×
130
        }
131
    }
132

133

134
    @Override
135
    public boolean isEqualTo(ILconst other) {
136
        if (other instanceof ILconstInt) {
1✔
137
            return (val == ((ILconstInt) other).getVal());
1✔
138
        } else if (other instanceof ILconstReal) {
×
139
            return (val == ((ILconstReal) other).getVal());
×
140
        } else {
141
            return false;
×
142
        }
143
    }
144

145
    @Override
146
    public boolean equals(Object o) {
147
        if (this == o) return true;
1✔
148
        if (o == null || getClass() != o.getClass()) return false;
1✔
149
        if (!super.equals(o)) return false;
1✔
150
        ILconstInt that = (ILconstInt) o;
1✔
151
        return val == that.val;
1✔
152
    }
153

154
    @Override
155
    public int hashCode() {
156
        return Objects.hash(val);
×
157
    }
158
}
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

© 2025 Coveralls, Inc