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

discoveryjs / jora / 5920619516

21 Aug 2023 12:47AM UTC coverage: 96.344% (+0.01%) from 96.333%
5920619516

push

github

lahmatiy
Modify the ternary operator to allow optional components

1075 of 1119 branches covered (96.07%)

Branch coverage included in aggregate %.

17 of 17 new or added lines in 1 file covered. (100.0%)

29 existing lines in 2 files now uncovered.

3352 of 3476 relevant lines covered (96.43%)

1492.51 hits per line

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

83.56
/src/lang/nodes/Assertion.js
1
export function suggest(node, ctx) {
1✔
2
    if (!Array.isArray(node.assertion)) {
×
3
        ctx.range(node.assertion.range, 'var');
×
4
        ctx.range(node.assertion.range, 'assertion');
×
5
    }
×
6
}
×
7
export function compile(node, ctx) {
1✔
8
    if (Array.isArray(node.assertion)) {
107✔
9
        ctx.put(node.negation ? '!(' : '(');
35✔
10

35✔
11
        for (let i = 0; i < node.assertion.length; i++) {
35✔
12
            if (i % 2 === 0) {
91✔
13
                ctx.node(node.assertion[i]);
63✔
14
            } else {
91✔
15
                switch (node.assertion[i]) {
28✔
16
                    case 'and':
28✔
17
                        ctx.put('&&');
12✔
18
                        break;
12✔
19
                    case 'or':
28✔
20
                        ctx.put('||');
16✔
21
                        break;
16✔
22
                    default:
28!
23
                        ctx.error('Bad conjuction operator in assertion', node);
×
24
                }
28✔
25
            }
28✔
26
        }
91✔
27

35✔
28
        ctx.put(')');
35✔
29
    } else {
107✔
30
        if (node.negation) {
72✔
31
            ctx.put('!');
15✔
32
        }
15✔
33

72✔
34
        switch (node.assertion.type) {
72✔
35
            case 'Identifier':
72✔
36
                if (node.assertion.name) {
59✔
37
                    ctx.put('!!');
59✔
38

59✔
39
                    if (ctx.tolerant) {
59!
40
                        ctx.put('(typeof ');
×
UNCOV
41
                    }
×
42

59✔
43
                    ctx.put('a.');
59✔
44
                    ctx.put(node.assertion.name);
59✔
45

59✔
46
                    if (ctx.tolerant) {
59!
UNCOV
47
                        ctx.put('==="function"?a.');
×
48
                        ctx.put(node.assertion.name);
×
49
                    }
×
50

59✔
51
                    ctx.put('(');
59✔
52
                    ctx.nodeOrCurrent();
59✔
53
                    ctx.put(')');
59✔
54

59✔
55
                    if (ctx.tolerant) {
59!
UNCOV
56
                        ctx.put(':false)');
×
UNCOV
57
                    }
×
58

59✔
59
                    if (ctx.usedAssertions.has(node.assertion.name)) {
59!
UNCOV
60
                        ctx.usedAssertions.get(node.assertion.name).push(node.assertion.range);
×
61
                    } else {
59✔
62
                        ctx.usedAssertions.set(node.assertion.name, node.assertion.range);
59✔
63
                    }
59✔
64
                } else {
59!
UNCOV
65
                    ctx.put('false');
×
UNCOV
66
                }
×
67

59✔
68
                break;
59✔
69

72✔
70
            case 'Method':
72✔
71
                ctx.put('!!');
13✔
72
                ctx.node(node.assertion);
13✔
73
                break;
13✔
74

72✔
75
            default:
72!
UNCOV
76
                ctx.error('Unknown assertion node type "' + node.assertion.type + '"', node.assertion);
×
77
        }
72✔
78
    }
72✔
79
}
107✔
80
export function walk(node, ctx) {
1✔
81
    if (Array.isArray(node.assertion)) {
81✔
82
        for (let i = 0; i < node.assertion.length; i++) {
30✔
83
            if (i % 2 === 0) {
84✔
84
                ctx.node(node.assertion[i]);
57✔
85
            }
57✔
86
        }
84✔
87
    } else {
81✔
88
        ctx.node(node.assertion);
51✔
89
    }
51✔
90
}
81✔
91
export function stringify(node, ctx) {
1✔
92
    if (node.negation) {
27✔
93
        ctx.put('not ');
8✔
94
    }
8✔
95

27✔
96
    if (Array.isArray(node.assertion)) {
27✔
97
        ctx.put('(');
10✔
98

10✔
99
        for (let i = 0; i < node.assertion.length; i++) {
10✔
100
            if (i % 2 === 0) {
28✔
101
                ctx.node(node.assertion[i]);
19✔
102
            } else {
28✔
103
                ctx.put(' ');
9✔
104
                ctx.put(node.assertion[i]);
9✔
105
                ctx.put(' ');
9✔
106
            }
9✔
107
        }
28✔
108

10✔
109
        ctx.put(')');
10✔
110
    } else {
27✔
111
        ctx.node(node.assertion);
17✔
112
    }
17✔
113
}
27✔
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