| OLD | NEW |
| 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 // Dart test program for testing setting/getting of instance fields. | 4 // Dart test program for testing setting/getting of instance fields. |
| 5 | 5 |
| 6 class First { | 6 class First { |
| 7 First() {} | 7 First() {} |
| 8 var a; | 8 var a; |
| 9 var b; | 9 var b; |
| 10 | 10 |
| 11 addFields() { | 11 addFields() { |
| 12 return a + b; | 12 return a + b; |
| 13 } | 13 } |
| 14 | 14 |
| 15 setValues() { | 15 setValues() { |
| 16 a = 24; | 16 a = 24; |
| 17 b = 10; | 17 b = 10; |
| 18 return a + b; | 18 return a + b; |
| 19 } | 19 } |
| 20 } | 20 } |
| 21 | 21 |
| 22 class Second extends First { | 22 class Second extends First { |
| 23 // TODO: consider removing once http://b/4254120 is fixed. | 23 // TODO: consider removing once http://b/4254120 is fixed. |
| 24 Second() : super() {} | 24 Second() : super() {} |
| 25 var c; | 25 var c; |
| 26 get a() { return -12; } | 26 get a { return -12; } |
| 27 set b(a) { a.c = 12; } | 27 set b(a) { a.c = 12; } |
| 28 } | 28 } |
| 29 | 29 |
| 30 class FieldTest { | 30 class FieldTest { |
| 31 static one() { | 31 static one() { |
| 32 var f = new First(); | 32 var f = new First(); |
| 33 f.a = 3; | 33 f.a = 3; |
| 34 f.b = f.a; | 34 f.b = f.a; |
| 35 Expect.equals(3, f.a); | 35 Expect.equals(3, f.a); |
| 36 Expect.equals(f.a, f.b); | 36 Expect.equals(f.a, f.b); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 62 static testMain() { | 62 static testMain() { |
| 63 // FieldTest.one(); | 63 // FieldTest.one(); |
| 64 FieldTest.two(); | 64 FieldTest.two(); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 | 68 |
| 69 main() { | 69 main() { |
| 70 FieldTest.testMain(); | 70 FieldTest.testMain(); |
| 71 } | 71 } |
| OLD | NEW |