Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Parent(x) { this.x = x }
  2.  
  3. Parent.prototype.showX = function () { console.log(this.x) }
  4.  
  5. function Child(x, y) { Parent.call(this, x); this.y = y; }
  6.  
  7. Child.prototype = Object.create(Parent.prototype);
  8. Child.prototype.showXY = function () { console.log(this.x, this.y) }
  9.  
  10. var tests = [
  11.   function shouldInitializeParentInstanceFields(Parent, Child) {
  12.     var c = new Child(1, 2);
  13.     return c.x === 1;
  14.   },
  15.   function shouldInitializeChildInstanceFields(Parent, Child) { /* ... */ },
  16.   function childIsInstanceOfParent(Parent, Child) { /* ... */ },
  17.   function childIsInstanceOfChild(Parent, Child) { /* ... */ },
  18.   function parentIsInstanceOfParent(Parent, Child) { /* ... */ },
  19.   function parentIsNotInstanceOfChild(Parent, Child) { /* ... */ },
  20.   function parentMethodsAreAvailableInParent(Parent, Child) { /* ... */ },
  21.   function parentMethodsAreAvailableInChild(Parent, Child) { /* ... */ },
  22.   function childMethodsAreNotAvailableInParent(Parent, Child) { /* ... */ },
  23.   function childMethodsAreAvailableInChild(Parent, Child) { /* ... */ },
  24.   function dynamicallyAddedParentMethodIsAvailableInParent(Parent, Child) { /* ... */ },
  25.   function dynamicallyAddedParentMethodIsAvailableInChild(Parent, Child) { /* ... */ },
  26.   function dynamicallyAddedChildMethodIsNotAvailableInParent(Parent, Child) { /* ... */ },
  27.   function dynamicallyAddedChildMethodIsAvailableInChild(Parent, Child) { /* ... */ },
  28.   function deletedParentInstancePropertyDisappearsFromChild(Parent, Child) { /* ... */ },
  29. ]
  30.  
  31. for (var test of tests) {
  32.   console.log(test(Parent, Child), test.name)
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement