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 point_test; | 5 library point_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 20 matching lines...) Expand all Loading... |
31 | 31 |
32 test('constructor X Y double', () { | 32 test('constructor X Y double', () { |
33 var point = new Point<double>(10.5, 20.897); | 33 var point = new Point<double>(10.5, 20.897); |
34 expect(point.x, 10.5); | 34 expect(point.x, 10.5); |
35 expect(point.y, 20.897); | 35 expect(point.y, 20.897); |
36 expect('$point', 'Point(10.5, 20.897)'); | 36 expect('$point', 'Point(10.5, 20.897)'); |
37 }); | 37 }); |
38 | 38 |
39 test('constructor X Y NaN', () { | 39 test('constructor X Y NaN', () { |
40 var point = new Point(double.NAN, 1000); | 40 var point = new Point(double.NAN, 1000); |
41 expect(point.x.isNaN, isTrue); | 41 expect(point.x, isNaN); |
42 expect(point.y, 1000); | 42 expect(point.y, 1000); |
43 expect('$point', 'Point(NaN, 1000)'); | 43 expect('$point', 'Point(NaN, 1000)'); |
44 }); | 44 }); |
45 | 45 |
46 test('squaredDistanceTo', () { | 46 test('squaredDistanceTo', () { |
47 var a = new Point(7, 11); | 47 var a = new Point(7, 11); |
48 var b = new Point(3, -1); | 48 var b = new Point(3, -1); |
49 expect(a.squaredDistanceTo(b), 160); | 49 expect(a.squaredDistanceTo(b), 160); |
50 expect(b.squaredDistanceTo(a), 160); | 50 expect(b.squaredDistanceTo(a), 160); |
51 }); | 51 }); |
(...skipping 29 matching lines...) Expand all Loading... |
81 test('magnitute', () { | 81 test('magnitute', () { |
82 var a = new Point(5, 10); | 82 var a = new Point(5, 10); |
83 var b = new Point(0, 0); | 83 var b = new Point(0, 0); |
84 expect(a.magnitude, a.distanceTo(b)); | 84 expect(a.magnitude, a.distanceTo(b)); |
85 expect(b.magnitude, 0); | 85 expect(b.magnitude, 0); |
86 | 86 |
87 var c = new Point(-5, -10); | 87 var c = new Point(-5, -10); |
88 expect(c.magnitude, a.distanceTo(b)); | 88 expect(c.magnitude, a.distanceTo(b)); |
89 }); | 89 }); |
90 } | 90 } |
OLD | NEW |