Comparing version 0.4.0 to 0.4.1
@@ -103,2 +103,3 @@ !function (name, definition) { | ||
, eql = require('./utils/eql') | ||
, toString = Object.prototype.toString | ||
, inspect = require('./utils/inspect'); | ||
@@ -129,2 +130,3 @@ | ||
* ## Assertion.includeStack | ||
* , toString = Object.prototype.toString | ||
* | ||
@@ -593,4 +595,6 @@ * User configurable property, influences whether stack trace | ||
Assertion.prototype.a = function (type) { | ||
var klass = type.charAt(0).toUpperCase() + type.slice(1); | ||
this.assert( | ||
type == typeof this.obj | ||
'[object ' + klass + ']' === toString.call(this.obj) | ||
, 'expected ' + this.inspect + ' to be a ' + type | ||
@@ -1012,3 +1016,3 @@ , 'expected ' + this.inspect + ' not to be a ' + type); | ||
exports.version = '0.4.0'; | ||
exports.version = '0.4.1'; | ||
@@ -1015,0 +1019,0 @@ exports.Assertion = require('./assertion'); |
0.4.1 / 2012-02-26 | ||
================== | ||
* Merge pull request #27 from logicalparadox/type-fix | ||
* Update the browser version. | ||
* Add should tests for type checks. | ||
* Add function type check test. | ||
* Add more type checks tests. | ||
* Add test for `new Number` type check. | ||
* Fix type of actual checks. | ||
0.4.0 / 2012-02-25 | ||
@@ -3,0 +14,0 @@ ================== |
@@ -6,337 +6,340 @@ /* automatically generated by JSCoverage - do not edit */ | ||
_$jscoverage['assertion.js'][48] = 0; | ||
_$jscoverage['assertion.js'][56] = 0; | ||
_$jscoverage['assertion.js'][67] = 0; | ||
_$jscoverage['assertion.js'][57] = 0; | ||
_$jscoverage['assertion.js'][68] = 0; | ||
_$jscoverage['assertion.js'][69] = 0; | ||
_$jscoverage['assertion.js'][70] = 0; | ||
_$jscoverage['assertion.js'][85] = 0; | ||
_$jscoverage['assertion.js'][99] = 0; | ||
_$jscoverage['assertion.js'][100] = 0; | ||
_$jscoverage['assertion.js'][103] = 0; | ||
_$jscoverage['assertion.js'][104] = 0; | ||
_$jscoverage['assertion.js'][121] = 0; | ||
_$jscoverage['assertion.js'][71] = 0; | ||
_$jscoverage['assertion.js'][87] = 0; | ||
_$jscoverage['assertion.js'][101] = 0; | ||
_$jscoverage['assertion.js'][102] = 0; | ||
_$jscoverage['assertion.js'][105] = 0; | ||
_$jscoverage['assertion.js'][106] = 0; | ||
_$jscoverage['assertion.js'][123] = 0; | ||
_$jscoverage['assertion.js'][137] = 0; | ||
_$jscoverage['assertion.js'][125] = 0; | ||
_$jscoverage['assertion.js'][139] = 0; | ||
_$jscoverage['assertion.js'][153] = 0; | ||
_$jscoverage['assertion.js'][141] = 0; | ||
_$jscoverage['assertion.js'][155] = 0; | ||
_$jscoverage['assertion.js'][170] = 0; | ||
_$jscoverage['assertion.js'][157] = 0; | ||
_$jscoverage['assertion.js'][172] = 0; | ||
_$jscoverage['assertion.js'][173] = 0; | ||
_$jscoverage['assertion.js'][187] = 0; | ||
_$jscoverage['assertion.js'][174] = 0; | ||
_$jscoverage['assertion.js'][175] = 0; | ||
_$jscoverage['assertion.js'][189] = 0; | ||
_$jscoverage['assertion.js'][202] = 0; | ||
_$jscoverage['assertion.js'][191] = 0; | ||
_$jscoverage['assertion.js'][204] = 0; | ||
_$jscoverage['assertion.js'][218] = 0; | ||
_$jscoverage['assertion.js'][206] = 0; | ||
_$jscoverage['assertion.js'][220] = 0; | ||
_$jscoverage['assertion.js'][234] = 0; | ||
_$jscoverage['assertion.js'][222] = 0; | ||
_$jscoverage['assertion.js'][236] = 0; | ||
_$jscoverage['assertion.js'][250] = 0; | ||
_$jscoverage['assertion.js'][238] = 0; | ||
_$jscoverage['assertion.js'][252] = 0; | ||
_$jscoverage['assertion.js'][266] = 0; | ||
_$jscoverage['assertion.js'][254] = 0; | ||
_$jscoverage['assertion.js'][268] = 0; | ||
_$jscoverage['assertion.js'][269] = 0; | ||
_$jscoverage['assertion.js'][288] = 0; | ||
_$jscoverage['assertion.js'][270] = 0; | ||
_$jscoverage['assertion.js'][271] = 0; | ||
_$jscoverage['assertion.js'][290] = 0; | ||
_$jscoverage['assertion.js'][295] = 0; | ||
_$jscoverage['assertion.js'][309] = 0; | ||
_$jscoverage['assertion.js'][292] = 0; | ||
_$jscoverage['assertion.js'][297] = 0; | ||
_$jscoverage['assertion.js'][311] = 0; | ||
_$jscoverage['assertion.js'][316] = 0; | ||
_$jscoverage['assertion.js'][330] = 0; | ||
_$jscoverage['assertion.js'][313] = 0; | ||
_$jscoverage['assertion.js'][318] = 0; | ||
_$jscoverage['assertion.js'][332] = 0; | ||
_$jscoverage['assertion.js'][337] = 0; | ||
_$jscoverage['assertion.js'][356] = 0; | ||
_$jscoverage['assertion.js'][334] = 0; | ||
_$jscoverage['assertion.js'][339] = 0; | ||
_$jscoverage['assertion.js'][358] = 0; | ||
_$jscoverage['assertion.js'][363] = 0; | ||
_$jscoverage['assertion.js'][379] = 0; | ||
_$jscoverage['assertion.js'][360] = 0; | ||
_$jscoverage['assertion.js'][365] = 0; | ||
_$jscoverage['assertion.js'][381] = 0; | ||
_$jscoverage['assertion.js'][383] = 0; | ||
_$jscoverage['assertion.js'][388] = 0; | ||
_$jscoverage['assertion.js'][406] = 0; | ||
_$jscoverage['assertion.js'][385] = 0; | ||
_$jscoverage['assertion.js'][390] = 0; | ||
_$jscoverage['assertion.js'][408] = 0; | ||
_$jscoverage['assertion.js'][413] = 0; | ||
_$jscoverage['assertion.js'][430] = 0; | ||
_$jscoverage['assertion.js'][431] = 0; | ||
_$jscoverage['assertion.js'][436] = 0; | ||
_$jscoverage['assertion.js'][451] = 0; | ||
_$jscoverage['assertion.js'][452] = 0; | ||
_$jscoverage['assertion.js'][456] = 0; | ||
_$jscoverage['assertion.js'][471] = 0; | ||
_$jscoverage['assertion.js'][472] = 0; | ||
_$jscoverage['assertion.js'][477] = 0; | ||
_$jscoverage['assertion.js'][492] = 0; | ||
_$jscoverage['assertion.js'][493] = 0; | ||
_$jscoverage['assertion.js'][498] = 0; | ||
_$jscoverage['assertion.js'][514] = 0; | ||
_$jscoverage['assertion.js'][515] = 0; | ||
_$jscoverage['assertion.js'][410] = 0; | ||
_$jscoverage['assertion.js'][415] = 0; | ||
_$jscoverage['assertion.js'][432] = 0; | ||
_$jscoverage['assertion.js'][433] = 0; | ||
_$jscoverage['assertion.js'][438] = 0; | ||
_$jscoverage['assertion.js'][453] = 0; | ||
_$jscoverage['assertion.js'][454] = 0; | ||
_$jscoverage['assertion.js'][458] = 0; | ||
_$jscoverage['assertion.js'][473] = 0; | ||
_$jscoverage['assertion.js'][474] = 0; | ||
_$jscoverage['assertion.js'][479] = 0; | ||
_$jscoverage['assertion.js'][494] = 0; | ||
_$jscoverage['assertion.js'][495] = 0; | ||
_$jscoverage['assertion.js'][500] = 0; | ||
_$jscoverage['assertion.js'][516] = 0; | ||
_$jscoverage['assertion.js'][517] = 0; | ||
_$jscoverage['assertion.js'][522] = 0; | ||
_$jscoverage['assertion.js'][537] = 0; | ||
_$jscoverage['assertion.js'][538] = 0; | ||
_$jscoverage['assertion.js'][543] = 0; | ||
_$jscoverage['assertion.js'][562] = 0; | ||
_$jscoverage['assertion.js'][563] = 0; | ||
_$jscoverage['assertion.js'][564] = 0; | ||
_$jscoverage['assertion.js'][569] = 0; | ||
_$jscoverage['assertion.js'][589] = 0; | ||
_$jscoverage['assertion.js'][590] = 0; | ||
_$jscoverage['assertion.js'][591] = 0; | ||
_$jscoverage['assertion.js'][592] = 0; | ||
_$jscoverage['assertion.js'][519] = 0; | ||
_$jscoverage['assertion.js'][524] = 0; | ||
_$jscoverage['assertion.js'][539] = 0; | ||
_$jscoverage['assertion.js'][540] = 0; | ||
_$jscoverage['assertion.js'][542] = 0; | ||
_$jscoverage['assertion.js'][547] = 0; | ||
_$jscoverage['assertion.js'][566] = 0; | ||
_$jscoverage['assertion.js'][567] = 0; | ||
_$jscoverage['assertion.js'][568] = 0; | ||
_$jscoverage['assertion.js'][573] = 0; | ||
_$jscoverage['assertion.js'][593] = 0; | ||
_$jscoverage['assertion.js'][594] = 0; | ||
_$jscoverage['assertion.js'][595] = 0; | ||
_$jscoverage['assertion.js'][601] = 0; | ||
_$jscoverage['assertion.js'][602] = 0; | ||
_$jscoverage['assertion.js'][609] = 0; | ||
_$jscoverage['assertion.js'][610] = 0; | ||
_$jscoverage['assertion.js'][626] = 0; | ||
_$jscoverage['assertion.js'][627] = 0; | ||
_$jscoverage['assertion.js'][596] = 0; | ||
_$jscoverage['assertion.js'][599] = 0; | ||
_$jscoverage['assertion.js'][605] = 0; | ||
_$jscoverage['assertion.js'][606] = 0; | ||
_$jscoverage['assertion.js'][613] = 0; | ||
_$jscoverage['assertion.js'][614] = 0; | ||
_$jscoverage['assertion.js'][630] = 0; | ||
_$jscoverage['assertion.js'][631] = 0; | ||
_$jscoverage['assertion.js'][648] = 0; | ||
_$jscoverage['assertion.js'][649] = 0; | ||
_$jscoverage['assertion.js'][650] = 0; | ||
_$jscoverage['assertion.js'][635] = 0; | ||
_$jscoverage['assertion.js'][652] = 0; | ||
_$jscoverage['assertion.js'][657] = 0; | ||
_$jscoverage['assertion.js'][672] = 0; | ||
_$jscoverage['assertion.js'][673] = 0; | ||
_$jscoverage['assertion.js'][678] = 0; | ||
_$jscoverage['assertion.js'][693] = 0; | ||
_$jscoverage['assertion.js'][694] = 0; | ||
_$jscoverage['assertion.js'][699] = 0; | ||
_$jscoverage['assertion.js'][714] = 0; | ||
_$jscoverage['assertion.js'][715] = 0; | ||
_$jscoverage['assertion.js'][717] = 0; | ||
_$jscoverage['assertion.js'][722] = 0; | ||
_$jscoverage['assertion.js'][736] = 0; | ||
_$jscoverage['assertion.js'][738] = 0; | ||
_$jscoverage['assertion.js'][739] = 0; | ||
_$jscoverage['assertion.js'][758] = 0; | ||
_$jscoverage['assertion.js'][759] = 0; | ||
_$jscoverage['assertion.js'][653] = 0; | ||
_$jscoverage['assertion.js'][654] = 0; | ||
_$jscoverage['assertion.js'][656] = 0; | ||
_$jscoverage['assertion.js'][661] = 0; | ||
_$jscoverage['assertion.js'][676] = 0; | ||
_$jscoverage['assertion.js'][677] = 0; | ||
_$jscoverage['assertion.js'][682] = 0; | ||
_$jscoverage['assertion.js'][697] = 0; | ||
_$jscoverage['assertion.js'][698] = 0; | ||
_$jscoverage['assertion.js'][703] = 0; | ||
_$jscoverage['assertion.js'][718] = 0; | ||
_$jscoverage['assertion.js'][719] = 0; | ||
_$jscoverage['assertion.js'][721] = 0; | ||
_$jscoverage['assertion.js'][726] = 0; | ||
_$jscoverage['assertion.js'][740] = 0; | ||
_$jscoverage['assertion.js'][742] = 0; | ||
_$jscoverage['assertion.js'][743] = 0; | ||
_$jscoverage['assertion.js'][762] = 0; | ||
_$jscoverage['assertion.js'][763] = 0; | ||
_$jscoverage['assertion.js'][766] = 0; | ||
_$jscoverage['assertion.js'][768] = 0; | ||
_$jscoverage['assertion.js'][770] = 0; | ||
_$jscoverage['assertion.js'][772] = 0; | ||
_$jscoverage['assertion.js'][773] = 0; | ||
_$jscoverage['assertion.js'][776] = 0; | ||
_$jscoverage['assertion.js'][777] = 0; | ||
_$jscoverage['assertion.js'][778] = 0; | ||
_$jscoverage['assertion.js'][781] = 0; | ||
_$jscoverage['assertion.js'][782] = 0; | ||
_$jscoverage['assertion.js'][783] = 0; | ||
_$jscoverage['assertion.js'][784] = 0; | ||
_$jscoverage['assertion.js'][786] = 0; | ||
_$jscoverage['assertion.js'][787] = 0; | ||
_$jscoverage['assertion.js'][789] = 0; | ||
_$jscoverage['assertion.js'][788] = 0; | ||
_$jscoverage['assertion.js'][790] = 0; | ||
_$jscoverage['assertion.js'][791] = 0; | ||
_$jscoverage['assertion.js'][793] = 0; | ||
_$jscoverage['assertion.js'][796] = 0; | ||
_$jscoverage['assertion.js'][799] = 0; | ||
_$jscoverage['assertion.js'][804] = 0; | ||
_$jscoverage['assertion.js'][823] = 0; | ||
_$jscoverage['assertion.js'][824] = 0; | ||
_$jscoverage['assertion.js'][826] = 0; | ||
_$jscoverage['assertion.js'][797] = 0; | ||
_$jscoverage['assertion.js'][800] = 0; | ||
_$jscoverage['assertion.js'][803] = 0; | ||
_$jscoverage['assertion.js'][808] = 0; | ||
_$jscoverage['assertion.js'][827] = 0; | ||
_$jscoverage['assertion.js'][828] = 0; | ||
_$jscoverage['assertion.js'][829] = 0; | ||
_$jscoverage['assertion.js'][831] = 0; | ||
_$jscoverage['assertion.js'][830] = 0; | ||
_$jscoverage['assertion.js'][832] = 0; | ||
_$jscoverage['assertion.js'][833] = 0; | ||
_$jscoverage['assertion.js'][835] = 0; | ||
_$jscoverage['assertion.js'][836] = 0; | ||
_$jscoverage['assertion.js'][837] = 0; | ||
_$jscoverage['assertion.js'][838] = 0; | ||
_$jscoverage['assertion.js'][840] = 0; | ||
_$jscoverage['assertion.js'][841] = 0; | ||
_$jscoverage['assertion.js'][842] = 0; | ||
_$jscoverage['assertion.js'][844] = 0; | ||
_$jscoverage['assertion.js'][846] = 0; | ||
_$jscoverage['assertion.js'][848] = 0; | ||
_$jscoverage['assertion.js'][850] = 0; | ||
_$jscoverage['assertion.js'][855] = 0; | ||
_$jscoverage['assertion.js'][871] = 0; | ||
_$jscoverage['assertion.js'][872] = 0; | ||
_$jscoverage['assertion.js'][852] = 0; | ||
_$jscoverage['assertion.js'][854] = 0; | ||
_$jscoverage['assertion.js'][859] = 0; | ||
_$jscoverage['assertion.js'][875] = 0; | ||
_$jscoverage['assertion.js'][876] = 0; | ||
_$jscoverage['assertion.js'][881] = 0; | ||
_$jscoverage['assertion.js'][896] = 0; | ||
_$jscoverage['assertion.js'][897] = 0; | ||
_$jscoverage['assertion.js'][902] = 0; | ||
_$jscoverage['assertion.js'][918] = 0; | ||
_$jscoverage['assertion.js'][919] = 0; | ||
_$jscoverage['assertion.js'][924] = 0; | ||
_$jscoverage['assertion.js'][931] = 0; | ||
_$jscoverage['assertion.js'][932] = 0; | ||
_$jscoverage['assertion.js'][933] = 0; | ||
_$jscoverage['assertion.js'][880] = 0; | ||
_$jscoverage['assertion.js'][885] = 0; | ||
_$jscoverage['assertion.js'][900] = 0; | ||
_$jscoverage['assertion.js'][901] = 0; | ||
_$jscoverage['assertion.js'][906] = 0; | ||
_$jscoverage['assertion.js'][922] = 0; | ||
_$jscoverage['assertion.js'][923] = 0; | ||
_$jscoverage['assertion.js'][928] = 0; | ||
_$jscoverage['assertion.js'][935] = 0; | ||
_$jscoverage['assertion.js'][936] = 0; | ||
_$jscoverage['assertion.js'][937] = 0; | ||
} | ||
_$jscoverage['assertion.js'][48]++; | ||
var AssertionError = require("./error"), eql = require("./utils/eql"), inspect = require("./utils/inspect"); | ||
_$jscoverage['assertion.js'][56]++; | ||
var AssertionError = require("./error"), eql = require("./utils/eql"), toString = Object.prototype.toString, inspect = require("./utils/inspect"); | ||
_$jscoverage['assertion.js'][57]++; | ||
module.exports = Assertion; | ||
_$jscoverage['assertion.js'][67]++; | ||
_$jscoverage['assertion.js'][68]++; | ||
function Assertion(obj, msg, stack) { | ||
_$jscoverage['assertion.js'][68]++; | ||
_$jscoverage['assertion.js'][69]++; | ||
this.ssfi = stack || arguments.callee; | ||
_$jscoverage['assertion.js'][69]++; | ||
_$jscoverage['assertion.js'][70]++; | ||
this.obj = obj; | ||
_$jscoverage['assertion.js'][70]++; | ||
_$jscoverage['assertion.js'][71]++; | ||
this.msg = msg; | ||
} | ||
_$jscoverage['assertion.js'][85]++; | ||
_$jscoverage['assertion.js'][87]++; | ||
Assertion.includeStack = false; | ||
_$jscoverage['assertion.js'][99]++; | ||
_$jscoverage['assertion.js'][101]++; | ||
Assertion.prototype.assert = (function (expr, msg, negateMsg) { | ||
_$jscoverage['assertion.js'][100]++; | ||
_$jscoverage['assertion.js'][102]++; | ||
var msg = (this.negate? negateMsg: msg), ok = this.negate? ! expr: expr; | ||
_$jscoverage['assertion.js'][103]++; | ||
_$jscoverage['assertion.js'][105]++; | ||
if (! ok) { | ||
_$jscoverage['assertion.js'][104]++; | ||
_$jscoverage['assertion.js'][106]++; | ||
throw new AssertionError({operator: this.msg, message: msg, stackStartFunction: Assertion.includeStack? this.assert: this.ssfi}); | ||
} | ||
}); | ||
_$jscoverage['assertion.js'][121]++; | ||
_$jscoverage['assertion.js'][123]++; | ||
Object.defineProperty(Assertion.prototype, "inspect", {get: (function () { | ||
_$jscoverage['assertion.js'][123]++; | ||
_$jscoverage['assertion.js'][125]++; | ||
return inspect(this.obj); | ||
}), configurable: true}); | ||
_$jscoverage['assertion.js'][137]++; | ||
_$jscoverage['assertion.js'][139]++; | ||
Object.defineProperty(Assertion.prototype, "to", {get: (function () { | ||
_$jscoverage['assertion.js'][139]++; | ||
_$jscoverage['assertion.js'][141]++; | ||
return this; | ||
}), configurable: true}); | ||
_$jscoverage['assertion.js'][153]++; | ||
_$jscoverage['assertion.js'][155]++; | ||
Object.defineProperty(Assertion.prototype, "be", {get: (function () { | ||
_$jscoverage['assertion.js'][155]++; | ||
_$jscoverage['assertion.js'][157]++; | ||
return this; | ||
}), configurable: true}); | ||
_$jscoverage['assertion.js'][170]++; | ||
_$jscoverage['assertion.js'][172]++; | ||
Object.defineProperty(Assertion.prototype, "been", {get: (function () { | ||
_$jscoverage['assertion.js'][172]++; | ||
_$jscoverage['assertion.js'][174]++; | ||
this.tense = "past"; | ||
_$jscoverage['assertion.js'][173]++; | ||
_$jscoverage['assertion.js'][175]++; | ||
return this; | ||
}), configurable: true}); | ||
_$jscoverage['assertion.js'][187]++; | ||
_$jscoverage['assertion.js'][189]++; | ||
Object.defineProperty(Assertion.prototype, "an", {get: (function () { | ||
_$jscoverage['assertion.js'][189]++; | ||
_$jscoverage['assertion.js'][191]++; | ||
return this; | ||
}), configurable: true}); | ||
_$jscoverage['assertion.js'][202]++; | ||
_$jscoverage['assertion.js'][204]++; | ||
Object.defineProperty(Assertion.prototype, "is", {get: (function () { | ||
_$jscoverage['assertion.js'][204]++; | ||
_$jscoverage['assertion.js'][206]++; | ||
return this; | ||
}), configurable: true}); | ||
_$jscoverage['assertion.js'][218]++; | ||
_$jscoverage['assertion.js'][220]++; | ||
Object.defineProperty(Assertion.prototype, "and", {get: (function () { | ||
_$jscoverage['assertion.js'][220]++; | ||
_$jscoverage['assertion.js'][222]++; | ||
return this; | ||
}), configurable: true}); | ||
_$jscoverage['assertion.js'][234]++; | ||
_$jscoverage['assertion.js'][236]++; | ||
Object.defineProperty(Assertion.prototype, "have", {get: (function () { | ||
_$jscoverage['assertion.js'][236]++; | ||
_$jscoverage['assertion.js'][238]++; | ||
return this; | ||
}), configurable: true}); | ||
_$jscoverage['assertion.js'][250]++; | ||
_$jscoverage['assertion.js'][252]++; | ||
Object.defineProperty(Assertion.prototype, "with", {get: (function () { | ||
_$jscoverage['assertion.js'][252]++; | ||
_$jscoverage['assertion.js'][254]++; | ||
return this; | ||
}), configurable: true}); | ||
_$jscoverage['assertion.js'][266]++; | ||
_$jscoverage['assertion.js'][268]++; | ||
Object.defineProperty(Assertion.prototype, "not", {get: (function () { | ||
_$jscoverage['assertion.js'][268]++; | ||
_$jscoverage['assertion.js'][270]++; | ||
this.negate = true; | ||
_$jscoverage['assertion.js'][269]++; | ||
_$jscoverage['assertion.js'][271]++; | ||
return this; | ||
}), configurable: true}); | ||
_$jscoverage['assertion.js'][288]++; | ||
_$jscoverage['assertion.js'][290]++; | ||
Object.defineProperty(Assertion.prototype, "ok", {get: (function () { | ||
_$jscoverage['assertion.js'][290]++; | ||
_$jscoverage['assertion.js'][292]++; | ||
this.assert(this.obj, "expected " + this.inspect + " to be truthy", "expected " + this.inspect + " to be falsey"); | ||
_$jscoverage['assertion.js'][295]++; | ||
_$jscoverage['assertion.js'][297]++; | ||
return this; | ||
}), configurable: true}); | ||
_$jscoverage['assertion.js'][309]++; | ||
_$jscoverage['assertion.js'][311]++; | ||
Object.defineProperty(Assertion.prototype, "true", {get: (function () { | ||
_$jscoverage['assertion.js'][311]++; | ||
_$jscoverage['assertion.js'][313]++; | ||
this.assert(true === this.obj, "expected " + this.inspect + " to be true", "expected " + this.inspect + " to be false"); | ||
_$jscoverage['assertion.js'][316]++; | ||
_$jscoverage['assertion.js'][318]++; | ||
return this; | ||
}), configurable: true}); | ||
_$jscoverage['assertion.js'][330]++; | ||
_$jscoverage['assertion.js'][332]++; | ||
Object.defineProperty(Assertion.prototype, "false", {get: (function () { | ||
_$jscoverage['assertion.js'][332]++; | ||
_$jscoverage['assertion.js'][334]++; | ||
this.assert(false === this.obj, "expected " + this.inspect + " to be false", "expected " + this.inspect + " to be true"); | ||
_$jscoverage['assertion.js'][337]++; | ||
_$jscoverage['assertion.js'][339]++; | ||
return this; | ||
}), configurable: true}); | ||
_$jscoverage['assertion.js'][356]++; | ||
_$jscoverage['assertion.js'][358]++; | ||
Object.defineProperty(Assertion.prototype, "exist", {get: (function () { | ||
_$jscoverage['assertion.js'][358]++; | ||
_$jscoverage['assertion.js'][360]++; | ||
this.assert(null != this.obj, "expected " + this.inspect + " to exist", "expected " + this.inspect + " to not exist"); | ||
_$jscoverage['assertion.js'][363]++; | ||
_$jscoverage['assertion.js'][365]++; | ||
return this; | ||
}), configurable: true}); | ||
_$jscoverage['assertion.js'][379]++; | ||
_$jscoverage['assertion.js'][381]++; | ||
Object.defineProperty(Assertion.prototype, "empty", {get: (function () { | ||
_$jscoverage['assertion.js'][381]++; | ||
_$jscoverage['assertion.js'][383]++; | ||
new Assertion(this.obj).to.have.property("length"); | ||
_$jscoverage['assertion.js'][383]++; | ||
_$jscoverage['assertion.js'][385]++; | ||
this.assert(0 === this.obj.length, "expected " + this.inspect + " to be empty", "expected " + this.inspect + " not to be empty"); | ||
_$jscoverage['assertion.js'][388]++; | ||
_$jscoverage['assertion.js'][390]++; | ||
return this; | ||
}), configurable: true}); | ||
_$jscoverage['assertion.js'][406]++; | ||
_$jscoverage['assertion.js'][408]++; | ||
Object.defineProperty(Assertion.prototype, "arguments", {get: (function () { | ||
_$jscoverage['assertion.js'][408]++; | ||
_$jscoverage['assertion.js'][410]++; | ||
this.assert("[object Arguments]" == Object.prototype.toString.call(this.obj), "expected " + this.inspect + " to be arguments", "expected " + this.inspect + " to not be arguments"); | ||
_$jscoverage['assertion.js'][413]++; | ||
_$jscoverage['assertion.js'][415]++; | ||
return this; | ||
}), configurable: true}); | ||
_$jscoverage['assertion.js'][430]++; | ||
_$jscoverage['assertion.js'][432]++; | ||
Assertion.prototype.equal = (function (val) { | ||
_$jscoverage['assertion.js'][431]++; | ||
_$jscoverage['assertion.js'][433]++; | ||
this.assert(val === this.obj, "expected " + this.inspect + " to equal " + inspect(val), "expected " + this.inspect + " to not equal " + inspect(val)); | ||
_$jscoverage['assertion.js'][436]++; | ||
_$jscoverage['assertion.js'][438]++; | ||
return this; | ||
}); | ||
_$jscoverage['assertion.js'][451]++; | ||
_$jscoverage['assertion.js'][453]++; | ||
Assertion.prototype.eql = (function (obj) { | ||
_$jscoverage['assertion.js'][452]++; | ||
_$jscoverage['assertion.js'][454]++; | ||
this.assert(eql(obj, this.obj), "expected " + this.inspect + " to equal " + inspect(obj), "expected " + this.inspect + " to not equal " + inspect(obj)); | ||
_$jscoverage['assertion.js'][456]++; | ||
_$jscoverage['assertion.js'][458]++; | ||
return this; | ||
}); | ||
_$jscoverage['assertion.js'][471]++; | ||
_$jscoverage['assertion.js'][473]++; | ||
Assertion.prototype.above = (function (val) { | ||
_$jscoverage['assertion.js'][472]++; | ||
_$jscoverage['assertion.js'][474]++; | ||
this.assert(this.obj > val, "expected " + this.inspect + " to be above " + val, "expected " + this.inspect + " to be below " + val); | ||
_$jscoverage['assertion.js'][477]++; | ||
_$jscoverage['assertion.js'][479]++; | ||
return this; | ||
}); | ||
_$jscoverage['assertion.js'][492]++; | ||
_$jscoverage['assertion.js'][494]++; | ||
Assertion.prototype.below = (function (val) { | ||
_$jscoverage['assertion.js'][493]++; | ||
_$jscoverage['assertion.js'][495]++; | ||
this.assert(this.obj < val, "expected " + this.inspect + " to be below " + val, "expected " + this.inspect + " to be above " + val); | ||
_$jscoverage['assertion.js'][498]++; | ||
_$jscoverage['assertion.js'][500]++; | ||
return this; | ||
}); | ||
_$jscoverage['assertion.js'][514]++; | ||
_$jscoverage['assertion.js'][516]++; | ||
Assertion.prototype.within = (function (start, finish) { | ||
_$jscoverage['assertion.js'][515]++; | ||
_$jscoverage['assertion.js'][517]++; | ||
var range = start + ".." + finish; | ||
_$jscoverage['assertion.js'][517]++; | ||
_$jscoverage['assertion.js'][519]++; | ||
this.assert(this.obj >= start && this.obj <= finish, "expected " + this.inspect + " to be within " + range, "expected " + this.inspect + " to not be within " + range); | ||
_$jscoverage['assertion.js'][522]++; | ||
_$jscoverage['assertion.js'][524]++; | ||
return this; | ||
}); | ||
_$jscoverage['assertion.js'][537]++; | ||
_$jscoverage['assertion.js'][539]++; | ||
Assertion.prototype.a = (function (type) { | ||
_$jscoverage['assertion.js'][538]++; | ||
this.assert(type == typeof this.obj, "expected " + this.inspect + " to be a " + type, "expected " + this.inspect + " not to be a " + type); | ||
_$jscoverage['assertion.js'][543]++; | ||
_$jscoverage['assertion.js'][540]++; | ||
var klass = type.charAt(0).toUpperCase() + type.slice(1); | ||
_$jscoverage['assertion.js'][542]++; | ||
this.assert("[object " + klass + "]" === toString.call(this.obj), "expected " + this.inspect + " to be a " + type, "expected " + this.inspect + " not to be a " + type); | ||
_$jscoverage['assertion.js'][547]++; | ||
return this; | ||
}); | ||
_$jscoverage['assertion.js'][562]++; | ||
_$jscoverage['assertion.js'][566]++; | ||
Assertion.prototype["instanceof"] = (function (constructor) { | ||
_$jscoverage['assertion.js'][563]++; | ||
_$jscoverage['assertion.js'][567]++; | ||
var name = constructor.name; | ||
_$jscoverage['assertion.js'][564]++; | ||
_$jscoverage['assertion.js'][568]++; | ||
this.assert(this.obj instanceof constructor, "expected " + this.inspect + " to be an instance of " + name, "expected " + this.inspect + " to not be an instance of " + name); | ||
_$jscoverage['assertion.js'][569]++; | ||
_$jscoverage['assertion.js'][573]++; | ||
return this; | ||
}); | ||
_$jscoverage['assertion.js'][589]++; | ||
_$jscoverage['assertion.js'][593]++; | ||
Assertion.prototype.property = (function (name, val) { | ||
_$jscoverage['assertion.js'][590]++; | ||
_$jscoverage['assertion.js'][594]++; | ||
if (this.negate && undefined !== val) { | ||
_$jscoverage['assertion.js'][591]++; | ||
_$jscoverage['assertion.js'][595]++; | ||
if (undefined === this.obj[name]) { | ||
_$jscoverage['assertion.js'][592]++; | ||
_$jscoverage['assertion.js'][596]++; | ||
throw new Error(this.inspect + " has no property " + inspect(name)); | ||
@@ -346,140 +349,140 @@ } | ||
else { | ||
_$jscoverage['assertion.js'][595]++; | ||
_$jscoverage['assertion.js'][599]++; | ||
this.assert(undefined !== this.obj[name], "expected " + this.inspect + " to have a property " + inspect(name), "expected " + this.inspect + " to not have property " + inspect(name)); | ||
} | ||
_$jscoverage['assertion.js'][601]++; | ||
_$jscoverage['assertion.js'][605]++; | ||
if (undefined !== val) { | ||
_$jscoverage['assertion.js'][602]++; | ||
_$jscoverage['assertion.js'][606]++; | ||
this.assert(val === this.obj[name], "expected " + this.inspect + " to have a property " + inspect(name) + " of " + inspect(val) + ", but got " + inspect(this.obj[name]), "expected " + this.inspect + " to not have a property " + inspect(name) + " of " + inspect(val)); | ||
} | ||
_$jscoverage['assertion.js'][609]++; | ||
_$jscoverage['assertion.js'][613]++; | ||
this.obj = this.obj[name]; | ||
_$jscoverage['assertion.js'][610]++; | ||
_$jscoverage['assertion.js'][614]++; | ||
return this; | ||
}); | ||
_$jscoverage['assertion.js'][626]++; | ||
_$jscoverage['assertion.js'][630]++; | ||
Assertion.prototype.ownProperty = (function (name) { | ||
_$jscoverage['assertion.js'][627]++; | ||
_$jscoverage['assertion.js'][631]++; | ||
this.assert(this.obj.hasOwnProperty(name), "expected " + this.inspect + " to have own property " + inspect(name), "expected " + this.inspect + " to not have own property " + inspect(name)); | ||
_$jscoverage['assertion.js'][631]++; | ||
_$jscoverage['assertion.js'][635]++; | ||
return this; | ||
}); | ||
_$jscoverage['assertion.js'][648]++; | ||
_$jscoverage['assertion.js'][652]++; | ||
Assertion.prototype.length = (function (n) { | ||
_$jscoverage['assertion.js'][649]++; | ||
_$jscoverage['assertion.js'][653]++; | ||
new Assertion(this.obj).to.have.property("length"); | ||
_$jscoverage['assertion.js'][650]++; | ||
_$jscoverage['assertion.js'][654]++; | ||
var len = this.obj.length; | ||
_$jscoverage['assertion.js'][652]++; | ||
_$jscoverage['assertion.js'][656]++; | ||
this.assert(len == n, "expected " + this.inspect + " to have a length of " + n + " but got " + len, "expected " + this.inspect + " to not have a length of " + len); | ||
_$jscoverage['assertion.js'][657]++; | ||
_$jscoverage['assertion.js'][661]++; | ||
return this; | ||
}); | ||
_$jscoverage['assertion.js'][672]++; | ||
_$jscoverage['assertion.js'][676]++; | ||
Assertion.prototype.match = (function (re) { | ||
_$jscoverage['assertion.js'][673]++; | ||
_$jscoverage['assertion.js'][677]++; | ||
this.assert(re.exec(this.obj), "expected " + this.inspect + " to match " + re, "expected " + this.inspect + " not to match " + re); | ||
_$jscoverage['assertion.js'][678]++; | ||
_$jscoverage['assertion.js'][682]++; | ||
return this; | ||
}); | ||
_$jscoverage['assertion.js'][693]++; | ||
_$jscoverage['assertion.js'][697]++; | ||
Assertion.prototype.include = (function (obj) { | ||
_$jscoverage['assertion.js'][694]++; | ||
_$jscoverage['assertion.js'][698]++; | ||
this.assert(~ this.obj.indexOf(obj), "expected " + this.inspect + " to include " + inspect(obj), "expected " + this.inspect + " to not include " + inspect(obj)); | ||
_$jscoverage['assertion.js'][699]++; | ||
_$jscoverage['assertion.js'][703]++; | ||
return this; | ||
}); | ||
_$jscoverage['assertion.js'][714]++; | ||
_$jscoverage['assertion.js'][718]++; | ||
Assertion.prototype.string = (function (str) { | ||
_$jscoverage['assertion.js'][715]++; | ||
_$jscoverage['assertion.js'][719]++; | ||
new Assertion(this.obj).is.a("string"); | ||
_$jscoverage['assertion.js'][717]++; | ||
_$jscoverage['assertion.js'][721]++; | ||
this.assert(~ this.obj.indexOf(str), "expected " + this.inspect + " to contain " + inspect(str), "expected " + this.inspect + " to not contain " + inspect(str)); | ||
_$jscoverage['assertion.js'][722]++; | ||
_$jscoverage['assertion.js'][726]++; | ||
return this; | ||
}); | ||
_$jscoverage['assertion.js'][736]++; | ||
_$jscoverage['assertion.js'][740]++; | ||
Object.defineProperty(Assertion.prototype, "contain", {get: (function () { | ||
_$jscoverage['assertion.js'][738]++; | ||
_$jscoverage['assertion.js'][742]++; | ||
this.contains = true; | ||
_$jscoverage['assertion.js'][739]++; | ||
_$jscoverage['assertion.js'][743]++; | ||
return this; | ||
}), configurable: true}); | ||
_$jscoverage['assertion.js'][758]++; | ||
_$jscoverage['assertion.js'][762]++; | ||
Assertion.prototype.keys = (function (keys) { | ||
_$jscoverage['assertion.js'][759]++; | ||
_$jscoverage['assertion.js'][763]++; | ||
var str, ok = true; | ||
_$jscoverage['assertion.js'][762]++; | ||
_$jscoverage['assertion.js'][766]++; | ||
keys = keys instanceof Array? keys: Array.prototype.slice.call(arguments); | ||
_$jscoverage['assertion.js'][766]++; | ||
_$jscoverage['assertion.js'][770]++; | ||
if (! keys.length) { | ||
_$jscoverage['assertion.js'][766]++; | ||
_$jscoverage['assertion.js'][770]++; | ||
throw new Error("keys required"); | ||
} | ||
_$jscoverage['assertion.js'][768]++; | ||
_$jscoverage['assertion.js'][772]++; | ||
var actual = Object.keys(this.obj), len = keys.length; | ||
_$jscoverage['assertion.js'][772]++; | ||
_$jscoverage['assertion.js'][776]++; | ||
ok = keys.every((function (key) { | ||
_$jscoverage['assertion.js'][773]++; | ||
_$jscoverage['assertion.js'][777]++; | ||
return ~ actual.indexOf(key); | ||
})); | ||
_$jscoverage['assertion.js'][777]++; | ||
_$jscoverage['assertion.js'][781]++; | ||
if (! this.negate && ! this.contains) { | ||
_$jscoverage['assertion.js'][778]++; | ||
_$jscoverage['assertion.js'][782]++; | ||
ok = ok && keys.length == actual.length; | ||
} | ||
_$jscoverage['assertion.js'][782]++; | ||
_$jscoverage['assertion.js'][786]++; | ||
if (len > 1) { | ||
_$jscoverage['assertion.js'][783]++; | ||
_$jscoverage['assertion.js'][787]++; | ||
keys = keys.map((function (key) { | ||
_$jscoverage['assertion.js'][784]++; | ||
_$jscoverage['assertion.js'][788]++; | ||
return inspect(key); | ||
})); | ||
_$jscoverage['assertion.js'][786]++; | ||
_$jscoverage['assertion.js'][790]++; | ||
var last = keys.pop(); | ||
_$jscoverage['assertion.js'][787]++; | ||
_$jscoverage['assertion.js'][791]++; | ||
str = keys.join(", ") + ", and " + last; | ||
} | ||
else { | ||
_$jscoverage['assertion.js'][789]++; | ||
_$jscoverage['assertion.js'][793]++; | ||
str = inspect(keys[0]); | ||
} | ||
_$jscoverage['assertion.js'][793]++; | ||
_$jscoverage['assertion.js'][797]++; | ||
str = (len > 1? "keys ": "key ") + str; | ||
_$jscoverage['assertion.js'][796]++; | ||
_$jscoverage['assertion.js'][800]++; | ||
str = (this.contains? "contain ": "have ") + str; | ||
_$jscoverage['assertion.js'][799]++; | ||
_$jscoverage['assertion.js'][803]++; | ||
this.assert(ok, "expected " + this.inspect + " to " + str, "expected " + this.inspect + " to not " + str); | ||
_$jscoverage['assertion.js'][804]++; | ||
_$jscoverage['assertion.js'][808]++; | ||
return this; | ||
}); | ||
_$jscoverage['assertion.js'][823]++; | ||
_$jscoverage['assertion.js'][827]++; | ||
Assertion.prototype["throw"] = (function (constructor) { | ||
_$jscoverage['assertion.js'][824]++; | ||
_$jscoverage['assertion.js'][828]++; | ||
new Assertion(this.obj).is.a("function"); | ||
_$jscoverage['assertion.js'][826]++; | ||
_$jscoverage['assertion.js'][830]++; | ||
var thrown = false; | ||
_$jscoverage['assertion.js'][828]++; | ||
_$jscoverage['assertion.js'][832]++; | ||
try { | ||
_$jscoverage['assertion.js'][829]++; | ||
_$jscoverage['assertion.js'][833]++; | ||
this.obj(); | ||
} | ||
catch (err) { | ||
_$jscoverage['assertion.js'][831]++; | ||
_$jscoverage['assertion.js'][835]++; | ||
if (constructor && "function" === typeof constructor && constructor.constructor != RegExp) { | ||
_$jscoverage['assertion.js'][832]++; | ||
_$jscoverage['assertion.js'][836]++; | ||
this.assert(err instanceof constructor && err.name == constructor.name, "expected " + this.inspect + " to throw " + constructor.name + " but a " + err.name + " was thrown", "expected " + this.inspect + " to not throw " + constructor.name); | ||
_$jscoverage['assertion.js'][836]++; | ||
_$jscoverage['assertion.js'][840]++; | ||
return this; | ||
} | ||
else { | ||
_$jscoverage['assertion.js'][837]++; | ||
_$jscoverage['assertion.js'][841]++; | ||
if (constructor && constructor instanceof RegExp) { | ||
_$jscoverage['assertion.js'][838]++; | ||
_$jscoverage['assertion.js'][842]++; | ||
this.assert(constructor.exec(err.message), "expected " + this.inspect + " to throw error matching " + constructor + " but got " + inspect(err.message), "expected " + this.inspect + " to throw error not matching " + constructor); | ||
_$jscoverage['assertion.js'][842]++; | ||
_$jscoverage['assertion.js'][846]++; | ||
return this; | ||
} | ||
else { | ||
_$jscoverage['assertion.js'][844]++; | ||
_$jscoverage['assertion.js'][848]++; | ||
thrown = true; | ||
@@ -489,39 +492,39 @@ } | ||
} | ||
_$jscoverage['assertion.js'][848]++; | ||
_$jscoverage['assertion.js'][852]++; | ||
var name = (constructor? constructor.name: "an error"); | ||
_$jscoverage['assertion.js'][850]++; | ||
_$jscoverage['assertion.js'][854]++; | ||
this.assert(thrown === true, "expected " + this.inspect + " to throw " + name, "expected " + this.inspect + " to not throw " + name); | ||
_$jscoverage['assertion.js'][855]++; | ||
_$jscoverage['assertion.js'][859]++; | ||
return this; | ||
}); | ||
_$jscoverage['assertion.js'][871]++; | ||
_$jscoverage['assertion.js'][875]++; | ||
Assertion.prototype.respondTo = (function (method) { | ||
_$jscoverage['assertion.js'][872]++; | ||
_$jscoverage['assertion.js'][876]++; | ||
var context = ("function" === typeof this.obj)? this.obj.prototype[method]: this.obj[method]; | ||
_$jscoverage['assertion.js'][876]++; | ||
_$jscoverage['assertion.js'][880]++; | ||
this.assert("function" === typeof context, "expected " + this.inspect + " to respond to " + inspect(method), "expected " + this.inspect + " to not respond to " + inspect(method)); | ||
_$jscoverage['assertion.js'][881]++; | ||
_$jscoverage['assertion.js'][885]++; | ||
return this; | ||
}); | ||
_$jscoverage['assertion.js'][896]++; | ||
_$jscoverage['assertion.js'][900]++; | ||
Assertion.prototype.satisfy = (function (matcher) { | ||
_$jscoverage['assertion.js'][897]++; | ||
_$jscoverage['assertion.js'][901]++; | ||
this.assert(matcher(this.obj), "expected " + this.inspect + " to satisfy " + inspect(matcher), "expected " + this.inspect + " to not satisfy" + inspect(matcher)); | ||
_$jscoverage['assertion.js'][902]++; | ||
_$jscoverage['assertion.js'][906]++; | ||
return this; | ||
}); | ||
_$jscoverage['assertion.js'][918]++; | ||
_$jscoverage['assertion.js'][922]++; | ||
Assertion.prototype.closeTo = (function (expected, delta) { | ||
_$jscoverage['assertion.js'][919]++; | ||
_$jscoverage['assertion.js'][923]++; | ||
this.assert((this.obj - delta === expected) || (this.obj + delta === expected), "expected " + this.inspect + " to be close to " + expected + " +/- " + delta, "expected " + this.inspect + " not to be close to " + expected + " +/- " + delta); | ||
_$jscoverage['assertion.js'][924]++; | ||
_$jscoverage['assertion.js'][928]++; | ||
return this; | ||
}); | ||
_$jscoverage['assertion.js'][931]++; | ||
_$jscoverage['assertion.js'][935]++; | ||
(function alias(name, as) { | ||
_$jscoverage['assertion.js'][932]++; | ||
_$jscoverage['assertion.js'][936]++; | ||
Assertion.prototype[as] = Assertion.prototype[name]; | ||
_$jscoverage['assertion.js'][933]++; | ||
_$jscoverage['assertion.js'][937]++; | ||
return alias; | ||
})("length", "lengthOf")("keys", "key")("ownProperty", "haveOwnProperty")("above", "greaterThan")("below", "lessThan")("throw", "throws")("throw", "Throw")("instanceof", "instanceOf"); | ||
_$jscoverage['assertion.js'].source = ["/*!"," * chai"," * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>"," * MIT Licensed"," *"," * Primarily a refactor of: should.js"," * https://github.com/visionmedia/should.js"," * Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>"," * MIT Licensed"," */","","/**"," * ### BDD Style Introduction"," *"," * The BDD style is exposed through `expect` or `should` interfaces. In both"," * scenarios, you chain together natural language assertions."," *"," * // expect"," * var expect = require('chai').expect;"," * expect(foo).to.equal('bar');"," *"," * // should"," * var should = require('chai').should();"," * foo.should.equal('bar');"," *"," * #### Differences"," *"," * The `expect` interface provides a function as a starting point for chaining"," * your language assertions. It works on both node.js and in the browser."," *"," * The `should` interface extends `Object.prototype` to provide a single getter as"," * the starting point for your language assertions. Most browser don't like"," * extensions to `Object.prototype` so it is not recommended for browser use."," *"," * #### Configuration"," *"," * By default, Chai does not show stack traces upon an AssertionError. This can"," * be changed by modifying the `includeStack` parameter for chai.Assertion. For example:"," *"," * var chai = require('chai');"," * chai.Assertion.includeStack = true; // defaults to false"," */","","/*!"," * Module dependencies."," */","","var AssertionError = require('./error')"," , eql = require('./utils/eql')"," , inspect = require('./utils/inspect');","","/*!"," * Module export."," */","","module.exports = Assertion;","","","/*!"," * # Assertion Constructor"," *"," * Creates object for chaining."," *"," * @api private"," */","","function Assertion (obj, msg, stack) {"," this.ssfi = stack || arguments.callee;"," this.obj = obj;"," this.msg = msg;","}","","/*!"," * ## Assertion.includeStack"," *"," * User configurable property, influences whether stack trace"," * is included in Assertion error message. Default of false"," * suppresses stack trace in the error message"," *"," * Assertion.includeStack = true; // enable stack on error"," *"," * @api public"," */","","Assertion.includeStack = false;","","/*!"," * # .assert(expression, message, negateMessage)"," *"," * Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass."," *"," * @name assert"," * @param {Philosophical} expression to be tested"," * @param {String} message to display if fails"," * @param {String} negatedMessage to display if negated expression fails"," * @api private"," */","","Assertion.prototype.assert = function (expr, msg, negateMsg) {"," var msg = (this.negate ? negateMsg : msg)"," , ok = this.negate ? !expr : expr;",""," if (!ok) {"," throw new AssertionError({"," operator: this.msg,"," message: msg,"," stackStartFunction: (Assertion.includeStack) ? this.assert : this.ssfi"," });"," }","};","","/*!"," * # inspect"," *"," * Returns the current object stringified."," *"," * @name inspect"," * @api private"," */","","Object.defineProperty(Assertion.prototype, 'inspect',"," { get: function () {"," return inspect(this.obj);"," },"," configurable: true","});","","/**"," * # to"," *"," * Language chain."," *"," * @name to"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'to',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # be"," *"," * Language chain."," *"," * @name be"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'be',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # been"," *"," * Language chain. Also tests `tense` to past for addon"," * modules that use the tense feature."," *"," * @name been"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'been',"," { get: function () {"," this.tense = 'past';"," return this;"," },"," configurable: true","});","","/**"," * # an"," *"," * Language chain."," *"," * @name an"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'an',"," { get: function () {"," return this;"," },"," configurable: true","});","/**"," * # is"," *"," * Language chain."," *"," * @name is"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'is',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # and"," *"," * Language chain."," *"," * @name and"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'and',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # have"," *"," * Language chain."," *"," * @name have"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'have',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # with"," *"," * Language chain."," *"," * @name with"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'with',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # .not"," *"," * Negates any of assertions following in the chain."," *"," * @name not"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'not',"," { get: function () {"," this.negate = true;"," return this;"," },"," configurable: true","});","","/**"," * # .ok"," *"," * Assert object truthiness."," *"," * expect('everthing').to.be.ok;"," * expect(false).to.not.be.ok;"," * expect(undefined).to.not.be.ok;"," * expect(null).to.not.be.ok;"," *"," * @name ok"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'ok',"," { get: function () {"," this.assert("," this.obj"," , 'expected ' + this.inspect + ' to be truthy'"," , 'expected ' + this.inspect + ' to be falsey');",""," return this;"," },"," configurable: true","});","","/**"," * # .true"," *"," * Assert object is true"," *"," * @name true"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'true',"," { get: function () {"," this.assert("," true === this.obj"," , 'expected ' + this.inspect + ' to be true'"," , 'expected ' + this.inspect + ' to be false');",""," return this;"," },"," configurable: true","});","","/**"," * # .false"," *"," * Assert object is false"," *"," * @name false"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'false',"," { get: function () {"," this.assert("," false === this.obj"," , 'expected ' + this.inspect + ' to be false'"," , 'expected ' + this.inspect + ' to be true');",""," return this;"," },"," configurable: true","});","","/**"," * # .exist"," *"," * Assert object exists (null)."," *"," * var foo = 'hi'"," * , bar;"," * expect(foo).to.exist;"," * expect(bar).to.not.exist;"," *"," * @name exist"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'exist',"," { get: function () {"," this.assert("," null != this.obj"," , 'expected ' + this.inspect + ' to exist'"," , 'expected ' + this.inspect + ' to not exist');",""," return this;"," },"," configurable: true","});","","/**"," * # .empty"," *"," * Assert object's length to be 0."," *"," * expect([]).to.be.empty;"," *"," * @name empty"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'empty',"," { get: function () {"," new Assertion(this.obj).to.have.property('length');",""," this.assert("," 0 === this.obj.length"," , 'expected ' + this.inspect + ' to be empty'"," , 'expected ' + this.inspect + ' not to be empty');",""," return this;"," },"," configurable: true","});","","/**"," * # .arguments"," *"," * Assert object is an instanceof arguments."," *"," * function test () {"," * expect(arguments).to.be.arguments;"," * }"," *"," * @name arguments"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'arguments',"," { get: function () {"," this.assert("," '[object Arguments]' == Object.prototype.toString.call(this.obj)"," , 'expected ' + this.inspect + ' to be arguments'"," , 'expected ' + this.inspect + ' to not be arguments');",""," return this;"," },"," configurable: true","});","","/**"," * # .equal(value)"," *"," * Assert strict equality."," *"," * expect('hello').to.equal('hello');"," *"," * @name equal"," * @param {*} value"," * @api public"," */","","Assertion.prototype.equal = function (val) {"," this.assert("," val === this.obj"," , 'expected ' + this.inspect + ' to equal ' + inspect(val)"," , 'expected ' + this.inspect + ' to not equal ' + inspect(val));",""," return this;","};","","/**"," * # .eql(value)"," *"," * Assert deep equality."," *"," * expect({ foo: 'bar' }).to.eql({ foo: 'bar' });"," *"," * @name eql"," * @param {*} value"," * @api public"," */","","Assertion.prototype.eql = function (obj) {"," this.assert("," eql(obj, this.obj)"," , 'expected ' + this.inspect + ' to equal ' + inspect(obj)"," , 'expected ' + this.inspect + ' to not equal ' + inspect(obj));"," return this;","};","","/**"," * # .above(value)"," *"," * Assert greater than `value`."," *"," * expect(10).to.be.above(5);"," *"," * @name above"," * @param {Number} value"," * @api public"," */","","Assertion.prototype.above = function (val) {"," this.assert("," this.obj > val"," , 'expected ' + this.inspect + ' to be above ' + val"," , 'expected ' + this.inspect + ' to be below ' + val);",""," return this;","};","","/**"," * # .below(value)"," *"," * Assert less than `value`."," *"," * expect(5).to.be.below(10);"," *"," * @name below"," * @param {Number} value"," * @api public"," */","","Assertion.prototype.below = function (val) {"," this.assert("," this.obj < val"," , 'expected ' + this.inspect + ' to be below ' + val"," , 'expected ' + this.inspect + ' to be above ' + val);",""," return this;","};","","/**"," * # .within(start, finish)"," *"," * Assert that a number is within a range."," *"," * expect(7).to.be.within(5,10);"," *"," * @name within"," * @param {Number} start lowerbound inclusive"," * @param {Number} finish upperbound inclusive"," * @api public"," */","","Assertion.prototype.within = function (start, finish) {"," var range = start + '..' + finish;",""," this.assert("," this.obj >= start && this.obj <= finish"," , 'expected ' + this.inspect + ' to be within ' + range"," , 'expected ' + this.inspect + ' to not be within ' + range);",""," return this;","};","","/**"," * # .a(type)"," *"," * Assert typeof."," *"," * expect('test').to.be.a('string');"," *"," * @name a"," * @param {String} type"," * @api public"," */","","Assertion.prototype.a = function (type) {"," this.assert("," type == typeof this.obj"," , 'expected ' + this.inspect + ' to be a ' + type"," , 'expected ' + this.inspect + ' not to be a ' + type);",""," return this;","};","","/**"," * # .instanceof(constructor)"," *"," * Assert instanceof."," *"," * var Tea = function (name) { this.name = name; }"," * , Chai = new Tea('chai');"," *"," * expect(Chai).to.be.an.instanceOf(Tea);"," *"," * @name instanceof"," * @param {Constructor}"," * @alias instanceOf"," * @api public"," */","","Assertion.prototype.instanceof = function (constructor) {"," var name = constructor.name;"," this.assert("," this.obj instanceof constructor"," , 'expected ' + this.inspect + ' to be an instance of ' + name"," , 'expected ' + this.inspect + ' to not be an instance of ' + name);",""," return this;","};","","/**"," * # .property(name, [value])"," *"," * Assert that property of `name` exists, optionally with `value`."," *"," * var obj = { foo: 'bar' }"," * expect(obj).to.have.property('foo');"," * expect(obj).to.have.property('foo', 'bar');"," * expect(obj).to.have.property('foo').to.be.a('string');"," *"," * @name property"," * @param {String} name"," * @param {*} value (optional)"," * @returns value of property for chaining"," * @api public"," */","","Assertion.prototype.property = function (name, val) {"," if (this.negate && undefined !== val) {"," if (undefined === this.obj[name]) {"," throw new Error(this.inspect + ' has no property ' + inspect(name));"," }"," } else {"," this.assert("," undefined !== this.obj[name]"," , 'expected ' + this.inspect + ' to have a property ' + inspect(name)"," , 'expected ' + this.inspect + ' to not have property ' + inspect(name));"," }",""," if (undefined !== val) {"," this.assert("," val === this.obj[name]"," , 'expected ' + this.inspect + ' to have a property ' + inspect(name) + ' of ' +"," inspect(val) + ', but got ' + inspect(this.obj[name])"," , 'expected ' + this.inspect + ' to not have a property ' + inspect(name) + ' of ' + inspect(val));"," }",""," this.obj = this.obj[name];"," return this;","};","","/**"," * # .ownProperty(name)"," *"," * Assert that has own property by `name`."," *"," * expect('test').to.have.ownProperty('length');"," *"," * @name ownProperty"," * @alias haveOwnProperty"," * @param {String} name"," * @api public"," */","","Assertion.prototype.ownProperty = function (name) {"," this.assert("," this.obj.hasOwnProperty(name)"," , 'expected ' + this.inspect + ' to have own property ' + inspect(name)"," , 'expected ' + this.inspect + ' to not have own property ' + inspect(name));"," return this;","};","","/**"," * # .length(val)"," *"," * Assert that object has expected length."," *"," * expect([1,2,3]).to.have.length(3);"," * expect('foobar').to.have.length(6);"," *"," * @name length"," * @alias lengthOf"," * @param {Number} length"," * @api public"," */","","Assertion.prototype.length = function (n) {"," new Assertion(this.obj).to.have.property('length');"," var len = this.obj.length;",""," this.assert("," len == n"," , 'expected ' + this.inspect + ' to have a length of ' + n + ' but got ' + len"," , 'expected ' + this.inspect + ' to not have a length of ' + len);",""," return this;","};","","/**"," * # .match(regexp)"," *"," * Assert that matches regular expression."," *"," * expect('foobar').to.match(/^foo/);"," *"," * @name match"," * @param {RegExp} RegularExpression"," * @api public"," */","","Assertion.prototype.match = function (re) {"," this.assert("," re.exec(this.obj)"," , 'expected ' + this.inspect + ' to match ' + re"," , 'expected ' + this.inspect + ' not to match ' + re);",""," return this;","};","","/**"," * # .include(obj)"," *"," * Assert the inclusion of an object in an Array or substring in string."," *"," * expect([1,2,3]).to.include(2);"," *"," * @name include"," * @param {Object|String|Number} obj"," * @api public"," */","","Assertion.prototype.include = function (obj) {"," this.assert("," ~this.obj.indexOf(obj)"," , 'expected ' + this.inspect + ' to include ' + inspect(obj)"," , 'expected ' + this.inspect + ' to not include ' + inspect(obj));",""," return this;","};","","/**"," * # .string(string)"," *"," * Assert inclusion of string in string."," *"," * expect('foobar').to.have.string('bar');"," *"," * @name string"," * @param {String} string"," * @api public"," */","","Assertion.prototype.string = function (str) {"," new Assertion(this.obj).is.a('string');",""," this.assert("," ~this.obj.indexOf(str)"," , 'expected ' + this.inspect + ' to contain ' + inspect(str)"," , 'expected ' + this.inspect + ' to not contain ' + inspect(str));",""," return this;","};","","","","/**"," * # contain"," *"," * Toggles the `contain` flag for the `keys` assertion."," *"," * @name contain"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'contain',"," { get: function () {"," this.contains = true;"," return this;"," },"," configurable: true","});","","/**"," * # .keys(key1, [key2], [...])"," *"," * Assert exact keys or the inclusing of keys using the `contain` modifier."," *"," * expect({ foo: 1, bar: 2 }).to.have.keys(['foo', 'bar']);"," * expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('foo', 'bar');"," *"," * @name keys"," * @alias key"," * @param {String|Array} Keys"," * @api public"," */","","Assertion.prototype.keys = function(keys) {"," var str"," , ok = true;",""," keys = keys instanceof Array"," ? keys"," : Array.prototype.slice.call(arguments);",""," if (!keys.length) throw new Error('keys required');",""," var actual = Object.keys(this.obj)"," , len = keys.length;",""," // Inclusion"," ok = keys.every(function(key){"," return ~actual.indexOf(key);"," });",""," // Strict"," if (!this.negate && !this.contains) {"," ok = ok && keys.length == actual.length;"," }",""," // Key string"," if (len > 1) {"," keys = keys.map(function(key){"," return inspect(key);"," });"," var last = keys.pop();"," str = keys.join(', ') + ', and ' + last;"," } else {"," str = inspect(keys[0]);"," }",""," // Form"," str = (len > 1 ? 'keys ' : 'key ') + str;",""," // Have / include"," str = (this.contains ? 'contain ' : 'have ') + str;",""," // Assertion"," this.assert("," ok"," , 'expected ' + this.inspect + ' to ' + str"," , 'expected ' + this.inspect + ' to not ' + str);",""," return this;","}","","/**"," * # .throw(constructor)"," *"," * Assert that a function will throw a specific type of error."," *"," * var fn = function () { throw new ReferenceError(''); }"," * expect(fn).to.throw(ReferenceError);"," *"," * @name throw"," * @alias throws"," * @alias Throw"," * @param {ErrorConstructor} constructor"," * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types"," * @api public"," */","","Assertion.prototype.throw = function (constructor) {"," new Assertion(this.obj).is.a('function');",""," var thrown = false;",""," try {"," this.obj();"," } catch (err) {"," if (constructor && 'function' === typeof constructor && constructor.constructor != RegExp) {"," this.assert("," err instanceof constructor && err.name == constructor.name"," , 'expected ' + this.inspect + ' to throw ' + constructor.name + ' but a ' + err.name + ' was thrown'"," , 'expected ' + this.inspect + ' to not throw ' + constructor.name );"," return this;"," } else if (constructor && constructor instanceof RegExp) {"," this.assert("," constructor.exec(err.message)"," , 'expected ' + this.inspect + ' to throw error matching ' + constructor + ' but got ' + inspect(err.message)"," , 'expected ' + this.inspect + ' to throw error not matching ' + constructor);"," return this;"," } else {"," thrown = true;"," }"," }",""," var name = (constructor ? constructor.name : 'an error');",""," this.assert("," thrown === true"," , 'expected ' + this.inspect + ' to throw ' + name"," , 'expected ' + this.inspect + ' to not throw ' + name);",""," return this;","};","","/**"," * # .respondTo(method)"," *"," * Assert that object/class will respond to a method."," *"," * expect(Klass).to.respondTo('bar');"," * expect(obj).to.respondTo('bar');"," *"," * @name respondTo"," * @param {String} method"," * @api public"," */","","Assertion.prototype.respondTo = function (method) {"," var context = ('function' === typeof this.obj)"," ? this.obj.prototype[method]"," : this.obj[method];",""," this.assert("," 'function' === typeof context"," , 'expected ' + this.inspect + ' to respond to ' + inspect(method)"," , 'expected ' + this.inspect + ' to not respond to ' + inspect(method));",""," return this;","};","","/**"," * # .satisfy(method)"," *"," * Assert that passes a truth test."," *"," * expect(1).to.satisfy(function(num) { return num > 0; });"," *"," * @name satisfy"," * @param {Function} matcher"," * @api public"," */","","Assertion.prototype.satisfy = function (matcher) {"," this.assert("," matcher(this.obj)"," , 'expected ' + this.inspect + ' to satisfy ' + inspect(matcher)"," , 'expected ' + this.inspect + ' to not satisfy' + inspect(matcher));",""," return this;","};","","/**"," * # .closeTo(expected, delta)"," *"," * Assert that actual is equal to +/- delta."," *"," * expect(1.5).to.be.closeTo(1, 0.5);"," *"," * @name closeTo"," * @param {Number} expected"," * @param {Number} delta"," * @api public"," */","","Assertion.prototype.closeTo = function (expected, delta) {"," this.assert("," (this.obj - delta === expected) || (this.obj + delta === expected)"," , 'expected ' + this.inspect + ' to be close to ' + expected + ' +/- ' + delta"," , 'expected ' + this.inspect + ' not to be close to ' + expected + ' +/- ' + delta);",""," return this;","};","","/*!"," * Aliases."," */","","(function alias(name, as){"," Assertion.prototype[as] = Assertion.prototype[name];"," return alias;","})","('length', 'lengthOf')","('keys', 'key')","('ownProperty', 'haveOwnProperty')","('above', 'greaterThan')","('below', 'lessThan')","('throw', 'throws')","('throw', 'Throw') // for troublesome browsers","('instanceof', 'instanceOf');"]; | ||
_$jscoverage['assertion.js'].source = ["/*!"," * chai"," * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>"," * MIT Licensed"," *"," * Primarily a refactor of: should.js"," * https://github.com/visionmedia/should.js"," * Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>"," * MIT Licensed"," */","","/**"," * ### BDD Style Introduction"," *"," * The BDD style is exposed through `expect` or `should` interfaces. In both"," * scenarios, you chain together natural language assertions."," *"," * // expect"," * var expect = require('chai').expect;"," * expect(foo).to.equal('bar');"," *"," * // should"," * var should = require('chai').should();"," * foo.should.equal('bar');"," *"," * #### Differences"," *"," * The `expect` interface provides a function as a starting point for chaining"," * your language assertions. It works on both node.js and in the browser."," *"," * The `should` interface extends `Object.prototype` to provide a single getter as"," * the starting point for your language assertions. Most browser don't like"," * extensions to `Object.prototype` so it is not recommended for browser use."," *"," * #### Configuration"," *"," * By default, Chai does not show stack traces upon an AssertionError. This can"," * be changed by modifying the `includeStack` parameter for chai.Assertion. For example:"," *"," * var chai = require('chai');"," * chai.Assertion.includeStack = true; // defaults to false"," */","","/*!"," * Module dependencies."," */","","var AssertionError = require('./error')"," , eql = require('./utils/eql')"," , toString = Object.prototype.toString"," , inspect = require('./utils/inspect');","","/*!"," * Module export."," */","","module.exports = Assertion;","","","/*!"," * # Assertion Constructor"," *"," * Creates object for chaining."," *"," * @api private"," */","","function Assertion (obj, msg, stack) {"," this.ssfi = stack || arguments.callee;"," this.obj = obj;"," this.msg = msg;","}","","/*!"," * ## Assertion.includeStack"," * , toString = Object.prototype.toString "," *"," * User configurable property, influences whether stack trace"," * is included in Assertion error message. Default of false"," * suppresses stack trace in the error message"," *"," * Assertion.includeStack = true; // enable stack on error"," *"," * @api public"," */","","Assertion.includeStack = false;","","/*!"," * # .assert(expression, message, negateMessage)"," *"," * Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass."," *"," * @name assert"," * @param {Philosophical} expression to be tested"," * @param {String} message to display if fails"," * @param {String} negatedMessage to display if negated expression fails"," * @api private"," */","","Assertion.prototype.assert = function (expr, msg, negateMsg) {"," var msg = (this.negate ? negateMsg : msg)"," , ok = this.negate ? !expr : expr;",""," if (!ok) {"," throw new AssertionError({"," operator: this.msg,"," message: msg,"," stackStartFunction: (Assertion.includeStack) ? this.assert : this.ssfi"," });"," }","};","","/*!"," * # inspect"," *"," * Returns the current object stringified."," *"," * @name inspect"," * @api private"," */","","Object.defineProperty(Assertion.prototype, 'inspect',"," { get: function () {"," return inspect(this.obj);"," },"," configurable: true","});","","/**"," * # to"," *"," * Language chain."," *"," * @name to"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'to',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # be"," *"," * Language chain."," *"," * @name be"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'be',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # been"," *"," * Language chain. Also tests `tense` to past for addon"," * modules that use the tense feature."," *"," * @name been"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'been',"," { get: function () {"," this.tense = 'past';"," return this;"," },"," configurable: true","});","","/**"," * # an"," *"," * Language chain."," *"," * @name an"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'an',"," { get: function () {"," return this;"," },"," configurable: true","});","/**"," * # is"," *"," * Language chain."," *"," * @name is"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'is',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # and"," *"," * Language chain."," *"," * @name and"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'and',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # have"," *"," * Language chain."," *"," * @name have"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'have',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # with"," *"," * Language chain."," *"," * @name with"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'with',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # .not"," *"," * Negates any of assertions following in the chain."," *"," * @name not"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'not',"," { get: function () {"," this.negate = true;"," return this;"," },"," configurable: true","});","","/**"," * # .ok"," *"," * Assert object truthiness."," *"," * expect('everthing').to.be.ok;"," * expect(false).to.not.be.ok;"," * expect(undefined).to.not.be.ok;"," * expect(null).to.not.be.ok;"," *"," * @name ok"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'ok',"," { get: function () {"," this.assert("," this.obj"," , 'expected ' + this.inspect + ' to be truthy'"," , 'expected ' + this.inspect + ' to be falsey');",""," return this;"," },"," configurable: true","});","","/**"," * # .true"," *"," * Assert object is true"," *"," * @name true"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'true',"," { get: function () {"," this.assert("," true === this.obj"," , 'expected ' + this.inspect + ' to be true'"," , 'expected ' + this.inspect + ' to be false');",""," return this;"," },"," configurable: true","});","","/**"," * # .false"," *"," * Assert object is false"," *"," * @name false"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'false',"," { get: function () {"," this.assert("," false === this.obj"," , 'expected ' + this.inspect + ' to be false'"," , 'expected ' + this.inspect + ' to be true');",""," return this;"," },"," configurable: true","});","","/**"," * # .exist"," *"," * Assert object exists (null)."," *"," * var foo = 'hi'"," * , bar;"," * expect(foo).to.exist;"," * expect(bar).to.not.exist;"," *"," * @name exist"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'exist',"," { get: function () {"," this.assert("," null != this.obj"," , 'expected ' + this.inspect + ' to exist'"," , 'expected ' + this.inspect + ' to not exist');",""," return this;"," },"," configurable: true","});","","/**"," * # .empty"," *"," * Assert object's length to be 0."," *"," * expect([]).to.be.empty;"," *"," * @name empty"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'empty',"," { get: function () {"," new Assertion(this.obj).to.have.property('length');",""," this.assert("," 0 === this.obj.length"," , 'expected ' + this.inspect + ' to be empty'"," , 'expected ' + this.inspect + ' not to be empty');",""," return this;"," },"," configurable: true","});","","/**"," * # .arguments"," *"," * Assert object is an instanceof arguments."," *"," * function test () {"," * expect(arguments).to.be.arguments;"," * }"," *"," * @name arguments"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'arguments',"," { get: function () {"," this.assert("," '[object Arguments]' == Object.prototype.toString.call(this.obj)"," , 'expected ' + this.inspect + ' to be arguments'"," , 'expected ' + this.inspect + ' to not be arguments');",""," return this;"," },"," configurable: true","});","","/**"," * # .equal(value)"," *"," * Assert strict equality."," *"," * expect('hello').to.equal('hello');"," *"," * @name equal"," * @param {*} value"," * @api public"," */","","Assertion.prototype.equal = function (val) {"," this.assert("," val === this.obj"," , 'expected ' + this.inspect + ' to equal ' + inspect(val)"," , 'expected ' + this.inspect + ' to not equal ' + inspect(val));",""," return this;","};","","/**"," * # .eql(value)"," *"," * Assert deep equality."," *"," * expect({ foo: 'bar' }).to.eql({ foo: 'bar' });"," *"," * @name eql"," * @param {*} value"," * @api public"," */","","Assertion.prototype.eql = function (obj) {"," this.assert("," eql(obj, this.obj)"," , 'expected ' + this.inspect + ' to equal ' + inspect(obj)"," , 'expected ' + this.inspect + ' to not equal ' + inspect(obj));"," return this;","};","","/**"," * # .above(value)"," *"," * Assert greater than `value`."," *"," * expect(10).to.be.above(5);"," *"," * @name above"," * @param {Number} value"," * @api public"," */","","Assertion.prototype.above = function (val) {"," this.assert("," this.obj > val"," , 'expected ' + this.inspect + ' to be above ' + val"," , 'expected ' + this.inspect + ' to be below ' + val);",""," return this;","};","","/**"," * # .below(value)"," *"," * Assert less than `value`."," *"," * expect(5).to.be.below(10);"," *"," * @name below"," * @param {Number} value"," * @api public"," */","","Assertion.prototype.below = function (val) {"," this.assert("," this.obj < val"," , 'expected ' + this.inspect + ' to be below ' + val"," , 'expected ' + this.inspect + ' to be above ' + val);",""," return this;","};","","/**"," * # .within(start, finish)"," *"," * Assert that a number is within a range."," *"," * expect(7).to.be.within(5,10);"," *"," * @name within"," * @param {Number} start lowerbound inclusive"," * @param {Number} finish upperbound inclusive"," * @api public"," */","","Assertion.prototype.within = function (start, finish) {"," var range = start + '..' + finish;",""," this.assert("," this.obj >= start && this.obj <= finish"," , 'expected ' + this.inspect + ' to be within ' + range"," , 'expected ' + this.inspect + ' to not be within ' + range);",""," return this;","};","","/**"," * # .a(type)"," *"," * Assert typeof."," *"," * expect('test').to.be.a('string');"," *"," * @name a"," * @param {String} type"," * @api public"," */","","Assertion.prototype.a = function (type) {"," var klass = type.charAt(0).toUpperCase() + type.slice(1);",""," this.assert("," '[object ' + klass + ']' === toString.call(this.obj)"," , 'expected ' + this.inspect + ' to be a ' + type"," , 'expected ' + this.inspect + ' not to be a ' + type);",""," return this;","};","","/**"," * # .instanceof(constructor)"," *"," * Assert instanceof."," *"," * var Tea = function (name) { this.name = name; }"," * , Chai = new Tea('chai');"," *"," * expect(Chai).to.be.an.instanceOf(Tea);"," *"," * @name instanceof"," * @param {Constructor}"," * @alias instanceOf"," * @api public"," */","","Assertion.prototype.instanceof = function (constructor) {"," var name = constructor.name;"," this.assert("," this.obj instanceof constructor"," , 'expected ' + this.inspect + ' to be an instance of ' + name"," , 'expected ' + this.inspect + ' to not be an instance of ' + name);",""," return this;","};","","/**"," * # .property(name, [value])"," *"," * Assert that property of `name` exists, optionally with `value`."," *"," * var obj = { foo: 'bar' }"," * expect(obj).to.have.property('foo');"," * expect(obj).to.have.property('foo', 'bar');"," * expect(obj).to.have.property('foo').to.be.a('string');"," *"," * @name property"," * @param {String} name"," * @param {*} value (optional)"," * @returns value of property for chaining"," * @api public"," */","","Assertion.prototype.property = function (name, val) {"," if (this.negate && undefined !== val) {"," if (undefined === this.obj[name]) {"," throw new Error(this.inspect + ' has no property ' + inspect(name));"," }"," } else {"," this.assert("," undefined !== this.obj[name]"," , 'expected ' + this.inspect + ' to have a property ' + inspect(name)"," , 'expected ' + this.inspect + ' to not have property ' + inspect(name));"," }",""," if (undefined !== val) {"," this.assert("," val === this.obj[name]"," , 'expected ' + this.inspect + ' to have a property ' + inspect(name) + ' of ' +"," inspect(val) + ', but got ' + inspect(this.obj[name])"," , 'expected ' + this.inspect + ' to not have a property ' + inspect(name) + ' of ' + inspect(val));"," }",""," this.obj = this.obj[name];"," return this;","};","","/**"," * # .ownProperty(name)"," *"," * Assert that has own property by `name`."," *"," * expect('test').to.have.ownProperty('length');"," *"," * @name ownProperty"," * @alias haveOwnProperty"," * @param {String} name"," * @api public"," */","","Assertion.prototype.ownProperty = function (name) {"," this.assert("," this.obj.hasOwnProperty(name)"," , 'expected ' + this.inspect + ' to have own property ' + inspect(name)"," , 'expected ' + this.inspect + ' to not have own property ' + inspect(name));"," return this;","};","","/**"," * # .length(val)"," *"," * Assert that object has expected length."," *"," * expect([1,2,3]).to.have.length(3);"," * expect('foobar').to.have.length(6);"," *"," * @name length"," * @alias lengthOf"," * @param {Number} length"," * @api public"," */","","Assertion.prototype.length = function (n) {"," new Assertion(this.obj).to.have.property('length');"," var len = this.obj.length;",""," this.assert("," len == n"," , 'expected ' + this.inspect + ' to have a length of ' + n + ' but got ' + len"," , 'expected ' + this.inspect + ' to not have a length of ' + len);",""," return this;","};","","/**"," * # .match(regexp)"," *"," * Assert that matches regular expression."," *"," * expect('foobar').to.match(/^foo/);"," *"," * @name match"," * @param {RegExp} RegularExpression"," * @api public"," */","","Assertion.prototype.match = function (re) {"," this.assert("," re.exec(this.obj)"," , 'expected ' + this.inspect + ' to match ' + re"," , 'expected ' + this.inspect + ' not to match ' + re);",""," return this;","};","","/**"," * # .include(obj)"," *"," * Assert the inclusion of an object in an Array or substring in string."," *"," * expect([1,2,3]).to.include(2);"," *"," * @name include"," * @param {Object|String|Number} obj"," * @api public"," */","","Assertion.prototype.include = function (obj) {"," this.assert("," ~this.obj.indexOf(obj)"," , 'expected ' + this.inspect + ' to include ' + inspect(obj)"," , 'expected ' + this.inspect + ' to not include ' + inspect(obj));",""," return this;","};","","/**"," * # .string(string)"," *"," * Assert inclusion of string in string."," *"," * expect('foobar').to.have.string('bar');"," *"," * @name string"," * @param {String} string"," * @api public"," */","","Assertion.prototype.string = function (str) {"," new Assertion(this.obj).is.a('string');",""," this.assert("," ~this.obj.indexOf(str)"," , 'expected ' + this.inspect + ' to contain ' + inspect(str)"," , 'expected ' + this.inspect + ' to not contain ' + inspect(str));",""," return this;","};","","","","/**"," * # contain"," *"," * Toggles the `contain` flag for the `keys` assertion."," *"," * @name contain"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'contain',"," { get: function () {"," this.contains = true;"," return this;"," },"," configurable: true","});","","/**"," * # .keys(key1, [key2], [...])"," *"," * Assert exact keys or the inclusing of keys using the `contain` modifier."," *"," * expect({ foo: 1, bar: 2 }).to.have.keys(['foo', 'bar']);"," * expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('foo', 'bar');"," *"," * @name keys"," * @alias key"," * @param {String|Array} Keys"," * @api public"," */","","Assertion.prototype.keys = function(keys) {"," var str"," , ok = true;",""," keys = keys instanceof Array"," ? keys"," : Array.prototype.slice.call(arguments);",""," if (!keys.length) throw new Error('keys required');",""," var actual = Object.keys(this.obj)"," , len = keys.length;",""," // Inclusion"," ok = keys.every(function(key){"," return ~actual.indexOf(key);"," });",""," // Strict"," if (!this.negate && !this.contains) {"," ok = ok && keys.length == actual.length;"," }",""," // Key string"," if (len > 1) {"," keys = keys.map(function(key){"," return inspect(key);"," });"," var last = keys.pop();"," str = keys.join(', ') + ', and ' + last;"," } else {"," str = inspect(keys[0]);"," }",""," // Form"," str = (len > 1 ? 'keys ' : 'key ') + str;",""," // Have / include"," str = (this.contains ? 'contain ' : 'have ') + str;",""," // Assertion"," this.assert("," ok"," , 'expected ' + this.inspect + ' to ' + str"," , 'expected ' + this.inspect + ' to not ' + str);",""," return this;","}","","/**"," * # .throw(constructor)"," *"," * Assert that a function will throw a specific type of error."," *"," * var fn = function () { throw new ReferenceError(''); }"," * expect(fn).to.throw(ReferenceError);"," *"," * @name throw"," * @alias throws"," * @alias Throw"," * @param {ErrorConstructor} constructor"," * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types"," * @api public"," */","","Assertion.prototype.throw = function (constructor) {"," new Assertion(this.obj).is.a('function');",""," var thrown = false;",""," try {"," this.obj();"," } catch (err) {"," if (constructor && 'function' === typeof constructor && constructor.constructor != RegExp) {"," this.assert("," err instanceof constructor && err.name == constructor.name"," , 'expected ' + this.inspect + ' to throw ' + constructor.name + ' but a ' + err.name + ' was thrown'"," , 'expected ' + this.inspect + ' to not throw ' + constructor.name );"," return this;"," } else if (constructor && constructor instanceof RegExp) {"," this.assert("," constructor.exec(err.message)"," , 'expected ' + this.inspect + ' to throw error matching ' + constructor + ' but got ' + inspect(err.message)"," , 'expected ' + this.inspect + ' to throw error not matching ' + constructor);"," return this;"," } else {"," thrown = true;"," }"," }",""," var name = (constructor ? constructor.name : 'an error');",""," this.assert("," thrown === true"," , 'expected ' + this.inspect + ' to throw ' + name"," , 'expected ' + this.inspect + ' to not throw ' + name);",""," return this;","};","","/**"," * # .respondTo(method)"," *"," * Assert that object/class will respond to a method."," *"," * expect(Klass).to.respondTo('bar');"," * expect(obj).to.respondTo('bar');"," *"," * @name respondTo"," * @param {String} method"," * @api public"," */","","Assertion.prototype.respondTo = function (method) {"," var context = ('function' === typeof this.obj)"," ? this.obj.prototype[method]"," : this.obj[method];",""," this.assert("," 'function' === typeof context"," , 'expected ' + this.inspect + ' to respond to ' + inspect(method)"," , 'expected ' + this.inspect + ' to not respond to ' + inspect(method));",""," return this;","};","","/**"," * # .satisfy(method)"," *"," * Assert that passes a truth test."," *"," * expect(1).to.satisfy(function(num) { return num > 0; });"," *"," * @name satisfy"," * @param {Function} matcher"," * @api public"," */","","Assertion.prototype.satisfy = function (matcher) {"," this.assert("," matcher(this.obj)"," , 'expected ' + this.inspect + ' to satisfy ' + inspect(matcher)"," , 'expected ' + this.inspect + ' to not satisfy' + inspect(matcher));",""," return this;","};","","/**"," * # .closeTo(expected, delta)"," *"," * Assert that actual is equal to +/- delta."," *"," * expect(1.5).to.be.closeTo(1, 0.5);"," *"," * @name closeTo"," * @param {Number} expected"," * @param {Number} delta"," * @api public"," */","","Assertion.prototype.closeTo = function (expected, delta) {"," this.assert("," (this.obj - delta === expected) || (this.obj + delta === expected)"," , 'expected ' + this.inspect + ' to be close to ' + expected + ' +/- ' + delta"," , 'expected ' + this.inspect + ' not to be close to ' + expected + ' +/- ' + delta);",""," return this;","};","","/*!"," * Aliases."," */","","(function alias(name, as){"," Assertion.prototype[as] = Assertion.prototype[name];"," return alias;","})","('length', 'lengthOf')","('keys', 'key')","('ownProperty', 'haveOwnProperty')","('above', 'greaterThan')","('below', 'lessThan')","('throw', 'throws')","('throw', 'Throw') // for troublesome browsers","('instanceof', 'instanceOf');"]; |
@@ -30,3 +30,3 @@ /* automatically generated by JSCoverage - do not edit */ | ||
_$jscoverage['chai.js'][10]++; | ||
exports.version = "0.4.0"; | ||
exports.version = "0.4.1"; | ||
_$jscoverage['chai.js'][12]++; | ||
@@ -67,2 +67,2 @@ exports.Assertion = require("./assertion"); | ||
exports.use(assert); | ||
_$jscoverage['chai.js'].source = ["/*!"," * chai"," * Copyright(c) 2011-2012 Jake Luer <jake@alogicalparadox.com>"," * MIT Licensed"," */","","var used = [];","var exports = module.exports = {};","","exports.version = '0.4.0';","","exports.Assertion = require('./assertion');","exports.AssertionError = require('./error');","","exports.inspect = require('./utils/inspect');","","exports.use = function (fn) {"," if (!~used.indexOf(fn)) {"," fn(this);"," used.push(fn);"," }",""," return this;","};","","exports.fail = function (actual, expected, message, operator, stackStartFunction) {"," throw new exports.AssertionError({"," message: message,"," actual: actual,"," expected: expected,"," operator: operator,"," stackStartFunction: stackStartFunction"," });","};","","var expect = require('./interface/expect');","exports.use(expect);","","var should = require('./interface/should');","exports.use(should);","","var assert = require('./interface/assert');","exports.use(assert);"]; | ||
_$jscoverage['chai.js'].source = ["/*!"," * chai"," * Copyright(c) 2011-2012 Jake Luer <jake@alogicalparadox.com>"," * MIT Licensed"," */","","var used = [];","var exports = module.exports = {};","","exports.version = '0.4.1';","","exports.Assertion = require('./assertion');","exports.AssertionError = require('./error');","","exports.inspect = require('./utils/inspect');","","exports.use = function (fn) {"," if (!~used.indexOf(fn)) {"," fn(this);"," used.push(fn);"," }",""," return this;","};","","exports.fail = function (actual, expected, message, operator, stackStartFunction) {"," throw new exports.AssertionError({"," message: message,"," actual: actual,"," expected: expected,"," operator: operator,"," stackStartFunction: stackStartFunction"," });","};","","var expect = require('./interface/expect');","exports.use(expect);","","var should = require('./interface/should');","exports.use(should);","","var assert = require('./interface/assert');","exports.use(assert);"]; |
@@ -50,2 +50,3 @@ /*! | ||
, eql = require('./utils/eql') | ||
, toString = Object.prototype.toString | ||
, inspect = require('./utils/inspect'); | ||
@@ -76,2 +77,3 @@ | ||
* ## Assertion.includeStack | ||
* , toString = Object.prototype.toString | ||
* | ||
@@ -540,4 +542,6 @@ * User configurable property, influences whether stack trace | ||
Assertion.prototype.a = function (type) { | ||
var klass = type.charAt(0).toUpperCase() + type.slice(1); | ||
this.assert( | ||
type == typeof this.obj | ||
'[object ' + klass + ']' === toString.call(this.obj) | ||
, 'expected ' + this.inspect + ' to be a ' + type | ||
@@ -544,0 +548,0 @@ , 'expected ' + this.inspect + ' not to be a ' + type); |
@@ -10,3 +10,3 @@ /*! | ||
exports.version = '0.4.0'; | ||
exports.version = '0.4.1'; | ||
@@ -13,0 +13,0 @@ exports.Assertion = require('./assertion'); |
@@ -6,3 +6,3 @@ { | ||
"keywords": [ "test", "assertion", "assert", "testing" ], | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"repository": { | ||
@@ -9,0 +9,0 @@ "type": "git", |
@@ -98,2 +98,10 @@ /*! | ||
expect(5).to.be.a('number'); | ||
expect(new Number(1)).to.be.a('number'); | ||
expect(Number(1)).to.be.a('number'); | ||
expect(true).to.be.a('boolean'); | ||
expect(new Array()).to.be.a('array'); | ||
expect(new Object()).to.be.a('object'); | ||
expect({}).to.be.a('object'); | ||
expect([]).to.be.a('array'); | ||
expect(function() {}).to.be.a('function'); | ||
@@ -100,0 +108,0 @@ err(function(){ |
@@ -105,3 +105,13 @@ /** | ||
(5).should.be.a('number'); | ||
(new Number(1)).should.be.a('number'); | ||
Number(1).should.be.a('number'); | ||
(true).should.be.a('boolean'); | ||
(new Array()).should.be.a('array'); | ||
(new Object()).should.be.a('object'); | ||
({}).should.be.a('object'); | ||
([]).should.be.a('array'); | ||
(function() {}).should.be.a('function'); | ||
(5).should.be.a('number'); | ||
err(function(){ | ||
@@ -108,0 +118,0 @@ (5).should.not.be.a('number'); |
Sorry, the diff of this file is not supported yet
490981
6363