-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preserve expected type when parsing 'let' expressions (#7301)
- Loading branch information
1 parent
23ac915
commit 395084c
Showing
2 changed files
with
59 additions
and
1 deletion.
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
58 changes: 58 additions & 0 deletions
58
test/integration/expression-tests/let/expected-value/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,58 @@ | ||
{ | ||
"expression": [ | ||
"let", | ||
"density", | ||
["/", ["get", "population"], ["get", "sq-km"]], | ||
[ | ||
"interpolate", | ||
["linear"], | ||
["var", "density"], | ||
1, | ||
"#000000", | ||
100, | ||
"#ffffff" | ||
] | ||
], | ||
"propertySpec": { | ||
"type": "color" | ||
}, | ||
"description": "let should preserve expected type for child expressions. If the expected 'color' type in this test were not preserved, it would not get passed into the interpolation and the literal strings wouldn't automatically coerce to the 'color' type", | ||
"inputs": [[{}, {"properties": {"population": 100, "sq-km": 10}}]], | ||
"expected": { | ||
"compiled": { | ||
"result": "success", | ||
"isFeatureConstant": false, | ||
"isZoomConstant": true, | ||
"type": "color" | ||
}, | ||
"outputs": [ | ||
[0.09090909090909091,0.09090909090909091,0.09090909090909091,1] | ||
], | ||
"serialized": [ | ||
"let", | ||
"density", | ||
["/", ["number", ["get", "population"]], ["number", ["get", "sq-km"]]], | ||
[ | ||
"interpolate", | ||
["linear"], | ||
["var", "density"], | ||
1, | ||
[ | ||
"rgba", | ||
0, | ||
0, | ||
0, | ||
1 | ||
], | ||
100, | ||
[ | ||
"rgba", | ||
255, | ||
255, | ||
255, | ||
1 | ||
] | ||
] | ||
] | ||
} | ||
} |