OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // |
| 5 // Test that ensures that fields can be accessed dynamically. |
| 6 |
| 7 import "package:expect/expect.dart"; |
| 8 |
| 9 class C { |
| 10 final x = "hello"; |
| 11 get y => ", "; |
| 12 m() => "world!"; |
| 13 } |
| 14 |
| 15 // Regression test for https://github.com/dart-lang/sdk/issues/27258 |
| 16 main() { |
| 17 dynamic c = new C(); |
| 18 Expect.equals(c.x + c.y + c.m(), "hello, world!"); |
| 19 |
| 20 Expect.throws(() { |
| 21 c.x = 1; |
| 22 }); |
| 23 Expect.throws(() { |
| 24 c.x = '1'; |
| 25 }); |
| 26 Expect.throws(() { |
| 27 c.y = '2'; |
| 28 }); |
| 29 Expect.throws(() { |
| 30 c.m = '3'; |
| 31 }); |
| 32 |
| 33 Expect.equals(c.x + c.y + c.m(), "hello, world!"); |
| 34 } |
OLD | NEW |