| 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 // Uses `invoke`. | 6 // Uses `newInstance`. |
| 7 | 7 |
| 8 library test_reflectable.test.new_instance_test; | 8 library test_reflectable.test.new_instance_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 Reflector extends Reflectable { | 13 class Reflector extends Reflectable { |
| 14 const Reflector() : super(newInstanceCapability); | 14 const Reflector() : super(newInstanceCapability); |
| 15 } | 15 } |
| 16 | 16 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 test('newInstance named constructor, no metadata, none required', () { | 90 test('newInstance named constructor, no metadata, none required', () { |
| 91 ClassMirror classMirror = reflector.reflectType(A); | 91 ClassMirror classMirror = reflector.reflectType(A); |
| 92 expect((classMirror.newInstance("noMeta", [0]) as A).f, 42); | 92 expect((classMirror.newInstance("noMeta", [0]) as A).f, 42); |
| 93 }); | 93 }); |
| 94 test('newInstance named constructor, no metadata, rejected', () { | 94 test('newInstance named constructor, no metadata, rejected', () { |
| 95 ClassMirror classMirror = metaReflector.reflectType(A); | 95 ClassMirror classMirror = metaReflector.reflectType(A); |
| 96 expect(() => classMirror.newInstance("noMeta", [0]), throwsNoCapability); | 96 expect(() => classMirror.newInstance("noMeta", [0]), throwsNoCapability); |
| 97 }); | 97 }); |
| 98 } | 98 } |
| OLD | NEW |