Ensure _.inRange swaps start with end when start is greater than end. [closes #1099]

This commit is contained in:
jdalton
2015-04-01 08:43:42 -07:00
parent 97bd1ef4ec
commit 4758a9e66d
2 changed files with 6 additions and 1 deletions

View File

@@ -10110,7 +10110,7 @@
} else {
end = +end || 0;
}
return value >= start && value < end;
return value >= nativeMin(start, end) && value < nativeMax(start, end);
}
/**

View File

@@ -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() {
strictEqual(_.inRange(0.5, 5), true);
strictEqual(_.inRange(1.2, 1, 5), true);