diff --git a/lib/warn.js b/lib/warn.js index c88c813..8e36c39 100644 --- a/lib/warn.js +++ b/lib/warn.js @@ -36,7 +36,7 @@ var _handler = null; * * @type {Object} */ -var _console = console; +var _console = ( typeof console !== 'undefined' ) ? console : undefined; /** diff --git a/test/test-combine-pre-es5.js b/test/test-combine-pre-es5.js index cbca10e..1fd021c 100644 --- a/test/test-combine-pre-es5.js +++ b/test/test-combine-pre-es5.js @@ -29,14 +29,15 @@ var common = require( './common' ), assert = require( 'assert' ), + vm = require( 'vm' ), Class = common.require( 'class' ), - Script = process.binding( 'evals' ).Script, // sandbox in which combined script will be run - sandbox = { + sandbox = vm.createContext( { // stub document.write() so we don't blow up document: { write: function() {} }, - }; + runTests: null, + } ); var file = 'ease-full.js'; @@ -69,8 +70,7 @@ data = "delete Object.defineProperty;" + ; // run the script (if this fails to compile, the generated code is invalid) -var cmb_script = new Script( data ); -cmb_script.runInNewContext( sandbox ); +vm.runInNewContext( data, sandbox ); // cross your fingers sandbox.easejs.runTests(); diff --git a/test/test-combine.js b/test/test-combine.js index d03cba1..da0dad5 100644 --- a/test/test-combine.js +++ b/test/test-combine.js @@ -24,8 +24,8 @@ var common = require( './common' ), assert = require( 'assert' ), + vm = require( 'vm' ), Class = common.require( 'class' ), - Script = process.binding( 'evals' ).Script, // sandbox in which combined script will be run sandbox = { @@ -60,8 +60,7 @@ while ( i-- ) } // run the script (if this fails to compile, the generated code is invalid) - var cmb_script = new Script( data ); - cmb_script.runInNewContext( sandbox ); + vm.runInNewContext( data, sandbox ); assert.equal( sandbox.require, diff --git a/test/test-warn-handlers.js b/test/test-warn-handlers.js index c609c43..4c49199 100644 --- a/test/test-warn-handlers.js +++ b/test/test-warn-handlers.js @@ -30,6 +30,8 @@ var common = require( './common' ), warning = Warning( Error( 'gninraw' ) ) ; +if ( typeof console === 'undefined' ) console = undefined; + /** * The log warning handler should log warnings to the console diff --git a/test/test-warn-impl.js b/test/test-warn-impl.js index 6eef84e..88a8396 100644 --- a/test/test-warn-impl.js +++ b/test/test-warn-impl.js @@ -27,6 +27,8 @@ var common = require( './common' ), warn = common.require( 'warn' ) ; +if ( typeof console === 'undefined' ) console = undefined; + /** * The default warning handler should be the 'log' handler. This is a friendly