Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Parent(x) { this.x = x }
- Parent.prototype.showX = function () { console.log(this.x) }
- function Child(x, y) { Parent.call(this, x); this.y = y; }
- Child.prototype = Object.create(Parent.prototype);
- Child.prototype.showXY = function () { console.log(this.x, this.y) }
- var tests = [
- function shouldInitializeParentInstanceFields(Parent, Child) {
- var c = new Child(1, 2);
- return c.x === 1;
- },
- function shouldInitializeChildInstanceFields(Parent, Child) { /* ... */ },
- function childIsInstanceOfParent(Parent, Child) { /* ... */ },
- function childIsInstanceOfChild(Parent, Child) { /* ... */ },
- function parentIsInstanceOfParent(Parent, Child) { /* ... */ },
- function parentIsNotInstanceOfChild(Parent, Child) { /* ... */ },
- function parentMethodsAreAvailableInParent(Parent, Child) { /* ... */ },
- function parentMethodsAreAvailableInChild(Parent, Child) { /* ... */ },
- function childMethodsAreNotAvailableInParent(Parent, Child) { /* ... */ },
- function childMethodsAreAvailableInChild(Parent, Child) { /* ... */ },
- function dynamicallyAddedParentMethodIsAvailableInParent(Parent, Child) { /* ... */ },
- function dynamicallyAddedParentMethodIsAvailableInChild(Parent, Child) { /* ... */ },
- function dynamicallyAddedChildMethodIsNotAvailableInParent(Parent, Child) { /* ... */ },
- function dynamicallyAddedChildMethodIsAvailableInChild(Parent, Child) { /* ... */ },
- function deletedParentInstancePropertyDisappearsFromChild(Parent, Child) { /* ... */ },
- ]
- for (var test of tests) {
- console.log(test(Parent, Child), test.name)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement