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

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

Issue 10541035: Fix problems that occur in checked mode. (Closed) Base URL: http://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
« no previous file with comments | « lib/unittest/collection_matchers.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {}
11 doesThrow() { throw 'X'; } 11 doesThrow() { throw 'X'; }
12 12
13 int errorCount; 13 int errorCount;
14 String errorString; 14 String errorString;
15 var testHandler; 15 var testHandler;
16 16
17 class MyFailureHandler extends DefaultFailureHandler { 17 class MyFailureHandler extends DefaultFailureHandler {
18 void fail(String reason) { 18 void fail(String reason) {
19 ++errorCount; 19 ++errorCount;
20 errorString = reason; 20 errorString = reason;
21 } 21 }
22 } 22 }
23 23
24 void shouldFail(var value, Matcher matcher, String 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);
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 test('allOf', () { 444 test('allOf', () {
445 shouldPass(1, allOf([lessThan(10), greaterThan(0)])); 445 shouldPass(1, allOf([lessThan(10), greaterThan(0)]));
446 shouldFail(-1, allOf([lessThan(10), greaterThan(0)]), 446 shouldFail(-1, allOf([lessThan(10), greaterThan(0)]),
447 "Expected: (a value less than <10> and a value greater than <0>) " 447 "Expected: (a value less than <10> and a value greater than <0>) "
448 "but: a value greater than <0> was <-1>"); 448 "but: a value greater than <0> was <-1>");
449 }); 449 });
450 }); 450 });
451 } 451 }
452 452
453 453
OLDNEW
« no previous file with comments | « lib/unittest/collection_matchers.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698