| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 | 6 |
| 7 class A { | 7 class A { |
| 8 A() { NamingTest.count++; } | 8 A() { |
| 9 NamingTest.count++; |
| 10 } |
| 9 foo(a, b) { | 11 foo(a, b) { |
| 10 Expect.equals(1, a); | 12 Expect.equals(1, a); |
| 11 Expect.equals(2, b); | 13 Expect.equals(2, b); |
| 12 } | 14 } |
| 13 } | 15 } |
| 14 | 16 |
| 15 class MyException { | 17 class MyException { |
| 16 MyException() {} | 18 MyException() {} |
| 17 } | 19 } |
| 18 | 20 |
| 19 class debugger { | 21 class debugger { |
| 20 static const int __PROTO__ = 5; | 22 static const int __PROTO__ = 5; |
| 21 | 23 |
| 22 int x; | 24 int x; |
| 23 | 25 |
| 24 factory debugger.F() { | 26 factory debugger.F() { |
| 25 return new debugger(1); | 27 return new debugger(1); |
| 26 } | 28 } |
| 27 debugger(x) : this.x = x + 1 { } | 29 debugger(x) : this.x = x + 1 {} |
| 28 debugger.C(x) : this.x = x + 2 { } | 30 debugger.C(x) : this.x = x + 2 {} |
| 29 debugger.C$C(x) : this.x = x + 3 { } | 31 debugger.C$C(x) : this.x = x + 3 {} |
| 30 debugger.C$I(x) : this.x = x + 4 { } | 32 debugger.C$I(x) : this.x = x + 4 {} |
| 31 } | 33 } |
| 32 | 34 |
| 33 class debugger$C { | 35 class debugger$C { |
| 34 int x; | 36 int x; |
| 35 | 37 |
| 36 factory debugger$C.F() { | 38 factory debugger$C.F() { |
| 37 return new debugger$C(1); | 39 return new debugger$C(1); |
| 38 } | 40 } |
| 39 debugger$C(x) : this.x = x + 5 { } | 41 debugger$C(x) : this.x = x + 5 {} |
| 40 debugger$C.C(x) : this.x = x + 6 { } | 42 debugger$C.C(x) : this.x = x + 6 {} |
| 41 debugger$C.C$C(x) : this.x = x + 7 { } | 43 debugger$C.C$C(x) : this.x = x + 7 {} |
| 42 debugger$C.C$I(x) : this.x = x + 8 { } | 44 debugger$C.C$I(x) : this.x = x + 8 {} |
| 43 } | 45 } |
| 44 | 46 |
| 45 class debugger$C$C { | 47 class debugger$C$C { |
| 46 int x; | 48 int x; |
| 47 | 49 |
| 48 factory debugger$C$C.F() { | 50 factory debugger$C$C.F() { |
| 49 return new debugger$C$C(1); | 51 return new debugger$C$C(1); |
| 50 } | 52 } |
| 51 debugger$C$C(x) : this.x = x + 9 { } | 53 debugger$C$C(x) : this.x = x + 9 {} |
| 52 debugger$C$C.C(x) : this.x = x + 10 { } | 54 debugger$C$C.C(x) : this.x = x + 10 {} |
| 53 debugger$C$C.C$C(x) : this.x = x + 11 { } | 55 debugger$C$C.C$C(x) : this.x = x + 11 {} |
| 54 debugger$C$C.C$I(x) : this.x = x + 12 { } | 56 debugger$C$C.C$I(x) : this.x = x + 12 {} |
| 55 } | 57 } |
| 56 | 58 |
| 57 class with$I extends debugger$C { | 59 class with$I extends debugger$C { |
| 58 int y; | 60 int y; |
| 59 | 61 |
| 60 factory with$I.F() { | 62 factory with$I.F() { |
| 61 return new with$I(1, 2); | 63 return new with$I(1, 2); |
| 62 } | 64 } |
| 63 with$I(x, y) : super(x), this.y = y + 11 { } | 65 with$I(x, y) |
| 64 with$I.I(x, y) : super.C(x), this.y = y + 12 { } | 66 : super(x), |
| 65 with$I.C(x, y) : super.C$C(x), this.y = y + 13 { } | 67 this.y = y + 11 {} |
| 66 with$I.I$C(x, y) : super.C$I(x), this.y = y + 14 { } | 68 with$I.I(x, y) |
| 67 with$I.C$C(x, y) : super(x), this.y = y + 15 { } | 69 : super.C(x), |
| 68 with$I.C$C$C(x, y) : super.C(x), this.y = y + 16 { } | 70 this.y = y + 12 {} |
| 69 with$I.$C$I(x, y) : super.C$C(x), this.y = y + 17 { } | 71 with$I.C(x, y) |
| 70 with$I.$$I$C(x, y) : super.C$I(x), this.y = y + 18 { } | 72 : super.C$C(x), |
| 71 with$I.$(x, y) : super(x), this.y = y + 19 { } | 73 this.y = y + 13 {} |
| 72 with$I.$$(x, y) : super.C(x), this.y = y + 20 { } | 74 with$I.I$C(x, y) |
| 75 : super.C$I(x), |
| 76 this.y = y + 14 {} |
| 77 with$I.C$C(x, y) |
| 78 : super(x), |
| 79 this.y = y + 15 {} |
| 80 with$I.C$C$C(x, y) |
| 81 : super.C(x), |
| 82 this.y = y + 16 {} |
| 83 with$I.$C$I(x, y) |
| 84 : super.C$C(x), |
| 85 this.y = y + 17 {} |
| 86 with$I.$$I$C(x, y) |
| 87 : super.C$I(x), |
| 88 this.y = y + 18 {} |
| 89 with$I.$(x, y) |
| 90 : super(x), |
| 91 this.y = y + 19 {} |
| 92 with$I.$$(x, y) |
| 93 : super.C(x), |
| 94 this.y = y + 20 {} |
| 73 } | 95 } |
| 74 | 96 |
| 75 class with$C extends debugger$C$C { | 97 class with$C extends debugger$C$C { |
| 76 int y; | 98 int y; |
| 77 | 99 |
| 78 factory with$C.F() { | 100 factory with$C.F() { |
| 79 return new with$C(1, 2); | 101 return new with$C(1, 2); |
| 80 } | 102 } |
| 81 with$C(x, y) : super(x), this.y = y + 21 { } | 103 with$C(x, y) |
| 82 with$C.I(x, y) : super.C(x), this.y = y + 22 { } | 104 : super(x), |
| 83 with$C.C(x, y) : super.C$C(x), this.y = y + 23 { } | 105 this.y = y + 21 {} |
| 84 with$C.I$C(x, y) : super.C$I(x), this.y = y + 24 { } | 106 with$C.I(x, y) |
| 85 with$C.C$C(x, y) : super(x), this.y = y + 25 { } | 107 : super.C(x), |
| 86 with$C.C$C$C(x, y) : super.C(x), this.y = y + 26 { } | 108 this.y = y + 22 {} |
| 87 with$C.$C$I(x, y) : super.C$C(x), this.y = y + 27 { } | 109 with$C.C(x, y) |
| 88 with$C.$$I$C(x, y) : super.C$I(x), this.y = y + 28 { } | 110 : super.C$C(x), |
| 89 with$C.$(x, y) : super(x), this.y = y + 29 { } | 111 this.y = y + 23 {} |
| 90 with$C.$$(x, y) : super.C(x), this.y = y + 30 { } | 112 with$C.I$C(x, y) |
| 113 : super.C$I(x), |
| 114 this.y = y + 24 {} |
| 115 with$C.C$C(x, y) |
| 116 : super(x), |
| 117 this.y = y + 25 {} |
| 118 with$C.C$C$C(x, y) |
| 119 : super.C(x), |
| 120 this.y = y + 26 {} |
| 121 with$C.$C$I(x, y) |
| 122 : super.C$C(x), |
| 123 this.y = y + 27 {} |
| 124 with$C.$$I$C(x, y) |
| 125 : super.C$I(x), |
| 126 this.y = y + 28 {} |
| 127 with$C.$(x, y) |
| 128 : super(x), |
| 129 this.y = y + 29 {} |
| 130 with$C.$$(x, y) |
| 131 : super.C(x), |
| 132 this.y = y + 30 {} |
| 91 } | 133 } |
| 92 | 134 |
| 93 class with$I$C extends debugger$C$C { | 135 class with$I$C extends debugger$C$C { |
| 94 int y; | 136 int y; |
| 95 | 137 |
| 96 factory with$I$C.F() { | 138 factory with$I$C.F() { |
| 97 return new with$I$C(1, 2); | 139 return new with$I$C(1, 2); |
| 98 } | 140 } |
| 99 with$I$C(x, y) : super(x), this.y = y + 31 { } | 141 with$I$C(x, y) |
| 100 with$I$C.I(x, y) : super.C(x), this.y = y + 32 { } | 142 : super(x), |
| 101 with$I$C.C(x, y) : super.C$C(x), this.y = y + 33 { } | 143 this.y = y + 31 {} |
| 102 with$I$C.I$C(x, y) : super.C$I(x), this.y = y + 34 { } | 144 with$I$C.I(x, y) |
| 103 with$I$C.C$C(x, y) : super(x), this.y = y + 35 { } | 145 : super.C(x), |
| 104 with$I$C.C$C$C(x, y) : super.C(x), this.y = y + 36 { } | 146 this.y = y + 32 {} |
| 105 with$I$C.$C$I(x, y) : super.C$C(x), this.y = y + 37 { } | 147 with$I$C.C(x, y) |
| 106 with$I$C.$$I$C(x, y) : super.C$I(x), this.y = y + 38 { } | 148 : super.C$C(x), |
| 107 with$I$C.$(x, y) : super(x), this.y = y + 39 { } | 149 this.y = y + 33 {} |
| 108 with$I$C.$$(x, y) : super.C(x), this.y = y + 40 { } | 150 with$I$C.I$C(x, y) |
| 151 : super.C$I(x), |
| 152 this.y = y + 34 {} |
| 153 with$I$C.C$C(x, y) |
| 154 : super(x), |
| 155 this.y = y + 35 {} |
| 156 with$I$C.C$C$C(x, y) |
| 157 : super.C(x), |
| 158 this.y = y + 36 {} |
| 159 with$I$C.$C$I(x, y) |
| 160 : super.C$C(x), |
| 161 this.y = y + 37 {} |
| 162 with$I$C.$$I$C(x, y) |
| 163 : super.C$I(x), |
| 164 this.y = y + 38 {} |
| 165 with$I$C.$(x, y) |
| 166 : super(x), |
| 167 this.y = y + 39 {} |
| 168 with$I$C.$$(x, y) |
| 169 : super.C(x), |
| 170 this.y = y + 40 {} |
| 109 } | 171 } |
| 110 | 172 |
| 111 class Tata { | 173 class Tata { |
| 112 var prototype; | 174 var prototype; |
| 113 | 175 |
| 114 Tata() : this.prototype = 0 {} | 176 Tata() : this.prototype = 0 {} |
| 115 | 177 |
| 116 __PROTO__$() { return 12; } | 178 __PROTO__$() { |
| 179 return 12; |
| 180 } |
| 117 } | 181 } |
| 118 | 182 |
| 119 class Toto extends Tata { | 183 class Toto extends Tata { |
| 120 var __PROTO__; | 184 var __PROTO__; |
| 121 | 185 |
| 122 Toto() : super(), this.__PROTO__ = 0 { } | 186 Toto() |
| 187 : super(), |
| 188 this.__PROTO__ = 0 {} |
| 123 | 189 |
| 124 prototype$() { return 10; } | 190 prototype$() { |
| 191 return 10; |
| 192 } |
| 125 | 193 |
| 126 titi() { | 194 titi() { |
| 127 Expect.equals(0, prototype); | 195 Expect.equals(0, prototype); |
| 128 Expect.equals(0, __PROTO__); | 196 Expect.equals(0, __PROTO__); |
| 129 prototype = 3; | 197 prototype = 3; |
| 130 __PROTO__ = 5; | 198 __PROTO__ = 5; |
| 131 Expect.equals(3, prototype); | 199 Expect.equals(3, prototype); |
| 132 Expect.equals(5, __PROTO__); | 200 Expect.equals(5, __PROTO__); |
| 133 Expect.equals(10, prototype$()); | 201 Expect.equals(10, prototype$()); |
| 134 Expect.equals(12, __PROTO__$()); | 202 Expect.equals(12, __PROTO__$()); |
| 135 Expect.equals(12, this.__PROTO__$()); | 203 Expect.equals(12, this.__PROTO__$()); |
| 136 Expect.equals(10, this.prototype$()); | 204 Expect.equals(10, this.prototype$()); |
| 137 Expect.equals(12, __PROTO__$()); | 205 Expect.equals(12, __PROTO__$()); |
| 138 } | 206 } |
| 139 } | 207 } |
| 140 | 208 |
| 141 class Bug4082360 { | 209 class Bug4082360 { |
| 142 int x_; | 210 int x_; |
| 143 Bug4082360() {} | 211 Bug4082360() {} |
| 144 | 212 |
| 145 int get x { return x_; } | 213 int get x { |
| 146 void set x(int value) { x_ = value; } | 214 return x_; |
| 215 } |
| 147 | 216 |
| 148 void indirectSet(int value) { x = value; } | 217 void set x(int value) { |
| 218 x_ = value; |
| 219 } |
| 220 |
| 221 void indirectSet(int value) { |
| 222 x = value; |
| 223 } |
| 149 | 224 |
| 150 static void test() { | 225 static void test() { |
| 151 var bug = new Bug4082360(); | 226 var bug = new Bug4082360(); |
| 152 bug.indirectSet(42); | 227 bug.indirectSet(42); |
| 153 Expect.equals(42, bug.x_); | 228 Expect.equals(42, bug.x_); |
| 154 Expect.equals(42, bug.x); | 229 Expect.equals(42, bug.x); |
| 155 } | 230 } |
| 156 } | 231 } |
| 157 | 232 |
| 158 class Hoisting { | 233 class Hoisting { |
| 159 var f_; | 234 var f_; |
| 160 Hoisting.negate(var x) { | 235 Hoisting.negate(var x) { |
| 161 f_ = () { return x; }; | 236 f_ = () { |
| 237 return x; |
| 238 }; |
| 162 } | 239 } |
| 163 | 240 |
| 164 operator -() { | 241 operator -() { |
| 165 var x = 3; | 242 var x = 3; |
| 166 return () { return x + 1; }; | 243 return () { |
| 244 return x + 1; |
| 245 }; |
| 167 } | 246 } |
| 168 | 247 |
| 169 operator[] (x) { | 248 operator [](x) { |
| 170 return () { return x + 3; }; | 249 return () { |
| 250 return x + 3; |
| 251 }; |
| 171 } | 252 } |
| 172 | 253 |
| 173 static void test() { | 254 static void test() { |
| 174 var h = new Hoisting.negate(1); | 255 var h = new Hoisting.negate(1); |
| 175 Expect.equals(1, (h.f_)()); | 256 Expect.equals(1, (h.f_)()); |
| 176 var f = -h; | 257 var f = -h; |
| 177 Expect.equals(4, f()); | 258 Expect.equals(4, f()); |
| 178 Expect.equals(7, h[4]()); | 259 Expect.equals(7, h[4]()); |
| 179 } | 260 } |
| 180 } | 261 } |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 $add(Object other) => other; | 500 $add(Object other) => other; |
| 420 $negate() => wrapped; | 501 $negate() => wrapped; |
| 421 | 502 |
| 422 operator +(Object other) => 123; | 503 operator +(Object other) => 123; |
| 423 operator -() => 444; | 504 operator -() => 444; |
| 424 } | 505 } |
| 425 | 506 |
| 426 $add(Object first, Object second) => second; | 507 $add(Object first, Object second) => second; |
| 427 DartQuery $(Object obj) => new DartQuery(obj); | 508 DartQuery $(Object obj) => new DartQuery(obj); |
| 428 | 509 |
| 429 | |
| 430 // Ensure we don't have false positive. | 510 // Ensure we don't have false positive. |
| 431 class Naming2Test { | 511 class Naming2Test { |
| 432 Naming2Test() { } | 512 Naming2Test() {} |
| 433 int get foo { return 1; } | 513 int get foo { |
| 434 set foo(x) { } | 514 return 1; |
| 515 } |
| 516 |
| 517 set foo(x) {} |
| 435 | 518 |
| 436 static void main(args) { | 519 static void main(args) { |
| 437 var a = new Naming2Test(); | 520 var a = new Naming2Test(); |
| 438 Expect.throws( | 521 Expect.throws( |
| 439 () => a.foo(2), | 522 () => a.foo(2), |
| 440 // We check for both exceptions because the exact exception to | 523 // We check for both exceptions because the exact exception to |
| 441 // throw is hard to compute on some browsers. | 524 // throw is hard to compute on some browsers. |
| 442 (e) => e is NoSuchMethodError); | 525 (e) => e is NoSuchMethodError); |
| 443 } | 526 } |
| 444 } | 527 } |
| 445 | 528 |
| 446 main() { | 529 main() { |
| 447 NamingTest.testMain(); | 530 NamingTest.testMain(); |
| 448 Naming2Test.main(null); | 531 Naming2Test.main(null); |
| 449 } | 532 } |
| OLD | NEW |