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

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

Issue 15492003: Split out unittest tests whose behavior differs in minified mode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 part of unittestTests; 5 library test_utils;
6
7 import 'dart:collection';
8
9 import 'package:unittest/unittest.dart';
10
11 import 'dart:async';
6 12
7 int errorCount; 13 int errorCount;
8 String errorString; 14 String errorString;
9 var _testHandler = null; 15 var _testHandler = null;
10 16
11 class MyFailureHandler extends DefaultFailureHandler { 17 class MyFailureHandler extends DefaultFailureHandler {
12 void fail(String reason) { 18 void fail(String reason) {
13 ++errorCount; 19 ++errorCount;
14 errorString = reason; 20 errorString = reason;
15 } 21 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 afterTest() { 57 afterTest() {
52 configureExpectFailureHandler(null); 58 configureExpectFailureHandler(null);
53 expect(errorCount, equals(0)); 59 expect(errorCount, equals(0));
54 } 60 }
55 if (isAsync) { 61 if (isAsync) {
56 Timer.run(expectAsync0(afterTest)); 62 Timer.run(expectAsync0(afterTest));
57 } else { 63 } else {
58 afterTest(); 64 afterTest();
59 } 65 }
60 } 66 }
67
68 doesNotThrow() {}
69 doesThrow() { throw 'X'; }
70
71 class PrefixMatcher extends BaseMatcher {
72 final String _prefix;
73 const PrefixMatcher(this._prefix);
74 bool matches(item, MatchState matchState) {
75 return item is String &&
76 (collapseWhitespace(item)).startsWith(collapseWhitespace(_prefix));
77 }
78
79 Description describe(Description description) =>
80 description.add('a string starting with ').
81 addDescriptionOf(collapseWhitespace(_prefix)).
82 add(' ignoring whitespace');
83 }
84
85 class Widget {
gram 2013/05/20 22:35:58 Can you move everything from Widget down into a fi
nweiz 2013/05/20 23:29:06 Done.
86 int price;
87 }
88
89 class HasPrice extends CustomMatcher {
90 HasPrice(matcher) :
91 super("Widget with a price that is", "price", matcher);
92 featureValueOf(actual) => actual.price;
93 }
94
95 class SimpleIterable extends IterableBase {
96 int count;
97 SimpleIterable(this.count);
98
99 bool contains(int val) => count < val ? false : true;
100
101 bool any(bool f(element)) {
102 for(var i = 0; i <= count; i++) {
103 if(f(i)) return true;
104 }
105 return false;
106 }
107
108 String toString() => "<[$count]>";
109
110 Iterator get iterator {
111 return new SimpleIterator(count);
112 }
113 }
114
115 class SimpleIterator implements Iterator {
116 int _count;
117 int _current;
118
119 SimpleIterator(this._count);
120
121 bool moveNext() {
122 if (_count > 0) {
123 _current = _count;
124 _count--;
125 return true;
126 }
127 _current = null;
128 return false;
129 }
130
131 get current => _current;
132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698