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

Side by Side Diff: pkg/matcher/lib/src/error_matchers.dart

Issue 438473002: pkg/matcher: refactored code around data-structure vs execution-based matchers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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/matcher/lib/src/core_matchers.dart ('k') | pkg/matcher/lib/src/expect.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 library matcher.error_matchers; 5 library matcher.error_matchers;
6 6
7 import 'core_matchers.dart'; 7 import 'core_matchers.dart';
8 import 'interfaces.dart'; 8 import 'interfaces.dart';
9 9
10 /// A matcher for ArgumentErrors. 10 /// A matcher for ArgumentErrors.
11 const Matcher isArgumentError = const _ArgumentError(); 11 const Matcher isArgumentError = const _ArgumentError();
12 12
13 /// A matcher for functions that throw ArgumentError.
14 const Matcher throwsArgumentError = const Throws(isArgumentError);
15
16 class _ArgumentError extends TypeMatcher { 13 class _ArgumentError extends TypeMatcher {
17 const _ArgumentError(): super("ArgumentError"); 14 const _ArgumentError(): super("ArgumentError");
18 bool matches(item, Map matchState) => item is ArgumentError; 15 bool matches(item, Map matchState) => item is ArgumentError;
19 } 16 }
20 17
21 /// A matcher for ConcurrentModificationError. 18 /// A matcher for ConcurrentModificationError.
22 const Matcher isConcurrentModificationError = 19 const Matcher isConcurrentModificationError =
23 const _ConcurrentModificationError(); 20 const _ConcurrentModificationError();
24 21
25 /// A matcher for functions that throw ConcurrentModificationError.
26 const Matcher throwsConcurrentModificationError =
27 const Throws(isConcurrentModificationError);
28
29 class _ConcurrentModificationError extends TypeMatcher { 22 class _ConcurrentModificationError extends TypeMatcher {
30 const _ConcurrentModificationError(): super("ConcurrentModificationError"); 23 const _ConcurrentModificationError(): super("ConcurrentModificationError");
31 bool matches(item, Map matchState) => item is ConcurrentModificationError; 24 bool matches(item, Map matchState) => item is ConcurrentModificationError;
32 } 25 }
33 26
34 /// A matcher for CyclicInitializationError. 27 /// A matcher for CyclicInitializationError.
35 const Matcher isCyclicInitializationError = const _CyclicInitializationError(); 28 const Matcher isCyclicInitializationError = const _CyclicInitializationError();
36 29
37 /// A matcher for functions that throw CyclicInitializationError.
38 const Matcher throwsCyclicInitializationError =
39 const Throws(isCyclicInitializationError);
40
41 class _CyclicInitializationError extends TypeMatcher { 30 class _CyclicInitializationError extends TypeMatcher {
42 const _CyclicInitializationError(): super("CyclicInitializationError"); 31 const _CyclicInitializationError(): super("CyclicInitializationError");
43 bool matches(item, Map matchState) => item is CyclicInitializationError; 32 bool matches(item, Map matchState) => item is CyclicInitializationError;
44 } 33 }
45 34
46 /// A matcher for Exceptions. 35 /// A matcher for Exceptions.
47 const Matcher isException = const _Exception(); 36 const Matcher isException = const _Exception();
48 37
49 /// A matcher for functions that throw Exception.
50 const Matcher throwsException = const Throws(isException);
51
52 class _Exception extends TypeMatcher { 38 class _Exception extends TypeMatcher {
53 const _Exception(): super("Exception"); 39 const _Exception(): super("Exception");
54 bool matches(item, Map matchState) => item is Exception; 40 bool matches(item, Map matchState) => item is Exception;
55 } 41 }
56 42
57 class _FallThroughError extends TypeMatcher { 43 class _FallThroughError extends TypeMatcher {
58 const _FallThroughError(): super("FallThroughError"); 44 const _FallThroughError(): super("FallThroughError");
59 bool matches(item, Map matchState) => item is FallThroughError; 45 bool matches(item, Map matchState) => item is FallThroughError;
60 } 46 }
61 47
62 /// A matcher for FormatExceptions. 48 /// A matcher for FormatExceptions.
63 const Matcher isFormatException = const _FormatException(); 49 const Matcher isFormatException = const _FormatException();
64 50
65 /// A matcher for functions that throw FormatException.
66 const Matcher throwsFormatException = const Throws(isFormatException);
67
68 class _FormatException extends TypeMatcher { 51 class _FormatException extends TypeMatcher {
69 const _FormatException(): super("FormatException"); 52 const _FormatException(): super("FormatException");
70 bool matches(item, Map matchState) => item is FormatException; 53 bool matches(item, Map matchState) => item is FormatException;
71 } 54 }
72 55
73 /// A matcher for NoSuchMethodErrors. 56 /// A matcher for NoSuchMethodErrors.
74 const Matcher isNoSuchMethodError = const _NoSuchMethodError(); 57 const Matcher isNoSuchMethodError = const _NoSuchMethodError();
75 58
76 /// A matcher for functions that throw NoSuchMethodError.
77 const Matcher throwsNoSuchMethodError = const Throws(isNoSuchMethodError);
78
79 class _NoSuchMethodError extends TypeMatcher { 59 class _NoSuchMethodError extends TypeMatcher {
80 const _NoSuchMethodError(): super("NoSuchMethodError"); 60 const _NoSuchMethodError(): super("NoSuchMethodError");
81 bool matches(item, Map matchState) => item is NoSuchMethodError; 61 bool matches(item, Map matchState) => item is NoSuchMethodError;
82 } 62 }
83 63
84 /// A matcher for NullThrownError. 64 /// A matcher for NullThrownError.
85 const Matcher isNullThrownError = const _NullThrownError(); 65 const Matcher isNullThrownError = const _NullThrownError();
86 66
87 /// A matcher for functions that throw NullThrownError.
88 const Matcher throwsNullThrownError = const Throws(isNullThrownError);
89
90 class _NullThrownError extends TypeMatcher { 67 class _NullThrownError extends TypeMatcher {
91 const _NullThrownError(): super("NullThrownError"); 68 const _NullThrownError(): super("NullThrownError");
92 bool matches(item, Map matchState) => item is NullThrownError; 69 bool matches(item, Map matchState) => item is NullThrownError;
93 } 70 }
94 71
95 /// A matcher for RangeErrors. 72 /// A matcher for RangeErrors.
96 const Matcher isRangeError = const _RangeError(); 73 const Matcher isRangeError = const _RangeError();
97 74
98 /// A matcher for functions that throw RangeError.
99 const Matcher throwsRangeError = const Throws(isRangeError);
100
101 class _RangeError extends TypeMatcher { 75 class _RangeError extends TypeMatcher {
102 const _RangeError(): super("RangeError"); 76 const _RangeError(): super("RangeError");
103 bool matches(item, Map matchState) => item is RangeError; 77 bool matches(item, Map matchState) => item is RangeError;
104 } 78 }
105 79
106 /// A matcher for StateErrors. 80 /// A matcher for StateErrors.
107 const Matcher isStateError = const _StateError(); 81 const Matcher isStateError = const _StateError();
108 82
109 /// A matcher for functions that throw StateError.
110 const Matcher throwsStateError = const Throws(isStateError);
111
112 class _StateError extends TypeMatcher { 83 class _StateError extends TypeMatcher {
113 const _StateError(): super("StateError"); 84 const _StateError(): super("StateError");
114 bool matches(item, Map matchState) => item is StateError; 85 bool matches(item, Map matchState) => item is StateError;
115 } 86 }
116 87
117 /// A matcher for UnimplementedErrors. 88 /// A matcher for UnimplementedErrors.
118 const Matcher isUnimplementedError = const _UnimplementedError(); 89 const Matcher isUnimplementedError = const _UnimplementedError();
119 90
120 /// A matcher for functions that throw Exception.
121 const Matcher throwsUnimplementedError = const Throws(isUnimplementedError);
122
123 class _UnimplementedError extends TypeMatcher { 91 class _UnimplementedError extends TypeMatcher {
124 const _UnimplementedError(): super("UnimplementedError"); 92 const _UnimplementedError(): super("UnimplementedError");
125 bool matches(item, Map matchState) => item is UnimplementedError; 93 bool matches(item, Map matchState) => item is UnimplementedError;
126 } 94 }
127 95
128 /// A matcher for UnsupportedError. 96 /// A matcher for UnsupportedError.
129 const Matcher isUnsupportedError = const _UnsupportedError(); 97 const Matcher isUnsupportedError = const _UnsupportedError();
130 98
131 /// A matcher for functions that throw UnsupportedError.
132 const Matcher throwsUnsupportedError = const Throws(isUnsupportedError);
133
134 class _UnsupportedError extends TypeMatcher { 99 class _UnsupportedError extends TypeMatcher {
135 const _UnsupportedError(): super("UnsupportedError"); 100 const _UnsupportedError(): super("UnsupportedError");
136 bool matches(item, Map matchState) => item is UnsupportedError; 101 bool matches(item, Map matchState) => item is UnsupportedError;
137 } 102 }
OLDNEW
« no previous file with comments | « pkg/matcher/lib/src/core_matchers.dart ('k') | pkg/matcher/lib/src/expect.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698