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

Unified Diff: tests/language/factory_redirection_test.dart

Issue 10964058: Support redirecting factory constructors in the VM (issue 3969). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 | « runtime/vm/symbols.h ('k') | tests/language/language.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/factory_redirection_test.dart
===================================================================
--- tests/language/factory_redirection_test.dart (revision 0)
+++ tests/language/factory_redirection_test.dart (revision 0)
@@ -0,0 +1,47 @@
+// Copyright (c) 2012, 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.
+
+class A<T> {
+ A() : x = null;
+
+ const A.constant(T x) : this.x = x;
siva 2012/09/24 20:51:35 const A.constant(this.x); ?
regis 2012/09/24 21:41:28 Done.
+
+ factory A.factory() {
+ return new B<Set>();
+ }
+
+ final T x;
+}
+
+class B<T> extends A<T> {
+ B();
+
+ factory B.A() = A<T>;
+
+ const factory B.A_constant(T x) = A<T>.constant;
+
+ factory B.A_factory() = A<T>.factory;
+}
+
+class C<K, V> extends B<V> {
+ C();
+
+ factory C.A() = A<V>;
+
+ factory C.A_factory() = A<V>.factory;
siva 2012/09/24 20:51:35 Would it be legal here to redirect to A<K>.factory
regis 2012/09/24 21:41:28 Yes, it would. But you would need to call new C<bo
+
+ const factory C.B_constant(V x) = B<V>.A_constant;
+}
+
+main() {
+ Expect.isTrue(new A<List>() is A<List>);
+ Expect.isTrue(new A<bool>.constant(true).x);
+ Expect.isTrue(new A<List>.factory() is B<Set>);
+ Expect.isTrue(new B<List>.A() is A<List>);
+ Expect.isTrue(new B<bool>.A_constant(true).x);
+ Expect.isTrue(new B<List>.A_factory() is B<Set>);
+ Expect.isTrue(new C<String, num>.A() is A<num>);
+ Expect.isTrue(new C<String, num>.A_factory() is B<Set>);
+ Expect.isTrue(new C<String, bool>.B_constant(true).x);
+}
« no previous file with comments | « runtime/vm/symbols.h ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698