Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Unified Diff: tests/lib/math/rectangle_test.dart

Issue 135273009: Make Rectangle and MutableRectangle constructors handle negative lengths. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Update tests. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/math/rectangle.dart ('k') | tools/dom/src/CssRectangle.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/math/rectangle_test.dart
diff --git a/tests/lib/math/rectangle_test.dart b/tests/lib/math/rectangle_test.dart
index 96a0ba1068698abacc5c45601e4aded7e565db49..45052f63e23b2446fa7d515932e84aa20f4da28f 100644
--- a/tests/lib/math/rectangle_test.dart
+++ b/tests/lib/math/rectangle_test.dart
@@ -160,4 +160,22 @@ main() {
expect(r1.width, 1.0);
expect(r2.width, 2.0);
});
+
+ test('negative lengths', () {
+ // Constructor allows negative lengths, but clamps them to zero.
+ expect(new Rectangle(4, 4, -2, -2), new Rectangle(4, 4, 0, 0));
+ expect(new MutableRectangle(4, 4, -2, -2), new Rectangle(4, 4, 0, 0));
+
+ // Setters clamp negative lengths to zero.
+ var r = new MutableRectangle(0, 0, 1, 1);
+ r.width = -1;
+ r.height = -1;
+ expect(r, new Rectangle(0, 0, 0, 0));
+
+ // Test that doubles are clamped to double zero.
+ r = new Rectangle(1.5, 1.5, -2.5, -2.5);
+ expect(identical(r.width, 0.0), isTrue);
+ expect(identical(r.height, 0.0), isTrue);
+ });
}
+
« no previous file with comments | « sdk/lib/math/rectangle.dart ('k') | tools/dom/src/CssRectangle.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698