| OLD | NEW |
| 1 define(['dart_sdk'], function(dart_sdk) { | 1 define(['dart_sdk'], function(dart_sdk) { |
| 2 'use strict'; | 2 'use strict'; |
| 3 const core = dart_sdk.core; | 3 const core = dart_sdk.core; |
| 4 const dart = dart_sdk.dart; | 4 const dart = dart_sdk.dart; |
| 5 const dartx = dart_sdk.dartx; | 5 const dartx = dart_sdk.dartx; |
| 6 const expect = Object.create(null); | 6 const expect = Object.create(null); |
| 7 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.functionType(dart.void,
[])))(); | 7 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.functionType(dart.void,
[])))(); |
| 8 let dynamicAnddynamicTobool = () => (dynamicAnddynamicTobool = dart.constFn(da
rt.definiteFunctionType(core.bool, [dart.dynamic, dart.dynamic])))(); | 8 let dynamicAnddynamicTobool = () => (dynamicAnddynamicTobool = dart.constFn(da
rt.definiteFunctionType(core.bool, [dart.dynamic, dart.dynamic])))(); |
| 9 expect.Expect = class Expect extends core.Object { | 9 expect.Expect = class Expect extends core.Object { |
| 10 static _truncateString(string, start, end, length) { | 10 static _truncateString(string, start, end, length) { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 sb.write(dart.str`${val} `); | 201 sb.write(dart.str`${val} `); |
| 202 } | 202 } |
| 203 if (!dart.test(extraSet.isEmpty)) { | 203 if (!dart.test(extraSet.isEmpty)) { |
| 204 sb.write('\nExpected collection should not contain: '); | 204 sb.write('\nExpected collection should not contain: '); |
| 205 } | 205 } |
| 206 for (let val of extraSet) { | 206 for (let val of extraSet) { |
| 207 sb.write(dart.str`${val} `); | 207 sb.write(dart.str`${val} `); |
| 208 } | 208 } |
| 209 expect.Expect._fail(sb.toString()); | 209 expect.Expect._fail(sb.toString()); |
| 210 } | 210 } |
| 211 static deepEquals(expected, actual) { |
| 212 if (dart.equals(expected, actual)) return; |
| 213 if (core.List.is(expected) && core.List.is(actual)) { |
| 214 let n = dart.notNull(expected[dartx.length]) < dart.notNull(actual[dartx
.length]) ? expected[dartx.length] : actual[dartx.length]; |
| 215 for (let i = 0; i < dart.notNull(n); i++) { |
| 216 expect.Expect.deepEquals(expected[dartx.get](i), actual[dartx.get](i))
; |
| 217 } |
| 218 if (expected[dartx.length] != actual[dartx.length]) { |
| 219 expect.Expect._fail('Expect.deepEquals(list length, ' + dart.str`expec
ted: <${expected[dartx.length]}>, actual: <${actual[dartx.length]}>) ` + 'fails:
Next element <' + dart.str`${dart.notNull(expected[dartx.length]) > dart.notNul
l(n) ? expected[dartx.get](n) : actual[dartx.get](n)}>`); |
| 220 } |
| 221 } else if (core.Map.is(expected) && core.Map.is(actual)) { |
| 222 for (let key of expected[dartx.keys]) { |
| 223 if (!dart.test(actual[dartx.containsKey](key))) { |
| 224 expect.Expect._fail(dart.str`Expect.deepEquals(missing expected key:
<${key}>) fails`); |
| 225 } |
| 226 expect.Expect.deepEquals(expected[dartx.get](key), actual[dartx.get](k
ey)); |
| 227 } |
| 228 for (let key of actual[dartx.keys]) { |
| 229 if (!dart.test(expected[dartx.containsKey](key))) { |
| 230 expect.Expect._fail(dart.str`Expect.deepEquals(unexpected key: <${ke
y}>) fails`); |
| 231 } |
| 232 } |
| 233 } else if (typeof expected == 'string' && typeof actual == 'string') { |
| 234 let stringDifference = expect.Expect._stringDifference(expected, actual)
; |
| 235 dart.assert(stringDifference != null); |
| 236 expect.Expect._fail(dart.str`Expect.deepEquals(${stringDifference}) fail
s.`); |
| 237 } else { |
| 238 expect.Expect._fail(dart.str`Expect.deepEquals(expected: <${expected}>,
actual: <${actual}>) ` + "fails."); |
| 239 } |
| 240 } |
| 211 static throws(f, check, reason) { | 241 static throws(f, check, reason) { |
| 212 if (check === void 0) check = null; | 242 if (check === void 0) check = null; |
| 213 if (reason === void 0) reason = null; | 243 if (reason === void 0) reason = null; |
| 214 let msg = reason == null ? "" : dart.str`(${reason})`; | 244 let msg = reason == null ? "" : dart.str`(${reason})`; |
| 215 if (!expect._Nullary.is(f)) { | 245 if (!expect._Nullary.is(f)) { |
| 216 expect.Expect._fail(dart.str`Expect.throws${msg}: Function f not callabl
e with zero arguments`); | 246 expect.Expect._fail(dart.str`Expect.throws${msg}: Function f not callabl
e with zero arguments`); |
| 217 } | 247 } |
| 218 try { | 248 try { |
| 219 f(); | 249 f(); |
| 220 } catch (e) { | 250 } catch (e) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 246 isNull: dart.definiteFunctionType(dart.void, [dart.dynamic], [core.String]
), | 276 isNull: dart.definiteFunctionType(dart.void, [dart.dynamic], [core.String]
), |
| 247 isNotNull: dart.definiteFunctionType(dart.void, [dart.dynamic], [core.Stri
ng]), | 277 isNotNull: dart.definiteFunctionType(dart.void, [dart.dynamic], [core.Stri
ng]), |
| 248 identical: dart.definiteFunctionType(dart.void, [dart.dynamic, dart.dynami
c], [core.String]), | 278 identical: dart.definiteFunctionType(dart.void, [dart.dynamic, dart.dynami
c], [core.String]), |
| 249 fail: dart.definiteFunctionType(dart.void, [core.String]), | 279 fail: dart.definiteFunctionType(dart.void, [core.String]), |
| 250 approxEquals: dart.definiteFunctionType(dart.void, [core.num, core.num], [
core.num, core.String]), | 280 approxEquals: dart.definiteFunctionType(dart.void, [core.num, core.num], [
core.num, core.String]), |
| 251 notEquals: dart.definiteFunctionType(dart.void, [dart.dynamic, dart.dynami
c], [core.String]), | 281 notEquals: dart.definiteFunctionType(dart.void, [dart.dynamic, dart.dynami
c], [core.String]), |
| 252 listEquals: dart.definiteFunctionType(dart.void, [core.List, core.List], [
core.String]), | 282 listEquals: dart.definiteFunctionType(dart.void, [core.List, core.List], [
core.String]), |
| 253 mapEquals: dart.definiteFunctionType(dart.void, [core.Map, core.Map], [cor
e.String]), | 283 mapEquals: dart.definiteFunctionType(dart.void, [core.Map, core.Map], [cor
e.String]), |
| 254 stringEquals: dart.definiteFunctionType(dart.void, [core.String, core.Stri
ng], [core.String]), | 284 stringEquals: dart.definiteFunctionType(dart.void, [core.String, core.Stri
ng], [core.String]), |
| 255 setEquals: dart.definiteFunctionType(dart.void, [core.Iterable, core.Itera
ble], [core.String]), | 285 setEquals: dart.definiteFunctionType(dart.void, [core.Iterable, core.Itera
ble], [core.String]), |
| 286 deepEquals: dart.definiteFunctionType(dart.void, [core.Object, core.Object
]), |
| 256 throws: dart.definiteFunctionType(dart.void, [VoidTovoid()], [expect._Chec
kExceptionFn, core.String]), | 287 throws: dart.definiteFunctionType(dart.void, [VoidTovoid()], [expect._Chec
kExceptionFn, core.String]), |
| 257 _getMessage: dart.definiteFunctionType(core.String, [core.String]), | 288 _getMessage: dart.definiteFunctionType(core.String, [core.String]), |
| 258 _fail: dart.definiteFunctionType(dart.void, [core.String]) | 289 _fail: dart.definiteFunctionType(dart.void, [core.String]) |
| 259 }), | 290 }), |
| 260 names: ['_truncateString', '_stringDifference', 'equals', 'isTrue', 'isFalse
', 'isNull', 'isNotNull', 'identical', 'fail', 'approxEquals', 'notEquals', 'lis
tEquals', 'mapEquals', 'stringEquals', 'setEquals', 'throws', '_getMessage', '_f
ail'] | 291 names: ['_truncateString', '_stringDifference', 'equals', 'isTrue', 'isFalse
', 'isNull', 'isNotNull', 'identical', 'fail', 'approxEquals', 'notEquals', 'lis
tEquals', 'mapEquals', 'stringEquals', 'setEquals', 'deepEquals', 'throws', '_ge
tMessage', '_fail'] |
| 261 }); | 292 }); |
| 262 expect._identical = function(a, b) { | 293 expect._identical = function(a, b) { |
| 263 return core.identical(a, b); | 294 return core.identical(a, b); |
| 264 }; | 295 }; |
| 265 dart.fn(expect._identical, dynamicAnddynamicTobool()); | 296 dart.fn(expect._identical, dynamicAnddynamicTobool()); |
| 266 expect._CheckExceptionFn = dart.typedef('_CheckExceptionFn', () => dart.functi
onType(core.bool, [dart.dynamic])); | 297 expect._CheckExceptionFn = dart.typedef('_CheckExceptionFn', () => dart.functi
onType(core.bool, [dart.dynamic])); |
| 267 expect._Nullary = dart.typedef('_Nullary', () => dart.functionType(dart.dynami
c, [])); | 298 expect._Nullary = dart.typedef('_Nullary', () => dart.functionType(dart.dynami
c, [])); |
| 268 expect.ExpectException = class ExpectException extends core.Object { | 299 expect.ExpectException = class ExpectException extends core.Object { |
| 269 new(message) { | 300 new(message) { |
| 270 this.message = message; | 301 this.message = message; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 297 } | 328 } |
| 298 }; | 329 }; |
| 299 dart.setSignature(expect.AssumeDynamic, { | 330 dart.setSignature(expect.AssumeDynamic, { |
| 300 constructors: () => ({new: dart.definiteFunctionType(expect.AssumeDynamic, [
])}) | 331 constructors: () => ({new: dart.definiteFunctionType(expect.AssumeDynamic, [
])}) |
| 301 }); | 332 }); |
| 302 // Exports: | 333 // Exports: |
| 303 return { | 334 return { |
| 304 expect: expect | 335 expect: expect |
| 305 }; | 336 }; |
| 306 }); | 337 }); |
| OLD | NEW |