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

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

Enable deployment with Grunt.

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