| 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:math'; | 7 import 'dart:math'; |
| 8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 | 9 |
| 10 main() { | 10 main() { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 }); | 121 }); |
| 122 | 122 |
| 123 test('hashCode', () { | 123 test('hashCode', () { |
| 124 var a = new Rectangle(0, 1, 2, 3); | 124 var a = new Rectangle(0, 1, 2, 3); |
| 125 var b = new Rectangle(0, 1, 2, 3); | 125 var b = new Rectangle(0, 1, 2, 3); |
| 126 expect(a.hashCode, b.hashCode); | 126 expect(a.hashCode, b.hashCode); |
| 127 | 127 |
| 128 var c = new Rectangle(1, 0, 2, 3); | 128 var c = new Rectangle(1, 0, 2, 3); |
| 129 expect(a.hashCode == c.hashCode, isFalse); | 129 expect(a.hashCode == c.hashCode, isFalse); |
| 130 }); | 130 }); |
| 131 |
| 132 { // Edge cases for boundingBox/intersection |
| 133 edgeTest(a, l) { |
| 134 test('edge case $a/$l', () { |
| 135 var r = new Rectangle(a, a, l, l); |
| 136 expect(r.boundingBox(r), r); |
| 137 expect(r.intersection(r), r); |
| 138 }); |
| 139 } |
| 140 |
| 141 var bignum1 = 0x20000000000000 + 0.0; |
| 142 var bignum2 = 0x20000000000002 + 0.0; |
| 143 var bignum3 = 0x20000000000004 + 0.0; |
| 144 edgeTest(1.0, bignum1); |
| 145 edgeTest(1.0, bignum2); |
| 146 edgeTest(1.0, bignum3); |
| 147 edgeTest(bignum1, 1.0); |
| 148 edgeTest(bignum2, 1.0); |
| 149 edgeTest(bignum3, 1.0); |
| 150 } |
| 151 |
| 152 test("equality with different widths", () { |
| 153 var bignum = 0x80000000000008 + 0.0; |
| 154 var r1 = new Rectangle(bignum, bignum, 1.0, 1.0); |
| 155 var r2 = new Rectangle(bignum, bignum, 2.0, 2.0); |
| 156 expect(r1, r2); |
| 157 expect(r1.hashCode, r2.hashCode); |
| 158 expect(r1.right, r2.right); |
| 159 expect(r1.bottom, r2.bottom); |
| 160 expect(r1.width, 1.0); |
| 161 expect(r2.width, 2.0); |
| 162 }); |
| 131 } | 163 } |
| OLD | NEW |