source: Dev/trunk/node_modules/should/should.js @ 484

Last change on this file since 484 was 484, checked in by hendrikvanantwerpen, 11 years ago

Commit node_modules, to make checkouts and builds more deterministic.

File size: 63.0 KB
Line 
1!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.should=e():"undefined"!=typeof global?global.should=e():"undefined"!=typeof self&&(self.should=e())}(function(){var define,module,exports;
2return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
3// Taken from node's assert module, because it sucks
4// and exposes next to nothing useful.
5var util = require('./util');
6
7module.exports = _deepEqual;
8
9var pSlice = Array.prototype.slice;
10
11function _deepEqual(actual, expected) {
12  // 7.1. All identical values are equivalent, as determined by ===.
13  if (actual === expected) {
14    return true;
15
16  } else if (util.isBuffer(actual) && util.isBuffer(expected)) {
17    if (actual.length != expected.length) return false;
18
19    for (var i = 0; i < actual.length; i++) {
20      if (actual[i] !== expected[i]) return false;
21    }
22
23    return true;
24
25  // 7.2. If the expected value is a Date object, the actual value is
26  // equivalent if it is also a Date object that refers to the same time.
27  } else if (util.isDate(actual) && util.isDate(expected)) {
28    return actual.getTime() === expected.getTime();
29
30  // 7.3 If the expected value is a RegExp object, the actual value is
31  // equivalent if it is also a RegExp object with the same source and
32  // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
33  } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
34    return actual.source === expected.source &&
35           actual.global === expected.global &&
36           actual.multiline === expected.multiline &&
37           actual.lastIndex === expected.lastIndex &&
38           actual.ignoreCase === expected.ignoreCase;
39
40  // 7.4. Other pairs that do not both pass typeof value == 'object',
41  // equivalence is determined by ==.
42  } else if (!util.isObject(actual) && !util.isObject(expected)) {
43    return actual == expected;
44
45  // 7.5 For all other Object pairs, including Array objects, equivalence is
46  // determined by having the same number of owned properties (as verified
47  // with Object.prototype.hasOwnProperty.call), the same set of keys
48  // (although not necessarily the same order), equivalent values for every
49  // corresponding key, and an identical 'prototype' property. Note: this
50  // accounts for both named and indexed properties on Arrays.
51  } else {
52    return objEquiv(actual, expected);
53  }
54}
55
56
57function objEquiv (a, b) {
58  if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b))
59    return false;
60  // an identical 'prototype' property.
61  if (a.prototype !== b.prototype) return false;
62  //~~~I've managed to break Object.keys through screwy arguments passing.
63  //   Converting to array solves the problem.
64  if (util.isArguments(a)) {
65    if (!util.isArguments(b)) {
66      return false;
67    }
68    a = pSlice.call(a);
69    b = pSlice.call(b);
70    return _deepEqual(a, b);
71  }
72  try{
73    var ka = Object.keys(a),
74      kb = Object.keys(b),
75      key, i;
76  } catch (e) {//happens when one is a string literal and the other isn't
77    return false;
78  }
79  // having the same number of owned properties (keys incorporates
80  // hasOwnProperty)
81  if (ka.length != kb.length)
82    return false;
83  //the same set of keys (although not necessarily the same order),
84  ka.sort();
85  kb.sort();
86  //~~~cheap key test
87  for (i = ka.length - 1; i >= 0; i--) {
88    if (ka[i] != kb[i])
89      return false;
90  }
91  //equivalent values for every corresponding key, and
92  //~~~possibly expensive deep test
93  for (i = ka.length - 1; i >= 0; i--) {
94    key = ka[i];
95    if (!_deepEqual(a[key], b[key])) return false;
96  }
97  return true;
98}
99
100},{"./util":4}],2:[function(require,module,exports){
101//copy of node http module status codes
102//https://github.com/joyent/node/blob/master/lib/_http_server.js
103
104var STATUS_CODES = exports.STATUS_CODES = {
105  100 : 'Continue',
106  101 : 'Switching Protocols',
107  102 : 'Processing',                 // RFC 2518, obsoleted by RFC 4918
108  200 : 'OK',
109  201 : 'Created',
110  202 : 'Accepted',
111  203 : 'Non-Authoritative Information',
112  204 : 'No Content',
113  205 : 'Reset Content',
114  206 : 'Partial Content',
115  207 : 'Multi-Status',               // RFC 4918
116  300 : 'Multiple Choices',
117  301 : 'Moved Permanently',
118  302 : 'Moved Temporarily',
119  303 : 'See Other',
120  304 : 'Not Modified',
121  305 : 'Use Proxy',
122  307 : 'Temporary Redirect',
123  400 : 'Bad Request',
124  401 : 'Unauthorized',
125  402 : 'Payment Required',
126  403 : 'Forbidden',
127  404 : 'Not Found',
128  405 : 'Method Not Allowed',
129  406 : 'Not Acceptable',
130  407 : 'Proxy Authentication Required',
131  408 : 'Request Time-out',
132  409 : 'Conflict',
133  410 : 'Gone',
134  411 : 'Length Required',
135  412 : 'Precondition Failed',
136  413 : 'Request Entity Too Large',
137  414 : 'Request-URI Too Large',
138  415 : 'Unsupported Media Type',
139  416 : 'Requested Range Not Satisfiable',
140  417 : 'Expectation Failed',
141  418 : 'I\'m a teapot',              // RFC 2324
142  422 : 'Unprocessable Entity',       // RFC 4918
143  423 : 'Locked',                     // RFC 4918
144  424 : 'Failed Dependency',          // RFC 4918
145  425 : 'Unordered Collection',       // RFC 4918
146  426 : 'Upgrade Required',           // RFC 2817
147  428 : 'Precondition Required',      // RFC 6585
148  429 : 'Too Many Requests',          // RFC 6585
149  431 : 'Request Header Fields Too Large',// RFC 6585
150  500 : 'Internal Server Error',
151  501 : 'Not Implemented',
152  502 : 'Bad Gateway',
153  503 : 'Service Unavailable',
154  504 : 'Gateway Time-out',
155  505 : 'HTTP Version Not Supported',
156  506 : 'Variant Also Negotiates',    // RFC 2295
157  507 : 'Insufficient Storage',       // RFC 4918
158  509 : 'Bandwidth Limit Exceeded',
159  510 : 'Not Extended',               // RFC 2774
160  511 : 'Network Authentication Required' // RFC 6585
161};
162
163module.exports.STATUS_CODES = STATUS_CODES;
164},{}],3:[function(require,module,exports){
165/*!
166 * Should
167 * Copyright(c) 2010-2012 TJ Holowaychuk <tj@vision-media.ca>
168 * MIT Licensed
169 */
170
171/**
172 * Module dependencies.
173 */
174
175var util = require('./util')
176  , assert = require('assert')
177  , AssertionError = assert.AssertionError
178  , statusCodes = require('./http').STATUS_CODES
179  , eql = require('./eql')
180  , inspect = require('util').inspect;
181
182/**
183 * Our function should
184 * @param obj
185 * @returns {Assertion}
186 */
187var should = function(obj) {
188  return new Assertion(util.isWrapperType(obj) ? obj.valueOf(): obj);
189};
190
191should.inspect = function(obj, opts) {
192  if(util.isDate(obj) && typeof obj.inspect !== 'function') obj = obj.toISOString();
193  return inspect(obj, opts);
194};
195
196/**
197 * Expose assert to should
198 *
199 * This allows you to do things like below
200 * without require()ing the assert module.
201 *
202 *    should.equal(foo.bar, undefined);
203 *
204 */
205util.merge(should, assert);
206
207
208/**
209 * Assert _obj_ exists, with optional message.
210 *
211 * @param {*} obj
212 * @param {String} [msg]
213 * @api public
214 */
215should.exist = should.exists = function(obj, msg) {
216  if(null == obj) {
217    throw new AssertionError({
218      message: msg || ('expected ' + should.inspect(obj) + ' to exist')
219      , stackStartFunction: should.exist
220    });
221  }
222};
223
224/**
225 * Asserts _obj_ does not exist, with optional message.
226 *
227 * @param {*} obj
228 * @param {String} [msg]
229 * @api public
230 */
231
232should.not = {};
233should.not.exist = should.not.exists = function(obj, msg){
234  if (null != obj) {
235    throw new AssertionError({
236      message: msg || ('expected ' + should.inspect(obj) + ' to not exist')
237      , stackStartFunction: should.not.exist
238    });
239  }
240};
241
242/**
243 * Expose should to external world.
244 */
245exports = module.exports = should;
246
247
248/**
249 * Expose api via `Object#should`.
250 *
251 * @api public
252 */
253
254Object.defineProperty(Object.prototype, 'should', {
255  set: function(){},
256  get: function(){
257    return should(this);
258  },
259  configurable: true
260});
261
262/**
263 * Initialize a new `Assertion` with the given _obj_.
264 *
265 * @param {*} obj
266 * @api private
267 */
268
269var Assertion = should.Assertion = function Assertion(obj) {
270  this.obj = obj;
271};
272
273var hasOwnProperty = Object.prototype.hasOwnProperty;
274
275/**
276 * Prototype.
277 */
278
279Assertion.prototype = {
280
281  /**
282   * Assert _expr_ with the given _msg_ and _negatedMsg_.
283   *
284   * @param {Boolean} expr
285   * @param {function} msg
286   * @param {function} negatedMsg
287   * @param {Object} [expected]
288   * @param {Boolean} [showDiff]
289   * @param {String} [description]
290   * @api private
291   */
292
293  assert: function(expr, msg, negatedMsg, expected, showDiff, description){
294    msg = this.negate ? negatedMsg : msg
295
296    var ok = this.negate ? !expr : expr
297      , obj = this.obj;
298
299    if (ok) return;
300
301    var err = new AssertionError({
302        message: msg.call(this)
303      , actual: obj
304      , expected: expected
305      , stackStartFunction: this.assert
306      , negated: this.negate
307    });
308
309    err.showDiff = showDiff;
310    err.description = description
311
312    throw err;
313  },
314
315  /**
316   * Dummy getter.
317   *
318   * @api public
319   */
320
321  get an() {
322    return this;
323  },
324
325  /**
326   * Dummy getter.
327   *
328   * @api public
329   */
330
331  get of() {
332    return this;
333  },
334
335  /**
336   * Dummy getter.
337   *
338   * @api public
339   */
340
341  get a() {
342    return this;
343  },
344
345  /**
346   * Dummy getter.
347   *
348   * @api public
349   */
350
351  get and() {
352    return this;
353  },
354
355  /**
356   * Dummy getter.
357   *
358   * @api public
359   */
360
361  get be() {
362    return this;
363  },
364
365  /**
366   * Dummy getter.
367   *
368   * @api public
369   */
370
371  get have() {
372    return this;
373  },
374
375  /**
376   * Dummy getter.
377   *
378   * @api public
379   */
380
381  get with() {
382    return this;
383  },
384
385  /**
386   * Negation modifier.
387   *
388   * @api public
389   */
390
391  get not() {
392    this.negate = true;
393    return this;
394  },
395
396  /**
397   * Get object inspection string.
398   *
399   * @return {String}
400   * @api private
401   */
402
403  get inspect() {
404    return should.inspect(this.obj);
405  },
406
407  /**
408   * Assert instanceof `Arguments`.
409   *
410   * @api public
411   */
412
413  get arguments() {
414    this.assert(
415        util.isArguments(this.obj)
416      , function(){ return 'expected ' + this.inspect + ' to be arguments' }
417      , function(){ return 'expected ' + this.inspect + ' to not be arguments' });
418    return this;
419  },
420
421  /**
422   * Assert that object is empty.
423   *
424   * @api public
425   */
426
427  get empty() {
428    var length = this.obj.length;
429
430    if(util.isString(this.obj) || Array.isArray(this.obj) || util.isArguments(this.obj)) {
431      this.assert(
432        0 === length
433        , function(){ return 'expected ' + this.inspect + ' to be empty' }
434        , function(){ return 'expected ' + this.inspect + ' not to be empty' });
435    } else {
436      var ok = true;
437      for (var prop in this.obj) {
438        if(hasOwnProperty.call(this.obj, prop)) {
439          ok = false;
440          break;
441        }
442      }
443
444      this.assert(
445        ok
446        , function(){ return 'expected ' + this.inspect + ' to be empty' }
447        , function(){ return 'expected ' + this.inspect + ' not to be empty' });
448
449    }
450    return this;
451  },
452
453  /**
454   * Assert ok.
455   *
456   * @api public
457   */
458
459  get ok() {
460    this.assert(
461        this.obj
462      , function(){ return 'expected ' + this.inspect + ' to be truthy' }
463      , function(){ return 'expected ' + this.inspect + ' to be falsey' });
464    return this;
465  },
466
467  /**
468   * Assert true.
469   *
470   * @api public
471   */
472
473  get true() {
474    this.assert(
475        true === this.obj
476      , function(){ return 'expected ' + this.inspect + ' to be true' }
477      , function(){ return 'expected ' + this.inspect + ' not to be true' });
478    return this;
479  },
480
481  /**
482   * Assert false.
483   *
484   * @api public
485   */
486
487  get false() {
488    this.assert(
489        false === this.obj
490      , function(){ return 'expected ' + this.inspect + ' to be false' }
491      , function(){ return 'expected ' + this.inspect + ' not to be false' });
492    return this;
493  },
494
495  /**
496   * Assert NaN.
497   *
498   * @api public
499   */
500
501  get NaN() {
502    this.assert(
503        util.isNumber(this.obj) && isNaN(this.obj)
504      , function(){ return 'expected ' + this.inspect + ' to be NaN' }
505      , function(){ return 'expected ' + this.inspect + ' not to be NaN' });
506    return this;
507  },
508
509  /**
510   * Assert Infinity.
511   *
512   * @api public
513   */
514
515  get Infinity() {
516    this.assert(
517      util.isNumber(this.obj) && !isNaN(this.obj) && !isFinite(this.obj)
518      , function(){ return 'expected ' + this.inspect + ' to be Infinity' }
519      , function(){ return 'expected ' + this.inspect + ' not to be Infinity' });
520    return this;
521  },
522
523  /**
524   * Assert equal.
525   *
526   * @param {*} val
527   * @param {String} description
528   * @api public
529   */
530
531  eql: function(val, description){
532    this.assert(
533        eql(val, this.obj)
534      , function(){ return 'expected ' + this.inspect + ' to equal ' + should.inspect(val) + (description ? " | " + description : "") }
535      , function(){ return 'expected ' + this.inspect + ' to not equal ' + should.inspect(val) + (description ? " | " + description : "") }
536      , val
537      , true
538      , description);
539    return this;
540  },
541
542  /**
543   * Assert strict equal.
544   *
545   * @param {*} val
546   * @param {String} description
547   * @api public
548   */
549
550  equal: function(val, description){
551    this.assert(
552        val === this.obj
553      , function(){ return 'expected ' + this.inspect + ' to equal ' + should.inspect(val) + (description ? " | " + description : "") }
554      , function(){ return 'expected ' + this.inspect + ' to not equal ' + should.inspect(val) + (description ? " | " + description : "") }
555      , val
556      , void 0
557      , description);
558    return this;
559  },
560
561  /**
562   * Assert within start to finish (inclusive).
563   *
564   * @param {Number} start
565   * @param {Number} finish
566   * @param {String} description
567   * @api public
568   */
569
570  within: function(start, finish, description){
571    var range = start + '..' + finish;
572    this.assert(
573        this.obj >= start && this.obj <= finish
574      , function(){ return 'expected ' + this.inspect + ' to be within ' + range + (description ? " | " + description : "") }
575      , function(){ return 'expected ' + this.inspect + ' to not be within ' + range + (description ? " | " + description : "") }
576      , void 0
577      , void 0
578      , description);
579    return this;
580  },
581
582  /**
583   * Assert within value +- delta (inclusive).
584   *
585   * @param {Number} value
586   * @param {Number} delta
587   * @param {String} description
588   * @api public
589   */
590
591  approximately: function(value, delta, description) {
592    this.assert(
593      Math.abs(this.obj - value) <= delta
594      , function(){ return 'expected ' + this.inspect + ' to be approximately ' + value + " +- " + delta + (description ? " | " + description : "") }
595      , function(){ return 'expected ' + this.inspect + ' to not be approximately ' + value + " +- " + delta + (description ? " | " + description : "") }
596      , void 0
597      , void 0
598      , description);
599    return this;
600  },
601
602  /**
603   * Assert typeof.
604   *
605   * @param {*} type
606   * @param {String} description
607   * @api public
608   */
609  type: function(type, description){
610    this.assert(
611        type == typeof this.obj
612      , function(){ return 'expected ' + this.inspect + ' to have type ' + type + (description ? " | " + description : "") }
613      , function(){ return 'expected ' + this.inspect + ' not to have type ' + type  + (description ? " | " + description : "") }
614      , void 0
615      , void 0
616      , description);
617    return this;
618  },
619
620  /**
621   * Assert instanceof.
622   *
623   * @param {Function} constructor
624   * @param {String} description
625   * @api public
626   */
627
628  instanceof: function(constructor, description){
629    var name = constructor.name;
630    this.assert(
631        this.obj instanceof constructor
632      , function(){ return 'expected ' + this.inspect + ' to be an instance of ' + name + (description ? " | " + description : "") }
633      , function(){ return 'expected ' + this.inspect + ' not to be an instance of ' + name + (description ? " | " + description : "") }
634      , void 0
635      , void 0
636      , description);
637    return this;
638  },
639
640  /**
641   * Assert if given object is a function.
642   */
643  get Function(){
644    this.assert(
645      util.isFunction(this.obj)
646      , function(){ return 'expected ' + this.inspect + ' to be a function' }
647      , function(){ return 'expected ' + this.inspect + ' not to be a function' });
648    return this;
649  },
650
651  /**
652   * Assert given object is an object.
653   */
654  get Object(){
655    this.assert(
656      util.isObject(this.obj) && !Array.isArray(this.obj)
657      , function(){ return 'expected ' + this.inspect + ' to be an object' }
658      , function(){ return 'expected ' + this.inspect + ' not to be an object' });
659    return this;
660  },
661
662  /**
663   * Assert given object is a string
664   */
665  get String(){
666    this.assert(
667      util.isString(this.obj)
668      , function(){ return 'expected ' + this.inspect + ' to be a string' }
669      , function(){ return 'expected ' + this.inspect + ' not to be a string' });
670    return this;
671  },
672
673  /**
674   * Assert given object is an array
675   */
676  get Array(){
677    this.assert(
678      Array.isArray(this.obj)
679      , function(){ return 'expected ' + this.inspect + ' to be an array' }
680      , function(){ return 'expected ' + this.inspect + ' not to be an array' });
681    return this;
682  },
683
684  /**
685   * Assert given object is a number. NaN and Infinity are not numbers.
686   */
687  get Number(){
688    this.assert(
689      util.isNumber(this.obj) && isFinite(this.obj) && !isNaN(this.obj)
690      , function(){ return 'expected ' + this.inspect + ' to be a number' }
691      , function(){ return 'expected ' + this.inspect + ' not to be a number' });
692    return this;
693  },
694
695  /**
696   * Assert given object is a boolean
697   */
698  get Boolean(){
699    this.assert(
700      util.isBoolean(this.obj)
701      , function(){ return 'expected ' + this.inspect + ' to be a boolean' }
702      , function(){ return 'expected ' + this.inspect + ' not to be a boolean' });
703    return this;
704  },
705
706  /**
707   * Assert given object is an error
708   */
709  get Error() {
710    this.assert(
711      util.isError(this.obj)
712      , function(){ return 'expected ' + this.inspect + ' to be an error' }
713      , function(){ return 'expected ' + this.inspect + ' not to be an error' });
714    return this;
715  },
716  /**
717   * Assert numeric value above _n_.
718   *
719   * @param {Number} n
720   * @param {String} description
721   * @api public
722   */
723
724  above: function(n, description){
725    this.assert(
726        this.obj > n
727      , function(){ return 'expected ' + this.inspect + ' to be above ' + n + (description ? " | " + description : "") }
728      , function(){ return 'expected ' + this.inspect + ' to be below ' + n + (description ? " | " + description : "") }
729      , void 0
730      , void 0
731      , description);
732    return this;
733  },
734
735  /**
736   * Assert numeric value below _n_.
737   *
738   * @param {Number} n
739   * @param {String} description
740   * @api public
741   */
742
743  below: function(n, description){
744    this.assert(
745        this.obj < n
746      , function(){ return 'expected ' + this.inspect + ' to be below ' + n + (description ? " | " + description : "") }
747      , function(){ return 'expected ' + this.inspect + ' to be above ' + n + (description ? " | " + description : "") }
748      , void 0
749      , void 0
750      , description);
751    return this;
752  },
753
754  /**
755   * Assert string value matches _regexp_.
756   *
757   * @param {RegExp} regexp
758   * @param {String} description
759   * @api public
760   */
761
762  match: function(regexp, description){
763    this.assert(
764        regexp.exec(this.obj)
765      , function(){ return 'expected ' + this.inspect + ' to match ' + regexp + (description ? " | " + description : "") }
766      , function(){ return 'expected ' + this.inspect + ' not to match ' + regexp + (description ? " | " + description : "") }
767      , void 0
768      , void 0
769      , description);
770    return this;
771  },
772
773  /**
774   * Assert property "length" exists and has value of _n_.
775   *
776   * @param {Number} n
777   * @param {String} description
778   * @api public
779   */
780
781  length: function(n, description){
782    this.obj.should.have.property('length');
783    var len = this.obj.length;
784    this.assert(
785        n == len
786      , function(){ return 'expected ' + this.inspect + ' to have a length of ' + n + ' but got ' + len + (description ? " | " + description : "") }
787      , function(){ return 'expected ' + this.inspect + ' to not have a length of ' + len + (description ? " | " + description : "") }
788      , void 0
789      , void 0
790      , description);
791    return this;
792  },
793
794  /**
795   * Assert property _name_ exists, with optional _val_.
796   *
797   * @param {String} name
798   * @param {*} [val]
799   * @param {String} description
800   * @api public
801   */
802
803  property: function(name, val, description){
804    if (this.negate && undefined !== val) {
805      if (undefined === this.obj[name]) {
806        throw new Error(this.inspect + ' has no property ' + should.inspect(name) + (description ? " | " + description : ""));
807      }
808    } else {
809      this.assert(
810          undefined !== this.obj[name]
811        , function(){ return 'expected ' + this.inspect + ' to have a property ' + should.inspect(name) + (description ? " | " + description : "") }
812        , function(){ return 'expected ' + this.inspect + ' to not have a property ' + should.inspect(name) + (description ? " | " + description : "") }
813        , void 0
814        , void 0
815        , description);
816    }
817
818    if (undefined !== val) {
819      this.assert(
820          val === this.obj[name]
821        , function(){ return 'expected ' + this.inspect + ' to have a property ' + should.inspect(name)
822          + ' of ' + should.inspect(val) + ', but got ' + should.inspect(this.obj[name]) + (description ? " | " + description : "") }
823        , function(){ return 'expected ' + this.inspect + ' to not have a property ' + should.inspect(name) + ' of ' + should.inspect(val) + (description ? " | " + description : "") }
824        , void 0
825        , void 0
826        , description);
827    }
828
829    this.obj = this.obj[name];
830    return this;
831  },
832  /**
833   * Asset have given properties
834   * @param {Array|String ...} names
835   * @api public
836   */
837  properties: function(names) {
838    var str
839      , ok = true;
840
841    names = names instanceof Array
842      ? names
843      : Array.prototype.slice.call(arguments);
844
845    var len = names.length;
846
847    if (!len) throw new Error('names required');
848
849    // make sure they're all present
850    ok = names.every(function(name){
851      return this.obj[name] !== undefined;
852    }, this);
853
854    // key string
855    if (len > 1) {
856      names = names.map(function(name){
857        return should.inspect(name);
858      });
859      var last = names.pop();
860      str = names.join(', ') + ', and ' + last;
861    } else {
862      str = should.inspect(names[0]);
863    }
864
865    // message
866    str = 'have ' + (len > 1 ? 'properties ' : 'a property ') + str;
867
868    this.assert(
869      ok
870      , function(){ return 'expected ' + this.inspect + ' to ' + str }
871      , function(){ return 'expected ' + this.inspect + ' to not ' + str });
872
873    return this;
874  },
875
876  /**
877   * Assert own property _name_ exists.
878   *
879   * @param {String} name
880   * @param {String} description
881   * @api public
882   */
883
884  ownProperty: function(name, description){
885    this.assert(
886      hasOwnProperty.call(this.obj, name)
887      , function(){ return 'expected ' + this.inspect + ' to have own property ' + should.inspect(name) + (description ? " | " + description : "") }
888      , function(){ return 'expected ' + this.inspect + ' to not have own property ' + should.inspect(name) + (description ? " | " + description : "") }
889      , void 0
890      , void 0
891      , description);
892    this.obj = this.obj[name];
893    return this;
894  },
895
896  /**
897   * Assert that string starts with `str`.
898   * @param {String} str
899   * @param {String} description
900   * @api public
901   */
902
903  startWith: function(str, description) {
904    this.assert(0 === this.obj.indexOf(str)
905    , function() { return 'expected ' + this.inspect + ' to start with ' + should.inspect(str) + (description ? " | " + description : "") }
906    , function() { return 'expected ' + this.inspect + ' to not start with ' + should.inspect(str) + (description ? " | " + description : "") }
907    , void 0
908    , void 0
909    , description);
910    return this;
911  },
912
913  /**
914   * Assert that string ends with `str`.
915   * @param {String} str
916   * @param {String} description
917   * @api public
918   */
919
920  endWith: function(str, description) {
921    this.assert(-1 !== this.obj.indexOf(str, this.obj.length - str.length)
922    , function() { return 'expected ' + this.inspect + ' to end with ' + should.inspect(str) + (description ? " | " + description : "") }
923    , function() { return 'expected ' + this.inspect + ' to not end with ' + should.inspect(str) + (description ? " | " + description : "") }
924    , void 0
925    , void 0
926    , description);
927    return this;
928  },
929
930  /**
931   * Assert that `obj` is present via `.indexOf()` or that `obj` contains some sub-object.
932   *
933   * @param {*} obj
934   * @param {String} description
935   * @api public
936   */
937
938  include: function(obj, description){
939    if (!Array.isArray(this.obj) && !util.isString(this.obj)){
940      var cmp = {};
941      for (var key in obj) cmp[key] = this.obj[key];
942      this.assert(
943          eql(cmp, obj)
944        , function(){ return 'expected ' + this.inspect + ' to include an object equal to ' + should.inspect(obj) + (description ? " | " + description : "") }
945        , function(){ return 'expected ' + this.inspect + ' to not include an object equal to ' + should.inspect(obj) + (description ? " | " + description : "") }
946        , void 0
947        , void 0
948        , description);
949    } else {
950      this.assert(
951          ~this.obj.indexOf(obj)
952        , function(){ return 'expected ' + this.inspect + ' to include ' + should.inspect(obj) + (description ? " | " + description : "") }
953        , function(){ return 'expected ' + this.inspect + ' to not include ' + should.inspect(obj) + (description ? " | " + description : "") }
954        , void 0
955        , void 0
956        , description);
957    }
958    return this;
959  },
960
961  /**
962   * Assert that an object equal to `obj` is present.
963   *
964   * @param {Array} obj
965   * @param {String} description
966   * @api public
967   */
968
969  includeEql: function(obj, description){
970    this.assert(
971      this.obj.some(function(item) { return eql(obj, item); })
972      , function(){ return 'expected ' + this.inspect + ' to include an object equal to ' + should.inspect(obj) + (description ? " | " + description : "") }
973      , function(){ return 'expected ' + this.inspect + ' to not include an object equal to ' + should.inspect(obj) + (description ? " | " + description : "") }
974      , void 0
975      , void 0
976      , description);
977    return this;
978  },
979
980  /**
981   * Assert exact keys or inclusion of keys by using
982   * the `.include` modifier.
983   *
984   * @param {Array|String ...} keys
985   * @api public
986   */
987
988  keys: function(keys){
989    var str
990      , ok = true;
991
992    keys = keys instanceof Array
993      ? keys
994      : Array.prototype.slice.call(arguments);
995
996    if (!keys.length) throw new Error('keys required');
997
998    var actual = Object.keys(this.obj)
999      , len = keys.length;
1000
1001    // make sure they're all present
1002    ok = keys.every(function(key){
1003      return ~actual.indexOf(key);
1004    });
1005
1006    // matching length
1007    ok = ok && keys.length == actual.length;
1008
1009    // key string
1010    if (len > 1) {
1011      keys = keys.map(function(key){
1012        return should.inspect(key);
1013      });
1014      var last = keys.pop();
1015      str = keys.join(', ') + ', and ' + last;
1016    } else {
1017      str = should.inspect(keys[0]);
1018    }
1019
1020    // message
1021    str = 'have ' + (len > 1 ? 'keys ' : 'key ') + str;
1022
1023    this.assert(
1024        ok
1025      , function(){ return 'expected ' + this.inspect + ' to ' + str }
1026      , function(){ return 'expected ' + this.inspect + ' to not ' + str });
1027
1028    return this;
1029  },
1030
1031  /**
1032   * Assert that header `field` has the given `val`.
1033   *
1034   * @param {String} field
1035   * @param {String} val
1036   * @return {Assertion} for chaining
1037   * @api public
1038   */
1039
1040  header: function(field, val){
1041    this.obj.should
1042      .have.property('headers').and
1043      .have.property(field.toLowerCase(), val);
1044    return this;
1045  },
1046
1047  /**
1048   * Assert `.statusCode` of `code`.
1049   *
1050   * @param {Number} code
1051   * @return {Assertion} for chaining
1052   * @api public
1053   */
1054
1055  status:  function(code){
1056    this.obj.should.have.property('statusCode');
1057    var status = this.obj.statusCode;
1058
1059    this.assert(
1060        code == status
1061      , function(){ return 'expected response code of ' + code + ' ' + should.inspect(statusCodes[code])
1062        + ', but got ' + status + ' ' + should.inspect(statusCodes[status]) }
1063      , function(){ return 'expected to not respond with ' + code + ' ' + should.inspect(statusCodes[code]) });
1064
1065    return this;
1066  },
1067
1068  /**
1069   * Assert that this response has content-type: application/json.
1070   *
1071   * @return {Assertion} for chaining
1072   * @api public
1073   */
1074
1075  get json() {
1076    this.obj.should.have.property('headers');
1077    this.obj.headers.should.have.property('content-type');
1078    this.obj.headers['content-type'].should.include('application/json');
1079    return this;
1080  },
1081
1082  /**
1083   * Assert that this response has content-type: text/html.
1084   *
1085   * @return {Assertion} for chaining
1086   * @api public
1087   */
1088
1089  get html() {
1090    this.obj.should.have.property('headers');
1091    this.obj.headers.should.have.property('content-type');
1092    this.obj.headers['content-type'].should.include('text/html');
1093    return this;
1094  },
1095
1096  /**
1097   * Assert that this function will or will not
1098   * throw an exception.
1099   *
1100   * @return {Assertion} for chaining
1101   * @api public
1102   */
1103
1104  throw: function(message){
1105    var fn = this.obj
1106      , err = {}
1107      , errorInfo = ''
1108      , ok = true;
1109
1110    try {
1111      fn();
1112      ok = false;
1113    } catch (e) {
1114      err = e;
1115    }
1116
1117    if (ok) {
1118      if ('string' == typeof message) {
1119        ok = message == err.message;
1120      } else if (message instanceof RegExp) {
1121        ok = message.test(err.message);
1122      } else if ('function' == typeof message) {
1123        ok = err instanceof message;
1124      }
1125
1126      if (message && !ok) {
1127        if ('string' == typeof message) {
1128          errorInfo = " with a message matching '" + message + "', but got '" + err.message + "'";
1129        } else if (message instanceof RegExp) {
1130          errorInfo = " with a message matching " + message + ", but got '" + err.message + "'";
1131        } else if ('function' == typeof message) {
1132          errorInfo = " of type " + message.name + ", but got " + err.constructor.name;
1133        }
1134      }
1135    }
1136
1137    this.assert(
1138        ok
1139      , function(){ return 'expected an exception to be thrown' + errorInfo }
1140      , function(){ return 'expected no exception to be thrown, got "' + err.message + '"' });
1141
1142    return this;
1143  }
1144};
1145
1146/**
1147 * Aliases.
1148 */
1149
1150(function alias(name, as){
1151  Assertion.prototype[as] = Assertion.prototype[name];
1152  return alias;
1153})
1154('instanceof', 'instanceOf')
1155('throw', 'throwError')
1156('length', 'lengthOf')
1157('keys', 'key')
1158('ownProperty', 'haveOwnProperty')
1159('above', 'greaterThan')
1160('below', 'lessThan')
1161('include', 'contain')
1162('equal', 'exactly');
1163
1164
1165},{"./eql":1,"./http":2,"./util":4,"assert":6,"util":7}],4:[function(require,module,exports){
1166/**
1167 * Check if given obj just a primitive type wrapper
1168 * @param {Object} obj
1169 * @returns {boolean}
1170 * @api private
1171 */
1172exports.isWrapperType = function(obj) {
1173    return isNumber(obj) || isString(obj) || isBoolean(obj);
1174}
1175
1176/**
1177 * Merge object b with object a.
1178 *
1179 *     var a = { foo: 'bar' }
1180 *       , b = { bar: 'baz' };
1181 *
1182 *     utils.merge(a, b);
1183 *     // => { foo: 'bar', bar: 'baz' }
1184 *
1185 * @param {Object} a
1186 * @param {Object} b
1187 * @return {Object}
1188 * @api private
1189 */
1190
1191exports.merge = function(a, b){
1192  if (a && b) {
1193    for (var key in b) {
1194      a[key] = b[key];
1195    }
1196  }
1197  return a;
1198};
1199
1200function isNumber(arg) {
1201  return typeof arg === 'number' || arg instanceof Number;
1202}
1203
1204exports.isNumber = isNumber;
1205
1206function isString(arg) {
1207  return typeof arg === 'string' || arg instanceof String;
1208}
1209
1210function isBoolean(arg) {
1211  return typeof arg === 'boolean' || arg instanceof Boolean;
1212}
1213exports.isBoolean = isBoolean;
1214
1215exports.isString = isString;
1216
1217function isBuffer(arg) {
1218  return typeof Buffer !== 'undefined' && arg instanceof Buffer;
1219}
1220
1221exports.isBuffer = isBuffer;
1222
1223function isDate(d) {
1224  return isObject(d) && objectToString(d) === '[object Date]';
1225}
1226
1227exports.isDate = isDate;
1228
1229function objectToString(o) {
1230  return Object.prototype.toString.call(o);
1231}
1232
1233function isObject(arg) {
1234  return typeof arg === 'object' && arg !== null;
1235}
1236
1237exports.isObject = isObject;
1238
1239function isRegExp(re) {
1240  return isObject(re) && objectToString(re) === '[object RegExp]';
1241}
1242
1243exports.isRegExp = isRegExp;
1244
1245function isNullOrUndefined(arg) {
1246  return arg == null;
1247}
1248
1249exports.isNullOrUndefined = isNullOrUndefined;
1250
1251function isArguments(object) {
1252  return objectToString(object) === '[object Arguments]';
1253}
1254
1255exports.isArguments = isArguments;
1256
1257exports.isFunction = function(arg) {
1258  return typeof arg === 'function' || arg instanceof Function;
1259};
1260
1261function isError(e) {
1262  return isObject(e) && objectToString(e) === '[object Error]';
1263}
1264exports.isError = isError;
1265},{}],5:[function(require,module,exports){
1266
1267
1268//
1269// The shims in this file are not fully implemented shims for the ES5
1270// features, but do work for the particular usecases there is in
1271// the other modules.
1272//
1273
1274var toString = Object.prototype.toString;
1275var hasOwnProperty = Object.prototype.hasOwnProperty;
1276
1277// Array.isArray is supported in IE9
1278function isArray(xs) {
1279  return toString.call(xs) === '[object Array]';
1280}
1281exports.isArray = typeof Array.isArray === 'function' ? Array.isArray : isArray;
1282
1283// Array.prototype.indexOf is supported in IE9
1284exports.indexOf = function indexOf(xs, x) {
1285  if (xs.indexOf) return xs.indexOf(x);
1286  for (var i = 0; i < xs.length; i++) {
1287    if (x === xs[i]) return i;
1288  }
1289  return -1;
1290};
1291
1292// Array.prototype.filter is supported in IE9
1293exports.filter = function filter(xs, fn) {
1294  if (xs.filter) return xs.filter(fn);
1295  var res = [];
1296  for (var i = 0; i < xs.length; i++) {
1297    if (fn(xs[i], i, xs)) res.push(xs[i]);
1298  }
1299  return res;
1300};
1301
1302// Array.prototype.forEach is supported in IE9
1303exports.forEach = function forEach(xs, fn, self) {
1304  if (xs.forEach) return xs.forEach(fn, self);
1305  for (var i = 0; i < xs.length; i++) {
1306    fn.call(self, xs[i], i, xs);
1307  }
1308};
1309
1310// Array.prototype.map is supported in IE9
1311exports.map = function map(xs, fn) {
1312  if (xs.map) return xs.map(fn);
1313  var out = new Array(xs.length);
1314  for (var i = 0; i < xs.length; i++) {
1315    out[i] = fn(xs[i], i, xs);
1316  }
1317  return out;
1318};
1319
1320// Array.prototype.reduce is supported in IE9
1321exports.reduce = function reduce(array, callback, opt_initialValue) {
1322  if (array.reduce) return array.reduce(callback, opt_initialValue);
1323  var value, isValueSet = false;
1324
1325  if (2 < arguments.length) {
1326    value = opt_initialValue;
1327    isValueSet = true;
1328  }
1329  for (var i = 0, l = array.length; l > i; ++i) {
1330    if (array.hasOwnProperty(i)) {
1331      if (isValueSet) {
1332        value = callback(value, array[i], i, array);
1333      }
1334      else {
1335        value = array[i];
1336        isValueSet = true;
1337      }
1338    }
1339  }
1340
1341  return value;
1342};
1343
1344// String.prototype.substr - negative index don't work in IE8
1345if ('ab'.substr(-1) !== 'b') {
1346  exports.substr = function (str, start, length) {
1347    // did we get a negative start, calculate how much it is from the beginning of the string
1348    if (start < 0) start = str.length + start;
1349
1350    // call the original function
1351    return str.substr(start, length);
1352  };
1353} else {
1354  exports.substr = function (str, start, length) {
1355    return str.substr(start, length);
1356  };
1357}
1358
1359// String.prototype.trim is supported in IE9
1360exports.trim = function (str) {
1361  if (str.trim) return str.trim();
1362  return str.replace(/^\s+|\s+$/g, '');
1363};
1364
1365// Function.prototype.bind is supported in IE9
1366exports.bind = function () {
1367  var args = Array.prototype.slice.call(arguments);
1368  var fn = args.shift();
1369  if (fn.bind) return fn.bind.apply(fn, args);
1370  var self = args.shift();
1371  return function () {
1372    fn.apply(self, args.concat([Array.prototype.slice.call(arguments)]));
1373  };
1374};
1375
1376// Object.create is supported in IE9
1377function create(prototype, properties) {
1378  var object;
1379  if (prototype === null) {
1380    object = { '__proto__' : null };
1381  }
1382  else {
1383    if (typeof prototype !== 'object') {
1384      throw new TypeError(
1385        'typeof prototype[' + (typeof prototype) + '] != \'object\''
1386      );
1387    }
1388    var Type = function () {};
1389    Type.prototype = prototype;
1390    object = new Type();
1391    object.__proto__ = prototype;
1392  }
1393  if (typeof properties !== 'undefined' && Object.defineProperties) {
1394    Object.defineProperties(object, properties);
1395  }
1396  return object;
1397}
1398exports.create = typeof Object.create === 'function' ? Object.create : create;
1399
1400// Object.keys and Object.getOwnPropertyNames is supported in IE9 however
1401// they do show a description and number property on Error objects
1402function notObject(object) {
1403  return ((typeof object != "object" && typeof object != "function") || object === null);
1404}
1405
1406function keysShim(object) {
1407  if (notObject(object)) {
1408    throw new TypeError("Object.keys called on a non-object");
1409  }
1410
1411  var result = [];
1412  for (var name in object) {
1413    if (hasOwnProperty.call(object, name)) {
1414      result.push(name);
1415    }
1416  }
1417  return result;
1418}
1419
1420// getOwnPropertyNames is almost the same as Object.keys one key feature
1421//  is that it returns hidden properties, since that can't be implemented,
1422//  this feature gets reduced so it just shows the length property on arrays
1423function propertyShim(object) {
1424  if (notObject(object)) {
1425    throw new TypeError("Object.getOwnPropertyNames called on a non-object");
1426  }
1427
1428  var result = keysShim(object);
1429  if (exports.isArray(object) && exports.indexOf(object, 'length') === -1) {
1430    result.push('length');
1431  }
1432  return result;
1433}
1434
1435var keys = typeof Object.keys === 'function' ? Object.keys : keysShim;
1436var getOwnPropertyNames = typeof Object.getOwnPropertyNames === 'function' ?
1437  Object.getOwnPropertyNames : propertyShim;
1438
1439if (new Error().hasOwnProperty('description')) {
1440  var ERROR_PROPERTY_FILTER = function (obj, array) {
1441    if (toString.call(obj) === '[object Error]') {
1442      array = exports.filter(array, function (name) {
1443        return name !== 'description' && name !== 'number' && name !== 'message';
1444      });
1445    }
1446    return array;
1447  };
1448
1449  exports.keys = function (object) {
1450    return ERROR_PROPERTY_FILTER(object, keys(object));
1451  };
1452  exports.getOwnPropertyNames = function (object) {
1453    return ERROR_PROPERTY_FILTER(object, getOwnPropertyNames(object));
1454  };
1455} else {
1456  exports.keys = keys;
1457  exports.getOwnPropertyNames = getOwnPropertyNames;
1458}
1459
1460// Object.getOwnPropertyDescriptor - supported in IE8 but only on dom elements
1461function valueObject(value, key) {
1462  return { value: value[key] };
1463}
1464
1465if (typeof Object.getOwnPropertyDescriptor === 'function') {
1466  try {
1467    Object.getOwnPropertyDescriptor({'a': 1}, 'a');
1468    exports.getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
1469  } catch (e) {
1470    // IE8 dom element issue - use a try catch and default to valueObject
1471    exports.getOwnPropertyDescriptor = function (value, key) {
1472      try {
1473        return Object.getOwnPropertyDescriptor(value, key);
1474      } catch (e) {
1475        return valueObject(value, key);
1476      }
1477    };
1478  }
1479} else {
1480  exports.getOwnPropertyDescriptor = valueObject;
1481}
1482
1483},{}],6:[function(require,module,exports){
1484// Copyright Joyent, Inc. and other Node contributors.
1485//
1486// Permission is hereby granted, free of charge, to any person obtaining a
1487// copy of this software and associated documentation files (the
1488// "Software"), to deal in the Software without restriction, including
1489// without limitation the rights to use, copy, modify, merge, publish,
1490// distribute, sublicense, and/or sell copies of the Software, and to permit
1491// persons to whom the Software is furnished to do so, subject to the
1492// following conditions:
1493//
1494// The above copyright notice and this permission notice shall be included
1495// in all copies or substantial portions of the Software.
1496//
1497// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1498// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1499// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
1500// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
1501// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1502// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
1503// USE OR OTHER DEALINGS IN THE SOFTWARE.
1504
1505// UTILITY
1506var util = require('util');
1507var shims = require('_shims');
1508var pSlice = Array.prototype.slice;
1509
1510// 1. The assert module provides functions that throw
1511// AssertionError's when particular conditions are not met. The
1512// assert module must conform to the following interface.
1513
1514var assert = module.exports = ok;
1515
1516// 2. The AssertionError is defined in assert.
1517// new assert.AssertionError({ message: message,
1518//                             actual: actual,
1519//                             expected: expected })
1520
1521assert.AssertionError = function AssertionError(options) {
1522  this.name = 'AssertionError';
1523  this.actual = options.actual;
1524  this.expected = options.expected;
1525  this.operator = options.operator;
1526  this.message = options.message || getMessage(this);
1527};
1528
1529// assert.AssertionError instanceof Error
1530util.inherits(assert.AssertionError, Error);
1531
1532function replacer(key, value) {
1533  if (util.isUndefined(value)) {
1534    return '' + value;
1535  }
1536  if (util.isNumber(value) && (isNaN(value) || !isFinite(value))) {
1537    return value.toString();
1538  }
1539  if (util.isFunction(value) || util.isRegExp(value)) {
1540    return value.toString();
1541  }
1542  return value;
1543}
1544
1545function truncate(s, n) {
1546  if (util.isString(s)) {
1547    return s.length < n ? s : s.slice(0, n);
1548  } else {
1549    return s;
1550  }
1551}
1552
1553function getMessage(self) {
1554  return truncate(JSON.stringify(self.actual, replacer), 128) + ' ' +
1555         self.operator + ' ' +
1556         truncate(JSON.stringify(self.expected, replacer), 128);
1557}
1558
1559// At present only the three keys mentioned above are used and
1560// understood by the spec. Implementations or sub modules can pass
1561// other keys to the AssertionError's constructor - they will be
1562// ignored.
1563
1564// 3. All of the following functions must throw an AssertionError
1565// when a corresponding condition is not met, with a message that
1566// may be undefined if not provided.  All assertion methods provide
1567// both the actual and expected values to the assertion error for
1568// display purposes.
1569
1570function fail(actual, expected, message, operator, stackStartFunction) {
1571  throw new assert.AssertionError({
1572    message: message,
1573    actual: actual,
1574    expected: expected,
1575    operator: operator,
1576    stackStartFunction: stackStartFunction
1577  });
1578}
1579
1580// EXTENSION! allows for well behaved errors defined elsewhere.
1581assert.fail = fail;
1582
1583// 4. Pure assertion tests whether a value is truthy, as determined
1584// by !!guard.
1585// assert.ok(guard, message_opt);
1586// This statement is equivalent to assert.equal(true, !!guard,
1587// message_opt);. To test strictly for the value true, use
1588// assert.strictEqual(true, guard, message_opt);.
1589
1590function ok(value, message) {
1591  if (!value) fail(value, true, message, '==', assert.ok);
1592}
1593assert.ok = ok;
1594
1595// 5. The equality assertion tests shallow, coercive equality with
1596// ==.
1597// assert.equal(actual, expected, message_opt);
1598
1599assert.equal = function equal(actual, expected, message) {
1600  if (actual != expected) fail(actual, expected, message, '==', assert.equal);
1601};
1602
1603// 6. The non-equality assertion tests for whether two objects are not equal
1604// with != assert.notEqual(actual, expected, message_opt);
1605
1606assert.notEqual = function notEqual(actual, expected, message) {
1607  if (actual == expected) {
1608    fail(actual, expected, message, '!=', assert.notEqual);
1609  }
1610};
1611
1612// 7. The equivalence assertion tests a deep equality relation.
1613// assert.deepEqual(actual, expected, message_opt);
1614
1615assert.deepEqual = function deepEqual(actual, expected, message) {
1616  if (!_deepEqual(actual, expected)) {
1617    fail(actual, expected, message, 'deepEqual', assert.deepEqual);
1618  }
1619};
1620
1621function _deepEqual(actual, expected) {
1622  // 7.1. All identical values are equivalent, as determined by ===.
1623  if (actual === expected) {
1624    return true;
1625
1626  } else if (util.isBuffer(actual) && util.isBuffer(expected)) {
1627    if (actual.length != expected.length) return false;
1628
1629    for (var i = 0; i < actual.length; i++) {
1630      if (actual[i] !== expected[i]) return false;
1631    }
1632
1633    return true;
1634
1635  // 7.2. If the expected value is a Date object, the actual value is
1636  // equivalent if it is also a Date object that refers to the same time.
1637  } else if (util.isDate(actual) && util.isDate(expected)) {
1638    return actual.getTime() === expected.getTime();
1639
1640  // 7.3 If the expected value is a RegExp object, the actual value is
1641  // equivalent if it is also a RegExp object with the same source and
1642  // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
1643  } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
1644    return actual.source === expected.source &&
1645           actual.global === expected.global &&
1646           actual.multiline === expected.multiline &&
1647           actual.lastIndex === expected.lastIndex &&
1648           actual.ignoreCase === expected.ignoreCase;
1649
1650  // 7.4. Other pairs that do not both pass typeof value == 'object',
1651  // equivalence is determined by ==.
1652  } else if (!util.isObject(actual) && !util.isObject(expected)) {
1653    return actual == expected;
1654
1655  // 7.5 For all other Object pairs, including Array objects, equivalence is
1656  // determined by having the same number of owned properties (as verified
1657  // with Object.prototype.hasOwnProperty.call), the same set of keys
1658  // (although not necessarily the same order), equivalent values for every
1659  // corresponding key, and an identical 'prototype' property. Note: this
1660  // accounts for both named and indexed properties on Arrays.
1661  } else {
1662    return objEquiv(actual, expected);
1663  }
1664}
1665
1666function isArguments(object) {
1667  return Object.prototype.toString.call(object) == '[object Arguments]';
1668}
1669
1670function objEquiv(a, b) {
1671  if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b))
1672    return false;
1673  // an identical 'prototype' property.
1674  if (a.prototype !== b.prototype) return false;
1675  //~~~I've managed to break Object.keys through screwy arguments passing.
1676  //   Converting to array solves the problem.
1677  if (isArguments(a)) {
1678    if (!isArguments(b)) {
1679      return false;
1680    }
1681    a = pSlice.call(a);
1682    b = pSlice.call(b);
1683    return _deepEqual(a, b);
1684  }
1685  try {
1686    var ka = shims.keys(a),
1687        kb = shims.keys(b),
1688        key, i;
1689  } catch (e) {//happens when one is a string literal and the other isn't
1690    return false;
1691  }
1692  // having the same number of owned properties (keys incorporates
1693  // hasOwnProperty)
1694  if (ka.length != kb.length)
1695    return false;
1696  //the same set of keys (although not necessarily the same order),
1697  ka.sort();
1698  kb.sort();
1699  //~~~cheap key test
1700  for (i = ka.length - 1; i >= 0; i--) {
1701    if (ka[i] != kb[i])
1702      return false;
1703  }
1704  //equivalent values for every corresponding key, and
1705  //~~~possibly expensive deep test
1706  for (i = ka.length - 1; i >= 0; i--) {
1707    key = ka[i];
1708    if (!_deepEqual(a[key], b[key])) return false;
1709  }
1710  return true;
1711}
1712
1713// 8. The non-equivalence assertion tests for any deep inequality.
1714// assert.notDeepEqual(actual, expected, message_opt);
1715
1716assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
1717  if (_deepEqual(actual, expected)) {
1718    fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
1719  }
1720};
1721
1722// 9. The strict equality assertion tests strict equality, as determined by ===.
1723// assert.strictEqual(actual, expected, message_opt);
1724
1725assert.strictEqual = function strictEqual(actual, expected, message) {
1726  if (actual !== expected) {
1727    fail(actual, expected, message, '===', assert.strictEqual);
1728  }
1729};
1730
1731// 10. The strict non-equality assertion tests for strict inequality, as
1732// determined by !==.  assert.notStrictEqual(actual, expected, message_opt);
1733
1734assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
1735  if (actual === expected) {
1736    fail(actual, expected, message, '!==', assert.notStrictEqual);
1737  }
1738};
1739
1740function expectedException(actual, expected) {
1741  if (!actual || !expected) {
1742    return false;
1743  }
1744
1745  if (Object.prototype.toString.call(expected) == '[object RegExp]') {
1746    return expected.test(actual);
1747  } else if (actual instanceof expected) {
1748    return true;
1749  } else if (expected.call({}, actual) === true) {
1750    return true;
1751  }
1752
1753  return false;
1754}
1755
1756function _throws(shouldThrow, block, expected, message) {
1757  var actual;
1758
1759  if (util.isString(expected)) {
1760    message = expected;
1761    expected = null;
1762  }
1763
1764  try {
1765    block();
1766  } catch (e) {
1767    actual = e;
1768  }
1769
1770  message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
1771            (message ? ' ' + message : '.');
1772
1773  if (shouldThrow && !actual) {
1774    fail(actual, expected, 'Missing expected exception' + message);
1775  }
1776
1777  if (!shouldThrow && expectedException(actual, expected)) {
1778    fail(actual, expected, 'Got unwanted exception' + message);
1779  }
1780
1781  if ((shouldThrow && actual && expected &&
1782      !expectedException(actual, expected)) || (!shouldThrow && actual)) {
1783    throw actual;
1784  }
1785}
1786
1787// 11. Expected to throw an error:
1788// assert.throws(block, Error_opt, message_opt);
1789
1790assert.throws = function(block, /*optional*/error, /*optional*/message) {
1791  _throws.apply(this, [true].concat(pSlice.call(arguments)));
1792};
1793
1794// EXTENSION! This is annoying to write outside this module.
1795assert.doesNotThrow = function(block, /*optional*/message) {
1796  _throws.apply(this, [false].concat(pSlice.call(arguments)));
1797};
1798
1799assert.ifError = function(err) { if (err) {throw err;}};
1800},{"_shims":5,"util":7}],7:[function(require,module,exports){
1801// Copyright Joyent, Inc. and other Node contributors.
1802//
1803// Permission is hereby granted, free of charge, to any person obtaining a
1804// copy of this software and associated documentation files (the
1805// "Software"), to deal in the Software without restriction, including
1806// without limitation the rights to use, copy, modify, merge, publish,
1807// distribute, sublicense, and/or sell copies of the Software, and to permit
1808// persons to whom the Software is furnished to do so, subject to the
1809// following conditions:
1810//
1811// The above copyright notice and this permission notice shall be included
1812// in all copies or substantial portions of the Software.
1813//
1814// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1815// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1816// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
1817// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
1818// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1819// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
1820// USE OR OTHER DEALINGS IN THE SOFTWARE.
1821
1822var shims = require('_shims');
1823
1824var formatRegExp = /%[sdj%]/g;
1825exports.format = function(f) {
1826  if (!isString(f)) {
1827    var objects = [];
1828    for (var i = 0; i < arguments.length; i++) {
1829      objects.push(inspect(arguments[i]));
1830    }
1831    return objects.join(' ');
1832  }
1833
1834  var i = 1;
1835  var args = arguments;
1836  var len = args.length;
1837  var str = String(f).replace(formatRegExp, function(x) {
1838    if (x === '%%') return '%';
1839    if (i >= len) return x;
1840    switch (x) {
1841      case '%s': return String(args[i++]);
1842      case '%d': return Number(args[i++]);
1843      case '%j':
1844        try {
1845          return JSON.stringify(args[i++]);
1846        } catch (_) {
1847          return '[Circular]';
1848        }
1849      default:
1850        return x;
1851    }
1852  });
1853  for (var x = args[i]; i < len; x = args[++i]) {
1854    if (isNull(x) || !isObject(x)) {
1855      str += ' ' + x;
1856    } else {
1857      str += ' ' + inspect(x);
1858    }
1859  }
1860  return str;
1861};
1862
1863/**
1864 * Echos the value of a value. Trys to print the value out
1865 * in the best way possible given the different types.
1866 *
1867 * @param {Object} obj The object to print out.
1868 * @param {Object} opts Optional options object that alters the output.
1869 */
1870/* legacy: obj, showHidden, depth, colors*/
1871function inspect(obj, opts) {
1872  // default options
1873  var ctx = {
1874    seen: [],
1875    stylize: stylizeNoColor
1876  };
1877  // legacy...
1878  if (arguments.length >= 3) ctx.depth = arguments[2];
1879  if (arguments.length >= 4) ctx.colors = arguments[3];
1880  if (isBoolean(opts)) {
1881    // legacy...
1882    ctx.showHidden = opts;
1883  } else if (opts) {
1884    // got an "options" object
1885    exports._extend(ctx, opts);
1886  }
1887  // set default options
1888  if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
1889  if (isUndefined(ctx.depth)) ctx.depth = 2;
1890  if (isUndefined(ctx.colors)) ctx.colors = false;
1891  if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
1892  if (ctx.colors) ctx.stylize = stylizeWithColor;
1893  return formatValue(ctx, obj, ctx.depth);
1894}
1895exports.inspect = inspect;
1896
1897
1898// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
1899inspect.colors = {
1900  'bold' : [1, 22],
1901  'italic' : [3, 23],
1902  'underline' : [4, 24],
1903  'inverse' : [7, 27],
1904  'white' : [37, 39],
1905  'grey' : [90, 39],
1906  'black' : [30, 39],
1907  'blue' : [34, 39],
1908  'cyan' : [36, 39],
1909  'green' : [32, 39],
1910  'magenta' : [35, 39],
1911  'red' : [31, 39],
1912  'yellow' : [33, 39]
1913};
1914
1915// Don't use 'blue' not visible on cmd.exe
1916inspect.styles = {
1917  'special': 'cyan',
1918  'number': 'yellow',
1919  'boolean': 'yellow',
1920  'undefined': 'grey',
1921  'null': 'bold',
1922  'string': 'green',
1923  'date': 'magenta',
1924  // "name": intentionally not styling
1925  'regexp': 'red'
1926};
1927
1928
1929function stylizeWithColor(str, styleType) {
1930  var style = inspect.styles[styleType];
1931
1932  if (style) {
1933    return '\u001b[' + inspect.colors[style][0] + 'm' + str +
1934           '\u001b[' + inspect.colors[style][1] + 'm';
1935  } else {
1936    return str;
1937  }
1938}
1939
1940
1941function stylizeNoColor(str, styleType) {
1942  return str;
1943}
1944
1945
1946function arrayToHash(array) {
1947  var hash = {};
1948
1949  shims.forEach(array, function(val, idx) {
1950    hash[val] = true;
1951  });
1952
1953  return hash;
1954}
1955
1956
1957function formatValue(ctx, value, recurseTimes) {
1958  // Provide a hook for user-specified inspect functions.
1959  // Check that value is an object with an inspect function on it
1960  if (ctx.customInspect &&
1961      value &&
1962      isFunction(value.inspect) &&
1963      // Filter out the util module, it's inspect function is special
1964      value.inspect !== exports.inspect &&
1965      // Also filter out any prototype objects using the circular check.
1966      !(value.constructor && value.constructor.prototype === value)) {
1967    var ret = value.inspect(recurseTimes);
1968    if (!isString(ret)) {
1969      ret = formatValue(ctx, ret, recurseTimes);
1970    }
1971    return ret;
1972  }
1973
1974  // Primitive types cannot have properties
1975  var primitive = formatPrimitive(ctx, value);
1976  if (primitive) {
1977    return primitive;
1978  }
1979
1980  // Look up the keys of the object.
1981  var keys = shims.keys(value);
1982  var visibleKeys = arrayToHash(keys);
1983
1984  if (ctx.showHidden) {
1985    keys = shims.getOwnPropertyNames(value);
1986  }
1987
1988  // Some type of object without properties can be shortcutted.
1989  if (keys.length === 0) {
1990    if (isFunction(value)) {
1991      var name = value.name ? ': ' + value.name : '';
1992      return ctx.stylize('[Function' + name + ']', 'special');
1993    }
1994    if (isRegExp(value)) {
1995      return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
1996    }
1997    if (isDate(value)) {
1998      return ctx.stylize(Date.prototype.toString.call(value), 'date');
1999    }
2000    if (isError(value)) {
2001      return formatError(value);
2002    }
2003  }
2004
2005  var base = '', array = false, braces = ['{', '}'];
2006
2007  // Make Array say that they are Array
2008  if (isArray(value)) {
2009    array = true;
2010    braces = ['[', ']'];
2011  }
2012
2013  // Make functions say that they are functions
2014  if (isFunction(value)) {
2015    var n = value.name ? ': ' + value.name : '';
2016    base = ' [Function' + n + ']';
2017  }
2018
2019  // Make RegExps say that they are RegExps
2020  if (isRegExp(value)) {
2021    base = ' ' + RegExp.prototype.toString.call(value);
2022  }
2023
2024  // Make dates with properties first say the date
2025  if (isDate(value)) {
2026    base = ' ' + Date.prototype.toUTCString.call(value);
2027  }
2028
2029  // Make error with message first say the error
2030  if (isError(value)) {
2031    base = ' ' + formatError(value);
2032  }
2033
2034  if (keys.length === 0 && (!array || value.length == 0)) {
2035    return braces[0] + base + braces[1];
2036  }
2037
2038  if (recurseTimes < 0) {
2039    if (isRegExp(value)) {
2040      return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
2041    } else {
2042      return ctx.stylize('[Object]', 'special');
2043    }
2044  }
2045
2046  ctx.seen.push(value);
2047
2048  var output;
2049  if (array) {
2050    output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
2051  } else {
2052    output = keys.map(function(key) {
2053      return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
2054    });
2055  }
2056
2057  ctx.seen.pop();
2058
2059  return reduceToSingleString(output, base, braces);
2060}
2061
2062
2063function formatPrimitive(ctx, value) {
2064  if (isUndefined(value))
2065    return ctx.stylize('undefined', 'undefined');
2066  if (isString(value)) {
2067    var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
2068                                             .replace(/'/g, "\\'")
2069                                             .replace(/\\"/g, '"') + '\'';
2070    return ctx.stylize(simple, 'string');
2071  }
2072  if (isNumber(value))
2073    return ctx.stylize('' + value, 'number');
2074  if (isBoolean(value))
2075    return ctx.stylize('' + value, 'boolean');
2076  // For some reason typeof null is "object", so special case here.
2077  if (isNull(value))
2078    return ctx.stylize('null', 'null');
2079}
2080
2081
2082function formatError(value) {
2083  return '[' + Error.prototype.toString.call(value) + ']';
2084}
2085
2086
2087function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
2088  var output = [];
2089  for (var i = 0, l = value.length; i < l; ++i) {
2090    if (hasOwnProperty(value, String(i))) {
2091      output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
2092          String(i), true));
2093    } else {
2094      output.push('');
2095    }
2096  }
2097
2098  shims.forEach(keys, function(key) {
2099    if (!key.match(/^\d+$/)) {
2100      output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
2101          key, true));
2102    }
2103  });
2104  return output;
2105}
2106
2107
2108function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
2109  var name, str, desc;
2110  desc = shims.getOwnPropertyDescriptor(value, key) || { value: value[key] };
2111  if (desc.get) {
2112    if (desc.set) {
2113      str = ctx.stylize('[Getter/Setter]', 'special');
2114    } else {
2115      str = ctx.stylize('[Getter]', 'special');
2116    }
2117  } else {
2118    if (desc.set) {
2119      str = ctx.stylize('[Setter]', 'special');
2120    }
2121  }
2122
2123  if (!hasOwnProperty(visibleKeys, key)) {
2124    name = '[' + key + ']';
2125  }
2126  if (!str) {
2127    if (shims.indexOf(ctx.seen, desc.value) < 0) {
2128      if (isNull(recurseTimes)) {
2129        str = formatValue(ctx, desc.value, null);
2130      } else {
2131        str = formatValue(ctx, desc.value, recurseTimes - 1);
2132      }
2133      if (str.indexOf('\n') > -1) {
2134        if (array) {
2135          str = str.split('\n').map(function(line) {
2136            return '  ' + line;
2137          }).join('\n').substr(2);
2138        } else {
2139          str = '\n' + str.split('\n').map(function(line) {
2140            return '   ' + line;
2141          }).join('\n');
2142        }
2143      }
2144    } else {
2145      str = ctx.stylize('[Circular]', 'special');
2146    }
2147  }
2148  if (isUndefined(name)) {
2149    if (array && key.match(/^\d+$/)) {
2150      return str;
2151    }
2152    name = JSON.stringify('' + key);
2153    if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
2154      name = name.substr(1, name.length - 2);
2155      name = ctx.stylize(name, 'name');
2156    } else {
2157      name = name.replace(/'/g, "\\'")
2158                 .replace(/\\"/g, '"')
2159                 .replace(/(^"|"$)/g, "'");
2160      name = ctx.stylize(name, 'string');
2161    }
2162  }
2163
2164  return name + ': ' + str;
2165}
2166
2167
2168function reduceToSingleString(output, base, braces) {
2169  var numLinesEst = 0;
2170  var length = shims.reduce(output, function(prev, cur) {
2171    numLinesEst++;
2172    if (cur.indexOf('\n') >= 0) numLinesEst++;
2173    return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
2174  }, 0);
2175
2176  if (length > 60) {
2177    return braces[0] +
2178           (base === '' ? '' : base + '\n ') +
2179           ' ' +
2180           output.join(',\n  ') +
2181           ' ' +
2182           braces[1];
2183  }
2184
2185  return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
2186}
2187
2188
2189// NOTE: These type checking functions intentionally don't use `instanceof`
2190// because it is fragile and can be easily faked with `Object.create()`.
2191function isArray(ar) {
2192  return shims.isArray(ar);
2193}
2194exports.isArray = isArray;
2195
2196function isBoolean(arg) {
2197  return typeof arg === 'boolean';
2198}
2199exports.isBoolean = isBoolean;
2200
2201function isNull(arg) {
2202  return arg === null;
2203}
2204exports.isNull = isNull;
2205
2206function isNullOrUndefined(arg) {
2207  return arg == null;
2208}
2209exports.isNullOrUndefined = isNullOrUndefined;
2210
2211function isNumber(arg) {
2212  return typeof arg === 'number';
2213}
2214exports.isNumber = isNumber;
2215
2216function isString(arg) {
2217  return typeof arg === 'string';
2218}
2219exports.isString = isString;
2220
2221function isSymbol(arg) {
2222  return typeof arg === 'symbol';
2223}
2224exports.isSymbol = isSymbol;
2225
2226function isUndefined(arg) {
2227  return arg === void 0;
2228}
2229exports.isUndefined = isUndefined;
2230
2231function isRegExp(re) {
2232  return isObject(re) && objectToString(re) === '[object RegExp]';
2233}
2234exports.isRegExp = isRegExp;
2235
2236function isObject(arg) {
2237  return typeof arg === 'object' && arg;
2238}
2239exports.isObject = isObject;
2240
2241function isDate(d) {
2242  return isObject(d) && objectToString(d) === '[object Date]';
2243}
2244exports.isDate = isDate;
2245
2246function isError(e) {
2247  return isObject(e) && objectToString(e) === '[object Error]';
2248}
2249exports.isError = isError;
2250
2251function isFunction(arg) {
2252  return typeof arg === 'function';
2253}
2254exports.isFunction = isFunction;
2255
2256function isPrimitive(arg) {
2257  return arg === null ||
2258         typeof arg === 'boolean' ||
2259         typeof arg === 'number' ||
2260         typeof arg === 'string' ||
2261         typeof arg === 'symbol' ||  // ES6 symbol
2262         typeof arg === 'undefined';
2263}
2264exports.isPrimitive = isPrimitive;
2265
2266function isBuffer(arg) {
2267  return arg && typeof arg === 'object'
2268    && typeof arg.copy === 'function'
2269    && typeof arg.fill === 'function'
2270    && typeof arg.binarySlice === 'function'
2271  ;
2272}
2273exports.isBuffer = isBuffer;
2274
2275function objectToString(o) {
2276  return Object.prototype.toString.call(o);
2277}
2278
2279
2280function pad(n) {
2281  return n < 10 ? '0' + n.toString(10) : n.toString(10);
2282}
2283
2284
2285var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
2286              'Oct', 'Nov', 'Dec'];
2287
2288// 26 Feb 16:19:34
2289function timestamp() {
2290  var d = new Date();
2291  var time = [pad(d.getHours()),
2292              pad(d.getMinutes()),
2293              pad(d.getSeconds())].join(':');
2294  return [d.getDate(), months[d.getMonth()], time].join(' ');
2295}
2296
2297
2298// log is just a thin wrapper to console.log that prepends a timestamp
2299exports.log = function() {
2300  console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
2301};
2302
2303
2304/**
2305 * Inherit the prototype methods from one constructor into another.
2306 *
2307 * The Function.prototype.inherits from lang.js rewritten as a standalone
2308 * function (not on Function.prototype). NOTE: If this file is to be loaded
2309 * during bootstrapping this function needs to be rewritten using some native
2310 * functions as prototype setup using normal JavaScript does not work as
2311 * expected during bootstrapping (see mirror.js in r114903).
2312 *
2313 * @param {function} ctor Constructor function which needs to inherit the
2314 *     prototype.
2315 * @param {function} superCtor Constructor function to inherit prototype from.
2316 */
2317exports.inherits = function(ctor, superCtor) {
2318  ctor.super_ = superCtor;
2319  ctor.prototype = shims.create(superCtor.prototype, {
2320    constructor: {
2321      value: ctor,
2322      enumerable: false,
2323      writable: true,
2324      configurable: true
2325    }
2326  });
2327};
2328
2329exports._extend = function(origin, add) {
2330  // Don't do anything if add isn't an object
2331  if (!add || !isObject(add)) return origin;
2332
2333  var keys = shims.keys(add);
2334  var i = keys.length;
2335  while (i--) {
2336    origin[keys[i]] = add[keys[i]];
2337  }
2338  return origin;
2339};
2340
2341function hasOwnProperty(obj, prop) {
2342  return Object.prototype.hasOwnProperty.call(obj, prop);
2343}
2344
2345},{"_shims":5}]},{},[3])
2346(3)
2347});
2348;
Note: See TracBrowser for help on using the repository browser.