| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |