| OLD | NEW |
| 1 dart_library.library('unittest', null, /* Imports */[ | 1 dart_library.library('unittest', null, /* Imports */[ |
| 2 'dart_sdk', | 2 'dart_sdk', |
| 3 'matcher' | 3 'matcher' |
| 4 ], function(exports, dart_sdk, matcher) { | 4 ], function(exports, dart_sdk, matcher) { |
| 5 'use strict'; | 5 'use strict'; |
| 6 const core = dart_sdk.core; | 6 const core = dart_sdk.core; |
| 7 const js = dart_sdk.js; | 7 const js = dart_sdk.js; |
| 8 const async = dart_sdk.async; | 8 const async = dart_sdk.async; |
| 9 const dart = dart_sdk.dart; | 9 const dart = dart_sdk.dart; |
| 10 const dartx = dart_sdk.dartx; | 10 const dartx = dart_sdk.dartx; |
| 11 const interfaces = matcher.interfaces; | 11 const src__interfaces = matcher.src__interfaces; |
| 12 const util = matcher.util; | 12 const src__util = matcher.src__util; |
| 13 const description$ = matcher.description; | 13 const src__description = matcher.src__description; |
| 14 const numeric_matchers = matcher.numeric_matchers; | 14 const src__numeric_matchers = matcher.src__numeric_matchers; |
| 15 const error_matchers = matcher.error_matchers; | 15 const src__error_matchers = matcher.src__error_matchers; |
| 16 const core_matchers = matcher.core_matchers; | 16 const src__core_matchers = matcher.src__core_matchers; |
| 17 const iterable_matchers = matcher.iterable_matchers; | 17 const src__iterable_matchers = matcher.src__iterable_matchers; |
| 18 const string_matchers = matcher.string_matchers; | 18 const src__string_matchers = matcher.src__string_matchers; |
| 19 const operator_matchers = matcher.operator_matchers; | 19 const src__operator_matchers = matcher.src__operator_matchers; |
| 20 const map_matchers = matcher.map_matchers; | 20 const src__map_matchers = matcher.src__map_matchers; |
| 21 const unittest = Object.create(null); | 21 const unittest = Object.create(null); |
| 22 unittest.group = function(name, body) { | 22 unittest.group = function(name, body) { |
| 23 return js.context.callMethod('suite', dart.list([name, body], core.Object)); | 23 return js.context.callMethod('suite', dart.list([name, body], core.Object)); |
| 24 }; | 24 }; |
| 25 dart.fn(unittest.group, dart.void, [core.String, dart.functionType(dart.void,
[])]); | 25 dart.fn(unittest.group, dart.void, [core.String, dart.functionType(dart.void,
[])]); |
| 26 unittest.test = function(name, body, opts) { | 26 unittest.test = function(name, body, opts) { |
| 27 let skip = opts && 'skip' in opts ? opts.skip : null; | 27 let skip = opts && 'skip' in opts ? opts.skip : null; |
| 28 if (skip != null) { | 28 if (skip != null) { |
| 29 core.print(`SKIP ${name}: ${skip}`); | 29 core.print(`SKIP ${name}: ${skip}`); |
| 30 return; | 30 return; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 47 TestFailure(message) { | 47 TestFailure(message) { |
| 48 this.message = message; | 48 this.message = message; |
| 49 } | 49 } |
| 50 toString() { | 50 toString() { |
| 51 return this.message; | 51 return this.message; |
| 52 } | 52 } |
| 53 }; | 53 }; |
| 54 dart.setSignature(unittest.TestFailure, { | 54 dart.setSignature(unittest.TestFailure, { |
| 55 constructors: () => ({TestFailure: [unittest.TestFailure, [core.String]]}) | 55 constructors: () => ({TestFailure: [unittest.TestFailure, [core.String]]}) |
| 56 }); | 56 }); |
| 57 unittest.ErrorFormatter = dart.typedef('ErrorFormatter', () => dart.functionTy
pe(core.String, [dart.dynamic, interfaces.Matcher, core.String, core.Map, core.b
ool])); | 57 unittest.ErrorFormatter = dart.typedef('ErrorFormatter', () => dart.functionTy
pe(core.String, [dart.dynamic, src__interfaces.Matcher, core.String, core.Map, c
ore.bool])); |
| 58 unittest.expect = function(actual, matcher, opts) { | 58 unittest.expect = function(actual, matcher, opts) { |
| 59 let reason = opts && 'reason' in opts ? opts.reason : null; | 59 let reason = opts && 'reason' in opts ? opts.reason : null; |
| 60 let verbose = opts && 'verbose' in opts ? opts.verbose : false; | 60 let verbose = opts && 'verbose' in opts ? opts.verbose : false; |
| 61 let formatter = opts && 'formatter' in opts ? opts.formatter : null; | 61 let formatter = opts && 'formatter' in opts ? opts.formatter : null; |
| 62 matcher = util.wrapMatcher(matcher); | 62 matcher = src__util.wrapMatcher(matcher); |
| 63 let matchState = dart.map(); | 63 let matchState = dart.map(); |
| 64 try { | 64 try { |
| 65 if (dart.notNull(dart.as(dart.dsend(matcher, 'matches', actual, matchState
), core.bool))) return; | 65 if (dart.notNull(dart.as(dart.dsend(matcher, 'matches', actual, matchState
), core.bool))) return; |
| 66 } catch (e) { | 66 } catch (e) { |
| 67 let trace = dart.stackTrace(e); | 67 let trace = dart.stackTrace(e); |
| 68 if (reason == null) { | 68 if (reason == null) { |
| 69 reason = `${typeof e == 'string' ? e : dart.toString(e)} at ${trace}`; | 69 reason = `${typeof e == 'string' ? e : dart.toString(e)} at ${trace}`; |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 if (formatter == null) formatter = unittest._defaultFailFormatter; | 73 if (formatter == null) formatter = unittest._defaultFailFormatter; |
| 74 unittest.fail(dart.dcall(formatter, actual, matcher, reason, matchState, ver
bose)); | 74 unittest.fail(dart.dcall(formatter, actual, matcher, reason, matchState, ver
bose)); |
| 75 }; | 75 }; |
| 76 dart.fn(unittest.expect, dart.void, [dart.dynamic, dart.dynamic], {reason: cor
e.String, verbose: core.bool, formatter: unittest.ErrorFormatter}); | 76 dart.fn(unittest.expect, dart.void, [dart.dynamic, dart.dynamic], {reason: cor
e.String, verbose: core.bool, formatter: unittest.ErrorFormatter}); |
| 77 unittest.fail = function(message) { | 77 unittest.fail = function(message) { |
| 78 return dart.throw(new unittest.TestFailure(message)); | 78 return dart.throw(new unittest.TestFailure(message)); |
| 79 }; | 79 }; |
| 80 dart.fn(unittest.fail, dart.void, [core.String]); | 80 dart.fn(unittest.fail, dart.void, [core.String]); |
| 81 unittest._defaultFailFormatter = function(actual, matcher, reason, matchState,
verbose) { | 81 unittest._defaultFailFormatter = function(actual, matcher, reason, matchState,
verbose) { |
| 82 let description = new description$.StringDescription(); | 82 let description = new src__description.StringDescription(); |
| 83 description.add('Expected: ').addDescriptionOf(matcher).add('\n'); | 83 description.add('Expected: ').addDescriptionOf(matcher).add('\n'); |
| 84 description.add(' Actual: ').addDescriptionOf(actual).add('\n'); | 84 description.add(' Actual: ').addDescriptionOf(actual).add('\n'); |
| 85 let mismatchDescription = new description$.StringDescription(); | 85 let mismatchDescription = new src__description.StringDescription(); |
| 86 matcher.describeMismatch(actual, mismatchDescription, matchState, verbose); | 86 matcher.describeMismatch(actual, mismatchDescription, matchState, verbose); |
| 87 if (dart.notNull(mismatchDescription.length) > 0) { | 87 if (dart.notNull(mismatchDescription.length) > 0) { |
| 88 description.add(` Which: ${mismatchDescription}\n`); | 88 description.add(` Which: ${mismatchDescription}\n`); |
| 89 } | 89 } |
| 90 if (reason != null) description.add(reason).add('\n'); | 90 if (reason != null) description.add(reason).add('\n'); |
| 91 return description.toString(); | 91 return description.toString(); |
| 92 }; | 92 }; |
| 93 dart.fn(unittest._defaultFailFormatter, core.String, [dart.dynamic, interfaces
.Matcher, core.String, core.Map, core.bool]); | 93 dart.fn(unittest._defaultFailFormatter, core.String, [dart.dynamic, src__inter
faces.Matcher, core.String, core.Map, core.bool]); |
| 94 unittest.isPositive = numeric_matchers.isPositive; | 94 unittest.isPositive = src__numeric_matchers.isPositive; |
| 95 unittest.isRangeError = error_matchers.isRangeError; | 95 unittest.isRangeError = src__error_matchers.isRangeError; |
| 96 unittest.isStateError = error_matchers.isStateError; | 96 unittest.isStateError = src__error_matchers.isStateError; |
| 97 unittest.equals = core_matchers.equals; | 97 unittest.equals = src__core_matchers.equals; |
| 98 unittest.CustomMatcher = core_matchers.CustomMatcher; | 98 unittest.CustomMatcher = src__core_matchers.CustomMatcher; |
| 99 unittest.inOpenClosedRange = numeric_matchers.inOpenClosedRange; | 99 unittest.inOpenClosedRange = src__numeric_matchers.inOpenClosedRange; |
| 100 unittest.pairwiseCompare = iterable_matchers.pairwiseCompare; | 100 unittest.pairwiseCompare = src__iterable_matchers.pairwiseCompare; |
| 101 unittest.equalsIgnoringCase = string_matchers.equalsIgnoringCase; | 101 unittest.equalsIgnoringCase = src__string_matchers.equalsIgnoringCase; |
| 102 unittest.isUnimplementedError = error_matchers.isUnimplementedError; | 102 unittest.isUnimplementedError = src__error_matchers.isUnimplementedError; |
| 103 unittest.hasLength = core_matchers.hasLength; | 103 unittest.hasLength = src__core_matchers.hasLength; |
| 104 unittest.StringDescription = description$.StringDescription; | 104 unittest.StringDescription = src__description.StringDescription; |
| 105 unittest.allOf = operator_matchers.allOf; | 105 unittest.allOf = src__operator_matchers.allOf; |
| 106 unittest.isNegative = numeric_matchers.isNegative; | 106 unittest.isNegative = src__numeric_matchers.isNegative; |
| 107 unittest.isInstanceOf$ = core_matchers.isInstanceOf$; | 107 unittest.isInstanceOf$ = src__core_matchers.isInstanceOf$; |
| 108 unittest.isInstanceOf = core_matchers.isInstanceOf; | 108 unittest.isInstanceOf = src__core_matchers.isInstanceOf; |
| 109 unittest.isNaN = core_matchers.isNaN; | 109 unittest.isNaN = src__core_matchers.isNaN; |
| 110 unittest.lessThan = numeric_matchers.lessThan; | 110 unittest.lessThan = src__numeric_matchers.lessThan; |
| 111 unittest.isNotEmpty = core_matchers.isNotEmpty; | 111 unittest.isNotEmpty = src__core_matchers.isNotEmpty; |
| 112 unittest.greaterThanOrEqualTo = numeric_matchers.greaterThanOrEqualTo; | 112 unittest.greaterThanOrEqualTo = src__numeric_matchers.greaterThanOrEqualTo; |
| 113 unittest.endsWith = string_matchers.endsWith; | 113 unittest.endsWith = src__string_matchers.endsWith; |
| 114 unittest.isConcurrentModificationError = error_matchers.isConcurrentModificati
onError; | 114 unittest.isConcurrentModificationError = src__error_matchers.isConcurrentModif
icationError; |
| 115 unittest.containsValue = map_matchers.containsValue; | 115 unittest.containsValue = src__map_matchers.containsValue; |
| 116 unittest.isFalse = core_matchers.isFalse; | 116 unittest.isFalse = src__core_matchers.isFalse; |
| 117 unittest.isTrue = core_matchers.isTrue; | 117 unittest.isTrue = src__core_matchers.isTrue; |
| 118 unittest.Matcher = interfaces.Matcher; | 118 unittest.Matcher = src__interfaces.Matcher; |
| 119 unittest.lessThanOrEqualTo = numeric_matchers.lessThanOrEqualTo; | 119 unittest.lessThanOrEqualTo = src__numeric_matchers.lessThanOrEqualTo; |
| 120 unittest.matches = string_matchers.matches; | 120 unittest.matches = src__string_matchers.matches; |
| 121 unittest.returnsNormally = core_matchers.returnsNormally; | 121 unittest.returnsNormally = src__core_matchers.returnsNormally; |
| 122 unittest.TypeMatcher = core_matchers.TypeMatcher; | 122 unittest.TypeMatcher = src__core_matchers.TypeMatcher; |
| 123 unittest.inExclusiveRange = numeric_matchers.inExclusiveRange; | 123 unittest.inExclusiveRange = src__numeric_matchers.inExclusiveRange; |
| 124 unittest.equalsIgnoringWhitespace = string_matchers.equalsIgnoringWhitespace; | 124 unittest.equalsIgnoringWhitespace = src__string_matchers.equalsIgnoringWhitesp
ace; |
| 125 unittest.isIn = core_matchers.isIn; | 125 unittest.isIn = src__core_matchers.isIn; |
| 126 unittest.isNotNaN = core_matchers.isNotNaN; | 126 unittest.isNotNaN = src__core_matchers.isNotNaN; |
| 127 unittest.isNonZero = numeric_matchers.isNonZero; | 127 unittest.isNonZero = src__numeric_matchers.isNonZero; |
| 128 unittest.startsWith = string_matchers.startsWith; | 128 unittest.startsWith = src__string_matchers.startsWith; |
| 129 unittest.isNullThrownError = error_matchers.isNullThrownError; | 129 unittest.isNullThrownError = src__error_matchers.isNullThrownError; |
| 130 unittest.isEmpty = core_matchers.isEmpty; | 130 unittest.isEmpty = src__core_matchers.isEmpty; |
| 131 unittest.anyOf = operator_matchers.anyOf; | 131 unittest.anyOf = src__operator_matchers.anyOf; |
| 132 unittest.unorderedMatches = iterable_matchers.unorderedMatches; | 132 unittest.unorderedMatches = src__iterable_matchers.unorderedMatches; |
| 133 unittest.isZero = numeric_matchers.isZero; | 133 unittest.isZero = src__numeric_matchers.isZero; |
| 134 unittest.isList = core_matchers.isList; | 134 unittest.isList = src__core_matchers.isList; |
| 135 unittest.escape = util.escape; | 135 unittest.escape = src__util.escape; |
| 136 unittest.isCyclicInitializationError = error_matchers.isCyclicInitializationEr
ror; | 136 unittest.isCyclicInitializationError = src__error_matchers.isCyclicInitializat
ionError; |
| 137 unittest.anyElement = iterable_matchers.anyElement; | 137 unittest.anyElement = src__iterable_matchers.anyElement; |
| 138 unittest.anything = core_matchers.anything; | 138 unittest.anything = src__core_matchers.anything; |
| 139 unittest.contains = core_matchers.contains; | 139 unittest.contains = src__core_matchers.contains; |
| 140 unittest.isUnsupportedError = error_matchers.isUnsupportedError; | 140 unittest.isUnsupportedError = src__error_matchers.isUnsupportedError; |
| 141 unittest.isNonPositive = numeric_matchers.isNonPositive; | 141 unittest.isNonPositive = src__numeric_matchers.isNonPositive; |
| 142 unittest.isNot = operator_matchers.isNot; | 142 unittest.isNot = src__operator_matchers.isNot; |
| 143 unittest.same = core_matchers.same; | 143 unittest.same = src__core_matchers.same; |
| 144 unittest.inClosedOpenRange = numeric_matchers.inClosedOpenRange; | 144 unittest.inClosedOpenRange = src__numeric_matchers.inClosedOpenRange; |
| 145 unittest.predicate = core_matchers.predicate; | 145 unittest.predicate = src__core_matchers.predicate; |
| 146 unittest.isNotNull = core_matchers.isNotNull; | 146 unittest.isNotNull = src__core_matchers.isNotNull; |
| 147 unittest.wrapMatcher = util.wrapMatcher; | 147 unittest.wrapMatcher = src__util.wrapMatcher; |
| 148 unittest.isNoSuchMethodError = error_matchers.isNoSuchMethodError; | 148 unittest.isNoSuchMethodError = src__error_matchers.isNoSuchMethodError; |
| 149 unittest.unorderedEquals = iterable_matchers.unorderedEquals; | 149 unittest.unorderedEquals = src__iterable_matchers.unorderedEquals; |
| 150 unittest.everyElement = iterable_matchers.everyElement; | 150 unittest.everyElement = src__iterable_matchers.everyElement; |
| 151 unittest.addStateInfo = util.addStateInfo; | 151 unittest.addStateInfo = src__util.addStateInfo; |
| 152 unittest.isArgumentError = error_matchers.isArgumentError; | 152 unittest.isArgumentError = src__error_matchers.isArgumentError; |
| 153 unittest.isException = error_matchers.isException; | 153 unittest.isException = src__error_matchers.isException; |
| 154 unittest.inInclusiveRange = numeric_matchers.inInclusiveRange; | 154 unittest.inInclusiveRange = src__numeric_matchers.inInclusiveRange; |
| 155 unittest.containsPair = map_matchers.containsPair; | 155 unittest.containsPair = src__map_matchers.containsPair; |
| 156 unittest.isFormatException = error_matchers.isFormatException; | 156 unittest.isFormatException = src__error_matchers.isFormatException; |
| 157 unittest.orderedEquals = iterable_matchers.orderedEquals; | 157 unittest.orderedEquals = src__iterable_matchers.orderedEquals; |
| 158 unittest.collapseWhitespace = string_matchers.collapseWhitespace; | 158 unittest.collapseWhitespace = src__string_matchers.collapseWhitespace; |
| 159 unittest.greaterThan = numeric_matchers.greaterThan; | 159 unittest.greaterThan = src__numeric_matchers.greaterThan; |
| 160 unittest.isNonNegative = numeric_matchers.isNonNegative; | 160 unittest.isNonNegative = src__numeric_matchers.isNonNegative; |
| 161 unittest.isNull = core_matchers.isNull; | 161 unittest.isNull = src__core_matchers.isNull; |
| 162 unittest.isMap = core_matchers.isMap; | 162 unittest.isMap = src__core_matchers.isMap; |
| 163 unittest.stringContainsInOrder = string_matchers.stringContainsInOrder; | 163 unittest.stringContainsInOrder = src__string_matchers.stringContainsInOrder; |
| 164 unittest.closeTo = numeric_matchers.closeTo; | 164 unittest.closeTo = src__numeric_matchers.closeTo; |
| 165 unittest.Description = interfaces.Description; | 165 unittest.Description = src__interfaces.Description; |
| 166 // Exports: | 166 // Exports: |
| 167 exports.unittest = unittest; | 167 exports.unittest = unittest; |
| 168 }); | 168 }); |
| OLD | NEW |