Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 class ParameterInitializerTest { | 7 class ParameterInitializerTest { |
| 8 | 8 |
| 9 static testMain() { | 9 static testMain() { |
| 10 var obj = new Foo.untyped(1); | 10 |
| 11 var /*obj = new Foo.untyped(1); | |
| 11 Expect.equals(1, obj.x); | 12 Expect.equals(1, obj.x); |
| 12 | 13 |
| 13 obj = new Foo.supertype(9); | 14 obj = new Foo.supertype(9); |
| 14 Expect.equals(9, obj.x); | 15 Expect.equals(9, obj.x); |
| 15 | 16 |
| 16 obj = new Foo.subtype(7); | 17 obj = new Foo.subtype(7); |
| 17 Expect.equals(7, obj.x); | 18 Expect.equals(7, obj.x); |
| 18 | 19 |
| 19 obj = new Foo.optional(111); | 20 obj = new Foo.optional(111); |
| 20 Expect.equals(111, obj.x); | 21 Expect.equals(111, obj.x); |
| 21 | 22 |
| 22 obj = new Foo.optional(); | 23 obj = new Foo.optional(); |
| 23 Expect.equals(5, obj.x); | 24 Expect.equals(5, obj.x); |
| 24 | 25 |
| 25 obj = new Foo(1); | 26 obj = new Foo(1); |
| 26 Expect.equals(2, obj.x); | 27 Expect.equals(2, obj.x); |
| 27 | 28 |
| 28 obj = new SubFoo(42); | 29 obj = new SubFoo(42); |
| 29 Expect.equals(1, obj.x); | 30 Expect.equals(1, obj.x); |
| 30 | 31 */ |
|
asgerf
2015/03/19 11:31:13
Clean up.
sra1
2015/03/19 16:54:25
Done.
| |
| 31 obj = new SubSubFoo(42); | 32 obj = new SubSubFoo(42); |
| 32 Expect.equals(1, obj.x); | 33 Expect.equals(1, obj.x); |
| 33 } | 34 } |
| 34 } | 35 } |
| 35 | 36 |
| 36 class Foo { | 37 class Foo { |
| 37 Foo(num this.x) { | 38 Foo(num this.x) { |
| 38 // Reference to x must resolve to the field. | 39 // Reference to x must resolve to the field. |
| 39 x++; | 40 x++; |
| 40 Expect.equals(this.x, x); | 41 Expect.equals(this.x, x); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 Expect.equals(x_, 1); | 77 Expect.equals(x_, 1); |
| 77 | 78 |
| 78 // There is no way to get to the field in Foo. | 79 // There is no way to get to the field in Foo. |
| 79 Expect.equals(super.x, 1); | 80 Expect.equals(super.x, 1); |
| 80 } | 81 } |
| 81 } | 82 } |
| 82 | 83 |
| 83 main() { | 84 main() { |
| 84 ParameterInitializerTest.testMain(); | 85 ParameterInitializerTest.testMain(); |
| 85 } | 86 } |
| OLD | NEW |