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

Side by Side Diff: tests/utils/unittest_test.dart

Issue 10548005: Add matchers for unit testing futures: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 months 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('unittestTest'); 5 #library('unittestTest');
6 6
7 #import('../../lib/unittest/unittest.dart'); 7 #import('../../lib/unittest/unittest.dart');
8 8
9 9
10 doesNotThrow() {} 10 doesNotThrow() {}
(...skipping 10 matching lines...) Expand all
21 } 21 }
22 } 22 }
23 23
24 void shouldFail(var value, Matcher matcher, expected) { 24 void shouldFail(var value, Matcher matcher, expected) {
25 errorCount = 0; 25 errorCount = 0;
26 errorString = ''; 26 errorString = '';
27 configureExpectHandler(testHandler); 27 configureExpectHandler(testHandler);
28 expect(value, matcher); 28 expect(value, matcher);
29 configureExpectHandler(null); 29 configureExpectHandler(null);
30 expect(errorCount, equals(1)); 30 expect(errorCount, equals(1));
31 if (expected is String) 31 if (expected is String) {
32 expect(errorString, equalsIgnoringWhitespace(expected)); 32 expect(errorString, equalsIgnoringWhitespace(expected));
33 else 33 } else {
34 expect(errorString, expected); 34 expect(errorString, expected);
35 }
35 } 36 }
36 37
37 void shouldPass(var value, Matcher matcher) { 38 void shouldPass(var value, Matcher matcher) {
38 errorCount = 0; 39 errorCount = 0;
39 errorString = ''; 40 errorString = '';
40 configureExpectHandler(testHandler); 41 configureExpectHandler(testHandler);
41 expect(value, matcher); 42 expect(value, matcher);
42 configureExpectHandler(null); 43 configureExpectHandler(null);
43 expect(errorCount, equals(0)); 44 expect(errorCount, equals(0));
44 } 45 }
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 test('allOf', () { 448 test('allOf', () {
448 shouldPass(1, allOf([lessThan(10), greaterThan(0)])); 449 shouldPass(1, allOf([lessThan(10), greaterThan(0)]));
449 shouldFail(-1, allOf([lessThan(10), greaterThan(0)]), 450 shouldFail(-1, allOf([lessThan(10), greaterThan(0)]),
450 "Expected: (a value less than <10> and a value greater than <0>) " 451 "Expected: (a value less than <10> and a value greater than <0>) "
451 "but: a value greater than <0> was <-1>"); 452 "but: a value greater than <0> was <-1>");
452 }); 453 });
453 }); 454 });
454 } 455 }
455 456
456 457
OLDNEW
« lib/unittest/future_matchers.dart ('K') | « lib/unittest/unittest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698