Skip to content

Commit

Permalink
Add test for range clamping.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Jan 1, 2012
1 parent a92f8b3 commit 5bae5f4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/scale/linear-test.js
Expand Up @@ -110,6 +110,16 @@ suite.addBatch({
assert.inDelta(x(-.5), 1, 1e-6);
assert.inDelta(x(.5), .5, 1e-6);
assert.inDelta(x(1.5), 0, 1e-6);
},
"can clamp to the range": function(linear) {
var x = linear().clamp(true);
assert.inDelta(x.invert(-.5), 0, 1e-6);
assert.inDelta(x.invert(.5), .5, 1e-6);
assert.inDelta(x.invert(1.5), 1, 1e-6);
var x = linear().range([1, 0]).clamp(true);
assert.inDelta(x.invert(-.5), 1, 1e-6);
assert.inDelta(x.invert(.5), .5, 1e-6);
assert.inDelta(x.invert(1.5), 0, 1e-6);
}
},

Expand Down

0 comments on commit 5bae5f4

Please sign in to comment.