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

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

Issue 119683004: Test for interceptor convention closurized methods (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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/dart2js_native.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js_native/bound_closure_test.dart
diff --git a/tests/compiler/dart2js_native/bound_closure_test.dart b/tests/compiler/dart2js_native/bound_closure_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..59dc306bfcb3449c1ed412fc4cec58744cd420b5
--- /dev/null
+++ b/tests/compiler/dart2js_native/bound_closure_test.dart
@@ -0,0 +1,83 @@
+// 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.
+
+import "package:expect/expect.dart";
+
+// Test calling convention of property extraction closures.
+
+class AA {
+ bar(a, [b = 'A']) => 'AA.bar($a, $b)'; // bar is plain dart convention.
+ foo(a, [b = 'A']) => 'AA.foo($a, $b)'; // foo has interceptor convention.
+}
+
+class BB native "BB" {
+ foo(a, [b = 'B']) native;
+}
+
+class CC extends BB native "CC" {
+ foo(a, [b = 'C']) native;
+
+ get superfoo => super.foo;
+}
+
+makeBB() native;
+makeCC() native;
+inscrutable(a) native;
+
+void setup() native r"""
+function BB() {}
+BB.prototype.foo = function(u, v) {
+ return 'BB.foo(' + u + ', ' + v + ')';
+};
+
+function CC() {}
+CC.prototype.foo = function(u, v) {
+ return 'CC.foo(' + u + ', ' + v + ')';
+};
+
+makeBB = function(){return new BB;};
+makeCC = function(){return new CC;};
+inscrutable = function(a){return a;};
+""";
+
+
+main() {
+ setup();
+ var a = inscrutable(new AA());
+ var b = inscrutable(makeBB());
+ var c = inscrutable(makeCC);
+
+ Expect.equals('AA.bar(1, A)', inscrutable(a).bar(1));
+ Expect.equals('AA.bar(2, 3)', inscrutable(a).bar(2, 3));
+
+ Expect.equals('AA.foo(1, A)', inscrutable(a).foo(1));
+ Expect.equals('AA.foo(2, 3)', inscrutable(a).foo(2, 3));
+
+ Expect.equals('BB.foo(1, B)', inscrutable(b).foo(1));
+ Expect.equals('BB.foo(2, 3)', inscrutable(b).foo(2, 3));
+
+ Expect.equals('CC.foo(1, C)', inscrutable(c).foo(1));
+ Expect.equals('CC.foo(2, 3)', inscrutable(c).foo(2, 3));
+
+ var abar = inscrutable(a).bar;
+ var afoo = inscrutable(a).foo;
+ var bfoo = inscrutable(b).foo;
+ var cfoo = inscrutable(c).foo;
+ var csfoo = inscrutable(c).superfoo;
+
+ Expect.equals('AA.bar(1, A)', abar(1));
+ Expect.equals('AA.bar(2, 3)', abar(2, 3));
+
+ Expect.equals('AA.foo(1, A)', afoo(1));
+ Expect.equals('AA.foo(2, 3)', afoo(2, 3));
+
+ Expect.equals('BB.foo(1, B)', bfoo(1));
+ Expect.equals('BB.foo(2, 3)', bfoo(2, 3));
+
+ Expect.equals('CC.foo(1, C)', cfoo(1));
+ Expect.equals('CC.foo(2, 3)', cfoo(2, 3));
+
+ Expect.equals('BB.foo(1, B)', csfoo(1));
+ Expect.equals('BB.foo(2, 3)', csfoo(2, 3));
+}
« no previous file with comments | « no previous file | tests/compiler/dart2js_native/dart2js_native.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698