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

leeonky / test-charm-java / 212

14 Apr 2025 05:15AM UTC coverage: 74.088% (-0.1%) from 74.209%
212

push

circleci

leeonky
Update version

7957 of 10740 relevant lines covered (74.09%)

0.74 hits per line

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

93.75
/DAL-java/src/main/java/com/github/leeonky/dal/ast/node/RegexNode.java
1
package com.github.leeonky.dal.ast.node;
2

3
import com.github.leeonky.dal.runtime.AssertionFailure;
4
import com.github.leeonky.dal.runtime.Data;
5
import com.github.leeonky.dal.runtime.ExpectationFactory;
6
import com.github.leeonky.dal.runtime.RuntimeContextBuilder.DALRuntimeContext;
7

8
import java.util.regex.Pattern;
9

10
import static com.github.leeonky.dal.runtime.ExpressionException.illegalOperation;
11
import static com.github.leeonky.dal.runtime.ExpressionException.opt2;
12
import static java.lang.String.format;
13

14
public class RegexNode extends DALNode {
15
    private final Pattern pattern;
16

17
    public RegexNode(String regex) {
1✔
18
        pattern = Pattern.compile(regex, Pattern.DOTALL);
1✔
19
    }
1✔
20

21
    @Override
22
    public String inspect() {
23
        return format("/%s/", pattern.toString());
1✔
24
    }
25

26
    @Override
27
    protected ExpectationFactory toVerify(DALRuntimeContext context) {
28
        return (operator, actual) -> new ExpectationFactory.Expectation() {
1✔
29
            @Override
30
            public Data matches() {
31
                String converted = opt2(() -> (String) actual.convert(String.class).instance());
1✔
32
                if (pattern.matcher(converted).matches())
1✔
33
                    return actual;
1✔
34
                throw new AssertionFailure(format("Expected to match: /%s/\nActual: <%s> converted from: %s", pattern,
1✔
35
                        converted, actual.dump()), getPositionBegin());
1✔
36
            }
37

38
            @Override
39
            public Data equalTo() {
40
                String str = actual.cast(String.class)
1✔
41
                        .orElseThrow(() -> illegalOperation("Operator = before regex need a string input value"));
1✔
42
                if (pattern.matcher(str).matches())
1✔
43
                    return actual;
1✔
44
                throw new AssertionFailure(format("Expected to match: /%s/\nActual: <%s>", pattern, actual.instance()), getPositionBegin());
1✔
45
            }
46

47
            @Override
48
            public ExpectationFactory.Type type() {
49
                return ExpectationFactory.Type.REGEX;
×
50
            }
51
        };
52
    }
53
}
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