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

Unified Diff: test/codegen/lib/mirrors/return_type_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 side-by-side diff with in-line comments
Download patch
Index: test/codegen/lib/mirrors/return_type_test.dart
diff --git a/test/codegen/lib/mirrors/return_type_test.dart b/test/codegen/lib/mirrors/return_type_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..547e7610fb2e1fb97045d3482deacf643e24d75f
--- /dev/null
+++ b/test/codegen/lib/mirrors/return_type_test.dart
@@ -0,0 +1,48 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/// Test of [MethodMirror.returnType].
+library test.return_type_test;
+
+@MirrorsUsed(targets: 'test.return_type_test', override: '*')
+import 'dart:mirrors';
+
+import 'stringify.dart';
+
+class B {
+ f() {}
+ int g() {}
+ List h() {}
+ B i() {}
+
+ // TODO(ahe): Test this when dart2js handles parameterized types.
+ // List<int> j() {}
+}
+
+methodsOf(ClassMirror cm) {
+ var result = new Map();
+ cm.declarations.forEach((k,v) {
+ if(v is MethodMirror && v.isRegularMethod) result[k] = v;
+ });
+ return result;
+}
+
+main() {
+ var methods = methodsOf(reflectClass(B));
+
+ expect('{f: Method(s(f) in s(B)), '
+ 'g: Method(s(g) in s(B)), '
+ 'h: Method(s(h) in s(B)), '
+ 'i: Method(s(i) in s(B))}', methods);
+
+ var f = methods[#f];
+ var g = methods[#g];
+ var h = methods[#h];
+ var i = methods[#i];
+
+ expect('Type(s(dynamic), top-level)', f.returnType);
+ expect('Class(s(int) in s(dart.core), top-level)', g.returnType);
+ expect('Class(s(List) in s(dart.core), top-level)', h.returnType);
+ expect('Class(s(B) in s(test.return_type_test), top-level)', i.returnType);
+}
« no previous file with comments | « test/codegen/lib/mirrors/repeated_private_anon_mixin_app_test.dart ('k') | test/codegen/lib/mirrors/runtime_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698