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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 test('throwsNoSuchMethodError', () { | 137 test('throwsNoSuchMethodError', () { |
138 shouldPass(() { throw new NoSuchMethodError(null, '', null, null); }, | 138 shouldPass(() { throw new NoSuchMethodError(null, '', null, null); }, |
139 throwsNoSuchMethodError); | 139 throwsNoSuchMethodError); |
140 shouldFail(() { throw new Exception(); }, | 140 shouldFail(() { throw new Exception(); }, |
141 throwsNoSuchMethodError, | 141 throwsNoSuchMethodError, |
142 "Expected: throws an exception which matches NoSuchMethodError " | 142 "Expected: throws an exception which matches NoSuchMethodError " |
143 "but: exception <Exception> does not match " | 143 "but: exception <Exception> does not match " |
144 "NoSuchMethodError."); | 144 "NoSuchMethodError."); |
145 }); | 145 }); |
146 | 146 |
147 test('throwsNotImplementedException', () { | 147 test('throwsUnimplementedError', () { |
148 shouldPass(() { throw new NotImplementedException(''); }, | 148 shouldPass(() { throw new UnimplementedError(''); }, |
149 throwsNotImplementedException); | 149 throwsUnimplementedError); |
150 shouldFail(() { throw new Exception(); }, | 150 shouldFail(() { throw new Exception(); }, |
151 throwsNotImplementedException, | 151 throwsUnimplementedError, |
152 "Expected: throws an exception which matches NotImplementedException " | 152 "Expected: throws an exception which matches UnimplementedError " |
153 "but: exception <Exception> does not match " | 153 "but: exception <Exception> does not match " |
154 "NotImplementedException."); | 154 "UnimplementedError."); |
155 }); | 155 }); |
156 | 156 |
157 test('throwsNullPointerException', () { | 157 test('throwsNullPointerException', () { |
158 shouldPass(() { throw new NullPointerException(''); }, | 158 shouldPass(() { throw new NullPointerException(''); }, |
159 throwsNullPointerException); | 159 throwsNullPointerException); |
160 shouldFail(() { throw new Exception(); }, | 160 shouldFail(() { throw new Exception(); }, |
161 throwsNullPointerException, | 161 throwsNullPointerException, |
162 "Expected: throws an exception which matches NullPointerException " | 162 "Expected: throws an exception which matches NullPointerException " |
163 "but: exception <Exception> does not match " | 163 "but: exception <Exception> does not match " |
164 "NullPointerException."); | 164 "NullPointerException."); |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 var w = new Widget(); | 536 var w = new Widget(); |
537 w.price = 10; | 537 w.price = 10; |
538 shouldPass(w, new HasPrice(greaterThan(0))); | 538 shouldPass(w, new HasPrice(greaterThan(0))); |
539 shouldFail(w, new HasPrice(greaterThan(10)), | 539 shouldFail(w, new HasPrice(greaterThan(10)), |
540 'Expected: Widget with a price that is a value greater than <10> ' | 540 'Expected: Widget with a price that is a value greater than <10> ' |
541 'but: price was <10>.'); | 541 'but: price was <10>.'); |
542 }); | 542 }); |
543 }); | 543 }); |
544 } | 544 } |
545 | 545 |
OLD | NEW |