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

Unified 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, 1 month 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test_reflectable/test/dynamic_reflected_type_test.dart
diff --git a/test_reflectable/test/dynamic_reflected_type_test.dart b/test_reflectable/test/dynamic_reflected_type_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..729f50a7301d270fabd973d608657568d0ae5004
--- /dev/null
+++ b/test_reflectable/test/dynamic_reflected_type_test.dart
@@ -0,0 +1,45 @@
+// Copyright (c) 2015, the Dart Team. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+
+// File being transformed by the reflectable transformer.
+// Uses `dynamicReflectedType`.
+
+library test_reflectable.test.dynamic_reflected_type_test;
+
+import 'package:reflectable/reflectable.dart';
+import 'package:unittest/unittest.dart';
+
+class Reflector extends Reflectable {
+ const Reflector() : super(typeCapability);
+}
+
+const reflector = const Reflector();
+
+@reflector
+class A {}
+
+@reflector
+class B<E> {}
+
+Matcher throwsUnsupported = throwsA(const isInstanceOf<UnsupportedError>());
+
+void testDynamicReflectedType(
+ String message, ClassMirror classMirror, Type expectedType) {
+ test('Dynamic reflected type, $message', () {
+ if (classMirror.hasDynamicReflectedType) {
+ expect(classMirror.dynamicReflectedType, expectedType);
+ } else {
+ expect(() => classMirror.dynamicReflectedType, throwsUnsupported);
+ }
+ });
+}
+
+main() {
+ ClassMirror aMirror = reflector.reflectType(A);
+ ClassMirror bMirror = reflector.reflectType(B);
+ ClassMirror bInstantiationMirror = reflector.reflect(new B<int>()).type;
+ testDynamicReflectedType('non-generic class', aMirror, A);
+ testDynamicReflectedType('generic class', bMirror, B);
+ testDynamicReflectedType('generic instantiation', bInstantiationMirror, B);
+}
« 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