Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(504)

Side by Side Diff: test/codegen/lib/mirrors/intercepted_object_test.dart

Issue 2265533002: Add mirrors tests (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Ensure that objects handled specially by dart2js can be reflected on.
6
7 library test.intercepted_object_test;
8
9 import 'dart:mirrors';
10
11 import 'stringify.dart' show stringify, expect;
12
13 import 'intercepted_class_test.dart' show checkClassMirrorMethods;
14
15 checkImplements(object, String name) {
16 ClassMirror cls = reflect(object).type;
17 checkClassMirrorMethods(cls);
18
19 // The VM implements List via a mixin, so check for that.
20 if (cls.superinterfaces.isEmpty && object is List) {
21 cls = cls.superclass.superclass.mixin;
22 }
23
24 List<ClassMirror> superinterfaces = cls.superinterfaces;
25 String symName = 's($name)';
26 for (ClassMirror superinterface in superinterfaces) {
27 print(superinterface.simpleName);
28 if (symName == stringify(superinterface.simpleName)) {
29 checkClassMirrorMethods(superinterface);
30 return;
31 }
32 }
33
34 // A class implements itself, even if not explicitly declared.
35 if (symName == stringify(cls.simpleName)) {
36 checkClassMirrorMethods(cls);
37 return;
38 }
39
40 // TODO(floitsch): use correct fail
41 expect(name, "super interface not found");
42 }
43
44 main() {
45 checkImplements('', 'String');
46 checkImplements(1, 'int');
47 checkImplements(1.5, 'double');
48 checkImplements(true, 'bool');
49 checkImplements(false, 'bool');
50 checkImplements([], 'List');
51 }
OLDNEW
« no previous file with comments | « test/codegen/lib/mirrors/intercepted_class_test.dart ('k') | test/codegen/lib/mirrors/intercepted_superclass_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698