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

Side by Side Diff: tests/html/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/element_test.dart ('k') | tests/html/rect_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
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:html';
8 import 'package:unittest/unittest.dart'; 8 import '../../pkg/unittest/lib/unittest.dart';
9 import '../../pkg/unittest/lib/html_config.dart';
9 10
10 main() { 11 main() {
12 useHtmlConfiguration();
13
11 test('constructor', () { 14 test('constructor', () {
12 var point = new Point(); 15 var point = new Point();
13 expect(point.x, 0); 16 expect(point.x, 0);
14 expect(point.y, 0); 17 expect(point.y, 0);
15 expect('$point', '(0, 0)'); 18 expect('$point', '(0, 0)');
16 }); 19 });
17 20
18 test('constructor X', () { 21 test('constructor X', () {
19 var point = new Point<int>(10); 22 var point = new Point(10);
20 expect(point.x, 10); 23 expect(point.x, 10);
21 expect(point.y, 0); 24 expect(point.y, 0);
22 expect('$point', '(10, 0)'); 25 expect('$point', '(10, 0)');
23 }); 26 });
24 27
25 test('constructor X Y', () { 28 test('constructor X Y', () {
26 var point = new Point<int>(10, 20); 29 var point = new Point(10, 20);
27 expect(point.x, 10); 30 expect(point.x, 10);
28 expect(point.y, 20); 31 expect(point.y, 20);
29 expect('$point', '(10, 20)'); 32 expect('$point', '(10, 20)');
30 }); 33 });
31 34
32 test('constructor X Y double', () { 35 test('constructor X Y double', () {
33 var point = new Point<double>(10.5, 20.897); 36 var point = new Point(10.5, 20.897);
34 expect(point.x, 10.5); 37 expect(point.x, 10.5);
35 expect(point.y, 20.897); 38 expect(point.y, 20.897);
36 expect('$point', '(10.5, 20.897)'); 39 expect('$point', '(10.5, 20.897)');
37 }); 40 });
38 41
39 test('constructor X Y NaN', () { 42 test('constructor X Y NaN', () {
40 var point = new Point(double.NAN, 1000); 43 var point = new Point(double.NAN, 1000);
41 expect(point.x.isNaN, isTrue); 44 expect(point.x.isNaN, isTrue);
42 expect(point.y, 1000); 45 expect(point.y, 1000);
43 expect('$point', '(NaN, 1000)'); 46 expect('$point', '(NaN, 1000)');
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 }); 89 });
87 90
88 test('round', () { 91 test('round', () {
89 var a = new Point(5.1, 10.8); 92 var a = new Point(5.1, 10.8);
90 expect(a.round(), new Point(5.0, 11.0)); 93 expect(a.round(), new Point(5.0, 11.0));
91 94
92 var b = new Point(5, 10); 95 var b = new Point(5, 10);
93 expect(b.round(), new Point(5, 10)); 96 expect(b.round(), new Point(5, 10));
94 }); 97 });
95 98
96 test('truncate', () { 99 test('toInt', () {
97 var a = new Point(5.1, 10.8); 100 var a = new Point(5.1, 10.8);
98 var b = a.truncate(); 101 var b = a.toInt();
99 expect(b, new Point(5, 10)); 102 expect(b, new Point(5, 10));
100 expect(b.x is int, isTrue); 103 expect(b.x is int, isTrue);
101 expect(b.y is int, isTrue); 104 expect(b.y is int, isTrue);
102 }); 105 });
103 106
104 test('hashCode', () { 107 test('hashCode', () {
105 var a = new Point(0, 1); 108 var a = new Point(0, 1);
106 var b = new Point(0, 1); 109 var b = new Point(0, 1);
107 expect(a.hashCode, b.hashCode); 110 expect(a.hashCode, b.hashCode);
108 111
109 var c = new Point(1, 0); 112 var c = new Point(1, 0);
110 expect(a.hashCode == c.hashCode, isFalse); 113 expect(a.hashCode == c.hashCode, isFalse);
111 }); 114 });
112 115
113 test('magnitute', () { 116 test('magnitute', () {
114 var a = new Point(5, 10); 117 var a = new Point(5, 10);
115 var b = new Point(0, 0); 118 var b = new Point(0, 0);
116 expect(a.magnitude, a.distanceTo(b)); 119 expect(a.magnitude, a.distanceTo(b));
117 expect(b.magnitude, 0); 120 expect(b.magnitude, 0);
118 121
119 var c = new Point(-5, -10); 122 var c = new Point(-5, -10);
120 expect(c.magnitude, a.distanceTo(b)); 123 expect(c.magnitude, a.distanceTo(b));
121 }); 124 });
122 } 125 }
OLDNEW
« no previous file with comments | « tests/html/element_test.dart ('k') | tests/html/rect_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698