mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 11:57:49 +00:00
Ensure _.inRange swaps start with end when start is greater than end. [closes #1099]
This commit is contained in:
@@ -10110,7 +10110,7 @@
|
|||||||
} else {
|
} else {
|
||||||
end = +end || 0;
|
end = +end || 0;
|
||||||
}
|
}
|
||||||
return value >= start && value < end;
|
return value >= nativeMin(start, end) && value < nativeMax(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6569,6 +6569,11 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should swap `start` and `end` when `start` is greater than `end`', 2, function() {
|
||||||
|
strictEqual(_.inRange(2, 5, 1), true);
|
||||||
|
strictEqual(_.inRange(-3, -2, -6), true);
|
||||||
|
});
|
||||||
|
|
||||||
test('should work with a floating point `n` value', 4, function() {
|
test('should work with a floating point `n` value', 4, function() {
|
||||||
strictEqual(_.inRange(0.5, 5), true);
|
strictEqual(_.inRange(0.5, 5), true);
|
||||||
strictEqual(_.inRange(1.2, 1, 5), true);
|
strictEqual(_.inRange(1.2, 1, 5), true);
|
||||||
|
|||||||
Reference in New Issue
Block a user