diff --git a/test/dart_api/value/number_test.dart b/test/dart_api/value/number_test.dart index 7a1ee544..a8126aed 100644 --- a/test/dart_api/value/number_test.dart +++ b/test/dart_api/value/number_test.dart @@ -48,6 +48,19 @@ main() { expect(value.valueInUnits(["abc"], ["def"]), equals(123)); }); + group("valueInRange()", () { + test("returns its value within a given range", () { + expect(value.valueInRange(0, 123), equals(123)); + expect(value.valueInRange(123, 123), equals(123)); + expect(value.valueInRange(123, 1000), equals(123)); + }); + + test("rejects a value outside the range", () { + expect(() => value.valueInRange(0, 122), throwsSassScriptException); + expect(() => value.valueInRange(124, 1000), throwsSassScriptException); + }); + }); + test("equals the same number", () { expect(value, equalsWithHash(new SassNumber(123))); }); @@ -136,6 +149,19 @@ main() { equalsWithHash( new SassNumber(123 - math.pow(10, -SassNumber.precision - 1)))); }); + + group("valueInRange()", () { + test("clamps within the given range", () { + expect(value.valueInRange(0, 123), equals(123)); + expect(value.valueInRange(123, 123), equals(123)); + expect(value.valueInRange(123, 1000), equals(123)); + }); + + test("rejects a value outside the range", () { + expect(() => value.valueInRange(0, 122), throwsSassScriptException); + expect(() => value.valueInRange(124, 1000), throwsSassScriptException); + }); + }); }); group("an integer with a single numerator unit", () {