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

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

Issue 20586002: Add matchers for some more recent error types. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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
« no previous file with comments | « pkg/unittest/lib/src/core_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 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 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 }); 699 });
700 }); 700 });
701 701
702 group('Predicate Matchers', () { 702 group('Predicate Matchers', () {
703 test('isInstanceOf', () { 703 test('isInstanceOf', () {
704 shouldFail(0, predicate((x) => x is String, "an instance of String"), 704 shouldFail(0, predicate((x) => x is String, "an instance of String"),
705 "Expected: an instance of String Actual: <0>"); 705 "Expected: an instance of String Actual: <0>");
706 shouldPass('cow', predicate((x) => x is String, "an instance of String")); 706 shouldPass('cow', predicate((x) => x is String, "an instance of String"));
707 }); 707 });
708 }); 708 });
709
710 group('exception/error matchers', () {
711 // TODO(gram): extend this to more types; for now this is just
712 // the types being added in this CL.
713
714 // TODO: enable this test when it works.
715 // See issue 12052.
716 skip_test('throwsCyclicInitializationError', () {
717 expect(() => new Bicycle(), throwsCyclicInitializationError);
718 });
719
720 test('throwsAbstractClassInstantiationError', () {
721 expect(() => new Abstraction(), throwsAbstractClassInstantiationError);
722 });
723
724 test('throwsConcurrentModificationError', () {
725 expect(() {
726 var a = { 'foo': 'bar' };
727 for (var k in a.keys) {
728 a.remove(k);
729 }
730 }, throwsConcurrentModificationError);
731 });
732
733 test('throwsNullThrownError', () {
734 expect(() => throw null, throwsNullThrownError);
735 });
736
737 test('throwsFallThroughError', () {
738 expect(() {
739 var a = 0;
740 switch (a) {
741 case 0:
742 a += 1;
743 case 1:
744 return;
745 }
746 }, throwsFallThroughError);
747 });
748 });
709 } 749 }
710 750
751 class Bicycle {
752 static var foo = bar();
753
754 static bar() {
755 return foo + 1;
756 }
757
758 X() {
759 print(foo);
760 }
761 }
762
763 abstract class Abstraction {
764 void norealization();
765 }
766
OLDNEW
« no previous file with comments | « pkg/unittest/lib/src/core_matchers.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698