Skip to content

Commit

Permalink
#668 remove custom stringify function in test (#670)
Browse files Browse the repository at this point in the history
* #668 remove custom stringify function in test

* #668 use 2 space indent

* #668 remove from CHANGELOG

* #668 replace all json for test via UPDATE=1 npm run jest
  • Loading branch information
smellman authored May 24, 2024
1 parent c068c87 commit 52f248f
Show file tree
Hide file tree
Showing 367 changed files with 17,592 additions and 2,616 deletions.
3 changes: 1 addition & 2 deletions test/integration/expression/expression.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
import ExpressionParsingError from '../../../src/expression/parsing_error';
import {Result} from '../../../src/util/result';
import {getGeometry} from '../../lib/geometry';
import {stringify} from '../../lib/util';
import {deepEqual, stripPrecision} from '../../lib/json-diff';

const DECIMAL_SIGNIFICANT_FIGURES = 6;
Expand Down Expand Up @@ -52,7 +51,7 @@ describe('expression', () => {
delete fixture.metadata;

const fname = path.join(__dirname, expressionTestFileName);
fs.writeFileSync(fname, `${stringify(fixture)}\n`);
fs.writeFileSync(fname, JSON.stringify(fixture, null, 2));
return;
}

Expand Down
43 changes: 37 additions & 6 deletions test/integration/expression/tests/abs/basic/test.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
{
"expression": ["abs", ["get", "x"]],
"expression": [
"abs",
[
"get",
"x"
]
],
"inputs": [
[{}, {"properties": {"x": -2}}],
[{}, {"properties": {"x": 2}}],
[{}, {"properties": {"x": -1.1}}]
[
{},
{
"properties": {
"x": -2
}
}
],
[
{},
{
"properties": {
"x": 2
}
}
],
[
{},
{
"properties": {
"x": -1.1
}
}
]
],
"expected": {
"compiled": {
Expand All @@ -12,6 +39,10 @@
"isZoomConstant": true,
"type": "number"
},
"outputs": [2, 2, 1.1]
"outputs": [
2,
2,
1.1
]
}
}
}
18 changes: 14 additions & 4 deletions test/integration/expression/tests/acos/basic/test.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
{
"expression": ["acos", 0.5],
"inputs": [[{}, {}]],
"expression": [
"acos",
0.5
],
"inputs": [
[
{},
{}
]
],
"expected": {
"compiled": {
"result": "success",
"isFeatureConstant": true,
"isZoomConstant": true,
"type": "number"
},
"outputs": [1.04719]
"outputs": [
1.04719
]
}
}
}
17 changes: 13 additions & 4 deletions test/integration/expression/tests/all/arity-0/test.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
{
"expression": ["all"],
"inputs": [[{}, {}]],
"expression": [
"all"
],
"inputs": [
[
{},
{}
]
],
"expected": {
"compiled": {
"result": "success",
"isFeatureConstant": true,
"isZoomConstant": true,
"type": "boolean"
},
"outputs": [true]
"outputs": [
true
]
}
}
}
18 changes: 14 additions & 4 deletions test/integration/expression/tests/all/arity-1/test.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
{
"expression": ["all", false],
"inputs": [[{}, {}]],
"expression": [
"all",
false
],
"inputs": [
[
{},
{}
]
],
"expected": {
"compiled": {
"result": "success",
"isFeatureConstant": true,
"isZoomConstant": true,
"type": "boolean"
},
"outputs": [false]
"outputs": [
false
]
}
}
}
45 changes: 40 additions & 5 deletions test/integration/expression/tests/all/basic/test.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,40 @@
{
"expression": ["all", ["boolean", ["get", "x"]], ["boolean", ["get", "y"]]],
"expression": [
"all",
[
"boolean",
[
"get",
"x"
]
],
[
"boolean",
[
"get",
"y"
]
]
],
"inputs": [
[{}, {"properties": {"x": true, "y": false}}],
[{}, {"properties": {"x": true, "y": true}}]
[
{},
{
"properties": {
"x": true,
"y": false
}
}
],
[
{},
{
"properties": {
"x": true,
"y": true
}
}
]
],
"expected": {
"compiled": {
Expand All @@ -11,6 +43,9 @@
"isZoomConstant": true,
"type": "boolean"
},
"outputs": [false, true]
"outputs": [
false,
true
]
}
}
}
22 changes: 18 additions & 4 deletions test/integration/expression/tests/all/short-circuiting/test.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
{
"expression": ["all", false, ["error", "unreachable"]],
"inputs": [[{}, {}]],
"expression": [
"all",
false,
[
"error",
"unreachable"
]
],
"inputs": [
[
{},
{}
]
],
"expected": {
"compiled": {
"result": "success",
"isFeatureConstant": true,
"isZoomConstant": true,
"type": "boolean"
},
"outputs": [false]
"outputs": [
false
]
}
}
}
17 changes: 13 additions & 4 deletions test/integration/expression/tests/any/arity-0/test.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
{
"expression": ["any"],
"inputs": [[{}, {}]],
"expression": [
"any"
],
"inputs": [
[
{},
{}
]
],
"expected": {
"compiled": {
"result": "success",
"isFeatureConstant": true,
"isZoomConstant": true,
"type": "boolean"
},
"outputs": [false]
"outputs": [
false
]
}
}
}
18 changes: 14 additions & 4 deletions test/integration/expression/tests/any/arity-1/test.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
{
"expression": ["any", false],
"inputs": [[{}, {}]],
"expression": [
"any",
false
],
"inputs": [
[
{},
{}
]
],
"expected": {
"compiled": {
"result": "success",
"isFeatureConstant": true,
"isZoomConstant": true,
"type": "boolean"
},
"outputs": [false]
"outputs": [
false
]
}
}
}
67 changes: 60 additions & 7 deletions test/integration/expression/tests/any/basic/test.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,58 @@
{
"expression": ["any", ["boolean", ["get", "x"]], ["boolean", ["get", "y"]]],
"expression": [
"any",
[
"boolean",
[
"get",
"x"
]
],
[
"boolean",
[
"get",
"y"
]
]
],
"inputs": [
[{}, {"properties": {"x": true, "y": true}}],
[{}, {"properties": {"x": true, "y": false}}],
[{}, {"properties": {"x": false, "y": true}}],
[{}, {"properties": {"x": false, "y": false}}]
[
{},
{
"properties": {
"x": true,
"y": true
}
}
],
[
{},
{
"properties": {
"x": true,
"y": false
}
}
],
[
{},
{
"properties": {
"x": false,
"y": true
}
}
],
[
{},
{
"properties": {
"x": false,
"y": false
}
}
]
],
"expected": {
"compiled": {
Expand All @@ -13,6 +61,11 @@
"isZoomConstant": true,
"type": "boolean"
},
"outputs": [true, true, true, false]
"outputs": [
true,
true,
true,
false
]
}
}
}
Loading

0 comments on commit 52f248f

Please sign in to comment.