Skip to content

Commit 5bae5f4

Browse files
committed
Add test for range clamping.
1 parent a92f8b3 commit 5bae5f4

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

test/scale/linear-test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@ suite.addBatch({
110110
assert.inDelta(x(-.5), 1, 1e-6);
111111
assert.inDelta(x(.5), .5, 1e-6);
112112
assert.inDelta(x(1.5), 0, 1e-6);
113+
},
114+
"can clamp to the range": function(linear) {
115+
var x = linear().clamp(true);
116+
assert.inDelta(x.invert(-.5), 0, 1e-6);
117+
assert.inDelta(x.invert(.5), .5, 1e-6);
118+
assert.inDelta(x.invert(1.5), 1, 1e-6);
119+
var x = linear().range([1, 0]).clamp(true);
120+
assert.inDelta(x.invert(-.5), 1, 1e-6);
121+
assert.inDelta(x.invert(.5), .5, 1e-6);
122+
assert.inDelta(x.invert(1.5), 0, 1e-6);
113123
}
114124
},
115125

0 commit comments

Comments
 (0)