diff --git a/object.js b/object.js index 3c9c748..972ebc8 100755 --- a/object.js +++ b/object.js @@ -1086,7 +1086,7 @@ function Constructor(name, a, b, c){ Object.assign( Object.getOwnPropertyDescriptor(Function.prototype, n), { value: function(){ - return this.__call__[n](...arguments) }, })) }) + return this.__call__[n](this, ...arguments) }, })) }) return _constructor } diff --git a/package.json b/package.json index 6c71b5d..16558bc 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-object", - "version": "5.2.1", + "version": "5.2.2", "description": "", "main": "object.js", "scripts": { diff --git a/test.js b/test.js index 2730b7f..cd4a24e 100755 --- a/test.js +++ b/test.js @@ -441,6 +441,14 @@ module.modifiers = { gen3: function(assert, setup){ return this.gen2(assert, this.gen2(assert, setup), '3') }, + // create instance clones via Object.create(..) + // + clones: function(assert, setup){ + return instances(setup) + .reduce(function(res, [k, o]){ + res[k] = Object.create(o) + return res }, {}) }, + // generate instances... // // NOTE: these are re-used as tests too... @@ -618,13 +626,19 @@ module.tests = { instances(setup) .filter(function([_, o]){ // NOTE: not all callables are instances of Function... - return typeof(o) == 'function' }) + return typeof(o) == 'function' + || !!o.__call__ }) .forEach(function([k, o]){ o.__non_function ? assert(!(o instanceof Function), 'non-instanceof Function', k) : assert(o instanceof Function, 'instanceof Function', k) - assert(o(), 'call', k) + typeof(o) == 'function' + && assert(o(), 'call', k) + + assert(o.call(), '.call(..)', k) + assert(o.apply(), 'apply(..)', k) + assert(o.bind(null)(), '.bind(..)(..)', k) test(o, k) })