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

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

Issue 184103002: Support nested matchers in deep equality matching. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 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_utils.dart'; 10 import 'test_utils.dart';
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 shouldFail([1], isEmpty, "Expected: empty Actual: [1]"); 394 shouldFail([1], isEmpty, "Expected: empty Actual: [1]");
395 }); 395 });
396 396
397 test('contains', () { 397 test('contains', () {
398 var d = [1, 2]; 398 var d = [1, 2];
399 shouldPass(d, contains(1)); 399 shouldPass(d, contains(1));
400 shouldFail(d, contains(0), "Expected: contains <0> " 400 shouldFail(d, contains(0), "Expected: contains <0> "
401 "Actual: [1, 2]"); 401 "Actual: [1, 2]");
402 }); 402 });
403 403
404 test('equals with matcher element', () {
405 var d = ['foo', 'bar'];
406 shouldPass(d, equals(['foo', startsWith('ba')]));
407 shouldFail(d, equals(['foo', endsWith('ba')]),
408 "Expected: ['foo', <a string ending with 'ba'>] "
409 "Actual: ['foo', 'bar'] "
410 "Which: does not match a string ending with 'ba' at location [1]");
411 });
412
404 test('isIn', () { 413 test('isIn', () {
405 var d = [1, 2]; 414 var d = [1, 2];
406 shouldPass(1, isIn(d)); 415 shouldPass(1, isIn(d));
407 shouldFail(0, isIn(d), "Expected: is in [1, 2] Actual: <0>"); 416 shouldFail(0, isIn(d), "Expected: is in [1, 2] Actual: <0>");
408 }); 417 });
409 418
410 test('everyElement', () { 419 test('everyElement', () {
411 var d = [1, 2]; 420 var d = [1, 2];
412 var e = [1, 1, 1]; 421 var e = [1, 1, 1];
413 shouldFail(d, everyElement(1), 422 shouldFail(d, everyElement(1),
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 shouldFail(a, equals(c), 595 shouldFail(a, equals(c),
587 "Expected: {'bar': 'foo', 'barrista': 'caffeine'} " 596 "Expected: {'bar': 'foo', 'barrista': 'caffeine'} "
588 "Actual: {'foo': 'bar'} " 597 "Actual: {'foo': 'bar'} "
589 "Which: has different length and is missing map key 'bar'"); 598 "Which: has different length and is missing map key 'bar'");
590 shouldFail(c, equals(a), 599 shouldFail(c, equals(a),
591 "Expected: {'foo': 'bar'} " 600 "Expected: {'foo': 'bar'} "
592 "Actual: {'bar': 'foo', 'barrista': 'caffeine'} " 601 "Actual: {'bar': 'foo', 'barrista': 'caffeine'} "
593 "Which: has different length and is missing map key 'foo'"); 602 "Which: has different length and is missing map key 'foo'");
594 }); 603 });
595 604
605 test('equals with matcher value', () {
606 var a = new Map();
607 a['foo'] = 'bar';
608 shouldPass(a, equals({'foo': startsWith('ba')}));
609 shouldFail(a, equals({'foo': endsWith('ba')}),
610 "Expected: {'foo': <a string ending with 'ba'>} "
611 "Actual: {'foo': 'bar'} "
612 "Which: does not match a string ending with 'ba' at location ['foo']") ;
Siggi Cherem (dart-lang) 2014/02/28 02:41:04 80 col
Bob Nystrom 2014/02/28 17:31:24 Done.
613 });
614
596 test('contains', () { 615 test('contains', () {
597 var a = new Map(); 616 var a = new Map();
598 a['foo'] = 'bar'; 617 a['foo'] = 'bar';
599 var b = new Map(); 618 var b = new Map();
600 shouldPass(a, contains('foo')); 619 shouldPass(a, contains('foo'));
601 shouldFail(b, contains('foo'), 620 shouldFail(b, contains('foo'),
602 "Expected: contains 'foo' Actual: {}"); 621 "Expected: contains 'foo' Actual: {}");
603 shouldFail(10, contains('foo'), 622 shouldFail(10, contains('foo'),
604 "Expected: contains 'foo' Actual: <10> " 623 "Expected: contains 'foo' Actual: <10> "
605 "Which: is not a string, map or iterable"); 624 "Which: is not a string, map or iterable");
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 798
780 X() { 799 X() {
781 print(foo); 800 print(foo);
782 } 801 }
783 } 802 }
784 803
785 abstract class Abstraction { 804 abstract class Abstraction {
786 void norealization(); 805 void norealization();
787 } 806 }
788 807
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698