Merge pull request #12022 from tschaub/expression-parsing

Throw when WebGL style parsing encounters an unexpected type
This commit is contained in:
Tim Schaub
2021-02-11 06:10:23 -07:00
committed by GitHub
2 changed files with 43 additions and 4 deletions

View File

@@ -273,6 +273,13 @@ describe('ol.style.expressions', function () {
).to.eql('vec4(a_attr4 / 255.0, 1.0 / 255.0, 2.0 / 255.0, 0.5)');
});
it('throws if the value does not match the type', function () {
const call = function () {
expressionToGlsl(context, '42', ValueTypes.NUMBER);
};
expect(call).to.throwException(/Unexpected expression/);
});
it('correctly adapts output for fragment shaders', function () {
context.inFragmentShader = true;
expect(expressionToGlsl(context, ['get', 'myAttr'])).to.eql('v_myAttr');