test.js 510 B

1234567891011121314151617181920212223242526
  1. var inherits = require('./inherits.js')
  2. var assert = require('assert')
  3. function test(c) {
  4. assert(c.constructor === Child)
  5. assert(c.constructor.super_ === Parent)
  6. assert(Object.getPrototypeOf(c) === Child.prototype)
  7. assert(Object.getPrototypeOf(Object.getPrototypeOf(c)) === Parent.prototype)
  8. assert(c instanceof Child)
  9. assert(c instanceof Parent)
  10. }
  11. function Child() {
  12. Parent.call(this)
  13. test(this)
  14. }
  15. function Parent() {}
  16. inherits(Child, Parent)
  17. var c = new Child
  18. test(c)
  19. console.log('ok')