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

Side by Side Diff: test/codegen/language/super_bound_closure_test.dart

Issue 1310513013: fixes #314, super method tear offs (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « test/codegen/language/method_binding_test.dart ('k') | no next file » | 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) 2014, 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 class A {
8 bar([var optional = 1]) => 498 + optional;
9 bar2({ namedOptional: 2 }) => 40 + namedOptional;
10 bar3(x, [var optional = 3]) => x + 498 + optional;
11 bar4(x, { namedOptional: 4 }) => 422 + x + namedOptional;
12
13 // Gee is the same as bar, but we make sure that gee is used. Potentially
14 // this yields different code if the redirecting stub exists.
15 gee([var optional = 1]) => 498 + optional;
16 gee2({ namedOptional: 2 }) => 40 + namedOptional;
17 gee3(x, [var optional = 3]) => x + 498 + optional;
18 gee4(x, { namedOptional: 4 }) => 422 + x + namedOptional;
19
20 // Use identifiers that could be intercepted.
21 add([var optional = 33]) => 1234 + optional;
22 trim({ namedOptional: 22 }) => 1313 + namedOptional;
23 sublist(x, [optional = 44]) => 4321 + optional + x;
24 splitMapJoin(x, { onMatch: 55, onNonMatch: 66}) =>
25 111 + x + onMatch + onNonMatch;
26
27 // Other interceptable identifiers, but all of them are used.
28 shuffle([var optional = 121]) => 12342 + optional;
29 toList({ growable: 2233 }) => 13131 + growable;
30 lastIndexOf(x, [optional = 424]) => 14321 + optional + x;
31 lastWhere(x, { orElse: 555 }) => x + 1213 + 555;
32 }
33
34 class B extends A {
35 // The closure `super.bar` is invoked without the optional argument.
36 // Dart2js must not generate a `bar$0 => bar$1(null)` closure, since that
37 // would redirect to B's `bar$1`. Instead it must enforce that `bar$0` in
38 // `A` redirects to A's bar$1.
39 foo() => confuse(super.bar)();
40 foo2() => confuse(super.bar)(2);
41 foo3() => confuse(super.bar2)();
42 foo4() => confuse(super.bar2)(namedOptional: 77);
43 foo5() => confuse(super.bar3)(-3);
44 foo6() => confuse(super.bar3)(-11, -19);
45 foo7() => confuse(super.bar4)(0);
46 foo8() => confuse(super.bar4)(3, namedOptional: 77);
47
48 fooGee() => confuse(super.gee)();
49 fooGee2() => confuse(super.gee)(2);
50 fooGee3() => confuse(super.gee2)();
51 fooGee4() => confuse(super.gee2)(namedOptional: 77);
52 fooGee5() => confuse(super.gee3)(-3);
53 fooGee6() => confuse(super.gee3)(-11, -19);
54 fooGee7() => confuse(super.gee4)(0);
55 fooGee8() => confuse(super.gee4)(3, namedOptional: 77);
56
57 fooIntercept() => confuse(super.add)();
58 fooIntercept2() => confuse(super.add)(2);
59 fooIntercept3() => confuse(super.trim)();
60 fooIntercept4() => confuse(super.trim)(namedOptional: 77);
61 fooIntercept5() => confuse(super.sublist)(-3);
62 fooIntercept6() => confuse(super.sublist)(-11, -19);
63 fooIntercept7() => confuse(super.splitMapJoin)(0);
64 fooIntercept8() => confuse(super.splitMapJoin)(3, onMatch: 77, onNonMatch: 8);
65
66 fooIntercept21() => confuse(super.shuffle)();
67 fooIntercept22() => confuse(super.shuffle)(2);
68 fooIntercept23() => confuse(super.toList)();
69 fooIntercept24() => confuse(super.toList)(growable: 77);
70 fooIntercept25() => confuse(super.lastIndexOf)(-3);
71 fooIntercept26() => confuse(super.lastIndexOf)(-11, -19);
72 fooIntercept27() => confuse(super.lastWhere)(0);
73 fooIntercept28() => confuse(super.lastWhere)(3, orElse: 77);
74
75 bar([var optional]) => -1; /// 01: static type warning
76 bar2({ namedOptional }) => -1; /// 01: continued
77 bar3(x, [var optional]) => -1; /// 01: continued
78 bar4(x, { namedOptional }) => -1; /// 01: continued
79
80 gee([var optional]) => -1; /// 01: continued
81 gee2({ namedOptional }) => -1; /// 01: continued
82 gee3(x, [var optional]) => -1; /// 01: continued
83 gee4(x, { namedOptional }) => -1; /// 01: continued
84
85 add([var optional = 33]) => -1;
86 trim({ namedOptional: 22 }) => -1;
87 sublist(x, [optional = 44]) => -1;
88 splitMapJoin(x, { onMatch: 55, onNonMatch: 66}) => -1;
89
90 shuffle([var optional = 121]) => -1;
91 toList({ growable: 2233 }) => -1;
92 lastIndexOf(x, [optional = 424]) => -1;
93 lastWhere(x, { orElse: 555 }) => -1;
94 }
95
96 confuse(x) {
97 if (new DateTime.now().millisecondsSinceEpoch == 42) return confuse(x - 1);
98 return x;
99 }
100
101 main() {
102 var list = [new A(), new B(), [], "foo" ];
103 var a = list[confuse(0)];
104 var b = list[confuse(1)];
105 var ignored = list[confuse(2)];
106 var ignored2 = list[confuse(3)];
107
108 var t = b.gee() + b.gee2() + b.gee3(9) + b.gee4(19);
109 Expect.equals(-4, t); /// 01: continued
110 t = b.shuffle() + b.toList() + b.lastIndexOf(1) + b.lastWhere(2);
111 Expect.equals(-4, t);
112
113 Expect.equals(499, b.foo()); /// 01: continued
114 Expect.equals(500, b.foo2()); /// 01: continued
115 Expect.equals(42, b.foo3()); /// 01: continued
116 Expect.equals(117, b.foo4()); /// 01: continued
117 Expect.equals(498, b.foo5()); /// 01: continued
118 Expect.equals(468, b.foo6()); /// 01: continued
119 Expect.equals(426, b.foo7()); /// 01: continued
120 Expect.equals(502, b.foo8()); /// 01: continued
121
122 Expect.equals(499, b.fooGee()); /// 01: continued
123 Expect.equals(500, b.fooGee2()); /// 01: continued
124 Expect.equals(42, b.fooGee3()); /// 01: continued
125 Expect.equals(117, b.fooGee4()); /// 01: continued
126 Expect.equals(498, b.fooGee5()); /// 01: continued
127 Expect.equals(468, b.fooGee6()); /// 01: continued
128 Expect.equals(426, b.fooGee7()); /// 01: continued
129 Expect.equals(502, b.fooGee8()); /// 01: continued
130
131 Expect.equals(1267, b.fooIntercept());
132 Expect.equals(1236, b.fooIntercept2());
133 Expect.equals(1335, b.fooIntercept3());
134 Expect.equals(1390, b.fooIntercept4());
135 Expect.equals(4362, b.fooIntercept5());
136 Expect.equals(4291, b.fooIntercept6());
137 Expect.equals(232, b.fooIntercept7());
138 Expect.equals(199, b.fooIntercept8());
139
140 Expect.equals(12463, b.fooIntercept21());
141 Expect.equals(12344, b.fooIntercept22());
142 Expect.equals(15364, b.fooIntercept23());
143 Expect.equals(13208, b.fooIntercept24());
144 Expect.equals(14742, b.fooIntercept25());
145 Expect.equals(14291, b.fooIntercept26());
146 Expect.equals(1768, b.fooIntercept27());
147 Expect.equals(1771, b.fooIntercept28());
148 }
OLDNEW
« no previous file with comments | « test/codegen/language/method_binding_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698