| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart Team. All rights reserved. Use of this | 1 // Copyright (c) 2015, the Dart Team. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in | 2 // source code is governed by a BSD-style license that can be found in |
| 3 // the LICENSE file. | 3 // the LICENSE file. |
| 4 | 4 |
| 5 // File being transformed by the reflectable transformer. | 5 // File being transformed by the reflectable transformer. |
| 6 // Implements a very simple kind of proxy object. | 6 // Implements a very simple kind of proxy object. |
| 7 | 7 |
| 8 library test_reflectable.test.proxy_test; | 8 library test_reflectable.test.proxy_test; |
| 9 | 9 |
| 10 import 'package:reflectable/reflectable.dart'; | 10 import 'package:reflectable/reflectable.dart'; |
| 11 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 12 | 12 |
| 13 class ProxyReflectable extends Reflectable { | 13 class ProxyReflectable extends Reflectable { |
| 14 const ProxyReflectable() | 14 const ProxyReflectable() |
| 15 : super(instanceInvokeCapability, typeCapability); | 15 : super(instanceInvokeCapability, declarationsCapability); |
| 16 } | 16 } |
| 17 const proxyReflectable = const ProxyReflectable(); | 17 const proxyReflectable = const ProxyReflectable(); |
| 18 | 18 |
| 19 @proxyReflectable | 19 @proxyReflectable |
| 20 class A { | 20 class A { |
| 21 int i = 0; | 21 int i = 0; |
| 22 String foo() => i == 42 ? "OK!" : "Error!"; | 22 String foo() => i == 42 ? "OK!" : "Error!"; |
| 23 void bar(int i) { | 23 void bar(int i) { |
| 24 this.i = i; | 24 this.i = i; |
| 25 } | 25 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 final A a = new A(); | 61 final A a = new A(); |
| 62 Proxy proxy = new Proxy(a, methodMapForA); | 62 Proxy proxy = new Proxy(a, methodMapForA); |
| 63 | 63 |
| 64 // Use it. | 64 // Use it. |
| 65 test("Using proxy", () { | 65 test("Using proxy", () { |
| 66 proxy.bar(42); | 66 proxy.bar(42); |
| 67 expect(a.i, 42); | 67 expect(a.i, 42); |
| 68 expect(proxy.foo(), "OK!"); | 68 expect(proxy.foo(), "OK!"); |
| 69 }); | 69 }); |
| 70 } | 70 } |
| OLD | NEW |