| OLD | NEW |
| (Empty) |
| 1 dart_library.library('matcher', null, /* Imports */[ | |
| 2 'dart_sdk' | |
| 3 ], function load__matcher(exports, dart_sdk) { | |
| 4 'use strict'; | |
| 5 const core = dart_sdk.core; | |
| 6 const mirrors = dart_sdk.mirrors; | |
| 7 const _interceptors = dart_sdk._interceptors; | |
| 8 const dart = dart_sdk.dart; | |
| 9 const dartx = dart_sdk.dartx; | |
| 10 const matcher = Object.create(null); | |
| 11 const mirror_matchers = Object.create(null); | |
| 12 const src__core_matchers = Object.create(null); | |
| 13 const src__description = Object.create(null); | |
| 14 const src__error_matchers = Object.create(null); | |
| 15 const src__interfaces = Object.create(null); | |
| 16 const src__iterable_matchers = Object.create(null); | |
| 17 const src__map_matchers = Object.create(null); | |
| 18 const src__numeric_matchers = Object.create(null); | |
| 19 const src__operator_matchers = Object.create(null); | |
| 20 const src__pretty_print = Object.create(null); | |
| 21 const src__string_matchers = Object.create(null); | |
| 22 const src__util = Object.create(null); | |
| 23 let dynamicTobool = () => (dynamicTobool = dart.constFn(dart.functionType(core
.bool, [dart.dynamic])))(); | |
| 24 let isInstanceOf = () => (isInstanceOf = dart.constFn(src__core_matchers.isIns
tanceOf$()))(); | |
| 25 let dynamicAnddynamicTobool = () => (dynamicAnddynamicTobool = dart.constFn(da
rt.functionType(core.bool, [dart.dynamic, dart.dynamic])))(); | |
| 26 let ListOfString = () => (ListOfString = dart.constFn(core.List$(core.String))
)(); | |
| 27 let JSArrayOfString = () => (JSArrayOfString = dart.constFn(_interceptors.JSAr
ray$(core.String)))(); | |
| 28 let ListOfbool = () => (ListOfbool = dart.constFn(core.List$(core.bool)))(); | |
| 29 let ListOfMatcher = () => (ListOfMatcher = dart.constFn(core.List$(src__interf
aces.Matcher)))(); | |
| 30 let dynamicToMatcher = () => (dynamicToMatcher = dart.constFn(dart.definiteFun
ctionType(src__interfaces.Matcher, [dart.dynamic])))(); | |
| 31 let dynamic__ToMatcher = () => (dynamic__ToMatcher = dart.constFn(dart.definit
eFunctionType(src__interfaces.Matcher, [dart.dynamic], [core.int])))(); | |
| 32 let Fn__ToMatcher = () => (Fn__ToMatcher = dart.constFn(dart.definiteFunctionT
ype(src__interfaces.Matcher, [dynamicTobool()], [core.String])))(); | |
| 33 let IterableAndFnAndStringToMatcher = () => (IterableAndFnAndStringToMatcher =
dart.constFn(dart.definiteFunctionType(src__interfaces.Matcher, [core.Iterable,
dynamicAnddynamicTobool(), core.String])))(); | |
| 34 let IterableToMatcher = () => (IterableToMatcher = dart.constFn(dart.definiteF
unctionType(src__interfaces.Matcher, [core.Iterable])))(); | |
| 35 let dynamicAnddynamicToMatcher = () => (dynamicAnddynamicToMatcher = dart.cons
tFn(dart.definiteFunctionType(src__interfaces.Matcher, [dart.dynamic, dart.dynam
ic])))(); | |
| 36 let numAndnumToMatcher = () => (numAndnumToMatcher = dart.constFn(dart.definit
eFunctionType(src__interfaces.Matcher, [core.num, core.num])))(); | |
| 37 let dynamic__ToMatcher$ = () => (dynamic__ToMatcher$ = dart.constFn(dart.defin
iteFunctionType(src__interfaces.Matcher, [dart.dynamic], [dart.dynamic, dart.dyn
amic, dart.dynamic, dart.dynamic, dart.dynamic, dart.dynamic])))(); | |
| 38 let StringToMatcher = () => (StringToMatcher = dart.constFn(dart.definiteFunct
ionType(src__interfaces.Matcher, [core.String])))(); | |
| 39 let StringToString = () => (StringToString = dart.constFn(dart.definiteFunctio
nType(core.String, [core.String])))(); | |
| 40 let ListOfStringToMatcher = () => (ListOfStringToMatcher = dart.constFn(dart.d
efiniteFunctionType(src__interfaces.Matcher, [ListOfString()])))(); | |
| 41 let MapAndMapTovoid = () => (MapAndMapTovoid = dart.constFn(dart.definiteFunct
ionType(dart.void, [core.Map, core.Map])))(); | |
| 42 let MatchToString = () => (MatchToString = dart.constFn(dart.definiteFunctionT
ype(core.String, [core.Match])))(); | |
| 43 let String__ToMatcher = () => (String__ToMatcher = dart.constFn(dart.definiteF
unctionType(src__interfaces.Matcher, [core.String], [dart.dynamic])))(); | |
| 44 let dynamicTobool$ = () => (dynamicTobool$ = dart.constFn(dart.definiteFunctio
nType(core.bool, [dart.dynamic])))(); | |
| 45 let dynamicAnddynamicAnddynamic__ToListOfMatcher = () => (dynamicAnddynamicAnd
dynamic__ToListOfMatcher = dart.constFn(dart.definiteFunctionType(ListOfMatcher(
), [dart.dynamic, dart.dynamic, dart.dynamic, dart.dynamic, dart.dynamic, dart.d
ynamic, dart.dynamic])))(); | |
| 46 let dynamicToString = () => (dynamicToString = dart.constFn(dart.definiteFunct
ionType(core.String, [dart.dynamic])))(); | |
| 47 let dynamicAndintAndSet__ToString = () => (dynamicAndintAndSet__ToString = dar
t.constFn(dart.definiteFunctionType(core.String, [dart.dynamic, core.int, core.S
et, core.bool])))(); | |
| 48 let dynamic__ToString = () => (dynamic__ToString = dart.constFn(dart.definiteF
unctionType(core.String, [dart.dynamic], {maxLineLength: core.int, maxItems: cor
e.int})))(); | |
| 49 let intToString = () => (intToString = dart.constFn(dart.definiteFunctionType(
core.String, [core.int])))(); | |
| 50 let StringTobool = () => (StringTobool = dart.constFn(dart.definiteFunctionTyp
e(core.bool, [core.String])))(); | |
| 51 src__interfaces.Matcher = class Matcher extends core.Object { | |
| 52 new() { | |
| 53 } | |
| 54 describeMismatch(item, mismatchDescription, matchState, verbose) { | |
| 55 return mismatchDescription; | |
| 56 } | |
| 57 }; | |
| 58 dart.setSignature(src__interfaces.Matcher, { | |
| 59 constructors: () => ({new: dart.definiteFunctionType(src__interfaces.Matcher
, [])}), | |
| 60 methods: () => ({describeMismatch: dart.definiteFunctionType(src__interfaces
.Description, [dart.dynamic, src__interfaces.Description, core.Map, core.bool])}
) | |
| 61 }); | |
| 62 src__core_matchers._IsTrue = class _IsTrue extends src__interfaces.Matcher { | |
| 63 new() { | |
| 64 super.new(); | |
| 65 } | |
| 66 matches(item, matchState) { | |
| 67 return dart.equals(item, true); | |
| 68 } | |
| 69 describe(description) { | |
| 70 return description.add('true'); | |
| 71 } | |
| 72 }; | |
| 73 dart.setSignature(src__core_matchers._IsTrue, { | |
| 74 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers._IsT
rue, [])}), | |
| 75 methods: () => ({ | |
| 76 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 77 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 78 }) | |
| 79 }); | |
| 80 src__core_matchers.isTrue = dart.const(new src__core_matchers._IsTrue()); | |
| 81 matcher.isTrue = src__core_matchers.isTrue; | |
| 82 src__core_matchers._IsFalse = class _IsFalse extends src__interfaces.Matcher { | |
| 83 new() { | |
| 84 super.new(); | |
| 85 } | |
| 86 matches(item, matchState) { | |
| 87 return dart.equals(item, false); | |
| 88 } | |
| 89 describe(description) { | |
| 90 return description.add('false'); | |
| 91 } | |
| 92 }; | |
| 93 dart.setSignature(src__core_matchers._IsFalse, { | |
| 94 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers._IsF
alse, [])}), | |
| 95 methods: () => ({ | |
| 96 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 97 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 98 }) | |
| 99 }); | |
| 100 src__core_matchers.isFalse = dart.const(new src__core_matchers._IsFalse()); | |
| 101 matcher.isFalse = src__core_matchers.isFalse; | |
| 102 src__core_matchers._Empty = class _Empty extends src__interfaces.Matcher { | |
| 103 new() { | |
| 104 super.new(); | |
| 105 } | |
| 106 matches(item, matchState) { | |
| 107 return core.bool._check(dart.dload(item, 'isEmpty')); | |
| 108 } | |
| 109 describe(description) { | |
| 110 return description.add('empty'); | |
| 111 } | |
| 112 }; | |
| 113 dart.setSignature(src__core_matchers._Empty, { | |
| 114 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers._Emp
ty, [])}), | |
| 115 methods: () => ({ | |
| 116 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 117 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 118 }) | |
| 119 }); | |
| 120 src__core_matchers.isEmpty = dart.const(new src__core_matchers._Empty()); | |
| 121 matcher.isEmpty = src__core_matchers.isEmpty; | |
| 122 src__core_matchers.same = function(expected) { | |
| 123 return new src__core_matchers._IsSameAs(expected); | |
| 124 }; | |
| 125 dart.fn(src__core_matchers.same, dynamicToMatcher()); | |
| 126 matcher.same = src__core_matchers.same; | |
| 127 src__core_matchers.equals = function(expected, limit) { | |
| 128 if (limit === void 0) limit = 100; | |
| 129 return typeof expected == 'string' ? new src__core_matchers._StringEqualsMat
cher(expected) : new src__core_matchers._DeepMatcher(expected, limit); | |
| 130 }; | |
| 131 dart.fn(src__core_matchers.equals, dynamic__ToMatcher()); | |
| 132 matcher.equals = src__core_matchers.equals; | |
| 133 const _featureDescription = Symbol('_featureDescription'); | |
| 134 const _featureName = Symbol('_featureName'); | |
| 135 const _matcher = Symbol('_matcher'); | |
| 136 src__core_matchers.CustomMatcher = class CustomMatcher extends src__interfaces
.Matcher { | |
| 137 new(featureDescription, featureName, matcher) { | |
| 138 this[_featureDescription] = featureDescription; | |
| 139 this[_featureName] = featureName; | |
| 140 this[_matcher] = src__util.wrapMatcher(matcher); | |
| 141 super.new(); | |
| 142 } | |
| 143 featureValueOf(actual) { | |
| 144 return actual; | |
| 145 } | |
| 146 matches(item, matchState) { | |
| 147 let f = this.featureValueOf(item); | |
| 148 if (dart.test(this[_matcher].matches(f, matchState))) return true; | |
| 149 src__util.addStateInfo(matchState, dart.map({feature: f}, core.String, dar
t.dynamic)); | |
| 150 return false; | |
| 151 } | |
| 152 describe(description) { | |
| 153 return description.add(this[_featureDescription]).add(' ').addDescriptionO
f(this[_matcher]); | |
| 154 } | |
| 155 describeMismatch(item, mismatchDescription, matchState, verbose) { | |
| 156 mismatchDescription.add('has ').add(this[_featureName]).add(' with value '
).addDescriptionOf(matchState[dartx.get]('feature')); | |
| 157 let innerDescription = new src__description.StringDescription(); | |
| 158 this[_matcher].describeMismatch(matchState[dartx.get]('feature'), innerDes
cription, core.Map._check(matchState[dartx.get]('state')), verbose); | |
| 159 if (dart.notNull(innerDescription.length) > 0) { | |
| 160 mismatchDescription.add(' which ').add(innerDescription.toString()); | |
| 161 } | |
| 162 return mismatchDescription; | |
| 163 } | |
| 164 }; | |
| 165 dart.setSignature(src__core_matchers.CustomMatcher, { | |
| 166 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers.Cust
omMatcher, [core.String, core.String, dart.dynamic])}), | |
| 167 methods: () => ({ | |
| 168 featureValueOf: dart.definiteFunctionType(dart.dynamic, [dart.dynamic]), | |
| 169 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 170 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 171 }) | |
| 172 }); | |
| 173 matcher.CustomMatcher = src__core_matchers.CustomMatcher; | |
| 174 const _name = Symbol('_name'); | |
| 175 src__core_matchers.TypeMatcher = class TypeMatcher extends src__interfaces.Mat
cher { | |
| 176 new(name) { | |
| 177 this[_name] = name; | |
| 178 super.new(); | |
| 179 } | |
| 180 describe(description) { | |
| 181 return description.add(this[_name]); | |
| 182 } | |
| 183 }; | |
| 184 dart.setSignature(src__core_matchers.TypeMatcher, { | |
| 185 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers.Type
Matcher, [core.String])}), | |
| 186 methods: () => ({describe: dart.definiteFunctionType(src__interfaces.Descrip
tion, [src__interfaces.Description])}) | |
| 187 }); | |
| 188 src__core_matchers._IsList = class _IsList extends src__core_matchers.TypeMatc
her { | |
| 189 new() { | |
| 190 super.new("List"); | |
| 191 } | |
| 192 matches(item, matchState) { | |
| 193 return core.List.is(item); | |
| 194 } | |
| 195 }; | |
| 196 dart.setSignature(src__core_matchers._IsList, { | |
| 197 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers._IsL
ist, [])}), | |
| 198 methods: () => ({matches: dart.definiteFunctionType(core.bool, [dart.dynamic
, core.Map])}) | |
| 199 }); | |
| 200 src__core_matchers.isList = dart.const(new src__core_matchers._IsList()); | |
| 201 matcher.isList = src__core_matchers.isList; | |
| 202 src__core_matchers.predicate = function(f, description) { | |
| 203 if (description === void 0) description = 'satisfies function'; | |
| 204 return new src__core_matchers._Predicate(f, description); | |
| 205 }; | |
| 206 dart.fn(src__core_matchers.predicate, Fn__ToMatcher()); | |
| 207 matcher.predicate = src__core_matchers.predicate; | |
| 208 src__core_matchers._IsNotNull = class _IsNotNull extends src__interfaces.Match
er { | |
| 209 new() { | |
| 210 super.new(); | |
| 211 } | |
| 212 matches(item, matchState) { | |
| 213 return item != null; | |
| 214 } | |
| 215 describe(description) { | |
| 216 return description.add('not null'); | |
| 217 } | |
| 218 }; | |
| 219 dart.setSignature(src__core_matchers._IsNotNull, { | |
| 220 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers._IsN
otNull, [])}), | |
| 221 methods: () => ({ | |
| 222 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 223 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 224 }) | |
| 225 }); | |
| 226 src__core_matchers.isNotNull = dart.const(new src__core_matchers._IsNotNull())
; | |
| 227 matcher.isNotNull = src__core_matchers.isNotNull; | |
| 228 src__core_matchers.hasLength = function(matcher) { | |
| 229 return new src__core_matchers._HasLength(src__util.wrapMatcher(matcher)); | |
| 230 }; | |
| 231 dart.fn(src__core_matchers.hasLength, dynamicToMatcher()); | |
| 232 matcher.hasLength = src__core_matchers.hasLength; | |
| 233 src__core_matchers.isInstanceOf$ = dart.generic(T => { | |
| 234 class isInstanceOf extends src__interfaces.Matcher { | |
| 235 new() { | |
| 236 super.new(); | |
| 237 } | |
| 238 matches(obj, matchState) { | |
| 239 return T.is(obj); | |
| 240 } | |
| 241 describe(description) { | |
| 242 return description.add(dart.str`an instance of ${dart.wrapType(T)}`); | |
| 243 } | |
| 244 } | |
| 245 dart.addTypeTests(isInstanceOf); | |
| 246 dart.setSignature(isInstanceOf, { | |
| 247 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers.is
InstanceOf$(T), [])}), | |
| 248 methods: () => ({ | |
| 249 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 250 describe: dart.definiteFunctionType(src__interfaces.Description, [src__i
nterfaces.Description]) | |
| 251 }) | |
| 252 }); | |
| 253 return isInstanceOf; | |
| 254 }); | |
| 255 src__core_matchers.isInstanceOf = isInstanceOf(); | |
| 256 matcher.isInstanceOf$ = src__core_matchers.isInstanceOf$; | |
| 257 matcher.isInstanceOf = src__core_matchers.isInstanceOf; | |
| 258 src__core_matchers._IsNaN = class _IsNaN extends src__interfaces.Matcher { | |
| 259 new() { | |
| 260 super.new(); | |
| 261 } | |
| 262 matches(item, matchState) { | |
| 263 return core.double.NAN[dartx.compareTo](core.num._check(item)) == 0; | |
| 264 } | |
| 265 describe(description) { | |
| 266 return description.add('NaN'); | |
| 267 } | |
| 268 }; | |
| 269 dart.setSignature(src__core_matchers._IsNaN, { | |
| 270 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers._IsN
aN, [])}), | |
| 271 methods: () => ({ | |
| 272 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 273 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 274 }) | |
| 275 }); | |
| 276 src__core_matchers.isNaN = dart.const(new src__core_matchers._IsNaN()); | |
| 277 matcher.isNaN = src__core_matchers.isNaN; | |
| 278 src__core_matchers._ReturnsNormally = class _ReturnsNormally extends src__inte
rfaces.Matcher { | |
| 279 new() { | |
| 280 super.new(); | |
| 281 } | |
| 282 matches(f, matchState) { | |
| 283 try { | |
| 284 dart.dcall(f); | |
| 285 return true; | |
| 286 } catch (e) { | |
| 287 let s = dart.stackTrace(e); | |
| 288 src__util.addStateInfo(matchState, dart.map({exception: e, stack: s}, co
re.String, dart.dynamic)); | |
| 289 return false; | |
| 290 } | |
| 291 | |
| 292 } | |
| 293 describe(description) { | |
| 294 return description.add("return normally"); | |
| 295 } | |
| 296 describeMismatch(item, mismatchDescription, matchState, verbose) { | |
| 297 mismatchDescription.add('threw ').addDescriptionOf(matchState[dartx.get]('
exception')); | |
| 298 if (dart.test(verbose)) { | |
| 299 mismatchDescription.add(' at ').add(dart.toString(matchState[dartx.get](
'stack'))); | |
| 300 } | |
| 301 return mismatchDescription; | |
| 302 } | |
| 303 }; | |
| 304 dart.setSignature(src__core_matchers._ReturnsNormally, { | |
| 305 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers._Ret
urnsNormally, [])}), | |
| 306 methods: () => ({ | |
| 307 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 308 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 309 }) | |
| 310 }); | |
| 311 src__core_matchers.returnsNormally = dart.const(new src__core_matchers._Return
sNormally()); | |
| 312 matcher.returnsNormally = src__core_matchers.returnsNormally; | |
| 313 src__core_matchers._IsAnything = class _IsAnything extends src__interfaces.Mat
cher { | |
| 314 new() { | |
| 315 super.new(); | |
| 316 } | |
| 317 matches(item, matchState) { | |
| 318 return true; | |
| 319 } | |
| 320 describe(description) { | |
| 321 return description.add('anything'); | |
| 322 } | |
| 323 }; | |
| 324 dart.setSignature(src__core_matchers._IsAnything, { | |
| 325 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers._IsA
nything, [])}), | |
| 326 methods: () => ({ | |
| 327 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 328 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 329 }) | |
| 330 }); | |
| 331 src__core_matchers.anything = dart.const(new src__core_matchers._IsAnything())
; | |
| 332 matcher.anything = src__core_matchers.anything; | |
| 333 matcher.TypeMatcher = src__core_matchers.TypeMatcher; | |
| 334 src__core_matchers.contains = function(expected) { | |
| 335 return new src__core_matchers._Contains(expected); | |
| 336 }; | |
| 337 dart.fn(src__core_matchers.contains, dynamicToMatcher()); | |
| 338 matcher.contains = src__core_matchers.contains; | |
| 339 src__core_matchers._NotEmpty = class _NotEmpty extends src__interfaces.Matcher
{ | |
| 340 new() { | |
| 341 super.new(); | |
| 342 } | |
| 343 matches(item, matchState) { | |
| 344 return core.bool._check(dart.dload(item, 'isNotEmpty')); | |
| 345 } | |
| 346 describe(description) { | |
| 347 return description.add('non-empty'); | |
| 348 } | |
| 349 }; | |
| 350 dart.setSignature(src__core_matchers._NotEmpty, { | |
| 351 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers._Not
Empty, [])}), | |
| 352 methods: () => ({ | |
| 353 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 354 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 355 }) | |
| 356 }); | |
| 357 src__core_matchers.isNotEmpty = dart.const(new src__core_matchers._NotEmpty())
; | |
| 358 matcher.isNotEmpty = src__core_matchers.isNotEmpty; | |
| 359 src__core_matchers._IsNull = class _IsNull extends src__interfaces.Matcher { | |
| 360 new() { | |
| 361 super.new(); | |
| 362 } | |
| 363 matches(item, matchState) { | |
| 364 return item == null; | |
| 365 } | |
| 366 describe(description) { | |
| 367 return description.add('null'); | |
| 368 } | |
| 369 }; | |
| 370 dart.setSignature(src__core_matchers._IsNull, { | |
| 371 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers._IsN
ull, [])}), | |
| 372 methods: () => ({ | |
| 373 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 374 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 375 }) | |
| 376 }); | |
| 377 src__core_matchers.isNull = dart.const(new src__core_matchers._IsNull()); | |
| 378 matcher.isNull = src__core_matchers.isNull; | |
| 379 src__core_matchers._IsMap = class _IsMap extends src__core_matchers.TypeMatche
r { | |
| 380 new() { | |
| 381 super.new("Map"); | |
| 382 } | |
| 383 matches(item, matchState) { | |
| 384 return core.Map.is(item); | |
| 385 } | |
| 386 }; | |
| 387 dart.setSignature(src__core_matchers._IsMap, { | |
| 388 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers._IsM
ap, [])}), | |
| 389 methods: () => ({matches: dart.definiteFunctionType(core.bool, [dart.dynamic
, core.Map])}) | |
| 390 }); | |
| 391 src__core_matchers.isMap = dart.const(new src__core_matchers._IsMap()); | |
| 392 matcher.isMap = src__core_matchers.isMap; | |
| 393 src__core_matchers._IsNotNaN = class _IsNotNaN extends src__interfaces.Matcher
{ | |
| 394 new() { | |
| 395 super.new(); | |
| 396 } | |
| 397 matches(item, matchState) { | |
| 398 return core.double.NAN[dartx.compareTo](core.num._check(item)) != 0; | |
| 399 } | |
| 400 describe(description) { | |
| 401 return description.add('not NaN'); | |
| 402 } | |
| 403 }; | |
| 404 dart.setSignature(src__core_matchers._IsNotNaN, { | |
| 405 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers._IsN
otNaN, [])}), | |
| 406 methods: () => ({ | |
| 407 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 408 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 409 }) | |
| 410 }); | |
| 411 src__core_matchers.isNotNaN = dart.const(new src__core_matchers._IsNotNaN()); | |
| 412 matcher.isNotNaN = src__core_matchers.isNotNaN; | |
| 413 src__core_matchers.isIn = function(expected) { | |
| 414 return new src__core_matchers._In(expected); | |
| 415 }; | |
| 416 dart.fn(src__core_matchers.isIn, dynamicToMatcher()); | |
| 417 matcher.isIn = src__core_matchers.isIn; | |
| 418 const _out = Symbol('_out'); | |
| 419 src__description.StringDescription = class StringDescription extends core.Obje
ct { | |
| 420 new(init) { | |
| 421 if (init === void 0) init = ''; | |
| 422 this[_out] = new core.StringBuffer(); | |
| 423 this[_out].write(init); | |
| 424 } | |
| 425 get length() { | |
| 426 return this[_out].length; | |
| 427 } | |
| 428 toString() { | |
| 429 return dart.toString(this[_out]); | |
| 430 } | |
| 431 add(text) { | |
| 432 this[_out].write(text); | |
| 433 return this; | |
| 434 } | |
| 435 replace(text) { | |
| 436 this[_out].clear(); | |
| 437 return this.add(text); | |
| 438 } | |
| 439 addDescriptionOf(value) { | |
| 440 if (src__interfaces.Matcher.is(value)) { | |
| 441 value.describe(this); | |
| 442 } else { | |
| 443 this.add(src__pretty_print.prettyPrint(value, {maxLineLength: 80, maxIte
ms: 25})); | |
| 444 } | |
| 445 return this; | |
| 446 } | |
| 447 addAll(start, separator, end, list) { | |
| 448 let separate = false; | |
| 449 this.add(start); | |
| 450 for (let item of list) { | |
| 451 if (separate) { | |
| 452 this.add(separator); | |
| 453 } | |
| 454 this.addDescriptionOf(item); | |
| 455 separate = true; | |
| 456 } | |
| 457 this.add(end); | |
| 458 return this; | |
| 459 } | |
| 460 }; | |
| 461 src__description.StringDescription[dart.implements] = () => [src__interfaces.D
escription]; | |
| 462 dart.setSignature(src__description.StringDescription, { | |
| 463 constructors: () => ({new: dart.definiteFunctionType(src__description.String
Description, [], [core.String])}), | |
| 464 methods: () => ({ | |
| 465 add: dart.definiteFunctionType(src__interfaces.Description, [core.String])
, | |
| 466 replace: dart.definiteFunctionType(src__interfaces.Description, [core.Stri
ng]), | |
| 467 addDescriptionOf: dart.definiteFunctionType(src__interfaces.Description, [
dart.dynamic]), | |
| 468 addAll: dart.definiteFunctionType(src__interfaces.Description, [core.Strin
g, core.String, core.String, core.Iterable]) | |
| 469 }) | |
| 470 }); | |
| 471 matcher.StringDescription = src__description.StringDescription; | |
| 472 src__error_matchers._ConcurrentModificationError = class _ConcurrentModificati
onError extends src__core_matchers.TypeMatcher { | |
| 473 new() { | |
| 474 super.new("ConcurrentModificationError"); | |
| 475 } | |
| 476 matches(item, matchState) { | |
| 477 return core.ConcurrentModificationError.is(item); | |
| 478 } | |
| 479 }; | |
| 480 dart.setSignature(src__error_matchers._ConcurrentModificationError, { | |
| 481 constructors: () => ({new: dart.definiteFunctionType(src__error_matchers._Co
ncurrentModificationError, [])}), | |
| 482 methods: () => ({matches: dart.definiteFunctionType(core.bool, [dart.dynamic
, core.Map])}) | |
| 483 }); | |
| 484 src__error_matchers.isConcurrentModificationError = dart.const(new src__error_
matchers._ConcurrentModificationError()); | |
| 485 matcher.isConcurrentModificationError = src__error_matchers.isConcurrentModifi
cationError; | |
| 486 src__error_matchers._CyclicInitializationError = class _CyclicInitializationEr
ror extends src__core_matchers.TypeMatcher { | |
| 487 new() { | |
| 488 super.new("CyclicInitializationError"); | |
| 489 } | |
| 490 matches(item, matchState) { | |
| 491 return core.CyclicInitializationError.is(item); | |
| 492 } | |
| 493 }; | |
| 494 dart.setSignature(src__error_matchers._CyclicInitializationError, { | |
| 495 constructors: () => ({new: dart.definiteFunctionType(src__error_matchers._Cy
clicInitializationError, [])}), | |
| 496 methods: () => ({matches: dart.definiteFunctionType(core.bool, [dart.dynamic
, core.Map])}) | |
| 497 }); | |
| 498 src__error_matchers.isCyclicInitializationError = dart.const(new src__error_ma
tchers._CyclicInitializationError()); | |
| 499 matcher.isCyclicInitializationError = src__error_matchers.isCyclicInitializati
onError; | |
| 500 src__error_matchers._ArgumentError = class _ArgumentError extends src__core_ma
tchers.TypeMatcher { | |
| 501 new() { | |
| 502 super.new("ArgumentError"); | |
| 503 } | |
| 504 matches(item, matchState) { | |
| 505 return core.ArgumentError.is(item); | |
| 506 } | |
| 507 }; | |
| 508 dart.setSignature(src__error_matchers._ArgumentError, { | |
| 509 constructors: () => ({new: dart.definiteFunctionType(src__error_matchers._Ar
gumentError, [])}), | |
| 510 methods: () => ({matches: dart.definiteFunctionType(core.bool, [dart.dynamic
, core.Map])}) | |
| 511 }); | |
| 512 src__error_matchers.isArgumentError = dart.const(new src__error_matchers._Argu
mentError()); | |
| 513 matcher.isArgumentError = src__error_matchers.isArgumentError; | |
| 514 src__error_matchers._Exception = class _Exception extends src__core_matchers.T
ypeMatcher { | |
| 515 new() { | |
| 516 super.new("Exception"); | |
| 517 } | |
| 518 matches(item, matchState) { | |
| 519 return core.Exception.is(item); | |
| 520 } | |
| 521 }; | |
| 522 dart.setSignature(src__error_matchers._Exception, { | |
| 523 constructors: () => ({new: dart.definiteFunctionType(src__error_matchers._Ex
ception, [])}), | |
| 524 methods: () => ({matches: dart.definiteFunctionType(core.bool, [dart.dynamic
, core.Map])}) | |
| 525 }); | |
| 526 src__error_matchers.isException = dart.const(new src__error_matchers._Exceptio
n()); | |
| 527 matcher.isException = src__error_matchers.isException; | |
| 528 src__error_matchers._NullThrownError = class _NullThrownError extends src__cor
e_matchers.TypeMatcher { | |
| 529 new() { | |
| 530 super.new("NullThrownError"); | |
| 531 } | |
| 532 matches(item, matchState) { | |
| 533 return core.NullThrownError.is(item); | |
| 534 } | |
| 535 }; | |
| 536 dart.setSignature(src__error_matchers._NullThrownError, { | |
| 537 constructors: () => ({new: dart.definiteFunctionType(src__error_matchers._Nu
llThrownError, [])}), | |
| 538 methods: () => ({matches: dart.definiteFunctionType(core.bool, [dart.dynamic
, core.Map])}) | |
| 539 }); | |
| 540 src__error_matchers.isNullThrownError = dart.const(new src__error_matchers._Nu
llThrownError()); | |
| 541 matcher.isNullThrownError = src__error_matchers.isNullThrownError; | |
| 542 src__error_matchers._RangeError = class _RangeError extends src__core_matchers
.TypeMatcher { | |
| 543 new() { | |
| 544 super.new("RangeError"); | |
| 545 } | |
| 546 matches(item, matchState) { | |
| 547 return core.RangeError.is(item); | |
| 548 } | |
| 549 }; | |
| 550 dart.setSignature(src__error_matchers._RangeError, { | |
| 551 constructors: () => ({new: dart.definiteFunctionType(src__error_matchers._Ra
ngeError, [])}), | |
| 552 methods: () => ({matches: dart.definiteFunctionType(core.bool, [dart.dynamic
, core.Map])}) | |
| 553 }); | |
| 554 src__error_matchers.isRangeError = dart.const(new src__error_matchers._RangeEr
ror()); | |
| 555 matcher.isRangeError = src__error_matchers.isRangeError; | |
| 556 src__error_matchers._FormatException = class _FormatException extends src__cor
e_matchers.TypeMatcher { | |
| 557 new() { | |
| 558 super.new("FormatException"); | |
| 559 } | |
| 560 matches(item, matchState) { | |
| 561 return core.FormatException.is(item); | |
| 562 } | |
| 563 }; | |
| 564 dart.setSignature(src__error_matchers._FormatException, { | |
| 565 constructors: () => ({new: dart.definiteFunctionType(src__error_matchers._Fo
rmatException, [])}), | |
| 566 methods: () => ({matches: dart.definiteFunctionType(core.bool, [dart.dynamic
, core.Map])}) | |
| 567 }); | |
| 568 src__error_matchers.isFormatException = dart.const(new src__error_matchers._Fo
rmatException()); | |
| 569 matcher.isFormatException = src__error_matchers.isFormatException; | |
| 570 src__error_matchers._StateError = class _StateError extends src__core_matchers
.TypeMatcher { | |
| 571 new() { | |
| 572 super.new("StateError"); | |
| 573 } | |
| 574 matches(item, matchState) { | |
| 575 return core.StateError.is(item); | |
| 576 } | |
| 577 }; | |
| 578 dart.setSignature(src__error_matchers._StateError, { | |
| 579 constructors: () => ({new: dart.definiteFunctionType(src__error_matchers._St
ateError, [])}), | |
| 580 methods: () => ({matches: dart.definiteFunctionType(core.bool, [dart.dynamic
, core.Map])}) | |
| 581 }); | |
| 582 src__error_matchers.isStateError = dart.const(new src__error_matchers._StateEr
ror()); | |
| 583 matcher.isStateError = src__error_matchers.isStateError; | |
| 584 src__error_matchers._NoSuchMethodError = class _NoSuchMethodError extends src_
_core_matchers.TypeMatcher { | |
| 585 new() { | |
| 586 super.new("NoSuchMethodError"); | |
| 587 } | |
| 588 matches(item, matchState) { | |
| 589 return core.NoSuchMethodError.is(item); | |
| 590 } | |
| 591 }; | |
| 592 dart.setSignature(src__error_matchers._NoSuchMethodError, { | |
| 593 constructors: () => ({new: dart.definiteFunctionType(src__error_matchers._No
SuchMethodError, [])}), | |
| 594 methods: () => ({matches: dart.definiteFunctionType(core.bool, [dart.dynamic
, core.Map])}) | |
| 595 }); | |
| 596 src__error_matchers.isNoSuchMethodError = dart.const(new src__error_matchers._
NoSuchMethodError()); | |
| 597 matcher.isNoSuchMethodError = src__error_matchers.isNoSuchMethodError; | |
| 598 src__error_matchers._UnimplementedError = class _UnimplementedError extends sr
c__core_matchers.TypeMatcher { | |
| 599 new() { | |
| 600 super.new("UnimplementedError"); | |
| 601 } | |
| 602 matches(item, matchState) { | |
| 603 return core.UnimplementedError.is(item); | |
| 604 } | |
| 605 }; | |
| 606 dart.setSignature(src__error_matchers._UnimplementedError, { | |
| 607 constructors: () => ({new: dart.definiteFunctionType(src__error_matchers._Un
implementedError, [])}), | |
| 608 methods: () => ({matches: dart.definiteFunctionType(core.bool, [dart.dynamic
, core.Map])}) | |
| 609 }); | |
| 610 src__error_matchers.isUnimplementedError = dart.const(new src__error_matchers.
_UnimplementedError()); | |
| 611 matcher.isUnimplementedError = src__error_matchers.isUnimplementedError; | |
| 612 src__error_matchers._UnsupportedError = class _UnsupportedError extends src__c
ore_matchers.TypeMatcher { | |
| 613 new() { | |
| 614 super.new("UnsupportedError"); | |
| 615 } | |
| 616 matches(item, matchState) { | |
| 617 return core.UnsupportedError.is(item); | |
| 618 } | |
| 619 }; | |
| 620 dart.setSignature(src__error_matchers._UnsupportedError, { | |
| 621 constructors: () => ({new: dart.definiteFunctionType(src__error_matchers._Un
supportedError, [])}), | |
| 622 methods: () => ({matches: dart.definiteFunctionType(core.bool, [dart.dynamic
, core.Map])}) | |
| 623 }); | |
| 624 src__error_matchers.isUnsupportedError = dart.const(new src__error_matchers._U
nsupportedError()); | |
| 625 matcher.isUnsupportedError = src__error_matchers.isUnsupportedError; | |
| 626 matcher.Matcher = src__interfaces.Matcher; | |
| 627 src__interfaces.Description = class Description extends core.Object {}; | |
| 628 matcher.Description = src__interfaces.Description; | |
| 629 src__iterable_matchers.pairwiseCompare = function(expected, comparator, descri
ption) { | |
| 630 return new src__iterable_matchers._PairwiseCompare(expected, comparator, des
cription); | |
| 631 }; | |
| 632 dart.fn(src__iterable_matchers.pairwiseCompare, IterableAndFnAndStringToMatche
r()); | |
| 633 matcher.pairwiseCompare = src__iterable_matchers.pairwiseCompare; | |
| 634 src__iterable_matchers.anyElement = function(matcher) { | |
| 635 return new src__iterable_matchers._AnyElement(src__util.wrapMatcher(matcher)
); | |
| 636 }; | |
| 637 dart.fn(src__iterable_matchers.anyElement, dynamicToMatcher()); | |
| 638 matcher.anyElement = src__iterable_matchers.anyElement; | |
| 639 src__iterable_matchers.orderedEquals = function(expected) { | |
| 640 return new src__iterable_matchers._OrderedEquals(expected); | |
| 641 }; | |
| 642 dart.fn(src__iterable_matchers.orderedEquals, IterableToMatcher()); | |
| 643 matcher.orderedEquals = src__iterable_matchers.orderedEquals; | |
| 644 src__iterable_matchers.unorderedEquals = function(expected) { | |
| 645 return new src__iterable_matchers._UnorderedEquals(expected); | |
| 646 }; | |
| 647 dart.fn(src__iterable_matchers.unorderedEquals, IterableToMatcher()); | |
| 648 matcher.unorderedEquals = src__iterable_matchers.unorderedEquals; | |
| 649 src__iterable_matchers.unorderedMatches = function(expected) { | |
| 650 return new src__iterable_matchers._UnorderedMatches(expected); | |
| 651 }; | |
| 652 dart.fn(src__iterable_matchers.unorderedMatches, IterableToMatcher()); | |
| 653 matcher.unorderedMatches = src__iterable_matchers.unorderedMatches; | |
| 654 src__iterable_matchers.everyElement = function(matcher) { | |
| 655 return new src__iterable_matchers._EveryElement(src__util.wrapMatcher(matche
r)); | |
| 656 }; | |
| 657 dart.fn(src__iterable_matchers.everyElement, dynamicToMatcher()); | |
| 658 matcher.everyElement = src__iterable_matchers.everyElement; | |
| 659 src__map_matchers.containsValue = function(value) { | |
| 660 return new src__map_matchers._ContainsValue(value); | |
| 661 }; | |
| 662 dart.fn(src__map_matchers.containsValue, dynamicToMatcher()); | |
| 663 matcher.containsValue = src__map_matchers.containsValue; | |
| 664 src__map_matchers.containsPair = function(key, value) { | |
| 665 return new src__map_matchers._ContainsMapping(key, src__util.wrapMatcher(val
ue)); | |
| 666 }; | |
| 667 dart.fn(src__map_matchers.containsPair, dynamicAnddynamicToMatcher()); | |
| 668 matcher.containsPair = src__map_matchers.containsPair; | |
| 669 const _value = Symbol('_value'); | |
| 670 const _equalValue = Symbol('_equalValue'); | |
| 671 const _lessThanValue = Symbol('_lessThanValue'); | |
| 672 const _greaterThanValue = Symbol('_greaterThanValue'); | |
| 673 const _comparisonDescription = Symbol('_comparisonDescription'); | |
| 674 const _valueInDescription = Symbol('_valueInDescription'); | |
| 675 src__numeric_matchers._OrderingComparison = class _OrderingComparison extends
src__interfaces.Matcher { | |
| 676 new(value, equalValue, lessThanValue, greaterThanValue, comparisonDescriptio
n, valueInDescription) { | |
| 677 if (valueInDescription === void 0) valueInDescription = true; | |
| 678 this[_value] = value; | |
| 679 this[_equalValue] = equalValue; | |
| 680 this[_lessThanValue] = lessThanValue; | |
| 681 this[_greaterThanValue] = greaterThanValue; | |
| 682 this[_comparisonDescription] = comparisonDescription; | |
| 683 this[_valueInDescription] = valueInDescription; | |
| 684 super.new(); | |
| 685 } | |
| 686 matches(item, matchState) { | |
| 687 if (dart.equals(item, this[_value])) { | |
| 688 return this[_equalValue]; | |
| 689 } else if (dart.test(dart.dsend(item, '<', this[_value]))) { | |
| 690 return this[_lessThanValue]; | |
| 691 } else { | |
| 692 return this[_greaterThanValue]; | |
| 693 } | |
| 694 } | |
| 695 describe(description) { | |
| 696 if (dart.test(this[_valueInDescription])) { | |
| 697 return description.add(this[_comparisonDescription]).add(' ').addDescrip
tionOf(this[_value]); | |
| 698 } else { | |
| 699 return description.add(this[_comparisonDescription]); | |
| 700 } | |
| 701 } | |
| 702 describeMismatch(item, mismatchDescription, matchState, verbose) { | |
| 703 mismatchDescription.add('is not '); | |
| 704 return this.describe(mismatchDescription); | |
| 705 } | |
| 706 }; | |
| 707 dart.setSignature(src__numeric_matchers._OrderingComparison, { | |
| 708 constructors: () => ({new: dart.definiteFunctionType(src__numeric_matchers._
OrderingComparison, [dart.dynamic, core.bool, core.bool, core.bool, core.String]
, [core.bool])}), | |
| 709 methods: () => ({ | |
| 710 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 711 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 712 }) | |
| 713 }); | |
| 714 src__numeric_matchers.isPositive = dart.const(new src__numeric_matchers._Order
ingComparison(0, false, false, true, 'a positive value', false)); | |
| 715 matcher.isPositive = src__numeric_matchers.isPositive; | |
| 716 src__numeric_matchers.isZero = dart.const(new src__numeric_matchers._OrderingC
omparison(0, true, false, false, 'a value equal to')); | |
| 717 matcher.isZero = src__numeric_matchers.isZero; | |
| 718 src__numeric_matchers.inOpenClosedRange = function(low, high) { | |
| 719 return new src__numeric_matchers._InRange(low, high, false, true); | |
| 720 }; | |
| 721 dart.fn(src__numeric_matchers.inOpenClosedRange, numAndnumToMatcher()); | |
| 722 matcher.inOpenClosedRange = src__numeric_matchers.inOpenClosedRange; | |
| 723 src__numeric_matchers.inClosedOpenRange = function(low, high) { | |
| 724 return new src__numeric_matchers._InRange(low, high, true, false); | |
| 725 }; | |
| 726 dart.fn(src__numeric_matchers.inClosedOpenRange, numAndnumToMatcher()); | |
| 727 matcher.inClosedOpenRange = src__numeric_matchers.inClosedOpenRange; | |
| 728 src__numeric_matchers.lessThanOrEqualTo = function(value) { | |
| 729 return new src__numeric_matchers._OrderingComparison(value, true, true, fals
e, 'a value less than or equal to'); | |
| 730 }; | |
| 731 dart.fn(src__numeric_matchers.lessThanOrEqualTo, dynamicToMatcher()); | |
| 732 matcher.lessThanOrEqualTo = src__numeric_matchers.lessThanOrEqualTo; | |
| 733 src__numeric_matchers.isNegative = dart.const(new src__numeric_matchers._Order
ingComparison(0, false, true, false, 'a negative value', false)); | |
| 734 matcher.isNegative = src__numeric_matchers.isNegative; | |
| 735 src__numeric_matchers.inInclusiveRange = function(low, high) { | |
| 736 return new src__numeric_matchers._InRange(low, high, true, true); | |
| 737 }; | |
| 738 dart.fn(src__numeric_matchers.inInclusiveRange, numAndnumToMatcher()); | |
| 739 matcher.inInclusiveRange = src__numeric_matchers.inInclusiveRange; | |
| 740 src__numeric_matchers.lessThan = function(value) { | |
| 741 return new src__numeric_matchers._OrderingComparison(value, false, true, fal
se, 'a value less than'); | |
| 742 }; | |
| 743 dart.fn(src__numeric_matchers.lessThan, dynamicToMatcher()); | |
| 744 matcher.lessThan = src__numeric_matchers.lessThan; | |
| 745 src__numeric_matchers.greaterThan = function(value) { | |
| 746 return new src__numeric_matchers._OrderingComparison(value, false, false, tr
ue, 'a value greater than'); | |
| 747 }; | |
| 748 dart.fn(src__numeric_matchers.greaterThan, dynamicToMatcher()); | |
| 749 matcher.greaterThan = src__numeric_matchers.greaterThan; | |
| 750 src__numeric_matchers.isNonNegative = dart.const(new src__numeric_matchers._Or
deringComparison(0, true, false, true, 'a non-negative value', false)); | |
| 751 matcher.isNonNegative = src__numeric_matchers.isNonNegative; | |
| 752 src__numeric_matchers.inExclusiveRange = function(low, high) { | |
| 753 return new src__numeric_matchers._InRange(low, high, false, false); | |
| 754 }; | |
| 755 dart.fn(src__numeric_matchers.inExclusiveRange, numAndnumToMatcher()); | |
| 756 matcher.inExclusiveRange = src__numeric_matchers.inExclusiveRange; | |
| 757 src__numeric_matchers.closeTo = function(value, delta) { | |
| 758 return new src__numeric_matchers._IsCloseTo(value, delta); | |
| 759 }; | |
| 760 dart.fn(src__numeric_matchers.closeTo, numAndnumToMatcher()); | |
| 761 matcher.closeTo = src__numeric_matchers.closeTo; | |
| 762 src__numeric_matchers.greaterThanOrEqualTo = function(value) { | |
| 763 return new src__numeric_matchers._OrderingComparison(value, true, false, tru
e, 'a value greater than or equal to'); | |
| 764 }; | |
| 765 dart.fn(src__numeric_matchers.greaterThanOrEqualTo, dynamicToMatcher()); | |
| 766 matcher.greaterThanOrEqualTo = src__numeric_matchers.greaterThanOrEqualTo; | |
| 767 src__numeric_matchers.isNonZero = dart.const(new src__numeric_matchers._Orderi
ngComparison(0, false, true, true, 'a value not equal to')); | |
| 768 matcher.isNonZero = src__numeric_matchers.isNonZero; | |
| 769 src__numeric_matchers.isNonPositive = dart.const(new src__numeric_matchers._Or
deringComparison(0, true, true, false, 'a non-positive value', false)); | |
| 770 matcher.isNonPositive = src__numeric_matchers.isNonPositive; | |
| 771 src__operator_matchers.allOf = function(arg0, arg1, arg2, arg3, arg4, arg5, ar
g6) { | |
| 772 if (arg1 === void 0) arg1 = null; | |
| 773 if (arg2 === void 0) arg2 = null; | |
| 774 if (arg3 === void 0) arg3 = null; | |
| 775 if (arg4 === void 0) arg4 = null; | |
| 776 if (arg5 === void 0) arg5 = null; | |
| 777 if (arg6 === void 0) arg6 = null; | |
| 778 return new src__operator_matchers._AllOf(src__operator_matchers._wrapArgs(ar
g0, arg1, arg2, arg3, arg4, arg5, arg6)); | |
| 779 }; | |
| 780 dart.fn(src__operator_matchers.allOf, dynamic__ToMatcher$()); | |
| 781 matcher.allOf = src__operator_matchers.allOf; | |
| 782 src__operator_matchers.isNot = function(matcher) { | |
| 783 return new src__operator_matchers._IsNot(src__util.wrapMatcher(matcher)); | |
| 784 }; | |
| 785 dart.fn(src__operator_matchers.isNot, dynamicToMatcher()); | |
| 786 matcher.isNot = src__operator_matchers.isNot; | |
| 787 src__operator_matchers.anyOf = function(arg0, arg1, arg2, arg3, arg4, arg5, ar
g6) { | |
| 788 if (arg1 === void 0) arg1 = null; | |
| 789 if (arg2 === void 0) arg2 = null; | |
| 790 if (arg3 === void 0) arg3 = null; | |
| 791 if (arg4 === void 0) arg4 = null; | |
| 792 if (arg5 === void 0) arg5 = null; | |
| 793 if (arg6 === void 0) arg6 = null; | |
| 794 return new src__operator_matchers._AnyOf(src__operator_matchers._wrapArgs(ar
g0, arg1, arg2, arg3, arg4, arg5, arg6)); | |
| 795 }; | |
| 796 dart.fn(src__operator_matchers.anyOf, dynamic__ToMatcher$()); | |
| 797 matcher.anyOf = src__operator_matchers.anyOf; | |
| 798 src__string_matchers.endsWith = function(suffixString) { | |
| 799 return new src__string_matchers._StringEndsWith(suffixString); | |
| 800 }; | |
| 801 dart.fn(src__string_matchers.endsWith, StringToMatcher()); | |
| 802 matcher.endsWith = src__string_matchers.endsWith; | |
| 803 src__string_matchers.startsWith = function(prefixString) { | |
| 804 return new src__string_matchers._StringStartsWith(prefixString); | |
| 805 }; | |
| 806 dart.fn(src__string_matchers.startsWith, StringToMatcher()); | |
| 807 matcher.startsWith = src__string_matchers.startsWith; | |
| 808 src__string_matchers.matches = function(re) { | |
| 809 return new src__string_matchers._MatchesRegExp(re); | |
| 810 }; | |
| 811 dart.fn(src__string_matchers.matches, dynamicToMatcher()); | |
| 812 matcher.matches = src__string_matchers.matches; | |
| 813 src__string_matchers.collapseWhitespace = function(string) { | |
| 814 let result = new core.StringBuffer(); | |
| 815 let skipSpace = true; | |
| 816 for (let i = 0; i < dart.notNull(string[dartx.length]); i++) { | |
| 817 let character = string[dartx.get](i); | |
| 818 if (dart.test(src__string_matchers._isWhitespace(character))) { | |
| 819 if (!skipSpace) { | |
| 820 result.write(' '); | |
| 821 skipSpace = true; | |
| 822 } | |
| 823 } else { | |
| 824 result.write(character); | |
| 825 skipSpace = false; | |
| 826 } | |
| 827 } | |
| 828 return result.toString()[dartx.trim](); | |
| 829 }; | |
| 830 dart.fn(src__string_matchers.collapseWhitespace, StringToString()); | |
| 831 matcher.collapseWhitespace = src__string_matchers.collapseWhitespace; | |
| 832 src__string_matchers.equalsIgnoringCase = function(value) { | |
| 833 return new src__string_matchers._IsEqualIgnoringCase(value); | |
| 834 }; | |
| 835 dart.fn(src__string_matchers.equalsIgnoringCase, StringToMatcher()); | |
| 836 matcher.equalsIgnoringCase = src__string_matchers.equalsIgnoringCase; | |
| 837 src__string_matchers.equalsIgnoringWhitespace = function(value) { | |
| 838 return new src__string_matchers._IsEqualIgnoringWhitespace(value); | |
| 839 }; | |
| 840 dart.fn(src__string_matchers.equalsIgnoringWhitespace, StringToMatcher()); | |
| 841 matcher.equalsIgnoringWhitespace = src__string_matchers.equalsIgnoringWhitespa
ce; | |
| 842 src__string_matchers.stringContainsInOrder = function(substrings) { | |
| 843 return new src__string_matchers._StringContainsInOrder(substrings); | |
| 844 }; | |
| 845 dart.fn(src__string_matchers.stringContainsInOrder, ListOfStringToMatcher()); | |
| 846 matcher.stringContainsInOrder = src__string_matchers.stringContainsInOrder; | |
| 847 src__util.addStateInfo = function(matchState, values) { | |
| 848 let innerState = core.Map.from(matchState); | |
| 849 matchState[dartx.clear](); | |
| 850 matchState[dartx.set]('state', innerState); | |
| 851 matchState[dartx.addAll](values); | |
| 852 }; | |
| 853 dart.fn(src__util.addStateInfo, MapAndMapTovoid()); | |
| 854 matcher.addStateInfo = src__util.addStateInfo; | |
| 855 src__util.wrapMatcher = function(x) { | |
| 856 if (src__interfaces.Matcher.is(x)) { | |
| 857 return x; | |
| 858 } else if (src__util._Predicate.is(x)) { | |
| 859 return src__core_matchers.predicate(x); | |
| 860 } else { | |
| 861 return src__core_matchers.equals(x); | |
| 862 } | |
| 863 }; | |
| 864 dart.fn(src__util.wrapMatcher, dynamicToMatcher()); | |
| 865 matcher.wrapMatcher = src__util.wrapMatcher; | |
| 866 src__util.escape = function(str) { | |
| 867 str = str[dartx.replaceAll]('\\', '\\\\'); | |
| 868 return str[dartx.replaceAllMapped](src__util._escapeRegExp, dart.fn(match =>
{ | |
| 869 let mapped = src__util._escapeMap[dartx.get](match.get(0)); | |
| 870 if (mapped != null) return mapped; | |
| 871 return src__util._getHexLiteral(match.get(0)); | |
| 872 }, MatchToString())); | |
| 873 }; | |
| 874 dart.fn(src__util.escape, StringToString()); | |
| 875 matcher.escape = src__util.escape; | |
| 876 mirror_matchers.hasProperty = function(name, matcher) { | |
| 877 if (matcher === void 0) matcher = null; | |
| 878 return new mirror_matchers._HasProperty(name, matcher == null ? null : src__
util.wrapMatcher(matcher)); | |
| 879 }; | |
| 880 dart.fn(mirror_matchers.hasProperty, String__ToMatcher()); | |
| 881 const _name$ = Symbol('_name'); | |
| 882 const _matcher$ = Symbol('_matcher'); | |
| 883 mirror_matchers._HasProperty = class _HasProperty extends src__interfaces.Matc
her { | |
| 884 new(name, matcher) { | |
| 885 if (matcher === void 0) matcher = null; | |
| 886 this[_name$] = name; | |
| 887 this[_matcher$] = matcher; | |
| 888 super.new(); | |
| 889 } | |
| 890 matches(item, matchState) { | |
| 891 let mirror = mirrors.reflect(item); | |
| 892 let classMirror = mirror.type; | |
| 893 let symbol = core.Symbol.new(this[_name$]); | |
| 894 let candidate = classMirror.declarations[dartx.get](symbol); | |
| 895 if (candidate == null) { | |
| 896 src__util.addStateInfo(matchState, dart.map({reason: dart.str`has no pro
perty named "${this[_name$]}"`}, core.String, core.String)); | |
| 897 return false; | |
| 898 } | |
| 899 let isInstanceField = mirrors.VariableMirror.is(candidate) && !dart.test(c
andidate.isStatic); | |
| 900 let isInstanceGetter = mirrors.MethodMirror.is(candidate) && dart.test(can
didate.isGetter) && !dart.test(candidate.isStatic); | |
| 901 if (!(isInstanceField || isInstanceGetter)) { | |
| 902 src__util.addStateInfo(matchState, dart.map({reason: dart.str`has a memb
er named "${this[_name$]}", but it is not an instance property`}, core.String, c
ore.String)); | |
| 903 return false; | |
| 904 } | |
| 905 if (this[_matcher$] == null) return true; | |
| 906 let result = mirror.getField(symbol); | |
| 907 let resultMatches = this[_matcher$].matches(result.reflectee, matchState); | |
| 908 if (!dart.test(resultMatches)) { | |
| 909 src__util.addStateInfo(matchState, dart.map({value: result.reflectee}, c
ore.String, dart.dynamic)); | |
| 910 } | |
| 911 return resultMatches; | |
| 912 } | |
| 913 describe(description) { | |
| 914 description.add(dart.str`has property "${this[_name$]}"`); | |
| 915 if (this[_matcher$] != null) { | |
| 916 description.add(' which matches ').addDescriptionOf(this[_matcher$]); | |
| 917 } | |
| 918 return description; | |
| 919 } | |
| 920 describeMismatch(item, mismatchDescription, matchState, verbose) { | |
| 921 let reason = matchState == null ? null : matchState[dartx.get]('reason'); | |
| 922 if (reason != null) { | |
| 923 mismatchDescription.add(core.String._check(reason)); | |
| 924 } else { | |
| 925 mismatchDescription.add(dart.str`has property "${this[_name$]}" with val
ue `).addDescriptionOf(matchState[dartx.get]('value')); | |
| 926 let innerDescription = new src__description.StringDescription(); | |
| 927 this[_matcher$].describeMismatch(matchState[dartx.get]('value'), innerDe
scription, core.Map._check(matchState[dartx.get]('state')), verbose); | |
| 928 if (dart.notNull(innerDescription.length) > 0) { | |
| 929 mismatchDescription.add(' which ').add(innerDescription.toString()); | |
| 930 } | |
| 931 } | |
| 932 return mismatchDescription; | |
| 933 } | |
| 934 }; | |
| 935 dart.setSignature(mirror_matchers._HasProperty, { | |
| 936 constructors: () => ({new: dart.definiteFunctionType(mirror_matchers._HasPro
perty, [core.String], [src__interfaces.Matcher])}), | |
| 937 methods: () => ({ | |
| 938 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 939 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 940 }) | |
| 941 }); | |
| 942 const _expected = Symbol('_expected'); | |
| 943 src__core_matchers._IsSameAs = class _IsSameAs extends src__interfaces.Matcher
{ | |
| 944 new(expected) { | |
| 945 this[_expected] = expected; | |
| 946 super.new(); | |
| 947 } | |
| 948 matches(item, matchState) { | |
| 949 return core.identical(item, this[_expected]); | |
| 950 } | |
| 951 describe(description) { | |
| 952 return description.add('same instance as ').addDescriptionOf(this[_expecte
d]); | |
| 953 } | |
| 954 }; | |
| 955 dart.setSignature(src__core_matchers._IsSameAs, { | |
| 956 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers._IsS
ameAs, [dart.dynamic])}), | |
| 957 methods: () => ({ | |
| 958 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 959 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 960 }) | |
| 961 }); | |
| 962 const _limit = Symbol('_limit'); | |
| 963 const _compareIterables = Symbol('_compareIterables'); | |
| 964 const _compareSets = Symbol('_compareSets'); | |
| 965 const _recursiveMatch = Symbol('_recursiveMatch'); | |
| 966 const _match = Symbol('_match'); | |
| 967 src__core_matchers._DeepMatcher = class _DeepMatcher extends src__interfaces.M
atcher { | |
| 968 new(expected, limit) { | |
| 969 if (limit === void 0) limit = 1000; | |
| 970 this[_expected] = expected; | |
| 971 this[_limit] = limit; | |
| 972 this.count = null; | |
| 973 super.new(); | |
| 974 } | |
| 975 [_compareIterables](expected, actual, matcher, depth, location) { | |
| 976 if (!core.Iterable.is(actual)) return ['is not Iterable', location]; | |
| 977 let expectedIterator = dart.dload(expected, 'iterator'); | |
| 978 let actualIterator = dart.dload(actual, 'iterator'); | |
| 979 for (let index = 0;; index++) { | |
| 980 let expectedNext = dart.dsend(expectedIterator, 'moveNext'); | |
| 981 let actualNext = dart.dsend(actualIterator, 'moveNext'); | |
| 982 if (!dart.test(expectedNext) && !dart.test(actualNext)) return null; | |
| 983 let newLocation = dart.str`${location}[${index}]`; | |
| 984 if (!dart.test(expectedNext)) return JSArrayOfString().of(['longer than
expected', newLocation]); | |
| 985 if (!dart.test(actualNext)) return JSArrayOfString().of(['shorter than e
xpected', newLocation]); | |
| 986 let rp = dart.dcall(matcher, dart.dload(expectedIterator, 'current'), da
rt.dload(actualIterator, 'current'), newLocation, depth); | |
| 987 if (rp != null) return core.List._check(rp); | |
| 988 } | |
| 989 } | |
| 990 [_compareSets](expected, actual, matcher, depth, location) { | |
| 991 if (!core.Iterable.is(actual)) return ['is not Iterable', location]; | |
| 992 actual = dart.dsend(actual, 'toSet'); | |
| 993 for (let expectedElement of expected) { | |
| 994 if (dart.test(dart.dsend(actual, 'every', dart.fn(actualElement => dart.
dcall(matcher, expectedElement, actualElement, location, depth) != null, dynamic
Tobool$())))) { | |
| 995 return [dart.str`does not contain ${expectedElement}`, location]; | |
| 996 } | |
| 997 } | |
| 998 if (dart.test(dart.dsend(dart.dload(actual, 'length'), '>', expected.lengt
h))) { | |
| 999 return ['larger than expected', location]; | |
| 1000 } else if (dart.test(dart.dsend(dart.dload(actual, 'length'), '<', expecte
d.length))) { | |
| 1001 return ['smaller than expected', location]; | |
| 1002 } else { | |
| 1003 return null; | |
| 1004 } | |
| 1005 } | |
| 1006 [_recursiveMatch](expected, actual, location, depth) { | |
| 1007 if (src__interfaces.Matcher.is(expected)) { | |
| 1008 let matchState = dart.map(); | |
| 1009 if (dart.test(expected.matches(actual, matchState))) return null; | |
| 1010 let description = new src__description.StringDescription(); | |
| 1011 expected.describe(description); | |
| 1012 return JSArrayOfString().of([dart.str`does not match ${description}`, lo
cation]); | |
| 1013 } else { | |
| 1014 try { | |
| 1015 if (dart.equals(expected, actual)) return null; | |
| 1016 } catch (e) { | |
| 1017 return JSArrayOfString().of([dart.str`== threw "${e}"`, location]); | |
| 1018 } | |
| 1019 | |
| 1020 } | |
| 1021 if (dart.notNull(depth) > dart.notNull(this[_limit])) return JSArrayOfStri
ng().of(['recursion depth limit exceeded', location]); | |
| 1022 if (depth == 0 || dart.notNull(this[_limit]) > 1) { | |
| 1023 if (core.Set.is(expected)) { | |
| 1024 return this[_compareSets](expected, actual, dart.bind(this, _recursive
Match), dart.notNull(depth) + 1, location); | |
| 1025 } else if (core.Iterable.is(expected)) { | |
| 1026 return this[_compareIterables](expected, actual, dart.bind(this, _recu
rsiveMatch), dart.notNull(depth) + 1, location); | |
| 1027 } else if (core.Map.is(expected)) { | |
| 1028 if (!core.Map.is(actual)) return JSArrayOfString().of(['expected a map
', location]); | |
| 1029 let err = dart.equals(expected[dartx.length], dart.dload(actual, 'leng
th')) ? '' : 'has different length and '; | |
| 1030 for (let key of expected[dartx.keys]) { | |
| 1031 if (!dart.test(dart.dsend(actual, 'containsKey', key))) { | |
| 1032 return JSArrayOfString().of([dart.str`${err}is missing map key '${
key}'`, location]); | |
| 1033 } | |
| 1034 } | |
| 1035 for (let key of core.Iterable._check(dart.dload(actual, 'keys'))) { | |
| 1036 if (!dart.test(expected[dartx.containsKey](key))) { | |
| 1037 return JSArrayOfString().of([dart.str`${err}has extra map key '${k
ey}'`, location]); | |
| 1038 } | |
| 1039 } | |
| 1040 for (let key of expected[dartx.keys]) { | |
| 1041 let rp = this[_recursiveMatch](expected[dartx.get](key), dart.dindex
(actual, key), dart.str`${location}['${key}']`, dart.notNull(depth) + 1); | |
| 1042 if (rp != null) return rp; | |
| 1043 } | |
| 1044 return null; | |
| 1045 } | |
| 1046 } | |
| 1047 let description = new src__description.StringDescription(); | |
| 1048 if (dart.notNull(depth) > 0) { | |
| 1049 description.add('was ').addDescriptionOf(actual).add(' instead of ').add
DescriptionOf(expected); | |
| 1050 return JSArrayOfString().of([description.toString(), location]); | |
| 1051 } | |
| 1052 return JSArrayOfString().of(["", location]); | |
| 1053 } | |
| 1054 [_match](expected, actual, matchState) { | |
| 1055 let rp = this[_recursiveMatch](expected, actual, '', 0); | |
| 1056 if (rp == null) return null; | |
| 1057 let reason = null; | |
| 1058 if (dart.test(dart.dsend(dart.dload(rp[dartx.get](0), 'length'), '>', 0)))
{ | |
| 1059 if (dart.test(dart.dsend(dart.dload(rp[dartx.get](1), 'length'), '>', 0)
)) { | |
| 1060 reason = dart.str`${rp[dartx.get](0)} at location ${rp[dartx.get](1)}`
; | |
| 1061 } else { | |
| 1062 reason = rp[dartx.get](0); | |
| 1063 } | |
| 1064 } else { | |
| 1065 reason = ''; | |
| 1066 } | |
| 1067 src__util.addStateInfo(matchState, dart.map({reason: reason}, core.String,
dart.dynamic)); | |
| 1068 return core.String._check(reason); | |
| 1069 } | |
| 1070 matches(item, matchState) { | |
| 1071 return this[_match](this[_expected], item, matchState) == null; | |
| 1072 } | |
| 1073 describe(description) { | |
| 1074 return description.addDescriptionOf(this[_expected]); | |
| 1075 } | |
| 1076 describeMismatch(item, mismatchDescription, matchState, verbose) { | |
| 1077 let reason = matchState[dartx.get]('reason'); | |
| 1078 if (dart.equals(dart.dload(reason, 'length'), 0) && dart.notNull(mismatchD
escription.length) > 0) { | |
| 1079 mismatchDescription.add('is ').addDescriptionOf(item); | |
| 1080 } else { | |
| 1081 mismatchDescription.add(core.String._check(reason)); | |
| 1082 } | |
| 1083 return mismatchDescription; | |
| 1084 } | |
| 1085 }; | |
| 1086 dart.setSignature(src__core_matchers._DeepMatcher, { | |
| 1087 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers._Dee
pMatcher, [dart.dynamic], [core.int])}), | |
| 1088 methods: () => ({ | |
| 1089 [_compareIterables]: dart.definiteFunctionType(core.List, [dart.dynamic, d
art.dynamic, dart.dynamic, dart.dynamic, dart.dynamic]), | |
| 1090 [_compareSets]: dart.definiteFunctionType(core.List, [core.Set, dart.dynam
ic, dart.dynamic, dart.dynamic, dart.dynamic]), | |
| 1091 [_recursiveMatch]: dart.definiteFunctionType(core.List, [dart.dynamic, dar
t.dynamic, core.String, core.int]), | |
| 1092 [_match]: dart.definiteFunctionType(core.String, [dart.dynamic, dart.dynam
ic, core.Map]), | |
| 1093 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1094 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1095 }) | |
| 1096 }); | |
| 1097 const _value$ = Symbol('_value'); | |
| 1098 src__core_matchers._StringEqualsMatcher = class _StringEqualsMatcher extends s
rc__interfaces.Matcher { | |
| 1099 new(value) { | |
| 1100 this[_value$] = value; | |
| 1101 super.new(); | |
| 1102 } | |
| 1103 get showActualValue() { | |
| 1104 return true; | |
| 1105 } | |
| 1106 matches(item, matchState) { | |
| 1107 return dart.equals(this[_value$], item); | |
| 1108 } | |
| 1109 describe(description) { | |
| 1110 return description.addDescriptionOf(this[_value$]); | |
| 1111 } | |
| 1112 describeMismatch(item, mismatchDescription, matchState, verbose) { | |
| 1113 if (!(typeof item == 'string')) { | |
| 1114 return mismatchDescription.addDescriptionOf(item).add('is not a string')
; | |
| 1115 } else { | |
| 1116 let buff = new core.StringBuffer(); | |
| 1117 buff.write('is different.'); | |
| 1118 let escapedItem = src__util.escape(core.String._check(item)); | |
| 1119 let escapedValue = src__util.escape(this[_value$]); | |
| 1120 let minLength = dart.notNull(escapedItem[dartx.length]) < dart.notNull(e
scapedValue[dartx.length]) ? escapedItem[dartx.length] : escapedValue[dartx.leng
th]; | |
| 1121 let start = 0; | |
| 1122 for (; start < dart.notNull(minLength); start++) { | |
| 1123 if (escapedValue[dartx.codeUnitAt](start) != escapedItem[dartx.codeUni
tAt](start)) { | |
| 1124 break; | |
| 1125 } | |
| 1126 } | |
| 1127 if (start == minLength) { | |
| 1128 if (dart.notNull(escapedValue[dartx.length]) < dart.notNull(escapedIte
m[dartx.length])) { | |
| 1129 buff.write(' Both strings start the same, but the given value also'
+ ' has the following trailing characters: '); | |
| 1130 src__core_matchers._StringEqualsMatcher._writeTrailing(buff, escaped
Item, escapedValue[dartx.length]); | |
| 1131 } else { | |
| 1132 buff.write(' Both strings start the same, but the given value is' +
' missing the following trailing characters: '); | |
| 1133 src__core_matchers._StringEqualsMatcher._writeTrailing(buff, escaped
Value, escapedItem[dartx.length]); | |
| 1134 } | |
| 1135 } else { | |
| 1136 buff.write('\nExpected: '); | |
| 1137 src__core_matchers._StringEqualsMatcher._writeLeading(buff, escapedVal
ue, start); | |
| 1138 src__core_matchers._StringEqualsMatcher._writeTrailing(buff, escapedVa
lue, start); | |
| 1139 buff.write('\n Actual: '); | |
| 1140 src__core_matchers._StringEqualsMatcher._writeLeading(buff, escapedIte
m, start); | |
| 1141 src__core_matchers._StringEqualsMatcher._writeTrailing(buff, escapedIt
em, start); | |
| 1142 buff.write('\n '); | |
| 1143 for (let i = start > 10 ? 14 : start; i > 0; i--) | |
| 1144 buff.write(' '); | |
| 1145 buff.write(dart.str`^\n Differ at offset ${start}`); | |
| 1146 } | |
| 1147 return mismatchDescription.replace(buff.toString()); | |
| 1148 } | |
| 1149 } | |
| 1150 static _writeLeading(buff, s, start) { | |
| 1151 if (dart.notNull(start) > 10) { | |
| 1152 buff.write('... '); | |
| 1153 buff.write(s[dartx.substring](dart.notNull(start) - 10, start)); | |
| 1154 } else { | |
| 1155 buff.write(s[dartx.substring](0, start)); | |
| 1156 } | |
| 1157 } | |
| 1158 static _writeTrailing(buff, s, start) { | |
| 1159 if (dart.notNull(start) + 10 > dart.notNull(s[dartx.length])) { | |
| 1160 buff.write(s[dartx.substring](start)); | |
| 1161 } else { | |
| 1162 buff.write(s[dartx.substring](start, dart.notNull(start) + 10)); | |
| 1163 buff.write(' ...'); | |
| 1164 } | |
| 1165 } | |
| 1166 }; | |
| 1167 dart.setSignature(src__core_matchers._StringEqualsMatcher, { | |
| 1168 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers._Str
ingEqualsMatcher, [core.String])}), | |
| 1169 methods: () => ({ | |
| 1170 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1171 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1172 }), | |
| 1173 statics: () => ({ | |
| 1174 _writeLeading: dart.definiteFunctionType(dart.void, [core.StringBuffer, co
re.String, core.int]), | |
| 1175 _writeTrailing: dart.definiteFunctionType(dart.void, [core.StringBuffer, c
ore.String, core.int]) | |
| 1176 }), | |
| 1177 names: ['_writeLeading', '_writeTrailing'] | |
| 1178 }); | |
| 1179 src__core_matchers._HasLength = class _HasLength extends src__interfaces.Match
er { | |
| 1180 new(matcher) { | |
| 1181 if (matcher === void 0) matcher = null; | |
| 1182 this[_matcher] = matcher; | |
| 1183 super.new(); | |
| 1184 } | |
| 1185 matches(item, matchState) { | |
| 1186 try { | |
| 1187 if (dart.test(dart.dsend(dart.dsend(dart.dload(item, 'length'), '*', dar
t.dload(item, 'length')), '>=', 0))) { | |
| 1188 return this[_matcher].matches(dart.dload(item, 'length'), matchState); | |
| 1189 } | |
| 1190 } catch (e) { | |
| 1191 } | |
| 1192 | |
| 1193 return false; | |
| 1194 } | |
| 1195 describe(description) { | |
| 1196 return description.add('an object with length of ').addDescriptionOf(this[
_matcher]); | |
| 1197 } | |
| 1198 describeMismatch(item, mismatchDescription, matchState, verbose) { | |
| 1199 try { | |
| 1200 if (dart.test(dart.dsend(dart.dsend(dart.dload(item, 'length'), '*', dar
t.dload(item, 'length')), '>=', 0))) { | |
| 1201 return mismatchDescription.add('has length of ').addDescriptionOf(dart
.dload(item, 'length')); | |
| 1202 } | |
| 1203 } catch (e) { | |
| 1204 } | |
| 1205 | |
| 1206 return mismatchDescription.add('has no length property'); | |
| 1207 } | |
| 1208 }; | |
| 1209 dart.setSignature(src__core_matchers._HasLength, { | |
| 1210 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers._Has
Length, [], [src__interfaces.Matcher])}), | |
| 1211 methods: () => ({ | |
| 1212 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1213 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1214 }) | |
| 1215 }); | |
| 1216 src__core_matchers._Contains = class _Contains extends src__interfaces.Matcher
{ | |
| 1217 new(expected) { | |
| 1218 this[_expected] = expected; | |
| 1219 super.new(); | |
| 1220 } | |
| 1221 matches(item, matchState) { | |
| 1222 if (typeof item == 'string') { | |
| 1223 return dart.notNull(item[dartx.indexOf](core.Pattern._check(this[_expect
ed]))) >= 0; | |
| 1224 } else if (core.Iterable.is(item)) { | |
| 1225 if (src__interfaces.Matcher.is(this[_expected])) { | |
| 1226 return item[dartx.any](dart.fn(e => core.bool._check(dart.dsend(this[_
expected], 'matches', e, matchState)), dynamicTobool$())); | |
| 1227 } else { | |
| 1228 return item[dartx.contains](this[_expected]); | |
| 1229 } | |
| 1230 } else if (core.Map.is(item)) { | |
| 1231 return item[dartx.containsKey](this[_expected]); | |
| 1232 } | |
| 1233 return false; | |
| 1234 } | |
| 1235 describe(description) { | |
| 1236 return description.add('contains ').addDescriptionOf(this[_expected]); | |
| 1237 } | |
| 1238 describeMismatch(item, mismatchDescription, matchState, verbose) { | |
| 1239 if (typeof item == 'string' || core.Iterable.is(item) || core.Map.is(item)
) { | |
| 1240 return super.describeMismatch(item, mismatchDescription, matchState, ver
bose); | |
| 1241 } else { | |
| 1242 return mismatchDescription.add('is not a string, map or iterable'); | |
| 1243 } | |
| 1244 } | |
| 1245 }; | |
| 1246 dart.setSignature(src__core_matchers._Contains, { | |
| 1247 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers._Con
tains, [dart.dynamic])}), | |
| 1248 methods: () => ({ | |
| 1249 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1250 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1251 }) | |
| 1252 }); | |
| 1253 src__core_matchers._In = class _In extends src__interfaces.Matcher { | |
| 1254 new(expected) { | |
| 1255 this[_expected] = expected; | |
| 1256 super.new(); | |
| 1257 } | |
| 1258 matches(item, matchState) { | |
| 1259 if (typeof this[_expected] == 'string') { | |
| 1260 return core.bool._check(dart.dsend(dart.dsend(this[_expected], 'indexOf'
, item), '>=', 0)); | |
| 1261 } else if (core.Iterable.is(this[_expected])) { | |
| 1262 return core.bool._check(dart.dsend(this[_expected], 'any', dart.fn(e =>
dart.equals(e, item), dynamicTobool$()))); | |
| 1263 } else if (core.Map.is(this[_expected])) { | |
| 1264 return core.bool._check(dart.dsend(this[_expected], 'containsKey', item)
); | |
| 1265 } | |
| 1266 return false; | |
| 1267 } | |
| 1268 describe(description) { | |
| 1269 return description.add('is in ').addDescriptionOf(this[_expected]); | |
| 1270 } | |
| 1271 }; | |
| 1272 dart.setSignature(src__core_matchers._In, { | |
| 1273 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers._In,
[dart.dynamic])}), | |
| 1274 methods: () => ({ | |
| 1275 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1276 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1277 }) | |
| 1278 }); | |
| 1279 src__core_matchers._PredicateFunction = dart.typedef('_PredicateFunction', ()
=> dart.functionType(core.bool, [dart.dynamic])); | |
| 1280 const _description = Symbol('_description'); | |
| 1281 src__core_matchers._Predicate = class _Predicate extends src__interfaces.Match
er { | |
| 1282 new(matcher, description) { | |
| 1283 this[_matcher] = matcher; | |
| 1284 this[_description] = description; | |
| 1285 super.new(); | |
| 1286 } | |
| 1287 matches(item, matchState) { | |
| 1288 return dart.dcall(this[_matcher], item); | |
| 1289 } | |
| 1290 describe(description) { | |
| 1291 return description.add(this[_description]); | |
| 1292 } | |
| 1293 }; | |
| 1294 dart.setSignature(src__core_matchers._Predicate, { | |
| 1295 constructors: () => ({new: dart.definiteFunctionType(src__core_matchers._Pre
dicate, [src__core_matchers._PredicateFunction, core.String])}), | |
| 1296 methods: () => ({ | |
| 1297 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1298 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1299 }) | |
| 1300 }); | |
| 1301 const _matcher$0 = Symbol('_matcher'); | |
| 1302 src__iterable_matchers._IterableMatcher = class _IterableMatcher extends src__
interfaces.Matcher { | |
| 1303 new() { | |
| 1304 super.new(); | |
| 1305 } | |
| 1306 describeMismatch(item, mismatchDescription, matchState, verbose) { | |
| 1307 if (!core.Iterable.is(item)) { | |
| 1308 return mismatchDescription.addDescriptionOf(item).add(' not an Iterable'
); | |
| 1309 } else { | |
| 1310 return super.describeMismatch(item, mismatchDescription, matchState, ver
bose); | |
| 1311 } | |
| 1312 } | |
| 1313 }; | |
| 1314 dart.setSignature(src__iterable_matchers._IterableMatcher, { | |
| 1315 constructors: () => ({new: dart.definiteFunctionType(src__iterable_matchers.
_IterableMatcher, [])}) | |
| 1316 }); | |
| 1317 src__iterable_matchers._EveryElement = class _EveryElement extends src__iterab
le_matchers._IterableMatcher { | |
| 1318 new(matcher) { | |
| 1319 this[_matcher$0] = matcher; | |
| 1320 super.new(); | |
| 1321 } | |
| 1322 matches(item, matchState) { | |
| 1323 if (!core.Iterable.is(item)) { | |
| 1324 return false; | |
| 1325 } | |
| 1326 let i = 0; | |
| 1327 for (let element of core.Iterable._check(item)) { | |
| 1328 if (!dart.test(this[_matcher$0].matches(element, matchState))) { | |
| 1329 src__util.addStateInfo(matchState, dart.map({index: i, element: elemen
t}, core.String, dart.dynamic)); | |
| 1330 return false; | |
| 1331 } | |
| 1332 ++i; | |
| 1333 } | |
| 1334 return true; | |
| 1335 } | |
| 1336 describe(description) { | |
| 1337 return description.add('every element(').addDescriptionOf(this[_matcher$0]
).add(')'); | |
| 1338 } | |
| 1339 describeMismatch(item, mismatchDescription, matchState, verbose) { | |
| 1340 if (matchState[dartx.get]('index') != null) { | |
| 1341 let index = matchState[dartx.get]('index'); | |
| 1342 let element = matchState[dartx.get]('element'); | |
| 1343 mismatchDescription.add('has value ').addDescriptionOf(element).add(' wh
ich '); | |
| 1344 let subDescription = new src__description.StringDescription(); | |
| 1345 this[_matcher$0].describeMismatch(element, subDescription, core.Map._che
ck(matchState[dartx.get]('state')), verbose); | |
| 1346 if (dart.notNull(subDescription.length) > 0) { | |
| 1347 mismatchDescription.add(subDescription.toString()); | |
| 1348 } else { | |
| 1349 mismatchDescription.add("doesn't match "); | |
| 1350 this[_matcher$0].describe(mismatchDescription); | |
| 1351 } | |
| 1352 mismatchDescription.add(dart.str` at index ${index}`); | |
| 1353 return mismatchDescription; | |
| 1354 } | |
| 1355 return super.describeMismatch(item, mismatchDescription, matchState, verbo
se); | |
| 1356 } | |
| 1357 }; | |
| 1358 dart.setSignature(src__iterable_matchers._EveryElement, { | |
| 1359 constructors: () => ({new: dart.definiteFunctionType(src__iterable_matchers.
_EveryElement, [src__interfaces.Matcher])}), | |
| 1360 methods: () => ({ | |
| 1361 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1362 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1363 }) | |
| 1364 }); | |
| 1365 src__iterable_matchers._AnyElement = class _AnyElement extends src__iterable_m
atchers._IterableMatcher { | |
| 1366 new(matcher) { | |
| 1367 this[_matcher$0] = matcher; | |
| 1368 super.new(); | |
| 1369 } | |
| 1370 matches(item, matchState) { | |
| 1371 return core.bool._check(dart.dsend(item, 'any', dart.fn(e => this[_matcher
$0].matches(e, matchState), dynamicTobool$()))); | |
| 1372 } | |
| 1373 describe(description) { | |
| 1374 return description.add('some element ').addDescriptionOf(this[_matcher$0])
; | |
| 1375 } | |
| 1376 }; | |
| 1377 dart.setSignature(src__iterable_matchers._AnyElement, { | |
| 1378 constructors: () => ({new: dart.definiteFunctionType(src__iterable_matchers.
_AnyElement, [src__interfaces.Matcher])}), | |
| 1379 methods: () => ({ | |
| 1380 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1381 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1382 }) | |
| 1383 }); | |
| 1384 const _expected$ = Symbol('_expected'); | |
| 1385 src__iterable_matchers._OrderedEquals = class _OrderedEquals extends src__inte
rfaces.Matcher { | |
| 1386 new(expected) { | |
| 1387 this[_expected$] = expected; | |
| 1388 this[_matcher$0] = null; | |
| 1389 super.new(); | |
| 1390 this[_matcher$0] = src__core_matchers.equals(this[_expected$], 1); | |
| 1391 } | |
| 1392 matches(item, matchState) { | |
| 1393 return core.Iterable.is(item) && dart.test(this[_matcher$0].matches(item,
matchState)); | |
| 1394 } | |
| 1395 describe(description) { | |
| 1396 return description.add('equals ').addDescriptionOf(this[_expected$]).add('
ordered'); | |
| 1397 } | |
| 1398 describeMismatch(item, mismatchDescription, matchState, verbose) { | |
| 1399 if (!core.Iterable.is(item)) { | |
| 1400 return mismatchDescription.add('is not an Iterable'); | |
| 1401 } else { | |
| 1402 return this[_matcher$0].describeMismatch(item, mismatchDescription, matc
hState, verbose); | |
| 1403 } | |
| 1404 } | |
| 1405 }; | |
| 1406 dart.setSignature(src__iterable_matchers._OrderedEquals, { | |
| 1407 constructors: () => ({new: dart.definiteFunctionType(src__iterable_matchers.
_OrderedEquals, [core.Iterable])}), | |
| 1408 methods: () => ({ | |
| 1409 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1410 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1411 }) | |
| 1412 }); | |
| 1413 const _expectedValues = Symbol('_expectedValues'); | |
| 1414 const _test = Symbol('_test'); | |
| 1415 src__iterable_matchers._UnorderedMatches = class _UnorderedMatches extends src
__interfaces.Matcher { | |
| 1416 new(expected) { | |
| 1417 this[_expected$] = expected[dartx.map](src__interfaces.Matcher)(src__util.
wrapMatcher)[dartx.toList](); | |
| 1418 super.new(); | |
| 1419 } | |
| 1420 [_test](item) { | |
| 1421 if (!core.Iterable.is(item)) return 'not iterable'; | |
| 1422 item = dart.dsend(item, 'toList'); | |
| 1423 if (dart.notNull(this[_expected$][dartx.length]) > dart.notNull(core.num._
check(dart.dload(item, 'length')))) { | |
| 1424 return dart.str`has too few elements (${dart.dload(item, 'length')} < ${
this[_expected$][dartx.length]})`; | |
| 1425 } else if (dart.notNull(this[_expected$][dartx.length]) < dart.notNull(cor
e.num._check(dart.dload(item, 'length')))) { | |
| 1426 return dart.str`has too many elements (${dart.dload(item, 'length')} > $
{this[_expected$][dartx.length]})`; | |
| 1427 } | |
| 1428 let matched = ListOfbool().filled(core.int._check(dart.dload(item, 'length
')), false); | |
| 1429 let expectedPosition = 0; | |
| 1430 for (let expectedMatcher of this[_expected$]) { | |
| 1431 let actualPosition = 0; | |
| 1432 let gotMatch = false; | |
| 1433 for (let actualElement of core.Iterable._check(item)) { | |
| 1434 if (!dart.test(matched[dartx.get](actualPosition))) { | |
| 1435 if (dart.test(expectedMatcher.matches(actualElement, dart.map()))) { | |
| 1436 matched[dartx.set](actualPosition, gotMatch = true); | |
| 1437 break; | |
| 1438 } | |
| 1439 } | |
| 1440 ++actualPosition; | |
| 1441 } | |
| 1442 if (!gotMatch) { | |
| 1443 return dart.toString(new src__description.StringDescription().add('has
no match for ').addDescriptionOf(expectedMatcher).add(dart.str` at index ${expe
ctedPosition}`)); | |
| 1444 } | |
| 1445 ++expectedPosition; | |
| 1446 } | |
| 1447 return null; | |
| 1448 } | |
| 1449 matches(item, mismatchState) { | |
| 1450 return this[_test](item) == null; | |
| 1451 } | |
| 1452 describe(description) { | |
| 1453 return description.add('matches ').addAll('[', ', ', ']', this[_expected$]
).add(' unordered'); | |
| 1454 } | |
| 1455 describeMismatch(item, mismatchDescription, matchState, verbose) { | |
| 1456 return mismatchDescription.add(this[_test](item)); | |
| 1457 } | |
| 1458 }; | |
| 1459 dart.setSignature(src__iterable_matchers._UnorderedMatches, { | |
| 1460 constructors: () => ({new: dart.definiteFunctionType(src__iterable_matchers.
_UnorderedMatches, [core.Iterable])}), | |
| 1461 methods: () => ({ | |
| 1462 [_test]: dart.definiteFunctionType(core.String, [dart.dynamic]), | |
| 1463 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1464 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1465 }) | |
| 1466 }); | |
| 1467 src__iterable_matchers._UnorderedEquals = class _UnorderedEquals extends src__
iterable_matchers._UnorderedMatches { | |
| 1468 new(expected) { | |
| 1469 this[_expectedValues] = expected[dartx.toList](); | |
| 1470 super.new(expected[dartx.map](src__interfaces.Matcher)(src__core_matchers.
equals)); | |
| 1471 } | |
| 1472 describe(description) { | |
| 1473 return description.add('equals ').addDescriptionOf(this[_expectedValues]).
add(' unordered'); | |
| 1474 } | |
| 1475 }; | |
| 1476 dart.setSignature(src__iterable_matchers._UnorderedEquals, { | |
| 1477 constructors: () => ({new: dart.definiteFunctionType(src__iterable_matchers.
_UnorderedEquals, [core.Iterable])}) | |
| 1478 }); | |
| 1479 src__iterable_matchers._Comparator = dart.typedef('_Comparator', () => dart.fu
nctionType(core.bool, [dart.dynamic, dart.dynamic])); | |
| 1480 const _comparator = Symbol('_comparator'); | |
| 1481 const _description$ = Symbol('_description'); | |
| 1482 src__iterable_matchers._PairwiseCompare = class _PairwiseCompare extends src__
iterable_matchers._IterableMatcher { | |
| 1483 new(expected, comparator, description) { | |
| 1484 this[_expected$] = expected; | |
| 1485 this[_comparator] = comparator; | |
| 1486 this[_description$] = description; | |
| 1487 super.new(); | |
| 1488 } | |
| 1489 matches(item, matchState) { | |
| 1490 if (!core.Iterable.is(item)) return false; | |
| 1491 if (!dart.equals(dart.dload(item, 'length'), this[_expected$][dartx.length
])) return false; | |
| 1492 let iterator = dart.dload(item, 'iterator'); | |
| 1493 let i = 0; | |
| 1494 for (let e of this[_expected$]) { | |
| 1495 dart.dsend(iterator, 'moveNext'); | |
| 1496 if (!dart.test(dart.dcall(this[_comparator], e, dart.dload(iterator, 'cu
rrent')))) { | |
| 1497 src__util.addStateInfo(matchState, dart.map({index: i, expected: e, ac
tual: dart.dload(iterator, 'current')}, core.String, dart.dynamic)); | |
| 1498 return false; | |
| 1499 } | |
| 1500 i++; | |
| 1501 } | |
| 1502 return true; | |
| 1503 } | |
| 1504 describe(description) { | |
| 1505 return description.add(dart.str`pairwise ${this[_description$]} `).addDesc
riptionOf(this[_expected$]); | |
| 1506 } | |
| 1507 describeMismatch(item, mismatchDescription, matchState, verbose) { | |
| 1508 if (!core.Iterable.is(item)) { | |
| 1509 return mismatchDescription.add('is not an Iterable'); | |
| 1510 } else if (!dart.equals(dart.dload(item, 'length'), this[_expected$][dartx
.length])) { | |
| 1511 return mismatchDescription.add(dart.str`has length ${dart.dload(item, 'l
ength')} instead of ${this[_expected$][dartx.length]}`); | |
| 1512 } else { | |
| 1513 return mismatchDescription.add('has ').addDescriptionOf(matchState[dartx
.get]("actual")).add(dart.str` which is not ${this[_description$]} `).addDescrip
tionOf(matchState[dartx.get]("expected")).add(dart.str` at index ${matchState[da
rtx.get]("index")}`); | |
| 1514 } | |
| 1515 } | |
| 1516 }; | |
| 1517 dart.setSignature(src__iterable_matchers._PairwiseCompare, { | |
| 1518 constructors: () => ({new: dart.definiteFunctionType(src__iterable_matchers.
_PairwiseCompare, [core.Iterable, src__iterable_matchers._Comparator, core.Strin
g])}), | |
| 1519 methods: () => ({ | |
| 1520 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1521 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1522 }) | |
| 1523 }); | |
| 1524 const _value$0 = Symbol('_value'); | |
| 1525 src__map_matchers._ContainsValue = class _ContainsValue extends src__interface
s.Matcher { | |
| 1526 new(value) { | |
| 1527 this[_value$0] = value; | |
| 1528 super.new(); | |
| 1529 } | |
| 1530 matches(item, matchState) { | |
| 1531 return core.bool._check(dart.dsend(item, 'containsValue', this[_value$0]))
; | |
| 1532 } | |
| 1533 describe(description) { | |
| 1534 return description.add('contains value ').addDescriptionOf(this[_value$0])
; | |
| 1535 } | |
| 1536 }; | |
| 1537 dart.setSignature(src__map_matchers._ContainsValue, { | |
| 1538 constructors: () => ({new: dart.definiteFunctionType(src__map_matchers._Cont
ainsValue, [dart.dynamic])}), | |
| 1539 methods: () => ({ | |
| 1540 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1541 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1542 }) | |
| 1543 }); | |
| 1544 const _key = Symbol('_key'); | |
| 1545 const _valueMatcher = Symbol('_valueMatcher'); | |
| 1546 src__map_matchers._ContainsMapping = class _ContainsMapping extends src__inter
faces.Matcher { | |
| 1547 new(key, valueMatcher) { | |
| 1548 this[_key] = key; | |
| 1549 this[_valueMatcher] = valueMatcher; | |
| 1550 super.new(); | |
| 1551 } | |
| 1552 matches(item, matchState) { | |
| 1553 return dart.test(dart.dsend(item, 'containsKey', this[_key])) && dart.test
(this[_valueMatcher].matches(dart.dindex(item, this[_key]), matchState)); | |
| 1554 } | |
| 1555 describe(description) { | |
| 1556 return description.add('contains pair ').addDescriptionOf(this[_key]).add(
' => ').addDescriptionOf(this[_valueMatcher]); | |
| 1557 } | |
| 1558 describeMismatch(item, mismatchDescription, matchState, verbose) { | |
| 1559 if (!dart.test(dart.dsend(item, 'containsKey', this[_key]))) { | |
| 1560 return mismatchDescription.add(" doesn't contain key ").addDescriptionOf
(this[_key]); | |
| 1561 } else { | |
| 1562 mismatchDescription.add(' contains key ').addDescriptionOf(this[_key]).a
dd(' but with value '); | |
| 1563 this[_valueMatcher].describeMismatch(dart.dindex(item, this[_key]), mism
atchDescription, matchState, verbose); | |
| 1564 return mismatchDescription; | |
| 1565 } | |
| 1566 } | |
| 1567 }; | |
| 1568 dart.setSignature(src__map_matchers._ContainsMapping, { | |
| 1569 constructors: () => ({new: dart.definiteFunctionType(src__map_matchers._Cont
ainsMapping, [dart.dynamic, src__interfaces.Matcher])}), | |
| 1570 methods: () => ({ | |
| 1571 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1572 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1573 }) | |
| 1574 }); | |
| 1575 src__numeric_matchers._isNumeric = function(value) { | |
| 1576 return typeof value == 'number'; | |
| 1577 }; | |
| 1578 dart.fn(src__numeric_matchers._isNumeric, dynamicTobool$()); | |
| 1579 const _delta = Symbol('_delta'); | |
| 1580 src__numeric_matchers._IsCloseTo = class _IsCloseTo extends src__interfaces.Ma
tcher { | |
| 1581 new(value, delta) { | |
| 1582 this[_value] = value; | |
| 1583 this[_delta] = delta; | |
| 1584 super.new(); | |
| 1585 } | |
| 1586 matches(item, matchState) { | |
| 1587 if (!dart.test(src__numeric_matchers._isNumeric(item))) { | |
| 1588 return false; | |
| 1589 } | |
| 1590 let diff = dart.dsend(item, '-', this[_value]); | |
| 1591 if (dart.test(dart.dsend(diff, '<', 0))) diff = dart.dsend(diff, 'unary-')
; | |
| 1592 return core.bool._check(dart.dsend(diff, '<=', this[_delta])); | |
| 1593 } | |
| 1594 describe(description) { | |
| 1595 return description.add('a numeric value within ').addDescriptionOf(this[_d
elta]).add(' of ').addDescriptionOf(this[_value]); | |
| 1596 } | |
| 1597 describeMismatch(item, mismatchDescription, matchState, verbose) { | |
| 1598 if (!(typeof item == 'number')) { | |
| 1599 return mismatchDescription.add(' not numeric'); | |
| 1600 } else { | |
| 1601 let diff = dart.dsend(item, '-', this[_value]); | |
| 1602 if (dart.test(dart.dsend(diff, '<', 0))) diff = dart.dsend(diff, 'unary-
'); | |
| 1603 return mismatchDescription.add(' differs by ').addDescriptionOf(diff); | |
| 1604 } | |
| 1605 } | |
| 1606 }; | |
| 1607 dart.setSignature(src__numeric_matchers._IsCloseTo, { | |
| 1608 constructors: () => ({new: dart.definiteFunctionType(src__numeric_matchers._
IsCloseTo, [core.num, core.num])}), | |
| 1609 methods: () => ({ | |
| 1610 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1611 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1612 }) | |
| 1613 }); | |
| 1614 const _low = Symbol('_low'); | |
| 1615 const _high = Symbol('_high'); | |
| 1616 const _lowMatchValue = Symbol('_lowMatchValue'); | |
| 1617 const _highMatchValue = Symbol('_highMatchValue'); | |
| 1618 src__numeric_matchers._InRange = class _InRange extends src__interfaces.Matche
r { | |
| 1619 new(low, high, lowMatchValue, highMatchValue) { | |
| 1620 this[_low] = low; | |
| 1621 this[_high] = high; | |
| 1622 this[_lowMatchValue] = lowMatchValue; | |
| 1623 this[_highMatchValue] = highMatchValue; | |
| 1624 super.new(); | |
| 1625 } | |
| 1626 matches(value, matchState) { | |
| 1627 if (!(typeof value == 'number')) { | |
| 1628 return false; | |
| 1629 } | |
| 1630 if (dart.test(dart.dsend(value, '<', this[_low])) || dart.test(dart.dsend(
value, '>', this[_high]))) { | |
| 1631 return false; | |
| 1632 } | |
| 1633 if (dart.equals(value, this[_low])) { | |
| 1634 return this[_lowMatchValue]; | |
| 1635 } | |
| 1636 if (dart.equals(value, this[_high])) { | |
| 1637 return this[_highMatchValue]; | |
| 1638 } | |
| 1639 return true; | |
| 1640 } | |
| 1641 describe(description) { | |
| 1642 return description.add("be in range from " + dart.str`${this[_low]} (${dar
t.test(this[_lowMatchValue]) ? 'inclusive' : 'exclusive'}) to ` + dart.str`${thi
s[_high]} (${dart.test(this[_highMatchValue]) ? 'inclusive' : 'exclusive'})`); | |
| 1643 } | |
| 1644 describeMismatch(item, mismatchDescription, matchState, verbose) { | |
| 1645 if (!(typeof item == 'number')) { | |
| 1646 return mismatchDescription.addDescriptionOf(item).add(' not numeric'); | |
| 1647 } else { | |
| 1648 return super.describeMismatch(item, mismatchDescription, matchState, ver
bose); | |
| 1649 } | |
| 1650 } | |
| 1651 }; | |
| 1652 dart.setSignature(src__numeric_matchers._InRange, { | |
| 1653 constructors: () => ({new: dart.definiteFunctionType(src__numeric_matchers._
InRange, [core.num, core.num, core.bool, core.bool])}), | |
| 1654 methods: () => ({ | |
| 1655 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1656 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1657 }) | |
| 1658 }); | |
| 1659 const _matcher$1 = Symbol('_matcher'); | |
| 1660 src__operator_matchers._IsNot = class _IsNot extends src__interfaces.Matcher { | |
| 1661 new(matcher) { | |
| 1662 this[_matcher$1] = matcher; | |
| 1663 super.new(); | |
| 1664 } | |
| 1665 matches(item, matchState) { | |
| 1666 return !dart.test(this[_matcher$1].matches(item, matchState)); | |
| 1667 } | |
| 1668 describe(description) { | |
| 1669 return description.add('not ').addDescriptionOf(this[_matcher$1]); | |
| 1670 } | |
| 1671 }; | |
| 1672 dart.setSignature(src__operator_matchers._IsNot, { | |
| 1673 constructors: () => ({new: dart.definiteFunctionType(src__operator_matchers.
_IsNot, [src__interfaces.Matcher])}), | |
| 1674 methods: () => ({ | |
| 1675 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1676 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1677 }) | |
| 1678 }); | |
| 1679 const _matchers = Symbol('_matchers'); | |
| 1680 src__operator_matchers._AllOf = class _AllOf extends src__interfaces.Matcher { | |
| 1681 new(matchers) { | |
| 1682 this[_matchers] = matchers; | |
| 1683 super.new(); | |
| 1684 } | |
| 1685 matches(item, matchState) { | |
| 1686 for (let matcher of this[_matchers]) { | |
| 1687 if (!dart.test(matcher.matches(item, matchState))) { | |
| 1688 src__util.addStateInfo(matchState, dart.map({matcher: matcher}, core.S
tring, src__interfaces.Matcher)); | |
| 1689 return false; | |
| 1690 } | |
| 1691 } | |
| 1692 return true; | |
| 1693 } | |
| 1694 describeMismatch(item, mismatchDescription, matchState, verbose) { | |
| 1695 let matcher = matchState[dartx.get]('matcher'); | |
| 1696 dart.dsend(matcher, 'describeMismatch', item, mismatchDescription, matchSt
ate[dartx.get]('state'), verbose); | |
| 1697 return mismatchDescription; | |
| 1698 } | |
| 1699 describe(description) { | |
| 1700 return description.addAll('(', ' and ', ')', this[_matchers]); | |
| 1701 } | |
| 1702 }; | |
| 1703 dart.setSignature(src__operator_matchers._AllOf, { | |
| 1704 constructors: () => ({new: dart.definiteFunctionType(src__operator_matchers.
_AllOf, [core.List$(src__interfaces.Matcher)])}), | |
| 1705 methods: () => ({ | |
| 1706 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1707 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1708 }) | |
| 1709 }); | |
| 1710 src__operator_matchers._AnyOf = class _AnyOf extends src__interfaces.Matcher { | |
| 1711 new(matchers) { | |
| 1712 this[_matchers] = matchers; | |
| 1713 super.new(); | |
| 1714 } | |
| 1715 matches(item, matchState) { | |
| 1716 for (let matcher of this[_matchers]) { | |
| 1717 if (dart.test(matcher.matches(item, matchState))) { | |
| 1718 return true; | |
| 1719 } | |
| 1720 } | |
| 1721 return false; | |
| 1722 } | |
| 1723 describe(description) { | |
| 1724 return description.addAll('(', ' or ', ')', this[_matchers]); | |
| 1725 } | |
| 1726 }; | |
| 1727 dart.setSignature(src__operator_matchers._AnyOf, { | |
| 1728 constructors: () => ({new: dart.definiteFunctionType(src__operator_matchers.
_AnyOf, [core.List$(src__interfaces.Matcher)])}), | |
| 1729 methods: () => ({ | |
| 1730 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1731 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1732 }) | |
| 1733 }); | |
| 1734 src__operator_matchers._wrapArgs = function(arg0, arg1, arg2, arg3, arg4, arg5
, arg6) { | |
| 1735 let args = null; | |
| 1736 if (core.List.is(arg0)) { | |
| 1737 if (arg1 != null || arg2 != null || arg3 != null || arg4 != null || arg5 !
= null || arg6 != null) { | |
| 1738 dart.throw(new core.ArgumentError('If arg0 is a List, all other argument
s must be' + ' null.')); | |
| 1739 } | |
| 1740 args = arg0; | |
| 1741 } else { | |
| 1742 args = [arg0, arg1, arg2, arg3, arg4, arg5, arg6][dartx.where](dart.fn(e =
> e != null, dynamicTobool$())); | |
| 1743 } | |
| 1744 return args[dartx.map](src__interfaces.Matcher)(dart.fn(e => src__util.wrapM
atcher(e), dynamicToMatcher()))[dartx.toList](); | |
| 1745 }; | |
| 1746 dart.fn(src__operator_matchers._wrapArgs, dynamicAnddynamicAnddynamic__ToListO
fMatcher()); | |
| 1747 src__pretty_print.prettyPrint = function(object, opts) { | |
| 1748 let maxLineLength = opts && 'maxLineLength' in opts ? opts.maxLineLength : n
ull; | |
| 1749 let maxItems = opts && 'maxItems' in opts ? opts.maxItems : null; | |
| 1750 function _prettyPrint(object, indent, seen, top) { | |
| 1751 if (src__interfaces.Matcher.is(object)) { | |
| 1752 let description = new src__description.StringDescription(); | |
| 1753 object.describe(description); | |
| 1754 return dart.str`<${description}>`; | |
| 1755 } | |
| 1756 if (dart.test(seen.contains(object))) return "(recursive)"; | |
| 1757 seen = seen.union(core.Set.from([object])); | |
| 1758 function pp(child) { | |
| 1759 return _prettyPrint(child, dart.notNull(indent) + 2, seen, false); | |
| 1760 } | |
| 1761 dart.fn(pp, dynamicToString()); | |
| 1762 if (core.Iterable.is(object)) { | |
| 1763 let type = core.List.is(object) ? "" : dart.notNull(src__pretty_print._t
ypeName(object)) + ":"; | |
| 1764 let strings = object[dartx.map](core.String)(pp)[dartx.toList](); | |
| 1765 if (maxItems != null && dart.notNull(strings[dartx.length]) > dart.notNu
ll(maxItems)) { | |
| 1766 strings[dartx.replaceRange](dart.notNull(maxItems) - 1, strings[dartx.
length], JSArrayOfString().of(['...'])); | |
| 1767 } | |
| 1768 let singleLine = dart.str`${type}[${strings[dartx.join](', ')}]`; | |
| 1769 if ((maxLineLength == null || dart.notNull(singleLine[dartx.length]) + d
art.notNull(indent) <= dart.notNull(maxLineLength)) && !dart.test(singleLine[dar
tx.contains]("\n"))) { | |
| 1770 return singleLine; | |
| 1771 } | |
| 1772 return dart.str`${type}[\n` + dart.notNull(strings[dartx.map](core.Strin
g)(dart.fn(string => dart.notNull(src__pretty_print._indent(dart.notNull(indent)
+ 2)) + dart.notNull(string), StringToString()))[dartx.join](",\n")) + "\n" + d
art.notNull(src__pretty_print._indent(indent)) + "]"; | |
| 1773 } else if (core.Map.is(object)) { | |
| 1774 let strings = object[dartx.keys][dartx.map](core.String)(dart.fn(key =>
dart.str`${pp(key)}: ${pp(object[dartx.get](key))}`, dynamicToString()))[dartx.t
oList](); | |
| 1775 if (maxItems != null && dart.notNull(strings[dartx.length]) > dart.notNu
ll(maxItems)) { | |
| 1776 strings[dartx.replaceRange](dart.notNull(maxItems) - 1, strings[dartx.
length], JSArrayOfString().of(['...'])); | |
| 1777 } | |
| 1778 let singleLine = dart.str`{${strings[dartx.join](", ")}}`; | |
| 1779 if ((maxLineLength == null || dart.notNull(singleLine[dartx.length]) + d
art.notNull(indent) <= dart.notNull(maxLineLength)) && !dart.test(singleLine[dar
tx.contains]("\n"))) { | |
| 1780 return singleLine; | |
| 1781 } | |
| 1782 return "{\n" + dart.notNull(strings[dartx.map](core.String)(dart.fn(stri
ng => dart.notNull(src__pretty_print._indent(dart.notNull(indent) + 2)) + dart.n
otNull(string), StringToString()))[dartx.join](",\n")) + "\n" + dart.notNull(src
__pretty_print._indent(indent)) + "}"; | |
| 1783 } else if (typeof object == 'string') { | |
| 1784 let lines = object[dartx.split]("\n"); | |
| 1785 return "'" + dart.notNull(lines[dartx.map](core.String)(src__pretty_prin
t._escapeString)[dartx.join](dart.str`\\n'\n${src__pretty_print._indent(dart.not
Null(indent) + 2)}'`)) + "'"; | |
| 1786 } else { | |
| 1787 let value = dart.toString(object)[dartx.replaceAll]("\n", dart.notNull(s
rc__pretty_print._indent(indent)) + "\n"); | |
| 1788 let defaultToString = value[dartx.startsWith]("Instance of "); | |
| 1789 if (dart.test(top)) value = dart.str`<${value}>`; | |
| 1790 if (typeof object == 'number' || typeof object == 'boolean' || core.Func
tion.is(object) || object == null || dart.test(defaultToString)) { | |
| 1791 return value; | |
| 1792 } else { | |
| 1793 return dart.str`${src__pretty_print._typeName(object)}:${value}`; | |
| 1794 } | |
| 1795 } | |
| 1796 } | |
| 1797 dart.fn(_prettyPrint, dynamicAndintAndSet__ToString()); | |
| 1798 return _prettyPrint(object, 0, core.Set.new(), true); | |
| 1799 }; | |
| 1800 dart.fn(src__pretty_print.prettyPrint, dynamic__ToString()); | |
| 1801 src__pretty_print._indent = function(length) { | |
| 1802 return ListOfString().filled(length, ' ')[dartx.join](''); | |
| 1803 }; | |
| 1804 dart.fn(src__pretty_print._indent, intToString()); | |
| 1805 src__pretty_print._typeName = function(x) { | |
| 1806 try { | |
| 1807 if (x == null) return "null"; | |
| 1808 let type = dart.toString(dart.runtimeType(x)); | |
| 1809 return dart.test(type[dartx.startsWith]("_")) ? "?" : type; | |
| 1810 } catch (e) { | |
| 1811 return "?"; | |
| 1812 } | |
| 1813 | |
| 1814 }; | |
| 1815 dart.fn(src__pretty_print._typeName, dynamicToString()); | |
| 1816 src__pretty_print._escapeString = function(source) { | |
| 1817 return src__util.escape(source)[dartx.replaceAll]("'", "\\'"); | |
| 1818 }; | |
| 1819 dart.fn(src__pretty_print._escapeString, StringToString()); | |
| 1820 const _value$1 = Symbol('_value'); | |
| 1821 const _matchValue = Symbol('_matchValue'); | |
| 1822 src__string_matchers._StringMatcher = class _StringMatcher extends src__interf
aces.Matcher { | |
| 1823 new() { | |
| 1824 super.new(); | |
| 1825 } | |
| 1826 describeMismatch(item, mismatchDescription, matchState, verbose) { | |
| 1827 if (!(typeof item == 'string')) { | |
| 1828 return mismatchDescription.addDescriptionOf(item).add(' not a string'); | |
| 1829 } else { | |
| 1830 return super.describeMismatch(item, mismatchDescription, matchState, ver
bose); | |
| 1831 } | |
| 1832 } | |
| 1833 }; | |
| 1834 dart.setSignature(src__string_matchers._StringMatcher, { | |
| 1835 constructors: () => ({new: dart.definiteFunctionType(src__string_matchers._S
tringMatcher, [])}) | |
| 1836 }); | |
| 1837 src__string_matchers._IsEqualIgnoringCase = class _IsEqualIgnoringCase extends
src__string_matchers._StringMatcher { | |
| 1838 new(value) { | |
| 1839 this[_value$1] = value; | |
| 1840 this[_matchValue] = value[dartx.toLowerCase](); | |
| 1841 super.new(); | |
| 1842 } | |
| 1843 matches(item, matchState) { | |
| 1844 return typeof item == 'string' && this[_matchValue] == item[dartx.toLowerC
ase](); | |
| 1845 } | |
| 1846 describe(description) { | |
| 1847 return description.addDescriptionOf(this[_value$1]).add(' ignoring case'); | |
| 1848 } | |
| 1849 }; | |
| 1850 dart.setSignature(src__string_matchers._IsEqualIgnoringCase, { | |
| 1851 constructors: () => ({new: dart.definiteFunctionType(src__string_matchers._I
sEqualIgnoringCase, [core.String])}), | |
| 1852 methods: () => ({ | |
| 1853 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1854 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1855 }) | |
| 1856 }); | |
| 1857 src__string_matchers._IsEqualIgnoringWhitespace = class _IsEqualIgnoringWhites
pace extends src__string_matchers._StringMatcher { | |
| 1858 new(value) { | |
| 1859 this[_value$1] = value; | |
| 1860 this[_matchValue] = src__string_matchers.collapseWhitespace(value); | |
| 1861 super.new(); | |
| 1862 } | |
| 1863 matches(item, matchState) { | |
| 1864 return typeof item == 'string' && this[_matchValue] == src__string_matcher
s.collapseWhitespace(item); | |
| 1865 } | |
| 1866 describe(description) { | |
| 1867 return description.addDescriptionOf(this[_matchValue]).add(' ignoring whit
espace'); | |
| 1868 } | |
| 1869 describeMismatch(item, mismatchDescription, matchState, verbose) { | |
| 1870 if (typeof item == 'string') { | |
| 1871 return mismatchDescription.add('is ').addDescriptionOf(src__string_match
ers.collapseWhitespace(item)).add(' with whitespace compressed'); | |
| 1872 } else { | |
| 1873 return super.describeMismatch(item, mismatchDescription, matchState, ver
bose); | |
| 1874 } | |
| 1875 } | |
| 1876 }; | |
| 1877 dart.setSignature(src__string_matchers._IsEqualIgnoringWhitespace, { | |
| 1878 constructors: () => ({new: dart.definiteFunctionType(src__string_matchers._I
sEqualIgnoringWhitespace, [core.String])}), | |
| 1879 methods: () => ({ | |
| 1880 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1881 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1882 }) | |
| 1883 }); | |
| 1884 const _prefix = Symbol('_prefix'); | |
| 1885 src__string_matchers._StringStartsWith = class _StringStartsWith extends src__
string_matchers._StringMatcher { | |
| 1886 new(prefix) { | |
| 1887 this[_prefix] = prefix; | |
| 1888 super.new(); | |
| 1889 } | |
| 1890 matches(item, matchState) { | |
| 1891 return typeof item == 'string' && dart.test(item[dartx.startsWith](this[_p
refix])); | |
| 1892 } | |
| 1893 describe(description) { | |
| 1894 return description.add('a string starting with ').addDescriptionOf(this[_p
refix]); | |
| 1895 } | |
| 1896 }; | |
| 1897 dart.setSignature(src__string_matchers._StringStartsWith, { | |
| 1898 constructors: () => ({new: dart.definiteFunctionType(src__string_matchers._S
tringStartsWith, [core.String])}), | |
| 1899 methods: () => ({ | |
| 1900 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1901 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1902 }) | |
| 1903 }); | |
| 1904 const _suffix = Symbol('_suffix'); | |
| 1905 src__string_matchers._StringEndsWith = class _StringEndsWith extends src__stri
ng_matchers._StringMatcher { | |
| 1906 new(suffix) { | |
| 1907 this[_suffix] = suffix; | |
| 1908 super.new(); | |
| 1909 } | |
| 1910 matches(item, matchState) { | |
| 1911 return typeof item == 'string' && dart.test(item[dartx.endsWith](this[_suf
fix])); | |
| 1912 } | |
| 1913 describe(description) { | |
| 1914 return description.add('a string ending with ').addDescriptionOf(this[_suf
fix]); | |
| 1915 } | |
| 1916 }; | |
| 1917 dart.setSignature(src__string_matchers._StringEndsWith, { | |
| 1918 constructors: () => ({new: dart.definiteFunctionType(src__string_matchers._S
tringEndsWith, [core.String])}), | |
| 1919 methods: () => ({ | |
| 1920 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1921 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1922 }) | |
| 1923 }); | |
| 1924 const _substrings = Symbol('_substrings'); | |
| 1925 src__string_matchers._StringContainsInOrder = class _StringContainsInOrder ext
ends src__string_matchers._StringMatcher { | |
| 1926 new(substrings) { | |
| 1927 this[_substrings] = substrings; | |
| 1928 super.new(); | |
| 1929 } | |
| 1930 matches(item, matchState) { | |
| 1931 if (!(typeof item == 'string')) { | |
| 1932 return false; | |
| 1933 } | |
| 1934 let from_index = 0; | |
| 1935 for (let s of this[_substrings]) { | |
| 1936 from_index = core.int._check(dart.dsend(item, 'indexOf', s, from_index))
; | |
| 1937 if (dart.notNull(from_index) < 0) return false; | |
| 1938 } | |
| 1939 return true; | |
| 1940 } | |
| 1941 describe(description) { | |
| 1942 return description.addAll('a string containing ', ', ', ' in order', this[
_substrings]); | |
| 1943 } | |
| 1944 }; | |
| 1945 dart.setSignature(src__string_matchers._StringContainsInOrder, { | |
| 1946 constructors: () => ({new: dart.definiteFunctionType(src__string_matchers._S
tringContainsInOrder, [core.List$(core.String)])}), | |
| 1947 methods: () => ({ | |
| 1948 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1949 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1950 }) | |
| 1951 }); | |
| 1952 const _regexp = Symbol('_regexp'); | |
| 1953 src__string_matchers._MatchesRegExp = class _MatchesRegExp extends src__string
_matchers._StringMatcher { | |
| 1954 new(re) { | |
| 1955 this[_regexp] = null; | |
| 1956 super.new(); | |
| 1957 if (typeof re == 'string') { | |
| 1958 this[_regexp] = core.RegExp.new(re); | |
| 1959 } else if (core.RegExp.is(re)) { | |
| 1960 this[_regexp] = re; | |
| 1961 } else { | |
| 1962 dart.throw(new core.ArgumentError('matches requires a regexp or string')
); | |
| 1963 } | |
| 1964 } | |
| 1965 matches(item, matchState) { | |
| 1966 return typeof item == 'string' ? this[_regexp].hasMatch(item) : false; | |
| 1967 } | |
| 1968 describe(description) { | |
| 1969 return description.add(dart.str`match '${this[_regexp].pattern}'`); | |
| 1970 } | |
| 1971 }; | |
| 1972 dart.setSignature(src__string_matchers._MatchesRegExp, { | |
| 1973 constructors: () => ({new: dart.definiteFunctionType(src__string_matchers._M
atchesRegExp, [dart.dynamic])}), | |
| 1974 methods: () => ({ | |
| 1975 matches: dart.definiteFunctionType(core.bool, [dart.dynamic, core.Map]), | |
| 1976 describe: dart.definiteFunctionType(src__interfaces.Description, [src__int
erfaces.Description]) | |
| 1977 }) | |
| 1978 }); | |
| 1979 src__string_matchers._isWhitespace = function(ch) { | |
| 1980 return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t'; | |
| 1981 }; | |
| 1982 dart.fn(src__string_matchers._isWhitespace, StringTobool()); | |
| 1983 src__util._Predicate = dart.typedef('_Predicate', () => dart.functionType(core
.bool, [dart.dynamic])); | |
| 1984 src__util._escapeMap = dart.const(dart.map({'\n': '\\n', '\r': '\\r', '\f': '\
\f', '\b': '\\b', '\t': '\\t', '\v': '\\v', '': '\\x7F'}, core.String, core.Str
ing)); | |
| 1985 dart.defineLazy(src__util, { | |
| 1986 get _escapeRegExp() { | |
| 1987 return core.RegExp.new(dart.str`[\\x00-\\x07\\x0E-\\x1F${src__util._escape
Map[dartx.keys][dartx.map](core.String)(src__util._getHexLiteral)[dartx.join]()}
]`); | |
| 1988 } | |
| 1989 }); | |
| 1990 src__util._getHexLiteral = function(input) { | |
| 1991 let rune = input[dartx.runes].single; | |
| 1992 return '\\x' + dart.notNull(rune[dartx.toRadixString](16)[dartx.toUpperCase]
()[dartx.padLeft](2, '0')); | |
| 1993 }; | |
| 1994 dart.fn(src__util._getHexLiteral, StringToString()); | |
| 1995 // Exports: | |
| 1996 exports.matcher = matcher; | |
| 1997 exports.mirror_matchers = mirror_matchers; | |
| 1998 exports.src__core_matchers = src__core_matchers; | |
| 1999 exports.src__description = src__description; | |
| 2000 exports.src__error_matchers = src__error_matchers; | |
| 2001 exports.src__interfaces = src__interfaces; | |
| 2002 exports.src__iterable_matchers = src__iterable_matchers; | |
| 2003 exports.src__map_matchers = src__map_matchers; | |
| 2004 exports.src__numeric_matchers = src__numeric_matchers; | |
| 2005 exports.src__operator_matchers = src__operator_matchers; | |
| 2006 exports.src__pretty_print = src__pretty_print; | |
| 2007 exports.src__string_matchers = src__string_matchers; | |
| 2008 exports.src__util = src__util; | |
| 2009 }); | |
| OLD | NEW |