| 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 // Tests function statement and expression syntax. | 5 // Tests function statement and expression syntax. |
| 6 | 6 |
| 7 class FunctionSyntaxTest { | 7 class FunctionSyntaxTest { |
| 8 | 8 |
| 9 static void testMain | 9 static void testMain |
| 10 /* /// 00: compile-time error | 10 /* /// 00: compile-time error |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 expectEvaluatesTo(2, ()=> 1 + 1); | 463 expectEvaluatesTo(2, ()=> 1 + 1); |
| 464 expectEvaluatesTo(1, ()=> 2 - 1); | 464 expectEvaluatesTo(1, ()=> 2 - 1); |
| 465 | 465 |
| 466 // Multiplicative. | 466 // Multiplicative. |
| 467 expectEvaluatesTo(2, ()=> 1 * 2); | 467 expectEvaluatesTo(2, ()=> 1 * 2); |
| 468 expectEvaluatesTo(2.0, ()=> 4 / 2); | 468 expectEvaluatesTo(2.0, ()=> 4 / 2); |
| 469 expectEvaluatesTo(2, ()=> 4 ~/ 2); | 469 expectEvaluatesTo(2, ()=> 4 ~/ 2); |
| 470 expectEvaluatesTo(0, ()=> 4 % 2); | 470 expectEvaluatesTo(0, ()=> 4 % 2); |
| 471 | 471 |
| 472 // Negate. | 472 // Negate. |
| 473 expectEvaluatesTo(-3, ()=> ~2); | |
| 474 expectEvaluatesTo(false, ()=> !true); | 473 expectEvaluatesTo(false, ()=> !true); |
| 475 | 474 |
| 476 // Postfix / prefix. | 475 // Postfix / prefix. |
| 477 var y = 0; | 476 var y = 0; |
| 478 expectEvaluatesTo(0, ()=> y++); | 477 expectEvaluatesTo(0, ()=> y++); |
| 479 expectEvaluatesTo(2, ()=> ++y); | 478 expectEvaluatesTo(2, ()=> ++y); |
| 480 expectEvaluatesTo(1, ()=> --y); | 479 expectEvaluatesTo(1, ()=> --y); |
| 481 expectEvaluatesTo(1, ()=> y--); | 480 expectEvaluatesTo(1, ()=> y--); |
| 482 Expect.equals(0, y); | 481 Expect.equals(0, y); |
| 483 | 482 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 | 621 |
| 623 } | 622 } |
| 624 | 623 |
| 625 main | 624 main |
| 626 /* /// 74: compile-time error | 625 /* /// 74: compile-time error |
| 627 () | 626 () |
| 628 */ /// 74: continued | 627 */ /// 74: continued |
| 629 { | 628 { |
| 630 FunctionSyntaxTest.testMain(); | 629 FunctionSyntaxTest.testMain(); |
| 631 } | 630 } |
| OLD | NEW |