In test.js, exports.testOverride verifies that the "youngest" Object (or "class") overrides the same-name function of its parent (or "base"). This test of course works.
However, if the prop argument is a function, the override order is reversed. See example below.
exports.testOverrideOfFunctions = function(test) {
test.expect(2);
var A = inherit(function(){
this.method = function() {
return 'A';
};
});
var B = inherit(A, function(){
this.method = function() {
return 'B';
};
});
test.equal(new A().method(), 'A');
test.equal(new B().method(), 'B');
test.done();
};
The above test fails. See output below.
✖ testOverrideOfFunctions
AssertionError: 'B' == 'A'
at Object.equal (/usr/local/lib/node_modules/nodeunit/lib/types.js:83:39)
at Object.exports.testOverrideOfFunctions (/home/kafoso/git/inherit/test/test.js:142:10)
at Object.<anonymous> (/usr/local/lib/node_modules/nodeunit/lib/core.js:236:16)
at /usr/local/lib/node_modules/nodeunit/lib/core.js:236:16
at Object.exports.runTest (/usr/local/lib/node_modules/nodeunit/lib/core.js:70:9)
at /usr/local/lib/node_modules/nodeunit/lib/core.js:118:25
at /usr/local/lib/node_modules/nodeunit/deps/async.js:513:13
at iterate (/usr/local/lib/node_modules/nodeunit/deps/async.js:123:13)
at /usr/local/lib/node_modules/nodeunit/deps/async.js:134:25
at /usr/local/lib/node_modules/nodeunit/deps/async.js:515:17
Naturally, the prop argument should be an Object per your documentation. However, it would be a nice addition.
In
test.js,exports.testOverrideverifies that the "youngest" Object (or "class") overrides the same-name function of its parent (or "base"). This test of course works.However, if the
propargument is a function, the override order is reversed. See example below.The above test fails. See output below.
Naturally, the
propargument should be an Object per your documentation. However, it would be a nice addition.