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

Side by Side Diff: tests/language/setter1_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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Dart test program for testing setting/getting of fields when 4 // Dart test program for testing setting/getting of fields when
5 // only getter/setter methods are specified. 5 // only getter/setter methods are specified.
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 8
9 class First { 9 class First {
10 First(int val) : a_ = val { } 10 First(int val) : a_ = val {}
11 11
12 void testMethod() { 12 void testMethod() {
13 a = 20; 13 a = 20;
14 } 14 }
15
15 static void testStaticMethod() { 16 static void testStaticMethod() {
16 b = 20; 17 b = 20;
17 } 18 }
18 19
19 int get a { 20 int get a {
20 return a_; 21 return a_;
21 } 22 }
23
22 void set a(int val) { 24 void set a(int val) {
23 a_ = a_ + val; 25 a_ = a_ + val;
24 } 26 }
25 27
26 static int get b { 28 static int get b {
27 return b_; 29 return b_;
28 } 30 }
31
29 static void set b(int val) { 32 static void set b(int val) {
30 b_ = val; 33 b_ = val;
31 } 34 }
32 35
33 int a_; 36 int a_;
34 static int b_; 37 static int b_;
35 } 38 }
36 39
37
38 class Second { 40 class Second {
39 static int c; 41 static int c;
40 int a_; 42 int a_;
41 43
42 Second(int value) : a_ = value { } 44 Second(int value) : a_ = value {}
43 45
44 void testMethod() { 46 void testMethod() {
45 a = 20; 47 a = 20;
46 } 48 }
47 49
48 static void testStaticMethod() { 50 static void testStaticMethod() {
49 int i; 51 int i;
50 b = 20; 52 b = 20;
51 i = d; 53 i = d;
52 // TODO(asiva): Turn these on once we have error handling. 54 // TODO(asiva): Turn these on once we have error handling.
53 // i = b; // Should be an error. 55 // i = b; // Should be an error.
54 // d = 40; // Should be an error. 56 // d = 40; // Should be an error.
55 } 57 }
56 58
57 int get a { 59 int get a {
58 return a_; 60 return a_;
59 } 61 }
62
60 void set a(int value) { 63 void set a(int value) {
61 a_ = a_ + value; 64 a_ = a_ + value;
62 } 65 }
63 66
64 static void set b(int value) { 67 static void set b(int value) {
65 Second.c = value; 68 Second.c = value;
66 } 69 }
70
67 static int get d { 71 static int get d {
68 return Second.c; 72 return Second.c;
69 } 73 }
70 } 74 }
71 75
72
73 class Setter1Test { 76 class Setter1Test {
74 static testMain() { 77 static testMain() {
75 First obj1 = new First(10); 78 First obj1 = new First(10);
76 Expect.equals(10, obj1.a); 79 Expect.equals(10, obj1.a);
77 obj1.testMethod(); 80 obj1.testMethod();
78 Expect.equals(30, obj1.a); 81 Expect.equals(30, obj1.a);
79 First.b = 10; 82 First.b = 10;
80 Expect.equals(10, First.b); 83 Expect.equals(10, First.b);
81 First.testStaticMethod(); 84 First.testStaticMethod();
82 Expect.equals(20, First.b); 85 Expect.equals(20, First.b);
83 86
84 Second obj = new Second(10); 87 Second obj = new Second(10);
85 Expect.equals(10, obj.a); 88 Expect.equals(10, obj.a);
86 obj.testMethod(); 89 obj.testMethod();
87 Expect.equals(30, obj.a); 90 Expect.equals(30, obj.a);
88 91
89 Second.testStaticMethod(); 92 Second.testStaticMethod();
90 Expect.equals(20, Second.c); 93 Expect.equals(20, Second.c);
91 Expect.equals(20, Second.d); 94 Expect.equals(20, Second.d);
92 } 95 }
93 } 96 }
94 97
95
96 main() { 98 main() {
97 Setter1Test.testMain(); 99 Setter1Test.testMain();
98 } 100 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698