Permalink
Browse files

add test

  • Loading branch information...
1 parent 7aa4058 commit 0f2414390067932bd46620bb1adc36ca06281e65 @isaacs committed May 16, 2013
Showing with 27 additions and 1 deletion.
  1. +2 −1 package.json
  2. +25 −0 test.js
View
@@ -6,4 +6,5 @@
, "browser" : "./inherits_browser.js"
, "repository" : "https://github.com/isaacs/inherits"
, "license": { "type": "WTFPL2" }
-, "author" : "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)" }
+, "author" : "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)"
+, "scripts" : { "test" : "node test" } }
View
25 test.js
@@ -0,0 +1,25 @@
+var inherits = require('./inherits.js')
+var assert = require('assert')
+
+function test(c) {
+ assert(c.constructor === Child)
+ assert(c.constructor.super_ === Parent)
+ assert(Object.getPrototypeOf(c) === Child.prototype)
+ assert(Object.getPrototypeOf(Object.getPrototypeOf(c)) === Parent.prototype)
+ assert(c instanceof Child)
+ assert(c instanceof Parent)
+}
+
+function Child() {
+ Parent.call(this)
+ test(this)
+}
+
+function Parent() {}
+
+inherits(Child, Parent)
+
+var c = new Child
+test(c)
+
+console.log('ok')

0 comments on commit 0f24143

Please sign in to comment.