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 unittestTests; | 5 library unittestTests; |
6 import '../../../pkg/unittest/lib/unittest.dart'; | 6 import '../../../pkg/unittest/lib/unittest.dart'; |
7 part 'test_utils.dart'; | 7 part 'test_utils.dart'; |
8 | 8 |
9 doesNotThrow() {} | 9 doesNotThrow() {} |
10 doesThrow() { throw 'X'; } | 10 doesThrow() { throw 'X'; } |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 test('throwsUnimplementedError', () { | 148 test('throwsUnimplementedError', () { |
149 shouldPass(() { throw new UnimplementedError(''); }, | 149 shouldPass(() { throw new UnimplementedError(''); }, |
150 throwsUnimplementedError); | 150 throwsUnimplementedError); |
151 shouldFail(() { throw new Exception(); }, | 151 shouldFail(() { throw new Exception(); }, |
152 throwsUnimplementedError, | 152 throwsUnimplementedError, |
153 "Expected: throws an exception which matches UnimplementedError " | 153 "Expected: throws an exception which matches UnimplementedError " |
154 "but: exception <Exception> does not match " | 154 "but: exception <Exception> does not match " |
155 "UnimplementedError."); | 155 "UnimplementedError."); |
156 }); | 156 }); |
157 | 157 |
| 158 test('throwsNullPointerException', () { |
| 159 shouldPass(() { throw new NullPointerException(''); }, |
| 160 throwsNullPointerException); |
| 161 shouldFail(() { throw new Exception(); }, |
| 162 throwsNullPointerException, |
| 163 "Expected: throws an exception which matches NullPointerException " |
| 164 "but: exception <Exception> does not match " |
| 165 "NullPointerException."); |
| 166 }); |
| 167 |
158 test('throwsUnsupportedError', () { | 168 test('throwsUnsupportedError', () { |
159 shouldPass(() { throw new UnsupportedError(''); }, | 169 shouldPass(() { throw new UnsupportedError(''); }, |
160 throwsUnsupportedError); | 170 throwsUnsupportedError); |
161 shouldFail(() { throw new Exception(); }, | 171 shouldFail(() { throw new Exception(); }, |
162 throwsUnsupportedError, | 172 throwsUnsupportedError, |
163 "Expected: throws an exception which matches UnsupportedError " | 173 "Expected: throws an exception which matches UnsupportedError " |
164 "but: exception <Exception> does not match " | 174 "but: exception <Exception> does not match " |
165 "UnsupportedError."); | 175 "UnsupportedError."); |
166 }); | 176 }); |
167 | 177 |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 var w = new Widget(); | 537 var w = new Widget(); |
528 w.price = 10; | 538 w.price = 10; |
529 shouldPass(w, new HasPrice(greaterThan(0))); | 539 shouldPass(w, new HasPrice(greaterThan(0))); |
530 shouldFail(w, new HasPrice(greaterThan(10)), | 540 shouldFail(w, new HasPrice(greaterThan(10)), |
531 'Expected: Widget with a price that is a value greater than <10> ' | 541 'Expected: Widget with a price that is a value greater than <10> ' |
532 'but: price was <10>.'); | 542 'but: price was <10>.'); |
533 }); | 543 }); |
534 }); | 544 }); |
535 } | 545 } |
536 | 546 |
OLD | NEW |