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

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

Issue 2774783002: Re-land "Format all multitests" (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « tests/language_strong/callable_test.dart ('k') | tests/language_strong/cast_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) 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 4
5 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 6
7 // Test cascades. 7 // Test cascades.
8 8
9 class A { 9 class A {
10 int x; 10 int x;
11 int y; 11 int y;
12 12
13 A(this.x, this.y); 13 A(this.x, this.y);
14 14
15 A setX(int x) { this.x = x; return this; } 15 A setX(int x) {
16 this.x = x;
17 return this;
18 }
16 19
17 void setY(int y) { this.y = y; } 20 void setY(int y) {
21 this.y = y;
22 }
18 23
19 Function swap() { 24 Function swap() {
20 int tmp = x; 25 int tmp = x;
21 x = y; 26 x = y;
22 y = tmp; 27 y = tmp;
23 return this.swap; 28 return this.swap;
24 } 29 }
25 30
26 void check(int x, int y) { 31 void check(int x, int y) {
27 Expect.equals(x, this.x); 32 Expect.equals(x, this.x);
28 Expect.equals(y, this.y); 33 Expect.equals(y, this.y);
29 } 34 }
30 35
31 operator[](var i) { 36 operator [](var i) {
32 if (i == 0) return x; 37 if (i == 0) return x;
33 if (i == 1) return y; 38 if (i == 1) return y;
34 if (i == "swap") return this.swap; 39 if (i == "swap") return this.swap;
35 return null; 40 return null;
36 } 41 }
37 42
38 int operator[]=(int i, int value) { 43 int operator []=(int i, int value) {
39 if (i == 0) { 44 if (i == 0) {
40 x = value; 45 x = value;
41 } else if (i == 1) { 46 } else if (i == 1) {
42 y = value; 47 y = value;
43 } 48 }
44 } 49 }
45 50
46 /** 51 /**
47 * A pseudo-keyword. 52 * A pseudo-keyword.
48 */ 53 */
49 import() { 54 import() {
50 x++; 55 x++;
51 } 56 }
52 } 57 }
53 58
54 main() { 59 main() {
55 A a = new A(1, 2); 60 A a = new A(1, 2);
56 a..check(1, 2) 61 a
57 ..swap()..check(2, 1) 62 ..check(1, 2)
58 ..x = 4..y = 9..check(4, 9) 63 ..swap()
59 ..setX(10)..check(10, 9) 64 ..check(2, 1)
60 ..y = 5..check(10, 5) 65 ..x = 4
61 ..swap()()()..check(5, 10) 66 ..y = 9
62 ..[0] = 2..check(2, 10) 67 ..check(4, 9)
63 ..setX(10).setY(3)..check(10, 3) 68 ..setX(10)
64 ..setX(7)["swap"]()..check(3, 7) 69 ..check(10, 9)
65 ..import()..check(4, 7) 70 ..y = 5
66 ..["swap"]()()()..check(7, 4); 71 ..check(10, 5)
67 a.check(7,4); 72 ..swap()()()
73 ..check(5, 10)
74 ..[0] = 2
75 ..check(2, 10)
76 ..setX(10).setY(3)
77 ..check(10, 3)
78 ..setX(7)["swap"]()
79 ..check(3, 7)
80 ..import()
81 ..check(4, 7)
82 ..["swap"]()()()
83 ..check(7, 4);
84 a.check(7, 4);
68 a..(42); // //# 01: compile-time error 85 a..(42); // //# 01: compile-time error
69 a..37; // //# 02: compile-time error 86 a..37; // //# 02: compile-time error
70 a.."foo"; // //# 03: compile-time error 87 a.."foo"; // //# 03: compile-time error
71 } 88 }
OLDNEW
« no previous file with comments | « tests/language_strong/callable_test.dart ('k') | tests/language_strong/cast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698