| OLD | NEW |
| 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:html'; | 7 import 'dart:html'; |
| 8 import '../../pkg/unittest/lib/unittest.dart'; | 8 import '../../pkg/unittest/lib/unittest.dart'; |
| 9 import '../../pkg/unittest/lib/html_config.dart'; | 9 import '../../pkg/unittest/lib/html_config.dart'; |
| 10 | 10 |
| 11 main() { | 11 main() { |
| 12 useHtmlConfiguration(); | 12 useHtmlConfiguration(); |
| 13 | 13 |
| 14 Rect createRect(List<num> a) { | 14 Rect createRect(List<num> a) { |
| 15 return a != null ? new Rect(a[0], a[1], a[2] - a[0], a[3] - a[1]) : null; | 15 return a != null ? new Rect(a[0], a[1], a[2] - a[0], a[3] - a[1]) : null; |
| 16 } | 16 } |
| 17 | 17 |
| 18 test('construction', () { | 18 test('construction', () { |
| 19 var r0 = new Rect(10, 20, 30, 40); | 19 var r0 = new Rect(10, 20, 30, 40); |
| 20 expect(r0.toString(), '(10, 20, 30, 40)'); | 20 expect(r0.toString(), '(10, 20, 30, 40)'); |
| 21 expect(r0.right, 40); | 21 expect(r0.right, 40); |
| 22 expect(r0.bottom, 60); | 22 expect(r0.bottom, 60); |
| 23 | 23 |
| 24 var r1 = new Rect.fromPoints(r0.topLeft, r0.bottomRight); | 24 var r1 = new Rect.fromPoints(r0.topLeft, r0.bottomRight); |
| 25 expect(r1, r0); | 25 expect(r1, r0); |
| 26 | 26 |
| 27 var r2 = new Rect.fromPoints(r0.bottomRight, r0.topLeft); | 27 var r2 = new Rect.fromPoints(r0.bottomRight, r0.topLeft); |
| 28 expect(r2, r0); | 28 expect(r2, r0); |
| 29 | |
| 30 expect(() { | |
| 31 new Rect(0, 0, -1, 0); | |
| 32 }, throwsArgumentError); | |
| 33 | |
| 34 expect(() { | |
| 35 new Rect(0, 0, 0, -1); | |
| 36 }, throwsArgumentError); | |
| 37 }); | 29 }); |
| 38 | 30 |
| 39 test('intersection', () { | 31 test('intersection', () { |
| 40 var tests = [ | 32 var tests = [ |
| 41 [[10, 10, 20, 20], [15, 15, 25, 25], [15, 15, 20, 20]], | 33 [[10, 10, 20, 20], [15, 15, 25, 25], [15, 15, 20, 20]], |
| 42 [[10, 10, 20, 20], [20, 0, 30, 10], [20, 10, 20, 10]], | 34 [[10, 10, 20, 20], [20, 0, 30, 10], [20, 10, 20, 10]], |
| 43 [[0, 0, 1, 1], [10, 11, 12, 13], null], | 35 [[0, 0, 1, 1], [10, 11, 12, 13], null], |
| 44 [[11, 12, 98, 99], [22, 23, 34, 35], [22, 23, 34, 35]]]; | 36 [[11, 12, 98, 99], [22, 23, 34, 35], [22, 23, 34, 35]]]; |
| 45 | 37 |
| 46 for (var test in tests) { | 38 for (var test in tests) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 var rect = new Rect(11.4, 26.6, 17.8, 9.2); | 141 var rect = new Rect(11.4, 26.6, 17.8, 9.2); |
| 150 var b = rect.toInt(); | 142 var b = rect.toInt(); |
| 151 expect(b, new Rect(11, 26, 17, 9)); | 143 expect(b, new Rect(11, 26, 17, 9)); |
| 152 | 144 |
| 153 expect(b.left is int, isTrue); | 145 expect(b.left is int, isTrue); |
| 154 expect(b.top is int, isTrue); | 146 expect(b.top is int, isTrue); |
| 155 expect(b.width is int, isTrue); | 147 expect(b.width is int, isTrue); |
| 156 expect(b.height is int, isTrue); | 148 expect(b.height is int, isTrue); |
| 157 }); | 149 }); |
| 158 } | 150 } |
| OLD | NEW |