Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: tests/lib/math/point_test.dart

Issue 25785003: "Reverting 28184" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/html/svgelement_test.dart ('k') | tests/lib/math/rectangle_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library point_test;
6
7 import 'dart:math';
8 import 'package:unittest/unittest.dart';
9
10 main() {
11 test('constructor', () {
12 var point = new Point();
13 expect(point.x, 0);
14 expect(point.y, 0);
15 expect('$point', '(0, 0)');
16 });
17
18 test('constructor X', () {
19 var point = new Point<int>(10);
20 expect(point.x, 10);
21 expect(point.y, 0);
22 expect('$point', '(10, 0)');
23 });
24
25 test('constructor X Y', () {
26 var point = new Point<int>(10, 20);
27 expect(point.x, 10);
28 expect(point.y, 20);
29 expect('$point', '(10, 20)');
30 });
31
32 test('constructor X Y double', () {
33 var point = new Point<double>(10.5, 20.897);
34 expect(point.x, 10.5);
35 expect(point.y, 20.897);
36 expect('$point', '(10.5, 20.897)');
37 });
38
39 test('constructor X Y NaN', () {
40 var point = new Point(double.NAN, 1000);
41 expect(point.x.isNaN, isTrue);
42 expect(point.y, 1000);
43 expect('$point', '(NaN, 1000)');
44 });
45
46 test('squaredDistanceTo', () {
47 var a = new Point(7, 11);
48 var b = new Point(3, -1);
49 expect(a.squaredDistanceTo(b), 160);
50 expect(b.squaredDistanceTo(a), 160);
51 });
52
53 test('distanceTo', () {
54 var a = new Point(-2, -3);
55 var b = new Point(2, 0);
56 expect(a.distanceTo(b), 5);
57 expect(b.distanceTo(a), 5);
58 });
59
60 test('subtract', () {
61 var a = new Point(5, 10);
62 var b = new Point(2, 50);
63 expect(a - b, new Point(3, -40));
64 });
65
66 test('add', () {
67 var a = new Point(5, 10);
68 var b = new Point(2, 50);
69 expect(a + b, new Point(7, 60));
70 });
71
72 test('ceil', () {
73 var a = new Point(5.1, 10.8);
74 expect(a.ceil(), new Point(6.0, 11.0));
75
76 var b = new Point(5, 10);
77 expect(b.ceil(), new Point(5, 10));
78 });
79
80 test('floor', () {
81 var a = new Point(5.1, 10.8);
82 expect(a.floor(), new Point(5.0, 10.0));
83
84 var b = new Point(5, 10);
85 expect(b.floor(), new Point(5, 10));
86 });
87
88 test('round', () {
89 var a = new Point(5.1, 10.8);
90 expect(a.round(), new Point(5.0, 11.0));
91
92 var b = new Point(5, 10);
93 expect(b.round(), new Point(5, 10));
94 });
95
96 test('truncate', () {
97 var a = new Point(5.1, 10.8);
98 var b = a.truncate();
99 expect(b, new Point(5, 10));
100 expect(b.x is int, isTrue);
101 expect(b.y is int, isTrue);
102 });
103
104 test('hashCode', () {
105 var a = new Point(0, 1);
106 var b = new Point(0, 1);
107 expect(a.hashCode, b.hashCode);
108
109 var c = new Point(1, 0);
110 expect(a.hashCode == c.hashCode, isFalse);
111 });
112
113 test('magnitute', () {
114 var a = new Point(5, 10);
115 var b = new Point(0, 0);
116 expect(a.magnitude, a.distanceTo(b));
117 expect(b.magnitude, 0);
118
119 var c = new Point(-5, -10);
120 expect(c.magnitude, a.distanceTo(b));
121 });
122 }
OLDNEW
« no previous file with comments | « tests/html/svgelement_test.dart ('k') | tests/lib/math/rectangle_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698