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

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: 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
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() {
11 Rectangle createRectangle(List<num> a) { 11 Rectangle createRectangle(List<num> a) {
12 return a != null ? new Rectangle(a[0], a[1], a[2] - a[0], a[3] - a[1]) 12 return a != null ? new Rectangle(a[0], a[1], a[2] - a[0], a[3] - a[1])
13 : null; 13 : null;
14 } 14 }
15 15
16 test('construction', () { 16 test('construction', () {
17 var r0 = new Rectangle(10, 20, 30, 40); 17 var r0 = new Rectangle(10, 20, 30, 40);
18 expect(r0.toString(), 'Rectangle (10, 20) 30 x 40'); 18 expect(r0.toString(), 'Rectangle (10, 20) 30 x 40');
19 expect(r0.right, 40); 19 expect(r0.right, 40);
20 expect(r0.bottom, 60); 20 expect(r0.bottom, 60);
21 21
22 var r1 = new Rectangle.fromPoints(r0.topLeft, r0.bottomRight); 22 var r1 = new Rectangle.fromPoints(r0.topLeft, r0.bottomRight);
23 expect(r1, r0); 23 expect(r1, r0);
24 24
25 var r2 = new Rectangle.fromPoints(r0.bottomRight, r0.topLeft); 25 var r2 = new Rectangle.fromPoints(r0.bottomRight, r0.topLeft);
26 expect(r2, r0); 26 expect(r2, r0);
27
28 var r3 = new Rectangle(40, 60, -30, -40);
29 expect(r3, r0);
27 }); 30 });
28 31
29 test('intersection', () { 32 test('intersection', () {
30 var tests = [ 33 var tests = [
31 [[10, 10, 20, 20], [15, 15, 25, 25], [15, 15, 20, 20]], 34 [[10, 10, 20, 20], [15, 15, 25, 25], [15, 15, 20, 20]],
32 [[10, 10, 20, 20], [20, 0, 30, 10], [20, 10, 20, 10]], 35 [[10, 10, 20, 20], [20, 0, 30, 10], [20, 10, 20, 10]],
33 [[0, 0, 1, 1], [10, 11, 12, 13], null], 36 [[0, 0, 1, 1], [10, 11, 12, 13], null],
34 [[11, 12, 98, 99], [22, 23, 34, 35], [22, 23, 34, 35]]]; 37 [[11, 12, 98, 99], [22, 23, 34, 35], [22, 23, 34, 35]]];
35 38
36 for (var test in tests) { 39 for (var test in tests) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 125
123 test('hashCode', () { 126 test('hashCode', () {
124 var a = new Rectangle(0, 1, 2, 3); 127 var a = new Rectangle(0, 1, 2, 3);
125 var b = new Rectangle(0, 1, 2, 3); 128 var b = new Rectangle(0, 1, 2, 3);
126 expect(a.hashCode, b.hashCode); 129 expect(a.hashCode, b.hashCode);
127 130
128 var c = new Rectangle(1, 0, 2, 3); 131 var c = new Rectangle(1, 0, 2, 3);
129 expect(a.hashCode == c.hashCode, isFalse); 132 expect(a.hashCode == c.hashCode, isFalse);
130 }); 133 });
131 } 134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698