| 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 class A { | 5 class A { |
| 6 A() { NamingTest.count++; } | 6 A() { NamingTest.count++; } |
| 7 foo(a, b) { | 7 foo(a, b) { |
| 8 Expect.equals(1, a); | 8 Expect.equals(1, a); |
| 9 Expect.equals(2, b); | 9 Expect.equals(2, b); |
| 10 } | 10 } |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 198 |
| 199 // It is not possible to make sure that the backend uses the hardcoded names | 199 // It is not possible to make sure that the backend uses the hardcoded names |
| 200 // we are testing against. This test might therefore become rapidly out of date | 200 // we are testing against. This test might therefore become rapidly out of date |
| 201 class NamingTest { | 201 class NamingTest { |
| 202 static int count; | 202 static int count; |
| 203 | 203 |
| 204 static testExceptionNaming() { | 204 static testExceptionNaming() { |
| 205 // Exceptions use a hardcoded "e" as exception name. If the namer works | 205 // Exceptions use a hardcoded "e" as exception name. If the namer works |
| 206 // correctly then it will be renamed in case of clashes. | 206 // correctly then it will be renamed in case of clashes. |
| 207 var e = 3; | 207 var e = 3; |
| 208 var caught = false; | 208 var caught = 0; |
| 209 try { | 209 try { |
| 210 throw new MyException(); | 210 throw new MyException(); |
| 211 } catch (var exc) { | 211 } catch (exc) { |
| 212 try { | 212 try { |
| 213 throw new MyException(); | 213 throw new MyException(); |
| 214 } catch (var exc2) { | 214 } catch (exc2) { |
| 215 exc = 9; | 215 caught++; |
| 216 } | 216 } |
| 217 Expect.equals(9, exc); | 217 Expect.equals(1, caught); |
| 218 caught = true; | 218 caught++; |
| 219 } | 219 } |
| 220 Expect.equals(true, caught); | 220 Expect.equals(2, caught); |
| 221 Expect.equals(3, e); | 221 Expect.equals(3, e); |
| 222 } | 222 } |
| 223 | 223 |
| 224 static testTmpNaming() { | 224 static testTmpNaming() { |
| 225 Expect.equals(0, count); | 225 Expect.equals(0, count); |
| 226 var tmp$0 = 1; | 226 var tmp$0 = 1; |
| 227 var tmp$1 = 2; | 227 var tmp$1 = 2; |
| 228 new A().foo(tmp$0, tmp$1++); | 228 new A().foo(tmp$0, tmp$1++); |
| 229 Expect.equals(1, count); | 229 Expect.equals(1, count); |
| 230 Expect.equals(3, tmp$1); | 230 Expect.equals(3, tmp$1); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 Expect.equals(38, x.y); | 384 Expect.equals(38, x.y); |
| 385 x = new with$I$C.$(0, 0); | 385 x = new with$I$C.$(0, 0); |
| 386 Expect.equals(9, x.x); | 386 Expect.equals(9, x.x); |
| 387 Expect.equals(39, x.y); | 387 Expect.equals(39, x.y); |
| 388 x = new with$I$C.$$(0, 0); | 388 x = new with$I$C.$$(0, 0); |
| 389 Expect.equals(10, x.x); | 389 Expect.equals(10, x.x); |
| 390 Expect.equals(40, x.y); | 390 Expect.equals(40, x.y); |
| 391 var wasCaught = false; | 391 var wasCaught = false; |
| 392 try { | 392 try { |
| 393 throw new with(0, 0); | 393 throw new with(0, 0); |
| 394 } catch(with e) { | 394 } on with catch (e) { |
| 395 wasCaught = true; | 395 wasCaught = true; |
| 396 Expect.equals(5, e.x); | 396 Expect.equals(5, e.x); |
| 397 } | 397 } |
| 398 Expect.equals(true, wasCaught); | 398 Expect.equals(true, wasCaught); |
| 399 } | 399 } |
| 400 | 400 |
| 401 static void testMemberMangling() { | 401 static void testMemberMangling() { |
| 402 Expect.equals(5, debugger.__PROTO__); | 402 Expect.equals(5, debugger.__PROTO__); |
| 403 new Toto().titi(); | 403 new Toto().titi(); |
| 404 } | 404 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 var a = new Naming2Test(); | 512 var a = new Naming2Test(); |
| 513 Expect.throws(() => a.foo(2), (e) => e is ObjectNotClosureException); | 513 Expect.throws(() => a.foo(2), (e) => e is ObjectNotClosureException); |
| 514 } | 514 } |
| 515 } | 515 } |
| 516 | 516 |
| 517 main() { | 517 main() { |
| 518 NamingTest.testMain(); | 518 NamingTest.testMain(); |
| 519 Naming1Test.main(null); | 519 Naming1Test.main(null); |
| 520 Naming2Test.main(null); | 520 Naming2Test.main(null); |
| 521 } | 521 } |
| OLD | NEW |