Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(568)

Side by Side Diff: pkg/unittest/test/matchers_test.dart

Issue 11275054: Modified unittest to use new argument syntax. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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('../../../pkg/unittest/unittest.dart'); 6 #import('../../../pkg/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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 "Expected: throws an exception which matches NullPointerException " 163 "Expected: throws an exception which matches NullPointerException "
164 "but: exception <Exception> does not match " 164 "but: exception <Exception> does not match "
165 "NullPointerException."); 165 "NullPointerException.");
166 }); 166 });
167 167
168 test('throwsUnsupportedError', () { 168 test('throwsUnsupportedError', () {
169 shouldPass(() { throw new UnsupportedError(''); }, 169 shouldPass(() { throw new UnsupportedError(''); },
170 throwsUnsupportedError); 170 throwsUnsupportedError);
171 shouldFail(() { throw new Exception(); }, 171 shouldFail(() { throw new Exception(); },
172 throwsUnsupportedError, 172 throwsUnsupportedError,
173 "Expected: throws an exception which matches " 173 "Expected: throws an exception which matches UnsupportedError "
174 "UnsupportedError "
175 "but: exception <Exception> does not match " 174 "but: exception <Exception> does not match "
176 "UnsupportedError."); 175 "UnsupportedError.");
177 }); 176 });
178 177
179 test('returnsNormally', () { 178 test('returnsNormally', () {
180 shouldPass(doesNotThrow, returnsNormally); 179 shouldPass(doesNotThrow, returnsNormally);
181 shouldFail(doesThrow, returnsNormally, 180 shouldFail(doesThrow, returnsNormally,
182 "Expected: return normally but: threw 'X'."); 181 "Expected: return normally but: threw 'X'.");
183 }); 182 });
184 183
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 test('allOf', () { 519 test('allOf', () {
521 shouldPass(1, allOf([lessThan(10), greaterThan(0)])); 520 shouldPass(1, allOf([lessThan(10), greaterThan(0)]));
522 shouldFail(-1, allOf([lessThan(10), greaterThan(0)]), 521 shouldFail(-1, allOf([lessThan(10), greaterThan(0)]),
523 "Expected: (a value less than <10> and a value greater than <0>) " 522 "Expected: (a value less than <10> and a value greater than <0>) "
524 "but: a value greater than <0> was <-1>."); 523 "but: a value greater than <0> was <-1>.");
525 }); 524 });
526 }); 525 });
527 526
528 group('Predicate Matchers', () { 527 group('Predicate Matchers', () {
529 test('isInstanceOf', () { 528 test('isInstanceOf', () {
530 shouldFail(0, predicate((x) => x is String, 529 shouldFail(0, predicate((x) => x is String, "an instance of String"),
531 description: "an instance of String"),
532 "Expected: an instance of String but: was <0>."); 530 "Expected: an instance of String but: was <0>.");
533 shouldPass('cow', predicate((x) => x is String, 531 shouldPass('cow', predicate((x) => x is String, "an instance of String"));
534 description: "an instance of String"));
535 }); 532 });
536 }); 533 });
537 534
538 group('Feature Matchers', () { 535 group('Feature Matchers', () {
539 test("Feature Matcher", () { 536 test("Feature Matcher", () {
540 var w = new Widget(); 537 var w = new Widget();
541 w.price = 10; 538 w.price = 10;
542 shouldPass(w, new HasPrice(greaterThan(0))); 539 shouldPass(w, new HasPrice(greaterThan(0)));
543 shouldFail(w, new HasPrice(greaterThan(10)), 540 shouldFail(w, new HasPrice(greaterThan(10)),
544 '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> '
545 'but: price was <10>.'); 542 'but: price was <10>.');
546 }); 543 });
547 }); 544 });
548 } 545 }
549 546
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698