Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 int toplevel = 'A'; | |
| 8 | |
| 9 class Foo { | |
| 10 int x = 'x'; | |
|
sigurdm
2014/07/03 07:48:12
var 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 shadow_y_local(z) { | |
| 21 var y = z; | |
| 22 return x + this.y + y; | |
| 23 } | |
| 24 shadow_y_capturedLocal(z) { | |
| 25 var y = z; | |
| 26 foo() { | |
| 27 return x + this.y + y; | |
| 28 } | |
| 29 return foo(); | |
| 30 } | |
| 31 shadow_y_closureParam(z) { | |
| 32 foo(y) { | |
| 33 return x + this.y + y; | |
| 34 } | |
| 35 return foo(z); | |
| 36 } | |
| 37 shadow_y_localInsideClosure(z) { | |
| 38 foo() { | |
| 39 var y = z; | |
| 40 return x + this.y + y; | |
| 41 } | |
| 42 return foo(); | |
| 43 } | |
| 44 | |
| 45 // Shadow the 'x' field in various ways | |
| 46 shadow_x_parameter(x) { | |
| 47 return this.x + y + x; | |
| 48 } | |
|
sigurdm
2014/07/03 07:48:12
Newlines missing between functions.
| |
| 49 shadow_x_local(z) { | |
| 50 var x = z; | |
| 51 return this.x + y + x; | |
| 52 } | |
| 53 shadow_x_capturedLocal(z) { | |
| 54 var x = z; | |
| 55 foo() { | |
| 56 return this.x + y + x; | |
| 57 } | |
| 58 return foo(); | |
| 59 } | |
| 60 shadow_x_closureParam(z) { | |
| 61 foo(x) { | |
| 62 return this.x + y + x; | |
| 63 } | |
| 64 return foo(z); | |
| 65 } | |
| 66 shadow_x_localInsideClosure(z) { | |
| 67 foo() { | |
| 68 var x = z; | |
| 69 return this.x + y + x; | |
| 70 } | |
| 71 return foo(); | |
| 72 } | |
| 73 | |
| 74 shadow_x_toplevel() { | |
| 75 return x + this.y + toplevel + this.toplevel; | |
| 76 } | |
| 77 | |
| 78 } | |
| 79 class Sub extends Foo { | |
| 80 int y = 'y'; | |
| 81 int toplevel = 'B'; | |
| 82 } | |
| 83 | |
| 84 main() { | |
| 85 Expect.equals('xyz', new Sub().easy('z')); | |
| 86 Expect.equals('xyz', new Sub().shadow_y_parameter('z')); | |
| 87 Expect.equals('xyz', new Sub().shadow_y_local('z')); | |
| 88 Expect.equals('xyz', new Sub().shadow_y_capturedLocal('z')); | |
| 89 Expect.equals('xyz', new Sub().shadow_y_closureParam('z')); | |
| 90 Expect.equals('xyz', new Sub().shadow_y_localInsideClosure('z')); | |
| 91 Expect.equals('xyz', new Sub().shadow_x_parameter('z')); | |
| 92 Expect.equals('xyz', new Sub().shadow_x_local('z')); | |
| 93 Expect.equals('xyz', new Sub().shadow_x_capturedLocal('z')); | |
| 94 Expect.equals('xyz', new Sub().shadow_x_closureParam('z')); | |
| 95 Expect.equals('xyz', new Sub().shadow_x_localInsideClosure('z')); | |
| 96 | |
| 97 Expect.equals('xyAB', new Sub().shadow_x_toplevel()); | |
| 98 } | |
| OLD | NEW |