From 8752ceef13a3c6478fee54b089fbfea1e3d8313c Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Fri, 6 Apr 2012 13:49:27 -0700 Subject: [PATCH] test: make repl-autolibs check that the callback was invoked --- test/simple/test-repl-autolibs.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/simple/test-repl-autolibs.js b/test/simple/test-repl-autolibs.js index 56fbaa602d6..593b6465cb3 100644 --- a/test/simple/test-repl-autolibs.js +++ b/test/simple/test-repl-autolibs.js @@ -44,7 +44,9 @@ var testMe = repl.start('', putIn, null, true); test1(); function test1(){ + var gotWrite = false; putIn.write = function (data) { + gotWrite = true; if (data.length) { // inspect output matches repl output assert.equal(data, util.inspect(require('fs'), null, null, false) + '\n'); @@ -53,11 +55,15 @@ function test1(){ test2(); } }; + assert(!gotWrite); putIn.run(['fs']); + assert(gotWrite); } function test2(){ + var gotWrite = false; putIn.write = function(data) { + gotWrite = true; if (data.length) { // repl response error message assert.equal(data.indexOf('A different'), 0); @@ -67,5 +73,7 @@ function test2(){ }; var val = {}; global.url = val; + assert(!gotWrite); putIn.run(['url']); + assert(gotWrite); }