blob: c243ba1e0eac2571bb98aa3e0f459720a083fd17 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
'use strict';
var suite = require('../../../mapbox-gl-js/test/integration').expression;
var mbgl = require('../index');
var tests;
if (process.argv[1] === __filename && process.argv.length > 2) {
tests = process.argv.slice(2);
}
suite.run('native', {tests: tests}, (fixture) => {
const compileResult = {};
const testResult = {
compileResult
};
try {
const expression = new mbgl.Expression(fixture.expression);
compileResult.result = 'success';
compileResult.isFeatureConstant = expression.isFeatureConstant();
compileResult.isZoomConstant = expression.isZoomConstant();
compileResult.type = expression.getType();
if (fixture.evaluate) {
const evaluateResults = [];
for (const input of fixture.evaluate) {
const zoom = typeof input[0].zoom === 'number' ?
input[0].zoom : -1;
const feature = Object.assign({
type: 'Feature',
properties: {},
geometry: { type: 'Unknown', coordinates: [] }
}, input[1])
const output = expression.evaluate(zoom, feature);
evaluateResults.push(output);
}
if (evaluateResults.length) {
testResult.evaluateResults = evaluateResults;
}
}
} catch (e) {
compileResult.result = 'error';
compileResult.errors = [e.message];
}
return testResult;
});
|