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

FontoXML / fontoxpath / 11973412300

22 Nov 2024 01:21PM UTC coverage: 91.545% (-0.03%) from 91.575%
11973412300

Pull #660

github

DrRataplan
Improve test coverage
Pull Request #660: Implement otherwise and combinating tests from XQ4

5059 of 5878 branches covered (86.07%)

Branch coverage included in aggregate %.

112 of 118 new or added lines in 11 files covered. (94.92%)

5 existing lines in 1 file now uncovered.

10868 of 11520 relevant lines covered (94.34%)

35628.9 hits per line

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

93.1
/src/expressions/tests/UnionNodeTest.ts
1
import Value from '../dataTypes/Value';
2
import DynamicContext from '../DynamicContext';
3
import ExecutionParameters from '../ExecutionParameters';
4
import Specificity from '../Specificity';
6✔
5
import StaticContext from '../StaticContext';
6
import { Bucket, unionBucket } from '../util/Bucket';
6✔
7
import TestAbstractExpression from './TestAbstractExpression';
6✔
8

9
/**
10
 * Union node test, used to process `descendant::(a|b|c)` selectors
11
 */
12
class UnionNodeTest extends TestAbstractExpression {
13
        private _subTests: TestAbstractExpression[];
14
        private _bucket: Bucket;
15
        constructor(subTests: TestAbstractExpression[]) {
16
                const maxSpecificity = subTests.reduce<Specificity>((currentMaxSpecificity, selector) => {
12✔
17
                        if (currentMaxSpecificity.compareTo(selector.specificity) > 0) {
24✔
18
                                return currentMaxSpecificity;
6✔
19
                        }
20
                        return selector.specificity;
18✔
21
                }, new Specificity({}));
22

23
                super(maxSpecificity);
12✔
24

25
                // If all subExpressions define the same bucket: use that one, else, use no bucket.
26
                let bucket: Bucket | null;
27
                for (let i = 0; i < subTests.length; ++i) {
12✔
28
                        const subTestBucket = subTests[i].getBucket();
24✔
29
                        if (bucket === undefined) {
24✔
30
                                bucket = subTestBucket;
12✔
31
                        }
32
                        if (bucket === null) {
24!
33
                                // Not applicable buckets
NEW
34
                                break;
×
35
                        }
36

37
                        bucket = unionBucket(bucket, subTestBucket);
24✔
38
                }
39

40
                this._bucket = bucket;
12✔
41
                this._subTests = subTests;
12✔
42
        }
43

44
        public evaluateToBoolean(
45
                dynamicContext: DynamicContext,
46
                value: Value,
47
                executionParameters: ExecutionParameters,
48
        ) {
49
                return this._subTests.some((test) => {
18✔
50
                        const result = test.evaluateToBoolean(dynamicContext, value, executionParameters);
30✔
51
                        return result;
30✔
52
                });
53
        }
54

55
        public override getBucket(): Bucket {
56
                return this._bucket;
12✔
57
        }
58

59
        public performStaticEvaluation(staticContext: StaticContext) {
60
                this._subTests.forEach((test) => test.performStaticEvaluation(staticContext));
18✔
61
        }
62
}
63

64
export default UnionNodeTest;
6✔
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