| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 | 4 |
| 5 // Ensure that objects handled specially by dart2js can be reflected on. | 5 // Ensure that objects handled specially by dart2js can be reflected on. |
| 6 | 6 |
| 7 library test.intercepted_object_test; | 7 library test.intercepted_object_test; |
| 8 | 8 |
| 9 import 'dart:mirrors'; | 9 import 'dart:mirrors'; |
| 10 | 10 |
| 11 import 'stringify.dart' show stringify, expect; | 11 import 'stringify.dart' show stringify, expect; |
| 12 | 12 |
| 13 import 'intercepted_class_test.dart' show checkClassMirrorMethods; | 13 import 'intercepted_class_test.dart' show checkClassMirrorMethods; |
| 14 | 14 |
| 15 checkImplements(object, String name) { | 15 checkImplements(object, String name) { |
| 16 ClassMirror cls = reflect(object).type; | 16 ClassMirror cls = reflect(object).type; |
| 17 checkClassMirrorMethods(cls); | 17 checkClassMirrorMethods(cls); |
| 18 | 18 |
| 19 List<ClassMirror> superinterfaces = cls.superinterfaces; | 19 List<ClassMirror> superinterfaces = cls.superinterfaces; |
| 20 String symName = 's($name)'; | 20 String symName = 's($name)'; |
| 21 for (ClassMirror superinterface in superinterfaces) { | 21 for (ClassMirror superinterface in superinterfaces) { |
| 22 print(superinterface.simpleName); | 22 print(superinterface.simpleName); |
| 23 if (symName == stringify(superinterface.simpleName)) { | 23 if (symName == stringify(superinterface.simpleName)) { |
| 24 checkClassMirrorMethods(superinterface); | 24 checkClassMirrorMethods(superinterface); |
| 25 return; | 25 return; |
| 26 } | 26 } |
| 27 } | 27 } |
| 28 |
| 29 // A class implements itself, even if not explicitly declared. |
| 30 if (symName == stringify(cls.simpleName)) { |
| 31 checkClassMirrorMethods(cls); |
| 32 return; |
| 33 } |
| 28 | 34 |
| 29 // TODO(floitsch): use correct fail | 35 // TODO(floitsch): use correct fail |
| 30 expect(name, "super interface not found"); | 36 expect(name, "super interface not found"); |
| 31 } | 37 } |
| 32 | 38 |
| 33 main() { | 39 main() { |
| 34 checkImplements('', 'String'); | 40 checkImplements('', 'String'); |
| 35 checkImplements(1, 'int'); | 41 checkImplements(1, 'int'); |
| 36 checkImplements(1.5, 'double'); | 42 checkImplements(1.5, 'double'); |
| 37 checkImplements(true, 'bool'); | 43 checkImplements(true, 'bool'); |
| 38 checkImplements(false, 'bool'); | 44 checkImplements(false, 'bool'); |
| 39 checkImplements([], 'List'); | 45 checkImplements([], 'List'); |
| 40 } | 46 } |
| OLD | NEW |