Index: tests/html/rect_test.dart |
diff --git a/tests/lib/math/rectangle_test.dart b/tests/html/rect_test.dart |
similarity index 57% |
rename from tests/lib/math/rectangle_test.dart |
rename to tests/html/rect_test.dart |
index 7b20894fe216d0ef7190f4124d4d8a78ecc2521f..8b52f615839af2695559138224849a928e541430 100644 |
--- a/tests/lib/math/rectangle_test.dart |
+++ b/tests/html/rect_test.dart |
@@ -4,25 +4,27 @@ |
library rect_test; |
-import 'dart:math'; |
-import 'package:unittest/unittest.dart'; |
+import 'dart:html'; |
+import '../../pkg/unittest/lib/unittest.dart'; |
+import '../../pkg/unittest/lib/html_config.dart'; |
main() { |
- Rectangle createRectangle(List<num> a) { |
- return a != null ? new Rectangle(a[0], a[1], a[2] - a[0], a[3] - a[1]) |
- : null; |
+ useHtmlConfiguration(); |
+ |
+ Rect createRect(List<num> a) { |
+ return a != null ? new Rect(a[0], a[1], a[2] - a[0], a[3] - a[1]) : null; |
} |
test('construction', () { |
- var r0 = new Rectangle(10, 20, 30, 40); |
- expect(r0.toString(), 'Rectangle (10, 20) 30 x 40'); |
+ var r0 = new Rect(10, 20, 30, 40); |
+ expect(r0.toString(), '(10, 20, 30, 40)'); |
expect(r0.right, 40); |
expect(r0.bottom, 60); |
- var r1 = new Rectangle.fromPoints(r0.topLeft, r0.bottomRight); |
+ var r1 = new Rect.fromPoints(r0.topLeft, r0.bottomRight); |
expect(r1, r0); |
- var r2 = new Rectangle.fromPoints(r0.bottomRight, r0.topLeft); |
+ var r2 = new Rect.fromPoints(r0.bottomRight, r0.topLeft); |
expect(r2, r0); |
}); |
@@ -34,9 +36,9 @@ main() { |
[[11, 12, 98, 99], [22, 23, 34, 35], [22, 23, 34, 35]]]; |
for (var test in tests) { |
- var r0 = createRectangle(test[0]); |
- var r1 = createRectangle(test[1]); |
- var expected = createRectangle(test[2]); |
+ var r0 = createRect(test[0]); |
+ var r1 = createRect(test[1]); |
+ var expected = createRect(test[2]); |
expect(r0.intersection(r1), expected); |
expect(r1.intersection(r0), expected); |
@@ -44,9 +46,9 @@ main() { |
}); |
test('intersects', () { |
- var r0 = new Rectangle(10, 10, 20, 20); |
- var r1 = new Rectangle(15, 15, 25, 25); |
- var r2 = new Rectangle(0, 0, 1, 1); |
+ var r0 = new Rect(10, 10, 20, 20); |
+ var r1 = new Rect(15, 15, 25, 25); |
+ var r2 = new Rect(0, 0, 1, 1); |
expect(r0.intersects(r1), isTrue); |
expect(r1.intersects(r0), isTrue); |
@@ -63,38 +65,38 @@ main() { |
[[11, 12, 98, 99], [22, 23, 34, 35], [11, 12, 98, 99]]]; |
for (var test in tests) { |
- var r0 = createRectangle(test[0]); |
- var r1 = createRectangle(test[1]); |
- var expected = createRectangle(test[2]); |
+ var r0 = createRect(test[0]); |
+ var r1 = createRect(test[1]); |
+ var expected = createRect(test[2]); |
expect(r0.union(r1), expected); |
expect(r1.union(r0), expected); |
} |
}); |
- test('containsRectangle', () { |
- var r = new Rectangle(-10, 0, 20, 10); |
- expect(r.contains(r), isTrue); |
- |
- expect(r.contains( |
- new Rectangle(double.NAN, double.NAN, double.NAN, double.NAN)), isFalse); |
- |
- var r2 = new Rectangle(0, 2, 5, 5); |
- expect(r.contains(r2), isTrue); |
- expect(r2.contains(r), isFalse); |
- |
- r2 = new Rectangle(-11, 2, 5, 5); |
- expect(r.contains(r2), isFalse); |
- r2 = new Rectangle(0, 2, 15, 5); |
- expect(r.contains(r2), isFalse); |
- r2 = new Rectangle(0, 2, 5, 10); |
- expect(r.contains(r2), isFalse); |
- r2 = new Rectangle(0, 0, 5, 10); |
- expect(r.contains(r2), isTrue); |
+ test('containsRect', () { |
+ var r = new Rect(-10, 0, 20, 10); |
+ expect(r.containsRect(r), isTrue); |
+ |
+ expect(r.containsRect( |
+ new Rect(double.NAN, double.NAN, double.NAN, double.NAN)), isFalse); |
+ |
+ var r2 = new Rect(0, 2, 5, 5); |
+ expect(r.containsRect(r2), isTrue); |
+ expect(r2.containsRect(r), isFalse); |
+ |
+ r2 = new Rect(-11, 2, 5, 5); |
+ expect(r.containsRect(r2), isFalse); |
+ r2 = new Rect(0, 2, 15, 5); |
+ expect(r.containsRect(r2), isFalse); |
+ r2 = new Rect(0, 2, 5, 10); |
+ expect(r.containsRect(r2), isFalse); |
+ r2 = new Rect(0, 0, 5, 10); |
+ expect(r.containsRect(r2), isTrue); |
}); |
test('containsPoint', () { |
- var r = new Rectangle(20, 40, 60, 80); |
+ var r = new Rect(20, 40, 60, 80); |
// Test middle. |
expect(r.containsPoint(new Point(50, 80)), isTrue); |
@@ -121,24 +123,24 @@ main() { |
}); |
test('ceil', () { |
- var rect = new Rectangle(11.4, 26.6, 17.8, 9.2); |
- expect(rect.ceil(), new Rectangle(12.0, 27.0, 18.0, 10.0)); |
+ var rect = new Rect(11.4, 26.6, 17.8, 9.2); |
+ expect(rect.ceil(), new Rect(12.0, 27.0, 18.0, 10.0)); |
}); |
test('floor', () { |
- var rect = new Rectangle(11.4, 26.6, 17.8, 9.2); |
- expect(rect.floor(), new Rectangle(11.0, 26.0, 17.0, 9.0)); |
+ var rect = new Rect(11.4, 26.6, 17.8, 9.2); |
+ expect(rect.floor(), new Rect(11.0, 26.0, 17.0, 9.0)); |
}); |
test('round', () { |
- var rect = new Rectangle(11.4, 26.6, 17.8, 9.2); |
- expect(rect.round(), new Rectangle(11.0, 27.0, 18.0, 9.0)); |
+ var rect = new Rect(11.4, 26.6, 17.8, 9.2); |
+ expect(rect.round(), new Rect(11.0, 27.0, 18.0, 9.0)); |
}); |
- test('truncate', () { |
- var rect = new Rectangle(11.4, 26.6, 17.8, 9.2); |
- var b = rect.truncate(); |
- expect(b, new Rectangle(11, 26, 17, 9)); |
+ test('toInt', () { |
+ var rect = new Rect(11.4, 26.6, 17.8, 9.2); |
+ var b = rect.toInt(); |
+ expect(b, new Rect(11, 26, 17, 9)); |
expect(b.left is int, isTrue); |
expect(b.top is int, isTrue); |
@@ -147,11 +149,11 @@ main() { |
}); |
test('hashCode', () { |
- var a = new Rectangle(0, 1, 2, 3); |
- var b = new Rectangle(0, 1, 2, 3); |
+ var a = new Rect(0, 1, 2, 3); |
+ var b = new Rect(0, 1, 2, 3); |
expect(a.hashCode, b.hashCode); |
- var c = new Rectangle(1, 0, 2, 3); |
+ var c = new Rect(1, 0, 2, 3); |
expect(a.hashCode == c.hashCode, isFalse); |
}); |
} |