| OLD | NEW |
| (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 // Test Parameter Intializer. | |
| 6 | |
| 7 | |
| 8 class ParameterInitializer2Test { | |
| 9 static testMain() { | |
| 10 var a = new A(123); | |
| 11 Expect.equals(123, a.x); | |
| 12 | |
| 13 var b = new B(123); | |
| 14 Expect.equals(123, b.x); | |
| 15 | |
| 16 var c = new C(123); | |
| 17 Expect.equals(123, c.x); | |
| 18 | |
| 19 var d = new D(123); | |
| 20 Expect.equals(123, d.x); | |
| 21 | |
| 22 var e = new E(1); | |
| 23 Expect.equals(4, e.x); | |
| 24 | |
| 25 var f = new F(1,2,3,4); | |
| 26 Expect.equals(4, f.z); | |
| 27 } | |
| 28 } | |
| 29 | |
| 30 // untyped | |
| 31 class A { | |
| 32 A(this.x) { | |
| 33 } | |
| 34 int x; | |
| 35 } | |
| 36 | |
| 37 // typed | |
| 38 class B { | |
| 39 B(int this.x) { | |
| 40 } | |
| 41 int x; | |
| 42 } | |
| 43 | |
| 44 // const typed | |
| 45 class C { | |
| 46 const C(int this.x); | |
| 47 final int x; | |
| 48 } | |
| 49 | |
| 50 // const untyped | |
| 51 class D { | |
| 52 const D(this.x); | |
| 53 final x; | |
| 54 } | |
| 55 | |
| 56 // make sure this.<X> references work properly in the constructor scope. | |
| 57 class E { | |
| 58 E(this.x) { | |
| 59 var myVar = this.x * 2; | |
| 60 this.x = myVar + 1; | |
| 61 x = myVar + 2; | |
| 62 var foo = x + 1; | |
| 63 } | |
| 64 int x; | |
| 65 } | |
| 66 | |
| 67 | |
| 68 // mixed | |
| 69 class F { | |
| 70 F(x, this.y_, int w, int this.z) : x_ = x, w_ = w { } | |
| 71 F.foobar(this.z, int this.x_, int this.az_) { } | |
| 72 int x_; | |
| 73 int y_; | |
| 74 int w_; | |
| 75 int z; | |
| 76 int az_; | |
| 77 } | |
| 78 | |
| 79 | |
| 80 main() { | |
| 81 ParameterInitializer2Test.testMain(); | |
| 82 } | |
| OLD | NEW |