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

Unified Diff: tests/language/mixin_method_test.dart

Issue 11886097: Get the most basic mixin applications working. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix checked mode. Created 7 years, 11 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: tests/language/mixin_method_test.dart
diff --git a/tests/language/mixin_method_test.dart b/tests/language/mixin_method_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..d5643f783b2185e383bbfa86f31dc66c44b722a7
--- /dev/null
+++ b/tests/language/mixin_method_test.dart
@@ -0,0 +1,52 @@
+// 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.
+
+class S {
+ foo() => "S-foo";
+ baz() => "S-baz";
+}
+
+class M1 {
+ bar() => "M1-bar";
+}
+
+class M2 {
+ bar() => "M2-bar";
+ baz() => "M2-baz";
+ fez() => "M2-fez";
+}
+
+typedef C = S with M1;
+typedef D = S with M1, M2;
+typedef E = S with M2, M1;
+
+class F extends E {
+ fez() => "F-fez";
+}
+
+main() {
+ var c = new C();
+ Expect.equals("S-foo", c.foo());
+ Expect.equals("M1-bar", c.bar());
+ Expect.equals("S-baz", c.baz());
+ Expect.throws(() => c.fez(), (error) => error is NoSuchMethodError);
+
+ var d = new D();
+ Expect.equals("S-foo", d.foo());
+ Expect.equals("M2-bar", d.bar());
+ Expect.equals("M2-baz", d.baz());
+ Expect.equals("M2-fez", d.fez());
+
+ var e = new E();
+ Expect.equals("S-foo", e.foo());
+ Expect.equals("M1-bar", e.bar());
+ Expect.equals("M2-baz", e.baz());
+ Expect.equals("M2-fez", e.fez());
+
+ var f = new F();
+ Expect.equals("S-foo", f.foo());
+ Expect.equals("M1-bar", f.bar());
+ Expect.equals("M2-baz", f.baz());
+ Expect.equals("F-fez", f.fez());
+}

Powered by Google App Engine
This is Rietveld 408576698