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

Side by Side 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, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/math/rectangle.dart ('k') | tools/dom/src/CssRectangle.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library rect_test; 5 library rect_test;
6 6
7 import 'dart:math'; 7 import 'dart:math';
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 9
10 main() { 10 main() {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 var bignum = 0x80000000000008 + 0.0; 153 var bignum = 0x80000000000008 + 0.0;
154 var r1 = new Rectangle(bignum, bignum, 1.0, 1.0); 154 var r1 = new Rectangle(bignum, bignum, 1.0, 1.0);
155 var r2 = new Rectangle(bignum, bignum, 2.0, 2.0); 155 var r2 = new Rectangle(bignum, bignum, 2.0, 2.0);
156 expect(r1, r2); 156 expect(r1, r2);
157 expect(r1.hashCode, r2.hashCode); 157 expect(r1.hashCode, r2.hashCode);
158 expect(r1.right, r2.right); 158 expect(r1.right, r2.right);
159 expect(r1.bottom, r2.bottom); 159 expect(r1.bottom, r2.bottom);
160 expect(r1.width, 1.0); 160 expect(r1.width, 1.0);
161 expect(r2.width, 2.0); 161 expect(r2.width, 2.0);
162 }); 162 });
163
164 test('negative lengths', () {
165 // Constructor allows negative lengths, but clamps them to zero.
166 expect(new Rectangle(4, 4, -2, -2), new Rectangle(4, 4, 0, 0));
167 expect(new MutableRectangle(4, 4, -2, -2), new Rectangle(4, 4, 0, 0));
168
169 // Setters clamp negative lengths to zero.
170 var r = new MutableRectangle(0, 0, 1, 1);
171 r.width = -1;
172 r.height = -1;
173 expect(r, new Rectangle(0, 0, 0, 0));
174
175 // Test that doubles are clamped to double zero.
176 r = new Rectangle(1.5, 1.5, -2.5, -2.5);
177 expect(identical(r.width, 0.0), isTrue);
178 expect(identical(r.height, 0.0), isTrue);
179 });
163 } 180 }
181
OLDNEW
« 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