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

Unified Diff: tests/lib/mirrors/constructor_kinds_test.dart

Issue 25609003: Add missing test coverage for constructor kinds, generic function typedefs and generic mixin applic… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/lib/lib.status ('k') | tests/lib/mirrors/constructors_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/mirrors/constructor_kinds_test.dart
diff --git a/tests/lib/mirrors/constructor_kinds_test.dart b/tests/lib/mirrors/constructor_kinds_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f3339ca844e068deb948027e1289f485ccc3dd13
--- /dev/null
+++ b/tests/lib/mirrors/constructor_kinds_test.dart
@@ -0,0 +1,104 @@
+// 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.
+
+library test.constructor_kinds_test;
+
+import 'dart:mirrors';
+import 'package:expect/expect.dart';
+
+class ClassWithDefaultConstructor {}
+
+class Class {
+ Class.generative();
+ Class.redirectingGenerative() : this.generative();
+ factory Class.faktory () => new Class.generative();
+ factory Class.redirectingFactory() = Class.faktory;
+
+ const Class.constGenerative();
+ const Class.constRedirectingGenerative() : this.constGenerative();
+ // Not legal.
+ // const factory Class.constFaktory () => const Class.constGenerative();
+ const factory Class.constRedirectingFactory() = Class.constGenerative;
+}
+
+main() {
+ ClassMirror cm;
+ MethodMirror mm;
+
+ new Class.generative();
+ new Class.redirectingGenerative();
+ new Class.faktory();
+ new Class.redirectingFactory();
+ const Class.constGenerative();
+ const Class.constRedirectingGenerative();
+ const Class.constRedirectingFactory();
+
+ cm = reflectClass(ClassWithDefaultConstructor);
+ mm = cm.constructors.values.single;
+ Expect.isTrue(mm.isConstructor);
+ Expect.isTrue(mm.isGenerativeConstructor);
+ Expect.isFalse(mm.isFactoryConstructor);
+ Expect.isFalse(mm.isRedirectingConstructor);
+ Expect.isFalse(mm.isConstConstructor);
+
+
+ cm = reflectClass(Class);
+
+ mm = cm.constructors[#generative];
+ Expect.isTrue(mm.isConstructor);
+ Expect.isTrue(mm.isGenerativeConstructor);
+ Expect.isFalse(mm.isFactoryConstructor);
+ Expect.isFalse(mm.isRedirectingConstructor);
+ Expect.isFalse(mm.isConstConstructor);
+
+ mm = cm.constructors[#redirectingGenerative];
+ Expect.isTrue(mm.isConstructor);
+ Expect.isTrue(mm.isGenerativeConstructor);
+ Expect.isFalse(mm.isFactoryConstructor);
+ Expect.isTrue(mm.isRedirectingConstructor);
+ Expect.isFalse(mm.isConstConstructor);
+
+ mm = cm.constructors[#faktory];
+ Expect.isTrue(mm.isConstructor);
+ Expect.isFalse(mm.isGenerativeConstructor);
+ Expect.isTrue(mm.isFactoryConstructor);
+ Expect.isFalse(mm.isRedirectingConstructor);
+ Expect.isFalse(mm.isConstConstructor);
+
+ mm = cm.constructors[#redirectingFactory];
+ Expect.isTrue(mm.isConstructor);
+ Expect.isFalse(mm.isGenerativeConstructor);
+ Expect.isTrue(mm.isFactoryConstructor);
+ Expect.isTrue(mm.isRedirectingConstructor);
+ Expect.isFalse(mm.isConstConstructor);
+
+ mm = cm.constructors[#constGenerative];
+ Expect.isTrue(mm.isConstructor);
+ Expect.isTrue(mm.isGenerativeConstructor);
+ Expect.isFalse(mm.isFactoryConstructor);
+ Expect.isFalse(mm.isRedirectingConstructor);
+ Expect.isTrue(mm.isConstConstructor);
+
+ mm = cm.constructors[#constRedirectingGenerative];
+ Expect.isTrue(mm.isConstructor);
+ Expect.isTrue(mm.isGenerativeConstructor);
+ Expect.isFalse(mm.isFactoryConstructor);
+ Expect.isTrue(mm.isRedirectingConstructor);
+ Expect.isTrue(mm.isConstConstructor);
+
+ // Not legal.
+ // mm = cm.constructors[#constFaktory];
+ // Expect.isTrue(mm.isConstructor);
+ // Expect.isFalse(mm.isGenerativeConstructor);
+ // Expect.isTrue(mm.isFactoryConstructor);
+ // Expect.isFalse(mm.isRedirectingConstructor);
+ // Expect.isTrue(mm.isConstConstructor);
+
+ mm = cm.constructors[#constRedirectingFactory];
+ Expect.isTrue(mm.isConstructor);
+ Expect.isFalse(mm.isGenerativeConstructor);
+ Expect.isTrue(mm.isFactoryConstructor);
+ Expect.isTrue(mm.isRedirectingConstructor);
+ Expect.isTrue(mm.isConstConstructor);
+}
« no previous file with comments | « tests/lib/lib.status ('k') | tests/lib/mirrors/constructors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698