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

Side by Side Diff: tests/language_strong/ct_const_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // All things regarding compile time constant expressions. 4 // All things regarding compile time constant expressions.
5 5
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 7
8 abstract class Roman { 8 abstract class Roman {
9 static const I = 1; 9 static const I = 1;
10 static const II = 2; 10 static const II = 2;
11 static const III = 3; 11 static const III = 3;
12 static const IV = 4; 12 static const IV = 4;
13 static const V = 5; 13 static const V = 5;
14 14
15 static const VivaItalia = const {"green": 1, "red": 3, "white": 2}; 15 static const VivaItalia = const {"green": 1, "red": 3, "white": 2};
16 } 16 }
17 17
18
19 class Point { 18 class Point {
20 static const int zero = 0; 19 static const int zero = 0;
21 20
22 static const origin = const Point(0, 0); 21 static const origin = const Point(0, 0);
23 static const origin2 = const Point(zero, Roman.IV - 4); 22 static const origin2 = const Point(zero, Roman.IV - 4);
24 23
25 const Point(x, y) : x_= x, y_ = y; 24 const Point(x, y)
26 const Point.X(x) : x_ = x, y_ = Roman.V - Roman.II - 3; 25 : x_ = x,
26 y_ = y;
27 const Point.X(x)
28 : x_ = x,
29 y_ = Roman.V - Roman.II - 3;
27 30
28 bool operator ==(final Point other) { 31 bool operator ==(final Point other) {
29 return (this.x_ == other.x_) && (this.y_ == other.y_); 32 return (this.x_ == other.x_) && (this.y_ == other.y_);
30 } 33 }
31 34
32 final int x_, y_; 35 final int x_, y_;
33 } 36 }
34 37
35
36 class Line { 38 class Line {
37 const Line(Point begin, Point end) : beg_ = begin, end_ = end; 39 const Line(Point begin, Point end)
40 : beg_ = begin,
41 end_ = end;
38 final Point beg_; 42 final Point beg_;
39 final Point end_; 43 final Point end_;
40 } 44 }
41 45
46 class CTConstTest {
47 static int getZero() {
48 return 0;
49 }
42 50
43 class CTConstTest {
44 static int getZero() { return 0; }
45 static const naught = null; 51 static const naught = null;
46 52
47 static testMain() { 53 static testMain() {
48 Expect.equals(0, Point.zero); 54 Expect.equals(0, Point.zero);
49 Expect.equals(0, Point.origin.x_); 55 Expect.equals(0, Point.origin.x_);
50 Expect.equals(true, identical(Point.origin, Point.origin2)); 56 Expect.equals(true, identical(Point.origin, Point.origin2));
51 var p1 = const Point(0, 0); 57 var p1 = const Point(0, 0);
52 Expect.equals(true, identical(Point.origin, p1)); 58 Expect.equals(true, identical(Point.origin, p1));
53 59
54 Expect.equals(false, Point.origin == const Point(1, 1)); 60 Expect.equals(false, Point.origin == const Point(1, 1));
55 Expect.equals(false, identical(Point.origin, const Point(1, 1))); 61 Expect.equals(false, identical(Point.origin, const Point(1, 1)));
56 62
57 var p2 = new Point(0, getZero()); 63 var p2 = new Point(0, getZero());
58 Expect.equals(true, Point.origin == p2); // Point.operator== 64 Expect.equals(true, Point.origin == p2); // Point.operator==
59 65
60 Expect.equals(true, identical(const Point.X(5), const Point(5, 0))); 66 Expect.equals(true, identical(const Point.X(5), const Point(5, 0)));
61 67
62 Line l1 = const Line(Point.origin, const Point(1, 1)); 68 Line l1 = const Line(Point.origin, const Point(1, 1));
63 Line l2 = const Line(const Point(0, 0), const Point(1, 1)); 69 Line l2 = const Line(const Point(0, 0), const Point(1, 1));
64 Line l3 = new Line(const Point(0, 0), const Point(1, 1)); 70 Line l3 = new Line(const Point(0, 0), const Point(1, 1));
65 Expect.equals(true, identical(l1, l2)); 71 Expect.equals(true, identical(l1, l2));
66 72
67 final evenNumbers = const <int>[2, 2*2, 2*3, 2*4, 2*5]; 73 final evenNumbers = const <int>[2, 2 * 2, 2 * 3, 2 * 4, 2 * 5];
68 Expect.equals(true, !identical(evenNumbers, const [2, 4, 6, 8, 10])); 74 Expect.equals(true, !identical(evenNumbers, const [2, 4, 6, 8, 10]));
69 75
70 final c11dGermany1 = const {"black": 1, "red": 2, "yellow": 3}; 76 final c11dGermany1 = const {"black": 1, "red": 2, "yellow": 3};
71 Expect.equals(true, 77 Expect.equals(true,
72 identical(c11dGermany1, const {"black": 1, "red": 2, "yellow": 3})); 78 identical(c11dGermany1, const {"black": 1, "red": 2, "yellow": 3}));
73 79
74 final c11dGermany2 = const {"black": 1, "red": 2, "yellow": 3}; 80 final c11dGermany2 = const {"black": 1, "red": 2, "yellow": 3};
75 Expect.equals(true, identical(c11dGermany1, c11dGermany2)); 81 Expect.equals(true, identical(c11dGermany1, c11dGermany2));
76 82
77 final c11dBelgium = const {"black": 1, "yellow": 2, "red": 3}; 83 final c11dBelgium = const {"black": 1, "yellow": 2, "red": 3};
78 Expect.equals(false, c11dGermany1 == c11dBelgium); 84 Expect.equals(false, c11dGermany1 == c11dBelgium);
79 Expect.equals(false, identical(c11dGermany1, c11dBelgium)); 85 Expect.equals(false, identical(c11dGermany1, c11dBelgium));
80 86
81 final c11dItaly = const {"green": 1, "red": 3, "white": 2}; 87 final c11dItaly = const {"green": 1, "red": 3, "white": 2};
82 Expect.equals(true, 88 Expect.equals(
83 identical(c11dItaly, const {"green": 1, "red": 3, "white": 2})); 89 true, identical(c11dItaly, const {"green": 1, "red": 3, "white": 2}));
84 Expect.equals(true, identical(c11dItaly, Roman.VivaItalia)); 90 Expect.equals(true, identical(c11dItaly, Roman.VivaItalia));
85 91
86 Expect.equals(3, c11dItaly.length); 92 Expect.equals(3, c11dItaly.length);
87 Expect.equals(3, c11dItaly.keys.length); 93 Expect.equals(3, c11dItaly.keys.length);
88 Expect.equals(true, c11dItaly.containsKey("white")); 94 Expect.equals(true, c11dItaly.containsKey("white"));
89 Expect.equals(false, c11dItaly.containsKey("black")); 95 Expect.equals(false, c11dItaly.containsKey("black"));
90 96
91 // Make sure the map object is immutable. 97 // Make sure the map object is immutable.
92 bool caughtException = false; 98 bool caughtException = false;
93 try { 99 try {
(...skipping 22 matching lines...) Expand all
116 Expect.equals(true, caughtException); 122 Expect.equals(true, caughtException);
117 Expect.equals(1, c11dItaly["green"]); 123 Expect.equals(1, c11dItaly["green"]);
118 124
119 Expect.equals(true, null == naught); 125 Expect.equals(true, null == naught);
120 } 126 }
121 } 127 }
122 128
123 main() { 129 main() {
124 CTConstTest.testMain(); 130 CTConstTest.testMain();
125 } 131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698