Skip to content

Commit

Permalink
Add expression test cases for implicit format type annotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisLoer committed Sep 18, 2018
1 parent feab065 commit a1233cb
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/integration/expression-tests/format/implicit-assert/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"expression": ["number", ["get", "p"]],
"propertySpec": {
"type": "formatted"
},
"expected": {
"compiled": {
"result": "error",
"errors": [
{"key": "", "error": "Expected formatted but found number instead."}
]
}
}
}
53 changes: 53 additions & 0 deletions test/integration/expression-tests/format/implicit-coerce/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"expression": ["to-string", ["get", "p"]],
"propertySpec": {
"type": "formatted"
},
"inputs": [
[{}, {"properties": {}}],
[{}, {"properties": {"p": 0}}],
[{}, {"properties": {"p": "a"}}]
],
"expected": {
"compiled": {
"result": "success",
"isFeatureConstant": false,
"isZoomConstant": true,
"type": "formatted"
},
"outputs": [
{
"sections": [
{
"text": "",
"scale": null,
"fontStack": null
}
]
},
{
"sections": [
{
"text": "0",
"scale": null,
"fontStack": null
}
]
},
{
"sections": [
{
"text": "a",
"scale": null,
"fontStack": null
}
]
}
],
"serialized": [
"format",
["to-string", ["get", "p"]],
{}
]
}
}
53 changes: 53 additions & 0 deletions test/integration/expression-tests/format/implicit-omit/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"expression": ["coalesce", ["get", "q"], ["get", "p"]],
"propertySpec": {
"type": "formatted"
},
"inputs": [
[{}, {"properties": {}}],
[{}, {"properties": {"p": 0}}],
[{}, {"properties": {"p": "a"}}]
],
"expected": {
"compiled": {
"result": "success",
"isFeatureConstant": false,
"isZoomConstant": true,
"type": "formatted"
},
"outputs": [
{
"sections": [
{
"text": "",
"scale": null,
"fontStack": null
}
]
},
{
"sections": [
{
"text": "0",
"scale": null,
"fontStack": null
}
]
},
{
"sections": [
{
"text": "a",
"scale": null,
"fontStack": null
}
]
}
],
"serialized": [
"format",
["coalesce", ["get", "q"], ["get", "p"]],
{}
]
}
}

0 comments on commit a1233cb

Please sign in to comment.