unexpected
Advanced tools
Comparing version 5.0.0-beta31 to 5.0.0-beta32
@@ -18,3 +18,3 @@ var utils = require('./utils'); | ||
output.append(inspect(this.unwrap(value))); | ||
return output.append(this.suffix(output.clone())); | ||
output.append(this.suffix(output.clone())); | ||
}, | ||
@@ -169,3 +169,2 @@ diff: function (actual, expected, output, diff, inspect) { | ||
} | ||
return output; | ||
}, | ||
@@ -361,3 +360,2 @@ diff: function (actual, expected, output, diff, inspect, equal) { | ||
} | ||
return output; | ||
}, | ||
@@ -371,3 +369,3 @@ diff: function (actual, expected, output, diff, inspect, equal) { | ||
if (actual.constructor !== expected.constructor) { | ||
return this.baseType.diff(actual, expected, output, diff, inspect, equal); | ||
return this.baseType.diff(actual, expected); | ||
} | ||
@@ -539,3 +537,3 @@ | ||
return a === b || | ||
(equal(a.message, b.message) && this.baseType.equal(a, b, equal)); | ||
(equal(a.message, b.message) && this.baseType.equal(a, b)); | ||
}, | ||
@@ -546,3 +544,3 @@ inspect: function (value, depth, output, inspect) { | ||
}, value); | ||
return output.text('[Error: ').append(inspect(errorObject, depth)).text(']'); | ||
output.text('[Error: ').append(inspect(errorObject, depth)).text(']'); | ||
}, | ||
@@ -567,3 +565,3 @@ diff: function (actual, expected, output, diff) { | ||
inspect: function (date, depth, output) { | ||
return output.text('[Date ').text(date.toUTCString()).text(']'); | ||
output.text('[Date ').text(date.toUTCString()).text(']'); | ||
} | ||
@@ -609,3 +607,2 @@ }); | ||
output.code('function ' + name + '(' + args + ') {' + body + '}', 'javascript'); | ||
return output; | ||
} | ||
@@ -646,3 +643,2 @@ }); | ||
output.text(')'); | ||
return output; | ||
} | ||
@@ -663,3 +659,3 @@ }); | ||
inspect: function (regExp, depth, output) { | ||
return output.regexp(regExp); | ||
output.regexp(regExp); | ||
} | ||
@@ -674,3 +670,3 @@ }); | ||
inspect: function (value, depth, output) { | ||
return output.code(utils.getOuterHTML(value), 'html'); | ||
output.code(utils.getOuterHTML(value), 'html'); | ||
} | ||
@@ -741,3 +737,3 @@ }); | ||
codeStr += '])'; | ||
return output.code(codeStr, 'javascript'); | ||
output.code(codeStr, 'javascript'); | ||
}, | ||
@@ -791,6 +787,6 @@ diffLimit: 512, | ||
inspect: function (value, depth, output) { | ||
return output.strings('\'') | ||
output.strings('\'') | ||
.strings(JSON.stringify(value).replace(/^"|"$/g, '') | ||
.replace(/'/g, "\\'") | ||
.replace(/\\"/g, '"')) | ||
.replace(/'/g, "\\'") | ||
.replace(/\\"/g, '"')) | ||
.strings('\''); | ||
@@ -814,3 +810,3 @@ }, | ||
inspect: function (value, depth, output) { | ||
return output.number(value); | ||
output.number(value); | ||
} | ||
@@ -817,0 +813,0 @@ }); |
@@ -220,2 +220,3 @@ /*global setTimeout*/ | ||
return that.findTypeOf(obj).inspect(obj, currentDepth, output, function (v, childDepth) { | ||
output = output.clone(); | ||
seen.push(obj); | ||
@@ -225,7 +226,8 @@ if (typeof childDepth === 'undefined') { | ||
} | ||
return printOutput(v, childDepth, output.clone()); | ||
return printOutput(v, childDepth, output) || output; | ||
}); | ||
}; | ||
return printOutput(obj, depth || 3, this.output.clone()); | ||
var output = this.output.clone(); | ||
return printOutput(obj, depth || 3, output) || output; | ||
}; | ||
@@ -337,2 +339,3 @@ | ||
Unexpected.prototype.addType = function (type) { | ||
var that = this; | ||
var baseType; | ||
@@ -358,4 +361,21 @@ if (typeof type.name !== 'string' || type.name.trim() === '') { | ||
var output = this.expect.output; | ||
var extendedBaseType = Object.create(baseType); | ||
extendedBaseType.inspect = function (value, depth) { | ||
return baseType.inspect(value, depth, output.clone(), extendedBaseType.inspect.bind(extendedBaseType)); | ||
}; | ||
var extendedType = extend({}, baseType, type, { baseType: baseType }); | ||
extendedBaseType.diff = function (actual, expected) { | ||
return baseType.diff(actual, expected, | ||
output.clone(), | ||
extendedBaseType.diff.bind(extendedBaseType), | ||
extendedBaseType.inspect.bind(extendedBaseType), | ||
extendedBaseType.equal.bind(extendedBaseType)); | ||
}; | ||
extendedBaseType.equal = function (actual, expected) { | ||
return baseType.equal(actual, expected, that.equal.bind(that)); | ||
}; | ||
var extendedType = extend({}, baseType, type, { baseType: extendedBaseType }); | ||
var inspect = extendedType.inspect; | ||
@@ -502,3 +522,3 @@ | ||
var assertionRule = this.assertions[typeWithAssertion.name][testDescriptionString]; | ||
while (!assertionRule && typeWithAssertion !== anyType) { | ||
while (!assertionRule && typeWithAssertion.name !== anyType.name) { | ||
// FIXME: Detect cycles? | ||
@@ -505,0 +525,0 @@ typeWithAssertion = typeWithAssertion.baseType; |
{ | ||
"name": "unexpected", | ||
"version": "5.0.0-beta31", | ||
"version": "5.0.0-beta32", | ||
"author": "Sune Sloth Simonsen <sune@we-knowhow.dk>", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
497472
19
11160