Permalink
Browse files

Fix minor bug in exponent notation interpolation.

  • Loading branch information...
jasondavies committed Nov 4, 2011
1 parent 98da365 commit e60bc4d525267bd9ba0619263cba2a5b69d9db48
Showing with 7 additions and 3 deletions.
  1. +1 −1 d3.js
  2. +1 −1 d3.min.js
  3. +1 −1 src/core/interpolate.js
  4. +4 −0 test/core/interpolate-test.js
View
2 d3.js
@@ -896,7 +896,7 @@ d3.interpolateObject = function(a, b) {
};
}
-var d3_interpolate_number = /[-+]?(?:\d+\.\d+|\d+\.|\.\d+|\d+)(?:[eE][-]?\d+)?/g,
+var d3_interpolate_number = /[-+]?(?:\d+\.\d+|\d+\.|\.\d+|\d+)(?:[eE][-+]?\d+)?/g,
d3_interpolate_rgb = {background: 1, fill: 1, stroke: 1};
function d3_interpolateByName(n) {
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -162,7 +162,7 @@ d3.interpolateObject = function(a, b) {
};
}
-var d3_interpolate_number = /[-+]?(?:\d+\.\d+|\d+\.|\.\d+|\d+)(?:[eE][-]?\d+)?/g,
+var d3_interpolate_number = /[-+]?(?:\d+\.\d+|\d+\.|\.\d+|\d+)(?:[eE][-+]?\d+)?/g,
d3_interpolate_rgb = {background: 1, fill: 1, stroke: 1};
function d3_interpolateByName(n) {
@@ -73,6 +73,10 @@ suite.addBatch({
"preserves equal-value numbers in both strings": function(interpolate) {
assert.equal(interpolate(" 10/20 100 20", "50/10 100, 20 ")(.2), "18/18 100, 20 ");
assert.equal(interpolate(" 10/20 100 20", "50/10 100, 20 ")(.4), "26/16 100, 20 ");
+ },
+ "interpolates exponent notation correctly": function(interpolate) {
+ assert.equal(interpolate("1e+3", "1e+4")(.5), "5500");
+ assert.equal(interpolate("1e-3", "1e-4")(.5), "0.00055");
}
}
});

0 comments on commit e60bc4d

Please sign in to comment.