| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
| 6 * This library contains an Expect class with static methods that can be used | 6 * This library contains an Expect class with static methods that can be used |
| 7 * for simple unit-tests. | 7 * for simple unit-tests. |
| 8 */ | 8 */ |
| 9 library expect; | 9 library expect; |
| 10 | 10 |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 } | 453 } |
| 454 return; | 454 return; |
| 455 } | 455 } |
| 456 _fail('Expect.throws$msg fails: Did not throw'); | 456 _fail('Expect.throws$msg fails: Did not throw'); |
| 457 } | 457 } |
| 458 | 458 |
| 459 static void throwsArgumentError(void f()) { | 459 static void throwsArgumentError(void f()) { |
| 460 Expect.throws(f, (error) => error is ArgumentError, "ArgumentError"); | 460 Expect.throws(f, (error) => error is ArgumentError, "ArgumentError"); |
| 461 } | 461 } |
| 462 | 462 |
| 463 static void throwsAssertionError(void f()) { |
| 464 Expect.throws(f, (error) => error is AssertionError, "AssertionError"); |
| 465 } |
| 466 |
| 463 static void throwsCastError(void f()) { | 467 static void throwsCastError(void f()) { |
| 464 Expect.throws(f, (error) => error is CastError, "CastError"); | 468 Expect.throws(f, (error) => error is CastError, "CastError"); |
| 465 } | 469 } |
| 466 | 470 |
| 467 static void throwsNoSuchMethodError(void f()) { | 471 static void throwsNoSuchMethodError(void f()) { |
| 468 Expect.throws( | 472 Expect.throws( |
| 469 f, (error) => error is NoSuchMethodError, "NoSuchMethodError"); | 473 f, (error) => error is NoSuchMethodError, "NoSuchMethodError"); |
| 470 } | 474 } |
| 471 | 475 |
| 472 static void throwsRangeError(void f()) { | 476 static void throwsRangeError(void f()) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 } on AssertionError catch (e) { | 555 } on AssertionError catch (e) { |
| 552 return true; | 556 return true; |
| 553 } | 557 } |
| 554 return false; | 558 return false; |
| 555 })(); | 559 })(); |
| 556 | 560 |
| 557 /// Is true iff checked mode is enabled. | 561 /// Is true iff checked mode is enabled. |
| 558 // TODO(rnystrom): Remove this once all tests are no longer using it. | 562 // TODO(rnystrom): Remove this once all tests are no longer using it. |
| 559 final bool checkedModeEnabled = | 563 final bool checkedModeEnabled = |
| 560 typeAssertionsEnabled && assertStatementsEnabled; | 564 typeAssertionsEnabled && assertStatementsEnabled; |
| OLD | NEW |