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

Unified Diff: tests/compiler/dart2js_native/native_mixin_multiple_test.dart

Issue 12079020: Extends native mixin tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « no previous file | tests/compiler/dart2js_native/native_mixin_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js_native/native_mixin_multiple_test.dart
diff --git a/tests/compiler/dart2js_native/native_mixin_multiple_test.dart b/tests/compiler/dart2js_native/native_mixin_multiple_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..bd917cbf00b5ce0a58d1e9e1e37cfe13a95bf3d6
--- /dev/null
+++ b/tests/compiler/dart2js_native/native_mixin_multiple_test.dart
@@ -0,0 +1,72 @@
+// 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 that native classes can use ordinary Dart classes as mixins.
+
+class A native "*A" {
+ foo() => "A-foo";
+ baz() => "A-baz";
+}
+
+class B extends A with M1, M2 native "*B" {
+ bar() => baz();
+}
+
+class M1 {
+ foo() => "M1-foo";
+ baz() => "M1-baz";
+}
+
+class M2 {
+ foo() => "M2-foo";
+}
+
+A makeA() native;
+B makeB() native;
+
+void setup() native """
+function A() {}
+function B() {}
+makeA = function(){return new A;};
+makeB = function(){return new B;};
+""";
+
+main() {
+ setup();
+ A a = makeA();
+ Expect.equals("A-foo", a.foo());
+ Expect.throws(() => a.bar(), (error) => error is NoSuchMethodError);
+ Expect.equals("A-baz", a.baz());
+ Expect.isTrue(a is A);
+ Expect.isFalse(a is B);
+ Expect.isFalse(a is M1);
+ Expect.isFalse(a is M2);
+
+ B b = makeB();
+ Expect.equals("M2-foo", b.foo());
+ Expect.equals("M1-baz", b.bar());
+ Expect.equals("M1-baz", b.baz());
+ Expect.isTrue(b is A);
+ Expect.isTrue(b is B);
+ Expect.isTrue(b is M1);
+ Expect.isTrue(b is M2);
+
+ M1 m1 = new M1();
+ Expect.equals("M1-foo", m1.foo());
+ Expect.throws(() => m1.bar(), (error) => error is NoSuchMethodError);
+ Expect.equals("M1-baz", m1.baz());
+ Expect.isFalse(m1 is A);
+ Expect.isFalse(m1 is B);
+ Expect.isTrue(m1 is M1);
+ Expect.isFalse(m1 is M2);
+
+ M2 m2 = new M2();
+ Expect.equals("M2-foo", m2.foo());
+ Expect.throws(() => m2.bar(), (error) => error is NoSuchMethodError);
+ Expect.throws(() => m2.baz(), (error) => error is NoSuchMethodError);
+ Expect.isFalse(m2 is A);
+ Expect.isFalse(m2 is B);
+ Expect.isFalse(m2 is M1);
+ Expect.isTrue(m2 is M2);
+}
« no previous file with comments | « no previous file | tests/compiler/dart2js_native/native_mixin_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698