Permalink
Browse files

foo test passes

  • Loading branch information...
substack committed Sep 1, 2012
1 parent 4a60d1d commit c6a321b23a34f10a2dfc0a31ffc69dcb3bec5569
Showing with 32 additions and 0 deletions.
  1. +1 −0 index.js
  2. +31 −0 test/foo.js
View
@@ -3,6 +3,7 @@ module.exports = function (obj, fn) {
if (typeof fn !== 'function') return;
return fn.apply(obj, arguments);
};
+ f.__proto__ = obj.__proto__;
Object.getOwnPropertyNames(obj).forEach(function (key) {
f[key] = obj[key];
View
@@ -0,0 +1,31 @@
+var test = require('tap').test;
+var funstance = require('../');
+
+var inherits = require('inherits');
+var Stream = require('stream');
+
+module.exports = Foo;
+inherits(Foo, Stream);
+
+function Foo (x) {
+ this.x = x;
+}
+
+Foo.prototype.beep = function () {
+ this.emit('beep', 'boop');
+};
+
+test('funstantiate foo', function (t) {
+ t.plan(2);
+
+ var obj = new Foo(4);
+ var fobj = funstance(obj, function (n) {
+ return n * obj.x
+ });
+
+ t.equal(fobj(111), 444);
+ fobj.on('beep', function (s) {
+ t.equal(s, 'boop');
+ });
+ fobj.beep();
+});

0 comments on commit c6a321b

Please sign in to comment.