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

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

Issue 21085010: Added hasProperty matcher. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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 | « pkg/unittest/lib/src/core_matchers.dart ('k') | pkg/unittest/test/mirror_matchers_test.dart » ('j') | 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:collection'; 6 import 'dart:collection';
7 7
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 9
10 import 'test_common.dart'; 10 import 'test_common.dart';
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 test('lessThanOrEqualTo', () { 196 test('lessThanOrEqualTo', () {
197 shouldPass(10, lessThanOrEqualTo(10)); 197 shouldPass(10, lessThanOrEqualTo(10));
198 shouldFail(11, lessThanOrEqualTo(10), 198 shouldFail(11, lessThanOrEqualTo(10),
199 "Expected: a value less than or equal to <10> " 199 "Expected: a value less than or equal to <10> "
200 "Actual: <11> " 200 "Actual: <11> "
201 "Which: is not a value less than or equal to <10>"); 201 "Which: is not a value less than or equal to <10>");
202 }); 202 });
203 203
204 test('isZero', () { 204 test('isZero', () {
205 shouldPass(0, isZero); 205 shouldPass(0, isZero);
206 shouldFail(1, isZero, 206 shouldFail(1, isZero,
207 "Expected: a value equal to <0> " 207 "Expected: a value equal to <0> "
208 "Actual: <1> " 208 "Actual: <1> "
209 "Which: is not a value equal to <0>"); 209 "Which: is not a value equal to <0>");
210 }); 210 });
211 211
212 test('isNonZero', () { 212 test('isNonZero', () {
213 shouldFail(0, isNonZero, 213 shouldFail(0, isNonZero,
214 "Expected: a value not equal to <0> " 214 "Expected: a value not equal to <0> "
215 "Actual: <0> " 215 "Actual: <0> "
216 "Which: is not a value not equal to <0>"); 216 "Which: is not a value not equal to <0>");
217 shouldPass(1, isNonZero); 217 shouldPass(1, isNonZero);
218 }); 218 });
219 219
220 test('isPositive', () { 220 test('isPositive', () {
221 shouldFail(-1, isPositive, 221 shouldFail(-1, isPositive,
222 "Expected: a positive value " 222 "Expected: a positive value "
223 "Actual: <-1> " 223 "Actual: <-1> "
224 "Which: is not a positive value"); 224 "Which: is not a positive value");
225 shouldFail(0, isPositive, 225 shouldFail(0, isPositive,
226 "Expected: a positive value " 226 "Expected: a positive value "
227 "Actual: <0> " 227 "Actual: <0> "
228 "Which: is not a positive value"); 228 "Which: is not a positive value");
229 shouldPass(1, isPositive); 229 shouldPass(1, isPositive);
230 }); 230 });
231 231
232 test('isNegative', () { 232 test('isNegative', () {
233 shouldPass(-1, isNegative); 233 shouldPass(-1, isNegative);
234 shouldFail(0, isNegative, 234 shouldFail(0, isNegative,
235 "Expected: a negative value " 235 "Expected: a negative value "
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 test('nested everyElement', () { 421 test('nested everyElement', () {
422 var d = [['foo', 'bar'], ['foo'], []]; 422 var d = [['foo', 'bar'], ['foo'], []];
423 var e = [['foo', 'bar'], ['foo'], 3, []]; 423 var e = [['foo', 'bar'], ['foo'], 3, []];
424 shouldPass(d, everyElement(anyOf(isEmpty, contains('foo')))); 424 shouldPass(d, everyElement(anyOf(isEmpty, contains('foo'))));
425 shouldFail(d, everyElement(everyElement(equals('foo'))), 425 shouldFail(d, everyElement(everyElement(equals('foo'))),
426 "Expected: every element(every element('foo')) " 426 "Expected: every element(every element('foo')) "
427 "Actual: [['foo', 'bar'], ['foo'], []] " 427 "Actual: [['foo', 'bar'], ['foo'], []] "
428 "Which: has value ['foo', 'bar'] which has value 'bar' " 428 "Which: has value ['foo', 'bar'] which has value 'bar' "
429 "which is different. Expected: foo Actual: bar ^ " 429 "which is different. Expected: foo Actual: bar ^ "
430 "Differ at offset 0 at index 1 at index 0"); 430 "Differ at offset 0 at index 1 at index 0");
431 shouldFail(d, everyElement(allOf(hasLength(greaterThan(0)), 431 shouldFail(d, everyElement(allOf(hasLength(greaterThan(0)),
432 contains('foo'))), 432 contains('foo'))),
433 "Expected: every element((an object with length of a value " 433 "Expected: every element((an object with length of a value "
434 "greater than <0> and contains 'foo')) " 434 "greater than <0> and contains 'foo')) "
435 "Actual: [['foo', 'bar'], ['foo'], []] " 435 "Actual: [['foo', 'bar'], ['foo'], []] "
436 "Which: has value [] which has length of <0> at index 2"); 436 "Which: has value [] which has length of <0> at index 2");
437 shouldFail(d, everyElement(allOf(contains('foo'), 437 shouldFail(d, everyElement(allOf(contains('foo'),
438 hasLength(greaterThan(0)))), 438 hasLength(greaterThan(0)))),
439 "Expected: every element((contains 'foo' and " 439 "Expected: every element((contains 'foo' and "
440 "an object with length of a value greater than <0>)) " 440 "an object with length of a value greater than <0>)) "
441 "Actual: [['foo', 'bar'], ['foo'], []] " 441 "Actual: [['foo', 'bar'], ['foo'], []] "
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 static var foo = bar(); 752 static var foo = bar();
753 753
754 static bar() { 754 static bar() {
755 return foo + 1; 755 return foo + 1;
756 } 756 }
757 757
758 X() { 758 X() {
759 print(foo); 759 print(foo);
760 } 760 }
761 } 761 }
762 762
763 abstract class Abstraction { 763 abstract class Abstraction {
764 void norealization(); 764 void norealization();
765 } 765 }
766 766
OLDNEW
« no previous file with comments | « pkg/unittest/lib/src/core_matchers.dart ('k') | pkg/unittest/test/mirror_matchers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698