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

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

Issue 10837359: Language tests updated to use const instead of final. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 8 years, 4 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/language/ct_const_test.dart ('k') | tests/language/index_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) 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 4
5 // Tests static and instance fields initialization. 5 // Tests static and instance fields initialization.
6 class DefaultInitTest { 6 class DefaultInitTest {
7 static testMain() { 7 static testMain() {
8 Expect.equals(0, A.a); 8 Expect.equals(0, A.a);
9 Expect.equals(2, A.b); 9 Expect.equals(2, A.b);
10 Expect.equals(null, A.c); 10 Expect.equals(null, A.c);
11 11
12 A a1 = new A(42); 12 A a1 = new A(42);
13 Expect.equals(42, a1.d); 13 Expect.equals(42, a1.d);
14 Expect.equals(null, a1.e); 14 Expect.equals(null, a1.e);
15 15
16 A a2 = new A.named(43); 16 A a2 = new A.named(43);
17 Expect.equals(null, a2.d); 17 Expect.equals(null, a2.d);
18 Expect.equals(43, a2.e); 18 Expect.equals(43, a2.e);
19 19
20 Expect.equals(42, B.instance.x); 20 Expect.equals(42, B.instance.x);
21 Expect.equals(3, C.instance.z); 21 Expect.equals(3, C.instance.z);
22 } 22 }
23 } 23 }
24 24
25 class A { 25 class A {
26 static final int a = 0; 26 static const int a = 0;
27 static final int b = 2; 27 static const int b = 2;
28 static int c; 28 static int c;
29 int d; 29 int d;
30 int e; 30 int e;
31 31
32 A(int val) { 32 A(int val) {
33 d = val; 33 d = val;
34 } 34 }
35 35
36 A.named(int val) { 36 A.named(int val) {
37 e = val; 37 e = val;
38 } 38 }
39 } 39 }
40 40
41 // The following tests cover cases described in b/4101270 41 // The following tests cover cases described in b/4101270
42 42
43 class B { 43 class B {
44 static final B instance = const B(); 44 static const B instance = const B();
45 // by putting this field after the static initializer above, the JS code gen 45 // by putting this field after the static initializer above, the JS code gen
46 // was calling the constructor before the setter of this property was defined. 46 // was calling the constructor before the setter of this property was defined.
47 final int x; 47 final int x;
48 const B() : this.x = (41 + 1); 48 const B() : this.x = (41 + 1);
49 } 49 }
50 50
51 class C { 51 class C {
52 // forward reference to another class 52 // forward reference to another class
53 static final D instance = const D(); 53 static const D instance = const D();
54 C() {} 54 C() {}
55 } 55 }
56 56
57 class D { 57 class D {
58 const D(): this.z = 3; 58 const D(): this.z = 3;
59 final int z; 59 final int z;
60 } 60 }
61 61
62 main() { 62 main() {
63 DefaultInitTest.testMain(); 63 DefaultInitTest.testMain();
64 } 64 }
OLDNEW
« no previous file with comments | « tests/language/ct_const_test.dart ('k') | tests/language/index_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698