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 #library('matcherTest'); | 5 #library('matcherTest'); |
6 #import('../../../lib/unittest/unittest.dart'); | 6 #import('../../../lib/unittest/unittest.dart'); |
7 #source('test_utils.dart'); | 7 #source('test_utils.dart'); |
8 | 8 |
9 doesNotThrow() {} | 9 doesNotThrow() {} |
10 doesThrow() { throw 'X'; } | 10 doesThrow() { throw 'X'; } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 shouldPass(doesThrow, throws); | 79 shouldPass(doesThrow, throws); |
80 }); | 80 }); |
81 | 81 |
82 test('throwsA', () { | 82 test('throwsA', () { |
83 shouldPass(doesThrow, throwsA(equals('X'))); | 83 shouldPass(doesThrow, throwsA(equals('X'))); |
84 shouldFail(doesThrow, throwsA(equals('Y')), | 84 shouldFail(doesThrow, throwsA(equals('Y')), |
85 "Expected: throws an exception which matches 'Y' " | 85 "Expected: throws an exception which matches 'Y' " |
86 "but: exception 'X' does not match 'Y'."); | 86 "but: exception 'X' does not match 'Y'."); |
87 }); | 87 }); |
88 | 88 |
89 test('throwsBadNumberFormatException', () { | 89 test('throwsFormatException', () { |
90 shouldPass(() { throw new BadNumberFormatException(''); }, | 90 shouldPass(() { throw new FormatException(''); }, |
91 throwsBadNumberFormatException); | 91 throwsFormatException); |
92 shouldFail(() { throw new Exception(); }, | 92 shouldFail(() { throw new Exception(); }, |
93 throwsBadNumberFormatException, | 93 throwsFormatException, |
94 "Expected: throws an exception which matches BadNumberFormatException " | 94 "Expected: throws an exception which matches FormatException " |
95 "but: exception <Exception> does not match " | 95 "but: exception <Exception> does not match FormatException."); |
96 "BadNumberFormatException."); | |
97 }); | 96 }); |
98 | 97 |
99 test('throwsIllegalArgumentException', () { | 98 test('throwsIllegalArgumentException', () { |
100 shouldPass(() { throw new IllegalArgumentException(''); }, | 99 shouldPass(() { throw new IllegalArgumentException(''); }, |
101 throwsIllegalArgumentException); | 100 throwsIllegalArgumentException); |
102 shouldFail(() { throw new Exception(); }, | 101 shouldFail(() { throw new Exception(); }, |
103 throwsIllegalArgumentException, | 102 throwsIllegalArgumentException, |
104 "Expected: throws an exception which matches IllegalArgumentException " | 103 "Expected: throws an exception which matches IllegalArgumentException " |
105 "but: exception <Exception> does not match " | 104 "but: exception <Exception> does not match " |
106 "IllegalArgumentException."); | 105 "IllegalArgumentException."); |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 | 517 |
519 group('Predicate Matchers', () { | 518 group('Predicate Matchers', () { |
520 test('isInstanceOf', () { | 519 test('isInstanceOf', () { |
521 shouldFail(0, predicate((x) => x is String, "an instance of String"), | 520 shouldFail(0, predicate((x) => x is String, "an instance of String"), |
522 "Expected: an instance of String but: was <0>."); | 521 "Expected: an instance of String but: was <0>."); |
523 shouldPass('cow', predicate((x) => x is String, "an instance of String")); | 522 shouldPass('cow', predicate((x) => x is String, "an instance of String")); |
524 }); | 523 }); |
525 }); | 524 }); |
526 } | 525 } |
527 | 526 |
OLD | NEW |