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

Side by Side Diff: tests/language/rewrite_implicit_this_test.dart

Issue 362343003: dart2dart: Use implicit 'this' when generating Dart code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed test case Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/dart_backend/dart_tree_printer.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 String toplevel = 'A';
8
9 class Foo {
10 String x = 'x';
11
12 easy(z) {
13 return x + y + z;
14 }
15
16 // Shadow the 'y' field in various ways
17 shadow_y_parameter(y) {
18 return x + this.y + y;
19 }
20
21 shadow_y_local(z) {
22 var y = z;
23 return x + this.y + y;
24 }
25
26 shadow_y_capturedLocal(z) {
27 var y = z;
28 foo() {
29 return x + this.y + y;
30 }
31 return foo();
32 }
33
34 shadow_y_closureParam(z) {
35 foo(y) {
36 return x + this.y + y;
37 }
38 return foo(z);
39 }
40
41 shadow_y_localInsideClosure(z) {
42 foo() {
43 var y = z;
44 return x + this.y + y;
45 }
46 return foo();
47 }
48
49 // Shadow the 'x' field in various ways
50 shadow_x_parameter(x) {
51 return this.x + y + x;
52 }
53
54 shadow_x_local(z) {
55 var x = z;
56 return this.x + y + x;
57 }
58
59 shadow_x_capturedLocal(z) {
60 var x = z;
61 foo() {
62 return this.x + y + x;
63 }
64 return foo();
65 }
66
67 shadow_x_closureParam(z) {
68 foo(x) {
69 return this.x + y + x;
70 }
71 return foo(z);
72 }
73
74 shadow_x_localInsideClosure(z) {
75 foo() {
76 var x = z;
77 return this.x + y + x;
78 }
79 return foo();
80 }
81
82 shadow_x_toplevel() {
83 return x + this.y + toplevel + this.toplevel;
84 }
85
86 }
87
88 class Sub extends Foo {
89 String y = 'y';
90 String toplevel = 'B';
91 }
92
93 main() {
94 Expect.equals('xyz', new Sub().easy('z'));
95 Expect.equals('xyz', new Sub().shadow_y_parameter('z'));
96 Expect.equals('xyz', new Sub().shadow_y_local('z'));
97 Expect.equals('xyz', new Sub().shadow_y_capturedLocal('z'));
98 Expect.equals('xyz', new Sub().shadow_y_closureParam('z'));
99 Expect.equals('xyz', new Sub().shadow_y_localInsideClosure('z'));
100 Expect.equals('xyz', new Sub().shadow_x_parameter('z'));
101 Expect.equals('xyz', new Sub().shadow_x_local('z'));
102 Expect.equals('xyz', new Sub().shadow_x_capturedLocal('z'));
103 Expect.equals('xyz', new Sub().shadow_x_closureParam('z'));
104 Expect.equals('xyz', new Sub().shadow_x_localInsideClosure('z'));
105
106 Expect.equals('xyAB', new Sub().shadow_x_toplevel());
107 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/dart_backend/dart_tree_printer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698