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

Side by Side Diff: tests/lib/mirrors/generic_bounded_test.dart

Issue 26772002: Mirror tests for type bounds. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
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.generic_bounded;
6
7 import 'dart:mirrors';
8
9 import 'package:expect/expect.dart';
10
11 import 'generics_test.dart';
12
13 class Super<T extends num> {}
14
15 class Fixed extends Super<int> {}
16 class Generic<R> extends Super<R> {}
17 class Malbounded extends Super<String> {} /// 01: static type warning
ahe 2013/10/10 15:22:51 See my comments in the previous file. Most of them
18
19 main() {
20 ClassMirror superDecl = reflectClass(Super);
21 ClassMirror superOfInt = reflectClass(Fixed).superclass;
ahe 2013/10/10 15:22:51 I'd call this superOfFixed.
22 ClassMirror genericDecl = reflectClass(Generic);
23 ClassMirror superOfR = genericDecl.superclass;
24 ClassMirror genericOfDouble = reflect(new Generic<double>()).type;
25 ClassMirror superOfDouble = genericOfDouble.superclass;
26 ClassMirror genericOfBool = reflect(new Generic<bool>()).type; /// 02: static type warning, dynamic type error
27 ClassMirror superOfBool = genericOfBool.superclass; /// 02: continued
28 ClassMirror superOfString = reflectClass(Malbounded).superclass; /// 01: cont inued
29
30 Expect.isTrue(superDecl.isOriginalDeclaration);
31 Expect.isFalse(superOfInt.isOriginalDeclaration);
32 Expect.isTrue(genericDecl.isOriginalDeclaration);
33 Expect.isFalse(superOfR.isOriginalDeclaration);
34 Expect.isFalse(genericOfDouble.isOriginalDeclaration);
35 Expect.isFalse(superOfDouble.isOriginalDeclaration);
36 Expect.isFalse(genericOfBool.isOriginalDeclaration); /// 02: continued
37 Expect.isFalse(superOfBool.isOriginalDeclaration); /// 02: continued
38 Expect.isFalse(superOfString.isOriginalDeclaration); /// 01: continued
39
40 TypeVariableMirror tFromSuper = superDecl.typeVariables.single;
41 TypeVariableMirror rFromGeneric = genericDecl.typeVariables.single;
42
43 Expect.equals(reflectClass(num), tFromSuper.upperBound);
44 Expect.equals(reflectClass(Object), rFromGeneric.upperBound);
45
46 typeParameters(superDecl, [#T]);
47 typeParameters(superOfInt, [#T]);
48 typeParameters(genericDecl, [#R]);
49 typeParameters(superOfR, [#T]);
50 typeParameters(genericOfDouble, [#R]);
51 typeParameters(superOfDouble, [#T]);
52 typeParameters(genericOfBool, [#R]); /// 02: continued
53 typeParameters(superOfBool, [#T]); /// 02: continued
54 typeParameters(superOfString, [#T]); /// 01: continued
55
56 typeArguments(superDecl, []);
57 typeArguments(superOfInt, [reflectClass(int)]);
58 typeArguments(genericDecl, []);
59 typeArguments(superOfR, [rFromGeneric]);
60 typeArguments(genericOfDouble, [reflectClass(double)]);
61 typeArguments(superOfDouble, [reflectClass(double)]);
62 typeArguments(genericOfBool, [reflectClass(bool)]); /// 02: continued
63 typeArguments(superOfBool, [reflectClass(bool)]); /// 02: continued
64 typeArguments(superOfString, [reflectClass(String)]); /// 01: continued
65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698