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

Side by Side Diff: lib/unittest/operator_matchers.dart

Issue 10692051: Some more changes that came out of writing an article on mocks. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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 /** 5 /**
6 * This returns a matcher that inverts [matcher] to its logical negation. 6 * This returns a matcher that inverts [matcher] to its logical negation.
7 */ 7 */
8 Matcher isNot(matcher) => new _IsNot(wrapMatcher(matcher)); 8 Matcher isNot(matcher) => new _IsNot(wrapMatcher(matcher));
9 9
10 class _IsNot extends BaseMatcher { 10 class _IsNot extends BaseMatcher {
(...skipping 28 matching lines...) Expand all
39 expect(arg4, isNull); 39 expect(arg4, isNull);
40 expect(arg5, isNull); 40 expect(arg5, isNull);
41 expect(arg6, isNull); 41 expect(arg6, isNull);
42 for (int i = 0; i < arg0.length; i++) { 42 for (int i = 0; i < arg0.length; i++) {
43 arg0[i] = wrapMatcher(arg0[i]); 43 arg0[i] = wrapMatcher(arg0[i]);
44 } 44 }
45 return new _AllOf(arg0); 45 return new _AllOf(arg0);
46 } else { 46 } else {
47 List matchers = new List(); 47 List matchers = new List();
48 if (arg0 != null) { 48 if (arg0 != null) {
49 matchers.add(arg0); 49 matchers.add(wrapMatcher(arg0));
50 } 50 }
51 if (arg1 != null) { 51 if (arg1 != null) {
52 matchers.add(arg1); 52 matchers.add(wrapMatcher(arg1));
53 } 53 }
54 if (arg2 != null) { 54 if (arg2 != null) {
55 matchers.add(arg2); 55 matchers.add(wrapMatcher(arg2));
56 } 56 }
57 if (arg3 != null) { 57 if (arg3 != null) {
58 matchers.add(arg3); 58 matchers.add(wrapMatcher(arg3));
59 } 59 }
60 if (arg4 != null) { 60 if (arg4 != null) {
61 matchers.add(arg4); 61 matchers.add(wrapMatcher(arg4));
62 } 62 }
63 if (arg5 != null) { 63 if (arg5 != null) {
64 matchers.add(arg5); 64 matchers.add(wrapMatcher(arg5));
65 } 65 }
66 if (arg6 != null) { 66 if (arg6 != null) {
67 matchers.add(arg6); 67 matchers.add(wrapMatcher(arg6));
68 } 68 }
69 return new _AllOf(matchers); 69 return new _AllOf(matchers);
70 } 70 }
71 } 71 }
72 72
73 class _AllOf extends BaseMatcher { 73 class _AllOf extends BaseMatcher {
74 final Iterable<Matcher> _matchers; 74 final Iterable<Matcher> _matchers;
75 75
76 const _AllOf(this._matchers); 76 const _AllOf(this._matchers);
77 77
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 expect(arg4, isNull); 125 expect(arg4, isNull);
126 expect(arg5, isNull); 126 expect(arg5, isNull);
127 expect(arg6, isNull); 127 expect(arg6, isNull);
128 for (int i = 0; i < arg0.length; i++) { 128 for (int i = 0; i < arg0.length; i++) {
129 arg0[i] = wrapMatcher(arg0[i]); 129 arg0[i] = wrapMatcher(arg0[i]);
130 } 130 }
131 return new _AnyOf(arg0); 131 return new _AnyOf(arg0);
132 } else { 132 } else {
133 List matchers = new List(); 133 List matchers = new List();
134 if (arg0 != null) { 134 if (arg0 != null) {
135 matchers.add(arg0); 135 matchers.add(wrapMatcher(arg0));
136 } 136 }
137 if (arg1 != null) { 137 if (arg1 != null) {
138 matchers.add(arg1); 138 matchers.add(wrapMatcher(arg1));
139 } 139 }
140 if (arg2 != null) { 140 if (arg2 != null) {
141 matchers.add(arg2); 141 matchers.add(wrapMatcher(arg2));
142 } 142 }
143 if (arg3 != null) { 143 if (arg3 != null) {
144 matchers.add(arg3); 144 matchers.add(wrapMatcher(arg3));
145 } 145 }
146 if (arg4 != null) { 146 if (arg4 != null) {
147 matchers.add(arg4); 147 matchers.add(wrapMatcher(arg4));
148 } 148 }
149 if (arg5 != null) { 149 if (arg5 != null) {
150 matchers.add(arg5); 150 matchers.add(wrapMatcher(arg5));
151 } 151 }
152 if (arg6 != null) { 152 if (arg6 != null) {
153 matchers.add(arg6); 153 matchers.add(wrapMatcher(arg6));
154 } 154 }
155 return new _AnyOf(matchers); 155 return new _AnyOf(matchers);
156 } 156 }
157 } 157 }
158 158
159 class _AnyOf extends BaseMatcher { 159 class _AnyOf extends BaseMatcher {
160 final Iterable<Matcher> _matchers; 160 final Iterable<Matcher> _matchers;
161 161
162 const _AnyOf(this._matchers); 162 const _AnyOf(this._matchers);
163 163
164 bool matches(item) { 164 bool matches(item) {
165 for (var matcher in _matchers) { 165 for (var matcher in _matchers) {
166 if (matcher.matches(item)) { 166 if (matcher.matches(item)) {
167 return true; 167 return true;
168 } 168 }
169 } 169 }
170 return false; 170 return false;
171 } 171 }
172 172
173 Description describe(Description description) => 173 Description describe(Description description) =>
174 description.addAll('(', ' or ', ')', _matchers); 174 description.addAll('(', ' or ', ')', _matchers);
175 } 175 }
176 176
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698