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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/compiler/dart2js_native/dart2js_native.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "package:expect/expect.dart";
6
7 // Test calling convention of property extraction closures.
8
9 class AA {
10 bar(a, [b = 'A']) => 'AA.bar($a, $b)'; // bar is plain dart convention.
11 foo(a, [b = 'A']) => 'AA.foo($a, $b)'; // foo has interceptor convention.
12 }
13
14 class BB native "BB" {
15 foo(a, [b = 'B']) native;
16 }
17
18 class CC extends BB native "CC" {
19 foo(a, [b = 'C']) native;
20
21 get superfoo => super.foo;
22 }
23
24 makeBB() native;
25 makeCC() native;
26 inscrutable(a) native;
27
28 void setup() native r"""
29 function BB() {}
30 BB.prototype.foo = function(u, v) {
31 return 'BB.foo(' + u + ', ' + v + ')';
32 };
33
34 function CC() {}
35 CC.prototype.foo = function(u, v) {
36 return 'CC.foo(' + u + ', ' + v + ')';
37 };
38
39 makeBB = function(){return new BB;};
40 makeCC = function(){return new CC;};
41 inscrutable = function(a){return a;};
42 """;
43
44
45 main() {
46 setup();
47 var a = inscrutable(new AA());
48 var b = inscrutable(makeBB());
49 var c = inscrutable(makeCC);
50
51 Expect.equals('AA.bar(1, A)', inscrutable(a).bar(1));
52 Expect.equals('AA.bar(2, 3)', inscrutable(a).bar(2, 3));
53
54 Expect.equals('AA.foo(1, A)', inscrutable(a).foo(1));
55 Expect.equals('AA.foo(2, 3)', inscrutable(a).foo(2, 3));
56
57 Expect.equals('BB.foo(1, B)', inscrutable(b).foo(1));
58 Expect.equals('BB.foo(2, 3)', inscrutable(b).foo(2, 3));
59
60 Expect.equals('CC.foo(1, C)', inscrutable(c).foo(1));
61 Expect.equals('CC.foo(2, 3)', inscrutable(c).foo(2, 3));
62
63 var abar = inscrutable(a).bar;
64 var afoo = inscrutable(a).foo;
65 var bfoo = inscrutable(b).foo;
66 var cfoo = inscrutable(c).foo;
67 var csfoo = inscrutable(c).superfoo;
68
69 Expect.equals('AA.bar(1, A)', abar(1));
70 Expect.equals('AA.bar(2, 3)', abar(2, 3));
71
72 Expect.equals('AA.foo(1, A)', afoo(1));
73 Expect.equals('AA.foo(2, 3)', afoo(2, 3));
74
75 Expect.equals('BB.foo(1, B)', bfoo(1));
76 Expect.equals('BB.foo(2, 3)', bfoo(2, 3));
77
78 Expect.equals('CC.foo(1, C)', cfoo(1));
79 Expect.equals('CC.foo(2, 3)', cfoo(2, 3));
80
81 Expect.equals('BB.foo(1, B)', csfoo(1));
82 Expect.equals('BB.foo(2, 3)', csfoo(2, 3));
83 }
OLDNEW
« 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