Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable implicit type assertions for array types
- Loading branch information
1 parent
1fb68f3
commit 4058f99
Showing
4 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
test/integration/expression-tests/array/implicit-1/test.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"expression": ["at", 0, ["get", "array"]], | ||
"inputs": [ | ||
[{}, {"properties": {"array": [0, 1, 2]}}], | ||
[{}, {"properties": {"array": "not"}}] | ||
], | ||
"expected": { | ||
"compiled": { | ||
"result": "success", | ||
"isFeatureConstant": false, | ||
"isZoomConstant": true, | ||
"type": "value" | ||
}, | ||
"outputs": [ | ||
0, | ||
{ | ||
"error": "Expected value to be of type array, but found string instead." | ||
} | ||
] | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
test/integration/expression-tests/array/implicit-2/test.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"propertySpec": {"type": "array", "value": "string"}, | ||
"expression": ["get", "array"], | ||
"inputs": [ | ||
[{}, {"properties": {"array": ["a", "b"]}}], | ||
[{}, {"properties": {"array": [1, 2]}}], | ||
[{}, {"properties": {"array": "not"}}] | ||
], | ||
"expected": { | ||
"compiled": { | ||
"result": "success", | ||
"isFeatureConstant": false, | ||
"isZoomConstant": true, | ||
"type": "array<string>" | ||
}, | ||
"outputs": [ | ||
["a", "b"], | ||
{ | ||
"error": "Expected value to be of type array<string>, but found array<number, 2> instead." | ||
}, | ||
{ | ||
"error": "Expected value to be of type array<string>, but found string instead." | ||
} | ||
] | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
test/integration/expression-tests/array/implicit-3/test.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"propertySpec": {"type": "array", "value": "number", "length": 2}, | ||
"expression": ["get", "array"], | ||
"inputs": [ | ||
[{}, {"properties": {"array": [1, 2]}}], | ||
[{}, {"properties": {"array": [1, 2, 3]}}], | ||
[{}, {"properties": {"array": "not"}}] | ||
], | ||
"expected": { | ||
"compiled": { | ||
"result": "success", | ||
"isFeatureConstant": false, | ||
"isZoomConstant": true, | ||
"type": "array<number, 2>" | ||
}, | ||
"outputs": [ | ||
[1, 2], | ||
{ | ||
"error": "Expected value to be of type array<number, 2>, but found array<number, 3> instead." | ||
}, | ||
{ | ||
"error": "Expected value to be of type array<number, 2>, but found string instead." | ||
} | ||
] | ||
} | ||
} |