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

Side by Side Diff: test/codegen/lib/mirrors/generics_substitution_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 library test.generics_substitution;
6
7 import 'dart:mirrors';
8 import 'package:expect/expect.dart';
9
10 class SuperGeneric<R, S> {
11 R r;
12 s(S s) {}
13 }
14
15 class Generic<T> extends SuperGeneric<T, int> {
16 T t() {}
17 }
18
19 main() {
20 ClassMirror genericDecl = reflectClass(Generic);
21 ClassMirror genericOfString = reflect(new Generic<String>()).type;
22 ClassMirror superGenericDecl = reflectClass(SuperGeneric);
23 ClassMirror superOfTAndInt = genericDecl.superclass;
24 ClassMirror superOfStringAndInt = genericOfString.superclass;
25
26 Expect.isTrue(genericDecl.isOriginalDeclaration);
27 Expect.isFalse(genericOfString.isOriginalDeclaration);
28 Expect.isTrue(superGenericDecl.isOriginalDeclaration);
29 Expect.isFalse(superOfTAndInt.isOriginalDeclaration);
30 Expect.isFalse(superOfStringAndInt.isOriginalDeclaration);
31
32 Symbol r(ClassMirror cm) =>
33 (cm.declarations[#r] as VariableMirror).type.simpleName;
34 Symbol s(ClassMirror cm) =>
35 (cm.declarations[#s] as MethodMirror).parameters[0].type.simpleName;
36 Symbol t(ClassMirror cm) =>
37 (cm.declarations[#t] as MethodMirror).returnType.simpleName;
38
39 Expect.equals(#T, r(genericDecl.superclass));
40 Expect.equals(#int, s(genericDecl.superclass));
41 Expect.equals(#T, t(genericDecl));
42
43 Expect.equals(#String, r(genericOfString.superclass));
44 Expect.equals(#int, s(genericOfString.superclass));
45 Expect.equals(#String, t(genericOfString));
46
47 Expect.equals(#R, r(superGenericDecl));
48 Expect.equals(#S, s(superGenericDecl));
49
50 Expect.equals(#T, r(superOfTAndInt));
51 Expect.equals(#int, s(superOfTAndInt));
52
53 Expect.equals(#String, r(superOfStringAndInt));
54 Expect.equals(#int, s(superOfStringAndInt));
55 }
OLDNEW
« no previous file with comments | « test/codegen/lib/mirrors/generics_special_types_test.dart ('k') | test/codegen/lib/mirrors/generics_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698