| 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 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 | 7 |
| 8 class First { | 8 class First { |
| 9 First() {} | 9 First() {} |
| 10 var a; | 10 var a; |
| 11 var b; | 11 var b; |
| 12 | 12 |
| 13 addFields() { | 13 addFields() { |
| 14 return a + b; | 14 return a + b; |
| 15 } | 15 } |
| 16 | 16 |
| 17 setValues() { | 17 setValues() { |
| 18 a = 24; | 18 a = 24; |
| 19 b = 10; | 19 b = 10; |
| 20 return a + b; | 20 return a + b; |
| 21 } | 21 } |
| 22 } | 22 } |
| 23 | 23 |
| 24 class Second extends First { | 24 class Second extends First { |
| 25 // TODO: consider removing once http://b/4254120 is fixed. | 25 // TODO: consider removing once http://b/4254120 is fixed. |
| 26 Second() : super() {} | 26 Second() : super() {} |
| 27 var c; | 27 var c; |
| 28 get a { return -12; } | 28 get a { |
| 29 set b(a) { a.c = 12; } | 29 return -12; |
| 30 } |
| 31 |
| 32 set b(a) { |
| 33 a.c = 12; |
| 34 } |
| 30 } | 35 } |
| 31 | 36 |
| 32 class FieldTest { | 37 class FieldTest { |
| 33 static one() { | 38 static one() { |
| 34 var f = new First(); | 39 var f = new First(); |
| 35 f.a = 3; | 40 f.a = 3; |
| 36 f.b = f.a; | 41 f.b = f.a; |
| 37 Expect.equals(3, f.a); | 42 Expect.equals(3, f.a); |
| 38 Expect.equals(f.a, f.b); | 43 Expect.equals(f.a, f.b); |
| 39 f.b = (f.a = 10); | 44 f.b = (f.a = 10); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 60 o.b = o; | 65 o.b = o; |
| 61 Expect.equals(12, o.c); | 66 Expect.equals(12, o.c); |
| 62 } | 67 } |
| 63 | 68 |
| 64 static testMain() { | 69 static testMain() { |
| 65 // FieldTest.one(); | 70 // FieldTest.one(); |
| 66 FieldTest.two(); | 71 FieldTest.two(); |
| 67 } | 72 } |
| 68 } | 73 } |
| 69 | 74 |
| 70 | |
| 71 main() { | 75 main() { |
| 72 FieldTest.testMain(); | 76 FieldTest.testMain(); |
| 73 } | 77 } |
| OLD | NEW |