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

leeonky / test-charm-java / 156

20 Mar 2025 01:53PM UTC coverage: 74.243% (-0.2%) from 74.475%
156

push

circleci

leeonky
Refactor

14 of 15 new or added lines in 12 files covered. (93.33%)

126 existing lines in 29 files now uncovered.

7947 of 10704 relevant lines covered (74.24%)

0.74 hits per line

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

68.97
/DAL-java/src/main/java/com/github/leeonky/dal/runtime/MetaData.java
1
package com.github.leeonky.dal.runtime;
2

3
import com.github.leeonky.dal.ast.node.DALNode;
4
import com.github.leeonky.dal.runtime.RuntimeContextBuilder.DALRuntimeContext;
5

6
import java.util.ArrayList;
7
import java.util.List;
8
import java.util.Objects;
9

10
import static com.github.leeonky.dal.runtime.Data.ResolvedMethods.instanceOf;
11
import static com.github.leeonky.dal.runtime.ExpressionException.illegalOp2;
12
import static java.lang.String.format;
13

14
public class MetaData extends RuntimeData {
15
    private DALNode inputNode;
16
    private final Object name;
17

18
    public MetaData(DALNode inputNode, Data inputData, Object symbolName, DALRuntimeContext runtimeContext) {
19
        super(inputData, runtimeContext);
1✔
20
        this.inputNode = inputNode;
1✔
21
        name = symbolName;
1✔
22
    }
1✔
23

24
    private MetaData(DALRuntimeContext runtimeContext, Data data, String name) {
25
        super(data, runtimeContext);
1✔
26
        this.name = name;
1✔
27
    }
1✔
28

29
    private final List<Class<?>> callTypes = new ArrayList<>();
1✔
30

31
    public Object callSuper() {
32
        return runtimeContext().fetchSuperMetaFunction(this).orElseThrow(() -> illegalOp2(format(
1✔
33
                        "Local meta property `%s` has no super in type %s", name, callTypes.get(callTypes.size() - 1).getName())))
1✔
34
                .apply(this);
1✔
35
    }
36

37
//    public Object callSuper(Supplier<Object> supplier) {
38
//        setData(() -> {
39
//            Object newData = supplier.get();
40
//            checkType(newData);
41
//            return runtimeContext.wrap(newData);
42
//        });
43
//        return callSuper();
44
//    }
45

46
    public Object callGlobal() {
47
        return runtimeContext().fetchGlobalMetaFunction(this).apply(this);
1✔
48
    }
49

50
//    TODO
51
//    public Object callGlobal(Supplier<Object> supplier) {
52
//        setData(() -> runtimeContext.wrap(supplier.get()));
53
//        return callGlobal();
54
//    }
55

56
    private MetaData newMeta(String name) {
57
        return new MetaData(runtimeContext, data, name);
1✔
58
    }
59

60
    public Object callMeta(String another) {
61
        MetaData metaData = newMeta(another);
1✔
62
        return runtimeContext().fetchGlobalMetaFunction(metaData).apply(metaData);
1✔
63
    }
64

65
//    TODO
66
//    public Object callMeta(String another, Supplier<Object> supplier) {
67
//        MetaData metaData = newMeta(another);
68
//        metaData.setData(() -> runtimeContext.wrap(supplier.get()));
69
//        return runtimeContext().fetchGlobalMetaFunction(metaData).apply(metaData);
70
//    }
71

72
    private void checkType(Object data) {
UNCOV
73
        Class<?> expect = this.data.instance().getClass();
×
UNCOV
74
        Class<?> actual = Objects.requireNonNull(data).getClass();
×
UNCOV
75
        if (actual.isAnonymousClass())
×
UNCOV
76
            actual = actual.getSuperclass();
×
UNCOV
77
        if (!actual.equals(expect))
×
UNCOV
78
            throw illegalOp2(format("Do not allow change data type in callSuper, expect %s but %s",
×
UNCOV
79
                    expect.getName(), actual.getName()));
×
UNCOV
80
    }
×
81

82
    public void addCallType(Class<?> callType) {
83
        callTypes.add(callType);
1✔
84
    }
1✔
85

86
    public boolean calledBy(Class<?> type) {
87
        return callTypes.contains(type);
1✔
88
    }
89

90
    public boolean isInstance(Class<?> type) {
91
        return data.probeIf(instanceOf(type));
1✔
92
    }
93

94
    public Object name() {
95
        return name;
1✔
96
    }
97

98
    public DALNode inputNode() {
UNCOV
99
        return inputNode;
×
100
    }
101
}
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