From 768a5004faf6915860333f3f39b8f5534f4c1552 Mon Sep 17 00:00:00 2001 From: Anand Thakker Date: Mon, 27 Nov 2017 13:44:33 -0500 Subject: [PATCH] Handle NaN as input to step and interpolate expressions Closes #4172 --- src/style-spec/expression/stops.js | 4 ++ .../mapbox-gl-js#4172/expected.png | Bin 0 -> 263 bytes .../regressions/mapbox-gl-js#4172/style.json | 61 ++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 test/integration/render-tests/regressions/mapbox-gl-js#4172/expected.png create mode 100644 test/integration/render-tests/regressions/mapbox-gl-js#4172/style.json diff --git a/src/style-spec/expression/stops.js b/src/style-spec/expression/stops.js index 3e047cce1aa..a187c7e4949 100644 --- a/src/style-spec/expression/stops.js +++ b/src/style-spec/expression/stops.js @@ -1,5 +1,7 @@ // @flow +const RuntimeError = require('./runtime_error'); + import type { Expression } from './expression'; export type Stops = Array<[number, Expression]>; @@ -25,6 +27,8 @@ function findStopLessThanOrEqualTo(stops: Array, input: number) { lowerIndex = currentIndex + 1; } else if (currentValue > input) { upperIndex = currentIndex - 1; + } else { + throw new RuntimeError('Input is not a number.'); } } diff --git a/test/integration/render-tests/regressions/mapbox-gl-js#4172/expected.png b/test/integration/render-tests/regressions/mapbox-gl-js#4172/expected.png new file mode 100644 index 0000000000000000000000000000000000000000..ee941df55604b9362cb5de80e71f058b866b7bea GIT binary patch literal 263 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=Or9=|Ar*{or0OmKc?Uqew+A=o z9&%t{z0f`}#*j()4%4(53@^iaHXU6%;RN>`m35Ov*6Daz%=+`)1sVL|SAQQE@K(x- zYgMeXyW`gE7i`v&*@wi%+@nqu2{wbbZIO}>Q+svNJ8>{Yh