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