Changeset 516 for Dev/trunk/node_modules/should/lib/should.js
- Timestamp:
- 03/14/14 12:36:58 (11 years ago)
- Location:
- Dev/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk
- Property svn:ignore
-
old new 1 1 build 2 quod-erat.git
-
- Property svn:ignore
-
Dev/trunk/node_modules/should/lib/should.js
r484 r516 25 25 }; 26 26 27 should.inspect = function(obj, opts) { 28 if(util.isDate(obj) && typeof obj.inspect !== 'function') obj = obj.toISOString(); 29 return inspect(obj, opts); 30 }; 27 should.inspect = inspect; 28 29 function i(value) { 30 if(util.isDate(value) && typeof value.inspect !== 'function') return value.toISOString(); //show millis in dates 31 return should.inspect(value); 32 } 31 33 32 34 /** … … 52 54 if(null == obj) { 53 55 throw new AssertionError({ 54 message: msg || ('expected ' + should.inspect(obj) + ' to exist')56 message: msg || ('expected ' + i(obj) + ' to exist') 55 57 , stackStartFunction: should.exist 56 58 }); … … 70 72 if (null != obj) { 71 73 throw new AssertionError({ 72 message: msg || ('expected ' + should.inspect(obj) + ' to not exist')74 message: msg || ('expected ' + i(obj) + ' to not exist') 73 75 , stackStartFunction: should.not.exist 74 76 }); … … 238 240 239 241 get inspect() { 240 return should.inspect(this.obj);242 return i(this.obj); 241 243 }, 242 244 … … 368 370 this.assert( 369 371 eql(val, this.obj) 370 , function(){ return 'expected ' + this.inspect + ' to equal ' + should.inspect(val) + (description ? " | " + description : "") }371 , function(){ return 'expected ' + this.inspect + ' to not equal ' + should.inspect(val) + (description ? " | " + description : "") }372 , function(){ return 'expected ' + this.inspect + ' to equal ' + i(val) + (description ? " | " + description : "") } 373 , function(){ return 'expected ' + this.inspect + ' to not equal ' + i(val) + (description ? " | " + description : "") } 372 374 , val 373 375 , true … … 387 389 this.assert( 388 390 val === this.obj 389 , function(){ return 'expected ' + this.inspect + ' to equal ' + should.inspect(val) + (description ? " | " + description : "") }390 , function(){ return 'expected ' + this.inspect + ' to not equal ' + should.inspect(val) + (description ? " | " + description : "") }391 , function(){ return 'expected ' + this.inspect + ' to equal ' + i(val) + (description ? " | " + description : "") } 392 , function(){ return 'expected ' + this.inspect + ' to not equal ' + i(val) + (description ? " | " + description : "") } 391 393 , val 392 394 , void 0 … … 640 642 if (this.negate && undefined !== val) { 641 643 if (undefined === this.obj[name]) { 642 throw new Error(this.inspect + ' has no property ' + should.inspect(name) + (description ? " | " + description : ""));644 throw new Error(this.inspect + ' has no property ' + i(name) + (description ? " | " + description : "")); 643 645 } 644 646 } else { 645 647 this.assert( 646 648 undefined !== this.obj[name] 647 , function(){ return 'expected ' + this.inspect + ' to have a property ' + should.inspect(name) + (description ? " | " + description : "") }648 , function(){ return 'expected ' + this.inspect + ' to not have a property ' + should.inspect(name) + (description ? " | " + description : "") }649 , function(){ return 'expected ' + this.inspect + ' to have a property ' + i(name) + (description ? " | " + description : "") } 650 , function(){ return 'expected ' + this.inspect + ' to not have a property ' + i(name) + (description ? " | " + description : "") } 649 651 , void 0 650 652 , void 0 … … 655 657 this.assert( 656 658 val === this.obj[name] 657 , function(){ return 'expected ' + this.inspect + ' to have a property ' + should.inspect(name)658 + ' of ' + should.inspect(val) + ', but got ' + should.inspect(this.obj[name]) + (description ? " | " + description : "") }659 , function(){ return 'expected ' + this.inspect + ' to not have a property ' + should.inspect(name) + ' of ' + should.inspect(val) + (description ? " | " + description : "") }659 , function(){ return 'expected ' + this.inspect + ' to have a property ' + i(name) 660 + ' of ' + i(val) + ', but got ' + i(this.obj[name]) + (description ? " | " + description : "") } 661 , function(){ return 'expected ' + this.inspect + ' to not have a property ' + i(name) + ' of ' + i(val) + (description ? " | " + description : "") } 660 662 , void 0 661 663 , void 0 … … 691 693 if (len > 1) { 692 694 names = names.map(function(name){ 693 return should.inspect(name);695 return i(name); 694 696 }); 695 697 var last = names.pop(); 696 698 str = names.join(', ') + ', and ' + last; 697 699 } else { 698 str = should.inspect(names[0]);700 str = i(names[0]); 699 701 } 700 702 … … 721 723 this.assert( 722 724 hasOwnProperty.call(this.obj, name) 723 , function(){ return 'expected ' + this.inspect + ' to have own property ' + should.inspect(name) + (description ? " | " + description : "") }724 , function(){ return 'expected ' + this.inspect + ' to not have own property ' + should.inspect(name) + (description ? " | " + description : "") }725 , function(){ return 'expected ' + this.inspect + ' to have own property ' + i(name) + (description ? " | " + description : "") } 726 , function(){ return 'expected ' + this.inspect + ' to not have own property ' + i(name) + (description ? " | " + description : "") } 725 727 , void 0 726 728 , void 0 … … 739 741 startWith: function(str, description) { 740 742 this.assert(0 === this.obj.indexOf(str) 741 , function() { return 'expected ' + this.inspect + ' to start with ' + should.inspect(str) + (description ? " | " + description : "") }742 , function() { return 'expected ' + this.inspect + ' to not start with ' + should.inspect(str) + (description ? " | " + description : "") }743 , function() { return 'expected ' + this.inspect + ' to start with ' + i(str) + (description ? " | " + description : "") } 744 , function() { return 'expected ' + this.inspect + ' to not start with ' + i(str) + (description ? " | " + description : "") } 743 745 , void 0 744 746 , void 0 … … 756 758 endWith: function(str, description) { 757 759 this.assert(-1 !== this.obj.indexOf(str, this.obj.length - str.length) 758 , function() { return 'expected ' + this.inspect + ' to end with ' + should.inspect(str) + (description ? " | " + description : "") }759 , function() { return 'expected ' + this.inspect + ' to not end with ' + should.inspect(str) + (description ? " | " + description : "") }760 , function() { return 'expected ' + this.inspect + ' to end with ' + i(str) + (description ? " | " + description : "") } 761 , function() { return 'expected ' + this.inspect + ' to not end with ' + i(str) + (description ? " | " + description : "") } 760 762 , void 0 761 763 , void 0 … … 778 780 this.assert( 779 781 eql(cmp, obj) 780 , function(){ return 'expected ' + this.inspect + ' to include an object equal to ' + should.inspect(obj) + (description ? " | " + description : "") }781 , function(){ return 'expected ' + this.inspect + ' to not include an object equal to ' + should.inspect(obj) + (description ? " | " + description : "") }782 , function(){ return 'expected ' + this.inspect + ' to include an object equal to ' + i(obj) + (description ? " | " + description : "") } 783 , function(){ return 'expected ' + this.inspect + ' to not include an object equal to ' + i(obj) + (description ? " | " + description : "") } 782 784 , void 0 783 785 , void 0 … … 786 788 this.assert( 787 789 ~this.obj.indexOf(obj) 788 , function(){ return 'expected ' + this.inspect + ' to include ' + should.inspect(obj) + (description ? " | " + description : "") }789 , function(){ return 'expected ' + this.inspect + ' to not include ' + should.inspect(obj) + (description ? " | " + description : "") }790 , function(){ return 'expected ' + this.inspect + ' to include ' + i(obj) + (description ? " | " + description : "") } 791 , function(){ return 'expected ' + this.inspect + ' to not include ' + i(obj) + (description ? " | " + description : "") } 790 792 , void 0 791 793 , void 0 … … 806 808 this.assert( 807 809 this.obj.some(function(item) { return eql(obj, item); }) 808 , function(){ return 'expected ' + this.inspect + ' to include an object equal to ' + should.inspect(obj) + (description ? " | " + description : "") }809 , function(){ return 'expected ' + this.inspect + ' to not include an object equal to ' + should.inspect(obj) + (description ? " | " + description : "") }810 , function(){ return 'expected ' + this.inspect + ' to include an object equal to ' + i(obj) + (description ? " | " + description : "") } 811 , function(){ return 'expected ' + this.inspect + ' to not include an object equal to ' + i(obj) + (description ? " | " + description : "") } 810 812 , void 0 811 813 , void 0 … … 846 848 if (len > 1) { 847 849 keys = keys.map(function(key){ 848 return should.inspect(key);850 return i(key); 849 851 }); 850 852 var last = keys.pop(); 851 853 str = keys.join(', ') + ', and ' + last; 852 854 } else { 853 str = should.inspect(keys[0]);855 str = i(keys[0]); 854 856 } 855 857 … … 895 897 this.assert( 896 898 code == status 897 , function(){ return 'expected response code of ' + code + ' ' + should.inspect(statusCodes[code])898 + ', but got ' + status + ' ' + should.inspect(statusCodes[status]) }899 , function(){ return 'expected to not respond with ' + code + ' ' + should.inspect(statusCodes[code]) });899 , function(){ return 'expected response code of ' + code + ' ' + i(statusCodes[code]) 900 + ', but got ' + status + ' ' + i(statusCodes[status]) } 901 , function(){ return 'expected to not respond with ' + code + ' ' + i(statusCodes[code]) }); 900 902 901 903 return this;
Note: See TracChangeset
for help on using the changeset viewer.