should.js-4.0.4+dfsg.orig/0000775000000000000000000000000012346073577014024 5ustar rootrootshould.js-4.0.4+dfsg.orig/test/0000775000000000000000000000000012345335655015000 5ustar rootrootshould.js-4.0.4+dfsg.orig/test/util.js0000664000000000000000000000057312345335655016320 0ustar rootrootvar should = require('../'); function err(fn, msg) { var ok = true; try { fn(); ok = false; } catch (err) { if(err.message !== msg) { throw new should.AssertionError({ message: 'Expected message does not match', expected: msg, actual: err.message }); } } if(!ok) throw new Error('expected an error'); } exports.err = err;should.js-4.0.4+dfsg.orig/test/should.test.js0000664000000000000000000000173412345335655017617 0ustar rootroot /** * Module dependencies. */ var should = require('../') , assert = require('assert'); function err(fn, msg) { try { fn(); should.fail('expected an error'); } catch (err) { should.equal(msg, err.message); } } describe('should', function() { it('test double require', function() { require('../').should.equal(should); }); it('test assertion', function() { 'test'.should.be.a.string; should.equal('foo', 'foo'); }); it('test .expected and .actual', function() { try { 'foo'.should.equal('bar'); } catch (err) { assert('foo' == err.actual, 'err.actual'); assert('bar' == err.expected, 'err.expected'); } }); it('test chaining', function() { var user = { name: 'tj', pets: ['tobi', 'loki', 'jane', 'bandit'] }; user.should.be.an.instanceOf(Object).and.have.property('name', 'tj'); user.should.have.ownProperty('name') .which.not.have.length(3) .and.be.equal('tj'); }); }); should.js-4.0.4+dfsg.orig/test/ext/0000775000000000000000000000000012345335655015600 5ustar rootrootshould.js-4.0.4+dfsg.orig/test/ext/type.test.js0000664000000000000000000001225212345335655020077 0ustar rootrootvar err = require('../util').err, should = require('../../'); var AssertionError = require('assert').AssertionError; var util = require('util'); describe('type', function() { it('test arguments', function() { var args = (function(){ return arguments; })(1,2,3); args.should.be.arguments; [].should.not.be.arguments; err(function() { ((function(){ return arguments; })(1,2,3)).should.not.be.arguments; }, "expected { '0': 1, '1': 2, '2': 3 } not to be arguments"); err(function() { ({}).should.be.arguments; }, "expected {} to be arguments"); }); it('test typeof', function() { 'test'.should.have.type('string'); err(function(){ 'test'.should.not.have.type('string'); }, "expected 'test' not to have type string"); err(function(){ 'test'.should.not.have.type('string', 'foo'); }, "foo"); err(function(){ (10).should.have.type('string'); }, "expected 10 to have type string"); (5).should.have.type('number'); err(function(){ (5).should.not.have.type('number'); }, "expected 5 not to have type number"); err(function(){ (5).should.not.have.type('number', 'foo'); }, "foo"); }); it('test instanceof', function() { function Foo(){} new Foo().should.be.an.instanceof(Foo); new Date().should.be.an.instanceof(Date); var tobi = { name: 'Tobi', age: 2 }; tobi.should.be.an.instanceof(Object); var getSomething = function() {return "something"}; getSomething.should.be.an.instanceof(Function); var number = Object(5); (number instanceof Number).should.be.true; number.should.be.an.instanceof(Number); var boolean = Object(true); (boolean instanceof Boolean).should.be.true; boolean.should.be.an.instanceof(Boolean); var string = Object('string'); (string instanceof String).should.be.true; string.should.be.an.instanceof(String); err(function(){ (3).should.an.instanceof(Foo); }, "expected 3 to be an instance of Foo"); err(function(){ (3).should.an.instanceof(Foo, 'foo'); }, "foo"); err(function(){ ({}).should.not.be.an.instanceof(Object); }, "expected {} not to be an instance of Object"); }); it('test instanceOf (non- it(reserved)', function() { function Foo(){} new Foo().should.be.an.instanceOf(Foo); new Date().should.be.an.instanceOf(Date); var tobi = { name: 'Tobi', age: 2 }; tobi.should.be.an.instanceOf(Object); var getSomething = function() {return "something"}; getSomething.should.be.an.instanceOf(Function); err(function(){ (9).should.an.instanceOf(Foo); }, "expected 9 to be an instance of Foo"); err(function(){ (9).should.an.instanceOf(Foo, 'foo'); }, "foo"); function Foo2(){} Foo2.prototype.valueOf = function (){ return 'foo'; }; new Foo2().should.be.an.instanceOf(Foo2); }); it('test Function', function() { var f = function() {}; f.should.be.a.Function; Object.should.be.a.Function; Function.should.be.a.Function; (new Function("1 * 1")).should.be.a.Function; err(function() { (1).should.be.a.Function; }, "expected 1 to be a function"); }); it('test Object', function() { ({}).should.be.an.Object; Function.should.not.be.an.Object; (new Object()).should.be.an.Object; (new Date()).should.be.an.Object; err(function() { (1).should.be.an.Object; }, 'expected 1 to be an object'); }); it('test String', function() { ''.should.be.a.String; ({}).should.not.be.a.String; (0).should.not.be.a.String; (new String("")).should.be.a.String; err(function() { (1).should.be.a.String }, 'expected 1 to be a string'); }); it('test Array', function() { [].should.be.an.Array; (new Array(10)).should.be.an.Array; ''.should.not.be.Array; (1).should.not.be.Array; err(function() { [].should.not.be.Array }, 'expected [] not to be an array'); }); it('test Number', function() { (1).should.be.a.Number; (new Number(10)).should.be.a.Number; NaN.should.be.a.Number; Infinity.should.be.a.Number; ({}).should.not.be.a.Number; err(function() { ([]).should.be.a.Number; }, 'expected [] to be a number'); }); it('test Boolean', function() { (true).should.be.a.Boolean; (false).should.be.a.Boolean; (new Boolean(false)).should.be.a.Boolean; ({}).should.not.be.a.Boolean; err(function() { [].should.be.a.Boolean; }, 'expected [] to be a boolean'); }); it('test Error', function() { (new Error()).should.be.an.Error; ({}).should.not.be.Error; var ae = new AssertionError({ actual: 10 }); ae.should.be.an.Error; var AsyncTimeoutError = function AsyncTimeoutError(msg) { msg && (this.message = msg); Error.apply(this, arguments); Error.captureStackTrace && Error.captureStackTrace(this, AsyncTimeoutError); }; util.inherits(AsyncTimeoutError, Error); AsyncTimeoutError.prototype.name = AsyncTimeoutError.name; var e = new AsyncTimeoutError('foo'); e.should.be.an.Error; err(function() { ([]).should.be.an.Error; }, 'expected [] to be an error'); }); });should.js-4.0.4+dfsg.orig/test/ext/string.test.js0000664000000000000000000000216212345335655020423 0ustar rootrootvar err = require('../util').err; var should = require('../../'); describe('string', function() { it('test startWith()', function() { 'foobar'.should.startWith('foo'); 'foobar'.should.not.startWith('bar'); err(function() { 'foobar'.should.startWith('bar'); }, "expected 'foobar' to start with 'bar'"); err(function() { 'foobar'.should.not.startWith('foo'); }, "expected 'foobar' not to start with 'foo'"); err(function() { 'foobar'.should.startWith('bar', 'baz'); }, "baz"); err(function() { 'foobar'.should.not.startWith('foo', 'baz'); }, "baz"); }); it('test endWith()', function() { 'foobar'.should.endWith('bar'); 'foobar'.should.not.endWith('foo'); err(function() { 'foobar'.should.endWith('foo'); }, "expected 'foobar' to end with 'foo'"); err(function() { 'foobar'.should.not.endWith('bar'); }, "expected 'foobar' not to end with 'bar'"); err(function() { 'foobar'.should.endWith('foo', 'baz'); }, "baz"); err(function() { 'foobar'.should.not.endWith('bar', 'baz'); }, "baz"); }); });should.js-4.0.4+dfsg.orig/test/ext/property.test.js0000664000000000000000000001621112345335655021001 0ustar rootrootvar err = require('../util').err; var should = require('../../'); describe('property', function() { it('test enumerable(name)', function() { ({'length': 5}).should.have.enumerable('length'); (4).should.not.have.enumerable('length'); err(function() { 'asd'.should.have.enumerable('length'); }, "expected 'asd' to have enumerable property length"); }); it('test enumerable(name, it(val)', function() { ({'length': 5}).should.have.enumerable('length', 5); err(function() { ({'length': 3}).should.have.enumerable('length', 5); }, "expected { length: 3 } to have enumerable property length equal to 5"); }); it('test property(name)', function() { 'test'.should.have.property('length'); (4).should.not.have.property('length'); err(function() { 'asd'.should.have.property('foo'); }, "expected 'asd' to have property foo"); }); it('test property(name, it(val)', function() { 'test'.should.have.property('length', 4); 'asd'.should.have.property('constructor', String); err(function() { 'asd'.should.have.property('length', 4); }, "expected 'asd' to have property length of 4 (got 3)"); err(function() { 'asd'.should.not.have.property('length', 3); }, "expected 'asd' not to have property length of 3"); err(function() { var obj = { f: function() {} }; var f1 = function() {}; obj.should.have.property('f', f1); }, "expected { f: [Function] } to have property f of [Function] (got [Function])"); err(function() { ({a: {b: 1}}).should.have.property('a') .and.have.property('b', 100); }, "expected { b: 1 } to have property b of 100 (got 1)"); err(function() { ({a: {b: 1}}).should.have.property('a') .and.have.property('c', 100); }, "expected { b: 1 } to have property c"); err(function() { ({a: {b: 1}}).should.have.property('a') .and.have.property('c'); }, "expected { b: 1 } to have property c"); }); it('test length(n)', function() { 'test'.should.have.length(4); 'test'.should.have.lengthOf(4); 'test'.should.not.have.length(3); [1, 2, 3].should.have.length(3); ({ length: 10}).should.have.length(10); err(function() { (4).should.have.length(3); }, "expected 4 to have property length"); err(function() { 'asd'.should.not.have.length(3); }, "expected 'asd' not to have property length of 3"); }); it('test ownProperty(name)', function() { 'test'.should.have.ownProperty('length'); ({ length: 12 }).should.have.ownProperty('length'); err(function() { ({ length: 12 }).should.not.have.ownProperty('length'); }, "expected { length: 12 } not to have own property length"); err(function() { ({ length: 12 }).should.not.have.ownProperty('length', 'foo'); }, "foo"); err(function() { ({ length: 12 }).should.have.ownProperty('foo', 'foo'); }, "foo"); }); it('test ownProperty(name).equal(val)', function() { ({length: 10}).should.have.ownProperty('length').equal(10); }); it('test properties(name1, name2, it(...)', function() { 'test'.should.have.properties('length', 'indexOf'); (4).should.not.have.properties('length'); err(function() { 'asd'.should.have.properties('foo'); }, "expected 'asd' to have property foo"); err(function() { 'asd'.should.not.have.properties('length', 'indexOf'); }, "expected 'asd' not to have properties length, indexOf"); }); it('test properties([names])', function() { 'test'.should.have.properties(['length', 'indexOf']); (4).should.not.have.properties(['length']); err(function() { 'asd'.should.have.properties(['foo']); }, "expected 'asd' to have property foo"); }); it('test any of properties', function() { 'test'.should.have.any.of.properties('length', 'a', 'b'); 'test'.should.have.any.of.properties('length'); ({ a: 10 }).should.have.any.of.properties('a', 'b'); ({ a: 10 }).should.have.any.of.properties({ a: 10, b: 12 }); ({ a: 10 }).should.not.have.any.of.properties('b', 'c'); ({ a: 10 }).should.have.any.of.properties(['a', 'b']); err(function() { ({ a: 10 }).should.not.have.any.of.properties(['a', 'b']); }, "expected { a: 10 } not to have property a"); err(function() { ({ a: 10, b: 10 }).should.not.have.any.of.properties(['a', 'b']); }, "expected { a: 10, b: 10 } not to have any of properties a, b"); err(function() { ({ a: 10, b: 10 }).should.not.have.any.of.properties({ a: 10, b: 12 }); }, "expected { a: 10, b: 10 } not to have property a of 10"); err(function() { ({ a: 10, b: 10 }).should.not.have.any.of.properties({ a: 10, b: 10 }); }, "expected { a: 10, b: 10 } not to have any of properties a of 10, b of 10"); err(function() { ({ a: 11, b: 11 }).should.have.any.of.properties({ a: 10, b: 10 }); }, "expected { a: 11, b: 11 } to have any of properties a of 10 (got 11), b of 10 (got 11)"); }); it('test keys(array)', function() { ({ foo: 1 }).should.have.keys(['foo']); ({ foo: 1, bar: 2 }).should.have.keys(['foo', 'bar']); ({ foo: 1, bar: 2 }).should.have.keys('foo', 'bar'); ({}).should.have.keys(); ({}).should.have.keys([]); ({ '1': 'cancelled', '3': 'deleted' }).should.have.keys(1, 3); err(function() { ({ foo: 1 }).should.have.keys(['bar']); }, "expected { foo: 1 } to have key bar\n\tmissing keys: bar\n\textra keys: foo"); err(function() { ({ foo: 1 }).should.have.keys(['bar', 'baz']); }, "expected { foo: 1 } to have keys bar, baz\n\tmissing keys: bar, baz\n\textra keys: foo"); err(function() { ({ foo: 1 }).should.not.have.keys('foo'); }, "expected { foo: 1 } not to have key foo"); err(function() { ({ foo: 1 }).should.not.have.keys(['foo']); }, "expected { foo: 1 } not to have key foo"); err(function() { ({ foo: 1, bar: 2 }).should.not.have.keys(['foo', 'bar']); }, "expected { foo: 1, bar: 2 } not to have keys foo, bar"); }); it('test empty', function() { ''.should.be.empty; [].should.be.empty; ({}).should.be.empty; ({ length: 10 }).should.not.be.empty; (function() { arguments.should.be.empty; })(); err(function() { ({}).should.not.be.empty; }, 'expected {} not to be empty'); err(function() { ({ length: 10 }).should.be.empty; }, 'expected { length: 10 } to be empty'); err(function() { 'asd'.should.be.empty; }, "expected 'asd' to be empty"); err(function() { ''.should.not.be.empty; }, "expected '' not to be empty"); }); it('should .propertyByPath lookup properties by name path', function() { ({ a: { b: 10}}).should.have.propertyByPath('a', 'b'); ({ '0': { '0': 10}}).should.not.have.propertyByPath(0, 0, 1); // true fail err(function() { ({ a: { b: 10}}).should.have.propertyByPath('a', 'b', 'c'); }, "expected { a: { b: 10 } } to have property by path a, b, c - failed on c"); // false positive err(function() { ({ a: { b: 10}}).should.not.have.propertyByPath('a', 'b'); }, "expected { a: { b: 10 } } not to have property by path a, b"); }) }); should.js-4.0.4+dfsg.orig/test/ext/number.test.js0000664000000000000000000000602412345335655020406 0ustar rootrootvar err = require('../util').err; var should = require('../../'); describe('number', function() { it('test NaN', function() { NaN.should.be.NaN; Infinity.should.not.be.NaN; (0).should.not.be.NaN; false.should.not.be.NaN; ({}).should.not.be.NaN; ''.should.not.be.NaN; 'foo'.should.not.be.NaN; /^$/.should.not.be.NaN; err(function(){ Infinity.should.be.NaN; }, "expected Infinity to be NaN") err(function(){ NaN.should.not.be.NaN; }, "expected NaN not to be NaN") }); it('test Infinity', function() { NaN.should.not.be.Infinity; (1/0).should.be.Infinity; Infinity.should.be.Infinity; (0).should.not.be.Infinity; false.should.not.be.Infinity; ({}).should.not.be.Infinity; ''.should.not.be.Infinity; 'foo'.should.not.be.Infinity; /^$/.should.not.be.Infinity; err(function(){ NaN.should.be.Infinity; }, "expected NaN to be Infinity") err(function(){ Infinity.should.not.be.Infinity; }, "expected Infinity not to be Infinity") }); it('test within(start, it(finish)', function() { (5).should.be.within(5, 10); (5).should.be.within(3,6); (5).should.be.within(3,5); (5).should.not.be.within(1,3); err(function(){ (5).should.not.be.within(4,6); }, "expected 5 not to be within 4..6"); err(function(){ (10).should.be.within(50,100); }, "expected 10 to be within 50..100"); err(function(){ (5).should.not.be.within(4,6, 'foo'); }, "foo"); err(function(){ (10).should.be.within(50,100, 'foo'); }, "foo"); }); it('test approximately(number, it(delta)', function() { (1.5).should.be.approximately(1.4, 0.2); (1.5).should.be.approximately(1.5, 10E-10); (1.5).should.not.be.approximately(1.4, 1E-2); err(function(){ (99.99).should.not.be.approximately(100, 0.1); }, "expected 99.99 not to be approximately 100 ±0.1"); err(function(){ (99.99).should.be.approximately(105, 0.1); }, "expected 99.99 to be approximately 105 ±0.1"); }); it('test above(n)', function() { (5).should.be.above(2); (5).should.be.greaterThan(2); (5).should.not.be.above(5); (5).should.not.be.above(6); err(function(){ (5).should.be.above(6); }, "expected 5 to be above 6"); err(function(){ (10).should.not.be.above(6); }, "expected 10 not to be above 6"); err(function(){ (5).should.be.above(6, 'foo'); }, "foo"); err(function(){ (10).should.not.be.above(6, 'foo'); }, "foo"); }); it('test below(n)', function() { (2).should.be.below(5); (2).should.be.lessThan(5); (5).should.not.be.below(5); (6).should.not.be.below(5); err(function(){ (6).should.be.below(5); }, "expected 6 to be below 5"); err(function(){ (6).should.not.be.below(10); }, "expected 6 not to be below 10"); err(function(){ (6).should.be.below(5, 'foo'); }, "foo"); err(function(){ (6).should.not.be.below(10, 'foo'); }, "foo"); }); });should.js-4.0.4+dfsg.orig/test/ext/match.test.js0000664000000000000000000001035012345335655020207 0ustar rootrootvar err = require('../util').err; var should = require('../../'); describe('match', function() { it('test string match(regexp)', function() { 'foobar'.should.match(/^foo/) 'foobar'.should.not.match(/^bar/) err(function() { 'foobar'.should.match(/^bar/i) }, "expected 'foobar' to match /^bar/i"); err(function() { 'foobar'.should.not.match(/^foo/i) }, "expected 'foobar' not to match /^foo/i"); err(function() { 'foobar'.should.match(/^bar/i, 'foo') }, "foo"); err(function() { 'foobar'.should.not.match(/^foo/i, 'foo') }, "foo"); }); it('test object match(regexp)', function() { ({ a: 'foo', c: 'barfoo' }).should.match(/foo$/); ({ a: 'a' }).should.not.match(/^http/); // positive false err(function() { ({ a: 'foo', c: 'barfoo' }).should.not.match(/foo$/); }, "expected { a: 'foo', c: 'barfoo' } not to match /foo$/\n\tmatched properties: a, c"); // negative true err(function() { ({ a: 'foo', c: 'barfoo' }).should.match(/^foo$/); }, "expected { a: 'foo', c: 'barfoo' } to match /^foo$/\n\tnot matched properties: c ('barfoo')\n\tmatched properties: a"); }); it('test array match(regexp)', function() { ['a', 'b', 'c'].should.match(/[a-z]/); ['a', 'b', 'c'].should.not.match(/[d-z]/); err(function() { ['a', 'b', 'c'].should.not.match(/[a-z]/); }, "expected [ 'a', 'b', 'c' ] not to match /[a-z]/"); err(function() { ['a', 'b', 'c'].should.match(/[d-z]/); }, "expected [ 'a', 'b', 'c' ] to match /[d-z]/"); }); it('test match(function)', function() { (5).should.match(function(n) { return n > 0; }); (5).should.not.match(function(n) { return n < 0; }); (5).should.not.match(function(it) { it.should.be.an.Array; }); (5).should.match(function(it) { it.should.be.a.Number; }); err(function() { (5).should.match(function(n) { return n < 0; }); }, "expected 5 to match [Function]"); err(function() { (5).should.match(function(it) { it.should.be.an.Array; }); }, "expected 5 to match [Function]\n\texpected 5 to be an array"); err(function() { (5).should.not.match(function(it) { return it.should.be.a.Number; }); }, "expected 5 not to match [Function]\n\texpected 5 to be a number"); err(function() { (5).should.not.match(function(n) { return n > 0; }); }, "expected 5 not to match [Function]"); }); it('test match(object)', function() { ({ a: 10, b: 'abc', c: { d: 10 }, d: 0 }).should .match({ a: 10, b: /c$/, c: function(it) { return it.should.have.property('d', 10); }}); [10, 'abc', { d: 10 }, 0].should .match({ '0': 10, '1': /c$/, '2': function(it) { return it.should.have.property('d', 10); } }); [10, 'abc', { d: 10 }, 0].should .match([10, /c$/, function(it) { return it.should.have.property('d', 10); }]); err(function() { ({ a: 10, b: 'abc', c: { d: 10 }, d: 0 }).should .match({ a: 11, b: /c$/, c: function(it) { return it.should.have.property('d', 10); }}); }, "expected { a: 10, b: 'abc', c: { d: 10 }, d: 0 } to match { a: 11, b: /c$/, c: [Function] }\n\tnot matched properties: a (10)\n\tmatched properties: b, c"); err(function() { ({ a: 10, b: 'abc', c: { d: 10 }, d: 0 }).should.not .match({ a: 10, b: /c$/, c: function(it) { return it.should.have.property('d', 10); }}); }, "expected { a: 10, b: 'abc', c: { d: 10 }, d: 0 } not to match { a: 10, b: /c$/, c: [Function] }\n\tmatched properties: a, b, c"); }); it('test each property match(function)', function() { [10, 11, 12].should.matchEach(function(it) { return it >= 10; }); [10, 10].should.matchEach(10); ({ a: 10, b: 11, c: 12}).should.matchEach(function(value, key) { value.should.be.a.Number; }); (['a', 'b', 'c']).should.matchEach(/[a-c]/); err(function() { (['a', 'b', 'c']).should.not.matchEach(/[a-c]/); }, "expected [ 'a', 'b', 'c' ] not to match each /[a-c]/"); err(function() { [10, 11].should.matchEach(10); }, "expected [ 10, 11 ] to match each 10"); }); });should.js-4.0.4+dfsg.orig/test/ext/error.test.js0000664000000000000000000001030412345335655020243 0ustar rootrootvar err = require('../util').err, should = require('../../'); describe('error', function() { it('test throw()', function() { (function(){}).should.not.throw(); (function(){ throw new Error('fail') }).should.throw(); err(function(){ (function(){}).should.throw(); }, 'expected [Function] to throw exception'); err(function(){ (function(){ throw new Error('fail'); }).should.not.throw(); }, 'expected [Function] not to throw exception (got [Error: fail])'); }); it('test throw() with regex message', function() { (function(){ throw new Error('fail'); }).should.throw(/fail/); err(function(){ (function(){}).should.throw(/fail/); }, 'expected [Function] to throw exception'); err(function(){ (function(){ throw new Error('error'); }).should.throw(/fail/); }, "expected [Function] to throw exception with a message matching /fail/, but got 'error'"); }); it('test throw() with string message', function() { (function(){ throw new Error('fail'); }).should.throw('fail'); err(function(){ (function(){}).should.throw('fail'); }, 'expected [Function] to throw exception'); err(function(){ (function(){ throw new Error('error'); }).should.throw('fail'); }, "expected [Function] to throw exception with a message matching 'fail', but got 'error'"); }); it('test throw() with type', function() { (function(){ throw new Error('fail'); }).should.throw(Error); err(function(){ (function(){}).should.throw(Error); }, 'expected [Function] to throw exception'); err(function(){ (function(){ throw 'error'; }).should.throw(Error); }, "expected [Function] to throw exception of type Error, but got String"); }); it('test throwError()', function() { (function(){}).should.not.throwError(); (function(){ throw new Error('fail') }).should.throwError(); err(function(){ (function(){}).should.throwError(); }, 'expected [Function] to throw exception'); err(function(){ (function(){ throw new Error('fail'); }).should.not.throwError(); }, 'expected [Function] not to throw exception (got [Error: fail])'); }); it('test throwError() with regex message', function() { (function(){ throw new Error('fail'); }).should.throwError(/fail/); err(function(){ (function(){}).should.throwError(/fail/); }, 'expected [Function] to throw exception'); err(function(){ (function(){ throw new Error('error'); }).should.throwError(/fail/); }, "expected [Function] to throw exception with a message matching /fail/, but got 'error'"); }); it('test throwError() with string message', function() { (function(){ throw new Error('fail'); }).should.throwError('fail'); err(function(){ (function(){}).should.throwError('fail'); }, 'expected [Function] to throw exception'); err(function(){ (function(){ throw new Error('error'); }).should.throwError('fail'); }, "expected [Function] to throw exception with a message matching 'fail', but got 'error'"); }); it('test throwError() with type', function() { (function(){ throw new Error('fail'); }).should.throw(Error); err(function(){ (function(){}).should.throw(Error); }, 'expected [Function] to throw exception'); err(function(){ (function(){ throw 'error'; }).should.throw(Error); }, "expected [Function] to throw exception of type Error, but got String"); }); it('test .throw(err, properties) with matching error', function() { var error = new Error(); error.a = 10; (function(){ throw error; }).should.throw(Error, { a: 10 }); err(function(){ (function(){ throw error; }).should.throw(Error, { a: 11 }); }, "expected [Function] to throw exception: expected [Error] to match { a: 11 }\n\tnot matched properties: a (10)"); }); it('test .throw(properties) with matching error', function() { var error = new Error(); error.a = 10; (function(){ throw error; }).should.throw({ a: 10 }); err(function(){ (function(){ throw error; }).should.throw({ a: 11 }); }, "expected [Function] to throw exception: expected [Error] to match { a: 11 }\n\tnot matched properties: a (10)"); }); });should.js-4.0.4+dfsg.orig/test/ext/eql.test.js0000664000000000000000000000162212345335655017676 0ustar rootrootvar err = require('../util').err, should = require('../../'); describe('eql', function() { it('test eql(val)', function() { 'test'.should.eql('test'); ({ foo: 'bar' }).should.eql({ foo: 'bar' }); (1).should.eql(1); '4'.should.eql(4); var memo = []; function memorize() { memo.push(arguments); } memorize('a', [1, 2]); memorize('a', [1, 2]); memo[0].should.eql(memo[1]); err(function(){ (4).should.eql(3); }, 'expected 4 to equal 3'); }); it('test equal(val)', function() { 'test'.should.equal('test'); (1).should.equal(1); err(function(){ (4).should.equal(3); }, 'expected 4 to be 3'); err(function(){ '4'.should.equal(4); }, "expected '4' to be 4"); var date = new Date; date.should.equal(date); }); it('test .equal()', function() { var foo; should.equal(undefined, foo); }); });should.js-4.0.4+dfsg.orig/test/ext/contain.test.js0000664000000000000000000000740612345335655020556 0ustar rootrootvar err = require('../util').err; var should = require('../../'); describe('property', function() { it('test containEql', function() { 'hello boy'.should.containEql('boy'); [1, 2, 3].should.containEql(3); [ [1], [2], [3] ].should.containEql([3]); [ [1], [2], [3, 4] ].should.not.containEql([3]); [ {a: 'a'}, {b: 'b', c: 'c'} ].should.containEql({a: 'a'}); [ {a: 'a'}, {b: 'b', c: 'c'} ].should.not.containEql({b: 'b'}); ({}).should.not.containEql({ a: 10 }); ({ b: 10 }).should.containEql({ b: 10 }); [1, 2, 3].should.containEql(1); ([1, 2, { a: 10 }]).should.containEql({ a: 10 }); [1, 2, 3].should.not.containEql({ a: 1 }); err(function() { [1, 2, 3].should.not.containEql(3); }, "expected [ 1, 2, 3 ] not to contain 3"); err(function() { [1, 2, 3].should.containEql(4); }, "expected [ 1, 2, 3 ] to contain 4"); }); it('test containDeep', function() { 'hello boy'.should.containDeep('boy'); ({ a: { b: 10 }, b: { c: 10, d: 11, a: { b: 10, c: 11} }}).should .containDeep({ a: { b: 10 }, b: { c: 10, a: { c: 11 }}}); [1, 2, 3, { a: { b: { d: 12 }}}].should.containDeep([ { a: { b: {d: 12}}} ]); [ [1, [2, 3], 3], [2] ].should.not.containDeep([1, 2]); [ [1], [2], [3] ].should.containDeep([ [3] ]); [ [1], [2], [3, 4] ].should.containDeep([ [3] ]); [ [1], [2], [3, 4] ].should.containDeep([ [1], [3] ]); [ [1], [2], [3, 4] ].should.containDeep([ [3], [1] ]); [1,2,3].should.not.containDeep([3,3,3]); [1,2,3].should.containDeep([3]); [ {a: 'a'}, {b: 'b', c: 'c'} ].should.containDeep([ {a: 'a'} ]); [ {a: 'a'}, {b: 'b', c: 'c'} ].should.containDeep([ {b: 'b'} ]); [1, 2, 3].should.containDeep([3, 2]); err(function() { 'hello boy'.should.not.containDeep('boy'); }, "expected 'hello boy' not to contain 'boy'"); err(function() { [ {a: 'a'}, {b: 'b', c: 'c'} ].should.not.containDeep([ {b: 'b'} ]); }, "expected [ { a: 'a' }, { b: 'b', c: 'c' } ] not to contain [ { b: 'b' } ]"); }); it('test .containDeepOrdered', function() { 'hello boy'.should.containDeepOrdered('boy'); ({ a: { b: 10 }, b: { c: 10, d: 11, a: { b: 10, c: 11} }}).should .containDeepOrdered({ a: { b: 10 }, b: { c: 10, a: { c: 11 }}}); [1, 2, 3, { a: { b: { d: 12 }}}].should.containDeepOrdered([ { a: { b: {d: 12}}} ]); [ [1, [2, 3], 3], [2] ].should.not.containDeepOrdered([1, 2]); [ [1], [2], [3] ].should.containDeepOrdered([ [3] ]); [ [1], [2], [3, 4] ].should.containDeepOrdered([ [3] ]); [ [1], [2], [3, 4] ].should.containDeepOrdered([ [1], [3] ]); [ [1], [2], [3, 4] ].should.not.containDeepOrdered([ [3], [1] ]); [ {a: 'a'}, {b: 'b', c: 'c'} ].should.containDeepOrdered([ {a: 'a'} ]); [ {a: 'a'}, {b: 'b', c: 'c'} ].should.containDeepOrdered([ {b: 'b'} ]); err(function() { 'hello boy'.should.not.containDeepOrdered('boy'); }, "expected 'hello boy' not to contain 'boy'"); err(function() { [ {a: 'a'}, {b: 'b', c: 'c'} ].should.not.containDeepOrdered([ {b: 'b'} ]); }, "expected [ { a: 'a' }, { b: 'b', c: 'c' } ] not to contain [ { b: 'b' } ]"); }); }); should.js-4.0.4+dfsg.orig/test/ext/bool.test.js0000664000000000000000000000176212345335655020055 0ustar rootrootvar err = require('../util').err; var should = require('../../'); describe('bool', function() { it('test true', function() { true.should.be.true; false.should.not.be.true; (1).should.not.be.true; err(function(){ 'test'.should.be.true; }, "expected 'test' to be true") err(function(){ true.should.not.be.true; }, "expected true not to be true") }); it('test false', function() { false.should.be.false; true.should.not.be.false; (0).should.not.be.false; err(function(){ ''.should.be.false; }, "expected '' to be false") err(function(){ false.should.not.be.false; }, "expected false not to be false") }); it('test ok', function() { true.should.be.ok; false.should.not.be.ok; (1).should.be.ok; (0).should.not.be.ok; err(function(){ ''.should.be.ok; }, "expected '' to be truthy"); err(function(){ 'test'.should.not.be.ok; }, "expected 'test' not to be truthy"); }); });should.js-4.0.4+dfsg.orig/test/exist.test.js0000664000000000000000000000401712345335655017452 0ustar rootroot/** * Module dependencies. */ var should = require('../'); function err(fn, msg) { try { fn(); should.fail('expected an error'); } catch(err) { should.equal(msg, err.message); } } function err_should_exist(obj) { err(function() { should.exist(obj); }, 'expected ' + should.format(obj) + ' to exist'); } function err_should_not_exist(obj) { err(function() { should.not.exist(obj); }, 'expected ' + should.format(obj) + ' to not exist'); } describe('exist', function() { // static should.exist() pass, it('test static should.exist() pass w/ bool', function() { should.exist(false); }); it('test static should.exist() pass w/ number', function() { should.exist(0); }); it('test static should.exist() pass w/ string', function() { should.exist(''); }); it('test static should.exist() pass w/ object', function() { should.exist({}); }); it('test static should.exist() pass w/ array', function() { should.exist([]); }); // static should.exist() fail, it('test static should.exist() fail w/ null', function() { err_should_exist(null); }); it('test static should.exist() fail w/ undefined', function() { err_should_exist(undefined); }); // static should.not.exist() pass, it('test static should.not.exist() pass w/ null', function() { should.not.exist(null); }); it('test static should.not.exist() pass w/ undefined', function() { should.not.exist(undefined); }); // static should.not.exist() fail, it('test static should.not.exist() fail w/ bool', function() { err_should_not_exist(false); }); it('test static should.not.exist() fail w/ number', function() { err_should_not_exist(0); }); it('test static should.not.exist() fail w/ string', function() { err_should_not_exist(''); }); it('test static should.not.exist() fail w/ object', function() { err_should_not_exist({}); }); it('test static should.not.exist() fail w/ array', function() { err_should_not_exist([]); }); }); should.js-4.0.4+dfsg.orig/package.json0000664000000000000000000000163212345335655016311 0ustar rootroot{ "name": "should", "description": "test framework agnostic BDD-style assertions", "version": "4.0.4", "author": "TJ Holowaychuk and contributors", "repository": { "type": "git", "url": "https://github.com/shouldjs/should.js.git" }, "homepage": "https://github.com/shouldjs/should.js", "scripts": { "test": "gulp test", "zuul": "zuul -- ./test/**/*.test.js ./test/*.test.js" }, "devDependencies": { "browserify": "latest", "mocha-better-spec-reporter": "0.0.2", "gulp-mocha": "^0.4.1", "gulp-uglify": "^0.3.0", "gulp-util": "^2.2.14", "gulp": "^3.6.2", "vinyl-source-stream2": "^0.1.1", "gulp-load-plugins": "^0.5.1", "gulp-rename": "^1.2.0", "gulp-header": "^1.0.2", "mocha": "^1.19.0", "zuul": "^1.6.5" }, "keywords": [ "test", "bdd", "assert" ], "main": "./lib/should.js", "license": "MIT" } should.js-4.0.4+dfsg.orig/lib/0000775000000000000000000000000012345335655014567 5ustar rootrootshould.js-4.0.4+dfsg.orig/lib/util.js0000664000000000000000000000623012345335655016103 0ustar rootroot/*! * Should * Copyright(c) 2010-2014 TJ Holowaychuk * MIT Licensed */ /** * Check if given obj just a primitive type wrapper * @param {Object} obj * @returns {boolean} * @api private */ exports.isWrapperType = function(obj) { return isNumber(obj) || isString(obj) || isBoolean(obj); }; /** * Merge object b with object a. * * var a = { foo: 'bar' } * , b = { bar: 'baz' }; * * utils.merge(a, b); * // => { foo: 'bar', bar: 'baz' } * * @param {Object} a * @param {Object} b * @return {Object} * @api private */ exports.merge = function(a, b){ if (a && b) { for (var key in b) { a[key] = b[key]; } } return a; }; function isArray(arr) { return isObject(arr) && (arr.__ArrayLike || Array.isArray(arr)); } exports.isArray = isArray; function isNumber(arg) { return typeof arg === 'number' || arg instanceof Number; } exports.isNumber = isNumber; function isString(arg) { return typeof arg === 'string' || arg instanceof String; } function isBoolean(arg) { return typeof arg === 'boolean' || arg instanceof Boolean; } exports.isBoolean = isBoolean; exports.isString = isString; function isBuffer(arg) { return typeof Buffer !== 'undefined' && arg instanceof Buffer; } exports.isBuffer = isBuffer; function isDate(d) { return isObject(d) && objectToString(d) === '[object Date]'; } exports.isDate = isDate; function objectToString(o) { return Object.prototype.toString.call(o); } function isObject(arg) { return typeof arg === 'object' && arg !== null; } exports.isObject = isObject; function isRegExp(re) { return isObject(re) && objectToString(re) === '[object RegExp]'; } exports.isRegExp = isRegExp; function isNullOrUndefined(arg) { return arg == null; } exports.isNullOrUndefined = isNullOrUndefined; function isNull(arg) { return arg === null; } exports.isNull = isNull; function isArguments(object) { return objectToString(object) === '[object Arguments]'; } exports.isArguments = isArguments; exports.isFunction = function(arg) { return typeof arg === 'function' || arg instanceof Function; }; function isError(e) { return (isObject(e) && objectToString(e) === '[object Error]') || (e instanceof Error); } exports.isError = isError; function isUndefined(arg) { return arg === void 0; } exports.isUndefined = isUndefined; exports.inspect = require('./inspect').inspect; exports.AssertionError = require('assert').AssertionError; var hasOwnProperty = Object.prototype.hasOwnProperty; exports.forOwn = function(obj, f, context) { for(var prop in obj) { if(hasOwnProperty.call(obj, prop)) { f.call(context, obj[prop], prop); } } }; var functionNameRE = /^\s*function\s*(\S*)\s*\(/; exports.functionName = function(f) { if(f.name) { return f.name; } var name = f.toString().match(functionNameRE)[1]; return name; }; exports.formatProp = function(name) { name = JSON.stringify('' + name); if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { name = name.substr(1, name.length - 2); } else { name = name.replace(/'/g, "\\'") .replace(/\\"/g, '"') .replace(/(^"|"$)/g, "'") .replace(/\\\\/g, '\\'); } return name; }should.js-4.0.4+dfsg.orig/lib/should.js0000664000000000000000000001040612345335655016424 0ustar rootroot/*! * Should * Copyright(c) 2010-2014 TJ Holowaychuk * MIT Licensed */ var util = require('./util'), AssertionError = util.AssertionError, inspect = util.inspect; /** * Our function should * @param obj * @returns {Assertion} */ var should = function(obj) { return new Assertion(util.isWrapperType(obj) ? obj.valueOf() : obj); }; /** * Initialize a new `Assertion` with the given _obj_. * * @param {*} obj * @api private */ var Assertion = should.Assertion = function Assertion(obj) { this.obj = obj; }; /** Way to extend Assertion function. It uses some logic to define only positive assertions and itself rule with negative assertion. All actions happen in subcontext and this method take care about negation. Potentially we can add some more modifiers that does not depends from state of assertion. */ Assertion.add = function(name, f, isGetter) { var prop = { enumerable: true }; prop[isGetter ? 'get' : 'value'] = function() { var context = new Assertion(this.obj); context.copy = context.copyIfMissing; context.anyOne = this.anyOne; try { f.apply(context, arguments); } catch(e) { //copy data from sub context to this this.copy(context); //check for fail if(e instanceof should.AssertionError) { //negative fail if(this.negate) { this.obj = context.obj; this.negate = false; return this; } this.assert(false); } // throw if it is another exception throw e; } //copy data from sub context to this this.copy(context); if(this.negate) { this.assert(false); } this.obj = context.obj; this.negate = false; return this; }; Object.defineProperty(Assertion.prototype, name, prop); }; Assertion.alias = function(from, to) { var desc = Object.getOwnPropertyDescriptor(Assertion.prototype, from); if(!desc) throw new Error('Alias ' + from + ' -> ' + to + ' could not be created as ' + from + ' not defined'); Object.defineProperty(Assertion.prototype, to, desc); }; should.AssertionError = AssertionError; should.format = function (value) { if(util.isDate(value) && typeof value.inspect !== 'function') return value.toISOString(); //show millis in dates return inspect(value, { depth: null }); }; should.use = function(f) { f(this, Assertion); return this; }; /** * Expose should to external world. */ exports = module.exports = should; /** * Expose api via `Object#should`. * * @api public */ Object.defineProperty(Object.prototype, 'should', { set: function() { }, get: function() { return should(this); }, configurable: true }); Assertion.prototype = { constructor: Assertion, assert: function(expr) { if(expr) return this; var params = this.params; var msg = params.message, generatedMessage = false; if(!msg) { msg = this.getMessage(); generatedMessage = true; } var err = new AssertionError({ message: msg, actual: this.obj, expected: params.expected, stackStartFunction: this.assert }); err.showDiff = params.showDiff; err.operator = params.operator; err.generatedMessage = generatedMessage; throw err; }, getMessage: function() { return 'expected ' + ('obj' in this.params ? this.params.obj: should.format(this.obj)) + (this.negate ? ' not ': ' ') + this.params.operator + ('expected' in this.params ? ' ' + should.format(this.params.expected) : ''); }, copy: function(other) { this.params = other.params; }, copyIfMissing: function(other) { if(!this.params) this.params = other.params; }, /** * Negation modifier. * * @api public */ get not() { this.negate = !this.negate; return this; }, /** * Any modifier - it affect on execution of sequenced assertion to do not check all, but any of * * @api public */ get any() { this.anyOne = true; return this; } }; should .use(require('./ext/assert')) .use(require('./ext/chain')) .use(require('./ext/bool')) .use(require('./ext/number')) .use(require('./ext/eql')) .use(require('./ext/type')) .use(require('./ext/string')) .use(require('./ext/property')) .use(require('./ext/error')) .use(require('./ext/match')) .use(require('./ext/contain')); should.js-4.0.4+dfsg.orig/lib/inspect.js0000664000000000000000000002772712345335655016611 0ustar rootroot// Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to permit // persons to whom the Software is furnished to do so, subject to the // following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. var util = require('./util'); var isBoolean = util.isBoolean; var isObject = util.isObject; var isUndefined = util.isUndefined; var isFunction = util.isFunction; var isString = util.isString; var isNumber = util.isNumber; var isNull = util.isNull; var isRegExp = util.isRegExp; var isDate = util.isDate; var isError = util.isError; var isArray = util.isArray; /** * Echos the value of a value. Trys to print the value out * in the best way possible given the different types. * * @param {Object} obj The object to print out. * @param {Object} opts Optional options object that alters the output. */ /* legacy: obj, showHidden, depth, colors*/ function inspect(obj, opts) { // default options var ctx = { seen: [], stylize: stylizeNoColor }; // legacy... if (arguments.length >= 3) ctx.depth = arguments[2]; if (arguments.length >= 4) ctx.colors = arguments[3]; if (isBoolean(opts)) { // legacy... ctx.showHidden = opts; } else if (opts) { // got an "options" object exports._extend(ctx, opts); } // set default options if (isUndefined(ctx.showHidden)) ctx.showHidden = false; if (isUndefined(ctx.depth)) ctx.depth = 2; if (isUndefined(ctx.colors)) ctx.colors = false; if (isUndefined(ctx.customInspect)) ctx.customInspect = true; if (ctx.colors) ctx.stylize = stylizeWithColor; return formatValue(ctx, obj, ctx.depth); } exports.inspect = inspect; // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics inspect.colors = { 'bold' : [1, 22], 'italic' : [3, 23], 'underline' : [4, 24], 'inverse' : [7, 27], 'white' : [37, 39], 'grey' : [90, 39], 'black' : [30, 39], 'blue' : [34, 39], 'cyan' : [36, 39], 'green' : [32, 39], 'magenta' : [35, 39], 'red' : [31, 39], 'yellow' : [33, 39] }; // Don't use 'blue' not visible on cmd.exe inspect.styles = { 'special': 'cyan', 'number': 'yellow', 'boolean': 'yellow', 'undefined': 'grey', 'null': 'bold', 'string': 'green', 'date': 'magenta', // "name": intentionally not styling 'regexp': 'red' }; function stylizeWithColor(str, styleType) { var style = inspect.styles[styleType]; if (style) { return '\u001b[' + inspect.colors[style][0] + 'm' + str + '\u001b[' + inspect.colors[style][1] + 'm'; } else { return str; } } function stylizeNoColor(str, styleType) { return str; } function arrayToHash(array) { var hash = {}; array.forEach(function(val, idx) { hash[val] = true; }); return hash; } function formatValue(ctx, value, recurseTimes) { // Provide a hook for user-specified inspect functions. // Check that value is an object with an inspect function on it if (ctx.customInspect && value && isFunction(value.inspect) && // Filter out the util module, it's inspect function is special value.inspect !== exports.inspect && // Also filter out any prototype objects using the circular check. !(value.constructor && value.constructor.prototype === value)) { var ret = value.inspect(recurseTimes, ctx); if (!isString(ret)) { ret = formatValue(ctx, ret, recurseTimes); } return ret; } // Primitive types cannot have properties var primitive = formatPrimitive(ctx, value); if (primitive) { return primitive; } // Look up the keys of the object. var keys = Object.keys(value); var visibleKeys = arrayToHash(keys); if (ctx.showHidden) { keys = Object.getOwnPropertyNames(value); } // This could be a boxed primitive (new String(), etc.), check valueOf() // NOTE: Avoid calling `valueOf` on `Date` instance because it will return // a number which, when object has some additional user-stored `keys`, // will be printed out. var formatted; var raw = value; try { // the .valueOf() call can fail for a multitude of reasons if (!isDate(value)) raw = value.valueOf(); } catch (e) { // ignore... } if (isString(raw)) { // for boxed Strings, we have to remove the 0-n indexed entries, // since they just noisey up the output and are redundant keys = keys.filter(function(key) { return !(key >= 0 && key < raw.length); }); } if (isError(value)) { return formatError(value); } // Some type of object without properties can be shortcutted. if (keys.length === 0) { if (isFunction(value)) { var name = value.name ? ': ' + value.name : ''; return ctx.stylize('[Function' + name + ']', 'special'); } if (isRegExp(value)) { return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); } if (isDate(value)) { return ctx.stylize(Date.prototype.toString.call(value), 'date'); } // now check the `raw` value to handle boxed primitives if (isString(raw)) { formatted = formatPrimitiveNoColor(ctx, raw); return ctx.stylize('[String: ' + formatted + ']', 'string'); } if (isNumber(raw)) { formatted = formatPrimitiveNoColor(ctx, raw); return ctx.stylize('[Number: ' + formatted + ']', 'number'); } if (isBoolean(raw)) { formatted = formatPrimitiveNoColor(ctx, raw); return ctx.stylize('[Boolean: ' + formatted + ']', 'boolean'); } } var base = '', array = false, braces = ['{', '}']; // Make Array say that they are Array if (isArray(value)) { array = true; braces = ['[', ']']; } // Make functions say that they are functions if (isFunction(value)) { var n = value.name ? ': ' + value.name : ''; base = ' [Function' + n + ']'; } // Make RegExps say that they are RegExps if (isRegExp(value)) { base = ' ' + RegExp.prototype.toString.call(value); } // Make dates with properties first say the date if (isDate(value)) { base = ' ' + Date.prototype.toUTCString.call(value); } // Make error with message first say the error if (isError(value)) { base = ' ' + formatError(value); } // Make boxed primitive Strings look like such if (isString(raw)) { formatted = formatPrimitiveNoColor(ctx, raw); base = ' ' + '[String: ' + formatted + ']'; } // Make boxed primitive Numbers look like such if (isNumber(raw)) { formatted = formatPrimitiveNoColor(ctx, raw); base = ' ' + '[Number: ' + formatted + ']'; } // Make boxed primitive Booleans look like such if (isBoolean(raw)) { formatted = formatPrimitiveNoColor(ctx, raw); base = ' ' + '[Boolean: ' + formatted + ']'; } if (keys.length === 0 && (!array || value.length === 0)) { return braces[0] + base + braces[1]; } if (recurseTimes < 0) { if (isRegExp(value)) { return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); } else { return ctx.stylize('[Object]', 'special'); } } ctx.seen.push(value); var output; if (array) { output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); } else { output = keys.map(function(key) { return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); }); } ctx.seen.pop(); return reduceToSingleString(output, base, braces); } function formatPrimitive(ctx, value) { if (isUndefined(value)) return ctx.stylize('undefined', 'undefined'); if (isString(value)) { var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') .replace(/'/g, "\\'") .replace(/\\"/g, '"') + '\''; return ctx.stylize(simple, 'string'); } if (isNumber(value)) { // Format -0 as '-0'. Strict equality won't distinguish 0 from -0, // so instead we use the fact that 1 / -0 < 0 whereas 1 / 0 > 0 . if (value === 0 && 1 / value < 0) return ctx.stylize('-0', 'number'); return ctx.stylize('' + value, 'number'); } if (isBoolean(value)) return ctx.stylize('' + value, 'boolean'); // For some reason typeof null is "object", so special case here. if (isNull(value)) return ctx.stylize('null', 'null'); } function formatPrimitiveNoColor(ctx, value) { var stylize = ctx.stylize; ctx.stylize = stylizeNoColor; var str = formatPrimitive(ctx, value); ctx.stylize = stylize; return str; } function formatError(value) { return '[' + Error.prototype.toString.call(value) + ']'; } function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { var output = []; for (var i = 0, l = value.length; i < l; ++i) { if (hasOwnProperty(value, String(i))) { output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true)); } else { output.push(''); } } keys.forEach(function(key) { if (!key.match(/^\d+$/)) { output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true)); } }); return output; } function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { var name, str, desc; desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; if (desc.get) { if (desc.set) { str = ctx.stylize('[Getter/Setter]', 'special'); } else { str = ctx.stylize('[Getter]', 'special'); } } else { if (desc.set) { str = ctx.stylize('[Setter]', 'special'); } } if (!hasOwnProperty(visibleKeys, key)) { name = '[' + key + ']'; } if (!str) { if (ctx.seen.indexOf(desc.value) < 0) { if (isNull(recurseTimes)) { str = formatValue(ctx, desc.value, null); } else { str = formatValue(ctx, desc.value, recurseTimes - 1); } if (str.indexOf('\n') > -1) { if (array) { str = str.split('\n').map(function(line) { return ' ' + line; }).join('\n').substr(2); } else { str = '\n' + str.split('\n').map(function(line) { return ' ' + line; }).join('\n'); } } } else { str = ctx.stylize('[Circular]', 'special'); } } if (isUndefined(name)) { if (array && key.match(/^\d+$/)) { return str; } name = JSON.stringify('' + key); if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { name = name.substr(1, name.length - 2); name = ctx.stylize(name, 'name'); } else { name = name.replace(/'/g, "\\'") .replace(/\\"/g, '"') .replace(/(^"|"$)/g, "'") .replace(/\\\\/g, '\\'); name = ctx.stylize(name, 'string'); } } return name + ': ' + str; } function reduceToSingleString(output, base, braces) { var length = output.reduce(function(prev, cur) { return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; }, 0); if (length > 60) { return braces[0] + (base === '' ? '' : base + '\n ') + ' ' + output.join(',\n ') + ' ' + braces[1]; } return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; } exports._extend = function _extend(origin, add) { // Don't do anything if add isn't an object if (!add || !isObject(add)) return origin; var keys = Object.keys(add); var i = keys.length; while (i--) { origin[keys[i]] = add[keys[i]]; } return origin; }; function hasOwnProperty(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } should.js-4.0.4+dfsg.orig/lib/ext/0000775000000000000000000000000012345335655015367 5ustar rootrootshould.js-4.0.4+dfsg.orig/lib/ext/type.js0000664000000000000000000000373512345335655016716 0ustar rootroot/*! * Should * Copyright(c) 2010-2014 TJ Holowaychuk * MIT Licensed */ var util = require('../util'); module.exports = function(should, Assertion) { Assertion.add('Number', function() { this.params = { operator: 'to be a number' }; this.assert(util.isNumber(this.obj)); }, true); Assertion.add('arguments', function() { this.params = { operator: 'to be arguments' }; this.assert(util.isArguments(this.obj)); }, true); Assertion.add('type', function(type, description) { this.params = { operator: 'to have type ' + type, message: description }; (typeof this.obj).should.be.exactly(type, description); }); Assertion.add('instanceof', function(constructor, description) { this.params = { operator: 'to be an instance of ' + util.functionName(constructor), message: description }; this.assert(Object(this.obj) instanceof constructor); }); Assertion.add('Function', function() { this.params = { operator: 'to be a function' }; this.assert(util.isFunction(this.obj)); }, true); Assertion.add('Object', function() { this.params = { operator: 'to be an object' }; this.assert(util.isObject(this.obj)); }, true); Assertion.add('String', function() { this.params = { operator: 'to be a string' }; this.assert(util.isString(this.obj)); }, true); Assertion.add('Array', function() { this.params = { operator: 'to be an array' }; this.assert(util.isArray(this.obj)); }, true); Assertion.add('Boolean', function() { this.params = { operator: 'to be a boolean' }; this.assert(util.isBoolean(this.obj)); }, true); Assertion.add('Error', function() { this.params = { operator: 'to be an error' }; this.assert(util.isError(this.obj)); }, true); Assertion.add('null', function() { this.params = { operator: 'to be null' }; this.assert(this.obj === null); }, true); Assertion.alias('null', 'Null'); Assertion.alias('instanceof', 'instanceOf'); }; should.js-4.0.4+dfsg.orig/lib/ext/string.js0000664000000000000000000000110412345335655017227 0ustar rootroot/*! * Should * Copyright(c) 2010-2014 TJ Holowaychuk * MIT Licensed */ module.exports = function(should, Assertion) { Assertion.add('startWith', function(str, description) { this.params = { operator: 'to start with ' + should.format(str), message: description }; this.assert(0 === this.obj.indexOf(str)); }); Assertion.add('endWith', function(str, description) { this.params = { operator: 'to end with ' + should.format(str), message: description }; this.assert(this.obj.indexOf(str, this.obj.length - str.length) >= 0); }); };should.js-4.0.4+dfsg.orig/lib/ext/property.js0000664000000000000000000001420612345335655017614 0ustar rootroot/*! * Should * Copyright(c) 2010-2014 TJ Holowaychuk * MIT Licensed */ var util = require('../util'), eql = require('../eql'); var aSlice = Array.prototype.slice; module.exports = function(should, Assertion) { var i = should.format; Assertion.add('enumerable', function(name, val) { name = String(name); this.params = { operator:"to have enumerable property " + util.formatProp(name) }; this.assert(this.obj.propertyIsEnumerable(name)); if(arguments.length > 1){ this.params.operator += " equal to "+i(val); this.assert(eql(val, this.obj[name])); } }); Assertion.add('property', function(name, val) { name = String(name); if(arguments.length > 1) { var p = {}; p[name] = val; this.have.properties(p); } else { this.have.properties(name); } this.obj = this.obj[name]; }); Assertion.add('properties', function(names) { var values = {}; if(arguments.length > 1) { names = aSlice.call(arguments); } else if(!util.isArray(names)) { if(util.isString(names)) { names = [names]; } else { values = names; names = Object.keys(names); } } var obj = Object(this.obj), missingProperties = []; //just enumerate properties and check if they all present names.forEach(function(name) { if(!(name in obj)) missingProperties.push(util.formatProp(name)); }); var props = missingProperties; if(props.length === 0) { props = names.map(util.formatProp); } else if(this.anyOne) { props = names.filter(function(name) { return missingProperties.indexOf(util.formatProp(name)) < 0; }).map(util.formatProp); } var operator = (props.length === 1 ? 'to have property ' : 'to have '+(this.anyOne? 'any of ' : '')+'properties ') + props.join(', '); this.params = { operator: operator }; //check that all properties presented //or if we request one of them that at least one them presented this.assert(missingProperties.length === 0 || (this.anyOne && missingProperties.length != names.length)); // check if values in object matched expected var valueCheckNames = Object.keys(values); if(valueCheckNames.length) { var wrongValues = []; props = []; // now check values, as there we have all properties valueCheckNames.forEach(function(name) { var value = values[name]; if(!eql(obj[name], value)) { wrongValues.push(util.formatProp(name) + ' of ' + i(value) + ' (got ' + i(obj[name]) + ')'); } else { props.push(util.formatProp(name) + ' of ' + i(value)); } }); if((wrongValues.length !== 0 && !this.anyOne) || (this.anyOne && props.length === 0)) { props = wrongValues; } operator = (props.length === 1 ? 'to have property ' : 'to have '+(this.anyOne? 'any of ' : '')+'properties ') + props.join(', '); this.params = { operator: operator }; //if there is no not matched values //or there is at least one matched this.assert(wrongValues.length === 0 || (this.anyOne && wrongValues.length != valueCheckNames.length)); } }); Assertion.add('length', function(n, description) { this.have.property('length', n, description); }); Assertion.alias('length', 'lengthOf'); var hasOwnProperty = Object.prototype.hasOwnProperty; Assertion.add('ownProperty', function(name, description) { name = String(name); this.params = { operator: 'to have own property ' + util.formatProp(name), message: description }; this.assert(hasOwnProperty.call(this.obj, name)); this.obj = this.obj[name]; }); Assertion.alias('ownProperty', 'hasOwnProperty'); Assertion.add('empty', function() { this.params = { operator: 'to be empty' }; if(util.isString(this.obj) || util.isArray(this.obj) || util.isArguments(this.obj)) { this.have.property('length', 0); } else { var obj = Object(this.obj); // wrap to reference for booleans and numbers for(var prop in obj) { this.have.not.ownProperty(prop); } } }, true); Assertion.add('keys', function(keys) { if(arguments.length > 1) keys = aSlice.call(arguments); else if(arguments.length === 1 && util.isString(keys)) keys = [ keys ]; else if(arguments.length === 0) keys = []; keys = keys.map(String); var obj = Object(this.obj); // first check if some keys are missing var missingKeys = []; keys.forEach(function(key) { if(!hasOwnProperty.call(this.obj, key)) missingKeys.push(util.formatProp(key)); }, this); // second check for extra keys var extraKeys = []; Object.keys(obj).forEach(function(key) { if(keys.indexOf(key) < 0) { extraKeys.push(util.formatProp(key)); } }); var verb = keys.length === 0 ? 'to be empty' : 'to have ' + (keys.length === 1 ? 'key ' : 'keys '); this.params = { operator: verb + keys.map(util.formatProp).join(', ')}; if(missingKeys.length > 0) this.params.operator += '\n\tmissing keys: ' + missingKeys.join(', '); if(extraKeys.length > 0) this.params.operator += '\n\textra keys: ' + extraKeys.join(', '); this.assert(missingKeys.length === 0 && extraKeys.length === 0); }); Assertion.alias("keys", "key"); Assertion.add('propertyByPath', function(properties) { if(arguments.length > 1) properties = aSlice.call(arguments); else if(arguments.length === 1 && util.isString(properties)) properties = [ properties ]; else if(arguments.length === 0) properties = []; var allProps = properties.map(util.formatProp); properties = properties.map(String); var obj = should(Object(this.obj)); var foundProperties = []; var currentProperty; while(currentProperty = properties.shift()) { this.params = { operator: 'to have property by path ' + allProps.join(', ') + ' - failed on ' + util.formatProp(currentProperty) }; obj = obj.have.property(currentProperty); foundProperties.push(currentProperty); } this.params = { operator: 'to have property by path ' + allProps.join(', ') }; this.obj = obj.obj; }); }; should.js-4.0.4+dfsg.orig/lib/ext/number.js0000664000000000000000000000250012345335655017212 0ustar rootroot/*! * Should * Copyright(c) 2010-2014 TJ Holowaychuk * MIT Licensed */ module.exports = function(should, Assertion) { Assertion.add('NaN', function() { this.params = { operator: 'to be NaN' }; this.assert(this.obj !== this.obj); }, true); Assertion.add('Infinity', function() { this.params = { operator: 'to be Infinity' }; this.is.a.Number .and.not.a.NaN .and.assert(!isFinite(this.obj)); }, true); Assertion.add('within', function(start, finish, description) { this.params = { operator: 'to be within ' + start + '..' + finish, message: description }; this.assert(this.obj >= start && this.obj <= finish); }); Assertion.add('approximately', function(value, delta, description) { this.params = { operator: 'to be approximately ' + value + " ±" + delta, message: description }; this.assert(Math.abs(this.obj - value) <= delta); }); Assertion.add('above', function(n, description) { this.params = { operator: 'to be above ' + n, message: description }; this.assert(this.obj > n); }); Assertion.add('below', function(n, description) { this.params = { operator: 'to be below ' + n, message: description }; this.assert(this.obj < n); }); Assertion.alias('above', 'greaterThan'); Assertion.alias('below', 'lessThan'); }; should.js-4.0.4+dfsg.orig/lib/ext/match.js0000664000000000000000000000677212345335655017035 0ustar rootroot/*! * Should * Copyright(c) 2010-2014 TJ Holowaychuk * MIT Licensed */ var util = require('../util'), eql = require('../eql'); module.exports = function(should, Assertion) { var i = should.format; Assertion.add('match', function(other, description) { this.params = { operator: 'to match ' + i(other), message: description }; if(!eql(this.obj, other)) { if(util.isRegExp(other)) { // something - regex if(util.isString(this.obj)) { this.assert(other.exec(this.obj)); } else if(util.isArray(this.obj)) { this.obj.forEach(function(item) { this.assert(other.exec(item));// should we try to convert to String and exec? }, this); } else if(util.isObject(this.obj)) { var notMatchedProps = [], matchedProps = []; util.forOwn(this.obj, function(value, name) { if(other.exec(value)) matchedProps.push(util.formatProp(name)); else notMatchedProps.push(util.formatProp(name) + ' (' + i(value) +')'); }, this); if(notMatchedProps.length) this.params.operator += '\n\tnot matched properties: ' + notMatchedProps.join(', '); if(matchedProps.length) this.params.operator += '\n\tmatched properties: ' + matchedProps.join(', '); this.assert(notMatchedProps.length == 0); } // should we try to convert to String and exec? } else if(util.isFunction(other)) { var res; try { res = other(this.obj); } catch(e) { if(e instanceof should.AssertionError) { this.params.operator += '\n\t' + e.message; } throw e; } if(res instanceof Assertion) { this.params.operator += '\n\t' + res.getMessage(); } //if we throw exception ok - it is used .should inside if(util.isBoolean(res)) { this.assert(res); // if it is just boolean function assert on it } } else if(util.isObject(other)) { // try to match properties (for Object and Array) notMatchedProps = []; matchedProps = []; util.forOwn(other, function(value, key) { try { should(this.obj[key]).match(value); matchedProps.push(util.formatProp(key)); } catch(e) { if(e instanceof should.AssertionError) { notMatchedProps.push(util.formatProp(key) + ' (' + i(this.obj[key]) + ')'); } else { throw e; } } }, this); if(notMatchedProps.length) this.params.operator += '\n\tnot matched properties: ' + notMatchedProps.join(', '); if(matchedProps.length) this.params.operator += '\n\tmatched properties: ' + matchedProps.join(', '); this.assert(notMatchedProps.length == 0); } else { this.assert(false); } } }); Assertion.add('matchEach', function(other, description) { this.params = { operator: 'to match each ' + i(other), message: description }; var f = other; if(util.isRegExp(other)) f = function(it) { return !!other.exec(it); }; else if(!util.isFunction(other)) f = function(it) { return eql(it, other); }; util.forOwn(this.obj, function(value, key) { var res = f(value, key); //if we throw exception ok - it is used .should inside if(util.isBoolean(res)) { this.assert(res); // if it is just boolean function assert on it } }, this); }); };should.js-4.0.4+dfsg.orig/lib/ext/error.js0000664000000000000000000000407512345335655017064 0ustar rootroot/*! * Should * Copyright(c) 2010-2014 TJ Holowaychuk * MIT Licensed */ var util = require('../util'); module.exports = function(should, Assertion) { var i = should.format; Assertion.add('throw', function(message, properties) { var fn = this.obj , err = {} , errorInfo = '' , thrown = false; var errorMatched = true; try { fn(); } catch(e) { thrown = true; err = e; } if(thrown) { if(message) { if('string' == typeof message) { errorMatched = message == err.message; } else if(message instanceof RegExp) { errorMatched = message.test(err.message); } else if('function' == typeof message) { errorMatched = err instanceof message; } else if(util.isObject(message)) { try { err.should.match(message); } catch(e) { if(e instanceof should.AssertionError) { errorInfo = ": " + e.message; errorMatched = false; } else { throw e; } } } if(!errorMatched) { if('string' == typeof message || message instanceof RegExp) { errorInfo = " with a message matching " + i(message) + ", but got '" + err.message + "'"; } else if('function' == typeof message) { errorInfo = " of type " + util.functionName(message) + ", but got " + util.functionName(err.constructor); } } else if('function' == typeof message && properties) { try { err.should.match(properties); } catch(e) { if(e instanceof should.AssertionError) { errorInfo = ": " + e.message; errorMatched = false; } else { throw e; } } } } else { errorInfo = " (got " + i(err) + ")"; } } this.params = { operator: 'to throw exception' + errorInfo }; this.assert(thrown); this.assert(errorMatched); }); Assertion.alias('throw', 'throwError'); };should.js-4.0.4+dfsg.orig/lib/ext/eql.js0000664000000000000000000000113012345335655016501 0ustar rootroot/*! * Should * Copyright(c) 2010-2014 TJ Holowaychuk * MIT Licensed */ var eql = require('../eql'); module.exports = function(should, Assertion) { Assertion.add('eql', function(val, description) { this.params = { operator: 'to equal', expected: val, showDiff: true, message: description }; this.assert(eql(val, this.obj)); }); Assertion.add('equal', function(val, description) { this.params = { operator: 'to be', expected: val, showDiff: true, message: description }; this.assert(val === this.obj); }); Assertion.alias('equal', 'exactly'); };should.js-4.0.4+dfsg.orig/lib/ext/contain.js0000664000000000000000000000630112345335655017360 0ustar rootroot/*! * Should * Copyright(c) 2010-2014 TJ Holowaychuk * MIT Licensed */ var util = require('../util'), eql = require('../eql'); module.exports = function(should, Assertion) { var i = should.format; Assertion.add('containEql', function(other) { this.params = { operator: 'to contain ' + i(other) }; var obj = this.obj; if(util.isArray(obj)) { this.assert(obj.some(function(item) { return eql(item, other); })); } else if(util.isString(obj)) { // expect obj to be string this.assert(obj.indexOf(String(other)) >= 0); } else if(util.isObject(obj)) { // object contains object case util.forOwn(other, function(value, key) { obj.should.have.property(key, value); }); } else { //other uncovered cases this.assert(false); } }); Assertion.add('containDeepOrdered', function(other) { this.params = { operator: 'to contain ' + i(other) }; var obj = this.obj; if(util.isArray(obj)) { if(util.isArray(other)) { var otherIdx = 0; obj.forEach(function(item) { try { should(item).not.be.Null.and.containDeep(other[otherIdx]); otherIdx++; } catch(e) { if(e instanceof should.AssertionError) { return; } throw e; } }, this); this.assert(otherIdx == other.length); //search array contain other as sub sequence } else { this.assert(false); } } else if(util.isString(obj)) {// expect other to be string this.assert(obj.indexOf(String(other)) >= 0); } else if(util.isObject(obj)) {// object contains object case if(util.isObject(other)) { util.forOwn(other, function(value, key) { should(obj[key]).not.be.Null.and.containDeep(value); }); } else {//one of the properties contain value this.assert(false); } } else { this.eql(other); } }); Assertion.add('containDeep', function(other) { this.params = { operator: 'to contain ' + i(other) }; var obj = this.obj; if(util.isArray(obj)) { if(util.isArray(other)) { var usedKeys = {}; other.forEach(function(otherItem) { this.assert(obj.some(function(item, index) { if(index in usedKeys) return false; try { should(item).not.be.Null.and.containDeep(otherItem); usedKeys[index] = true; return true; } catch(e) { if(e instanceof should.AssertionError) { return false; } throw e; } })); }, this); } else { this.assert(false); } } else if(util.isString(obj)) {// expect other to be string this.assert(obj.indexOf(String(other)) >= 0); } else if(util.isObject(obj)) {// object contains object case if(util.isObject(other)) { util.forOwn(other, function(value, key) { should(obj[key]).not.be.Null.and.containDeep(value); }); } else {//one of the properties contain value this.assert(false); } } else { this.eql(other); } }); }; should.js-4.0.4+dfsg.orig/lib/ext/chain.js0000664000000000000000000000063012345335655017006 0ustar rootroot/*! * Should * Copyright(c) 2010-2014 TJ Holowaychuk * MIT Licensed */ module.exports = function(should, Assertion) { function addLink(name) { Object.defineProperty(Assertion.prototype, name, { get: function() { return this; }, enumerable: true }); } ['an', 'of', 'a', 'and', 'be', 'have', 'with', 'is', 'which', 'the'].forEach(addLink); };should.js-4.0.4+dfsg.orig/lib/ext/bool.js0000664000000000000000000000076312345335655016666 0ustar rootroot/*! * Should * Copyright(c) 2010-2014 TJ Holowaychuk * MIT Licensed */ module.exports = function(should, Assertion) { Assertion.add('true', function() { this.is.exactly(true); }, true); Assertion.alias('true', 'True'); Assertion.add('false', function() { this.is.exactly(false); }, true); Assertion.alias('false', 'False'); Assertion.add('ok', function() { this.params = { operator: 'to be truthy' }; this.assert(this.obj); }, true); };should.js-4.0.4+dfsg.orig/lib/ext/assert.js0000664000000000000000000000233212345335655017226 0ustar rootroot/*! * Should * Copyright(c) 2010-2014 TJ Holowaychuk * MIT Licensed */ var util = require('../util') , assert = require('assert') , AssertionError = assert.AssertionError; module.exports = function(should) { var i = should.format; /** * Expose assert to should * * This allows you to do things like below * without require()ing the assert module. * * should.equal(foo.bar, undefined); * */ util.merge(should, assert); /** * Assert _obj_ exists, with optional message. * * @param {*} obj * @param {String} [msg] * @api public */ should.exist = should.exists = function(obj, msg) { if(null == obj) { throw new AssertionError({ message: msg || ('expected ' + i(obj) + ' to exist'), stackStartFunction: should.exist }); } }; /** * Asserts _obj_ does not exist, with optional message. * * @param {*} obj * @param {String} [msg] * @api public */ should.not = {}; should.not.exist = should.not.exists = function(obj, msg) { if(null != obj) { throw new AssertionError({ message: msg || ('expected ' + i(obj) + ' to not exist'), stackStartFunction: should.not.exist }); } }; };should.js-4.0.4+dfsg.orig/lib/eql.js0000664000000000000000000000651012345335655015710 0ustar rootroot/*! * Should * Copyright(c) 2010-2014 TJ Holowaychuk * MIT Licensed */ // Taken from node's assert module, because it sucks // and exposes next to nothing useful. var util = require('./util'); module.exports = _deepEqual; var pSlice = Array.prototype.slice; function _deepEqual(actual, expected) { // 7.1. All identical values are equivalent, as determined by ===. if (actual === expected) { return true; } else if (util.isBuffer(actual) && util.isBuffer(expected)) { if (actual.length != expected.length) return false; for (var i = 0; i < actual.length; i++) { if (actual[i] !== expected[i]) return false; } return true; // 7.2. If the expected value is a Date object, the actual value is // equivalent if it is also a Date object that refers to the same time. } else if (util.isDate(actual) && util.isDate(expected)) { return actual.getTime() === expected.getTime(); // 7.3 If the expected value is a RegExp object, the actual value is // equivalent if it is also a RegExp object with the same source and // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`). } else if (util.isRegExp(actual) && util.isRegExp(expected)) { return actual.source === expected.source && actual.global === expected.global && actual.multiline === expected.multiline && actual.lastIndex === expected.lastIndex && actual.ignoreCase === expected.ignoreCase; // 7.4. Other pairs that do not both pass typeof value == 'object', // equivalence is determined by ==. } else if (!util.isObject(actual) && !util.isObject(expected)) { return actual == expected; // 7.5 For all other Object pairs, including Array objects, equivalence is // determined by having the same number of owned properties (as verified // with Object.prototype.hasOwnProperty.call), the same set of keys // (although not necessarily the same order), equivalent values for every // corresponding key, and an identical 'prototype' property. Note: this // accounts for both named and indexed properties on Arrays. } else { return objEquiv(actual, expected); } } function objEquiv (a, b) { if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b)) return false; // an identical 'prototype' property. if (a.prototype !== b.prototype) return false; //~~~I've managed to break Object.keys through screwy arguments passing. // Converting to array solves the problem. if (util.isArguments(a)) { if (!util.isArguments(b)) { return false; } a = pSlice.call(a); b = pSlice.call(b); return _deepEqual(a, b); } try{ var ka = Object.keys(a), kb = Object.keys(b), key, i; } catch (e) {//happens when one is a string literal and the other isn't return false; } // having the same number of owned properties (keys incorporates // hasOwnProperty) if (ka.length != kb.length) return false; //the same set of keys (although not necessarily the same order), ka.sort(); kb.sort(); //~~~cheap key test for (i = ka.length - 1; i >= 0; i--) { if (ka[i] != kb[i]) return false; } //equivalent values for every corresponding key, and //~~~possibly expensive deep test for (i = ka.length - 1; i >= 0; i--) { key = ka[i]; if (!_deepEqual(a[key], b[key])) return false; } return true; } should.js-4.0.4+dfsg.orig/index.js0000664000000000000000000000005512345335655015466 0ustar rootroot module.exports = require('./lib/should.js');should.js-4.0.4+dfsg.orig/gulpfile.js0000664000000000000000000000224112345335655016165 0ustar rootrootvar gulp = require('gulp'); var $ = require('gulp-load-plugins')({ lazy: false }); var source = require('vinyl-source-stream2'); var browserify = require('browserify'); var path = require('path'); var pkg = require('./package.json'); var banner = ['/**', ' * <%= pkg.name %> - <%= pkg.description %>', ' * @version v<%= pkg.version %>', ' * @author <%= pkg.author %>', ' * @link <%= pkg.homepage %>', ' * @license <%= pkg.license %>', ' */', ''].join('\n'); gulp.task('test', function() { return gulp.src('test/**/*.test.js', { read: false }) .pipe($.mocha({ reporter: 'mocha-better-spec-reporter' })); }); gulp.task('script', function () { var bundleStream = browserify({ entries: './lib/should.js', builtins: ['util', 'assert'] }) .bundle({ insertGlobals: false, detectGlobals: false, standalone: 'Should' }); return bundleStream .pipe(source('should.js')) .pipe($.header(banner, { pkg : pkg } )) .pipe(gulp.dest('./')) .pipe($.uglify()) .pipe($.header(banner, { pkg : pkg } )) .pipe($.rename('should.min.js')) .pipe(gulp.dest('./')); });should.js-4.0.4+dfsg.orig/examples/0000775000000000000000000000000012345335655015637 5ustar rootrootshould.js-4.0.4+dfsg.orig/examples/runner.js0000664000000000000000000000246112345335655017511 0ustar rootroot /** * Module dependencies. */ var should = require('../'); function test(name, fn){ try { fn(); } catch (err) { console.log(' \x1b[31m%s', name); console.log(' %s\x1b[0m', err.stack); return; } console.log(' √ \x1b[32m%s\x1b[0m', name); } function Point(x, y) { this.x = x; this.y = y; this.sub = function(other){ return new Point( this.x - other.x , this.y - other.y); } } console.log(); test('new Point(x, y)', function(){ var point = new Point(50, 100); point.should.be.an.instanceof(Point); point.should.have.property('x', 50); point.should.have.property('y', 100); }); test('Point#sub()', function(){ var a = new Point(50, 100) , b = new Point(20, 50); a.sub(b).should.be.an.instanceof(Point); a.sub(b).should.not.equal(a); a.sub(b).should.not.equal(b); a.sub(b).should.have.property('x', 30); a.sub(b).should.have.property('y', 50); }); test('Point#add()', function(){ var point = new Point(50, 100); point.should.have.not.property('add'); }); test('Math#sin()', function(){ Math.sin(12).should.be.approximately(-0.5365, 1e-3); }); test('Math#cos()', function(){ Math.cos(0).should.not.be.approximately(10, 1e-3); }); test('Math#log()', function(){ Math.log(10).should.be.approximately(2.3, 1e-1); }); console.log();should.js-4.0.4+dfsg.orig/Readme.md0000664000000000000000000004561012345335655015546 0ustar rootroot# should.js [![Build Status](https://travis-ci.org/shouldjs/should.js.svg?branch=master)](https://travis-ci.org/shouldjs/should.js) [![Selenium Test Status](https://saucelabs.com/browser-matrix/shouldjs.svg)](https://saucelabs.com/u/shouldjs) _should_ is an expressive, readable, framework-agnostic assertion library. The main goals of this library are __to be expressive__ and __to be helpful__. It keeps your test code clean, and your error messages helpful. _should_ extends the `Object.prototype` with a single non-enumerable getter that allows you to express how that object should behave. It also returns itself when required with `require`. ### Breaking changes for 4.x Please check [wiki](https://github.com/shouldjs/should.js/wiki/Breaking-changes-4.x). ## Example ```javascript var should = require('should'); var user = { name: 'tj' , pets: ['tobi', 'loki', 'jane', 'bandit'] }; user.should.have.property('name', 'tj'); user.should.have.property('pets').with.lengthOf(4); // If the object was created with Object.create(null) // then it doesn't inherit `Object.prototype`, so it will not have `.should` getter // so you can do: should(user).have.property('name', 'tj'); // also you can test in that way for null's should(null).not.be.ok; someAsyncTask(foo, function(err, result){ should.not.exist(err); should.exist(result); result.bar.should.equal(foo); }); ``` ## To begin 1. Install it: ```bash $ npm install should --save-dev ``` 2. Require it and use: ```js var should = require('should'); (5).should.be.exactly(5).and.be.a.Number; ``` ## In browser Well, even when browsers by complains of authors has 100% es5 support, it does not mean it has not bugs. Please see [wiki](https://github.com/shouldjs/should.js/wiki/Known-Bugs) for known bugs. If you want to use _should_ in browser, use the `should.js` file in the root of this repository, or build it yourself. To build a fresh version: ```bash $ npm install $ gulp script ``` The script is exported to `window.Should`. It is the same as using `should` statically: ```js Should(5).be.exactly(5) ``` Also, in the case of node.js, `Object.prototype` is extended with `should` (hence the capital S in `window.Should`): ```js window.should.be.exactly(window); // the same // window is host object should.be.exactly(window); // you should not really care about it (5).should.be.exactly(5); ``` You can easy install it with npm or bower: ``` npm install should --save-dev # or bower install shouldjs/should.js ``` ## Static should and assert module For some rare cases _should_ can be used statically, without `Object.prototype`. It can be a replacement for the node assert module: ```javascript assert.fail(actual, expected, message, operator) // just write wrong should assertion assert(value, message), assert.ok(value, [message]) // should(value).ok assert.equal(actual, expected, [message]) // should(actual).eql(expected, [message]) assert.notEqual(actual, expected, [message]) // should(actual).not.eql(expected, [message]) assert.deepEqual(actual, expected, [message]) // should(actual).eql(expected, [message]) assert.notDeepEqual(actual, expected, [message]) // should(actual).not.eql(expected, [message]) assert.strictEqual(actual, expected, [message]) // should(actual).equal(expected, [message]) assert.notStrictEqual(actual, expected, [message]) // should(actual).not.equal(expected, [message]) assert.throws(block, [error], [message]) // should(block).throw([error]) assert.doesNotThrow(block, [message]) // should(block).not.throw([error]) assert.ifError(value) // should(value).Error (to check if it is error) or should(value).not.ok (to check that it is falsy) ``` ## .not `.not` negates the current assertion. ## .any `.any` allow for assertions with multiple parameters to assert any of the parameters (but not all). This is similar to the native JavaScript [array.some](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some). # Assertions ## chaining assertions Every assertion will return a `should.js`-wrapped Object, so assertions can be chained. To help chained assertions read more clearly, you can use the following helpers anywhere in your chain: `.an`, `.of`, `.a`, `.and`, `.be`, `.have`, `.with`, `.is`, `.which`. Use them for better readability; they do nothing at all. For example: ```js user.should.be.an.instanceOf(Object).and.have.property('name', 'tj'); user.pets.should.be.instanceof(Array).and.have.lengthOf(4); ``` Almost all assertions return the same object - so you can easy chain them. But some (eg: `.length` and `.property`) move the assertion object to a property value, so be careful. ## .ok Assert that a chained object is truthy in javascript (ie: not '', null, undefined, 0 , NaN). Assert truthfulness: ```javascript true.should.be.ok; 'yay'.should.be.ok; (1).should.be.ok; ({}).should.be.ok; ``` or negated: ```javascript false.should.not.be.ok; ''.should.not.be.ok; (0).should.not.be.ok; ``` *Warning:* No assertions can be performed on null and undefined values. e.g. ```js undefined.should.not.be.ok; ``` will give you `Uncaught TypeError: Cannot read property 'should' of undefined)`. In order to test for null use ```js (err === null).should.be.true; ``` ## .true Assert if a chained object === true: ```javascript true.should.be.true; '1'.should.not.be.true; ``` ## .false Assert if a chained object === false: ```javascript false.should.be.false; (0).should.not.be.false; ``` ## .eql(otherValue) Assert if a chained object is *equal* to otherValue. The object is compared by its actual content, not just reference equality. ```javascript ({ foo: 'bar' }).should.eql({ foo: 'bar' }); [1,2,3].should.eql([1,2,3]); // see next example it is correct, even if it is different types, but actual content the same [1, 2, 3].should.eql({ '0': 1, '1': 2, '2': 3 }); ``` ## .equal(otherValue) and .exactly(otherValue) Asserts if a chained object is strictly equal to `otherValue` (using `===` - no type conversion for primitive types and reference equivalence for reference types). ```javascript (4).should.equal(4); 'test'.should.equal('test'); [1,2,3].should.not.equal([1,2,3]); (4).should.be.exactly(4); ``` ## .startWith(str) Assert that a string starts with `str`. ```javascript 'foobar'.should.startWith('foo'); 'foobar'.should.not.startWith('bar'); ``` ## .endWith(str) Assert that a string ends with `str`. ```javascript 'foobar'.should.endWith('bar'); 'foobar'.should.not.endWith('foo'); ``` ## .within(from, to) Assert inclusive numeric range (`<= to` and `>= from`): ```javascript user.age.should.be.within(5, 50); (5).should.be.within(5, 10).and.within(5, 5); ``` ## .approximately(num, delta) Assert a floating point number is near `num` within the `delta` margin: ```javascript (99.99).should.be.approximately(100, 0.1); ``` ## .above(num) and .greaterThan(num) Assert a numeric value is above the given value (`> num`): ```javascript user.age.should.be.above(5); user.age.should.not.be.above(100); (5).should.be.above(0); (5).should.not.be.above(5); ``` ## .below(num) and .lessThan(num) Assert a numeric value is below the given value (`< num`): ```javascript user.age.should.be.below(100); user.age.should.not.be.below(5); (5).should.be.below(6); (5).should.not.be.below(5); ``` ## .NaN Assert a numeric value is NaN: ```javascript (undefined + 0).should.be.NaN; ``` ## .Infinity Assert a numeric value is Infinity: ```javascript (1/0).should.be.Infinity; ``` ## .type(str) Assert a given object is of a particular type (using __typeof__ operator): ```javascript user.should.be.type('object'); 'test'.should.be.type('string'); ``` ## .instanceof(constructor) and .instanceOf(constructor) Assert a given object is an instance of `constructor` (using __instanceof__ operator): ```javascript user.should.be.an.instanceof(User); [].should.be.an.instanceOf(Array); ``` ## .arguments Assert a given object is an `Arguments`: ```javascript var args = (function(){ return arguments; })(1,2,3); args.should.be.arguments; [].should.not.be.arguments; ``` ## .Object, .Number, .Array, .Boolean, .Function, .String, .Error Assert a given object is instance of the given constructor (shortcut for `.instanceof` assertion). ```javascript ({}).should.be.an.Object; (1).should.be.a.Number; [].should.be.an.Array.and.an.Object; (true).should.be.a.Boolean; ''.should.be.a.String; ``` ## .enumerable(name[, value]) Assert a property exists, is enumerable, and has an optional value (compare using `.eql`): ```javascript 'asd'.should.not.have.enumerable('0'); user.should.have.enumerable('name'); user.should.have.enumerable('age', 15); user.should.not.have.enumerable('rawr'); user.should.not.have.enumerable('age', 0); [1, 2].should.have.enumerable('0', 1); ``` ## .property(name[, value]) Assert property exists and has an optional value (compare using `.eql`): ```javascript user.should.have.property('name'); user.should.have.property('age', 15); user.should.not.have.property('rawr'); user.should.not.have.property('age', 0); [1, 2].should.have.property('0', 1); ``` __NB__ `.property` changes the chain's object to the given property's value, so be careful when chaining after `.property`! ## .properties(propName1, propName2, ...) or .properties([propName1, propName2, ...]) or .properties(obj) `obj` should be an object that maps properties to their actual values. Assert all given properties exist and have given values (compare using `.eql`): ```javascript user.should.have.properties('name', 'age'); user.should.have.properties(['name', 'age']); user.should.have.properties({ name: 'denis', age: 24 }); ``` ## .length(number) and .lengthOf(number) Assert _length_ property exists and has a value of the given number (shortcut for `.property('length', number)`): ```javascript user.pets.should.have.length(5); user.pets.should.have.a.lengthOf(5); ({ length: 10}).should.have.length(10); ``` __NB__ `.length` and `.lengthOf` change the chain's object to the given length value, so be careful when chaining! ## .ownProperty(str) and .hasOwnProperty(str) Assert given object has own property (using `.hasOwnProperty`): ```javascript ({ foo: 'bar' }).should.have.ownProperty('foo').equal('bar'); ``` __NB__ `.ownProperty` and `.hasOwnProperty` change the chain's object to the given property value, so be careful when chaining! ## .empty Assert given value is empty. Strings, arrays, arguments with a length of 0, and objects without their own properties, are considered empty. ```javascript [].should.be.empty; ''.should.be.empty; ({}).should.be.empty; (function() { arguments.should.be.empty; })(); ``` ## .keys([key1, key2, ...]) and .keys(key1, key2, ...) and .key(key) Assert own object keys, which must match _exactly_, and will fail if you omit a key or two: ```javascript var obj = { foo: 'bar', baz: 'raz' }; obj.should.have.keys('foo', 'baz'); obj.should.have.keys(['foo', 'baz']); ({}).should.have.keys(); ({}).should.have.keys('key'); //fail AssertionError: expected {} to have key 'key'missing keys: 'key' ``` ## .propertyByPath([name1, ...]) or .propertyByPath(name1, name2, ...) Assert property exists and has optional value (compare using `.eql`): ```javascript var obj = { foo: 'bar', baz: 'raz', zad: { a: 10 } }; obj.should.have.propertyByPath('zad', 'a'); obj.should.not.have.propertyByPath(0, 1, 2); ``` __NB__ `.propertyByPath` changes the chain's object to the given property's value if found ## .containEql(otherValue) Assert given value to contain something *.eql* to otherValue. See examples to understand better: ```javascript 'hello boy'.should.containEql('boy'); [1,2,3].should.containEql(3); [[1],[2],[3]].should.containEql([3]); [[1],[2],[3, 4]].should.not.containEql([3]); ({ b: 10 }).should.containEql({ b: 10 }); ([1, 2, { a: 10 }]).should.containEql({ a: 10 }); [1, 2, 3].should.not.containEql({ a: 1 }); [{a: 'a'}, {b: 'b', c: 'c'}].should.containEql({a: 'a'}); [{a: 'a'}, {b: 'b', c: 'c'}].should.not.containEql({b: 'b'}); ``` When `.containEql` check arrays it check elements to be in the same order in `otherValue` and object just to be presented. ## .containDeep(otherValue) Assert given value to contain something *.eql* to otherValue within depth. Again see examples: ```javascript 'hello boy'.should.containDeep('boy'); [1,2,3].should.containDeep([3]); [1,2,3].should.containDeep([1, 3]); //but not [1,2,3].should.containDeep([3, 1]); ({ a: { b: 10 }, b: { c: 10, d: 11, a: { b: 10, c: 11} }}).should .containDeep({ a: { b: 10 }, b: { c: 10, a: { c: 11 }}}); [1, 2, 3, { a: { b: { d: 12 }}}].should.containDeep([{ a: { b: {d: 12}}}]); [[1],[2],[3]].should.containDeep([[3]]); [[1],[2],[3, 4]].should.containDeep([[3]]); [{a: 'a'}, {b: 'b', c: 'c'}].should.containDeep([{a: 'a'}]); [{a: 'a'}, {b: 'b', c: 'c'}].should.containDeep([{b: 'b'}]); ``` It does not search somewhere in depth it check all pattern in depth. Objects are checked by properties key and value; arrays are checked like sub sequences. Everyting is compared using `.eql`. Main difference with `.containEql` is that this assertion requires full type chain - if asserted value is an object, otherValue should be also an object (which is sub object of given). The same is true for arrays, otherValue should be an array which compared to be subsequence of given object. Also exists assertion `.containDeepOrdered` which check arrays in the same order. ## .match(otherValue) Assert given object matches `otherValue`. Given: String, otherValue: regexp. Uses `RegExp#exec(str)`: ```javascript username.should.match(/^\w+$/) ``` Given: Array, otherValue: regexp - assert each value match to regexp. ```javascript ['a', 'b', 'c'].should.match(/[a-z]/); ['a', 'b', 'c'].should.not.match(/[d-z]/); ``` Given: Object, otherValue: regexp - assert own property's values to match regexp. ```javascript ({ a: 'foo', c: 'barfoo' }).should.match(/foo$/); ({ a: 'a' }).should.not.match(/^http/); ``` Given: Anything, otherValue: function - assert if given value matched to function. Function can use `.should` inside or return 'true' or 'false', in all other cases it do nothing. If you return value that return assertion, you will receive better error messages. ```javascript (5).should.match(function(n) { return n > 0; }); (5).should.not.match(function(n) { return n < 0; }); (5).should.not.match(function(it) { it.should.be.an.Array; }); (5).should.match(function(it) { return it.should.be.a.Number; }); ``` Now compare messages: ```javascript (5).should.not.match(function(it) { it.should.be.a.Number; }); //AssertionError: expected 5 not to match [Function] (5).should.not.match(function(it) { return it.should.be.a.Number; }); //AssertionError: expected 5 not to match [Function] // expected 5 to be a number ``` Given: object, otherValue: another object - assert that object properties match to properties of another object in meaning that describe above cases. See examples: ```javascript ({ a: 10, b: 'abc', c: { d: 10 }, d: 0 }).should .match({ a: 10, b: /c$/, c: function(it) { return it.should.have.property('d', 10); }}); [10, 'abc', { d: 10 }, 0].should .match({ '0': 10, '1': /c$/, '2': function(it) { return it.should.have.property('d', 10); } }); [10, 'abc', { d: 10 }, 0].should .match([10, /c$/, function(it) { return it.should.have.property('d', 10); }]); ``` ## .matchEach(otherValue) Assert given property keys and values each match given check object. If `otherValue` is RegExp, then each property value checked to match it: ```javascript (['a', 'b', 'c']).should.matchEach(/[a-c]/); ``` If `otherValue` is Function, then check each property value and key matched it: ```javascript [10, 11, 12].should.matchEach(function(it) { return it >= 10; }); [10, 11, 12].should.matchEach(function(it) { return it >= 10; }); ``` In other cases it checks that each property value is `.eql` to `otherValue`: ```javascript [10, 10].should.matchEach(10); ``` ## .throw() and throwError() Assert an exception is thrown: ```js (function(){ throw new Error('fail'); }).should.throw(); ``` Assert an exception is not thrown: ```js (function(){ }).should.not.throw(); ``` Assert exception message matches string: ```js (function(){ throw new Error('fail'); }).should.throw('fail'); ``` Assert error message matches regexp: ```js (function(){ throw new Error('failed to foo'); }).should.throw(/^fail/); ``` Error properties to match some other properties (used `.match`): ```js var error = new Error(); error.a = 10; (function(){ throw error; }).should.throw({ a: 10 }); (function(){ throw error; }).should.throw(Error, { a: 10 }); ``` If you need to pass arguments and/or context to execute function use `Function#bind(context, arg1, ...)`: ```js function isPositive(n) { if(n <= 0) throw new Error('Given number is not positive') } isPositive.bind(null, 10).should.not.throw(); isPositive.bind(null, -10).should.throw(); ``` If you need to check something in an asynchronous function, you must do it in 2 steps: ```js // first we need to check that function is called var called = false; collection.findOne({ _id: 10 }, function(err, res) { called = true; //second we test what you want res.should.be.... }); called.should.be.true; ``` In case you are using something like `Mocha`, you should use an asynchronous test, and call `done()` in the proper place to make sure that your asynchronous function is called before the test finishes. ```js collection.findOne({ _id: 10 }, function(err, res) { if(err) return done(err); //second we test what you want res.should.be.... done(); }); ``` In general, if you need to check that something is executed, you are best using `spies`. A good example is [sinon](http://sinonjs.org/). ## Optional Error description As it can often be difficult to ascertain exactly where failed assertions are coming from in your tests, an optional description parameter can be passed to several should matchers. The description will follow the failed assertion in the error: (1).should.eql(0, 'some useful description') AssertionError: some useful description at Object.eql (/Users/swift/code/should.js/node_modules/should/lib/should.js:280:10) ... The methods that support this optional description are: `eql`, `equal`, `within`, `instanceof`, `above`, `below`, `match`, `length`, `property`, `ownProperty`. ## Mocha example For example you can use should with the [Mocha test framework](http://visionmedia.github.io/mocha/) by simply including it: ```javascript var should = require('should'); var mylib = require('mylib'); describe('mylib', function() { it('should have a version with the format #.#.#', function() { lib.version.should.match(/^\d+\.\d+\.\d+$/); }); }); ``` ## Contributions [Actual list of contributors](https://github.com/visionmedia/should.js/graphs/contributors) if you want to show it your friends. To run the tests for _should_ simply run: $ make test See also [CONTRIBUTING](./CONTRIBUTING.md). ## OMG IT EXTENDS OBJECT???!?!@ Yes, yes it does, with a single getter _should_, and no it won't break your code, because it does this **properly** with a non-enumerable property. ## License MIT © 2010-2014 TJ Holowaychuk should.js-4.0.4+dfsg.orig/LICENSE0000664000000000000000000000207312345335655015030 0ustar rootrootCopyright (c) 2010-2014 TJ Holowaychuk Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.should.js-4.0.4+dfsg.orig/History.md0000664000000000000000000001503712345335655016012 0ustar rootroot4.0.4 / 2014-06-09 ================== * Make all assertions enumerable in Assertion.prototype 4.0.3 / 2014-06-09 ================== * Fix wrong/strange behaviour of .containDeep with equal keys. Now it check to contain element once. * Added util.formatProp to format properties more accurate 4.0.1 / 2014-06-04 ================== * Missing name in browser script 4.0.0 / 2014-05-29 ================== * Breaking change: Move non core assertions out * Added casting in properties assertions to String for all property names * Added .propertyByPath assertion * Breaking change: Remove deprecated .includeEql and .include * Breaking change: .containDeep now do not check order for 2 arrays case * Added .containDeepOrdered for old .containDeep * Added support of array-like objects * Added to .throw matching by error properties with .match 3.3.2 / 2014-05-23 ================== * Fix for should.format 3.3.1 / 2014-04-16 ================== * Added aliases for es reserved words * Fix bug with ownProperty alias * Fix bug with not function alias 3.3.0 / 2014-04-07 ================== * Added .enumerable(name, val) 3.2.0 / 2014-03-29 ================== * Added first version of .any modifier that affect assertions with multiple parameters * .header now have more nice message * assertion can now override how to show object 3.1.4 / 2014-03-18 ================== * .Error now do not throw assertion error for custom errors. 3.1.3 / 2014-02-25 ================== * Fix TypeError in .containEql 3.1.2 / 2014-01-28 ================== * Fix for adding .inspect for JQuery object only in case when it is exist 3.1.1 / 2014-01-28 ================== * Fix for HTMLElement in DOM less environments 3.1.0 / 2014-01-23 ================== * Added jquery based browser extension 3.0.1 / 2014-01-17 ================== * Fix: .lengthOf() 3.0.0 / 2014-01-17 ================== * Split everything to smaller files * Added huge extension to .match and .matchEach. Thanks @alsotang for initial code and idea. * Added .containDeep and .containEql * Separate build for browser and node.js * Basic plugin system * Breaking change: .Object now do not fail on arrays * Breaking change: Additional messages now replaces generated and do not added * Breaking change: .keys now check as is - no keys in args means no keys in object * Deprecated: assert extension * Deprecated: .include and .includeEql * Now all assertions define only positive cases, should.js take care about negations and chains 2.1.1 / 2013-12-05 ================== * Move date formatting out of should.inspect 2.1.0 / 2013-11-11 ================== * Override .inspect for Date's to convert them to ISOString 2.0.2 / 2013-10-21 ================== * Add '#of' as getter for chaining. * Exclude browser script for .npmignore. 2.0.1 / 2013-10-10 ================== * Fix wrong path in .npmignore. 2.0.0 / 2013-10-10 ================== * breaking change: #a now getter like #an. Was replaced with #type(str) * breaking change: #empty does not check length for objects. Now it check if object do not have own properties. * #properties check if object have some properties * util.inspect now exposed as should.inspect * assertions for NaN, Infinity, Array, Object, String, Boolean, Number, Error, Function * #equal got alias #exactly 1.3.0 / 2013-09-13 ================== * fix doc for .keys. Closes #108. * add #endWith() * add .startWith (#119) 1.2.2 / 2013-02-19 ================== * fix should.be.instanceOf() failure on Date 1.2.1 / 2012-11-02 ================== * add .showDiff * Make instanceOf and throwError be aliased like others [alFReD-NSH] * Fix should[.not].exist not having stack trace #84 [alFReD-NSH] 1.2.0 / 2012-09-21 ================== * Added #approximately(value, delta, description) for doing assertions on results of operations with numbers. [titarenko] 1.1.1 / 2012-09-19 ================== * add .type for eql()s assert 1.1.0 / 2012-07-30 ================== * add enclosing of failure message functions. Closes #81 * add mocha .actual / .expected string support for all assertion values 0.7.0 / 2012-07-17 ================== * add `.throw(Constructor)` support [snakamura] 0.6.3 / 2012-04-26 ================== * Added object inclusion support back 0.6.2 / 2012-04-26 ================== * Added homepage to package.json * Fixed .equal() with dates. Closes #63 0.6.1 / 2012-04-10 ================== * package: add "repository" section [TooTallNate] * use valueOf() to get the reference the object [TooTallNate] 0.6.0 / 2012-03-01 ================== * Added `err.actual` and `err.expected` for .{eql,equal}() * Added 'return this;' to 'get json' and 'get html' in order to provide chaining for should.be.json and should.be.html 0.5.1 / 2012-01-13 ================== * Added better `.json` * Added better `.html` 0.5.0 / 2012-01-12 ================== * Added string matching to `.throw()` [serby] * Added regexp matching to `.throw()` [serby] * Added `.includeEql()` [RubenVerborgh] * Added `.should.be.html` * Added `.should.be.json` * Added optional description args to most matchers [Mike Swift] 0.4.2 / 2011-12-17 ================== * Fixed .header() for realzzz 0.4.1 / 2011-12-16 ================== * Fixed: chain .header() to retain negation 0.4.0 / 2011-12-16 ================== * Added `.should.throw()` * Added `.include()` support for strings * Added `.include()` support for arrays * Removed `keys()` `.include` modifier support * Removed `.object()` * Removed `.string()` * Removed `.contain()` * Removed `.respondTo()` rubyism * expresso -> mocha 0.3.2 / 2011-10-24 ================== * Fixed tests for 0.5.x * Fixed sys warning 0.3.1 / 2011-08-22 ================== * configurable 0.3.0 / 2011-08-20 ================== * Added assertion for inclusion of an object: `foo.should.include.object({ foo: 'bar' })` 0.2.1 / 2011-05-13 ================== * Fixed .status(code). Closes #18 0.2.0 / 2011-04-17 ================== * Added `res.should.have.status(code)` method * Added `res.should.have.header(field, val)` method 0.1.0 / 2011-04-06 ================== * Added `should.exist(obj)` [aseemk] * Added `should.not.exist(obj)` [aseemk] 0.0.4 / 2010-11-24 ================== * Added `.ok` to assert truthfulness * Added `.arguments` * Fixed double required bug. [thanks dominictarr] 0.0.3 / 2010-11-19 ================== * Added `true` / `false` assertions 0.0.2 / 2010-11-19 ================== * Added chaining support 0.0.1 / 2010-11-19 ================== * Initial release should.js-4.0.4+dfsg.orig/CONTRIBUTING.md0000664000000000000000000000167012345335655016256 0ustar rootrootBefore contribute something: 1. Your code should look like all the other code - this project should look like it was written by one man, always. 2. If you want to propose something - just create an issue and describe your question with as much description as you can. 3. Please never send issues or pull requests about code style, jshint violations etc - I do not accept it (and you will spend your time for free). 4. If you think you have some general improvement, consider creating a pull request with it. 5. If you are not sure whether your improvement is general enough, just create your own plugin for should.js. (see should.use and Assertion.add usage). 6. If you add new code, it should be covered by tests. No tests - no code. 7. If you find a bug (or at least you think it is a bug), create an issue with the library version and test case that I can run and see what are you talking about, or at least full steps by which I can reproduce it. should.js-4.0.4+dfsg.orig/.zuul.yml0000664000000000000000000000026612345335655015625 0ustar rootrootui: mocha-bdd browsers: - name: chrome version: 30..latest - name: ie version: 9..latest - name: firefox version: 24..latest - name: safari version: 6..latestshould.js-4.0.4+dfsg.orig/.travis.yml0000664000000000000000000000076712345335655016144 0ustar rootrootlanguage: node_js node_js: - '0.10' script: - test $SAUCE_USERNAME && npm run zuul || echo 'not running on saucelabs' env: global: - secure: aB4+vAj+mJHqQfnq9x10eZ5//erfxecs3l9u/oSJX1Ok+WLrpUW0x3qpaC1bEEPq4bkAuIifxohnPv0XTE3m8GyTfRHzqmeNnNQNsnex3IzunbU4aG7QyS3jFa6gjT5OrgPA+eHobNXBvwASZczighlWtoYKD5RW7Uak4E8EpPs= - secure: kJaOWFzFnSGEZ4keShHST18OC6z+rmvnnht0SwqmhPlBX4nBQ2bdBR09n0O/GVQ0uAzohn1oObouQH0yuXpbgmk4whMVZgt8RPztusLskt88fE9EOPFNA+YOWNpmcelDiXsMXv7vN2bBlZJSrILUgUppuHIqsdqTGWut08l3Zhg= should.js-4.0.4+dfsg.orig/.npmignore0000664000000000000000000000001512345335655016014 0ustar rootrootexamples testshould.js-4.0.4+dfsg.orig/.gitignore0000664000000000000000000000010312345335655016003 0ustar rootrootnode_modules .DS_Store desktop.ini .idea should.js.for-tests *.swp