| 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 fields when | 4 // Dart test program for testing setting/getting of fields when |
| 5 // only getter/setter methods are specified. | 5 // only getter/setter methods are specified. |
| 6 | 6 |
| 7 class First { | 7 class First { |
| 8 First(int val) : a_ = val { } | 8 First(int val) : a_ = val { } |
| 9 | 9 |
| 10 void testMethod() { | 10 void testMethod() { |
| 11 a = 20; | 11 a = 20; |
| 12 } | 12 } |
| 13 static void testStaticMethod() { | 13 static void testStaticMethod() { |
| 14 b = 20; | 14 b = 20; |
| 15 } | 15 } |
| 16 | 16 |
| 17 int get a() { | 17 int get a { |
| 18 return a_; | 18 return a_; |
| 19 } | 19 } |
| 20 void set a(int val) { | 20 void set a(int val) { |
| 21 a_ = a_ + val; | 21 a_ = a_ + val; |
| 22 } | 22 } |
| 23 | 23 |
| 24 static int get b() { | 24 static int get b { |
| 25 return b_; | 25 return b_; |
| 26 } | 26 } |
| 27 static void set b(int val) { | 27 static void set b(int val) { |
| 28 b_ = val; | 28 b_ = val; |
| 29 } | 29 } |
| 30 | 30 |
| 31 int a_; | 31 int a_; |
| 32 static int b_; | 32 static int b_; |
| 33 } | 33 } |
| 34 | 34 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 45 | 45 |
| 46 static void testStaticMethod() { | 46 static void testStaticMethod() { |
| 47 int i; | 47 int i; |
| 48 b = 20; | 48 b = 20; |
| 49 i = d; | 49 i = d; |
| 50 // TODO(asiva): Turn these on once we have error handling. | 50 // TODO(asiva): Turn these on once we have error handling. |
| 51 // i = b; // Should be an error. | 51 // i = b; // Should be an error. |
| 52 // d = 40; // Should be an error. | 52 // d = 40; // Should be an error. |
| 53 } | 53 } |
| 54 | 54 |
| 55 int get a() { | 55 int get a { |
| 56 return a_; | 56 return a_; |
| 57 } | 57 } |
| 58 void set a(int value) { | 58 void set a(int value) { |
| 59 a_ = a_ + value; | 59 a_ = a_ + value; |
| 60 } | 60 } |
| 61 | 61 |
| 62 static void set b(int value) { | 62 static void set b(int value) { |
| 63 Second.c = value; | 63 Second.c = value; |
| 64 } | 64 } |
| 65 static int get d() { | 65 static int get d { |
| 66 return Second.c; | 66 return Second.c; |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 | 69 |
| 70 | 70 |
| 71 class Setter1Test { | 71 class Setter1Test { |
| 72 static testMain() { | 72 static testMain() { |
| 73 First obj1 = new First(10); | 73 First obj1 = new First(10); |
| 74 Expect.equals(10, obj1.a); | 74 Expect.equals(10, obj1.a); |
| 75 obj1.testMethod(); | 75 obj1.testMethod(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 87 Second.testStaticMethod(); | 87 Second.testStaticMethod(); |
| 88 Expect.equals(20, Second.c); | 88 Expect.equals(20, Second.c); |
| 89 Expect.equals(20, Second.d); | 89 Expect.equals(20, Second.d); |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 | 93 |
| 94 main() { | 94 main() { |
| 95 Setter1Test.testMain(); | 95 Setter1Test.testMain(); |
| 96 } | 96 } |
| OLD | NEW |