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

Side by Side Diff: tests/language/src/ParameterInitializerTest.dart

Issue 10248007: test rename overhaul: step 8 - language tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 class ParameterInitializerTest {
6
7 static testMain() {
8 var obj = new Foo.untyped(1);
9 Expect.equals(1, obj.x);
10
11 obj = new Foo.supertype(9);
12 Expect.equals(9, obj.x);
13
14 obj = new Foo.subtype(7);
15 Expect.equals(7, obj.x);
16
17 obj = new Foo.optional(x: 111);
18 Expect.equals(111, obj.x);
19
20 obj = new Foo.optional();
21 Expect.equals(5, obj.x);
22
23 obj = new Foo.optional_private(_y: 222);
24 Expect.equals(222, obj._y);
25
26 obj = new Foo.optional_private();
27 Expect.equals(77, obj._y);
28
29 obj = new Foo(1);
30 Expect.equals(2, obj.x);
31
32 obj = new SubFoo(42);
33 Expect.equals(1, obj.x);
34
35 obj = new SubSubFoo(42);
36 Expect.equals(1, obj.x);
37 }
38 }
39
40 class Foo {
41 Foo(num this.x) {
42 // Reference to x must resolve to the field.
43 x++;
44 Expect.equals(this.x, x);
45 }
46
47 Foo.untyped(this.x) {}
48 Foo.supertype(Object this.x) {}
49 Foo.subtype(int this.x) {}
50 Foo.optional([this.x = 5]) {}
51 Foo.optional_private([this._y = 77]) {}
52
53 num x;
54 num _y;
55 }
56
57 class SubFoo extends Foo {
58 SubFoo(num y) : super(y), x_ = 0 {
59 // Subfoo.setter of x has been invoked in the Foo constructor.
60 Expect.equals(x, 1);
61 Expect.equals(x_, 1);
62
63 // The super.x will resolved to the field in Foo.
64 Expect.equals(super.x, y);
65 }
66
67 get x() {
68 return x_;
69 }
70
71 set x(num val) {
72 x_ = val;
73 }
74
75 num x_;
76 }
77
78 class SubSubFoo extends SubFoo {
79 SubSubFoo(num y) : super(y) {
80 // Subfoo.setter of x has been invoked in the Foo constructor.
81 Expect.equals(x, 1);
82 Expect.equals(x_, 1);
83
84 // There is no way to get to the field in Foo.
85 Expect.equals(super.x, 1);
86 }
87 }
88
89 main() {
90 ParameterInitializerTest.testMain();
91 }
OLDNEW
« no previous file with comments | « tests/language/src/ParameterInitializer5NegativeTest.dart ('k') | tests/language/src/ParseTypesTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698