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

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

Issue 12079022: Add test for native mixin fields and fix the implementation. (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 | « sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js_native/native_mixin_field_test.dart
diff --git a/tests/compiler/dart2js_native/native_mixin_field_test.dart b/tests/compiler/dart2js_native/native_mixin_field_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..e00d87171b6e9335776f5c2f04947dd6d2c43add
--- /dev/null
+++ b/tests/compiler/dart2js_native/native_mixin_field_test.dart
@@ -0,0 +1,59 @@
+// 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.
ngeoffray 2013/01/28 10:22:13 Dart classes with fields as mixins.
kasperl 2013/01/28 10:22:49 Done.
+
+class A native "*A" {
+ var foo;
+}
+
+class B extends A with M1, M2 native "*B" {
+ var bar;
+}
+
+class M1 {
+ var baz;
+}
+
+class M2 {
+ var bar;
+ var buz;
+}
+
+A makeA() native;
+B makeB() native;
+
+void setup() native """
+function A() {this.foo='A-foo';}
+function B() {A.call(this);this.bar='B-bar';this.baz='M1-baz';}
+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, (e) => e is NoSuchMethodError);
+ Expect.throws(() => a.baz, (e) => e is NoSuchMethodError);
+ Expect.throws(() => a.buz, (e) => e is NoSuchMethodError);
+
+ B b = makeB();
+ Expect.equals("A-foo", b.foo);
+ Expect.equals("B-bar", b.bar);
+ Expect.equals("M1-baz", b.baz);
+ Expect.isNull(b.buz);
+
+ M1 m1 = new M1();
+ Expect.throws(() => m1.foo, (e) => e is NoSuchMethodError);
+ Expect.throws(() => m1.bar, (e) => e is NoSuchMethodError);
+ Expect.isNull(m1.baz);
+ Expect.throws(() => m1.buz, (e) => e is NoSuchMethodError);
+
+ M2 m2 = new M2();
+ Expect.throws(() => m2.foo, (e) => e is NoSuchMethodError);
+ Expect.isNull(m2.bar);
+ Expect.throws(() => m2.baz, (e) => e is NoSuchMethodError);
+ Expect.isNull(m2.buz);
+}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698