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

wurstscript / WurstScript / 196

09 Oct 2023 10:49PM UTC coverage: 63.447% (+0.006%) from 63.441%
196

push

circleci

web-flow
small performance fixes (#1079)

17146 of 27024 relevant lines covered (63.45%)

0.63 hits per line

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

69.57
de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/attributes/IntVal.java
1
package de.peeeq.wurstscript.attributes;
2

3
import de.peeeq.wurstscript.ast.ExprIntVal;
4
import de.peeeq.wurstscript.utils.Utils;
5

6
import java.util.regex.Pattern;
7

8
public class IntVal {
×
9

10
    private static final Pattern INT_PATTERN =Pattern.compile("-?(0|[1-9][0-9]*)");
1✔
11
    private static final Pattern OINT_PATTERN =Pattern.compile("-?0[0-9]+");
1✔
12
    private static final Pattern HINT_PATTERN =Pattern.compile("-?0x[0-9a-fA-F]+");
1✔
13
    private static final Pattern HINT_PATTERN2 =Pattern.compile("-?\\$[0-9a-fA-F]+");
1✔
14
    public static int getValI(ExprIntVal i) {
15
        String raw = i.getValIraw();
1✔
16
        try {
17
            if (INT_PATTERN.matcher(raw).matches()) {
1✔
18
                return Utils.parseInt(raw);
1✔
19
            } else if (OINT_PATTERN.matcher(raw).matches()) {
1✔
20
                return Utils.parseOctalInt(raw);
1✔
21
            } else if (HINT_PATTERN.matcher(raw).matches()) {
1✔
22
                return Utils.parseHexInt(raw, 2);
1✔
23
            } else if (HINT_PATTERN2.matcher(raw).matches()) {
1✔
24
                return Utils.parseHexInt(raw, 1);
1✔
25
            } else if (raw.startsWith("'")) {
1✔
26
                try {
27
                    return Utils.parseAsciiInt(raw);
1✔
28
                } catch (NumberFormatException e) {
×
29
                    i.addError(e.getMessage());
×
30
                    return 0;
×
31
                }
32
            }
33
        } catch (NumberFormatException e) {
1✔
34
            // fall through...
35
        }
×
36
        i.addError("Invalid number: " + raw);
×
37
        return 0;
×
38
    }
39

40
}
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