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

Side by Side Diff: test_reflectable/test/dynamic_reflected_type_test.dart

Issue 1473073009: Added `dynamicReflected..Type`, corrected type expressions. (Closed) Base URL: https://github.com/dart-lang/reflectable.git@master
Patch Set: Review response. Created 5 years 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
« no previous file with comments | « test_reflectable/pubspec.yaml ('k') | test_reflectable/test/new_instance_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // the LICENSE file.
4
5 // File being transformed by the reflectable transformer.
6 // Uses `dynamicReflectedType`.
7
8 library test_reflectable.test.dynamic_reflected_type_test;
9
10 import 'package:reflectable/reflectable.dart';
11 import 'package:unittest/unittest.dart';
12
13 class Reflector extends Reflectable {
14 const Reflector() : super(typeCapability);
15 }
16
17 const reflector = const Reflector();
18
19 @reflector
20 class A {}
21
22 @reflector
23 class B<E> {}
24
25 Matcher throwsUnsupported = throwsA(const isInstanceOf<UnsupportedError>());
26
27 void testDynamicReflectedType(
28 String message, ClassMirror classMirror, Type expectedType) {
29 test('Dynamic reflected type, $message', () {
30 if (classMirror.hasDynamicReflectedType) {
31 expect(classMirror.dynamicReflectedType, expectedType);
32 } else {
33 expect(() => classMirror.dynamicReflectedType, throwsUnsupported);
34 }
35 });
36 }
37
38 main() {
39 ClassMirror aMirror = reflector.reflectType(A);
40 ClassMirror bMirror = reflector.reflectType(B);
41 ClassMirror bInstantiationMirror = reflector.reflect(new B<int>()).type;
42 testDynamicReflectedType('non-generic class', aMirror, A);
43 testDynamicReflectedType('generic class', bMirror, B);
44 testDynamicReflectedType('generic instantiation', bInstantiationMirror, B);
45 }
OLDNEW
« no previous file with comments | « test_reflectable/pubspec.yaml ('k') | test_reflectable/test/new_instance_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698