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

Side by Side Diff: tests/language/static_field_test.dart

Issue 2768073002: 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
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 // Dart test program for testing setting/getting/initializing static fields. 4 // Dart test program for testing setting/getting/initializing static fields.
5 5
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 7
8 class First { 8 class First {
9 First() {} 9 First() {}
10 static var a; 10 static var a;
11 static var b; 11 static var b;
12 static const int c = 1; 12 static const int c = 1;
13 static setValues() { 13 static setValues() {
14 a = 24; 14 a = 24;
15 b = 10; 15 b = 10;
16 return a + b + c; 16 return a + b + c;
17 } 17 }
18 } 18 }
19 19
20
21 class InitializerTest { 20 class InitializerTest {
22 static var one; 21 static var one;
23 static var two = 2; 22 static var two = 2;
24 static var three = 2; 23 static var three = 2;
25 24
26 static checkValueOfThree() { 25 static checkValueOfThree() {
27 // We need to keep this check separate to prevent three from 26 // We need to keep this check separate to prevent three from
28 // getting initialized before the += is executed. 27 // getting initialized before the += is executed.
29 Expect.equals(3, three); 28 Expect.equals(3, three);
30 } 29 }
31 30
32 static void testStaticFieldInitialization() { 31 static void testStaticFieldInitialization() {
33 Expect.equals(null, one); 32 Expect.equals(null, one);
34 Expect.equals(2, two); 33 Expect.equals(2, two);
35 one = 11; 34 one = 11;
36 two = 22; 35 two = 22;
37 Expect.equals(11, one); 36 Expect.equals(11, one);
38 Expect.equals(22, two); 37 Expect.equals(22, two);
39 38
40 // Assignment operators exercise a different code path. Make sure 39 // Assignment operators exercise a different code path. Make sure
41 // that initialization works here as well. 40 // that initialization works here as well.
42 three += 1; 41 three += 1;
43 checkValueOfThree(); 42 checkValueOfThree();
44 } 43 }
45 } 44 }
46 45
47
48 class StaticFieldTest { 46 class StaticFieldTest {
49 static testMain() { 47 static testMain() {
50 First.a = 3; 48 First.a = 3;
51 First.b = First.a; 49 First.b = First.a;
52 Expect.equals(3, First.a); 50 Expect.equals(3, First.a);
53 Expect.equals(First.a, First.b); 51 Expect.equals(First.a, First.b);
54 First.b = (First.a = 10); 52 First.b = (First.a = 10);
55 Expect.equals(10, First.a); 53 Expect.equals(10, First.a);
56 Expect.equals(10, First.b); 54 Expect.equals(10, First.b);
57 First.b = First.a = 15; 55 First.b = First.a = 15;
58 Expect.equals(15, First.a); 56 Expect.equals(15, First.a);
59 Expect.equals(15, First.b); 57 Expect.equals(15, First.b);
60 Expect.equals(35, First.setValues()); 58 Expect.equals(35, First.setValues());
61 Expect.equals(24, First.a); 59 Expect.equals(24, First.a);
62 Expect.equals(10, First.b); 60 Expect.equals(10, First.b);
63 } 61 }
64 } 62 }
65 63
66
67 class StaticField1RunNegativeTest { 64 class StaticField1RunNegativeTest {
68 static // //# 01: static type warning, runtime error 65 static // //# 01: static type warning, runtime error
69 var x; 66 var x;
70 testMain() { 67 testMain() {
71 var foo = new StaticField1RunNegativeTest(); 68 var foo = new StaticField1RunNegativeTest();
72 print(x); // Used to compile 'x' and force any errors. 69 print(x); // Used to compile 'x' and force any errors.
73 var result = foo.x; 70 var result = foo.x;
74 } 71 }
75 } 72 }
76 73
77 class StaticField1aRunNegativeTest { 74 class StaticField1aRunNegativeTest {
78 static // //# 02: static type warning, runtime error 75 static // //# 02: static type warning, runtime error
79 void m() {} 76 void m() {}
80 77
81 testMain() { 78 testMain() {
82 var foo = new StaticField1aRunNegativeTest(); 79 var foo = new StaticField1aRunNegativeTest();
83 print(m); // Used to compile 'm' and force any errors. 80 print(m); // Used to compile 'm' and force any errors.
84 var result = foo.m; 81 var result = foo.m;
85 } 82 }
86 } 83 }
87 84
88 class StaticField2RunNegativeTest { 85 class StaticField2RunNegativeTest {
89 static //# 03: static type warning, runtime error 86 static //# 03: static type warning, runtime error
90 var x; 87 var x;
91 88
92 testMain() { 89 testMain() {
93 var foo = new StaticField2RunNegativeTest(); 90 var foo = new StaticField2RunNegativeTest();
94 print(x); // Used to compile 'x' and force any errors. 91 print(x); // Used to compile 'x' and force any errors.
95 foo.x = 1; 92 foo.x = 1;
96 } 93 }
97 } 94 }
98 95
99 class StaticField2aRunNegativeTest { 96 class StaticField2aRunNegativeTest {
100 static // //# 04: static type warning, runtime error 97 static // //# 04: static type warning, runtime error
101 void m() {} 98 void m() {}
102 99
103 testMain() { 100 testMain() {
104 var foo = new StaticField2aRunNegativeTest(); 101 var foo = new StaticField2aRunNegativeTest();
105 print(m); // Used to compile 'm' and force any errors. 102 print(m); // Used to compile 'm' and force any errors.
106 foo.m = 1; //# 04:continued 103 foo.m = 1; //# 04:continued
107 } 104 }
108 } 105 }
109 106
110 main() { 107 main() {
111 StaticFieldTest.testMain(); 108 StaticFieldTest.testMain();
112 InitializerTest.testStaticFieldInitialization(); 109 InitializerTest.testStaticFieldInitialization();
113 new StaticField1RunNegativeTest().testMain(); 110 new StaticField1RunNegativeTest().testMain();
114 new StaticField1aRunNegativeTest().testMain(); 111 new StaticField1aRunNegativeTest().testMain();
115 new StaticField2RunNegativeTest().testMain(); 112 new StaticField2RunNegativeTest().testMain();
116 new StaticField2aRunNegativeTest().testMain(); 113 new StaticField2aRunNegativeTest().testMain();
117 } 114 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698