OLD | NEW |
1 dart_library.library('unittest', null, /* Imports */[ | 1 dart_library.library('unittest', null, /* Imports */[ |
2 'dart_sdk', | 2 'dart_sdk', |
3 'matcher' | 3 'stack_trace' |
4 ], function(exports, dart_sdk, matcher) { | 4 ], function(exports, dart_sdk, stack_trace) { |
5 'use strict'; | 5 'use strict'; |
6 const core = dart_sdk.core; | 6 const core = dart_sdk.core; |
| 7 const collection = dart_sdk.collection; |
7 const async = dart_sdk.async; | 8 const async = dart_sdk.async; |
| 9 const isolate = dart_sdk.isolate; |
| 10 const io = dart_sdk.io; |
| 11 const html = dart_sdk.html; |
| 12 const convert = dart_sdk.convert; |
8 const js = dart_sdk.js; | 13 const js = dart_sdk.js; |
9 const dart = dart_sdk.dart; | 14 const dart = dart_sdk.dart; |
10 const dartx = dart_sdk.dartx; | 15 const dartx = dart_sdk.dartx; |
11 const src__util = matcher.src__util; | 16 const src__trace = stack_trace.src__trace; |
12 const src__interfaces = matcher.src__interfaces; | 17 const src__frame = stack_trace.src__frame; |
13 const src__description = matcher.src__description; | |
14 const src__numeric_matchers = matcher.src__numeric_matchers; | |
15 const src__error_matchers = matcher.src__error_matchers; | |
16 const src__core_matchers = matcher.src__core_matchers; | |
17 const src__iterable_matchers = matcher.src__iterable_matchers; | |
18 const src__string_matchers = matcher.src__string_matchers; | |
19 const src__operator_matchers = matcher.src__operator_matchers; | |
20 const src__map_matchers = matcher.src__map_matchers; | |
21 const unittest = Object.create(null); | 18 const unittest = Object.create(null); |
22 dart.defineLazy(unittest, { | 19 const vm_config = Object.create(null); |
23 get _wrapAsync() { | 20 const html_enhanced_config = Object.create(null); |
24 return dart.fn((f, id) => { | 21 const html_individual_config = Object.create(null); |
25 if (id === void 0) id = null; | 22 const src__simple_configuration = Object.create(null); |
26 return f; | 23 const src__group_context = Object.create(null); |
27 }, core.Function, [core.Function], [dart.dynamic]); | 24 const src__utils = Object.create(null); |
| 25 const src__test_case = Object.create(null); |
| 26 const src__configuration = Object.create(null); |
| 27 const src__matcher = Object.create(null); |
| 28 const src__test_environment = Object.create(null); |
| 29 const src__matcher__core_matchers = Object.create(null); |
| 30 const src__matcher__future_matchers = Object.create(null); |
| 31 const src__matcher__throws_matchers = Object.create(null); |
| 32 const src__matcher__string_matchers = Object.create(null); |
| 33 const src__matcher__util = Object.create(null); |
| 34 const src__matcher__interfaces = Object.create(null); |
| 35 const src__matcher__throws_matcher = Object.create(null); |
| 36 const src__matcher__pretty_print = Object.create(null); |
| 37 const src__matcher__numeric_matchers = Object.create(null); |
| 38 const src__matcher__description = Object.create(null); |
| 39 const src__matcher__error_matchers = Object.create(null); |
| 40 const src__matcher__operator_matchers = Object.create(null); |
| 41 const src__matcher__expect = Object.create(null); |
| 42 const src__matcher__map_matchers = Object.create(null); |
| 43 const src__matcher__prints_matcher = Object.create(null); |
| 44 const src__matcher__iterable_matchers = Object.create(null); |
| 45 const src__internal_test_case = Object.create(null); |
| 46 const src__expected_function = Object.create(null); |
| 47 const compact_vm_config = Object.create(null); |
| 48 const html_config = Object.create(null); |
| 49 unittest.TestFunction = dart.typedef('TestFunction', () => dart.functionType(d
art.dynamic, [])); |
| 50 dart.copyProperties(unittest, { |
| 51 get unittestConfiguration() { |
| 52 if (src__test_environment.config == null) src__test_environment.environmen
t.config = src__configuration.Configuration.new(); |
| 53 return src__test_environment.config; |
28 }, | 54 }, |
29 set _wrapAsync(_) {} | 55 set unittestConfiguration(value) { |
30 }); | 56 if (core.identical(src__test_environment.config, value)) return; |
| 57 if (src__test_environment.config != null) { |
| 58 unittest.logMessage('Warning: The unittestConfiguration has already been
set. New ' + 'unittestConfiguration ignored.'); |
| 59 } else { |
| 60 src__test_environment.environment.config = value; |
| 61 } |
| 62 } |
| 63 }); |
| 64 unittest.formatStacks = true; |
| 65 unittest.filterStacks = true; |
| 66 unittest.groupSep = ' '; |
| 67 unittest.logMessage = function(message) { |
| 68 return src__test_environment.config.onLogMessage(unittest.currentTestCase, m
essage); |
| 69 }; |
| 70 dart.fn(unittest.logMessage, dart.void, [core.String]); |
| 71 dart.copyProperties(unittest, { |
| 72 get testCases() { |
| 73 return new (collection.UnmodifiableListView$(src__test_case.TestCase))(src
__test_environment.environment.testCases); |
| 74 } |
| 75 }); |
| 76 unittest.BREATH_INTERVAL = 200; |
| 77 dart.copyProperties(unittest, { |
| 78 get currentTestCase() { |
| 79 return dart.notNull(src__test_environment.environment.currentTestCaseIndex
) >= 0 && dart.notNull(src__test_environment.environment.currentTestCaseIndex) <
dart.notNull(unittest.testCases[dartx.length]) ? unittest.testCases[dartx.get](
src__test_environment.environment.currentTestCaseIndex) : null; |
| 80 } |
| 81 }); |
| 82 dart.copyProperties(unittest, { |
| 83 get _currentTestCase() { |
| 84 return dart.as(unittest.currentTestCase, src__internal_test_case.InternalT
estCase); |
| 85 } |
| 86 }); |
| 87 unittest.PASS = 'pass'; |
| 88 unittest.FAIL = 'fail'; |
| 89 unittest.ERROR = 'error'; |
| 90 unittest.test = function(description, body) { |
| 91 unittest._requireNotRunning(); |
| 92 unittest.ensureInitialized(); |
| 93 if (dart.notNull(src__test_environment.environment.soloTestSeen) && src__tes
t_environment.environment.soloNestingLevel == 0) return; |
| 94 let testCase = new src__internal_test_case.InternalTestCase(dart.notNull(uni
ttest.testCases[dartx.length]) + 1, unittest._fullDescription(description), body
); |
| 95 src__test_environment.environment.testCases[dartx.add](testCase); |
| 96 }; |
| 97 dart.fn(unittest.test, dart.void, [core.String, unittest.TestFunction]); |
| 98 unittest._fullDescription = function(description) { |
| 99 let group = src__test_environment.environment.currentContext.fullName; |
| 100 if (description == null) return group; |
| 101 return group != '' ? `${group}${unittest.groupSep}${description}` : descript
ion; |
| 102 }; |
| 103 dart.fn(unittest._fullDescription, core.String, [core.String]); |
| 104 unittest.skip_test = function(spec, body) { |
| 105 }; |
| 106 dart.fn(unittest.skip_test, dart.void, [core.String, unittest.TestFunction]); |
| 107 unittest.solo_test = function(spec, body) { |
| 108 unittest._requireNotRunning(); |
| 109 unittest.ensureInitialized(); |
| 110 if (!dart.notNull(src__test_environment.environment.soloTestSeen)) { |
| 111 src__test_environment.environment.soloTestSeen = true; |
| 112 src__test_environment.environment.testCases[dartx.clear](); |
| 113 } |
| 114 let o = src__test_environment.environment; |
| 115 o.soloNestingLevel = dart.notNull(o.soloNestingLevel) + 1; |
| 116 try { |
| 117 unittest.test(spec, body); |
| 118 } finally { |
| 119 let o$ = src__test_environment.environment; |
| 120 o$.soloNestingLevel = dart.notNull(o$.soloNestingLevel) - 1; |
| 121 } |
| 122 }; |
| 123 dart.fn(unittest.solo_test, dart.void, [core.String, unittest.TestFunction]); |
| 124 unittest.expectAsync = function(callback, opts) { |
| 125 let count = opts && 'count' in opts ? opts.count : 1; |
| 126 let max = opts && 'max' in opts ? opts.max : 0; |
| 127 let id = opts && 'id' in opts ? opts.id : null; |
| 128 let reason = opts && 'reason' in opts ? opts.reason : null; |
| 129 return new src__expected_function.ExpectedFunction(callback, count, max, {id
: id, reason: reason}).func; |
| 130 }; |
| 131 dart.fn(unittest.expectAsync, core.Function, [core.Function], {count: core.int
, max: core.int, id: core.String, reason: core.String}); |
| 132 unittest.expectAsyncUntil = function(callback, isDone, opts) { |
| 133 let id = opts && 'id' in opts ? opts.id : null; |
| 134 let reason = opts && 'reason' in opts ? opts.reason : null; |
| 135 return new src__expected_function.ExpectedFunction(callback, 0, -1, {id: id,
reason: reason, isDone: isDone}).func; |
| 136 }; |
| 137 dart.fn(unittest.expectAsyncUntil, core.Function, [core.Function, dart.functio
nType(core.bool, [])], {id: core.String, reason: core.String}); |
| 138 unittest.group = function(description, body) { |
| 139 unittest.ensureInitialized(); |
| 140 unittest._requireNotRunning(); |
| 141 src__test_environment.environment.currentContext = new src__group_context.Gr
oupContext(src__test_environment.environment.currentContext, description); |
| 142 try { |
| 143 body(); |
| 144 } catch (e) { |
| 145 let trace = dart.stackTrace(e); |
| 146 let stack = trace == null ? '' : `: ${trace.toString()}`; |
| 147 src__test_environment.environment.uncaughtErrorMessage = `${dart.toString(
e)}${stack}`; |
| 148 } |
| 149 finally { |
| 150 src__test_environment.environment.currentContext = src__test_environment.e
nvironment.currentContext.parent; |
| 151 } |
| 152 }; |
| 153 dart.fn(unittest.group, dart.void, [core.String, dart.functionType(dart.void,
[])]); |
| 154 unittest.skip_group = function(description, body) { |
| 155 }; |
| 156 dart.fn(unittest.skip_group, dart.void, [core.String, dart.functionType(dart.v
oid, [])]); |
| 157 unittest.solo_group = function(description, body) { |
| 158 unittest._requireNotRunning(); |
| 159 unittest.ensureInitialized(); |
| 160 if (!dart.notNull(src__test_environment.environment.soloTestSeen)) { |
| 161 src__test_environment.environment.soloTestSeen = true; |
| 162 src__test_environment.environment.testCases[dartx.clear](); |
| 163 } |
| 164 let o = src__test_environment.environment; |
| 165 o.soloNestingLevel = dart.notNull(o.soloNestingLevel) + 1; |
| 166 try { |
| 167 unittest.group(description, body); |
| 168 } finally { |
| 169 let o$ = src__test_environment.environment; |
| 170 o$.soloNestingLevel = dart.notNull(o$.soloNestingLevel) - 1; |
| 171 } |
| 172 }; |
| 173 dart.fn(unittest.solo_group, dart.void, [core.String, dart.functionType(dart.v
oid, [])]); |
| 174 unittest.setUp = function(callback) { |
| 175 unittest._requireNotRunning(); |
| 176 src__test_environment.environment.currentContext.testSetUp = callback; |
| 177 }; |
| 178 dart.fn(unittest.setUp, dart.void, [core.Function]); |
| 179 unittest.tearDown = function(callback) { |
| 180 unittest._requireNotRunning(); |
| 181 src__test_environment.environment.currentContext.testTearDown = callback; |
| 182 }; |
| 183 dart.fn(unittest.tearDown, dart.void, [core.Function]); |
| 184 unittest._nextTestCase = function() { |
| 185 let o = src__test_environment.environment; |
| 186 o.currentTestCaseIndex = dart.notNull(o.currentTestCaseIndex) + 1; |
| 187 unittest._runTest(); |
| 188 }; |
| 189 dart.fn(unittest._nextTestCase, dart.void, []); |
| 190 unittest.handleExternalError = function(e, message, stackTrace) { |
| 191 if (stackTrace === void 0) stackTrace = null; |
| 192 let msg = `${message}\nCaught ${e}`; |
| 193 if (unittest.currentTestCase != null) { |
| 194 unittest._currentTestCase.error(msg, dart.as(stackTrace, core.StackTrace))
; |
| 195 } else { |
| 196 src__test_environment.environment.uncaughtErrorMessage = `${msg}: ${stackT
race}`; |
| 197 } |
| 198 }; |
| 199 dart.fn(unittest.handleExternalError, dart.void, [dart.dynamic, core.String],
[dart.dynamic]); |
| 200 unittest._TestFilter = dart.typedef('_TestFilter', () => dart.functionType(cor
e.bool, [src__internal_test_case.InternalTestCase])); |
| 201 unittest.filterTests = function(testFilter) { |
| 202 let filterFunction = null; |
| 203 if (typeof testFilter == 'string') { |
| 204 let re = core.RegExp.new(testFilter); |
| 205 filterFunction = dart.fn(t => re.hasMatch(t.description), core.bool, [src_
_internal_test_case.InternalTestCase]); |
| 206 } else if (dart.is(testFilter, core.RegExp)) { |
| 207 filterFunction = dart.fn(t => testFilter.hasMatch(t.description), core.boo
l, [src__internal_test_case.InternalTestCase]); |
| 208 } else if (dart.is(testFilter, unittest._TestFilter)) { |
| 209 filterFunction = testFilter; |
| 210 } |
| 211 src__test_environment.environment.testCases[dartx.retainWhere](filterFunctio
n); |
| 212 }; |
| 213 dart.fn(unittest.filterTests, dart.void, [dart.dynamic]); |
| 214 unittest.runTests = function() { |
| 215 unittest._requireNotRunning(); |
| 216 unittest._ensureInitialized(false); |
| 217 src__test_environment.environment.currentTestCaseIndex = 0; |
| 218 src__test_environment.config.onStart(); |
| 219 unittest._runTest(); |
| 220 }; |
| 221 dart.fn(unittest.runTests, dart.void, []); |
| 222 unittest.registerException = function(error, stackTrace) { |
| 223 if (stackTrace === void 0) stackTrace = null; |
| 224 return unittest._currentTestCase.registerException(error, stackTrace); |
| 225 }; |
| 226 dart.fn(unittest.registerException, dart.void, [dart.dynamic], [core.StackTrac
e]); |
| 227 unittest._runTest = function() { |
| 228 if (dart.notNull(src__test_environment.environment.currentTestCaseIndex) >=
dart.notNull(unittest.testCases[dartx.length])) { |
| 229 dart.assert(src__test_environment.environment.currentTestCaseIndex == unit
test.testCases[dartx.length]); |
| 230 unittest._completeTests(); |
| 231 return; |
| 232 } |
| 233 let testCase = unittest._currentTestCase; |
| 234 let f = async.runZoned(async.Future)(dart.bind(testCase, 'run'), {onError: d
art.fn((error, stack) => { |
| 235 testCase.registerException(error, dart.as(stack, core.StackTrace)); |
| 236 })}); |
| 237 let timer = null; |
| 238 let timeout = unittest.unittestConfiguration.timeout; |
| 239 if (timeout != null) { |
| 240 try { |
| 241 timer = async.Timer.new(timeout, dart.fn(() => { |
| 242 testCase.error(`Test timed out after ${timeout.inSeconds} seconds.`); |
| 243 unittest._nextTestCase(); |
| 244 }, dart.void, [])); |
| 245 } catch (e) { |
| 246 if (dart.is(e, core.UnsupportedError)) { |
| 247 if (e.message != "Timer greater than 0.") throw e; |
| 248 } else |
| 249 throw e; |
| 250 } |
| 251 |
| 252 } |
| 253 f.whenComplete(dart.fn(() => { |
| 254 if (timer != null) dart.dsend(timer, 'cancel'); |
| 255 let now = new core.DateTime.now().millisecondsSinceEpoch; |
| 256 if (dart.notNull(now) - dart.notNull(src__test_environment.environment.las
tBreath) >= dart.notNull(unittest.BREATH_INTERVAL)) { |
| 257 src__test_environment.environment.lastBreath = now; |
| 258 async.Timer.run(unittest._nextTestCase); |
| 259 } else { |
| 260 async.scheduleMicrotask(unittest._nextTestCase); |
| 261 } |
| 262 })); |
| 263 }; |
| 264 dart.fn(unittest._runTest, dart.void, []); |
| 265 unittest._completeTests = function() { |
| 266 if (!dart.notNull(src__test_environment.environment.initialized)) return; |
| 267 let passed = 0; |
| 268 let failed = 0; |
| 269 let errors = 0; |
| 270 for (let testCase of unittest.testCases) { |
| 271 switch (testCase.result) { |
| 272 case unittest.PASS: |
| 273 { |
| 274 passed++; |
| 275 break; |
| 276 } |
| 277 case unittest.FAIL: |
| 278 { |
| 279 failed++; |
| 280 break; |
| 281 } |
| 282 case unittest.ERROR: |
| 283 { |
| 284 errors++; |
| 285 break; |
| 286 } |
| 287 } |
| 288 } |
| 289 src__test_environment.config.onSummary(passed, failed, errors, unittest.test
Cases, src__test_environment.environment.uncaughtErrorMessage); |
| 290 src__test_environment.config.onDone(passed > 0 && failed == 0 && errors == 0
&& src__test_environment.environment.uncaughtErrorMessage == null); |
| 291 src__test_environment.environment.initialized = false; |
| 292 src__test_environment.environment.currentTestCaseIndex = -1; |
| 293 }; |
| 294 dart.fn(unittest._completeTests, dart.void, []); |
| 295 unittest.ensureInitialized = function() { |
| 296 unittest._ensureInitialized(true); |
| 297 }; |
| 298 dart.fn(unittest.ensureInitialized, dart.void, []); |
| 299 unittest._ensureInitialized = function(configAutoStart) { |
| 300 if (dart.notNull(src__test_environment.environment.initialized)) return; |
| 301 src__test_environment.environment.initialized = true; |
| 302 src__matcher__expect.wrapAsync = dart.fn((f, id) => { |
| 303 if (id === void 0) id = null; |
| 304 return unittest.expectAsync(dart.as(f, core.Function), {id: dart.as(id, co
re.String)}); |
| 305 }, core.Function, [dart.dynamic], [dart.dynamic]); |
| 306 src__test_environment.environment.uncaughtErrorMessage = null; |
| 307 unittest.unittestConfiguration.onInit(); |
| 308 if (dart.notNull(configAutoStart) && dart.notNull(src__test_environment.conf
ig.autoStart)) async.scheduleMicrotask(unittest.runTests); |
| 309 }; |
| 310 dart.fn(unittest._ensureInitialized, dart.void, [core.bool]); |
| 311 unittest.setSoloTest = function(id) { |
| 312 return src__test_environment.environment.testCases[dartx.retainWhere](dart.f
n(t => t.id == id, core.bool, [src__internal_test_case.InternalTestCase])); |
| 313 }; |
| 314 dart.fn(unittest.setSoloTest, dart.void, [core.int]); |
| 315 unittest.enableTest = function(id) { |
| 316 return unittest._setTestEnabledState(id, {enable: true}); |
| 317 }; |
| 318 dart.fn(unittest.enableTest, dart.void, [core.int]); |
| 319 unittest.disableTest = function(id) { |
| 320 return unittest._setTestEnabledState(id, {enable: false}); |
| 321 }; |
| 322 dart.fn(unittest.disableTest, dart.void, [core.int]); |
| 323 unittest._setTestEnabledState = function(id, opts) { |
| 324 let enable = opts && 'enable' in opts ? opts.enable : true; |
| 325 if (dart.notNull(unittest.testCases[dartx.length]) > dart.notNull(id) && uni
ttest.testCases[dartx.get](id).id == id) { |
| 326 src__test_environment.environment.testCases[dartx.get](id).enabled = enabl
e; |
| 327 } else { |
| 328 for (let i = 0; i < dart.notNull(unittest.testCases[dartx.length]); i++) { |
| 329 if (unittest.testCases[dartx.get](i).id != id) continue; |
| 330 src__test_environment.environment.testCases[dartx.get](i).enabled = enab
le; |
| 331 break; |
| 332 } |
| 333 } |
| 334 }; |
| 335 dart.fn(unittest._setTestEnabledState, dart.void, [core.int], {enable: core.bo
ol}); |
| 336 unittest._requireNotRunning = function() { |
| 337 if (src__test_environment.environment.currentTestCaseIndex == -1) return; |
| 338 dart.throw(new core.StateError('Not allowed when tests are running.')); |
| 339 }; |
| 340 dart.fn(unittest._requireNotRunning, dart.void, []); |
| 341 unittest.withTestEnvironment = function(callback) { |
| 342 return async.runZoned(dart.dynamic)(callback, {zoneValues: dart.map([dart.co
nst(core.Symbol.new('unittest.environment')), new src__test_environment.TestEnvi
ronment()])}); |
| 343 }; |
| 344 dart.fn(unittest.withTestEnvironment, dart.dynamic, [dart.functionType(dart.dy
namic, [])]); |
| 345 src__configuration.Configuration = class Configuration extends core.Object { |
| 346 static new() { |
| 347 return new src__simple_configuration.SimpleConfiguration(); |
| 348 } |
| 349 blank() { |
| 350 this.autoStart = true; |
| 351 this.timeout = dart.const(new core.Duration({minutes: 2})); |
| 352 } |
| 353 onInit() {} |
| 354 onStart() {} |
| 355 onTestStart(testCase) {} |
| 356 onTestResult(testCase) {} |
| 357 onTestResultChanged(testCase) {} |
| 358 onLogMessage(testCase, message) {} |
| 359 onDone(success) {} |
| 360 onSummary(passed, failed, errors, results, uncaughtError) {} |
| 361 }; |
| 362 dart.defineNamedConstructor(src__configuration.Configuration, 'blank'); |
| 363 dart.setSignature(src__configuration.Configuration, { |
| 364 constructors: () => ({ |
| 365 new: [src__configuration.Configuration, []], |
| 366 blank: [src__configuration.Configuration, []] |
| 367 }), |
| 368 methods: () => ({ |
| 369 onInit: [dart.void, []], |
| 370 onStart: [dart.void, []], |
| 371 onTestStart: [dart.void, [src__test_case.TestCase]], |
| 372 onTestResult: [dart.void, [src__test_case.TestCase]], |
| 373 onTestResultChanged: [dart.void, [src__test_case.TestCase]], |
| 374 onLogMessage: [dart.void, [src__test_case.TestCase, core.String]], |
| 375 onDone: [dart.void, [core.bool]], |
| 376 onSummary: [dart.void, [core.int, core.int, core.int, core.List$(src__test
_case.TestCase), core.String]] |
| 377 }) |
| 378 }); |
| 379 unittest.Configuration = src__configuration.Configuration; |
| 380 src__matcher__expect.configureExpectFormatter = function(formatter) { |
| 381 if (formatter === void 0) formatter = null; |
| 382 if (formatter == null) { |
| 383 formatter = src__matcher__expect._defaultErrorFormatter; |
| 384 } |
| 385 return src__matcher__expect._assertErrorFormatter = formatter; |
| 386 }; |
| 387 dart.lazyFn(src__matcher__expect.configureExpectFormatter, () => [src__matcher
__expect.ErrorFormatter, [], [src__matcher__expect.ErrorFormatter]]); |
| 388 unittest.configureExpectFormatter = src__matcher__expect.configureExpectFormat
ter; |
| 389 const _name = Symbol('_name'); |
| 390 src__matcher__interfaces.Matcher = class Matcher extends core.Object { |
| 391 Matcher() { |
| 392 } |
| 393 describeMismatch(item, mismatchDescription, matchState, verbose) { |
| 394 return mismatchDescription; |
| 395 } |
| 396 }; |
| 397 dart.setSignature(src__matcher__interfaces.Matcher, { |
| 398 constructors: () => ({Matcher: [src__matcher__interfaces.Matcher, []]}), |
| 399 methods: () => ({describeMismatch: [src__matcher__interfaces.Description, [d
art.dynamic, src__matcher__interfaces.Description, core.Map, core.bool]]}) |
| 400 }); |
| 401 src__matcher__core_matchers.TypeMatcher = class TypeMatcher extends src__match
er__interfaces.Matcher { |
| 402 TypeMatcher(name) { |
| 403 this[_name] = name; |
| 404 super.Matcher(); |
| 405 } |
| 406 describe(description) { |
| 407 return description.add(this[_name]); |
| 408 } |
| 409 }; |
| 410 dart.setSignature(src__matcher__core_matchers.TypeMatcher, { |
| 411 constructors: () => ({TypeMatcher: [src__matcher__core_matchers.TypeMatcher,
[core.String]]}), |
| 412 methods: () => ({describe: [src__matcher__interfaces.Description, [src__matc
her__interfaces.Description]]}) |
| 413 }); |
| 414 src__matcher__error_matchers._RangeError = class _RangeError extends src__matc
her__core_matchers.TypeMatcher { |
| 415 _RangeError() { |
| 416 super.TypeMatcher("RangeError"); |
| 417 } |
| 418 matches(item, matchState) { |
| 419 return dart.is(item, core.RangeError); |
| 420 } |
| 421 }; |
| 422 dart.setSignature(src__matcher__error_matchers._RangeError, { |
| 423 constructors: () => ({_RangeError: [src__matcher__error_matchers._RangeError
, []]}), |
| 424 methods: () => ({matches: [core.bool, [dart.dynamic, core.Map]]}) |
| 425 }); |
| 426 src__matcher__error_matchers.isRangeError = dart.const(new src__matcher__error
_matchers._RangeError()); |
| 427 unittest.isRangeError = src__matcher__error_matchers.isRangeError; |
| 428 src__matcher__error_matchers._StateError = class _StateError extends src__matc
her__core_matchers.TypeMatcher { |
| 429 _StateError() { |
| 430 super.TypeMatcher("StateError"); |
| 431 } |
| 432 matches(item, matchState) { |
| 433 return dart.is(item, core.StateError); |
| 434 } |
| 435 }; |
| 436 dart.setSignature(src__matcher__error_matchers._StateError, { |
| 437 constructors: () => ({_StateError: [src__matcher__error_matchers._StateError
, []]}), |
| 438 methods: () => ({matches: [core.bool, [dart.dynamic, core.Map]]}) |
| 439 }); |
| 440 src__matcher__error_matchers.isStateError = dart.const(new src__matcher__error
_matchers._StateError()); |
| 441 unittest.isStateError = src__matcher__error_matchers.isStateError; |
| 442 src__matcher__core_matchers.equals = function(expected, limit) { |
| 443 if (limit === void 0) limit = 100; |
| 444 return typeof expected == 'string' ? new src__matcher__core_matchers._String
EqualsMatcher(expected) : new src__matcher__core_matchers._DeepMatcher(expected,
limit); |
| 445 }; |
| 446 dart.fn(src__matcher__core_matchers.equals, src__matcher__interfaces.Matcher,
[dart.dynamic], [core.int]); |
| 447 unittest.equals = src__matcher__core_matchers.equals; |
| 448 const _featureDescription = Symbol('_featureDescription'); |
| 449 const _featureName = Symbol('_featureName'); |
31 const _matcher = Symbol('_matcher'); | 450 const _matcher = Symbol('_matcher'); |
32 unittest.Throws = class Throws extends src__interfaces.Matcher { | 451 src__matcher__core_matchers.CustomMatcher = class CustomMatcher extends src__m
atcher__interfaces.Matcher { |
| 452 CustomMatcher(featureDescription, featureName, matcher) { |
| 453 this[_featureDescription] = featureDescription; |
| 454 this[_featureName] = featureName; |
| 455 this[_matcher] = src__matcher__util.wrapMatcher(matcher); |
| 456 super.Matcher(); |
| 457 } |
| 458 featureValueOf(actual) { |
| 459 return actual; |
| 460 } |
| 461 matches(item, matchState) { |
| 462 let f = this.featureValueOf(item); |
| 463 if (dart.notNull(this[_matcher].matches(f, matchState))) return true; |
| 464 src__matcher__util.addStateInfo(matchState, dart.map({feature: f})); |
| 465 return false; |
| 466 } |
| 467 describe(description) { |
| 468 return description.add(this[_featureDescription]).add(' ').addDescriptionO
f(this[_matcher]); |
| 469 } |
| 470 describeMismatch(item, mismatchDescription, matchState, verbose) { |
| 471 mismatchDescription.add('has ').add(this[_featureName]).add(' with value '
).addDescriptionOf(matchState[dartx.get]('feature')); |
| 472 let innerDescription = new src__matcher__description.StringDescription(); |
| 473 this[_matcher].describeMismatch(matchState[dartx.get]('feature'), innerDes
cription, dart.as(matchState[dartx.get]('state'), core.Map), verbose); |
| 474 if (dart.notNull(innerDescription.length) > 0) { |
| 475 mismatchDescription.add(' which ').add(innerDescription.toString()); |
| 476 } |
| 477 return mismatchDescription; |
| 478 } |
| 479 }; |
| 480 dart.setSignature(src__matcher__core_matchers.CustomMatcher, { |
| 481 constructors: () => ({CustomMatcher: [src__matcher__core_matchers.CustomMatc
her, [core.String, core.String, dart.dynamic]]}), |
| 482 methods: () => ({ |
| 483 featureValueOf: [dart.dynamic, [dart.dynamic]], |
| 484 matches: [core.bool, [dart.dynamic, core.Map]], |
| 485 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 486 }) |
| 487 }); |
| 488 unittest.CustomMatcher = src__matcher__core_matchers.CustomMatcher; |
| 489 src__matcher__iterable_matchers.pairwiseCompare = function(expected, comparato
r, description) { |
| 490 return new src__matcher__iterable_matchers._PairwiseCompare(expected, compar
ator, description); |
| 491 }; |
| 492 dart.fn(src__matcher__iterable_matchers.pairwiseCompare, src__matcher__interfa
ces.Matcher, [core.Iterable, dart.functionType(core.bool, [dart.dynamic, dart.dy
namic]), core.String]); |
| 493 unittest.pairwiseCompare = src__matcher__iterable_matchers.pairwiseCompare; |
| 494 src__matcher__error_matchers._UnimplementedError = class _UnimplementedError e
xtends src__matcher__core_matchers.TypeMatcher { |
| 495 _UnimplementedError() { |
| 496 super.TypeMatcher("UnimplementedError"); |
| 497 } |
| 498 matches(item, matchState) { |
| 499 return dart.is(item, core.UnimplementedError); |
| 500 } |
| 501 }; |
| 502 dart.setSignature(src__matcher__error_matchers._UnimplementedError, { |
| 503 constructors: () => ({_UnimplementedError: [src__matcher__error_matchers._Un
implementedError, []]}), |
| 504 methods: () => ({matches: [core.bool, [dart.dynamic, core.Map]]}) |
| 505 }); |
| 506 src__matcher__error_matchers.isUnimplementedError = dart.const(new src__matche
r__error_matchers._UnimplementedError()); |
| 507 unittest.isUnimplementedError = src__matcher__error_matchers.isUnimplementedEr
ror; |
| 508 src__matcher__core_matchers.hasLength = function(matcher) { |
| 509 return new src__matcher__core_matchers._HasLength(src__matcher__util.wrapMat
cher(matcher)); |
| 510 }; |
| 511 dart.fn(src__matcher__core_matchers.hasLength, src__matcher__interfaces.Matche
r, [dart.dynamic]); |
| 512 unittest.hasLength = src__matcher__core_matchers.hasLength; |
| 513 src__matcher__expect.expect = function(actual, matcher, opts) { |
| 514 let reason = opts && 'reason' in opts ? opts.reason : null; |
| 515 let failureHandler = opts && 'failureHandler' in opts ? opts.failureHandler
: null; |
| 516 let verbose = opts && 'verbose' in opts ? opts.verbose : false; |
| 517 matcher = src__matcher__util.wrapMatcher(matcher); |
| 518 let doesMatch = null; |
| 519 let matchState = dart.map(); |
| 520 try { |
| 521 doesMatch = dart.as(dart.dsend(matcher, 'matches', actual, matchState), co
re.bool); |
| 522 } catch (e) { |
| 523 let trace = dart.stackTrace(e); |
| 524 doesMatch = false; |
| 525 if (reason == null) { |
| 526 reason = `${typeof e == 'string' ? e : dart.toString(e)} at ${trace}`; |
| 527 } |
| 528 } |
| 529 |
| 530 if (!dart.notNull(doesMatch)) { |
| 531 if (failureHandler == null) { |
| 532 failureHandler = src__matcher__expect.getOrCreateExpectFailureHandler(); |
| 533 } |
| 534 failureHandler.failMatch(actual, dart.as(matcher, src__matcher__interfaces
.Matcher), reason, matchState, verbose); |
| 535 } |
| 536 }; |
| 537 dart.lazyFn(src__matcher__expect.expect, () => [dart.void, [dart.dynamic, dart
.dynamic], {reason: core.String, failureHandler: src__matcher__expect.FailureHan
dler, verbose: core.bool}]); |
| 538 unittest.expect = src__matcher__expect.expect; |
| 539 const _out = Symbol('_out'); |
| 540 src__matcher__description.StringDescription = class StringDescription extends
core.Object { |
| 541 StringDescription(init) { |
| 542 if (init === void 0) init = ''; |
| 543 this[_out] = new core.StringBuffer(); |
| 544 this[_out].write(init); |
| 545 } |
| 546 get length() { |
| 547 return this[_out].length; |
| 548 } |
| 549 toString() { |
| 550 return dart.toString(this[_out]); |
| 551 } |
| 552 add(text) { |
| 553 this[_out].write(text); |
| 554 return this; |
| 555 } |
| 556 replace(text) { |
| 557 this[_out].clear(); |
| 558 return this.add(text); |
| 559 } |
| 560 addDescriptionOf(value) { |
| 561 if (dart.is(value, src__matcher__interfaces.Matcher)) { |
| 562 value.describe(this); |
| 563 } else { |
| 564 this.add(src__matcher__pretty_print.prettyPrint(value, {maxLineLength: 8
0, maxItems: 25})); |
| 565 } |
| 566 return this; |
| 567 } |
| 568 addAll(start, separator, end, list) { |
| 569 let separate = false; |
| 570 this.add(start); |
| 571 for (let item of list) { |
| 572 if (separate) { |
| 573 this.add(separator); |
| 574 } |
| 575 this.addDescriptionOf(item); |
| 576 separate = true; |
| 577 } |
| 578 this.add(end); |
| 579 return this; |
| 580 } |
| 581 }; |
| 582 src__matcher__description.StringDescription[dart.implements] = () => [src__mat
cher__interfaces.Description]; |
| 583 dart.setSignature(src__matcher__description.StringDescription, { |
| 584 constructors: () => ({StringDescription: [src__matcher__description.StringDe
scription, [], [core.String]]}), |
| 585 methods: () => ({ |
| 586 add: [src__matcher__interfaces.Description, [core.String]], |
| 587 replace: [src__matcher__interfaces.Description, [core.String]], |
| 588 addDescriptionOf: [src__matcher__interfaces.Description, [dart.dynamic]], |
| 589 addAll: [src__matcher__interfaces.Description, [core.String, core.String,
core.String, core.Iterable]] |
| 590 }) |
| 591 }); |
| 592 unittest.StringDescription = src__matcher__description.StringDescription; |
| 593 src__matcher__expect.fail = function(message, opts) { |
| 594 let failureHandler = opts && 'failureHandler' in opts ? opts.failureHandler
: null; |
| 595 if (failureHandler == null) { |
| 596 failureHandler = src__matcher__expect.getOrCreateExpectFailureHandler(); |
| 597 } |
| 598 failureHandler.fail(message); |
| 599 }; |
| 600 dart.lazyFn(src__matcher__expect.fail, () => [dart.void, [core.String], {failu
reHandler: src__matcher__expect.FailureHandler}]); |
| 601 unittest.fail = src__matcher__expect.fail; |
| 602 src__matcher__core_matchers._IsNaN = class _IsNaN extends src__matcher__interf
aces.Matcher { |
| 603 _IsNaN() { |
| 604 super.Matcher(); |
| 605 } |
| 606 matches(item, matchState) { |
| 607 return core.double.NAN[dartx.compareTo](dart.as(item, core.num)) == 0; |
| 608 } |
| 609 describe(description) { |
| 610 return description.add('NaN'); |
| 611 } |
| 612 }; |
| 613 dart.setSignature(src__matcher__core_matchers._IsNaN, { |
| 614 constructors: () => ({_IsNaN: [src__matcher__core_matchers._IsNaN, []]}), |
| 615 methods: () => ({ |
| 616 matches: [core.bool, [dart.dynamic, core.Map]], |
| 617 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 618 }) |
| 619 }); |
| 620 src__matcher__core_matchers.isNaN = dart.const(new src__matcher__core_matchers
._IsNaN()); |
| 621 unittest.isNaN = src__matcher__core_matchers.isNaN; |
| 622 src__matcher__core_matchers.isInstanceOf$ = dart.generic(T => { |
| 623 class isInstanceOf extends src__matcher__interfaces.Matcher { |
| 624 isInstanceOf(name) { |
| 625 if (name === void 0) name = null; |
| 626 super.Matcher(); |
| 627 } |
| 628 matches(obj, matchState) { |
| 629 return dart.is(obj, T); |
| 630 } |
| 631 describe(description) { |
| 632 return description.add(`an instance of ${dart.wrapType(T)}`); |
| 633 } |
| 634 } |
| 635 dart.setSignature(isInstanceOf, { |
| 636 constructors: () => ({isInstanceOf: [src__matcher__core_matchers.isInstanc
eOf$(T), [], [[core.String, core.deprecated]]]}), |
| 637 methods: () => ({ |
| 638 matches: [core.bool, [dart.dynamic, core.Map]], |
| 639 describe: [src__matcher__interfaces.Description, [src__matcher__interfac
es.Description]] |
| 640 }) |
| 641 }); |
| 642 return isInstanceOf; |
| 643 }); |
| 644 src__matcher__core_matchers.isInstanceOf = src__matcher__core_matchers.isInsta
nceOf$(); |
| 645 unittest.isInstanceOf$ = src__matcher__core_matchers.isInstanceOf$; |
| 646 unittest.isInstanceOf = src__matcher__core_matchers.isInstanceOf; |
| 647 const _matcher$ = Symbol('_matcher'); |
| 648 src__matcher__throws_matcher.Throws = class Throws extends src__matcher__inter
faces.Matcher { |
33 Throws(matcher) { | 649 Throws(matcher) { |
34 if (matcher === void 0) matcher = null; | 650 if (matcher === void 0) matcher = null; |
35 this[_matcher] = matcher; | 651 this[_matcher$] = matcher; |
36 super.Matcher(); | 652 super.Matcher(); |
37 } | 653 } |
38 matches(item, matchState) { | 654 matches(item, matchState) { |
39 if (!dart.is(item, core.Function) && !dart.is(item, async.Future)) return
false; | 655 if (!dart.is(item, core.Function) && !dart.is(item, async.Future)) return
false; |
40 if (dart.is(item, async.Future)) { | 656 if (dart.is(item, async.Future)) { |
41 let done = dart.dcall(unittest._wrapAsync, dart.fn(fn => dart.dcall(fn))
); | 657 let done = dart.dcall(src__matcher__expect.wrapAsync, dart.fn(fn => dart
.dcall(fn))); |
42 item.then(dart.dynamic)(dart.fn(value => { | 658 item.then(dart.dynamic)(dart.fn(value => { |
43 dart.dcall(done, dart.fn(() => { | 659 dart.dcall(done, dart.fn(() => { |
44 unittest.fail(`Expected future to fail, but succeeded with '${value}
'.`); | 660 src__matcher__expect.fail(`Expected future to fail, but succeeded wi
th '${value}'.`); |
45 })); | 661 })); |
46 }), {onError: dart.fn((error, trace) => { | 662 }), {onError: dart.fn((error, trace) => { |
47 dart.dcall(done, dart.fn(() => { | 663 dart.dcall(done, dart.fn(() => { |
48 if (this[_matcher] == null) return; | 664 if (this[_matcher$] == null) return; |
49 let reason = null; | 665 let reason = null; |
50 if (trace != null) { | 666 if (trace != null) { |
51 let stackTrace = dart.toString(trace); | 667 let stackTrace = dart.toString(trace); |
52 stackTrace = ` ${stackTrace[dartx.replaceAll]("\n", "\n ")}`; | 668 stackTrace = ` ${stackTrace[dartx.replaceAll]("\n", "\n ")}`; |
53 reason = `Actual exception trace:\n${stackTrace}`; | 669 reason = `Actual exception trace:\n${stackTrace}`; |
54 } | 670 } |
55 unittest.expect(error, this[_matcher], {reason: dart.as(reason, co
re.String)}); | 671 src__matcher__expect.expect(error, this[_matcher$], {reason: dart.
as(reason, core.String)}); |
56 })); | 672 })); |
57 })}); | 673 })}); |
58 return true; | 674 return true; |
59 } | 675 } |
60 try { | 676 try { |
61 dart.dcall(item); | 677 dart.dcall(item); |
62 return false; | 678 return false; |
63 } catch (e) { | 679 } catch (e) { |
64 let s = dart.stackTrace(e); | 680 let s = dart.stackTrace(e); |
65 if (this[_matcher] == null || dart.notNull(this[_matcher].matches(e, mat
chState))) { | 681 if (this[_matcher$] == null || dart.notNull(this[_matcher$].matches(e, m
atchState))) { |
66 return true; | 682 return true; |
67 } else { | 683 } else { |
68 src__util.addStateInfo(matchState, dart.map({exception: e, stack: s}))
; | 684 src__matcher__util.addStateInfo(matchState, dart.map({exception: e, st
ack: s})); |
69 return false; | 685 return false; |
70 } | 686 } |
71 } | 687 } |
72 | 688 |
73 } | 689 } |
74 describe(description) { | 690 describe(description) { |
75 if (this[_matcher] == null) { | 691 if (this[_matcher$] == null) { |
76 return description.add("throws"); | 692 return description.add("throws"); |
77 } else { | 693 } else { |
78 return description.add('throws ').addDescriptionOf(this[_matcher]); | 694 return description.add('throws ').addDescriptionOf(this[_matcher$]); |
79 } | 695 } |
80 } | 696 } |
81 describeMismatch(item, mismatchDescription, matchState, verbose) { | 697 describeMismatch(item, mismatchDescription, matchState, verbose) { |
82 if (!dart.is(item, core.Function) && !dart.is(item, async.Future)) { | 698 if (!dart.is(item, core.Function) && !dart.is(item, async.Future)) { |
83 return mismatchDescription.add('is not a Function or Future'); | 699 return mismatchDescription.add('is not a Function or Future'); |
84 } else if (this[_matcher] == null || matchState[dartx.get]('exception') ==
null) { | 700 } else if (this[_matcher$] == null || matchState[dartx.get]('exception') =
= null) { |
85 return mismatchDescription.add('did not throw'); | 701 return mismatchDescription.add('did not throw'); |
86 } else { | 702 } else { |
87 mismatchDescription.add('threw ').addDescriptionOf(matchState[dartx.get]
('exception')); | 703 mismatchDescription.add('threw ').addDescriptionOf(matchState[dartx.get]
('exception')); |
88 if (dart.notNull(verbose)) { | 704 if (dart.notNull(verbose)) { |
89 mismatchDescription.add(' at ').add(dart.toString(matchState[dartx.get
]('stack'))); | 705 mismatchDescription.add(' at ').add(dart.toString(matchState[dartx.get
]('stack'))); |
90 } | 706 } |
91 return mismatchDescription; | 707 return mismatchDescription; |
92 } | 708 } |
93 } | 709 } |
94 }; | 710 }; |
95 dart.setSignature(unittest.Throws, { | 711 dart.setSignature(src__matcher__throws_matcher.Throws, { |
96 constructors: () => ({Throws: [unittest.Throws, [], [src__interfaces.Matcher
]]}), | 712 constructors: () => ({Throws: [src__matcher__throws_matcher.Throws, [], [src
__matcher__interfaces.Matcher]]}), |
97 methods: () => ({ | 713 methods: () => ({ |
98 matches: [core.bool, [dart.dynamic, core.Map]], | 714 matches: [core.bool, [dart.dynamic, core.Map]], |
99 describe: [src__interfaces.Description, [src__interfaces.Description]] | 715 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
100 }) | 716 }) |
101 }); | 717 }); |
102 unittest.throws = dart.const(new unittest.Throws()); | 718 src__matcher__error_matchers._CyclicInitializationError = class _CyclicInitial
izationError extends src__matcher__core_matchers.TypeMatcher { |
103 unittest.throwsA = function(matcher) { | 719 _CyclicInitializationError() { |
104 return new unittest.Throws(src__util.wrapMatcher(matcher)); | 720 super.TypeMatcher("CyclicInitializationError"); |
105 }; | 721 } |
106 dart.fn(unittest.throwsA, src__interfaces.Matcher, [dart.dynamic]); | 722 matches(item, matchState) { |
107 unittest.group = function(name, body) { | 723 return dart.is(item, core.CyclicInitializationError); |
108 return js.context.callMethod('suite', dart.list([name, body], core.Object)); | 724 } |
109 }; | 725 }; |
110 dart.fn(unittest.group, dart.void, [core.String, dart.functionType(dart.void,
[])]); | 726 dart.setSignature(src__matcher__error_matchers._CyclicInitializationError, { |
111 unittest.test = function(name, body, opts) { | 727 constructors: () => ({_CyclicInitializationError: [src__matcher__error_match
ers._CyclicInitializationError, []]}), |
112 let skip = opts && 'skip' in opts ? opts.skip : null; | 728 methods: () => ({matches: [core.bool, [dart.dynamic, core.Map]]}) |
113 if (skip != null) { | 729 }); |
114 core.print(`SKIP ${name}: ${skip}`); | 730 src__matcher__error_matchers.isCyclicInitializationError = dart.const(new src_
_matcher__error_matchers._CyclicInitializationError()); |
115 return; | 731 src__matcher__throws_matchers.throwsCyclicInitializationError = dart.const(new
src__matcher__throws_matcher.Throws(src__matcher__error_matchers.isCyclicInitia
lizationError)); |
116 } | 732 unittest.throwsCyclicInitializationError = src__matcher__throws_matchers.throw
sCyclicInitializationError; |
117 let result = dart.as(js.context.callMethod('test', dart.list([name, dart.fn(
done => { | 733 const _matcher$0 = Symbol('_matcher'); |
118 function _finishTest(f) { | 734 const _id = Symbol('_id'); |
119 if (dart.is(f, async.Future)) { | 735 src__matcher__future_matchers._Completes = class _Completes extends src__match
er__interfaces.Matcher { |
120 f.then(dart.dynamic)(_finishTest); | 736 _Completes(matcher, id) { |
121 } else { | 737 this[_matcher$0] = matcher; |
122 done.apply([]); | 738 this[_id] = id; |
| 739 super.Matcher(); |
| 740 } |
| 741 matches(item, matchState) { |
| 742 if (!dart.is(item, async.Future)) return false; |
| 743 let done = dart.dcall(src__matcher__expect.wrapAsync, dart.fn(fn => dart.d
call(fn)), this[_id]); |
| 744 dart.dsend(item, 'then', dart.fn(value => { |
| 745 dart.dcall(done, dart.fn(() => { |
| 746 if (this[_matcher$0] != null) src__matcher__expect.expect(value, this[
_matcher$0]); |
| 747 })); |
| 748 }), {onError: dart.fn((error, trace) => { |
| 749 let id = this[_id] == '' ? '' : `${this[_id]} `; |
| 750 let reason = `Expected future ${id}to complete successfully, ` + `but
it failed with ${error}`; |
| 751 if (trace != null) { |
| 752 let stackTrace = dart.toString(trace); |
| 753 stackTrace = ` ${stackTrace[dartx.replaceAll]('\n', '\n ')}`; |
| 754 reason = `${reason}\nStack trace:\n${stackTrace}`; |
123 } | 755 } |
124 } | 756 dart.dcall(done, dart.fn(() => src__matcher__expect.fail(reason), dart
.void, [])); |
125 dart.fn(_finishTest); | 757 })}); |
126 _finishTest(body()); | 758 return true; |
127 }, dart.dynamic, [js.JsFunction])], core.Object)), js.JsObject); | 759 } |
128 result.set('async', 1); | 760 describe(description) { |
129 }; | 761 if (this[_matcher$0] == null) { |
130 dart.fn(unittest.test, dart.void, [core.String, dart.functionType(dart.dynamic
, [])], {skip: core.String}); | 762 description.add('completes successfully'); |
131 unittest.TestFailure = class TestFailure extends core.Object { | 763 } else { |
| 764 description.add('completes to a value that ').addDescriptionOf(this[_mat
cher$0]); |
| 765 } |
| 766 return description; |
| 767 } |
| 768 }; |
| 769 dart.setSignature(src__matcher__future_matchers._Completes, { |
| 770 constructors: () => ({_Completes: [src__matcher__future_matchers._Completes,
[src__matcher__interfaces.Matcher, core.String]]}), |
| 771 methods: () => ({ |
| 772 matches: [core.bool, [dart.dynamic, core.Map]], |
| 773 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 774 }) |
| 775 }); |
| 776 src__matcher__future_matchers.completes = dart.const(new src__matcher__future_
matchers._Completes(null, '')); |
| 777 unittest.completes = src__matcher__future_matchers.completes; |
| 778 src__matcher__core_matchers._NotEmpty = class _NotEmpty extends src__matcher__
interfaces.Matcher { |
| 779 _NotEmpty() { |
| 780 super.Matcher(); |
| 781 } |
| 782 matches(item, matchState) { |
| 783 return dart.as(dart.dload(item, 'isNotEmpty'), core.bool); |
| 784 } |
| 785 describe(description) { |
| 786 return description.add('non-empty'); |
| 787 } |
| 788 }; |
| 789 dart.setSignature(src__matcher__core_matchers._NotEmpty, { |
| 790 constructors: () => ({_NotEmpty: [src__matcher__core_matchers._NotEmpty, []]
}), |
| 791 methods: () => ({ |
| 792 matches: [core.bool, [dart.dynamic, core.Map]], |
| 793 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 794 }) |
| 795 }); |
| 796 src__matcher__core_matchers.isNotEmpty = dart.const(new src__matcher__core_mat
chers._NotEmpty()); |
| 797 unittest.isNotEmpty = src__matcher__core_matchers.isNotEmpty; |
| 798 src__matcher__error_matchers._ConcurrentModificationError = class _ConcurrentM
odificationError extends src__matcher__core_matchers.TypeMatcher { |
| 799 _ConcurrentModificationError() { |
| 800 super.TypeMatcher("ConcurrentModificationError"); |
| 801 } |
| 802 matches(item, matchState) { |
| 803 return dart.is(item, core.ConcurrentModificationError); |
| 804 } |
| 805 }; |
| 806 dart.setSignature(src__matcher__error_matchers._ConcurrentModificationError, { |
| 807 constructors: () => ({_ConcurrentModificationError: [src__matcher__error_mat
chers._ConcurrentModificationError, []]}), |
| 808 methods: () => ({matches: [core.bool, [dart.dynamic, core.Map]]}) |
| 809 }); |
| 810 src__matcher__error_matchers.isConcurrentModificationError = dart.const(new sr
c__matcher__error_matchers._ConcurrentModificationError()); |
| 811 unittest.isConcurrentModificationError = src__matcher__error_matchers.isConcur
rentModificationError; |
| 812 src__matcher__throws_matcher.throwsA = function(matcher) { |
| 813 return new src__matcher__throws_matcher.Throws(src__matcher__util.wrapMatche
r(matcher)); |
| 814 }; |
| 815 dart.fn(src__matcher__throws_matcher.throwsA, src__matcher__interfaces.Matcher
, [dart.dynamic]); |
| 816 unittest.throwsA = src__matcher__throws_matcher.throwsA; |
| 817 src__matcher__core_matchers._IsTrue = class _IsTrue extends src__matcher__inte
rfaces.Matcher { |
| 818 _IsTrue() { |
| 819 super.Matcher(); |
| 820 } |
| 821 matches(item, matchState) { |
| 822 return dart.equals(item, true); |
| 823 } |
| 824 describe(description) { |
| 825 return description.add('true'); |
| 826 } |
| 827 }; |
| 828 dart.setSignature(src__matcher__core_matchers._IsTrue, { |
| 829 constructors: () => ({_IsTrue: [src__matcher__core_matchers._IsTrue, []]}), |
| 830 methods: () => ({ |
| 831 matches: [core.bool, [dart.dynamic, core.Map]], |
| 832 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 833 }) |
| 834 }); |
| 835 src__matcher__core_matchers.isTrue = dart.const(new src__matcher__core_matcher
s._IsTrue()); |
| 836 unittest.isTrue = src__matcher__core_matchers.isTrue; |
| 837 src__matcher__throws_matchers.throwsRangeError = dart.const(new src__matcher__
throws_matcher.Throws(src__matcher__error_matchers.isRangeError)); |
| 838 unittest.throwsRangeError = src__matcher__throws_matchers.throwsRangeError; |
| 839 src__matcher__expect.ErrorFormatter = dart.typedef('ErrorFormatter', () => dar
t.functionType(core.String, [dart.dynamic, src__matcher__interfaces.Matcher, cor
e.String, core.Map, core.bool])); |
| 840 unittest.ErrorFormatter = src__matcher__expect.ErrorFormatter; |
| 841 src__matcher__error_matchers._FormatException = class _FormatException extends
src__matcher__core_matchers.TypeMatcher { |
| 842 _FormatException() { |
| 843 super.TypeMatcher("FormatException"); |
| 844 } |
| 845 matches(item, matchState) { |
| 846 return dart.is(item, core.FormatException); |
| 847 } |
| 848 }; |
| 849 dart.setSignature(src__matcher__error_matchers._FormatException, { |
| 850 constructors: () => ({_FormatException: [src__matcher__error_matchers._Forma
tException, []]}), |
| 851 methods: () => ({matches: [core.bool, [dart.dynamic, core.Map]]}) |
| 852 }); |
| 853 src__matcher__error_matchers.isFormatException = dart.const(new src__matcher__
error_matchers._FormatException()); |
| 854 src__matcher__throws_matchers.throwsFormatException = dart.const(new src__matc
her__throws_matcher.Throws(src__matcher__error_matchers.isFormatException)); |
| 855 unittest.throwsFormatException = src__matcher__throws_matchers.throwsFormatExc
eption; |
| 856 src__matcher__core_matchers._ReturnsNormally = class _ReturnsNormally extends
src__matcher__interfaces.Matcher { |
| 857 _ReturnsNormally() { |
| 858 super.Matcher(); |
| 859 } |
| 860 matches(f, matchState) { |
| 861 try { |
| 862 dart.dcall(f); |
| 863 return true; |
| 864 } catch (e) { |
| 865 let s = dart.stackTrace(e); |
| 866 src__matcher__util.addStateInfo(matchState, dart.map({exception: e, stac
k: s})); |
| 867 return false; |
| 868 } |
| 869 |
| 870 } |
| 871 describe(description) { |
| 872 return description.add("return normally"); |
| 873 } |
| 874 describeMismatch(item, mismatchDescription, matchState, verbose) { |
| 875 mismatchDescription.add('threw ').addDescriptionOf(matchState[dartx.get]('
exception')); |
| 876 if (dart.notNull(verbose)) { |
| 877 mismatchDescription.add(' at ').add(dart.toString(matchState[dartx.get](
'stack'))); |
| 878 } |
| 879 return mismatchDescription; |
| 880 } |
| 881 }; |
| 882 dart.setSignature(src__matcher__core_matchers._ReturnsNormally, { |
| 883 constructors: () => ({_ReturnsNormally: [src__matcher__core_matchers._Return
sNormally, []]}), |
| 884 methods: () => ({ |
| 885 matches: [core.bool, [dart.dynamic, core.Map]], |
| 886 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 887 }) |
| 888 }); |
| 889 src__matcher__core_matchers.returnsNormally = dart.const(new src__matcher__cor
e_matchers._ReturnsNormally()); |
| 890 unittest.returnsNormally = src__matcher__core_matchers.returnsNormally; |
| 891 src__matcher__numeric_matchers.inExclusiveRange = function(low, high) { |
| 892 return new src__matcher__numeric_matchers._InRange(low, high, false, false); |
| 893 }; |
| 894 dart.fn(src__matcher__numeric_matchers.inExclusiveRange, src__matcher__interfa
ces.Matcher, [core.num, core.num]); |
| 895 unittest.inExclusiveRange = src__matcher__numeric_matchers.inExclusiveRange; |
| 896 src__matcher__core_matchers.isIn = function(expected) { |
| 897 return new src__matcher__core_matchers._In(expected); |
| 898 }; |
| 899 dart.fn(src__matcher__core_matchers.isIn, src__matcher__interfaces.Matcher, [d
art.dynamic]); |
| 900 unittest.isIn = src__matcher__core_matchers.isIn; |
| 901 src__matcher__string_matchers.equalsIgnoringWhitespace = function(value) { |
| 902 return new src__matcher__string_matchers._IsEqualIgnoringWhitespace(value); |
| 903 }; |
| 904 dart.fn(src__matcher__string_matchers.equalsIgnoringWhitespace, src__matcher__
interfaces.Matcher, [core.String]); |
| 905 unittest.equalsIgnoringWhitespace = src__matcher__string_matchers.equalsIgnori
ngWhitespace; |
| 906 src__matcher__string_matchers.startsWith = function(prefixString) { |
| 907 return new src__matcher__string_matchers._StringStartsWith(prefixString); |
| 908 }; |
| 909 dart.fn(src__matcher__string_matchers.startsWith, src__matcher__interfaces.Mat
cher, [core.String]); |
| 910 unittest.startsWith = src__matcher__string_matchers.startsWith; |
| 911 src__matcher__iterable_matchers.unorderedMatches = function(expected) { |
| 912 return new src__matcher__iterable_matchers._UnorderedMatches(expected); |
| 913 }; |
| 914 dart.fn(src__matcher__iterable_matchers.unorderedMatches, src__matcher__interf
aces.Matcher, [core.Iterable]); |
| 915 unittest.unorderedMatches = src__matcher__iterable_matchers.unorderedMatches; |
| 916 const _value = Symbol('_value'); |
| 917 const _equalValue = Symbol('_equalValue'); |
| 918 const _lessThanValue = Symbol('_lessThanValue'); |
| 919 const _greaterThanValue = Symbol('_greaterThanValue'); |
| 920 const _comparisonDescription = Symbol('_comparisonDescription'); |
| 921 const _valueInDescription = Symbol('_valueInDescription'); |
| 922 src__matcher__numeric_matchers._OrderingComparison = class _OrderingComparison
extends src__matcher__interfaces.Matcher { |
| 923 _OrderingComparison(value, equalValue, lessThanValue, greaterThanValue, comp
arisonDescription, valueInDescription) { |
| 924 if (valueInDescription === void 0) valueInDescription = true; |
| 925 this[_value] = value; |
| 926 this[_equalValue] = equalValue; |
| 927 this[_lessThanValue] = lessThanValue; |
| 928 this[_greaterThanValue] = greaterThanValue; |
| 929 this[_comparisonDescription] = comparisonDescription; |
| 930 this[_valueInDescription] = valueInDescription; |
| 931 super.Matcher(); |
| 932 } |
| 933 matches(item, matchState) { |
| 934 if (dart.equals(item, this[_value])) { |
| 935 return this[_equalValue]; |
| 936 } else if (dart.notNull(dart.as(dart.dsend(item, '<', this[_value]), core.
bool))) { |
| 937 return this[_lessThanValue]; |
| 938 } else { |
| 939 return this[_greaterThanValue]; |
| 940 } |
| 941 } |
| 942 describe(description) { |
| 943 if (dart.notNull(this[_valueInDescription])) { |
| 944 return description.add(this[_comparisonDescription]).add(' ').addDescrip
tionOf(this[_value]); |
| 945 } else { |
| 946 return description.add(this[_comparisonDescription]); |
| 947 } |
| 948 } |
| 949 describeMismatch(item, mismatchDescription, matchState, verbose) { |
| 950 mismatchDescription.add('is not '); |
| 951 return this.describe(mismatchDescription); |
| 952 } |
| 953 }; |
| 954 dart.setSignature(src__matcher__numeric_matchers._OrderingComparison, { |
| 955 constructors: () => ({_OrderingComparison: [src__matcher__numeric_matchers._
OrderingComparison, [dart.dynamic, core.bool, core.bool, core.bool, core.String]
, [core.bool]]}), |
| 956 methods: () => ({ |
| 957 matches: [core.bool, [dart.dynamic, core.Map]], |
| 958 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 959 }) |
| 960 }); |
| 961 src__matcher__numeric_matchers.isZero = dart.const(new src__matcher__numeric_m
atchers._OrderingComparison(0, true, false, false, 'a value equal to')); |
| 962 unittest.isZero = src__matcher__numeric_matchers.isZero; |
| 963 src__matcher__core_matchers._IsList = class _IsList extends src__matcher__core
_matchers.TypeMatcher { |
| 964 _IsList() { |
| 965 super.TypeMatcher("List"); |
| 966 } |
| 967 matches(item, matchState) { |
| 968 return dart.is(item, core.List); |
| 969 } |
| 970 }; |
| 971 dart.setSignature(src__matcher__core_matchers._IsList, { |
| 972 constructors: () => ({_IsList: [src__matcher__core_matchers._IsList, []]}), |
| 973 methods: () => ({matches: [core.bool, [dart.dynamic, core.Map]]}) |
| 974 }); |
| 975 src__matcher__core_matchers.isList = dart.const(new src__matcher__core_matcher
s._IsList()); |
| 976 unittest.isList = src__matcher__core_matchers.isList; |
| 977 src__matcher__prints_matcher.prints = function(matcher) { |
| 978 return new src__matcher__prints_matcher._Prints(src__matcher__util.wrapMatch
er(matcher)); |
| 979 }; |
| 980 dart.fn(src__matcher__prints_matcher.prints, src__matcher__interfaces.Matcher,
[dart.dynamic]); |
| 981 unittest.prints = src__matcher__prints_matcher.prints; |
| 982 src__matcher__util.escape = function(str) { |
| 983 str = str[dartx.replaceAll]('\\', '\\\\'); |
| 984 return str[dartx.replaceAllMapped](src__matcher__util._escapeRegExp, dart.fn
(match => { |
| 985 let mapped = src__matcher__util._escapeMap[dartx.get](match.get(0)); |
| 986 if (mapped != null) return mapped; |
| 987 return src__matcher__util._getHexLiteral(match.get(0)); |
| 988 }, core.String, [core.Match])); |
| 989 }; |
| 990 dart.fn(src__matcher__util.escape, core.String, [core.String]); |
| 991 unittest.escape = src__matcher__util.escape; |
| 992 src__matcher__iterable_matchers.anyElement = function(matcher) { |
| 993 return new src__matcher__iterable_matchers._AnyElement(src__matcher__util.wr
apMatcher(matcher)); |
| 994 }; |
| 995 dart.fn(src__matcher__iterable_matchers.anyElement, src__matcher__interfaces.M
atcher, [dart.dynamic]); |
| 996 unittest.anyElement = src__matcher__iterable_matchers.anyElement; |
| 997 src__matcher__error_matchers._Exception = class _Exception extends src__matche
r__core_matchers.TypeMatcher { |
| 998 _Exception() { |
| 999 super.TypeMatcher("Exception"); |
| 1000 } |
| 1001 matches(item, matchState) { |
| 1002 return dart.is(item, core.Exception); |
| 1003 } |
| 1004 }; |
| 1005 dart.setSignature(src__matcher__error_matchers._Exception, { |
| 1006 constructors: () => ({_Exception: [src__matcher__error_matchers._Exception,
[]]}), |
| 1007 methods: () => ({matches: [core.bool, [dart.dynamic, core.Map]]}) |
| 1008 }); |
| 1009 src__matcher__error_matchers.isException = dart.const(new src__matcher__error_
matchers._Exception()); |
| 1010 src__matcher__throws_matchers.throwsException = dart.const(new src__matcher__t
hrows_matcher.Throws(src__matcher__error_matchers.isException)); |
| 1011 unittest.throwsException = src__matcher__throws_matchers.throwsException; |
| 1012 src__matcher__core_matchers._IsAnything = class _IsAnything extends src__match
er__interfaces.Matcher { |
| 1013 _IsAnything() { |
| 1014 super.Matcher(); |
| 1015 } |
| 1016 matches(item, matchState) { |
| 1017 return true; |
| 1018 } |
| 1019 describe(description) { |
| 1020 return description.add('anything'); |
| 1021 } |
| 1022 }; |
| 1023 dart.setSignature(src__matcher__core_matchers._IsAnything, { |
| 1024 constructors: () => ({_IsAnything: [src__matcher__core_matchers._IsAnything,
[]]}), |
| 1025 methods: () => ({ |
| 1026 matches: [core.bool, [dart.dynamic, core.Map]], |
| 1027 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 1028 }) |
| 1029 }); |
| 1030 src__matcher__core_matchers.anything = dart.const(new src__matcher__core_match
ers._IsAnything()); |
| 1031 unittest.anything = src__matcher__core_matchers.anything; |
| 1032 src__matcher__core_matchers.contains = function(expected) { |
| 1033 return new src__matcher__core_matchers._Contains(expected); |
| 1034 }; |
| 1035 dart.fn(src__matcher__core_matchers.contains, src__matcher__interfaces.Matcher
, [dart.dynamic]); |
| 1036 unittest.contains = src__matcher__core_matchers.contains; |
| 1037 src__matcher__operator_matchers.isNot = function(matcher) { |
| 1038 return new src__matcher__operator_matchers._IsNot(src__matcher__util.wrapMat
cher(matcher)); |
| 1039 }; |
| 1040 dart.fn(src__matcher__operator_matchers.isNot, src__matcher__interfaces.Matche
r, [dart.dynamic]); |
| 1041 unittest.isNot = src__matcher__operator_matchers.isNot; |
| 1042 dart.defineLazy(src__matcher__expect, { |
| 1043 get wrapAsync() { |
| 1044 return dart.fn((f, id) => { |
| 1045 if (id === void 0) id = null; |
| 1046 return f; |
| 1047 }, core.Function, [core.Function], [dart.dynamic]); |
| 1048 }, |
| 1049 set wrapAsync(_) {} |
| 1050 }); |
| 1051 dart.export(unittest, src__matcher__expect, 'wrapAsync'); |
| 1052 src__matcher__core_matchers.same = function(expected) { |
| 1053 return new src__matcher__core_matchers._IsSameAs(expected); |
| 1054 }; |
| 1055 dart.fn(src__matcher__core_matchers.same, src__matcher__interfaces.Matcher, [d
art.dynamic]); |
| 1056 unittest.same = src__matcher__core_matchers.same; |
| 1057 src__matcher__numeric_matchers.inClosedOpenRange = function(low, high) { |
| 1058 return new src__matcher__numeric_matchers._InRange(low, high, true, false); |
| 1059 }; |
| 1060 dart.fn(src__matcher__numeric_matchers.inClosedOpenRange, src__matcher__interf
aces.Matcher, [core.num, core.num]); |
| 1061 unittest.inClosedOpenRange = src__matcher__numeric_matchers.inClosedOpenRange; |
| 1062 src__matcher__core_matchers.predicate = function(f, description) { |
| 1063 if (description === void 0) description = 'satisfies function'; |
| 1064 return new src__matcher__core_matchers._Predicate(f, description); |
| 1065 }; |
| 1066 dart.fn(src__matcher__core_matchers.predicate, src__matcher__interfaces.Matche
r, [dart.functionType(core.bool, [dart.dynamic])], [core.String]); |
| 1067 unittest.predicate = src__matcher__core_matchers.predicate; |
| 1068 src__matcher__util.wrapMatcher = function(x) { |
| 1069 if (dart.is(x, src__matcher__interfaces.Matcher)) { |
| 1070 return x; |
| 1071 } else if (dart.is(x, src__matcher__util._Predicate)) { |
| 1072 return src__matcher__core_matchers.predicate(x); |
| 1073 } else { |
| 1074 return src__matcher__core_matchers.equals(x); |
| 1075 } |
| 1076 }; |
| 1077 dart.fn(src__matcher__util.wrapMatcher, src__matcher__interfaces.Matcher, [dar
t.dynamic]); |
| 1078 unittest.wrapMatcher = src__matcher__util.wrapMatcher; |
| 1079 src__matcher__iterable_matchers.unorderedEquals = function(expected) { |
| 1080 return new src__matcher__iterable_matchers._UnorderedEquals(expected); |
| 1081 }; |
| 1082 dart.fn(src__matcher__iterable_matchers.unorderedEquals, src__matcher__interfa
ces.Matcher, [core.Iterable]); |
| 1083 unittest.unorderedEquals = src__matcher__iterable_matchers.unorderedEquals; |
| 1084 src__matcher__expect.TestFailure = class TestFailure extends core.Error { |
132 TestFailure(message) { | 1085 TestFailure(message) { |
133 this.message = message; | 1086 this.message = message; |
| 1087 super.Error(); |
134 } | 1088 } |
135 toString() { | 1089 toString() { |
136 return this.message; | 1090 return this.message; |
137 } | 1091 } |
138 }; | 1092 }; |
139 dart.setSignature(unittest.TestFailure, { | 1093 dart.setSignature(src__matcher__expect.TestFailure, { |
140 constructors: () => ({TestFailure: [unittest.TestFailure, [core.String]]}) | 1094 constructors: () => ({TestFailure: [src__matcher__expect.TestFailure, [core.
String]]}) |
141 }); | 1095 }); |
142 unittest.TestCase = class TestCase extends core.Object { | 1096 unittest.TestFailure = src__matcher__expect.TestFailure; |
| 1097 unittest.isException = src__matcher__error_matchers.isException; |
| 1098 src__matcher__util.addStateInfo = function(matchState, values) { |
| 1099 let innerState = core.Map.from(matchState); |
| 1100 matchState[dartx.clear](); |
| 1101 matchState[dartx.set]('state', innerState); |
| 1102 matchState[dartx.addAll](values); |
| 1103 }; |
| 1104 dart.fn(src__matcher__util.addStateInfo, dart.void, [core.Map, core.Map]); |
| 1105 unittest.addStateInfo = src__matcher__util.addStateInfo; |
| 1106 src__matcher__throws_matchers.throwsConcurrentModificationError = dart.const(n
ew src__matcher__throws_matcher.Throws(src__matcher__error_matchers.isConcurrent
ModificationError)); |
| 1107 unittest.throwsConcurrentModificationError = src__matcher__throws_matchers.thr
owsConcurrentModificationError; |
| 1108 src__matcher__numeric_matchers.closeTo = function(value, delta) { |
| 1109 return new src__matcher__numeric_matchers._IsCloseTo(value, delta); |
| 1110 }; |
| 1111 dart.fn(src__matcher__numeric_matchers.closeTo, src__matcher__interfaces.Match
er, [core.num, core.num]); |
| 1112 unittest.closeTo = src__matcher__numeric_matchers.closeTo; |
| 1113 src__matcher__numeric_matchers.isPositive = dart.const(new src__matcher__numer
ic_matchers._OrderingComparison(0, false, false, true, 'a positive value', false
)); |
| 1114 unittest.isPositive = src__matcher__numeric_matchers.isPositive; |
| 1115 src__matcher__numeric_matchers.inOpenClosedRange = function(low, high) { |
| 1116 return new src__matcher__numeric_matchers._InRange(low, high, false, true); |
| 1117 }; |
| 1118 dart.fn(src__matcher__numeric_matchers.inOpenClosedRange, src__matcher__interf
aces.Matcher, [core.num, core.num]); |
| 1119 unittest.inOpenClosedRange = src__matcher__numeric_matchers.inOpenClosedRange; |
| 1120 src__matcher__string_matchers.equalsIgnoringCase = function(value) { |
| 1121 return new src__matcher__string_matchers._IsEqualIgnoringCase(value); |
| 1122 }; |
| 1123 dart.fn(src__matcher__string_matchers.equalsIgnoringCase, src__matcher__interf
aces.Matcher, [core.String]); |
| 1124 unittest.equalsIgnoringCase = src__matcher__string_matchers.equalsIgnoringCase
; |
| 1125 src__matcher__numeric_matchers.isNegative = dart.const(new src__matcher__numer
ic_matchers._OrderingComparison(0, false, true, false, 'a negative value', false
)); |
| 1126 unittest.isNegative = src__matcher__numeric_matchers.isNegative; |
| 1127 src__matcher__operator_matchers.allOf = function(arg0, arg1, arg2, arg3, arg4,
arg5, arg6) { |
| 1128 if (arg1 === void 0) arg1 = null; |
| 1129 if (arg2 === void 0) arg2 = null; |
| 1130 if (arg3 === void 0) arg3 = null; |
| 1131 if (arg4 === void 0) arg4 = null; |
| 1132 if (arg5 === void 0) arg5 = null; |
| 1133 if (arg6 === void 0) arg6 = null; |
| 1134 return new src__matcher__operator_matchers._AllOf(src__matcher__operator_mat
chers._wrapArgs(arg0, arg1, arg2, arg3, arg4, arg5, arg6)); |
| 1135 }; |
| 1136 dart.fn(src__matcher__operator_matchers.allOf, src__matcher__interfaces.Matche
r, [dart.dynamic], [dart.dynamic, dart.dynamic, dart.dynamic, dart.dynamic, dart
.dynamic, dart.dynamic]); |
| 1137 unittest.allOf = src__matcher__operator_matchers.allOf; |
| 1138 src__matcher__error_matchers._ArgumentError = class _ArgumentError extends src
__matcher__core_matchers.TypeMatcher { |
| 1139 _ArgumentError() { |
| 1140 super.TypeMatcher("ArgumentError"); |
| 1141 } |
| 1142 matches(item, matchState) { |
| 1143 return dart.is(item, core.ArgumentError); |
| 1144 } |
| 1145 }; |
| 1146 dart.setSignature(src__matcher__error_matchers._ArgumentError, { |
| 1147 constructors: () => ({_ArgumentError: [src__matcher__error_matchers._Argumen
tError, []]}), |
| 1148 methods: () => ({matches: [core.bool, [dart.dynamic, core.Map]]}) |
| 1149 }); |
| 1150 src__matcher__error_matchers.isArgumentError = dart.const(new src__matcher__er
ror_matchers._ArgumentError()); |
| 1151 src__matcher__throws_matchers.throwsArgumentError = dart.const(new src__matche
r__throws_matcher.Throws(src__matcher__error_matchers.isArgumentError)); |
| 1152 unittest.throwsArgumentError = src__matcher__throws_matchers.throwsArgumentErr
or; |
| 1153 src__matcher__numeric_matchers.lessThan = function(value) { |
| 1154 return new src__matcher__numeric_matchers._OrderingComparison(value, false,
true, false, 'a value less than'); |
| 1155 }; |
| 1156 dart.fn(src__matcher__numeric_matchers.lessThan, src__matcher__interfaces.Matc
her, [dart.dynamic]); |
| 1157 unittest.lessThan = src__matcher__numeric_matchers.lessThan; |
| 1158 src__matcher__throws_matchers.throwsStateError = dart.const(new src__matcher__
throws_matcher.Throws(src__matcher__error_matchers.isStateError)); |
| 1159 unittest.throwsStateError = src__matcher__throws_matchers.throwsStateError; |
| 1160 src__matcher__numeric_matchers.greaterThanOrEqualTo = function(value) { |
| 1161 return new src__matcher__numeric_matchers._OrderingComparison(value, true, f
alse, true, 'a value greater than or equal to'); |
| 1162 }; |
| 1163 dart.fn(src__matcher__numeric_matchers.greaterThanOrEqualTo, src__matcher__int
erfaces.Matcher, [dart.dynamic]); |
| 1164 unittest.greaterThanOrEqualTo = src__matcher__numeric_matchers.greaterThanOrEq
ualTo; |
| 1165 unittest.Throws = src__matcher__throws_matcher.Throws; |
| 1166 src__matcher__map_matchers.containsValue = function(value) { |
| 1167 return new src__matcher__map_matchers._ContainsValue(value); |
| 1168 }; |
| 1169 dart.fn(src__matcher__map_matchers.containsValue, src__matcher__interfaces.Mat
cher, [dart.dynamic]); |
| 1170 unittest.containsValue = src__matcher__map_matchers.containsValue; |
| 1171 src__matcher__string_matchers.endsWith = function(suffixString) { |
| 1172 return new src__matcher__string_matchers._StringEndsWith(suffixString); |
| 1173 }; |
| 1174 dart.fn(src__matcher__string_matchers.endsWith, src__matcher__interfaces.Match
er, [core.String]); |
| 1175 unittest.endsWith = src__matcher__string_matchers.endsWith; |
| 1176 src__matcher__core_matchers._IsFalse = class _IsFalse extends src__matcher__in
terfaces.Matcher { |
| 1177 _IsFalse() { |
| 1178 super.Matcher(); |
| 1179 } |
| 1180 matches(item, matchState) { |
| 1181 return dart.equals(item, false); |
| 1182 } |
| 1183 describe(description) { |
| 1184 return description.add('false'); |
| 1185 } |
| 1186 }; |
| 1187 dart.setSignature(src__matcher__core_matchers._IsFalse, { |
| 1188 constructors: () => ({_IsFalse: [src__matcher__core_matchers._IsFalse, []]})
, |
| 1189 methods: () => ({ |
| 1190 matches: [core.bool, [dart.dynamic, core.Map]], |
| 1191 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 1192 }) |
| 1193 }); |
| 1194 src__matcher__core_matchers.isFalse = dart.const(new src__matcher__core_matche
rs._IsFalse()); |
| 1195 unittest.isFalse = src__matcher__core_matchers.isFalse; |
| 1196 unittest.Matcher = src__matcher__interfaces.Matcher; |
| 1197 src__matcher__numeric_matchers.lessThanOrEqualTo = function(value) { |
| 1198 return new src__matcher__numeric_matchers._OrderingComparison(value, true, t
rue, false, 'a value less than or equal to'); |
| 1199 }; |
| 1200 dart.fn(src__matcher__numeric_matchers.lessThanOrEqualTo, src__matcher__interf
aces.Matcher, [dart.dynamic]); |
| 1201 unittest.lessThanOrEqualTo = src__matcher__numeric_matchers.lessThanOrEqualTo; |
| 1202 src__matcher__expect.getOrCreateExpectFailureHandler = function() { |
| 1203 if (src__matcher__expect._assertFailureHandler == null) { |
| 1204 src__matcher__expect.configureExpectFailureHandler(); |
| 1205 } |
| 1206 return src__matcher__expect._assertFailureHandler; |
| 1207 }; |
| 1208 dart.lazyFn(src__matcher__expect.getOrCreateExpectFailureHandler, () => [src__
matcher__expect.FailureHandler, []]); |
| 1209 unittest.getOrCreateExpectFailureHandler = src__matcher__expect.getOrCreateExp
ectFailureHandler; |
| 1210 src__matcher__string_matchers.matches = function(re) { |
| 1211 return new src__matcher__string_matchers._MatchesRegExp(re); |
| 1212 }; |
| 1213 dart.fn(src__matcher__string_matchers.matches, src__matcher__interfaces.Matche
r, [dart.dynamic]); |
| 1214 unittest.matches = src__matcher__string_matchers.matches; |
| 1215 src__matcher__error_matchers._UnsupportedError = class _UnsupportedError exten
ds src__matcher__core_matchers.TypeMatcher { |
| 1216 _UnsupportedError() { |
| 1217 super.TypeMatcher("UnsupportedError"); |
| 1218 } |
| 1219 matches(item, matchState) { |
| 1220 return dart.is(item, core.UnsupportedError); |
| 1221 } |
| 1222 }; |
| 1223 dart.setSignature(src__matcher__error_matchers._UnsupportedError, { |
| 1224 constructors: () => ({_UnsupportedError: [src__matcher__error_matchers._Unsu
pportedError, []]}), |
| 1225 methods: () => ({matches: [core.bool, [dart.dynamic, core.Map]]}) |
| 1226 }); |
| 1227 src__matcher__error_matchers.isUnsupportedError = dart.const(new src__matcher_
_error_matchers._UnsupportedError()); |
| 1228 src__matcher__throws_matchers.throwsUnsupportedError = dart.const(new src__mat
cher__throws_matcher.Throws(src__matcher__error_matchers.isUnsupportedError)); |
| 1229 unittest.throwsUnsupportedError = src__matcher__throws_matchers.throwsUnsuppor
tedError; |
| 1230 unittest.TypeMatcher = src__matcher__core_matchers.TypeMatcher; |
| 1231 src__matcher__expect.configureExpectFailureHandler = function(handler) { |
| 1232 if (handler === void 0) handler = null; |
| 1233 if (handler == null) { |
| 1234 handler = new src__matcher__expect.DefaultFailureHandler(); |
| 1235 } |
| 1236 src__matcher__expect._assertFailureHandler = handler; |
| 1237 }; |
| 1238 dart.lazyFn(src__matcher__expect.configureExpectFailureHandler, () => [dart.vo
id, [], [src__matcher__expect.FailureHandler]]); |
| 1239 unittest.configureExpectFailureHandler = src__matcher__expect.configureExpectF
ailureHandler; |
| 1240 src__matcher__expect.FailureHandler = class FailureHandler extends core.Object
{}; |
| 1241 unittest.FailureHandler = src__matcher__expect.FailureHandler; |
| 1242 src__matcher__core_matchers._IsNotNaN = class _IsNotNaN extends src__matcher__
interfaces.Matcher { |
| 1243 _IsNotNaN() { |
| 1244 super.Matcher(); |
| 1245 } |
| 1246 matches(item, matchState) { |
| 1247 return core.double.NAN[dartx.compareTo](dart.as(item, core.num)) != 0; |
| 1248 } |
| 1249 describe(description) { |
| 1250 return description.add('not NaN'); |
| 1251 } |
| 1252 }; |
| 1253 dart.setSignature(src__matcher__core_matchers._IsNotNaN, { |
| 1254 constructors: () => ({_IsNotNaN: [src__matcher__core_matchers._IsNotNaN, []]
}), |
| 1255 methods: () => ({ |
| 1256 matches: [core.bool, [dart.dynamic, core.Map]], |
| 1257 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 1258 }) |
| 1259 }); |
| 1260 src__matcher__core_matchers.isNotNaN = dart.const(new src__matcher__core_match
ers._IsNotNaN()); |
| 1261 unittest.isNotNaN = src__matcher__core_matchers.isNotNaN; |
| 1262 src__matcher__numeric_matchers.isNonZero = dart.const(new src__matcher__numeri
c_matchers._OrderingComparison(0, false, true, true, 'a value not equal to')); |
| 1263 unittest.isNonZero = src__matcher__numeric_matchers.isNonZero; |
| 1264 src__matcher__throws_matcher.throws = dart.const(new src__matcher__throws_matc
her.Throws()); |
| 1265 unittest.throws = src__matcher__throws_matcher.throws; |
| 1266 src__matcher__error_matchers._NullThrownError = class _NullThrownError extends
src__matcher__core_matchers.TypeMatcher { |
| 1267 _NullThrownError() { |
| 1268 super.TypeMatcher("NullThrownError"); |
| 1269 } |
| 1270 matches(item, matchState) { |
| 1271 return dart.is(item, core.NullThrownError); |
| 1272 } |
| 1273 }; |
| 1274 dart.setSignature(src__matcher__error_matchers._NullThrownError, { |
| 1275 constructors: () => ({_NullThrownError: [src__matcher__error_matchers._NullT
hrownError, []]}), |
| 1276 methods: () => ({matches: [core.bool, [dart.dynamic, core.Map]]}) |
| 1277 }); |
| 1278 src__matcher__error_matchers.isNullThrownError = dart.const(new src__matcher__
error_matchers._NullThrownError()); |
| 1279 unittest.isNullThrownError = src__matcher__error_matchers.isNullThrownError; |
| 1280 src__matcher__expect.DefaultFailureHandler = class DefaultFailureHandler exten
ds core.Object { |
| 1281 DefaultFailureHandler() { |
| 1282 if (src__matcher__expect._assertErrorFormatter == null) { |
| 1283 src__matcher__expect._assertErrorFormatter = src__matcher__expect._defau
ltErrorFormatter; |
| 1284 } |
| 1285 } |
| 1286 fail(reason) { |
| 1287 dart.throw(new src__matcher__expect.TestFailure(reason)); |
| 1288 } |
| 1289 failMatch(actual, matcher, reason, matchState, verbose) { |
| 1290 this.fail(dart.dcall(src__matcher__expect._assertErrorFormatter, actual, m
atcher, reason, matchState, verbose)); |
| 1291 } |
| 1292 }; |
| 1293 src__matcher__expect.DefaultFailureHandler[dart.implements] = () => [src__matc
her__expect.FailureHandler]; |
| 1294 dart.setSignature(src__matcher__expect.DefaultFailureHandler, { |
| 1295 constructors: () => ({DefaultFailureHandler: [src__matcher__expect.DefaultFa
ilureHandler, []]}), |
| 1296 methods: () => ({ |
| 1297 fail: [dart.void, [core.String]], |
| 1298 failMatch: [dart.void, [dart.dynamic, src__matcher__interfaces.Matcher, co
re.String, core.Map, core.bool]] |
| 1299 }) |
| 1300 }); |
| 1301 unittest.DefaultFailureHandler = src__matcher__expect.DefaultFailureHandler; |
| 1302 src__matcher__core_matchers._Empty = class _Empty extends src__matcher__interf
aces.Matcher { |
| 1303 _Empty() { |
| 1304 super.Matcher(); |
| 1305 } |
| 1306 matches(item, matchState) { |
| 1307 return dart.as(dart.dload(item, 'isEmpty'), core.bool); |
| 1308 } |
| 1309 describe(description) { |
| 1310 return description.add('empty'); |
| 1311 } |
| 1312 }; |
| 1313 dart.setSignature(src__matcher__core_matchers._Empty, { |
| 1314 constructors: () => ({_Empty: [src__matcher__core_matchers._Empty, []]}), |
| 1315 methods: () => ({ |
| 1316 matches: [core.bool, [dart.dynamic, core.Map]], |
| 1317 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 1318 }) |
| 1319 }); |
| 1320 src__matcher__core_matchers.isEmpty = dart.const(new src__matcher__core_matche
rs._Empty()); |
| 1321 unittest.isEmpty = src__matcher__core_matchers.isEmpty; |
| 1322 src__matcher__operator_matchers.anyOf = function(arg0, arg1, arg2, arg3, arg4,
arg5, arg6) { |
| 1323 if (arg1 === void 0) arg1 = null; |
| 1324 if (arg2 === void 0) arg2 = null; |
| 1325 if (arg3 === void 0) arg3 = null; |
| 1326 if (arg4 === void 0) arg4 = null; |
| 1327 if (arg5 === void 0) arg5 = null; |
| 1328 if (arg6 === void 0) arg6 = null; |
| 1329 return new src__matcher__operator_matchers._AnyOf(src__matcher__operator_mat
chers._wrapArgs(arg0, arg1, arg2, arg3, arg4, arg5, arg6)); |
| 1330 }; |
| 1331 dart.fn(src__matcher__operator_matchers.anyOf, src__matcher__interfaces.Matche
r, [dart.dynamic], [dart.dynamic, dart.dynamic, dart.dynamic, dart.dynamic, dart
.dynamic, dart.dynamic]); |
| 1332 unittest.anyOf = src__matcher__operator_matchers.anyOf; |
| 1333 unittest.isCyclicInitializationError = src__matcher__error_matchers.isCyclicIn
itializationError; |
| 1334 src__matcher__error_matchers._NoSuchMethodError = class _NoSuchMethodError ext
ends src__matcher__core_matchers.TypeMatcher { |
| 1335 _NoSuchMethodError() { |
| 1336 super.TypeMatcher("NoSuchMethodError"); |
| 1337 } |
| 1338 matches(item, matchState) { |
| 1339 return dart.is(item, core.NoSuchMethodError); |
| 1340 } |
| 1341 }; |
| 1342 dart.setSignature(src__matcher__error_matchers._NoSuchMethodError, { |
| 1343 constructors: () => ({_NoSuchMethodError: [src__matcher__error_matchers._NoS
uchMethodError, []]}), |
| 1344 methods: () => ({matches: [core.bool, [dart.dynamic, core.Map]]}) |
| 1345 }); |
| 1346 src__matcher__error_matchers.isNoSuchMethodError = dart.const(new src__matcher
__error_matchers._NoSuchMethodError()); |
| 1347 src__matcher__throws_matchers.throwsNoSuchMethodError = dart.const(new src__ma
tcher__throws_matcher.Throws(src__matcher__error_matchers.isNoSuchMethodError)); |
| 1348 unittest.throwsNoSuchMethodError = src__matcher__throws_matchers.throwsNoSuchM
ethodError; |
| 1349 src__matcher__future_matchers.completion = function(matcher, id) { |
| 1350 if (id === void 0) id = ''; |
| 1351 return new src__matcher__future_matchers._Completes(src__matcher__util.wrapM
atcher(matcher), id); |
| 1352 }; |
| 1353 dart.fn(src__matcher__future_matchers.completion, src__matcher__interfaces.Mat
cher, [dart.dynamic], [core.String]); |
| 1354 unittest.completion = src__matcher__future_matchers.completion; |
| 1355 unittest.isUnsupportedError = src__matcher__error_matchers.isUnsupportedError; |
| 1356 src__matcher__numeric_matchers.isNonPositive = dart.const(new src__matcher__nu
meric_matchers._OrderingComparison(0, true, true, false, 'a non-positive value',
false)); |
| 1357 unittest.isNonPositive = src__matcher__numeric_matchers.isNonPositive; |
| 1358 dart.export(unittest, src__matcher__expect, 'wrapAsync'); |
| 1359 src__matcher__core_matchers._IsNotNull = class _IsNotNull extends src__matcher
__interfaces.Matcher { |
| 1360 _IsNotNull() { |
| 1361 super.Matcher(); |
| 1362 } |
| 1363 matches(item, matchState) { |
| 1364 return item != null; |
| 1365 } |
| 1366 describe(description) { |
| 1367 return description.add('not null'); |
| 1368 } |
| 1369 }; |
| 1370 dart.setSignature(src__matcher__core_matchers._IsNotNull, { |
| 1371 constructors: () => ({_IsNotNull: [src__matcher__core_matchers._IsNotNull, [
]]}), |
| 1372 methods: () => ({ |
| 1373 matches: [core.bool, [dart.dynamic, core.Map]], |
| 1374 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 1375 }) |
| 1376 }); |
| 1377 src__matcher__core_matchers.isNotNull = dart.const(new src__matcher__core_matc
hers._IsNotNull()); |
| 1378 unittest.isNotNull = src__matcher__core_matchers.isNotNull; |
| 1379 unittest.isNoSuchMethodError = src__matcher__error_matchers.isNoSuchMethodErro
r; |
| 1380 src__matcher__throws_matchers.throwsNullThrownError = dart.const(new src__matc
her__throws_matcher.Throws(src__matcher__error_matchers.isNullThrownError)); |
| 1381 unittest.throwsNullThrownError = src__matcher__throws_matchers.throwsNullThrow
nError; |
| 1382 src__matcher__throws_matchers.throwsUnimplementedError = dart.const(new src__m
atcher__throws_matcher.Throws(src__matcher__error_matchers.isUnimplementedError)
); |
| 1383 unittest.throwsUnimplementedError = src__matcher__throws_matchers.throwsUnimpl
ementedError; |
| 1384 src__matcher__iterable_matchers.everyElement = function(matcher) { |
| 1385 return new src__matcher__iterable_matchers._EveryElement(src__matcher__util.
wrapMatcher(matcher)); |
| 1386 }; |
| 1387 dart.fn(src__matcher__iterable_matchers.everyElement, src__matcher__interfaces
.Matcher, [dart.dynamic]); |
| 1388 unittest.everyElement = src__matcher__iterable_matchers.everyElement; |
| 1389 unittest.isArgumentError = src__matcher__error_matchers.isArgumentError; |
| 1390 src__matcher__map_matchers.containsPair = function(key, value) { |
| 1391 return new src__matcher__map_matchers._ContainsMapping(key, src__matcher__ut
il.wrapMatcher(value)); |
| 1392 }; |
| 1393 dart.fn(src__matcher__map_matchers.containsPair, src__matcher__interfaces.Matc
her, [dart.dynamic, dart.dynamic]); |
| 1394 unittest.containsPair = src__matcher__map_matchers.containsPair; |
| 1395 src__matcher__numeric_matchers.inInclusiveRange = function(low, high) { |
| 1396 return new src__matcher__numeric_matchers._InRange(low, high, true, true); |
| 1397 }; |
| 1398 dart.fn(src__matcher__numeric_matchers.inInclusiveRange, src__matcher__interfa
ces.Matcher, [core.num, core.num]); |
| 1399 unittest.inInclusiveRange = src__matcher__numeric_matchers.inInclusiveRange; |
| 1400 unittest.isFormatException = src__matcher__error_matchers.isFormatException; |
| 1401 src__matcher__iterable_matchers.orderedEquals = function(expected) { |
| 1402 return new src__matcher__iterable_matchers._OrderedEquals(expected); |
| 1403 }; |
| 1404 dart.fn(src__matcher__iterable_matchers.orderedEquals, src__matcher__interface
s.Matcher, [core.Iterable]); |
| 1405 unittest.orderedEquals = src__matcher__iterable_matchers.orderedEquals; |
| 1406 src__matcher__string_matchers.collapseWhitespace = function(string) { |
| 1407 let result = new core.StringBuffer(); |
| 1408 let skipSpace = true; |
| 1409 for (let i = 0; i < dart.notNull(string[dartx.length]); i++) { |
| 1410 let character = string[dartx.get](i); |
| 1411 if (dart.notNull(src__matcher__string_matchers._isWhitespace(character)))
{ |
| 1412 if (!skipSpace) { |
| 1413 result.write(' '); |
| 1414 skipSpace = true; |
| 1415 } |
| 1416 } else { |
| 1417 result.write(character); |
| 1418 skipSpace = false; |
| 1419 } |
| 1420 } |
| 1421 return result.toString()[dartx.trim](); |
| 1422 }; |
| 1423 dart.fn(src__matcher__string_matchers.collapseWhitespace, core.String, [core.S
tring]); |
| 1424 unittest.collapseWhitespace = src__matcher__string_matchers.collapseWhitespace
; |
| 1425 src__matcher__numeric_matchers.greaterThan = function(value) { |
| 1426 return new src__matcher__numeric_matchers._OrderingComparison(value, false,
false, true, 'a value greater than'); |
| 1427 }; |
| 1428 dart.fn(src__matcher__numeric_matchers.greaterThan, src__matcher__interfaces.M
atcher, [dart.dynamic]); |
| 1429 unittest.greaterThan = src__matcher__numeric_matchers.greaterThan; |
| 1430 src__matcher__numeric_matchers.isNonNegative = dart.const(new src__matcher__nu
meric_matchers._OrderingComparison(0, true, false, true, 'a non-negative value',
false)); |
| 1431 unittest.isNonNegative = src__matcher__numeric_matchers.isNonNegative; |
| 1432 src__matcher__core_matchers._IsNull = class _IsNull extends src__matcher__inte
rfaces.Matcher { |
| 1433 _IsNull() { |
| 1434 super.Matcher(); |
| 1435 } |
| 1436 matches(item, matchState) { |
| 1437 return item == null; |
| 1438 } |
| 1439 describe(description) { |
| 1440 return description.add('null'); |
| 1441 } |
| 1442 }; |
| 1443 dart.setSignature(src__matcher__core_matchers._IsNull, { |
| 1444 constructors: () => ({_IsNull: [src__matcher__core_matchers._IsNull, []]}), |
| 1445 methods: () => ({ |
| 1446 matches: [core.bool, [dart.dynamic, core.Map]], |
| 1447 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 1448 }) |
| 1449 }); |
| 1450 src__matcher__core_matchers.isNull = dart.const(new src__matcher__core_matcher
s._IsNull()); |
| 1451 unittest.isNull = src__matcher__core_matchers.isNull; |
| 1452 src__matcher__core_matchers._IsMap = class _IsMap extends src__matcher__core_m
atchers.TypeMatcher { |
| 1453 _IsMap() { |
| 1454 super.TypeMatcher("Map"); |
| 1455 } |
| 1456 matches(item, matchState) { |
| 1457 return dart.is(item, core.Map); |
| 1458 } |
| 1459 }; |
| 1460 dart.setSignature(src__matcher__core_matchers._IsMap, { |
| 1461 constructors: () => ({_IsMap: [src__matcher__core_matchers._IsMap, []]}), |
| 1462 methods: () => ({matches: [core.bool, [dart.dynamic, core.Map]]}) |
| 1463 }); |
| 1464 src__matcher__core_matchers.isMap = dart.const(new src__matcher__core_matchers
._IsMap()); |
| 1465 unittest.isMap = src__matcher__core_matchers.isMap; |
| 1466 src__matcher__interfaces.Description = class Description extends core.Object {
}; |
| 1467 unittest.Description = src__matcher__interfaces.Description; |
| 1468 src__matcher__string_matchers.stringContainsInOrder = function(substrings) { |
| 1469 return new src__matcher__string_matchers._StringContainsInOrder(substrings); |
| 1470 }; |
| 1471 dart.fn(src__matcher__string_matchers.stringContainsInOrder, src__matcher__int
erfaces.Matcher, [core.List$(core.String)]); |
| 1472 unittest.stringContainsInOrder = src__matcher__string_matchers.stringContainsI
nOrder; |
| 1473 const _testLogBuffer = Symbol('_testLogBuffer'); |
| 1474 const _receivePort = Symbol('_receivePort'); |
| 1475 const _postMessage = Symbol('_postMessage'); |
| 1476 src__simple_configuration.SimpleConfiguration = class SimpleConfiguration exte
nds src__configuration.Configuration { |
| 1477 SimpleConfiguration() { |
| 1478 this[_testLogBuffer] = dart.list([], src__utils.Pair$(core.String, core.St
ackTrace)); |
| 1479 this[_receivePort] = null; |
| 1480 this.name = 'Configuration'; |
| 1481 this.throwOnTestFailures = true; |
| 1482 this.stopTestOnExpectFailure = true; |
| 1483 super.blank(); |
| 1484 src__matcher__expect.configureExpectFailureHandler(new src__simple_configu
ration._ExpectFailureHandler(this)); |
| 1485 } |
| 1486 onInit() { |
| 1487 unittest.filterStacks = false; |
| 1488 this[_receivePort] = isolate.ReceivePort.new(); |
| 1489 this[_postMessage]('unittest-suite-wait-for-done'); |
| 1490 } |
| 1491 onTestStart(testCase) { |
| 1492 return this[_testLogBuffer][dartx.clear](); |
| 1493 } |
| 1494 onTestResult(externalTestCase) { |
| 1495 if (dart.notNull(this.stopTestOnExpectFailure) || dart.notNull(this[_testL
ogBuffer][dartx.isEmpty])) return; |
| 1496 let testCase = dart.as(externalTestCase, src__internal_test_case.InternalT
estCase); |
| 1497 let reason = new core.StringBuffer(); |
| 1498 for (let reasonAndTrace of this[_testLogBuffer][dartx.take](dart.notNull(t
his[_testLogBuffer][dartx.length]) - 1)) { |
| 1499 reason.write(reasonAndTrace.first); |
| 1500 reason.write('\n'); |
| 1501 reason.write(reasonAndTrace.last); |
| 1502 reason.write('\n'); |
| 1503 } |
| 1504 let lastReasonAndTrace = this[_testLogBuffer][dartx.last]; |
| 1505 reason.write(lastReasonAndTrace.first); |
| 1506 if (testCase.result == unittest.PASS) { |
| 1507 testCase.result = unittest.FAIL; |
| 1508 testCase.message = reason.toString(); |
| 1509 testCase.stackTrace = lastReasonAndTrace.last; |
| 1510 } else { |
| 1511 reason.write(lastReasonAndTrace.last); |
| 1512 reason.write('\n'); |
| 1513 testCase.message = `${reason.toString()}\n${testCase.message}`; |
| 1514 } |
| 1515 } |
| 1516 onLogMessage(testCase, message) { |
| 1517 core.print(message); |
| 1518 } |
| 1519 onExpectFailure(reason) { |
| 1520 if (dart.notNull(this.stopTestOnExpectFailure)) dart.throw(new src__matche
r__expect.TestFailure(reason)); |
| 1521 try { |
| 1522 dart.throw(''); |
| 1523 } catch (_) { |
| 1524 let stack = dart.stackTrace(_); |
| 1525 let trace = src__utils.getTrace(stack, unittest.formatStacks, unittest.f
ilterStacks); |
| 1526 if (trace == null) trace = dart.as(stack, src__trace.Trace); |
| 1527 this[_testLogBuffer][dartx.add](new (src__utils.Pair$(core.String, core.
StackTrace))(reason, trace)); |
| 1528 } |
| 1529 |
| 1530 } |
| 1531 formatResult(testCase) { |
| 1532 let result = new core.StringBuffer(); |
| 1533 result.write(testCase.result[dartx.toUpperCase]()); |
| 1534 result.write(": "); |
| 1535 result.write(testCase.description); |
| 1536 result.write("\n"); |
| 1537 if (testCase.message != '') { |
| 1538 result.write(src__utils.indent(testCase.message)); |
| 1539 result.write("\n"); |
| 1540 } |
| 1541 if (testCase.stackTrace != null) { |
| 1542 result.write(src__utils.indent(dart.toString(testCase.stackTrace))); |
| 1543 result.write("\n"); |
| 1544 } |
| 1545 return result.toString(); |
| 1546 } |
| 1547 onSummary(passed, failed, errors, results, uncaughtError) { |
| 1548 for (let test of results) { |
| 1549 core.print(this.formatResult(test)[dartx.trim]()); |
| 1550 } |
| 1551 core.print(''); |
| 1552 if (passed == 0 && failed == 0 && errors == 0 && uncaughtError == null) { |
| 1553 core.print('No tests found.'); |
| 1554 } else if (failed == 0 && errors == 0 && uncaughtError == null) { |
| 1555 core.print(`All ${passed} tests passed.`); |
| 1556 } else { |
| 1557 if (uncaughtError != null) { |
| 1558 core.print(`Top-level uncaught error: ${uncaughtError}`); |
| 1559 } |
| 1560 core.print(`${passed} PASSED, ${failed} FAILED, ${errors} ERRORS`); |
| 1561 } |
| 1562 } |
| 1563 onDone(success) { |
| 1564 if (dart.notNull(success)) { |
| 1565 this[_postMessage]('unittest-suite-success'); |
| 1566 this[_receivePort].close(); |
| 1567 } else { |
| 1568 this[_receivePort].close(); |
| 1569 if (dart.notNull(this.throwOnTestFailures)) { |
| 1570 dart.throw(core.Exception.new('Some tests failed.')); |
| 1571 } |
| 1572 } |
| 1573 } |
| 1574 [_postMessage](message) { |
| 1575 core.print(message); |
| 1576 } |
| 1577 }; |
| 1578 dart.setSignature(src__simple_configuration.SimpleConfiguration, { |
| 1579 constructors: () => ({SimpleConfiguration: [src__simple_configuration.Simple
Configuration, []]}), |
| 1580 methods: () => ({ |
| 1581 onExpectFailure: [dart.void, [core.String]], |
| 1582 formatResult: [core.String, [src__test_case.TestCase]], |
| 1583 [_postMessage]: [dart.void, [core.String]] |
| 1584 }) |
| 1585 }); |
| 1586 unittest.SimpleConfiguration = src__simple_configuration.SimpleConfiguration; |
| 1587 src__test_case.TestCase = class TestCase extends core.Object { |
143 get isComplete() { | 1588 get isComplete() { |
144 return !dart.notNull(this.enabled) || this.result != null; | 1589 return !dart.notNull(this.enabled) || this.result != null; |
145 } | 1590 } |
146 }; | 1591 }; |
147 unittest.ErrorFormatter = dart.typedef('ErrorFormatter', () => dart.functionTy
pe(core.String, [dart.dynamic, src__interfaces.Matcher, core.String, core.Map, c
ore.bool])); | 1592 unittest.TestCase = src__test_case.TestCase; |
148 unittest.expect = function(actual, matcher, opts) { | 1593 vm_config.VMConfiguration = class VMConfiguration extends src__simple_configur
ation.SimpleConfiguration { |
149 let reason = opts && 'reason' in opts ? opts.reason : null; | 1594 VMConfiguration() { |
150 let verbose = opts && 'verbose' in opts ? opts.verbose : false; | 1595 this.useColor = dart.equals(io.stdioType(io.stdout), io.StdioType.TERMINAL
); |
151 let formatter = opts && 'formatter' in opts ? opts.formatter : null; | 1596 this.GREEN_COLOR = '[32m'; |
152 matcher = src__util.wrapMatcher(matcher); | 1597 this.RED_COLOR = '[31m'; |
153 let matchState = dart.map(); | 1598 this.MAGENTA_COLOR = '[35m'; |
| 1599 this.NO_COLOR = '[0m'; |
| 1600 super.SimpleConfiguration(); |
| 1601 } |
| 1602 formatResult(testCase) { |
| 1603 let result = super.formatResult(testCase); |
| 1604 if (dart.notNull(this.useColor)) { |
| 1605 if (testCase.result == unittest.PASS) { |
| 1606 return `${this.GREEN_COLOR}${result}${this.NO_COLOR}`; |
| 1607 } else if (testCase.result == unittest.FAIL) { |
| 1608 return `${this.RED_COLOR}${result}${this.NO_COLOR}`; |
| 1609 } else if (testCase.result == unittest.ERROR) { |
| 1610 return `${this.MAGENTA_COLOR}${result}${this.NO_COLOR}`; |
| 1611 } |
| 1612 } |
| 1613 return result; |
| 1614 } |
| 1615 onInit() { |
| 1616 super.onInit(); |
| 1617 unittest.filterStacks = unittest.formatStacks = true; |
| 1618 } |
| 1619 onDone(success) { |
| 1620 let status = null; |
| 1621 try { |
| 1622 super.onDone(success); |
| 1623 status = 0; |
| 1624 } catch (ex) { |
| 1625 status = 1; |
| 1626 } |
| 1627 |
| 1628 async.Future.wait(dart.dynamic)(dart.list([io.stdout.close(), io.stderr.cl
ose()], async.Future)).then(dart.dynamic)(dart.fn(_ => { |
| 1629 io.exit(status); |
| 1630 }, dart.dynamic, [core.List])); |
| 1631 } |
| 1632 }; |
| 1633 dart.setSignature(vm_config.VMConfiguration, { |
| 1634 constructors: () => ({VMConfiguration: [vm_config.VMConfiguration, []]}) |
| 1635 }); |
| 1636 vm_config.useVMConfiguration = function() { |
| 1637 unittest.unittestConfiguration = vm_config._singleton; |
| 1638 }; |
| 1639 dart.fn(vm_config.useVMConfiguration, dart.void, []); |
| 1640 dart.defineLazy(vm_config, { |
| 1641 get _singleton() { |
| 1642 return new vm_config.VMConfiguration(); |
| 1643 } |
| 1644 }); |
| 1645 const _isLayoutTest = Symbol('_isLayoutTest'); |
| 1646 const _onErrorSubscription = Symbol('_onErrorSubscription'); |
| 1647 const _onMessageSubscription = Symbol('_onMessageSubscription'); |
| 1648 const _installOnErrorHandler = Symbol('_installOnErrorHandler'); |
| 1649 const _installOnMessageHandler = Symbol('_installOnMessageHandler'); |
| 1650 const _installHandlers = Symbol('_installHandlers'); |
| 1651 const _uninstallHandlers = Symbol('_uninstallHandlers'); |
| 1652 const _htmlTestCSS = Symbol('_htmlTestCSS'); |
| 1653 const _showInteractiveResultsInPage = Symbol('_showInteractiveResultsInPage'); |
| 1654 const _buildRow = Symbol('_buildRow'); |
| 1655 html_enhanced_config.HtmlEnhancedConfiguration = class HtmlEnhancedConfigurati
on extends src__simple_configuration.SimpleConfiguration { |
| 1656 HtmlEnhancedConfiguration(isLayoutTest) { |
| 1657 this[_isLayoutTest] = isLayoutTest; |
| 1658 this[_onErrorSubscription] = null; |
| 1659 this[_onMessageSubscription] = null; |
| 1660 super.SimpleConfiguration(); |
| 1661 } |
| 1662 [_installOnErrorHandler]() { |
| 1663 if (this[_onErrorSubscription] == null) { |
| 1664 this[_onErrorSubscription] = html.window[dartx.onError].listen(dart.fn(e
=> unittest.handleExternalError(e, '(DOM callback has errors)'), dart.void, [ht
ml.Event])); |
| 1665 } |
| 1666 } |
| 1667 [_installOnMessageHandler]() { |
| 1668 if (this[_onMessageSubscription] == null) { |
| 1669 this[_onMessageSubscription] = html.window[dartx.onMessage].listen(dart.
fn(e => this.processMessage(e), dart.void, [html.MessageEvent])); |
| 1670 } |
| 1671 } |
| 1672 [_installHandlers]() { |
| 1673 this[_installOnErrorHandler](); |
| 1674 this[_installOnMessageHandler](); |
| 1675 } |
| 1676 [_uninstallHandlers]() { |
| 1677 if (this[_onErrorSubscription] != null) { |
| 1678 dart.dsend(this[_onErrorSubscription], 'cancel'); |
| 1679 this[_onErrorSubscription] = null; |
| 1680 } |
| 1681 if (this[_onMessageSubscription] != null) { |
| 1682 dart.dsend(this[_onMessageSubscription], 'cancel'); |
| 1683 this[_onMessageSubscription] = null; |
| 1684 } |
| 1685 } |
| 1686 processMessage(e) { |
| 1687 if (dart.equals('unittest-suite-external-error', dart.dload(e, 'data'))) { |
| 1688 unittest.handleExternalError('<unknown>', '(external error detected)'); |
| 1689 } |
| 1690 } |
| 1691 onInit() { |
| 1692 this[_installHandlers](); |
| 1693 let _CSSID = '_unittestcss_'; |
| 1694 let cssElement = html.document[dartx.head][dartx.querySelector](`#${_CSSID
}`); |
| 1695 if (cssElement == null) { |
| 1696 cssElement = html.StyleElement.new(); |
| 1697 cssElement[dartx.id] = _CSSID; |
| 1698 html.document[dartx.head][dartx.append](cssElement); |
| 1699 } |
| 1700 cssElement[dartx.text] = this[_htmlTestCSS]; |
| 1701 html.window[dartx.postMessage]('unittest-suite-wait-for-done', '*'); |
| 1702 } |
| 1703 onStart() { |
| 1704 this[_installOnErrorHandler](); |
| 1705 } |
| 1706 onSummary(passed, failed, errors, results, uncaughtError) { |
| 1707 this[_showInteractiveResultsInPage](passed, failed, errors, results, this[
_isLayoutTest], uncaughtError); |
| 1708 } |
| 1709 onDone(success) { |
| 1710 this[_uninstallHandlers](); |
| 1711 html.window[dartx.postMessage]('unittest-suite-done', '*'); |
| 1712 } |
| 1713 [_showInteractiveResultsInPage](passed, failed, errors, results, isLayoutTes
t, uncaughtError) { |
| 1714 if (dart.notNull(isLayoutTest) && passed == results[dartx.length]) { |
| 1715 html.document[dartx.body][dartx.innerHtml] = "PASS"; |
| 1716 } else { |
| 1717 let te = html.Element.html('<div class="unittest-table"></div>'); |
| 1718 te[dartx.children][dartx.add](html.Element.html(passed == results[dartx.
length] ? "<div class='unittest-overall unittest-pass'>PASS</div>" : "<div class
='unittest-overall unittest-fail'>FAIL</div>")); |
| 1719 if (passed == results[dartx.length] && uncaughtError == null) { |
| 1720 te[dartx.children][dartx.add](html.Element.html(` <div class=
'unittest-pass'>All ${passed} tests passed</div>`)); |
| 1721 } else { |
| 1722 if (uncaughtError != null) { |
| 1723 te[dartx.children][dartx.add](html.Element.html(` <div cl
ass='unittest-summary'>\n <span class='unittest-error'>Uncaught err
or: ${uncaughtError}</span>\n </div>`)); |
| 1724 } |
| 1725 te[dartx.children][dartx.add](html.Element.html(` <div class=
'unittest-summary'>\n <span class='unittest-pass'>Total ${passed} pas
sed</span>,\n <span class='unittest-fail'>${failed} failed</span>,\n
<span class='unittest-error'>\n ${dart.notNull(errors) + (
uncaughtError == null ? 0 : 1)} errors</span>\n </div>`)); |
| 1726 } |
| 1727 te[dartx.children][dartx.add](html.Element.html(" <div><button id
='btnCollapseAll'>Collapse All</button></div>\n ")); |
| 1728 te[dartx.querySelector]('#btnCollapseAll')[dartx.onClick].listen(dart.fn
(_ => { |
| 1729 html.document[dartx.querySelectorAll](html.Element)('.unittest-row').f
orEach(dart.fn(el => el[dartx.attributes][dartx.set]('class', el[dartx.attribute
s][dartx.get]('class')[dartx.replaceAll]('unittest-row ', 'unittest-row-hidden '
)), core.String, [html.Element])); |
| 1730 }, dart.void, [html.MouseEvent])); |
| 1731 let previousGroup = ''; |
| 1732 let groupPassFail = true; |
| 1733 let groupedBy = collection.LinkedHashMap$(core.String, core.List$(src__t
est_case.TestCase)).new(); |
| 1734 for (let t of results) { |
| 1735 if (!dart.notNull(groupedBy.containsKey(t.currentGroup))) { |
| 1736 groupedBy.set(t.currentGroup, core.List$(src__test_case.TestCase).ne
w()); |
| 1737 } |
| 1738 groupedBy.get(t.currentGroup)[dartx.add](t); |
| 1739 } |
| 1740 let flattened = core.List$(src__test_case.TestCase).new(); |
| 1741 groupedBy.values[dartx.forEach](dart.fn(tList => { |
| 1742 tList[dartx.sort](dart.fn((tcA, tcB) => dart.notNull(tcA.id) - dart.no
tNull(tcB.id), core.int, [src__test_case.TestCase, src__test_case.TestCase])); |
| 1743 flattened[dartx.addAll](tList); |
| 1744 }, dart.void, [core.List$(src__test_case.TestCase)])); |
| 1745 let nonAlphanumeric = core.RegExp.new('[^a-z0-9A-Z]'); |
| 1746 for (let test_ of flattened) { |
| 1747 let safeGroup = test_.currentGroup[dartx.replaceAll](nonAlphanumeric,
'_'); |
| 1748 if (test_.currentGroup != previousGroup) { |
| 1749 previousGroup = test_.currentGroup; |
| 1750 let testsInGroup = results[dartx.where](dart.fn(t => t.currentGroup
== previousGroup, core.bool, [src__test_case.TestCase]))[dartx.toList](); |
| 1751 let groupTotalTestCount = testsInGroup[dartx.length]; |
| 1752 let groupTestPassedCount = testsInGroup[dartx.where](dart.fn(t => t.
result == 'pass', core.bool, [src__test_case.TestCase]))[dartx.length]; |
| 1753 groupPassFail = groupTotalTestCount == groupTestPassedCount; |
| 1754 let passFailClass = "unittest-group-status unittest-group-" + `statu
s-${groupPassFail ? 'pass' : 'fail'}`; |
| 1755 te[dartx.children][dartx.add](html.Element.html(` <div>\n
<div id='${safeGroup}'\n class='unittest-group $
{safeGroup} test${safeGroup}'>\n <div ${dart.notNull(html_enhance
d_config.HtmlEnhancedConfiguration._isIE) ? "style='display:inline-block' " : ""
}\n class='unittest-row-status'>\n <div cla
ss='${passFailClass}'></div>\n </div>\n <div ${dar
t.notNull(html_enhanced_config.HtmlEnhancedConfiguration._isIE) ? "style='displa
y:inline-block' " : ""}>\n ${test_.currentGroup}</div>\n
\n <div ${dart.notNull(html_enhanced_config.Html
EnhancedConfiguration._isIE) ? "style='display:inline-block' " : ""}>\n
(${groupTestPassedCount}/${groupTotalTestCount})</div>\n
</div>\n </div>`)); |
| 1756 let grp = safeGroup == '' ? null : te[dartx.querySelector](`#${safeG
roup}`); |
| 1757 if (grp != null) { |
| 1758 grp[dartx.onClick].listen(dart.fn(_ => { |
| 1759 let row = html.document[dartx.querySelector](`.unittest-row-${sa
feGroup}`); |
| 1760 if (dart.notNull(row[dartx.attributes][dartx.get]('class')[dartx
.contains]('unittest-row '))) { |
| 1761 html.document[dartx.querySelectorAll](html.Element)(`.unittest
-row-${safeGroup}`).forEach(dart.fn(e => e[dartx.attributes][dartx.set]('class',
e[dartx.attributes][dartx.get]('class')[dartx.replaceAll]('unittest-row ', 'uni
ttest-row-hidden ')), core.String, [html.Element])); |
| 1762 } else { |
| 1763 html.document[dartx.querySelectorAll](html.Element)(`.unittest
-row-${safeGroup}`).forEach(dart.fn(e => e[dartx.attributes][dartx.set]('class',
e[dartx.attributes][dartx.get]('class')[dartx.replaceAll]('unittest-row-hidden'
, 'unittest-row')), core.String, [html.Element])); |
| 1764 } |
| 1765 }, dart.void, [html.MouseEvent])); |
| 1766 } |
| 1767 } |
| 1768 this[_buildRow](test_, te, safeGroup, !groupPassFail); |
| 1769 } |
| 1770 html.document[dartx.body][dartx.children][dartx.clear](); |
| 1771 html.document[dartx.body][dartx.children][dartx.add](te); |
| 1772 } |
| 1773 } |
| 1774 [_buildRow](test_, te, groupID, isVisible) { |
| 1775 let background = `unittest-row-${test_.id[dartx['%']](2) == 0 ? "even" : "
odd"}`; |
| 1776 let display = `${dart.notNull(isVisible) ? "unittest-row" : "unittest-row-
hidden"}`; |
| 1777 function addRowElement(id, status, description) { |
| 1778 te[dartx.children][dartx.add](html.Element.html(` <div>\n
<div class='${display} unittest-row-${groupID} ${background}'>\n
<div ${dart.notNull(html_enhanced_config.HtmlEnhancedConfiguration._isIE) ? "
style='display:inline-block' " : ""}\n class='unittest-row
-id'>${id}</div>\n <div ${dart.notNull(html_enhanced_config.Htm
lEnhancedConfiguration._isIE) ? "style='display:inline-block' " : ""}\n
class="unittest-row-status unittest-${test_.result}">\n
${status}</div>\n <div ${dart.notNull(html_enhanced
_config.HtmlEnhancedConfiguration._isIE) ? "style='display:inline-block' " : ""}
\n class='unittest-row-description'>${description}</div>\n
</div>\n </div>`)); |
| 1779 } |
| 1780 dart.fn(addRowElement); |
| 1781 if (!dart.notNull(test_.isComplete)) { |
| 1782 addRowElement(`${test_.id}`, 'NO STATUS', 'Test did not complete.'); |
| 1783 return; |
| 1784 } |
| 1785 addRowElement(`${test_.id}`, `${test_.result[dartx.toUpperCase]()}`, `${te
st_.description}. ${convert.HTML_ESCAPE.convert(test_.message)}`); |
| 1786 if (test_.stackTrace != null) { |
| 1787 addRowElement('', '', `<pre>${convert.HTML_ESCAPE.convert(dart.toString(
test_.stackTrace))}</pre>`); |
| 1788 } |
| 1789 } |
| 1790 static get _isIE() { |
| 1791 return html.window[dartx.navigator][dartx.userAgent][dartx.contains]('MSIE
'); |
| 1792 } |
| 1793 get [_htmlTestCSS]() { |
| 1794 return ' body{\n font-size: 14px;\n font-family: \'Open Sans\', \'L
ucida Sans Unicode\', \'Lucida Grande\',' + ` sans-serif;\n background: White
Smoke;\n }\n\n .unittest-group\n {\n background: rgb(75,75,75);\n width
:98%;\n color: WhiteSmoke;\n font-weight: bold;\n padding: 6px;\n cu
rsor: pointer;\n\n /* Provide some visual separation between groups for IE */
\n ${dart.notNull(html_enhanced_config.HtmlEnhancedConfiguration._isIE) ? "bo
rder-bottom:solid black 1px;" : ""}\n ${dart.notNull(html_enhanced_config.Htm
lEnhancedConfiguration._isIE) ? "border-top:solid #777777 1px;" : ""}\n\n bac
kground-image: -webkit-linear-gradient(bottom, rgb(50,50,50) 0%, ` + 'rgb(100,10
0,100) 100%);\n background-image: -moz-linear-gradient(bottom, rgb(50,50,50)
0%, ' + 'rgb(100,100,100) 100%);\n background-image: -ms-linear-gradient(bott
om, rgb(50,50,50) 0%, ' + 'rgb(100,100,100) 100%);\n background-image: linear
-gradient(bottom, rgb(50,50,50) 0%, ' + 'rgb(100,100,100) 100%);\n\n display:
-webkit-box;\n display: -moz-box;\n display: -ms-box;\n display: box;\
n\n -webkit-box-orient: horizontal;\n -moz-box-orient: horizontal;\n -m
s-box-orient: horizontal;\n box-orient: horizontal;\n\n -webkit-box-align:
center;\n -moz-box-align: center;\n -ms-box-align: center;\n box-align
: center;\n }\n\n .unittest-group-status\n {\n width: 20px;\n height:
20px;\n border-radius: 20px;\n margin-left: 10px;\n }\n\n .unittest-grou
p-status-pass{\n background: Green;\n background: ' + '-webkit-radial-grad
ient(center, ellipse cover, #AAFFAA 0%,Green 100%);\n background: ' + '-moz-r
adial-gradient(center, ellipse cover, #AAFFAA 0%,Green 100%);\n background: '
+ '-ms-radial-gradient(center, ellipse cover, #AAFFAA 0%,Green 100%);\n back
ground: ' + 'radial-gradient(center, ellipse cover, #AAFFAA 0%,Green 100%);\n }
\n\n .unittest-group-status-fail{\n background: Red;\n background: ' + '-
webkit-radial-gradient(center, ellipse cover, #FFAAAA 0%,Red 100%);\n backgro
und: ' + '-moz-radial-gradient(center, ellipse cover, #FFAAAA 0%,Red 100%);\n
background: ' + '-ms-radial-gradient(center, ellipse cover, #AAFFAA 0%,Green 10
0%);\n background: radial-gradient(center, ellipse cover, #FFAAAA 0%,Red 100%
);\n }\n\n .unittest-overall{\n font-size: 20px;\n }\n\n .unittest-summar
y{\n font-size: 18px;\n }\n\n .unittest-pass{\n color: Green;\n }\n\n
.unittest-fail, .unittest-error\n {\n color: Red;\n }\n\n .unittest-row\n
{\n display: -webkit-box;\n display: -moz-box;\n display: -ms-box;\n
display: box;\n -webkit-box-orient: horizontal;\n -moz-box-orient: horiz
ontal;\n -ms-box-orient: horizontal;\n box-orient: horizontal;\n width:
100%;\n }\n\n .unittest-row-hidden\n {\n display: none;\n }\n\n .unitte
st-row-odd\n {\n background: WhiteSmoke;\n }\n\n .unittest-row-even\n {\n
background: #E5E5E5;\n }\n\n .unittest-row-id\n {\n width: 3em;\n }\n
\n .unittest-row-status\n {\n width: 4em;\n }\n\n .unittest-row-descripti
on\n {\n }\n\n '; |
| 1795 } |
| 1796 }; |
| 1797 dart.setSignature(html_enhanced_config.HtmlEnhancedConfiguration, { |
| 1798 constructors: () => ({HtmlEnhancedConfiguration: [html_enhanced_config.HtmlE
nhancedConfiguration, [core.bool]]}), |
| 1799 methods: () => ({ |
| 1800 [_installOnErrorHandler]: [dart.void, []], |
| 1801 [_installOnMessageHandler]: [dart.void, []], |
| 1802 [_installHandlers]: [dart.void, []], |
| 1803 [_uninstallHandlers]: [dart.void, []], |
| 1804 processMessage: [dart.void, [dart.dynamic]], |
| 1805 [_showInteractiveResultsInPage]: [dart.void, [core.int, core.int, core.int
, core.List$(src__test_case.TestCase), core.bool, core.String]], |
| 1806 [_buildRow]: [dart.void, [src__test_case.TestCase, html.Element, core.Stri
ng, core.bool]] |
| 1807 }) |
| 1808 }); |
| 1809 html_enhanced_config.useHtmlEnhancedConfiguration = function(isLayoutTest) { |
| 1810 if (isLayoutTest === void 0) isLayoutTest = false; |
| 1811 unittest.unittestConfiguration = dart.notNull(isLayoutTest) ? html_enhanced_
config._singletonLayout : html_enhanced_config._singletonNotLayout; |
| 1812 }; |
| 1813 dart.fn(html_enhanced_config.useHtmlEnhancedConfiguration, dart.void, [], [cor
e.bool]); |
| 1814 dart.defineLazy(html_enhanced_config, { |
| 1815 get _singletonLayout() { |
| 1816 return new html_enhanced_config.HtmlEnhancedConfiguration(true); |
| 1817 } |
| 1818 }); |
| 1819 dart.defineLazy(html_enhanced_config, { |
| 1820 get _singletonNotLayout() { |
| 1821 return new html_enhanced_config.HtmlEnhancedConfiguration(false); |
| 1822 } |
| 1823 }); |
| 1824 const _isLayoutTest$ = Symbol('_isLayoutTest'); |
| 1825 const _onErrorSubscription$ = Symbol('_onErrorSubscription'); |
| 1826 const _onMessageSubscription$ = Symbol('_onMessageSubscription'); |
| 1827 const _installHandlers$ = Symbol('_installHandlers'); |
| 1828 const _uninstallHandlers$ = Symbol('_uninstallHandlers'); |
| 1829 html_config.HtmlConfiguration = class HtmlConfiguration extends src__simple_co
nfiguration.SimpleConfiguration { |
| 1830 HtmlConfiguration(isLayoutTest) { |
| 1831 this[_isLayoutTest$] = isLayoutTest; |
| 1832 this[_onErrorSubscription$] = null; |
| 1833 this[_onMessageSubscription$] = null; |
| 1834 super.SimpleConfiguration(); |
| 1835 } |
| 1836 [_installHandlers$]() { |
| 1837 if (this[_onErrorSubscription$] == null) { |
| 1838 this[_onErrorSubscription$] = html.window[dartx.onError].listen(dart.fn(
e => { |
| 1839 if (!dart.equals(js.context.get('testExpectsGlobalError'), true)) { |
| 1840 unittest.handleExternalError(e, '(DOM callback has errors)'); |
| 1841 } |
| 1842 }, dart.void, [html.Event])); |
| 1843 } |
| 1844 if (this[_onMessageSubscription$] == null) { |
| 1845 this[_onMessageSubscription$] = html.window[dartx.onMessage].listen(dart
.fn(e => this.processMessage(e), dart.void, [html.MessageEvent])); |
| 1846 } |
| 1847 } |
| 1848 [_uninstallHandlers$]() { |
| 1849 if (this[_onErrorSubscription$] != null) { |
| 1850 this[_onErrorSubscription$].cancel(); |
| 1851 this[_onErrorSubscription$] = null; |
| 1852 } |
| 1853 if (this[_onMessageSubscription$] != null) { |
| 1854 this[_onMessageSubscription$].cancel(); |
| 1855 this[_onMessageSubscription$] = null; |
| 1856 } |
| 1857 } |
| 1858 processMessage(e) { |
| 1859 if (dart.equals('unittest-suite-external-error', dart.dload(e, 'data'))) { |
| 1860 unittest.handleExternalError('<unknown>', '(external error detected)'); |
| 1861 } |
| 1862 } |
| 1863 onInit() { |
| 1864 let meta = dart.as(html.querySelector('meta[name="dart.unittest"]'), html.
MetaElement); |
| 1865 unittest.filterStacks = meta == null ? true : !dart.notNull(meta[dartx.con
tent][dartx.contains]('full-stack-traces')); |
| 1866 this[_installHandlers$](); |
| 1867 html.window[dartx.postMessage]('unittest-suite-wait-for-done', '*'); |
| 1868 } |
| 1869 onStart() { |
| 1870 let hash = html.window[dartx.location][dartx.hash]; |
| 1871 if (hash != null && dart.notNull(hash[dartx.length]) > 1) { |
| 1872 let params = hash[dartx.substring](1)[dartx.split]('&'); |
| 1873 for (let param of params) { |
| 1874 let parts = param[dartx.split]('='); |
| 1875 if (parts[dartx.length] == 2 && parts[dartx.get](0) == 'testFilter') { |
| 1876 unittest.filterTests(`^${parts[dartx.get](1)}`); |
| 1877 } |
| 1878 } |
| 1879 } |
| 1880 super.onStart(); |
| 1881 } |
| 1882 onSummary(passed, failed, errors, results, uncaughtError) { |
| 1883 html_config._showResultsInPage(passed, failed, errors, results, this[_isLa
youtTest$], uncaughtError); |
| 1884 } |
| 1885 onDone(success) { |
| 1886 this[_uninstallHandlers$](); |
| 1887 html.window[dartx.postMessage]('unittest-suite-done', '*'); |
| 1888 } |
| 1889 }; |
| 1890 dart.setSignature(html_config.HtmlConfiguration, { |
| 1891 constructors: () => ({HtmlConfiguration: [html_config.HtmlConfiguration, [co
re.bool]]}), |
| 1892 methods: () => ({ |
| 1893 [_installHandlers$]: [dart.void, []], |
| 1894 [_uninstallHandlers$]: [dart.void, []], |
| 1895 processMessage: [dart.void, [dart.dynamic]] |
| 1896 }) |
| 1897 }); |
| 1898 html_individual_config.HtmlIndividualConfiguration = class HtmlIndividualConfi
guration extends html_config.HtmlConfiguration { |
| 1899 HtmlIndividualConfiguration(isLayoutTest) { |
| 1900 super.HtmlConfiguration(isLayoutTest); |
| 1901 } |
| 1902 onStart() { |
| 1903 let uri = core.Uri.parse(html.window[dartx.location][dartx.href]); |
| 1904 let groups = 'group='[dartx.allMatches](uri.query)[dartx.toList](); |
| 1905 if (dart.notNull(groups[dartx.length]) > 1) { |
| 1906 dart.throw(new core.ArgumentError('More than one "group" parameter provi
ded.')); |
| 1907 } |
| 1908 let testGroupName = uri.queryParameters[dartx.get]('group'); |
| 1909 if (testGroupName != null) { |
| 1910 let startsWith = `${testGroupName}${unittest.groupSep}`; |
| 1911 unittest.filterTests(dart.fn(tc => tc.description[dartx.startsWith](star
tsWith), core.bool, [src__test_case.TestCase])); |
| 1912 } |
| 1913 super.onStart(); |
| 1914 } |
| 1915 }; |
| 1916 dart.setSignature(html_individual_config.HtmlIndividualConfiguration, { |
| 1917 constructors: () => ({HtmlIndividualConfiguration: [html_individual_config.H
tmlIndividualConfiguration, [core.bool]]}) |
| 1918 }); |
| 1919 html_individual_config.useHtmlIndividualConfiguration = function(isLayoutTest)
{ |
| 1920 if (isLayoutTest === void 0) isLayoutTest = false; |
| 1921 unittest.unittestConfiguration = dart.notNull(isLayoutTest) ? html_individua
l_config._singletonLayout : html_individual_config._singletonNotLayout; |
| 1922 }; |
| 1923 dart.fn(html_individual_config.useHtmlIndividualConfiguration, dart.void, [],
[core.bool]); |
| 1924 dart.defineLazy(html_individual_config, { |
| 1925 get _singletonLayout() { |
| 1926 return new html_individual_config.HtmlIndividualConfiguration(true); |
| 1927 } |
| 1928 }); |
| 1929 dart.defineLazy(html_individual_config, { |
| 1930 get _singletonNotLayout() { |
| 1931 return new html_individual_config.HtmlIndividualConfiguration(false); |
| 1932 } |
| 1933 }); |
| 1934 const _config = Symbol('_config'); |
| 1935 src__simple_configuration._ExpectFailureHandler = class _ExpectFailureHandler
extends src__matcher__expect.DefaultFailureHandler { |
| 1936 _ExpectFailureHandler(config) { |
| 1937 this[_config] = config; |
| 1938 super.DefaultFailureHandler(); |
| 1939 } |
| 1940 fail(reason) { |
| 1941 this[_config].onExpectFailure(reason); |
| 1942 } |
| 1943 }; |
| 1944 dart.setSignature(src__simple_configuration._ExpectFailureHandler, { |
| 1945 constructors: () => ({_ExpectFailureHandler: [src__simple_configuration._Exp
ectFailureHandler, [src__simple_configuration.SimpleConfiguration]]}) |
| 1946 }); |
| 1947 const _testSetUp = Symbol('_testSetUp'); |
| 1948 const _testTearDown = Symbol('_testTearDown'); |
| 1949 const _name$ = Symbol('_name'); |
| 1950 src__group_context.GroupContext = class GroupContext extends core.Object { |
| 1951 get isRoot() { |
| 1952 return this.parent == null; |
| 1953 } |
| 1954 get testSetUp() { |
| 1955 return this[_testSetUp]; |
| 1956 } |
| 1957 set testSetUp(setUp) { |
| 1958 if (this.parent == null || this.parent.testSetUp == null) { |
| 1959 this[_testSetUp] = setUp; |
| 1960 return; |
| 1961 } |
| 1962 this[_testSetUp] = dart.fn(() => { |
| 1963 let f = dart.dcall(this.parent.testSetUp); |
| 1964 if (dart.is(f, async.Future)) { |
| 1965 return f.then(dart.dynamic)(dart.fn(_ => dart.dcall(setUp))); |
| 1966 } else { |
| 1967 return dart.dcall(setUp); |
| 1968 } |
| 1969 }); |
| 1970 } |
| 1971 get testTearDown() { |
| 1972 return this[_testTearDown]; |
| 1973 } |
| 1974 set testTearDown(tearDown) { |
| 1975 if (this.parent == null || this.parent.testTearDown == null) { |
| 1976 this[_testTearDown] = tearDown; |
| 1977 return; |
| 1978 } |
| 1979 this[_testTearDown] = dart.fn(() => { |
| 1980 let f = dart.dcall(tearDown); |
| 1981 if (dart.is(f, async.Future)) { |
| 1982 return f.then(dart.dynamic)(dart.fn(_ => dart.dcall(this.parent.testTe
arDown))); |
| 1983 } else { |
| 1984 return dart.dcall(this.parent.testTearDown); |
| 1985 } |
| 1986 }); |
| 1987 } |
| 1988 get fullName() { |
| 1989 return dart.notNull(this.isRoot) || dart.notNull(this.parent.isRoot) ? thi
s[_name$] : `${this.parent.fullName}${unittest.groupSep}${this[_name$]}`; |
| 1990 } |
| 1991 root() { |
| 1992 this.parent = null; |
| 1993 this[_name$] = ''; |
| 1994 this[_testSetUp] = null; |
| 1995 this[_testTearDown] = null; |
| 1996 } |
| 1997 GroupContext(parent, name) { |
| 1998 this.parent = parent; |
| 1999 this[_name$] = name; |
| 2000 this[_testSetUp] = null; |
| 2001 this[_testTearDown] = null; |
| 2002 this[_testSetUp] = this.parent.testSetUp; |
| 2003 this[_testTearDown] = this.parent.testTearDown; |
| 2004 } |
| 2005 }; |
| 2006 dart.defineNamedConstructor(src__group_context.GroupContext, 'root'); |
| 2007 dart.setSignature(src__group_context.GroupContext, { |
| 2008 constructors: () => ({ |
| 2009 root: [src__group_context.GroupContext, []], |
| 2010 GroupContext: [src__group_context.GroupContext, [src__group_context.GroupC
ontext, core.String]] |
| 2011 }) |
| 2012 }); |
| 2013 src__utils.indent = function(str) { |
| 2014 return str[dartx.replaceAll](core.RegExp.new("^", {multiLine: true}), " "); |
| 2015 }; |
| 2016 dart.fn(src__utils.indent, core.String, [core.String]); |
| 2017 src__utils.Pair$ = dart.generic((E, F) => { |
| 2018 class Pair extends core.Object { |
| 2019 Pair(first, last) { |
| 2020 this.first = first; |
| 2021 this.last = last; |
| 2022 } |
| 2023 toString() { |
| 2024 return `(${this.first}, ${this.last})`; |
| 2025 } |
| 2026 ['=='](other) { |
| 2027 if (!dart.is(other, src__utils.Pair)) return false; |
| 2028 return dart.equals(dart.dload(other, 'first'), this.first) && dart.equal
s(dart.dload(other, 'last'), this.last); |
| 2029 } |
| 2030 get hashCode() { |
| 2031 return (dart.notNull(dart.hashCode(this.first)) ^ dart.notNull(dart.hash
Code(this.last))) >>> 0; |
| 2032 } |
| 2033 } |
| 2034 dart.setSignature(Pair, { |
| 2035 constructors: () => ({Pair: [src__utils.Pair$(E, F), [E, F]]}) |
| 2036 }); |
| 2037 return Pair; |
| 2038 }); |
| 2039 src__utils.Pair = src__utils.Pair$(); |
| 2040 src__utils.getTrace = function(stack, formatStacks, filterStacks) { |
| 2041 let trace = null; |
| 2042 if (stack == null || !dart.notNull(formatStacks)) return null; |
| 2043 if (typeof stack == 'string') { |
| 2044 trace = src__trace.Trace.parse(stack); |
| 2045 } else if (dart.is(stack, core.StackTrace)) { |
| 2046 trace = src__trace.Trace.from(stack); |
| 2047 } else { |
| 2048 dart.throw(core.Exception.new(`Invalid stack type ${dart.runtimeType(stack
)} for ${stack}.`)); |
| 2049 } |
| 2050 if (!dart.notNull(filterStacks)) return trace; |
| 2051 return new src__trace.Trace(trace.frames[dartx.takeWhile](dart.fn(frame => f
rame.package != 'unittest' || frame.member != 'TestCase._runTest', core.bool, [s
rc__frame.Frame]))).terse.foldFrames(dart.fn(frame => frame.package == 'unittest
' || dart.notNull(frame.isCore), core.bool, [src__frame.Frame])); |
| 2052 }; |
| 2053 dart.fn(src__utils.getTrace, src__trace.Trace, [dart.dynamic, core.bool, core.
bool]); |
| 2054 src__matcher.isTrue = src__matcher__core_matchers.isTrue; |
| 2055 src__matcher.isFalse = src__matcher__core_matchers.isFalse; |
| 2056 src__matcher.isEmpty = src__matcher__core_matchers.isEmpty; |
| 2057 src__matcher.same = src__matcher__core_matchers.same; |
| 2058 src__matcher.equals = src__matcher__core_matchers.equals; |
| 2059 src__matcher.CustomMatcher = src__matcher__core_matchers.CustomMatcher; |
| 2060 src__matcher.isList = src__matcher__core_matchers.isList; |
| 2061 src__matcher.predicate = src__matcher__core_matchers.predicate; |
| 2062 src__matcher.isNotNull = src__matcher__core_matchers.isNotNull; |
| 2063 src__matcher.hasLength = src__matcher__core_matchers.hasLength; |
| 2064 src__matcher.isInstanceOf$ = src__matcher__core_matchers.isInstanceOf$; |
| 2065 src__matcher.isInstanceOf = src__matcher__core_matchers.isInstanceOf; |
| 2066 src__matcher.isNaN = src__matcher__core_matchers.isNaN; |
| 2067 src__matcher.returnsNormally = src__matcher__core_matchers.returnsNormally; |
| 2068 src__matcher.anything = src__matcher__core_matchers.anything; |
| 2069 src__matcher.TypeMatcher = src__matcher__core_matchers.TypeMatcher; |
| 2070 src__matcher.contains = src__matcher__core_matchers.contains; |
| 2071 src__matcher.isNotEmpty = src__matcher__core_matchers.isNotEmpty; |
| 2072 src__matcher.isNull = src__matcher__core_matchers.isNull; |
| 2073 src__matcher.isMap = src__matcher__core_matchers.isMap; |
| 2074 src__matcher.isNotNaN = src__matcher__core_matchers.isNotNaN; |
| 2075 src__matcher.isIn = src__matcher__core_matchers.isIn; |
| 2076 src__matcher.StringDescription = src__matcher__description.StringDescription; |
| 2077 src__matcher.isConcurrentModificationError = src__matcher__error_matchers.isCo
ncurrentModificationError; |
| 2078 src__matcher.isCyclicInitializationError = src__matcher__error_matchers.isCycl
icInitializationError; |
| 2079 src__matcher.isArgumentError = src__matcher__error_matchers.isArgumentError; |
| 2080 src__matcher.isException = src__matcher__error_matchers.isException; |
| 2081 src__matcher.isNullThrownError = src__matcher__error_matchers.isNullThrownErro
r; |
| 2082 src__matcher.isRangeError = src__matcher__error_matchers.isRangeError; |
| 2083 src__matcher.isFormatException = src__matcher__error_matchers.isFormatExceptio
n; |
| 2084 src__matcher.isStateError = src__matcher__error_matchers.isStateError; |
| 2085 src__matcher.isNoSuchMethodError = src__matcher__error_matchers.isNoSuchMethod
Error; |
| 2086 src__matcher.isUnimplementedError = src__matcher__error_matchers.isUnimplement
edError; |
| 2087 src__matcher.isUnsupportedError = src__matcher__error_matchers.isUnsupportedEr
ror; |
| 2088 src__matcher.TestFailure = src__matcher__expect.TestFailure; |
| 2089 src__matcher.configureExpectFormatter = src__matcher__expect.configureExpectFo
rmatter; |
| 2090 src__matcher.DefaultFailureHandler = src__matcher__expect.DefaultFailureHandle
r; |
| 2091 src__matcher.fail = src__matcher__expect.fail; |
| 2092 src__matcher.ErrorFormatter = src__matcher__expect.ErrorFormatter; |
| 2093 dart.export(src__matcher, src__matcher__expect, 'wrapAsync'); |
| 2094 dart.export(src__matcher, src__matcher__expect, 'wrapAsync'); |
| 2095 src__matcher.configureExpectFailureHandler = src__matcher__expect.configureExp
ectFailureHandler; |
| 2096 src__matcher.FailureHandler = src__matcher__expect.FailureHandler; |
| 2097 src__matcher.expect = src__matcher__expect.expect; |
| 2098 src__matcher.getOrCreateExpectFailureHandler = src__matcher__expect.getOrCreat
eExpectFailureHandler; |
| 2099 src__matcher.completes = src__matcher__future_matchers.completes; |
| 2100 src__matcher.completion = src__matcher__future_matchers.completion; |
| 2101 src__matcher.Matcher = src__matcher__interfaces.Matcher; |
| 2102 src__matcher.Description = src__matcher__interfaces.Description; |
| 2103 src__matcher.pairwiseCompare = src__matcher__iterable_matchers.pairwiseCompare
; |
| 2104 src__matcher.anyElement = src__matcher__iterable_matchers.anyElement; |
| 2105 src__matcher.orderedEquals = src__matcher__iterable_matchers.orderedEquals; |
| 2106 src__matcher.unorderedEquals = src__matcher__iterable_matchers.unorderedEquals
; |
| 2107 src__matcher.unorderedMatches = src__matcher__iterable_matchers.unorderedMatch
es; |
| 2108 src__matcher.everyElement = src__matcher__iterable_matchers.everyElement; |
| 2109 src__matcher.containsValue = src__matcher__map_matchers.containsValue; |
| 2110 src__matcher.containsPair = src__matcher__map_matchers.containsPair; |
| 2111 src__matcher.isPositive = src__matcher__numeric_matchers.isPositive; |
| 2112 src__matcher.isZero = src__matcher__numeric_matchers.isZero; |
| 2113 src__matcher.inOpenClosedRange = src__matcher__numeric_matchers.inOpenClosedRa
nge; |
| 2114 src__matcher.inClosedOpenRange = src__matcher__numeric_matchers.inClosedOpenRa
nge; |
| 2115 src__matcher.lessThanOrEqualTo = src__matcher__numeric_matchers.lessThanOrEqua
lTo; |
| 2116 src__matcher.isNegative = src__matcher__numeric_matchers.isNegative; |
| 2117 src__matcher.inInclusiveRange = src__matcher__numeric_matchers.inInclusiveRang
e; |
| 2118 src__matcher.lessThan = src__matcher__numeric_matchers.lessThan; |
| 2119 src__matcher.greaterThan = src__matcher__numeric_matchers.greaterThan; |
| 2120 src__matcher.isNonNegative = src__matcher__numeric_matchers.isNonNegative; |
| 2121 src__matcher.inExclusiveRange = src__matcher__numeric_matchers.inExclusiveRang
e; |
| 2122 src__matcher.closeTo = src__matcher__numeric_matchers.closeTo; |
| 2123 src__matcher.greaterThanOrEqualTo = src__matcher__numeric_matchers.greaterThan
OrEqualTo; |
| 2124 src__matcher.isNonZero = src__matcher__numeric_matchers.isNonZero; |
| 2125 src__matcher.isNonPositive = src__matcher__numeric_matchers.isNonPositive; |
| 2126 src__matcher.allOf = src__matcher__operator_matchers.allOf; |
| 2127 src__matcher.isNot = src__matcher__operator_matchers.isNot; |
| 2128 src__matcher.anyOf = src__matcher__operator_matchers.anyOf; |
| 2129 src__matcher.prints = src__matcher__prints_matcher.prints; |
| 2130 src__matcher.endsWith = src__matcher__string_matchers.endsWith; |
| 2131 src__matcher.startsWith = src__matcher__string_matchers.startsWith; |
| 2132 src__matcher.matches = src__matcher__string_matchers.matches; |
| 2133 src__matcher.collapseWhitespace = src__matcher__string_matchers.collapseWhites
pace; |
| 2134 src__matcher.equalsIgnoringCase = src__matcher__string_matchers.equalsIgnoring
Case; |
| 2135 src__matcher.equalsIgnoringWhitespace = src__matcher__string_matchers.equalsIg
noringWhitespace; |
| 2136 src__matcher.stringContainsInOrder = src__matcher__string_matchers.stringConta
insInOrder; |
| 2137 src__matcher.throwsA = src__matcher__throws_matcher.throwsA; |
| 2138 src__matcher.throws = src__matcher__throws_matcher.throws; |
| 2139 src__matcher.Throws = src__matcher__throws_matcher.Throws; |
| 2140 src__matcher.throwsArgumentError = src__matcher__throws_matchers.throwsArgumen
tError; |
| 2141 src__matcher.throwsRangeError = src__matcher__throws_matchers.throwsRangeError
; |
| 2142 src__matcher.throwsUnsupportedError = src__matcher__throws_matchers.throwsUnsu
pportedError; |
| 2143 src__matcher.throwsCyclicInitializationError = src__matcher__throws_matchers.t
hrowsCyclicInitializationError; |
| 2144 src__matcher.throwsException = src__matcher__throws_matchers.throwsException; |
| 2145 src__matcher.throwsNoSuchMethodError = src__matcher__throws_matchers.throwsNoS
uchMethodError; |
| 2146 src__matcher.throwsFormatException = src__matcher__throws_matchers.throwsForma
tException; |
| 2147 src__matcher.throwsStateError = src__matcher__throws_matchers.throwsStateError
; |
| 2148 src__matcher.throwsConcurrentModificationError = src__matcher__throws_matchers
.throwsConcurrentModificationError; |
| 2149 src__matcher.throwsNullThrownError = src__matcher__throws_matchers.throwsNullT
hrownError; |
| 2150 src__matcher.throwsUnimplementedError = src__matcher__throws_matchers.throwsUn
implementedError; |
| 2151 src__matcher.addStateInfo = src__matcher__util.addStateInfo; |
| 2152 src__matcher.wrapMatcher = src__matcher__util.wrapMatcher; |
| 2153 src__matcher.escape = src__matcher__util.escape; |
| 2154 dart.defineLazy(src__test_environment, { |
| 2155 get _defaultEnvironment() { |
| 2156 return new src__test_environment.TestEnvironment(); |
| 2157 } |
| 2158 }); |
| 2159 dart.copyProperties(src__test_environment, { |
| 2160 get environment() { |
| 2161 let environment = async.Zone.current.get(dart.const(core.Symbol.new('unitt
est.environment'))); |
| 2162 return dart.as(environment == null ? src__test_environment._defaultEnviron
ment : environment, src__test_environment.TestEnvironment); |
| 2163 } |
| 2164 }); |
| 2165 dart.copyProperties(src__test_environment, { |
| 2166 get config() { |
| 2167 return src__test_environment.environment.config; |
| 2168 } |
| 2169 }); |
| 2170 src__test_environment.TestEnvironment = class TestEnvironment extends core.Obj
ect { |
| 2171 TestEnvironment() { |
| 2172 this.rootContext = new src__group_context.GroupContext.root(); |
| 2173 this.lastBreath = new core.DateTime.now().millisecondsSinceEpoch; |
| 2174 this.testCases = core.List$(src__internal_test_case.InternalTestCase).new(
); |
| 2175 this.config = null; |
| 2176 this.currentContext = null; |
| 2177 this.currentTestCaseIndex = -1; |
| 2178 this.initialized = false; |
| 2179 this.soloNestingLevel = 0; |
| 2180 this.soloTestSeen = false; |
| 2181 this.uncaughtErrorMessage = null; |
| 2182 this.currentContext = this.rootContext; |
| 2183 } |
| 2184 }; |
| 2185 dart.setSignature(src__test_environment.TestEnvironment, { |
| 2186 constructors: () => ({TestEnvironment: [src__test_environment.TestEnvironmen
t, []]}) |
| 2187 }); |
| 2188 const _expected = Symbol('_expected'); |
| 2189 src__matcher__core_matchers._IsSameAs = class _IsSameAs extends src__matcher__
interfaces.Matcher { |
| 2190 _IsSameAs(expected) { |
| 2191 this[_expected] = expected; |
| 2192 super.Matcher(); |
| 2193 } |
| 2194 matches(item, matchState) { |
| 2195 return core.identical(item, this[_expected]); |
| 2196 } |
| 2197 describe(description) { |
| 2198 return description.add('same instance as ').addDescriptionOf(this[_expecte
d]); |
| 2199 } |
| 2200 }; |
| 2201 dart.setSignature(src__matcher__core_matchers._IsSameAs, { |
| 2202 constructors: () => ({_IsSameAs: [src__matcher__core_matchers._IsSameAs, [da
rt.dynamic]]}), |
| 2203 methods: () => ({ |
| 2204 matches: [core.bool, [dart.dynamic, core.Map]], |
| 2205 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 2206 }) |
| 2207 }); |
| 2208 const _limit = Symbol('_limit'); |
| 2209 const _compareIterables = Symbol('_compareIterables'); |
| 2210 const _compareSets = Symbol('_compareSets'); |
| 2211 const _recursiveMatch = Symbol('_recursiveMatch'); |
| 2212 const _match = Symbol('_match'); |
| 2213 src__matcher__core_matchers._DeepMatcher = class _DeepMatcher extends src__mat
cher__interfaces.Matcher { |
| 2214 _DeepMatcher(expected, limit) { |
| 2215 if (limit === void 0) limit = 1000; |
| 2216 this[_expected] = expected; |
| 2217 this[_limit] = limit; |
| 2218 this.count = null; |
| 2219 super.Matcher(); |
| 2220 } |
| 2221 [_compareIterables](expected, actual, matcher, depth, location) { |
| 2222 if (!dart.is(actual, core.Iterable)) return ['is not Iterable', location]; |
| 2223 let expectedIterator = dart.dload(expected, 'iterator'); |
| 2224 let actualIterator = dart.dload(actual, 'iterator'); |
| 2225 for (let index = 0;; index++) { |
| 2226 let expectedNext = dart.dsend(expectedIterator, 'moveNext'); |
| 2227 let actualNext = dart.dsend(actualIterator, 'moveNext'); |
| 2228 if (!dart.notNull(dart.as(expectedNext, core.bool)) && !dart.notNull(dar
t.as(actualNext, core.bool))) return null; |
| 2229 let newLocation = `${location}[${index}]`; |
| 2230 if (!dart.notNull(dart.as(expectedNext, core.bool))) return dart.list(['
longer than expected', newLocation], core.String); |
| 2231 if (!dart.notNull(dart.as(actualNext, core.bool))) return dart.list(['sh
orter than expected', newLocation], core.String); |
| 2232 let rp = dart.dcall(matcher, dart.dload(expectedIterator, 'current'), da
rt.dload(actualIterator, 'current'), newLocation, depth); |
| 2233 if (rp != null) return dart.as(rp, core.List); |
| 2234 } |
| 2235 } |
| 2236 [_compareSets](expected, actual, matcher, depth, location) { |
| 2237 if (!dart.is(actual, core.Iterable)) return ['is not Iterable', location]; |
| 2238 actual = dart.dsend(actual, 'toSet'); |
| 2239 for (let expectedElement of expected) { |
| 2240 if (dart.notNull(dart.as(dart.dsend(actual, 'every', dart.fn(actualEleme
nt => dart.dcall(matcher, expectedElement, actualElement, location, depth) != nu
ll, core.bool, [dart.dynamic])), core.bool))) { |
| 2241 return [`does not contain ${expectedElement}`, location]; |
| 2242 } |
| 2243 } |
| 2244 if (dart.notNull(dart.as(dart.dsend(dart.dload(actual, 'length'), '>', exp
ected.length), core.bool))) { |
| 2245 return ['larger than expected', location]; |
| 2246 } else if (dart.notNull(dart.as(dart.dsend(dart.dload(actual, 'length'), '
<', expected.length), core.bool))) { |
| 2247 return ['smaller than expected', location]; |
| 2248 } else { |
| 2249 return null; |
| 2250 } |
| 2251 } |
| 2252 [_recursiveMatch](expected, actual, location, depth) { |
| 2253 if (dart.is(expected, src__matcher__interfaces.Matcher)) { |
| 2254 let matchState = dart.map(); |
| 2255 if (dart.notNull(expected.matches(actual, matchState))) return null; |
| 2256 let description = new src__matcher__description.StringDescription(); |
| 2257 expected.describe(description); |
| 2258 return dart.list([`does not match ${description}`, location], core.Strin
g); |
| 2259 } else { |
| 2260 try { |
| 2261 if (dart.equals(expected, actual)) return null; |
| 2262 } catch (e) { |
| 2263 return dart.list([`== threw "${e}"`, location], core.String); |
| 2264 } |
| 2265 |
| 2266 } |
| 2267 if (dart.notNull(depth) > dart.notNull(this[_limit])) return dart.list(['r
ecursion depth limit exceeded', location], core.String); |
| 2268 if (depth == 0 || dart.notNull(this[_limit]) > 1) { |
| 2269 if (dart.is(expected, core.Set)) { |
| 2270 return this[_compareSets](expected, actual, dart.bind(this, _recursive
Match), dart.notNull(depth) + 1, location); |
| 2271 } else if (dart.is(expected, core.Iterable)) { |
| 2272 return this[_compareIterables](expected, actual, dart.bind(this, _recu
rsiveMatch), dart.notNull(depth) + 1, location); |
| 2273 } else if (dart.is(expected, core.Map)) { |
| 2274 if (!dart.is(actual, core.Map)) return dart.list(['expected a map', lo
cation], core.String); |
| 2275 let err = dart.equals(expected[dartx.length], dart.dload(actual, 'leng
th')) ? '' : 'has different length and '; |
| 2276 for (let key of expected[dartx.keys]) { |
| 2277 if (!dart.notNull(dart.as(dart.dsend(actual, 'containsKey', key), co
re.bool))) { |
| 2278 return dart.list([`${err}is missing map key '${key}'`, location],
core.String); |
| 2279 } |
| 2280 } |
| 2281 for (let key of dart.as(dart.dload(actual, 'keys'), core.Iterable)) { |
| 2282 if (!dart.notNull(expected[dartx.containsKey](key))) { |
| 2283 return dart.list([`${err}has extra map key '${key}'`, location], c
ore.String); |
| 2284 } |
| 2285 } |
| 2286 for (let key of expected[dartx.keys]) { |
| 2287 let rp = this[_recursiveMatch](expected[dartx.get](key), dart.dindex
(actual, key), `${location}['${key}']`, dart.notNull(depth) + 1); |
| 2288 if (rp != null) return rp; |
| 2289 } |
| 2290 return null; |
| 2291 } |
| 2292 } |
| 2293 let description = new src__matcher__description.StringDescription(); |
| 2294 if (dart.notNull(depth) > 0) { |
| 2295 description.add('was ').addDescriptionOf(actual).add(' instead of ').add
DescriptionOf(expected); |
| 2296 return dart.list([description.toString(), location], core.String); |
| 2297 } |
| 2298 return dart.list(["", location], core.String); |
| 2299 } |
| 2300 [_match](expected, actual, matchState) { |
| 2301 let rp = this[_recursiveMatch](expected, actual, '', 0); |
| 2302 if (rp == null) return null; |
| 2303 let reason = null; |
| 2304 if (dart.notNull(dart.as(dart.dsend(dart.dload(rp[dartx.get](0), 'length')
, '>', 0), core.bool))) { |
| 2305 if (dart.notNull(dart.as(dart.dsend(dart.dload(rp[dartx.get](1), 'length
'), '>', 0), core.bool))) { |
| 2306 reason = `${rp[dartx.get](0)} at location ${rp[dartx.get](1)}`; |
| 2307 } else { |
| 2308 reason = rp[dartx.get](0); |
| 2309 } |
| 2310 } else { |
| 2311 reason = ''; |
| 2312 } |
| 2313 src__matcher__util.addStateInfo(matchState, dart.map({reason: reason})); |
| 2314 return dart.as(reason, core.String); |
| 2315 } |
| 2316 matches(item, matchState) { |
| 2317 return this[_match](this[_expected], item, matchState) == null; |
| 2318 } |
| 2319 describe(description) { |
| 2320 return description.addDescriptionOf(this[_expected]); |
| 2321 } |
| 2322 describeMismatch(item, mismatchDescription, matchState, verbose) { |
| 2323 let reason = matchState[dartx.get]('reason'); |
| 2324 if (dart.equals(dart.dload(reason, 'length'), 0) && dart.notNull(mismatchD
escription.length) > 0) { |
| 2325 mismatchDescription.add('is ').addDescriptionOf(item); |
| 2326 } else { |
| 2327 mismatchDescription.add(dart.as(reason, core.String)); |
| 2328 } |
| 2329 return mismatchDescription; |
| 2330 } |
| 2331 }; |
| 2332 dart.setSignature(src__matcher__core_matchers._DeepMatcher, { |
| 2333 constructors: () => ({_DeepMatcher: [src__matcher__core_matchers._DeepMatche
r, [dart.dynamic], [core.int]]}), |
| 2334 methods: () => ({ |
| 2335 [_compareIterables]: [core.List, [dart.dynamic, dart.dynamic, dart.dynamic
, dart.dynamic, dart.dynamic]], |
| 2336 [_compareSets]: [core.List, [core.Set, dart.dynamic, dart.dynamic, dart.dy
namic, dart.dynamic]], |
| 2337 [_recursiveMatch]: [core.List, [dart.dynamic, dart.dynamic, core.String, c
ore.int]], |
| 2338 [_match]: [core.String, [dart.dynamic, dart.dynamic, core.Map]], |
| 2339 matches: [core.bool, [dart.dynamic, core.Map]], |
| 2340 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 2341 }) |
| 2342 }); |
| 2343 const _value$ = Symbol('_value'); |
| 2344 src__matcher__core_matchers._StringEqualsMatcher = class _StringEqualsMatcher
extends src__matcher__interfaces.Matcher { |
| 2345 _StringEqualsMatcher(value) { |
| 2346 this[_value$] = value; |
| 2347 super.Matcher(); |
| 2348 } |
| 2349 get showActualValue() { |
| 2350 return true; |
| 2351 } |
| 2352 matches(item, matchState) { |
| 2353 return dart.equals(this[_value$], item); |
| 2354 } |
| 2355 describe(description) { |
| 2356 return description.addDescriptionOf(this[_value$]); |
| 2357 } |
| 2358 describeMismatch(item, mismatchDescription, matchState, verbose) { |
| 2359 if (!(typeof item == 'string')) { |
| 2360 return mismatchDescription.addDescriptionOf(item).add('is not a string')
; |
| 2361 } else { |
| 2362 let buff = new core.StringBuffer(); |
| 2363 buff.write('is different.'); |
| 2364 let escapedItem = src__matcher__util.escape(dart.as(item, core.String)); |
| 2365 let escapedValue = src__matcher__util.escape(this[_value$]); |
| 2366 let minLength = dart.notNull(escapedItem[dartx.length]) < dart.notNull(e
scapedValue[dartx.length]) ? escapedItem[dartx.length] : escapedValue[dartx.leng
th]; |
| 2367 let start = null; |
| 2368 for (start = 0; dart.notNull(start) < dart.notNull(minLength); start = d
art.notNull(start) + 1) { |
| 2369 if (escapedValue[dartx.codeUnitAt](start) != escapedItem[dartx.codeUni
tAt](start)) { |
| 2370 break; |
| 2371 } |
| 2372 } |
| 2373 if (start == minLength) { |
| 2374 if (dart.notNull(escapedValue[dartx.length]) < dart.notNull(escapedIte
m[dartx.length])) { |
| 2375 buff.write(' Both strings start the same, but the given value also'
+ ' has the following trailing characters: '); |
| 2376 src__matcher__core_matchers._StringEqualsMatcher._writeTrailing(buff
, escapedItem, escapedValue[dartx.length]); |
| 2377 } else { |
| 2378 buff.write(' Both strings start the same, but the given value is' +
' missing the following trailing characters: '); |
| 2379 src__matcher__core_matchers._StringEqualsMatcher._writeTrailing(buff
, escapedValue, escapedItem[dartx.length]); |
| 2380 } |
| 2381 } else { |
| 2382 buff.write('\nExpected: '); |
| 2383 src__matcher__core_matchers._StringEqualsMatcher._writeLeading(buff, e
scapedValue, start); |
| 2384 src__matcher__core_matchers._StringEqualsMatcher._writeTrailing(buff,
escapedValue, start); |
| 2385 buff.write('\n Actual: '); |
| 2386 src__matcher__core_matchers._StringEqualsMatcher._writeLeading(buff, e
scapedItem, start); |
| 2387 src__matcher__core_matchers._StringEqualsMatcher._writeTrailing(buff,
escapedItem, start); |
| 2388 buff.write('\n '); |
| 2389 for (let i = dart.notNull(start) > 10 ? 14 : start; dart.notNull(i) >
0; i = dart.notNull(i) - 1) |
| 2390 buff.write(' '); |
| 2391 buff.write(`^\n Differ at offset ${start}`); |
| 2392 } |
| 2393 return mismatchDescription.replace(buff.toString()); |
| 2394 } |
| 2395 } |
| 2396 static _writeLeading(buff, s, start) { |
| 2397 if (dart.notNull(start) > 10) { |
| 2398 buff.write('... '); |
| 2399 buff.write(s[dartx.substring](dart.notNull(start) - 10, start)); |
| 2400 } else { |
| 2401 buff.write(s[dartx.substring](0, start)); |
| 2402 } |
| 2403 } |
| 2404 static _writeTrailing(buff, s, start) { |
| 2405 if (dart.notNull(start) + 10 > dart.notNull(s[dartx.length])) { |
| 2406 buff.write(s[dartx.substring](start)); |
| 2407 } else { |
| 2408 buff.write(s[dartx.substring](start, dart.notNull(start) + 10)); |
| 2409 buff.write(' ...'); |
| 2410 } |
| 2411 } |
| 2412 }; |
| 2413 dart.setSignature(src__matcher__core_matchers._StringEqualsMatcher, { |
| 2414 constructors: () => ({_StringEqualsMatcher: [src__matcher__core_matchers._St
ringEqualsMatcher, [core.String]]}), |
| 2415 methods: () => ({ |
| 2416 matches: [core.bool, [dart.dynamic, core.Map]], |
| 2417 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 2418 }), |
| 2419 statics: () => ({ |
| 2420 _writeLeading: [dart.void, [core.StringBuffer, core.String, core.int]], |
| 2421 _writeTrailing: [dart.void, [core.StringBuffer, core.String, core.int]] |
| 2422 }), |
| 2423 names: ['_writeLeading', '_writeTrailing'] |
| 2424 }); |
| 2425 src__matcher__core_matchers._HasLength = class _HasLength extends src__matcher
__interfaces.Matcher { |
| 2426 _HasLength(matcher) { |
| 2427 if (matcher === void 0) matcher = null; |
| 2428 this[_matcher] = matcher; |
| 2429 super.Matcher(); |
| 2430 } |
| 2431 matches(item, matchState) { |
| 2432 try { |
| 2433 if (dart.notNull(dart.as(dart.dsend(dart.dsend(dart.dload(item, 'length'
), '*', dart.dload(item, 'length')), '>=', 0), core.bool))) { |
| 2434 return this[_matcher].matches(dart.dload(item, 'length'), matchState); |
| 2435 } |
| 2436 } catch (e) { |
| 2437 } |
| 2438 |
| 2439 return false; |
| 2440 } |
| 2441 describe(description) { |
| 2442 return description.add('an object with length of ').addDescriptionOf(this[
_matcher]); |
| 2443 } |
| 2444 describeMismatch(item, mismatchDescription, matchState, verbose) { |
| 2445 try { |
| 2446 if (dart.notNull(dart.as(dart.dsend(dart.dsend(dart.dload(item, 'length'
), '*', dart.dload(item, 'length')), '>=', 0), core.bool))) { |
| 2447 return mismatchDescription.add('has length of ').addDescriptionOf(dart
.dload(item, 'length')); |
| 2448 } |
| 2449 } catch (e) { |
| 2450 } |
| 2451 |
| 2452 return mismatchDescription.add('has no length property'); |
| 2453 } |
| 2454 }; |
| 2455 dart.setSignature(src__matcher__core_matchers._HasLength, { |
| 2456 constructors: () => ({_HasLength: [src__matcher__core_matchers._HasLength, [
], [src__matcher__interfaces.Matcher]]}), |
| 2457 methods: () => ({ |
| 2458 matches: [core.bool, [dart.dynamic, core.Map]], |
| 2459 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 2460 }) |
| 2461 }); |
| 2462 src__matcher__core_matchers._Contains = class _Contains extends src__matcher__
interfaces.Matcher { |
| 2463 _Contains(expected) { |
| 2464 this[_expected] = expected; |
| 2465 super.Matcher(); |
| 2466 } |
| 2467 matches(item, matchState) { |
| 2468 if (typeof item == 'string') { |
| 2469 return dart.notNull(item[dartx.indexOf](dart.as(this[_expected], core.Pa
ttern))) >= 0; |
| 2470 } else if (dart.is(item, core.Iterable)) { |
| 2471 if (dart.is(this[_expected], src__matcher__interfaces.Matcher)) { |
| 2472 return item[dartx.any](dart.fn(e => dart.as(dart.dsend(this[_expected]
, 'matches', e, matchState), core.bool), core.bool, [dart.dynamic])); |
| 2473 } else { |
| 2474 return item[dartx.contains](this[_expected]); |
| 2475 } |
| 2476 } else if (dart.is(item, core.Map)) { |
| 2477 return item[dartx.containsKey](this[_expected]); |
| 2478 } |
| 2479 return false; |
| 2480 } |
| 2481 describe(description) { |
| 2482 return description.add('contains ').addDescriptionOf(this[_expected]); |
| 2483 } |
| 2484 describeMismatch(item, mismatchDescription, matchState, verbose) { |
| 2485 if (typeof item == 'string' || dart.is(item, core.Iterable) || dart.is(ite
m, core.Map)) { |
| 2486 return super.describeMismatch(item, mismatchDescription, matchState, ver
bose); |
| 2487 } else { |
| 2488 return mismatchDescription.add('is not a string, map or iterable'); |
| 2489 } |
| 2490 } |
| 2491 }; |
| 2492 dart.setSignature(src__matcher__core_matchers._Contains, { |
| 2493 constructors: () => ({_Contains: [src__matcher__core_matchers._Contains, [da
rt.dynamic]]}), |
| 2494 methods: () => ({ |
| 2495 matches: [core.bool, [dart.dynamic, core.Map]], |
| 2496 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 2497 }) |
| 2498 }); |
| 2499 src__matcher__core_matchers._In = class _In extends src__matcher__interfaces.M
atcher { |
| 2500 _In(expected) { |
| 2501 this[_expected] = expected; |
| 2502 super.Matcher(); |
| 2503 } |
| 2504 matches(item, matchState) { |
| 2505 if (typeof this[_expected] == 'string') { |
| 2506 return dart.as(dart.dsend(dart.dsend(this[_expected], 'indexOf', item),
'>=', 0), core.bool); |
| 2507 } else if (dart.is(this[_expected], core.Iterable)) { |
| 2508 return dart.as(dart.dsend(this[_expected], 'any', dart.fn(e => dart.equa
ls(e, item), core.bool, [dart.dynamic])), core.bool); |
| 2509 } else if (dart.is(this[_expected], core.Map)) { |
| 2510 return dart.as(dart.dsend(this[_expected], 'containsKey', item), core.bo
ol); |
| 2511 } |
| 2512 return false; |
| 2513 } |
| 2514 describe(description) { |
| 2515 return description.add('is in ').addDescriptionOf(this[_expected]); |
| 2516 } |
| 2517 }; |
| 2518 dart.setSignature(src__matcher__core_matchers._In, { |
| 2519 constructors: () => ({_In: [src__matcher__core_matchers._In, [dart.dynamic]]
}), |
| 2520 methods: () => ({ |
| 2521 matches: [core.bool, [dart.dynamic, core.Map]], |
| 2522 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 2523 }) |
| 2524 }); |
| 2525 src__matcher__core_matchers._PredicateFunction = dart.typedef('_PredicateFunct
ion', () => dart.functionType(core.bool, [dart.dynamic])); |
| 2526 const _description = Symbol('_description'); |
| 2527 src__matcher__core_matchers._Predicate = class _Predicate extends src__matcher
__interfaces.Matcher { |
| 2528 _Predicate(matcher, description) { |
| 2529 this[_matcher] = matcher; |
| 2530 this[_description] = description; |
| 2531 super.Matcher(); |
| 2532 } |
| 2533 matches(item, matchState) { |
| 2534 return dart.dcall(this[_matcher], item); |
| 2535 } |
| 2536 describe(description) { |
| 2537 return description.add(this[_description]); |
| 2538 } |
| 2539 }; |
| 2540 dart.setSignature(src__matcher__core_matchers._Predicate, { |
| 2541 constructors: () => ({_Predicate: [src__matcher__core_matchers._Predicate, [
src__matcher__core_matchers._PredicateFunction, core.String]]}), |
| 2542 methods: () => ({ |
| 2543 matches: [core.bool, [dart.dynamic, core.Map]], |
| 2544 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 2545 }) |
| 2546 }); |
| 2547 const _value$0 = Symbol('_value'); |
| 2548 const _matchValue = Symbol('_matchValue'); |
| 2549 src__matcher__string_matchers._StringMatcher = class _StringMatcher extends sr
c__matcher__interfaces.Matcher { |
| 2550 _StringMatcher() { |
| 2551 super.Matcher(); |
| 2552 } |
| 2553 describeMismatch(item, mismatchDescription, matchState, verbose) { |
| 2554 if (!(typeof item == 'string')) { |
| 2555 return mismatchDescription.addDescriptionOf(item).add(' not a string'); |
| 2556 } else { |
| 2557 return super.describeMismatch(item, mismatchDescription, matchState, ver
bose); |
| 2558 } |
| 2559 } |
| 2560 }; |
| 2561 dart.setSignature(src__matcher__string_matchers._StringMatcher, { |
| 2562 constructors: () => ({_StringMatcher: [src__matcher__string_matchers._String
Matcher, []]}) |
| 2563 }); |
| 2564 src__matcher__string_matchers._IsEqualIgnoringCase = class _IsEqualIgnoringCas
e extends src__matcher__string_matchers._StringMatcher { |
| 2565 _IsEqualIgnoringCase(value) { |
| 2566 this[_value$0] = value; |
| 2567 this[_matchValue] = value[dartx.toLowerCase](); |
| 2568 super._StringMatcher(); |
| 2569 } |
| 2570 matches(item, matchState) { |
| 2571 return typeof item == 'string' && this[_matchValue] == item[dartx.toLowerC
ase](); |
| 2572 } |
| 2573 describe(description) { |
| 2574 return description.addDescriptionOf(this[_value$0]).add(' ignoring case'); |
| 2575 } |
| 2576 }; |
| 2577 dart.setSignature(src__matcher__string_matchers._IsEqualIgnoringCase, { |
| 2578 constructors: () => ({_IsEqualIgnoringCase: [src__matcher__string_matchers._
IsEqualIgnoringCase, [core.String]]}), |
| 2579 methods: () => ({ |
| 2580 matches: [core.bool, [dart.dynamic, core.Map]], |
| 2581 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 2582 }) |
| 2583 }); |
| 2584 src__matcher__string_matchers._IsEqualIgnoringWhitespace = class _IsEqualIgnor
ingWhitespace extends src__matcher__string_matchers._StringMatcher { |
| 2585 _IsEqualIgnoringWhitespace(value) { |
| 2586 this[_value$0] = value; |
| 2587 this[_matchValue] = src__matcher__string_matchers.collapseWhitespace(value
); |
| 2588 super._StringMatcher(); |
| 2589 } |
| 2590 matches(item, matchState) { |
| 2591 return typeof item == 'string' && this[_matchValue] == src__matcher__strin
g_matchers.collapseWhitespace(item); |
| 2592 } |
| 2593 describe(description) { |
| 2594 return description.addDescriptionOf(this[_matchValue]).add(' ignoring whit
espace'); |
| 2595 } |
| 2596 describeMismatch(item, mismatchDescription, matchState, verbose) { |
| 2597 if (typeof item == 'string') { |
| 2598 return mismatchDescription.add('is ').addDescriptionOf(src__matcher__str
ing_matchers.collapseWhitespace(item)).add(' with whitespace compressed'); |
| 2599 } else { |
| 2600 return super.describeMismatch(item, mismatchDescription, matchState, ver
bose); |
| 2601 } |
| 2602 } |
| 2603 }; |
| 2604 dart.setSignature(src__matcher__string_matchers._IsEqualIgnoringWhitespace, { |
| 2605 constructors: () => ({_IsEqualIgnoringWhitespace: [src__matcher__string_matc
hers._IsEqualIgnoringWhitespace, [core.String]]}), |
| 2606 methods: () => ({ |
| 2607 matches: [core.bool, [dart.dynamic, core.Map]], |
| 2608 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 2609 }) |
| 2610 }); |
| 2611 const _prefix = Symbol('_prefix'); |
| 2612 src__matcher__string_matchers._StringStartsWith = class _StringStartsWith exte
nds src__matcher__string_matchers._StringMatcher { |
| 2613 _StringStartsWith(prefix) { |
| 2614 this[_prefix] = prefix; |
| 2615 super._StringMatcher(); |
| 2616 } |
| 2617 matches(item, matchState) { |
| 2618 return typeof item == 'string' && dart.notNull(item[dartx.startsWith](this
[_prefix])); |
| 2619 } |
| 2620 describe(description) { |
| 2621 return description.add('a string starting with ').addDescriptionOf(this[_p
refix]); |
| 2622 } |
| 2623 }; |
| 2624 dart.setSignature(src__matcher__string_matchers._StringStartsWith, { |
| 2625 constructors: () => ({_StringStartsWith: [src__matcher__string_matchers._Str
ingStartsWith, [core.String]]}), |
| 2626 methods: () => ({ |
| 2627 matches: [core.bool, [dart.dynamic, core.Map]], |
| 2628 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 2629 }) |
| 2630 }); |
| 2631 const _suffix = Symbol('_suffix'); |
| 2632 src__matcher__string_matchers._StringEndsWith = class _StringEndsWith extends
src__matcher__string_matchers._StringMatcher { |
| 2633 _StringEndsWith(suffix) { |
| 2634 this[_suffix] = suffix; |
| 2635 super._StringMatcher(); |
| 2636 } |
| 2637 matches(item, matchState) { |
| 2638 return typeof item == 'string' && dart.notNull(item[dartx.endsWith](this[_
suffix])); |
| 2639 } |
| 2640 describe(description) { |
| 2641 return description.add('a string ending with ').addDescriptionOf(this[_suf
fix]); |
| 2642 } |
| 2643 }; |
| 2644 dart.setSignature(src__matcher__string_matchers._StringEndsWith, { |
| 2645 constructors: () => ({_StringEndsWith: [src__matcher__string_matchers._Strin
gEndsWith, [core.String]]}), |
| 2646 methods: () => ({ |
| 2647 matches: [core.bool, [dart.dynamic, core.Map]], |
| 2648 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 2649 }) |
| 2650 }); |
| 2651 const _substrings = Symbol('_substrings'); |
| 2652 src__matcher__string_matchers._StringContainsInOrder = class _StringContainsIn
Order extends src__matcher__string_matchers._StringMatcher { |
| 2653 _StringContainsInOrder(substrings) { |
| 2654 this[_substrings] = substrings; |
| 2655 super._StringMatcher(); |
| 2656 } |
| 2657 matches(item, matchState) { |
| 2658 if (!(typeof item == 'string')) { |
| 2659 return false; |
| 2660 } |
| 2661 let from_index = 0; |
| 2662 for (let s of this[_substrings]) { |
| 2663 from_index = dart.as(dart.dsend(item, 'indexOf', s, from_index), core.in
t); |
| 2664 if (dart.notNull(from_index) < 0) return false; |
| 2665 } |
| 2666 return true; |
| 2667 } |
| 2668 describe(description) { |
| 2669 return description.addAll('a string containing ', ', ', ' in order', this[
_substrings]); |
| 2670 } |
| 2671 }; |
| 2672 dart.setSignature(src__matcher__string_matchers._StringContainsInOrder, { |
| 2673 constructors: () => ({_StringContainsInOrder: [src__matcher__string_matchers
._StringContainsInOrder, [core.List$(core.String)]]}), |
| 2674 methods: () => ({ |
| 2675 matches: [core.bool, [dart.dynamic, core.Map]], |
| 2676 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 2677 }) |
| 2678 }); |
| 2679 const _regexp = Symbol('_regexp'); |
| 2680 src__matcher__string_matchers._MatchesRegExp = class _MatchesRegExp extends sr
c__matcher__string_matchers._StringMatcher { |
| 2681 _MatchesRegExp(re) { |
| 2682 this[_regexp] = null; |
| 2683 super._StringMatcher(); |
| 2684 if (typeof re == 'string') { |
| 2685 this[_regexp] = core.RegExp.new(re); |
| 2686 } else if (dart.is(re, core.RegExp)) { |
| 2687 this[_regexp] = re; |
| 2688 } else { |
| 2689 dart.throw(new core.ArgumentError('matches requires a regexp or string')
); |
| 2690 } |
| 2691 } |
| 2692 matches(item, matchState) { |
| 2693 return typeof item == 'string' ? this[_regexp].hasMatch(item) : false; |
| 2694 } |
| 2695 describe(description) { |
| 2696 return description.add(`match '${this[_regexp].pattern}'`); |
| 2697 } |
| 2698 }; |
| 2699 dart.setSignature(src__matcher__string_matchers._MatchesRegExp, { |
| 2700 constructors: () => ({_MatchesRegExp: [src__matcher__string_matchers._Matche
sRegExp, [dart.dynamic]]}), |
| 2701 methods: () => ({ |
| 2702 matches: [core.bool, [dart.dynamic, core.Map]], |
| 2703 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 2704 }) |
| 2705 }); |
| 2706 src__matcher__string_matchers._isWhitespace = function(ch) { |
| 2707 return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t'; |
| 2708 }; |
| 2709 dart.fn(src__matcher__string_matchers._isWhitespace, core.bool, [core.String])
; |
| 2710 src__matcher__util._Predicate = dart.typedef('_Predicate', () => dart.function
Type(core.bool, [dart.dynamic])); |
| 2711 src__matcher__util._escapeMap = dart.const(dart.map({'\n': '\\n', '\r': '\\r',
'\f': '\\f', '\b': '\\b', '\t': '\\t', '\v': '\\v', '': '\\x7F'})); |
| 2712 dart.defineLazy(src__matcher__util, { |
| 2713 get _escapeRegExp() { |
| 2714 return core.RegExp.new(`[\\x00-\\x07\\x0E-\\x1F${src__matcher__util._escap
eMap[dartx.keys][dartx.map](core.String)(src__matcher__util._getHexLiteral)[dart
x.join]()}]`); |
| 2715 } |
| 2716 }); |
| 2717 src__matcher__util._getHexLiteral = function(input) { |
| 2718 let rune = input[dartx.runes].single; |
| 2719 return '\\x' + dart.notNull(rune[dartx.toRadixString](16)[dartx.toUpperCase]
()[dartx.padLeft](2, '0')); |
| 2720 }; |
| 2721 dart.fn(src__matcher__util._getHexLiteral, core.String, [core.String]); |
| 2722 src__matcher__pretty_print.prettyPrint = function(object, opts) { |
| 2723 let maxLineLength = opts && 'maxLineLength' in opts ? opts.maxLineLength : n
ull; |
| 2724 let maxItems = opts && 'maxItems' in opts ? opts.maxItems : null; |
| 2725 function _prettyPrint(object, indent, seen, top) { |
| 2726 if (dart.is(object, src__matcher__interfaces.Matcher)) { |
| 2727 let description = new src__matcher__description.StringDescription(); |
| 2728 object.describe(description); |
| 2729 return `<${description}>`; |
| 2730 } |
| 2731 if (dart.notNull(seen.contains(object))) return "(recursive)"; |
| 2732 seen = seen.union(core.Set.from([object])); |
| 2733 function pp(child) { |
| 2734 return _prettyPrint(child, dart.notNull(indent) + 2, seen, false); |
| 2735 } |
| 2736 dart.fn(pp, core.String, [dart.dynamic]); |
| 2737 if (dart.is(object, core.Iterable)) { |
| 2738 let type = dart.is(object, core.List) ? "" : dart.notNull(src__matcher__
pretty_print._typeName(object)) + ":"; |
| 2739 let strings = object[dartx.map](core.String)(pp)[dartx.toList](); |
| 2740 if (maxItems != null && dart.notNull(strings[dartx.length]) > dart.notNu
ll(maxItems)) { |
| 2741 strings[dartx.replaceRange](dart.notNull(maxItems) - 1, strings[dartx.
length], dart.list(['...'], core.String)); |
| 2742 } |
| 2743 let singleLine = `${type}[${strings[dartx.join](', ')}]`; |
| 2744 if ((maxLineLength == null || dart.notNull(singleLine[dartx.length]) + d
art.notNull(indent) <= dart.notNull(maxLineLength)) && !dart.notNull(singleLine[
dartx.contains]("\n"))) { |
| 2745 return singleLine; |
| 2746 } |
| 2747 return `${type}[\n` + dart.notNull(strings[dartx.map](core.String)(dart.
fn(string => dart.notNull(src__matcher__pretty_print._indent(dart.notNull(indent
) + 2)) + dart.notNull(string), core.String, [core.String]))[dartx.join](",\n"))
+ "\n" + dart.notNull(src__matcher__pretty_print._indent(indent)) + "]"; |
| 2748 } else if (dart.is(object, core.Map)) { |
| 2749 let strings = object[dartx.keys][dartx.map](core.String)(dart.fn(key =>
`${pp(key)}: ${pp(object[dartx.get](key))}`, core.String, [dart.dynamic]))[dartx
.toList](); |
| 2750 if (maxItems != null && dart.notNull(strings[dartx.length]) > dart.notNu
ll(maxItems)) { |
| 2751 strings[dartx.replaceRange](dart.notNull(maxItems) - 1, strings[dartx.
length], dart.list(['...'], core.String)); |
| 2752 } |
| 2753 let singleLine = `{${strings[dartx.join](", ")}}`; |
| 2754 if ((maxLineLength == null || dart.notNull(singleLine[dartx.length]) + d
art.notNull(indent) <= dart.notNull(maxLineLength)) && !dart.notNull(singleLine[
dartx.contains]("\n"))) { |
| 2755 return singleLine; |
| 2756 } |
| 2757 return "{\n" + dart.notNull(strings[dartx.map](core.String)(dart.fn(stri
ng => dart.notNull(src__matcher__pretty_print._indent(dart.notNull(indent) + 2))
+ dart.notNull(string), core.String, [core.String]))[dartx.join](",\n")) + "\n"
+ dart.notNull(src__matcher__pretty_print._indent(indent)) + "}"; |
| 2758 } else if (typeof object == 'string') { |
| 2759 let lines = object[dartx.split]("\n"); |
| 2760 return "'" + dart.notNull(lines[dartx.map](core.String)(src__matcher__pr
etty_print._escapeString)[dartx.join](`\\n'\n${src__matcher__pretty_print._inden
t(dart.notNull(indent) + 2)}'`)) + "'"; |
| 2761 } else { |
| 2762 let value = dart.toString(object)[dartx.replaceAll]("\n", dart.notNull(s
rc__matcher__pretty_print._indent(indent)) + "\n"); |
| 2763 let defaultToString = value[dartx.startsWith]("Instance of "); |
| 2764 if (dart.notNull(top)) value = `<${value}>`; |
| 2765 if (typeof object == 'number' || typeof object == 'boolean' || dart.is(o
bject, core.Function) || object == null || dart.notNull(defaultToString)) { |
| 2766 return value; |
| 2767 } else { |
| 2768 return `${src__matcher__pretty_print._typeName(object)}:${value}`; |
| 2769 } |
| 2770 } |
| 2771 } |
| 2772 dart.fn(_prettyPrint, core.String, [dart.dynamic, core.int, core.Set, core.b
ool]); |
| 2773 return _prettyPrint(object, 0, core.Set.new(), true); |
| 2774 }; |
| 2775 dart.fn(src__matcher__pretty_print.prettyPrint, core.String, [dart.dynamic], {
maxLineLength: core.int, maxItems: core.int}); |
| 2776 src__matcher__pretty_print._indent = function(length) { |
| 2777 return core.List.filled(length, ' ')[dartx.join](''); |
| 2778 }; |
| 2779 dart.fn(src__matcher__pretty_print._indent, core.String, [core.int]); |
| 2780 src__matcher__pretty_print._typeName = function(x) { |
154 try { | 2781 try { |
155 if (dart.notNull(dart.as(dart.dsend(matcher, 'matches', actual, matchState
), core.bool))) return; | 2782 if (x == null) return "null"; |
| 2783 let type = dart.toString(dart.runtimeType(x)); |
| 2784 return dart.notNull(type[dartx.startsWith]("_")) ? "?" : type; |
156 } catch (e) { | 2785 } catch (e) { |
157 let trace = dart.stackTrace(e); | 2786 return "?"; |
158 if (reason == null) { | |
159 reason = `${typeof e == 'string' ? e : dart.toString(e)} at ${trace}`; | |
160 } | |
161 } | 2787 } |
162 | 2788 |
163 if (formatter == null) formatter = unittest._defaultFailFormatter; | 2789 }; |
164 unittest.fail(dart.dcall(formatter, actual, matcher, reason, matchState, ver
bose)); | 2790 dart.fn(src__matcher__pretty_print._typeName, core.String, [dart.dynamic]); |
165 }; | 2791 src__matcher__pretty_print._escapeString = function(source) { |
166 dart.fn(unittest.expect, dart.void, [dart.dynamic, dart.dynamic], {reason: cor
e.String, verbose: core.bool, formatter: unittest.ErrorFormatter}); | 2792 return src__matcher__util.escape(source)[dartx.replaceAll]("'", "\\'"); |
167 unittest.fail = function(message) { | 2793 }; |
168 return dart.throw(new unittest.TestFailure(message)); | 2794 dart.fn(src__matcher__pretty_print._escapeString, core.String, [core.String]); |
169 }; | 2795 src__matcher__numeric_matchers._isNumeric = function(value) { |
170 dart.fn(unittest.fail, dart.void, [core.String]); | 2796 return typeof value == 'number'; |
171 unittest._defaultFailFormatter = function(actual, matcher, reason, matchState,
verbose) { | 2797 }; |
172 let description = new src__description.StringDescription(); | 2798 dart.fn(src__matcher__numeric_matchers._isNumeric, core.bool, [dart.dynamic]); |
| 2799 const _delta = Symbol('_delta'); |
| 2800 src__matcher__numeric_matchers._IsCloseTo = class _IsCloseTo extends src__matc
her__interfaces.Matcher { |
| 2801 _IsCloseTo(value, delta) { |
| 2802 this[_value] = value; |
| 2803 this[_delta] = delta; |
| 2804 super.Matcher(); |
| 2805 } |
| 2806 matches(item, matchState) { |
| 2807 if (!dart.notNull(src__matcher__numeric_matchers._isNumeric(item))) { |
| 2808 return false; |
| 2809 } |
| 2810 let diff = dart.dsend(item, '-', this[_value]); |
| 2811 if (dart.notNull(dart.as(dart.dsend(diff, '<', 0), core.bool))) diff = dar
t.dsend(diff, 'unary-'); |
| 2812 return dart.as(dart.dsend(diff, '<=', this[_delta]), core.bool); |
| 2813 } |
| 2814 describe(description) { |
| 2815 return description.add('a numeric value within ').addDescriptionOf(this[_d
elta]).add(' of ').addDescriptionOf(this[_value]); |
| 2816 } |
| 2817 describeMismatch(item, mismatchDescription, matchState, verbose) { |
| 2818 if (!(typeof item == 'number')) { |
| 2819 return mismatchDescription.add(' not numeric'); |
| 2820 } else { |
| 2821 let diff = dart.dsend(item, '-', this[_value]); |
| 2822 if (dart.notNull(dart.as(dart.dsend(diff, '<', 0), core.bool))) diff = d
art.dsend(diff, 'unary-'); |
| 2823 return mismatchDescription.add(' differs by ').addDescriptionOf(diff); |
| 2824 } |
| 2825 } |
| 2826 }; |
| 2827 dart.setSignature(src__matcher__numeric_matchers._IsCloseTo, { |
| 2828 constructors: () => ({_IsCloseTo: [src__matcher__numeric_matchers._IsCloseTo
, [core.num, core.num]]}), |
| 2829 methods: () => ({ |
| 2830 matches: [core.bool, [dart.dynamic, core.Map]], |
| 2831 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 2832 }) |
| 2833 }); |
| 2834 const _low = Symbol('_low'); |
| 2835 const _high = Symbol('_high'); |
| 2836 const _lowMatchValue = Symbol('_lowMatchValue'); |
| 2837 const _highMatchValue = Symbol('_highMatchValue'); |
| 2838 src__matcher__numeric_matchers._InRange = class _InRange extends src__matcher_
_interfaces.Matcher { |
| 2839 _InRange(low, high, lowMatchValue, highMatchValue) { |
| 2840 this[_low] = low; |
| 2841 this[_high] = high; |
| 2842 this[_lowMatchValue] = lowMatchValue; |
| 2843 this[_highMatchValue] = highMatchValue; |
| 2844 super.Matcher(); |
| 2845 } |
| 2846 matches(value, matchState) { |
| 2847 if (!(typeof value == 'number')) { |
| 2848 return false; |
| 2849 } |
| 2850 if (dart.notNull(dart.as(dart.dsend(value, '<', this[_low]), core.bool)) |
| dart.notNull(dart.as(dart.dsend(value, '>', this[_high]), core.bool))) { |
| 2851 return false; |
| 2852 } |
| 2853 if (dart.equals(value, this[_low])) { |
| 2854 return this[_lowMatchValue]; |
| 2855 } |
| 2856 if (dart.equals(value, this[_high])) { |
| 2857 return this[_highMatchValue]; |
| 2858 } |
| 2859 return true; |
| 2860 } |
| 2861 describe(description) { |
| 2862 return description.add("be in range from " + `${this[_low]} (${dart.notNul
l(this[_lowMatchValue]) ? 'inclusive' : 'exclusive'}) to ` + `${this[_high]} (${
dart.notNull(this[_highMatchValue]) ? 'inclusive' : 'exclusive'})`); |
| 2863 } |
| 2864 describeMismatch(item, mismatchDescription, matchState, verbose) { |
| 2865 if (!(typeof item == 'number')) { |
| 2866 return mismatchDescription.addDescriptionOf(item).add(' not numeric'); |
| 2867 } else { |
| 2868 return super.describeMismatch(item, mismatchDescription, matchState, ver
bose); |
| 2869 } |
| 2870 } |
| 2871 }; |
| 2872 dart.setSignature(src__matcher__numeric_matchers._InRange, { |
| 2873 constructors: () => ({_InRange: [src__matcher__numeric_matchers._InRange, [c
ore.num, core.num, core.bool, core.bool]]}), |
| 2874 methods: () => ({ |
| 2875 matches: [core.bool, [dart.dynamic, core.Map]], |
| 2876 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 2877 }) |
| 2878 }); |
| 2879 const _matcher$1 = Symbol('_matcher'); |
| 2880 src__matcher__operator_matchers._IsNot = class _IsNot extends src__matcher__in
terfaces.Matcher { |
| 2881 _IsNot(matcher) { |
| 2882 this[_matcher$1] = matcher; |
| 2883 super.Matcher(); |
| 2884 } |
| 2885 matches(item, matchState) { |
| 2886 return !dart.notNull(this[_matcher$1].matches(item, matchState)); |
| 2887 } |
| 2888 describe(description) { |
| 2889 return description.add('not ').addDescriptionOf(this[_matcher$1]); |
| 2890 } |
| 2891 }; |
| 2892 dart.setSignature(src__matcher__operator_matchers._IsNot, { |
| 2893 constructors: () => ({_IsNot: [src__matcher__operator_matchers._IsNot, [src_
_matcher__interfaces.Matcher]]}), |
| 2894 methods: () => ({ |
| 2895 matches: [core.bool, [dart.dynamic, core.Map]], |
| 2896 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 2897 }) |
| 2898 }); |
| 2899 const _matchers = Symbol('_matchers'); |
| 2900 src__matcher__operator_matchers._AllOf = class _AllOf extends src__matcher__in
terfaces.Matcher { |
| 2901 _AllOf(matchers) { |
| 2902 this[_matchers] = matchers; |
| 2903 super.Matcher(); |
| 2904 } |
| 2905 matches(item, matchState) { |
| 2906 for (let matcher of this[_matchers]) { |
| 2907 if (!dart.notNull(matcher.matches(item, matchState))) { |
| 2908 src__matcher__util.addStateInfo(matchState, dart.map({matcher: matcher
})); |
| 2909 return false; |
| 2910 } |
| 2911 } |
| 2912 return true; |
| 2913 } |
| 2914 describeMismatch(item, mismatchDescription, matchState, verbose) { |
| 2915 let matcher = matchState[dartx.get]('matcher'); |
| 2916 dart.dsend(matcher, 'describeMismatch', item, mismatchDescription, matchSt
ate[dartx.get]('state'), verbose); |
| 2917 return mismatchDescription; |
| 2918 } |
| 2919 describe(description) { |
| 2920 return description.addAll('(', ' and ', ')', this[_matchers]); |
| 2921 } |
| 2922 }; |
| 2923 dart.setSignature(src__matcher__operator_matchers._AllOf, { |
| 2924 constructors: () => ({_AllOf: [src__matcher__operator_matchers._AllOf, [core
.List$(src__matcher__interfaces.Matcher)]]}), |
| 2925 methods: () => ({ |
| 2926 matches: [core.bool, [dart.dynamic, core.Map]], |
| 2927 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 2928 }) |
| 2929 }); |
| 2930 src__matcher__operator_matchers._AnyOf = class _AnyOf extends src__matcher__in
terfaces.Matcher { |
| 2931 _AnyOf(matchers) { |
| 2932 this[_matchers] = matchers; |
| 2933 super.Matcher(); |
| 2934 } |
| 2935 matches(item, matchState) { |
| 2936 for (let matcher of this[_matchers]) { |
| 2937 if (dart.notNull(matcher.matches(item, matchState))) { |
| 2938 return true; |
| 2939 } |
| 2940 } |
| 2941 return false; |
| 2942 } |
| 2943 describe(description) { |
| 2944 return description.addAll('(', ' or ', ')', this[_matchers]); |
| 2945 } |
| 2946 }; |
| 2947 dart.setSignature(src__matcher__operator_matchers._AnyOf, { |
| 2948 constructors: () => ({_AnyOf: [src__matcher__operator_matchers._AnyOf, [core
.List$(src__matcher__interfaces.Matcher)]]}), |
| 2949 methods: () => ({ |
| 2950 matches: [core.bool, [dart.dynamic, core.Map]], |
| 2951 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 2952 }) |
| 2953 }); |
| 2954 src__matcher__operator_matchers._wrapArgs = function(arg0, arg1, arg2, arg3, a
rg4, arg5, arg6) { |
| 2955 let args = null; |
| 2956 if (dart.is(arg0, core.List)) { |
| 2957 if (arg1 != null || arg2 != null || arg3 != null || arg4 != null || arg5 !
= null || arg6 != null) { |
| 2958 dart.throw(new core.ArgumentError('If arg0 is a List, all other argument
s must be' + ' null.')); |
| 2959 } |
| 2960 args = arg0; |
| 2961 } else { |
| 2962 args = [arg0, arg1, arg2, arg3, arg4, arg5, arg6][dartx.where](dart.fn(e =
> e != null, core.bool, [dart.dynamic])); |
| 2963 } |
| 2964 return args[dartx.map](src__matcher__interfaces.Matcher)(dart.fn(e => src__m
atcher__util.wrapMatcher(e), src__matcher__interfaces.Matcher, [dart.dynamic]))[
dartx.toList](); |
| 2965 }; |
| 2966 dart.fn(src__matcher__operator_matchers._wrapArgs, core.List$(src__matcher__in
terfaces.Matcher), [dart.dynamic, dart.dynamic, dart.dynamic, dart.dynamic, dart
.dynamic, dart.dynamic, dart.dynamic]); |
| 2967 src__matcher__expect._assertFailureHandler = null; |
| 2968 src__matcher__expect._assertErrorFormatter = null; |
| 2969 src__matcher__expect._defaultErrorFormatter = function(actual, matcher, reason
, matchState, verbose) { |
| 2970 let description = new src__matcher__description.StringDescription(); |
173 description.add('Expected: ').addDescriptionOf(matcher).add('\n'); | 2971 description.add('Expected: ').addDescriptionOf(matcher).add('\n'); |
174 description.add(' Actual: ').addDescriptionOf(actual).add('\n'); | 2972 description.add(' Actual: ').addDescriptionOf(actual).add('\n'); |
175 let mismatchDescription = new src__description.StringDescription(); | 2973 let mismatchDescription = new src__matcher__description.StringDescription(); |
176 matcher.describeMismatch(actual, mismatchDescription, matchState, verbose); | 2974 matcher.describeMismatch(actual, mismatchDescription, matchState, verbose); |
177 if (dart.notNull(mismatchDescription.length) > 0) { | 2975 if (dart.notNull(mismatchDescription.length) > 0) { |
178 description.add(` Which: ${mismatchDescription}\n`); | 2976 description.add(` Which: ${mismatchDescription}\n`); |
179 } | 2977 } |
180 if (reason != null) description.add(reason).add('\n'); | 2978 if (reason != null) { |
| 2979 description.add(reason).add('\n'); |
| 2980 } |
181 return description.toString(); | 2981 return description.toString(); |
182 }; | 2982 }; |
183 dart.fn(unittest._defaultFailFormatter, core.String, [dart.dynamic, src__inter
faces.Matcher, core.String, core.Map, core.bool]); | 2983 dart.fn(src__matcher__expect._defaultErrorFormatter, core.String, [dart.dynami
c, src__matcher__interfaces.Matcher, core.String, core.Map, core.bool]); |
184 unittest.useHtmlConfiguration = function(isLayoutTest) { | 2984 const _value$1 = Symbol('_value'); |
| 2985 src__matcher__map_matchers._ContainsValue = class _ContainsValue extends src__
matcher__interfaces.Matcher { |
| 2986 _ContainsValue(value) { |
| 2987 this[_value$1] = value; |
| 2988 super.Matcher(); |
| 2989 } |
| 2990 matches(item, matchState) { |
| 2991 return dart.as(dart.dsend(item, 'containsValue', this[_value$1]), core.boo
l); |
| 2992 } |
| 2993 describe(description) { |
| 2994 return description.add('contains value ').addDescriptionOf(this[_value$1])
; |
| 2995 } |
| 2996 }; |
| 2997 dart.setSignature(src__matcher__map_matchers._ContainsValue, { |
| 2998 constructors: () => ({_ContainsValue: [src__matcher__map_matchers._ContainsV
alue, [dart.dynamic]]}), |
| 2999 methods: () => ({ |
| 3000 matches: [core.bool, [dart.dynamic, core.Map]], |
| 3001 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 3002 }) |
| 3003 }); |
| 3004 const _key = Symbol('_key'); |
| 3005 const _valueMatcher = Symbol('_valueMatcher'); |
| 3006 src__matcher__map_matchers._ContainsMapping = class _ContainsMapping extends s
rc__matcher__interfaces.Matcher { |
| 3007 _ContainsMapping(key, valueMatcher) { |
| 3008 this[_key] = key; |
| 3009 this[_valueMatcher] = valueMatcher; |
| 3010 super.Matcher(); |
| 3011 } |
| 3012 matches(item, matchState) { |
| 3013 return dart.notNull(dart.as(dart.dsend(item, 'containsKey', this[_key]), c
ore.bool)) && dart.notNull(this[_valueMatcher].matches(dart.dindex(item, this[_k
ey]), matchState)); |
| 3014 } |
| 3015 describe(description) { |
| 3016 return description.add('contains pair ').addDescriptionOf(this[_key]).add(
' => ').addDescriptionOf(this[_valueMatcher]); |
| 3017 } |
| 3018 describeMismatch(item, mismatchDescription, matchState, verbose) { |
| 3019 if (!dart.notNull(dart.as(dart.dsend(item, 'containsKey', this[_key]), cor
e.bool))) { |
| 3020 return mismatchDescription.add(" doesn't contain key ").addDescriptionOf
(this[_key]); |
| 3021 } else { |
| 3022 mismatchDescription.add(' contains key ').addDescriptionOf(this[_key]).a
dd(' but with value '); |
| 3023 this[_valueMatcher].describeMismatch(dart.dindex(item, this[_key]), mism
atchDescription, matchState, verbose); |
| 3024 return mismatchDescription; |
| 3025 } |
| 3026 } |
| 3027 }; |
| 3028 dart.setSignature(src__matcher__map_matchers._ContainsMapping, { |
| 3029 constructors: () => ({_ContainsMapping: [src__matcher__map_matchers._Contain
sMapping, [dart.dynamic, src__matcher__interfaces.Matcher]]}), |
| 3030 methods: () => ({ |
| 3031 matches: [core.bool, [dart.dynamic, core.Map]], |
| 3032 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 3033 }) |
| 3034 }); |
| 3035 const _matcher$2 = Symbol('_matcher'); |
| 3036 src__matcher__prints_matcher._Prints = class _Prints extends src__matcher__int
erfaces.Matcher { |
| 3037 _Prints(matcher) { |
| 3038 this[_matcher$2] = matcher; |
| 3039 super.Matcher(); |
| 3040 } |
| 3041 matches(item, matchState) { |
| 3042 if (!dart.is(item, core.Function)) return false; |
| 3043 let buffer = new core.StringBuffer(); |
| 3044 let result = async.runZoned(dart.dynamic)(dart.as(item, dart.functionType(
dart.dynamic, [])), {zoneSpecification: async.ZoneSpecification.new({print: dart
.fn((_, __, ____, line) => { |
| 3045 buffer.writeln(line); |
| 3046 }, dart.void, [async.Zone, async.ZoneDelegate, async.Zone, core.String
])})}); |
| 3047 if (!dart.is(result, async.Future)) { |
| 3048 let actual = buffer.toString(); |
| 3049 matchState[dartx.set]('prints.actual', actual); |
| 3050 return this[_matcher$2].matches(actual, matchState); |
| 3051 } |
| 3052 return src__matcher__future_matchers.completes.matches(dart.dsend(result,
'then', dart.dcall(src__matcher__expect.wrapAsync, dart.fn(_ => { |
| 3053 src__matcher__expect.expect(buffer.toString(), this[_matcher$2]); |
| 3054 }), 'prints')), matchState); |
| 3055 } |
| 3056 describe(description) { |
| 3057 return description.add('prints ').addDescriptionOf(this[_matcher$2]); |
| 3058 } |
| 3059 describeMismatch(item, description, matchState, verbose) { |
| 3060 let actual = matchState[dartx.remove]('prints.actual'); |
| 3061 if (actual == null) return description; |
| 3062 if (dart.notNull(dart.as(dart.dload(actual, 'isEmpty'), core.bool))) retur
n description.add("printed nothing."); |
| 3063 description.add('printed ').addDescriptionOf(actual); |
| 3064 let innerMismatch = dart.toString(this[_matcher$2].describeMismatch(actual
, new src__matcher__description.StringDescription(), matchState, verbose)); |
| 3065 if (dart.notNull(innerMismatch[dartx.isNotEmpty])) { |
| 3066 description.add('\n Which: ').add(dart.toString(innerMismatch)); |
| 3067 } |
| 3068 return description; |
| 3069 } |
| 3070 }; |
| 3071 dart.setSignature(src__matcher__prints_matcher._Prints, { |
| 3072 constructors: () => ({_Prints: [src__matcher__prints_matcher._Prints, [src__
matcher__interfaces.Matcher]]}), |
| 3073 methods: () => ({ |
| 3074 matches: [core.bool, [dart.dynamic, core.Map]], |
| 3075 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 3076 }) |
| 3077 }); |
| 3078 const _matcher$3 = Symbol('_matcher'); |
| 3079 src__matcher__iterable_matchers._IterableMatcher = class _IterableMatcher exte
nds src__matcher__interfaces.Matcher { |
| 3080 _IterableMatcher() { |
| 3081 super.Matcher(); |
| 3082 } |
| 3083 describeMismatch(item, mismatchDescription, matchState, verbose) { |
| 3084 if (!dart.is(item, core.Iterable)) { |
| 3085 return mismatchDescription.addDescriptionOf(item).add(' not an Iterable'
); |
| 3086 } else { |
| 3087 return super.describeMismatch(item, mismatchDescription, matchState, ver
bose); |
| 3088 } |
| 3089 } |
| 3090 }; |
| 3091 dart.setSignature(src__matcher__iterable_matchers._IterableMatcher, { |
| 3092 constructors: () => ({_IterableMatcher: [src__matcher__iterable_matchers._It
erableMatcher, []]}) |
| 3093 }); |
| 3094 src__matcher__iterable_matchers._EveryElement = class _EveryElement extends sr
c__matcher__iterable_matchers._IterableMatcher { |
| 3095 _EveryElement(matcher) { |
| 3096 this[_matcher$3] = matcher; |
| 3097 super._IterableMatcher(); |
| 3098 } |
| 3099 matches(item, matchState) { |
| 3100 if (!dart.is(item, core.Iterable)) { |
| 3101 return false; |
| 3102 } |
| 3103 let i = 0; |
| 3104 for (let element of dart.as(item, core.Iterable)) { |
| 3105 if (!dart.notNull(this[_matcher$3].matches(element, matchState))) { |
| 3106 src__matcher__util.addStateInfo(matchState, dart.map({index: i, elemen
t: element})); |
| 3107 return false; |
| 3108 } |
| 3109 ++i; |
| 3110 } |
| 3111 return true; |
| 3112 } |
| 3113 describe(description) { |
| 3114 return description.add('every element(').addDescriptionOf(this[_matcher$3]
).add(')'); |
| 3115 } |
| 3116 describeMismatch(item, mismatchDescription, matchState, verbose) { |
| 3117 if (matchState[dartx.get]('index') != null) { |
| 3118 let index = matchState[dartx.get]('index'); |
| 3119 let element = matchState[dartx.get]('element'); |
| 3120 mismatchDescription.add('has value ').addDescriptionOf(element).add(' wh
ich '); |
| 3121 let subDescription = new src__matcher__description.StringDescription(); |
| 3122 this[_matcher$3].describeMismatch(element, subDescription, dart.as(match
State[dartx.get]('state'), core.Map), verbose); |
| 3123 if (dart.notNull(subDescription.length) > 0) { |
| 3124 mismatchDescription.add(subDescription.toString()); |
| 3125 } else { |
| 3126 mismatchDescription.add("doesn't match "); |
| 3127 this[_matcher$3].describe(mismatchDescription); |
| 3128 } |
| 3129 mismatchDescription.add(` at index ${index}`); |
| 3130 return mismatchDescription; |
| 3131 } |
| 3132 return super.describeMismatch(item, mismatchDescription, matchState, verbo
se); |
| 3133 } |
| 3134 }; |
| 3135 dart.setSignature(src__matcher__iterable_matchers._EveryElement, { |
| 3136 constructors: () => ({_EveryElement: [src__matcher__iterable_matchers._Every
Element, [src__matcher__interfaces.Matcher]]}), |
| 3137 methods: () => ({ |
| 3138 matches: [core.bool, [dart.dynamic, core.Map]], |
| 3139 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 3140 }) |
| 3141 }); |
| 3142 src__matcher__iterable_matchers._AnyElement = class _AnyElement extends src__m
atcher__iterable_matchers._IterableMatcher { |
| 3143 _AnyElement(matcher) { |
| 3144 this[_matcher$3] = matcher; |
| 3145 super._IterableMatcher(); |
| 3146 } |
| 3147 matches(item, matchState) { |
| 3148 return dart.as(dart.dsend(item, 'any', dart.fn(e => this[_matcher$3].match
es(e, matchState), core.bool, [dart.dynamic])), core.bool); |
| 3149 } |
| 3150 describe(description) { |
| 3151 return description.add('some element ').addDescriptionOf(this[_matcher$3])
; |
| 3152 } |
| 3153 }; |
| 3154 dart.setSignature(src__matcher__iterable_matchers._AnyElement, { |
| 3155 constructors: () => ({_AnyElement: [src__matcher__iterable_matchers._AnyElem
ent, [src__matcher__interfaces.Matcher]]}), |
| 3156 methods: () => ({ |
| 3157 matches: [core.bool, [dart.dynamic, core.Map]], |
| 3158 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 3159 }) |
| 3160 }); |
| 3161 const _expected$ = Symbol('_expected'); |
| 3162 src__matcher__iterable_matchers._OrderedEquals = class _OrderedEquals extends
src__matcher__interfaces.Matcher { |
| 3163 _OrderedEquals(expected) { |
| 3164 this[_expected$] = expected; |
| 3165 this[_matcher$3] = null; |
| 3166 super.Matcher(); |
| 3167 this[_matcher$3] = src__matcher__core_matchers.equals(this[_expected$], 1)
; |
| 3168 } |
| 3169 matches(item, matchState) { |
| 3170 return dart.is(item, core.Iterable) && dart.notNull(this[_matcher$3].match
es(item, matchState)); |
| 3171 } |
| 3172 describe(description) { |
| 3173 return description.add('equals ').addDescriptionOf(this[_expected$]).add('
ordered'); |
| 3174 } |
| 3175 describeMismatch(item, mismatchDescription, matchState, verbose) { |
| 3176 if (!dart.is(item, core.Iterable)) { |
| 3177 return mismatchDescription.add('is not an Iterable'); |
| 3178 } else { |
| 3179 return this[_matcher$3].describeMismatch(item, mismatchDescription, matc
hState, verbose); |
| 3180 } |
| 3181 } |
| 3182 }; |
| 3183 dart.setSignature(src__matcher__iterable_matchers._OrderedEquals, { |
| 3184 constructors: () => ({_OrderedEquals: [src__matcher__iterable_matchers._Orde
redEquals, [core.Iterable]]}), |
| 3185 methods: () => ({ |
| 3186 matches: [core.bool, [dart.dynamic, core.Map]], |
| 3187 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 3188 }) |
| 3189 }); |
| 3190 const _expectedValues = Symbol('_expectedValues'); |
| 3191 const _test = Symbol('_test'); |
| 3192 src__matcher__iterable_matchers._UnorderedMatches = class _UnorderedMatches ex
tends src__matcher__interfaces.Matcher { |
| 3193 _UnorderedMatches(expected) { |
| 3194 this[_expected$] = expected[dartx.map](src__matcher__interfaces.Matcher)(s
rc__matcher__util.wrapMatcher)[dartx.toList](); |
| 3195 super.Matcher(); |
| 3196 } |
| 3197 [_test](item) { |
| 3198 if (!dart.is(item, core.Iterable)) return 'not iterable'; |
| 3199 item = dart.dsend(item, 'toList'); |
| 3200 if (dart.notNull(this[_expected$][dartx.length]) > dart.notNull(dart.as(da
rt.dload(item, 'length'), core.num))) { |
| 3201 return `has too few elements (${dart.dload(item, 'length')} < ${this[_ex
pected$][dartx.length]})`; |
| 3202 } else if (dart.notNull(this[_expected$][dartx.length]) < dart.notNull(dar
t.as(dart.dload(item, 'length'), core.num))) { |
| 3203 return `has too many elements (${dart.dload(item, 'length')} > ${this[_e
xpected$][dartx.length]})`; |
| 3204 } |
| 3205 let matched = core.List$(core.bool).filled(dart.as(dart.dload(item, 'lengt
h'), core.int), false); |
| 3206 let expectedPosition = 0; |
| 3207 for (let expectedMatcher of this[_expected$]) { |
| 3208 let actualPosition = 0; |
| 3209 let gotMatch = false; |
| 3210 for (let actualElement of dart.as(item, core.Iterable)) { |
| 3211 if (!dart.notNull(matched[dartx.get](actualPosition))) { |
| 3212 if (dart.notNull(expectedMatcher.matches(actualElement, dart.map()))
) { |
| 3213 matched[dartx.set](actualPosition, gotMatch = true); |
| 3214 break; |
| 3215 } |
| 3216 } |
| 3217 ++actualPosition; |
| 3218 } |
| 3219 if (!gotMatch) { |
| 3220 return dart.toString(new src__matcher__description.StringDescription()
.add('has no match for ').addDescriptionOf(expectedMatcher).add(` at index ${exp
ectedPosition}`)); |
| 3221 } |
| 3222 ++expectedPosition; |
| 3223 } |
| 3224 return null; |
| 3225 } |
| 3226 matches(item, mismatchState) { |
| 3227 return this[_test](item) == null; |
| 3228 } |
| 3229 describe(description) { |
| 3230 return description.add('matches ').addAll('[', ', ', ']', this[_expected$]
).add(' unordered'); |
| 3231 } |
| 3232 describeMismatch(item, mismatchDescription, matchState, verbose) { |
| 3233 return mismatchDescription.add(this[_test](item)); |
| 3234 } |
| 3235 }; |
| 3236 dart.setSignature(src__matcher__iterable_matchers._UnorderedMatches, { |
| 3237 constructors: () => ({_UnorderedMatches: [src__matcher__iterable_matchers._U
norderedMatches, [core.Iterable]]}), |
| 3238 methods: () => ({ |
| 3239 [_test]: [core.String, [dart.dynamic]], |
| 3240 matches: [core.bool, [dart.dynamic, core.Map]], |
| 3241 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 3242 }) |
| 3243 }); |
| 3244 src__matcher__iterable_matchers._UnorderedEquals = class _UnorderedEquals exte
nds src__matcher__iterable_matchers._UnorderedMatches { |
| 3245 _UnorderedEquals(expected) { |
| 3246 this[_expectedValues] = expected[dartx.toList](); |
| 3247 super._UnorderedMatches(expected[dartx.map](src__matcher__interfaces.Match
er)(src__matcher__core_matchers.equals)); |
| 3248 } |
| 3249 describe(description) { |
| 3250 return description.add('equals ').addDescriptionOf(this[_expectedValues]).
add(' unordered'); |
| 3251 } |
| 3252 }; |
| 3253 dart.setSignature(src__matcher__iterable_matchers._UnorderedEquals, { |
| 3254 constructors: () => ({_UnorderedEquals: [src__matcher__iterable_matchers._Un
orderedEquals, [core.Iterable]]}) |
| 3255 }); |
| 3256 src__matcher__iterable_matchers._Comparator = dart.typedef('_Comparator', () =
> dart.functionType(core.bool, [dart.dynamic, dart.dynamic])); |
| 3257 const _comparator = Symbol('_comparator'); |
| 3258 const _description$ = Symbol('_description'); |
| 3259 src__matcher__iterable_matchers._PairwiseCompare = class _PairwiseCompare exte
nds src__matcher__iterable_matchers._IterableMatcher { |
| 3260 _PairwiseCompare(expected, comparator, description) { |
| 3261 this[_expected$] = expected; |
| 3262 this[_comparator] = comparator; |
| 3263 this[_description$] = description; |
| 3264 super._IterableMatcher(); |
| 3265 } |
| 3266 matches(item, matchState) { |
| 3267 if (!dart.is(item, core.Iterable)) return false; |
| 3268 if (!dart.equals(dart.dload(item, 'length'), this[_expected$][dartx.length
])) return false; |
| 3269 let iterator = dart.dload(item, 'iterator'); |
| 3270 let i = 0; |
| 3271 for (let e of this[_expected$]) { |
| 3272 dart.dsend(iterator, 'moveNext'); |
| 3273 if (!dart.notNull(dart.dcall(this[_comparator], e, dart.dload(iterator,
'current')))) { |
| 3274 src__matcher__util.addStateInfo(matchState, dart.map({index: i, expect
ed: e, actual: dart.dload(iterator, 'current')})); |
| 3275 return false; |
| 3276 } |
| 3277 i++; |
| 3278 } |
| 3279 return true; |
| 3280 } |
| 3281 describe(description) { |
| 3282 return description.add(`pairwise ${this[_description$]} `).addDescriptionO
f(this[_expected$]); |
| 3283 } |
| 3284 describeMismatch(item, mismatchDescription, matchState, verbose) { |
| 3285 if (!dart.is(item, core.Iterable)) { |
| 3286 return mismatchDescription.add('is not an Iterable'); |
| 3287 } else if (!dart.equals(dart.dload(item, 'length'), this[_expected$][dartx
.length])) { |
| 3288 return mismatchDescription.add(`has length ${dart.dload(item, 'length')}
instead of ${this[_expected$][dartx.length]}`); |
| 3289 } else { |
| 3290 return mismatchDescription.add('has ').addDescriptionOf(matchState[dartx
.get]("actual")).add(` which is not ${this[_description$]} `).addDescriptionOf(m
atchState[dartx.get]("expected")).add(` at index ${matchState[dartx.get]("index"
)}`); |
| 3291 } |
| 3292 } |
| 3293 }; |
| 3294 dart.setSignature(src__matcher__iterable_matchers._PairwiseCompare, { |
| 3295 constructors: () => ({_PairwiseCompare: [src__matcher__iterable_matchers._Pa
irwiseCompare, [core.Iterable, src__matcher__iterable_matchers._Comparator, core
.String]]}), |
| 3296 methods: () => ({ |
| 3297 matches: [core.bool, [dart.dynamic, core.Map]], |
| 3298 describe: [src__matcher__interfaces.Description, [src__matcher__interfaces
.Description]] |
| 3299 }) |
| 3300 }); |
| 3301 const _startTime = Symbol('_startTime'); |
| 3302 const _runningTime = Symbol('_runningTime'); |
| 3303 const _testFunction = Symbol('_testFunction'); |
| 3304 const _setUp = Symbol('_setUp'); |
| 3305 const _tearDown = Symbol('_tearDown'); |
| 3306 const _testComplete = Symbol('_testComplete'); |
| 3307 const _errorHandler = Symbol('_errorHandler'); |
| 3308 const _setResult = Symbol('_setResult'); |
| 3309 const _complete = Symbol('_complete'); |
| 3310 src__internal_test_case.InternalTestCase = class InternalTestCase extends core
.Object { |
| 3311 get passed() { |
| 3312 return this.result == unittest.PASS; |
| 3313 } |
| 3314 get startTime() { |
| 3315 return this[_startTime]; |
| 3316 } |
| 3317 get runningTime() { |
| 3318 return this[_runningTime]; |
| 3319 } |
| 3320 get isComplete() { |
| 3321 return !dart.notNull(this.enabled) || this.result != null; |
| 3322 } |
| 3323 InternalTestCase(id, description, testFunction) { |
| 3324 this.id = id; |
| 3325 this.description = description; |
| 3326 this[_testFunction] = testFunction; |
| 3327 this.currentGroup = src__test_environment.environment.currentContext.fullN
ame; |
| 3328 this[_setUp] = src__test_environment.environment.currentContext.testSetUp; |
| 3329 this[_tearDown] = src__test_environment.environment.currentContext.testTea
rDown; |
| 3330 this.callbackFunctionsOutstanding = 0; |
| 3331 this.message = ''; |
| 3332 this.result = null; |
| 3333 this.stackTrace = null; |
| 3334 this[_startTime] = null; |
| 3335 this[_runningTime] = null; |
| 3336 this.enabled = true; |
| 3337 this[_testComplete] = null; |
| 3338 } |
| 3339 [_errorHandler](stage) { |
| 3340 return dart.fn((e, stack) => { |
| 3341 if (stack == null && dart.is(e, core.Error)) { |
| 3342 stack = e.stackTrace; |
| 3343 } |
| 3344 if (this.result == null || this.result == unittest.PASS) { |
| 3345 if (dart.is(e, src__matcher__expect.TestFailure)) { |
| 3346 this.fail(`${e}`, dart.as(stack, core.StackTrace)); |
| 3347 } else { |
| 3348 this.error(`${stage} failed: Caught ${e}`, dart.as(stack, core.Stack
Trace)); |
| 3349 } |
| 3350 } |
| 3351 }); |
| 3352 } |
| 3353 run() { |
| 3354 if (!dart.notNull(this.enabled)) return async.Future.value(); |
| 3355 this.result = this.stackTrace = null; |
| 3356 this.message = ''; |
| 3357 return async.Future.value().then(dart.dynamic)(dart.fn(_ => { |
| 3358 if (this[_setUp] != null) return dart.dcall(this[_setUp]); |
| 3359 })).catchError(this[_errorHandler]('Setup')).then(async.Future)(dart.fn(_
=> { |
| 3360 if (this.result != null) return async.Future.value(); |
| 3361 src__test_environment.config.onTestStart(this); |
| 3362 this[_startTime] = new core.DateTime.now(); |
| 3363 this[_runningTime] = null; |
| 3364 this.callbackFunctionsOutstanding = dart.notNull(this.callbackFunctionsO
utstanding) + 1; |
| 3365 let testReturn = this[_testFunction](); |
| 3366 if (dart.is(testReturn, async.Future)) { |
| 3367 this.callbackFunctionsOutstanding = dart.notNull(this.callbackFunction
sOutstanding) + 1; |
| 3368 testReturn.catchError(this[_errorHandler]('Test')).whenComplete(dart.b
ind(this, 'markCallbackComplete')); |
| 3369 } |
| 3370 }, async.Future, [dart.dynamic])).catchError(this[_errorHandler]('Test')).
then(dart.dynamic)(dart.fn(_ => { |
| 3371 this.markCallbackComplete(); |
| 3372 if (this.result == null) { |
| 3373 this[_testComplete] = async.Completer.new(); |
| 3374 return this[_testComplete].future.whenComplete(dart.fn(() => { |
| 3375 if (this[_tearDown] != null) { |
| 3376 return dart.dcall(this[_tearDown]); |
| 3377 } |
| 3378 })).catchError(this[_errorHandler]('Teardown')); |
| 3379 } else if (this[_tearDown] != null) { |
| 3380 return dart.dcall(this[_tearDown]); |
| 3381 } |
| 3382 })).catchError(this[_errorHandler]('Teardown')).whenComplete(dart.fn(() =>
{ |
| 3383 this[_setUp] = null; |
| 3384 this[_tearDown] = null; |
| 3385 this[_testFunction] = null; |
| 3386 })); |
| 3387 } |
| 3388 [_complete](testResult, messageText, stack) { |
| 3389 if (messageText === void 0) messageText = ''; |
| 3390 if (stack === void 0) stack = null; |
| 3391 if (this.runningTime == null) { |
| 3392 if (this.startTime != null) { |
| 3393 this[_runningTime] = new core.DateTime.now().difference(this.startTime
); |
| 3394 } else { |
| 3395 this[_runningTime] = dart.const(new core.Duration({seconds: 0})); |
| 3396 } |
| 3397 } |
| 3398 this[_setResult](testResult, messageText, stack); |
| 3399 if (this[_testComplete] != null) { |
| 3400 let t = this[_testComplete]; |
| 3401 this[_testComplete] = null; |
| 3402 t.complete(this); |
| 3403 } |
| 3404 } |
| 3405 [_setResult](testResult, messageText, stack) { |
| 3406 this.message = messageText; |
| 3407 this.stackTrace = src__utils.getTrace(stack, unittest.formatStacks, unitte
st.filterStacks); |
| 3408 if (this.stackTrace == null) this.stackTrace = stack; |
| 3409 if (this.result == null) { |
| 3410 this.result = testResult; |
| 3411 src__test_environment.config.onTestResult(this); |
| 3412 } else { |
| 3413 this.result = testResult; |
| 3414 src__test_environment.config.onTestResultChanged(this); |
| 3415 } |
| 3416 } |
| 3417 pass() { |
| 3418 this[_complete](unittest.PASS); |
| 3419 } |
| 3420 registerException(error, stackTrace) { |
| 3421 if (stackTrace === void 0) stackTrace = null; |
| 3422 let message = dart.is(error, src__matcher__expect.TestFailure) ? error.mes
sage : `Caught ${error}`; |
| 3423 if (this.result == null) { |
| 3424 this.fail(message, stackTrace); |
| 3425 } else { |
| 3426 this.error(message, stackTrace); |
| 3427 } |
| 3428 } |
| 3429 fail(messageText, stack) { |
| 3430 if (stack === void 0) stack = null; |
| 3431 if (this.result != null) { |
| 3432 let newMessage = this.result == unittest.PASS ? `Test failed after initi
ally passing: ${messageText}` : `Test failed more than once: ${messageText}`; |
| 3433 this[_complete](unittest.ERROR, newMessage, stack); |
| 3434 } else { |
| 3435 this[_complete](unittest.FAIL, messageText, stack); |
| 3436 } |
| 3437 } |
| 3438 error(messageText, stack) { |
| 3439 if (stack === void 0) stack = null; |
| 3440 this[_complete](unittest.ERROR, messageText, stack); |
| 3441 } |
| 3442 markCallbackComplete() { |
| 3443 this.callbackFunctionsOutstanding = dart.notNull(this.callbackFunctionsOut
standing) - 1; |
| 3444 if (this.callbackFunctionsOutstanding == 0 && !dart.notNull(this.isComplet
e)) this.pass(); |
| 3445 } |
| 3446 toString() { |
| 3447 return this.result != null ? `${this.description}: ${this.result}` : this.
description; |
| 3448 } |
| 3449 }; |
| 3450 src__internal_test_case.InternalTestCase[dart.implements] = () => [src__test_c
ase.TestCase]; |
| 3451 dart.setSignature(src__internal_test_case.InternalTestCase, { |
| 3452 constructors: () => ({InternalTestCase: [src__internal_test_case.InternalTes
tCase, [core.int, core.String, unittest.TestFunction]]}), |
| 3453 methods: () => ({ |
| 3454 [_errorHandler]: [core.Function, [core.String]], |
| 3455 run: [async.Future, []], |
| 3456 [_complete]: [dart.void, [core.String], [core.String, core.StackTrace]], |
| 3457 [_setResult]: [dart.void, [core.String, core.String, core.StackTrace]], |
| 3458 pass: [dart.void, []], |
| 3459 registerException: [dart.void, [dart.dynamic], [core.StackTrace]], |
| 3460 fail: [dart.void, [core.String], [core.StackTrace]], |
| 3461 error: [dart.void, [core.String], [core.StackTrace]], |
| 3462 markCallbackComplete: [dart.void, []] |
| 3463 }) |
| 3464 }); |
| 3465 src__expected_function._PLACEHOLDER = dart.const(new core.Object()); |
| 3466 src__expected_function._Func0 = dart.typedef('_Func0', () => dart.functionType
(dart.dynamic, [])); |
| 3467 src__expected_function._Func1 = dart.typedef('_Func1', () => dart.functionType
(dart.dynamic, [dart.dynamic])); |
| 3468 src__expected_function._Func2 = dart.typedef('_Func2', () => dart.functionType
(dart.dynamic, [dart.dynamic, dart.dynamic])); |
| 3469 src__expected_function._Func3 = dart.typedef('_Func3', () => dart.functionType
(dart.dynamic, [dart.dynamic, dart.dynamic, dart.dynamic])); |
| 3470 src__expected_function._Func4 = dart.typedef('_Func4', () => dart.functionType
(dart.dynamic, [dart.dynamic, dart.dynamic, dart.dynamic, dart.dynamic])); |
| 3471 src__expected_function._Func5 = dart.typedef('_Func5', () => dart.functionType
(dart.dynamic, [dart.dynamic, dart.dynamic, dart.dynamic, dart.dynamic, dart.dyn
amic])); |
| 3472 src__expected_function._Func6 = dart.typedef('_Func6', () => dart.functionType
(dart.dynamic, [dart.dynamic, dart.dynamic, dart.dynamic, dart.dynamic, dart.dyn
amic, dart.dynamic])); |
| 3473 src__expected_function._IsDoneCallback = dart.typedef('_IsDoneCallback', () =>
dart.functionType(core.bool, [])); |
| 3474 const _callback = Symbol('_callback'); |
| 3475 const _minExpectedCalls = Symbol('_minExpectedCalls'); |
| 3476 const _maxExpectedCalls = Symbol('_maxExpectedCalls'); |
| 3477 const _isDone = Symbol('_isDone'); |
| 3478 const _reason = Symbol('_reason'); |
| 3479 const _testCase = Symbol('_testCase'); |
| 3480 const _id$ = Symbol('_id'); |
| 3481 const _actualCalls = Symbol('_actualCalls'); |
| 3482 const _complete$ = Symbol('_complete'); |
| 3483 const _max6 = Symbol('_max6'); |
| 3484 const _max5 = Symbol('_max5'); |
| 3485 const _max4 = Symbol('_max4'); |
| 3486 const _max3 = Symbol('_max3'); |
| 3487 const _max2 = Symbol('_max2'); |
| 3488 const _max1 = Symbol('_max1'); |
| 3489 const _max0 = Symbol('_max0'); |
| 3490 const _run = Symbol('_run'); |
| 3491 const _afterRun = Symbol('_afterRun'); |
| 3492 src__expected_function.ExpectedFunction = class ExpectedFunction extends core.
Object { |
| 3493 ExpectedFunction(callback, minExpected, maxExpected, opts) { |
| 3494 let id = opts && 'id' in opts ? opts.id : null; |
| 3495 let reason = opts && 'reason' in opts ? opts.reason : null; |
| 3496 let isDone = opts && 'isDone' in opts ? opts.isDone : null; |
| 3497 this[_callback] = callback; |
| 3498 this[_minExpectedCalls] = minExpected; |
| 3499 this[_maxExpectedCalls] = maxExpected == 0 && dart.notNull(minExpected) >
0 ? minExpected : maxExpected; |
| 3500 this[_isDone] = isDone; |
| 3501 this[_reason] = reason == null ? '' : `\n${reason}`; |
| 3502 this[_testCase] = dart.as(unittest.currentTestCase, src__internal_test_cas
e.InternalTestCase); |
| 3503 this[_id$] = src__expected_function.ExpectedFunction._makeCallbackId(id, c
allback); |
| 3504 this[_actualCalls] = 0; |
| 3505 this[_complete$] = null; |
| 3506 unittest.ensureInitialized(); |
| 3507 if (this[_testCase] == null) { |
| 3508 dart.throw(new core.StateError("No valid test. Did you forget to run you
r test " + "inside a call to test()?")); |
| 3509 } |
| 3510 if (isDone != null || dart.notNull(minExpected) > 0) { |
| 3511 this[_testCase].callbackFunctionsOutstanding = dart.notNull(this[_testCa
se].callbackFunctionsOutstanding) + 1; |
| 3512 this[_complete$] = false; |
| 3513 } else { |
| 3514 this[_complete$] = true; |
| 3515 } |
| 3516 } |
| 3517 static _makeCallbackId(id, callback) { |
| 3518 if (id != null) return `${id} `; |
| 3519 let toString = dart.toString(callback); |
| 3520 let prefix = "Function '"; |
| 3521 let start = toString[dartx.indexOf](prefix); |
| 3522 if (start == -1) return ''; |
| 3523 start = dart.notNull(start) + dart.notNull(prefix[dartx.length]); |
| 3524 let end = toString[dartx.indexOf]("'", start); |
| 3525 if (end == -1) return ''; |
| 3526 return `${toString[dartx.substring](start, end)} `; |
| 3527 } |
| 3528 get func() { |
| 3529 if (dart.is(this[_callback], src__expected_function._Func6)) return dart.b
ind(this, _max6); |
| 3530 if (dart.is(this[_callback], src__expected_function._Func5)) return dart.b
ind(this, _max5); |
| 3531 if (dart.is(this[_callback], src__expected_function._Func4)) return dart.b
ind(this, _max4); |
| 3532 if (dart.is(this[_callback], src__expected_function._Func3)) return dart.b
ind(this, _max3); |
| 3533 if (dart.is(this[_callback], src__expected_function._Func2)) return dart.b
ind(this, _max2); |
| 3534 if (dart.is(this[_callback], src__expected_function._Func1)) return dart.b
ind(this, _max1); |
| 3535 if (dart.is(this[_callback], src__expected_function._Func0)) return dart.b
ind(this, _max0); |
| 3536 dart.throw(new core.ArgumentError('The wrapped function has more than 6 re
quired arguments')); |
| 3537 } |
| 3538 [_max0]() { |
| 3539 return this[_max6](); |
| 3540 } |
| 3541 [_max1](a0) { |
| 3542 if (a0 === void 0) a0 = src__expected_function._PLACEHOLDER; |
| 3543 return this[_max6](a0); |
| 3544 } |
| 3545 [_max2](a0, a1) { |
| 3546 if (a0 === void 0) a0 = src__expected_function._PLACEHOLDER; |
| 3547 if (a1 === void 0) a1 = src__expected_function._PLACEHOLDER; |
| 3548 return this[_max6](a0, a1); |
| 3549 } |
| 3550 [_max3](a0, a1, a2) { |
| 3551 if (a0 === void 0) a0 = src__expected_function._PLACEHOLDER; |
| 3552 if (a1 === void 0) a1 = src__expected_function._PLACEHOLDER; |
| 3553 if (a2 === void 0) a2 = src__expected_function._PLACEHOLDER; |
| 3554 return this[_max6](a0, a1, a2); |
| 3555 } |
| 3556 [_max4](a0, a1, a2, a3) { |
| 3557 if (a0 === void 0) a0 = src__expected_function._PLACEHOLDER; |
| 3558 if (a1 === void 0) a1 = src__expected_function._PLACEHOLDER; |
| 3559 if (a2 === void 0) a2 = src__expected_function._PLACEHOLDER; |
| 3560 if (a3 === void 0) a3 = src__expected_function._PLACEHOLDER; |
| 3561 return this[_max6](a0, a1, a2, a3); |
| 3562 } |
| 3563 [_max5](a0, a1, a2, a3, a4) { |
| 3564 if (a0 === void 0) a0 = src__expected_function._PLACEHOLDER; |
| 3565 if (a1 === void 0) a1 = src__expected_function._PLACEHOLDER; |
| 3566 if (a2 === void 0) a2 = src__expected_function._PLACEHOLDER; |
| 3567 if (a3 === void 0) a3 = src__expected_function._PLACEHOLDER; |
| 3568 if (a4 === void 0) a4 = src__expected_function._PLACEHOLDER; |
| 3569 return this[_max6](a0, a1, a2, a3, a4); |
| 3570 } |
| 3571 [_max6](a0, a1, a2, a3, a4, a5) { |
| 3572 if (a0 === void 0) a0 = src__expected_function._PLACEHOLDER; |
| 3573 if (a1 === void 0) a1 = src__expected_function._PLACEHOLDER; |
| 3574 if (a2 === void 0) a2 = src__expected_function._PLACEHOLDER; |
| 3575 if (a3 === void 0) a3 = src__expected_function._PLACEHOLDER; |
| 3576 if (a4 === void 0) a4 = src__expected_function._PLACEHOLDER; |
| 3577 if (a5 === void 0) a5 = src__expected_function._PLACEHOLDER; |
| 3578 return this[_run]([a0, a1, a2, a3, a4, a5][dartx.where](dart.fn(a => !dart
.equals(a, src__expected_function._PLACEHOLDER), core.bool, [dart.dynamic]))); |
| 3579 } |
| 3580 [_run](args) { |
| 3581 try { |
| 3582 this[_actualCalls] = dart.notNull(this[_actualCalls]) + 1; |
| 3583 if (dart.notNull(this[_testCase].isComplete)) { |
| 3584 if (this[_testCase].result == unittest.PASS) { |
| 3585 this[_testCase].error(`Callback ${this[_id$]}called (${this[_actualC
alls]}) after test case ` + `${this[_testCase].description} had already been mar
ked as ` + `${this[_testCase].result}.${this[_reason]}`); |
| 3586 } |
| 3587 return null; |
| 3588 } else if (dart.notNull(this[_maxExpectedCalls]) >= 0 && dart.notNull(th
is[_actualCalls]) > dart.notNull(this[_maxExpectedCalls])) { |
| 3589 dart.throw(new src__matcher__expect.TestFailure(`Callback ${this[_id$]
}called more times than expected ` + `(${this[_maxExpectedCalls]}).${this[_reaso
n]}`)); |
| 3590 } |
| 3591 return core.Function.apply(this[_callback], args[dartx.toList]()); |
| 3592 } catch (error) { |
| 3593 let stackTrace = dart.stackTrace(error); |
| 3594 this[_testCase].registerException(error, stackTrace); |
| 3595 return null; |
| 3596 } |
| 3597 finally { |
| 3598 this[_afterRun](); |
| 3599 } |
| 3600 } |
| 3601 [_afterRun]() { |
| 3602 if (dart.notNull(this[_complete$])) return; |
| 3603 if (dart.notNull(this[_minExpectedCalls]) > 0 && dart.notNull(this[_actual
Calls]) < dart.notNull(this[_minExpectedCalls])) return; |
| 3604 if (this[_isDone] != null && !dart.notNull(this[_isDone]())) return; |
| 3605 this[_complete$] = true; |
| 3606 this[_testCase].markCallbackComplete(); |
| 3607 } |
| 3608 }; |
| 3609 dart.setSignature(src__expected_function.ExpectedFunction, { |
| 3610 constructors: () => ({ExpectedFunction: [src__expected_function.ExpectedFunc
tion, [core.Function, core.int, core.int], {id: core.String, reason: core.String
, isDone: dart.functionType(core.bool, [])}]}), |
| 3611 methods: () => ({ |
| 3612 [_max0]: [dart.dynamic, []], |
| 3613 [_max1]: [dart.dynamic, [], [dart.dynamic]], |
| 3614 [_max2]: [dart.dynamic, [], [dart.dynamic, dart.dynamic]], |
| 3615 [_max3]: [dart.dynamic, [], [dart.dynamic, dart.dynamic, dart.dynamic]], |
| 3616 [_max4]: [dart.dynamic, [], [dart.dynamic, dart.dynamic, dart.dynamic, dar
t.dynamic]], |
| 3617 [_max5]: [dart.dynamic, [], [dart.dynamic, dart.dynamic, dart.dynamic, dar
t.dynamic, dart.dynamic]], |
| 3618 [_max6]: [dart.dynamic, [], [dart.dynamic, dart.dynamic, dart.dynamic, dar
t.dynamic, dart.dynamic, dart.dynamic]], |
| 3619 [_run]: [dart.dynamic, [core.Iterable]], |
| 3620 [_afterRun]: [dart.void, []] |
| 3621 }), |
| 3622 statics: () => ({_makeCallbackId: [core.String, [core.String, core.Function]
]}), |
| 3623 names: ['_makeCallbackId'] |
| 3624 }); |
| 3625 compact_vm_config._GREEN = '[32m'; |
| 3626 compact_vm_config._RED = '[31m'; |
| 3627 compact_vm_config._NONE = '[0m'; |
| 3628 compact_vm_config.MAX_LINE = 80; |
| 3629 const _passing = Symbol('_passing'); |
| 3630 const _failing = Symbol('_failing'); |
| 3631 const _receivePort$ = Symbol('_receivePort'); |
| 3632 const _start = Symbol('_start'); |
| 3633 const _lastLength = Symbol('_lastLength'); |
| 3634 const _nonVisiblePrefix = Symbol('_nonVisiblePrefix'); |
| 3635 const _pass = Symbol('_pass'); |
| 3636 const _fail = Symbol('_fail'); |
| 3637 const _progressLine = Symbol('_progressLine'); |
| 3638 const _timeString = Symbol('_timeString'); |
| 3639 const _snippet = Symbol('_snippet'); |
| 3640 const _padTime = Symbol('_padTime'); |
| 3641 compact_vm_config.CompactVMConfiguration = class CompactVMConfiguration extend
s vm_config.VMConfiguration { |
| 3642 CompactVMConfiguration() { |
| 3643 this[_passing] = core.Set$(core.int).new(); |
| 3644 this[_failing] = core.Set$(core.int).new(); |
| 3645 this[_receivePort$] = null; |
| 3646 this[_start] = null; |
| 3647 this[_lastLength] = 0; |
| 3648 this[_nonVisiblePrefix] = 1 + dart.notNull(compact_vm_config._GREEN[dartx.
length]) + dart.notNull(compact_vm_config._NONE[dartx.length]); |
| 3649 super.VMConfiguration(); |
| 3650 } |
| 3651 get [_pass]() { |
| 3652 return this[_passing].length; |
| 3653 } |
| 3654 get [_fail]() { |
| 3655 return this[_failing].length; |
| 3656 } |
| 3657 onInit() { |
| 3658 this[_receivePort$] = isolate.ReceivePort.new(); |
| 3659 } |
| 3660 onStart() { |
| 3661 this[_start] = new core.DateTime.now(); |
| 3662 } |
| 3663 onTestStart(test) { |
| 3664 super.onTestStart(test); |
| 3665 this[_progressLine](test.description); |
| 3666 } |
| 3667 onTestResult(test) { |
| 3668 super.onTestResult(test); |
| 3669 if (test.result == unittest.PASS) { |
| 3670 this[_passing].add(test.id); |
| 3671 this[_progressLine](test.description); |
| 3672 } else { |
| 3673 this[_failing].add(test.id); |
| 3674 this[_progressLine](test.description); |
| 3675 compact_vm_config._print(); |
| 3676 if (test.message != '') { |
| 3677 compact_vm_config._print(src__utils.indent(test.message)); |
| 3678 } |
| 3679 if (test.stackTrace != null) { |
| 3680 compact_vm_config._print(src__utils.indent(dart.toString(test.stackTra
ce))); |
| 3681 } |
| 3682 } |
| 3683 } |
| 3684 onTestResultChanged(test) { |
| 3685 this[_passing].remove(test.id); |
| 3686 this[_failing].add(test.id); |
| 3687 this[_progressLine](test.description); |
| 3688 compact_vm_config._print(); |
| 3689 if (test.message != '') { |
| 3690 compact_vm_config._print(src__utils.indent(test.message)); |
| 3691 } |
| 3692 if (test.stackTrace != null) { |
| 3693 compact_vm_config._print(src__utils.indent(dart.toString(test.stackTrace
))); |
| 3694 } |
| 3695 } |
| 3696 onDone(success) { |
| 3697 async.Future.wait(dart.dynamic)(dart.list([io.stdout.close(), io.stderr.cl
ose()], async.Future)).then(dart.dynamic)(dart.fn(_ => { |
| 3698 this[_receivePort$].close(); |
| 3699 io.exit(dart.notNull(success) ? 0 : 1); |
| 3700 }, dart.dynamic, [core.List])); |
| 3701 } |
| 3702 onSummary(passed, failed, errors, results, uncaughtError) { |
| 3703 if (passed == 0 && failed == 0 && errors == 0 && uncaughtError == null) { |
| 3704 compact_vm_config._print('\nNo tests ran.'); |
| 3705 } else if (failed == 0 && errors == 0 && uncaughtError == null) { |
| 3706 this[_progressLine]('All tests passed!', compact_vm_config._NONE); |
| 3707 compact_vm_config._print(); |
| 3708 } else { |
| 3709 this[_progressLine]('Some tests failed.', compact_vm_config._RED); |
| 3710 compact_vm_config._print(); |
| 3711 if (uncaughtError != null) { |
| 3712 compact_vm_config._print(`Top-level uncaught error: ${uncaughtError}`)
; |
| 3713 } |
| 3714 compact_vm_config._print(`${passed} PASSED, ${failed} FAILED, ${errors}
ERRORS`); |
| 3715 } |
| 3716 } |
| 3717 [_progressLine](message, color) { |
| 3718 if (color === void 0) color = compact_vm_config._NONE; |
| 3719 let duration = new core.DateTime.now().difference(this[_start]); |
| 3720 let buffer = new core.StringBuffer(); |
| 3721 buffer.write(`\r${this[_timeString](duration)} `); |
| 3722 buffer.write(compact_vm_config._GREEN); |
| 3723 buffer.write('+'); |
| 3724 buffer.write(this[_pass]); |
| 3725 buffer.write(compact_vm_config._NONE); |
| 3726 if (this[_fail] != 0) { |
| 3727 buffer.write(compact_vm_config._RED); |
| 3728 buffer.write(' -'); |
| 3729 buffer.write(this[_fail]); |
| 3730 buffer.write(compact_vm_config._NONE); |
| 3731 } |
| 3732 buffer.write(': '); |
| 3733 buffer.write(color); |
| 3734 let nonVisible = dart.notNull(this[_nonVisiblePrefix]) + dart.notNull(colo
r[dartx.length]) + (this[_fail] != 0 ? dart.notNull(compact_vm_config._RED[dartx
.length]) + dart.notNull(compact_vm_config._NONE[dartx.length]) : 0); |
| 3735 let len = dart.notNull(buffer.length) - nonVisible; |
| 3736 buffer.write(this[_snippet](message, dart.notNull(compact_vm_config.MAX_LI
NE) - len)); |
| 3737 buffer.write(compact_vm_config._NONE); |
| 3738 len = dart.notNull(buffer.length) - nonVisible - dart.notNull(compact_vm_c
onfig._NONE[dartx.length]); |
| 3739 if (len > dart.notNull(this[_lastLength])) { |
| 3740 this[_lastLength] = len; |
| 3741 } else { |
| 3742 while (len < dart.notNull(this[_lastLength])) { |
| 3743 buffer.write(' '); |
| 3744 this[_lastLength] = dart.notNull(this[_lastLength]) - 1; |
| 3745 } |
| 3746 } |
| 3747 io.stdout.write(buffer.toString()); |
| 3748 } |
| 3749 [_padTime](time) { |
| 3750 return time == 0 ? '00' : dart.notNull(time) < 10 ? `0${time}` : `${time}`
; |
| 3751 } |
| 3752 [_timeString](duration) { |
| 3753 let min = duration.inMinutes; |
| 3754 let sec = duration.inSeconds[dartx['%']](60); |
| 3755 return `${this[_padTime](min)}:${this[_padTime](sec)}`; |
| 3756 } |
| 3757 [_snippet](text, maxLength) { |
| 3758 if (dart.notNull(text[dartx.length]) <= dart.notNull(maxLength)) return te
xt; |
| 3759 let words = text[dartx.split](' '); |
| 3760 if (dart.notNull(words[dartx.length]) > 1) { |
| 3761 let i = words[dartx.length]; |
| 3762 let len = dart.notNull(words[dartx.first][dartx.length]) + 4; |
| 3763 do { |
| 3764 len = len + (1 + dart.notNull(words[dartx.get]((i = dart.notNull(i) -
1))[dartx.length])); |
| 3765 } while (len <= dart.notNull(maxLength) && dart.notNull(i) > 0); |
| 3766 if (len > dart.notNull(maxLength) || i == 0) { |
| 3767 i = dart.notNull(i) + 1; |
| 3768 } |
| 3769 if (dart.notNull(i) < dart.notNull(words[dartx.length]) - 4) { |
| 3770 let buffer = new core.StringBuffer(); |
| 3771 buffer.write(words[dartx.first]); |
| 3772 buffer.write(' ...'); |
| 3773 for (; dart.notNull(i) < dart.notNull(words[dartx.length]); i = dart.n
otNull(i) + 1) { |
| 3774 buffer.write(' '); |
| 3775 buffer.write(words[dartx.get](i)); |
| 3776 } |
| 3777 return buffer.toString(); |
| 3778 } |
| 3779 } |
| 3780 let res = text[dartx.substring](dart.notNull(text[dartx.length]) - dart.no
tNull(maxLength) + 4); |
| 3781 let firstSpace = res[dartx.indexOf](' '); |
| 3782 if (dart.notNull(firstSpace) > 0) { |
| 3783 res = res[dartx.substring](firstSpace); |
| 3784 } |
| 3785 return `...${res}`; |
| 3786 } |
| 3787 }; |
| 3788 dart.setSignature(compact_vm_config.CompactVMConfiguration, { |
| 3789 methods: () => ({ |
| 3790 [_progressLine]: [dart.void, [core.String], [core.String]], |
| 3791 [_padTime]: [core.String, [core.int]], |
| 3792 [_timeString]: [core.String, [core.Duration]], |
| 3793 [_snippet]: [core.String, [core.String, core.int]] |
| 3794 }) |
| 3795 }); |
| 3796 compact_vm_config._print = function(value) { |
| 3797 if (value === void 0) value = ''; |
| 3798 return io.stdout.write(`${value}\n`); |
| 3799 }; |
| 3800 dart.fn(compact_vm_config._print, dart.dynamic, [], [dart.dynamic]); |
| 3801 compact_vm_config.useCompactVMConfiguration = function() { |
| 3802 if (io.Platform.environment[dartx.get]('LOGNAME') == 'chrome-bot') { |
| 3803 return; |
| 3804 } |
| 3805 unittest.unittestConfiguration = compact_vm_config._singleton; |
| 3806 }; |
| 3807 dart.fn(compact_vm_config.useCompactVMConfiguration, dart.void, []); |
| 3808 dart.defineLazy(compact_vm_config, { |
| 3809 get _singleton() { |
| 3810 return new compact_vm_config.CompactVMConfiguration(); |
| 3811 } |
| 3812 }); |
| 3813 html_config._showResultsInPage = function(passed, failed, errors, results, isL
ayoutTest, uncaughtError) { |
| 3814 if (dart.notNull(isLayoutTest) && passed == results[dartx.length] && uncaugh
tError == null) { |
| 3815 html.document[dartx.body][dartx.innerHtml] = "PASS"; |
| 3816 } else { |
| 3817 let newBody = new core.StringBuffer(); |
| 3818 newBody.write("<table class='unittest-table'><tbody>"); |
| 3819 newBody.write(passed == results[dartx.length] && uncaughtError == null ? "
<tr><td colspan='3' class='unittest-pass'>PASS</td></tr>" : "<tr><td colspan='3'
class='unittest-fail'>FAIL</td></tr>"); |
| 3820 for (let test_ of results) { |
| 3821 newBody.write(html_config._toHtml(test_)); |
| 3822 } |
| 3823 if (uncaughtError != null) { |
| 3824 newBody.write(`<tr>\n <td>--</td>\n <td class="unittes
t-error">ERROR</td>\n <td>Uncaught error: ${uncaughtError}</td>\n
</tr>`); |
| 3825 } |
| 3826 if (passed == results[dartx.length] && uncaughtError == null) { |
| 3827 newBody.write(` <tr><td colspan='3' class='unittest-pass'>\n
All ${passed} tests passed\n </td></tr>`); |
| 3828 } else { |
| 3829 newBody.write(` <tr><td colspan='3'>Total\n <span cl
ass='unittest-pass'>${passed} passed</span>,\n <span class='unittest-
fail'>${failed} failed</span>\n <span class='unittest-error'>\n
${dart.notNull(errors) + (uncaughtError == null ? 0 : 1)} errors</span>\n
</td></tr>`); |
| 3830 } |
| 3831 newBody.write("</tbody></table>"); |
| 3832 html.document[dartx.body][dartx.innerHtml] = newBody.toString(); |
| 3833 html.window[dartx.onHashChange].listen(dart.fn(_ => { |
| 3834 if (html.window[dartx.location][dartx.hash] != null && dart.notNull(html
.window[dartx.location][dartx.hash][dartx.contains]('testFilter'))) { |
| 3835 html.window[dartx.location][dartx.reload](); |
| 3836 } |
| 3837 }, dart.void, [html.Event])); |
| 3838 } |
| 3839 }; |
| 3840 dart.fn(html_config._showResultsInPage, dart.void, [core.int, core.int, core.i
nt, core.List$(src__test_case.TestCase), core.bool, core.String]); |
| 3841 html_config._toHtml = function(testCase) { |
| 3842 if (!dart.notNull(testCase.isComplete)) { |
| 3843 return ` <tr>\n <td>${testCase.id}</td>\n <td cla
ss="unittest-error">NO STATUS</td>\n <td>Test did not complete</td>\n
</tr>`; |
| 3844 } |
| 3845 let html = ` <tr>\n <td>${testCase.id}</td>\n <td class="
unittest-${testCase.result}">\n ${testCase.result[dartx.toUpperCase]()}
\n </td>\n <td>\n <p>Expectation: \n <a href="
#testFilter=${testCase.description}">\n ${testCase.description}\n
</a>.\n </p>\n <pre>${convert.HTML_ESCAPE.convert(te
stCase.message)}</pre>\n </td>\n </tr>`; |
| 3846 if (testCase.stackTrace != null) { |
| 3847 html = `${html}<tr><td></td><td colspan="2"><pre>` + dart.notNull(convert.
HTML_ESCAPE.convert(dart.toString(testCase.stackTrace))) + '</pre></td></tr>'; |
| 3848 } |
| 3849 return html; |
| 3850 }; |
| 3851 dart.fn(html_config._toHtml, core.String, [src__test_case.TestCase]); |
| 3852 html_config.useHtmlConfiguration = function(isLayoutTest) { |
185 if (isLayoutTest === void 0) isLayoutTest = false; | 3853 if (isLayoutTest === void 0) isLayoutTest = false; |
186 }; | 3854 unittest.unittestConfiguration = dart.notNull(isLayoutTest) ? html_config._s
ingletonLayout : html_config._singletonNotLayout; |
187 dart.fn(unittest.useHtmlConfiguration, dart.void, [], [core.bool]); | 3855 }; |
188 dart.export(unittest, src__numeric_matchers, 'isPositive'); | 3856 dart.fn(html_config.useHtmlConfiguration, dart.void, [], [core.bool]); |
189 dart.export(unittest, src__error_matchers, 'isRangeError'); | 3857 dart.defineLazy(html_config, { |
190 dart.export(unittest, src__error_matchers, 'isStateError'); | 3858 get _singletonLayout() { |
191 unittest.equals = src__core_matchers.equals; | 3859 return new html_config.HtmlConfiguration(true); |
192 unittest.CustomMatcher = src__core_matchers.CustomMatcher; | 3860 } |
193 unittest.inOpenClosedRange = src__numeric_matchers.inOpenClosedRange; | 3861 }); |
194 unittest.pairwiseCompare = src__iterable_matchers.pairwiseCompare; | 3862 dart.defineLazy(html_config, { |
195 unittest.equalsIgnoringCase = src__string_matchers.equalsIgnoringCase; | 3863 get _singletonNotLayout() { |
196 dart.export(unittest, src__error_matchers, 'isUnimplementedError'); | 3864 return new html_config.HtmlConfiguration(false); |
197 unittest.hasLength = src__core_matchers.hasLength; | 3865 } |
198 unittest.StringDescription = src__description.StringDescription; | 3866 }); |
199 unittest.allOf = src__operator_matchers.allOf; | |
200 dart.export(unittest, src__numeric_matchers, 'isNegative'); | |
201 unittest.isInstanceOf$ = src__core_matchers.isInstanceOf$; | |
202 unittest.isInstanceOf = src__core_matchers.isInstanceOf; | |
203 dart.export(unittest, src__core_matchers, 'isNaN'); | |
204 unittest.lessThan = src__numeric_matchers.lessThan; | |
205 dart.export(unittest, src__core_matchers, 'isNotEmpty'); | |
206 unittest.greaterThanOrEqualTo = src__numeric_matchers.greaterThanOrEqualTo; | |
207 unittest.endsWith = src__string_matchers.endsWith; | |
208 dart.export(unittest, src__error_matchers, 'isConcurrentModificationError'); | |
209 unittest.containsValue = src__map_matchers.containsValue; | |
210 dart.export(unittest, src__core_matchers, 'isFalse'); | |
211 dart.export(unittest, src__core_matchers, 'isTrue'); | |
212 unittest.Matcher = src__interfaces.Matcher; | |
213 unittest.lessThanOrEqualTo = src__numeric_matchers.lessThanOrEqualTo; | |
214 unittest.matches = src__string_matchers.matches; | |
215 dart.export(unittest, src__core_matchers, 'returnsNormally'); | |
216 unittest.TypeMatcher = src__core_matchers.TypeMatcher; | |
217 unittest.inExclusiveRange = src__numeric_matchers.inExclusiveRange; | |
218 unittest.equalsIgnoringWhitespace = src__string_matchers.equalsIgnoringWhitesp
ace; | |
219 unittest.isIn = src__core_matchers.isIn; | |
220 dart.export(unittest, src__core_matchers, 'isNotNaN'); | |
221 dart.export(unittest, src__numeric_matchers, 'isNonZero'); | |
222 unittest.startsWith = src__string_matchers.startsWith; | |
223 dart.export(unittest, src__error_matchers, 'isNullThrownError'); | |
224 dart.export(unittest, src__core_matchers, 'isEmpty'); | |
225 unittest.anyOf = src__operator_matchers.anyOf; | |
226 unittest.unorderedMatches = src__iterable_matchers.unorderedMatches; | |
227 dart.export(unittest, src__numeric_matchers, 'isZero'); | |
228 dart.export(unittest, src__core_matchers, 'isList'); | |
229 unittest.escape = src__util.escape; | |
230 dart.export(unittest, src__error_matchers, 'isCyclicInitializationError'); | |
231 unittest.anyElement = src__iterable_matchers.anyElement; | |
232 dart.export(unittest, src__core_matchers, 'anything'); | |
233 unittest.contains = src__core_matchers.contains; | |
234 dart.export(unittest, src__error_matchers, 'isUnsupportedError'); | |
235 dart.export(unittest, src__numeric_matchers, 'isNonPositive'); | |
236 unittest.isNot = src__operator_matchers.isNot; | |
237 unittest.same = src__core_matchers.same; | |
238 unittest.inClosedOpenRange = src__numeric_matchers.inClosedOpenRange; | |
239 unittest.predicate = src__core_matchers.predicate; | |
240 dart.export(unittest, src__core_matchers, 'isNotNull'); | |
241 unittest.wrapMatcher = src__util.wrapMatcher; | |
242 dart.export(unittest, src__error_matchers, 'isNoSuchMethodError'); | |
243 unittest.unorderedEquals = src__iterable_matchers.unorderedEquals; | |
244 unittest.everyElement = src__iterable_matchers.everyElement; | |
245 unittest.addStateInfo = src__util.addStateInfo; | |
246 dart.export(unittest, src__error_matchers, 'isArgumentError'); | |
247 dart.export(unittest, src__error_matchers, 'isException'); | |
248 unittest.inInclusiveRange = src__numeric_matchers.inInclusiveRange; | |
249 unittest.containsPair = src__map_matchers.containsPair; | |
250 dart.export(unittest, src__error_matchers, 'isFormatException'); | |
251 unittest.orderedEquals = src__iterable_matchers.orderedEquals; | |
252 unittest.collapseWhitespace = src__string_matchers.collapseWhitespace; | |
253 unittest.greaterThan = src__numeric_matchers.greaterThan; | |
254 dart.export(unittest, src__numeric_matchers, 'isNonNegative'); | |
255 dart.export(unittest, src__core_matchers, 'isNull'); | |
256 dart.export(unittest, src__core_matchers, 'isMap'); | |
257 unittest.stringContainsInOrder = src__string_matchers.stringContainsInOrder; | |
258 unittest.closeTo = src__numeric_matchers.closeTo; | |
259 unittest.Description = src__interfaces.Description; | |
260 // Exports: | 3867 // Exports: |
261 exports.unittest = unittest; | 3868 exports.unittest = unittest; |
| 3869 exports.vm_config = vm_config; |
| 3870 exports.html_enhanced_config = html_enhanced_config; |
| 3871 exports.html_individual_config = html_individual_config; |
| 3872 exports.src__simple_configuration = src__simple_configuration; |
| 3873 exports.src__group_context = src__group_context; |
| 3874 exports.src__utils = src__utils; |
| 3875 exports.src__test_case = src__test_case; |
| 3876 exports.src__configuration = src__configuration; |
| 3877 exports.src__matcher = src__matcher; |
| 3878 exports.src__test_environment = src__test_environment; |
| 3879 exports.src__matcher__core_matchers = src__matcher__core_matchers; |
| 3880 exports.src__matcher__future_matchers = src__matcher__future_matchers; |
| 3881 exports.src__matcher__throws_matchers = src__matcher__throws_matchers; |
| 3882 exports.src__matcher__string_matchers = src__matcher__string_matchers; |
| 3883 exports.src__matcher__util = src__matcher__util; |
| 3884 exports.src__matcher__interfaces = src__matcher__interfaces; |
| 3885 exports.src__matcher__throws_matcher = src__matcher__throws_matcher; |
| 3886 exports.src__matcher__pretty_print = src__matcher__pretty_print; |
| 3887 exports.src__matcher__numeric_matchers = src__matcher__numeric_matchers; |
| 3888 exports.src__matcher__description = src__matcher__description; |
| 3889 exports.src__matcher__error_matchers = src__matcher__error_matchers; |
| 3890 exports.src__matcher__operator_matchers = src__matcher__operator_matchers; |
| 3891 exports.src__matcher__expect = src__matcher__expect; |
| 3892 exports.src__matcher__map_matchers = src__matcher__map_matchers; |
| 3893 exports.src__matcher__prints_matcher = src__matcher__prints_matcher; |
| 3894 exports.src__matcher__iterable_matchers = src__matcher__iterable_matchers; |
| 3895 exports.src__internal_test_case = src__internal_test_case; |
| 3896 exports.src__expected_function = src__expected_function; |
| 3897 exports.compact_vm_config = compact_vm_config; |
| 3898 exports.html_config = html_config; |
262 }); | 3899 }); |
OLD | NEW |