diff --git a/lib/_debugger.js b/lib/_debugger.js index b8a3177d6877..9887f015550f 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var util = require('util'), path = require('path'), net = require('net'), diff --git a/lib/_http_agent.js b/lib/_http_agent.js index 6fbff37d85db..96797b2e8228 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var net = require('net'); var util = require('util'); var EventEmitter = require('events').EventEmitter; diff --git a/lib/_http_client.js b/lib/_http_client.js index 5f873d65d18c..0467faead1b8 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var util = require('util'); var net = require('net'); var url = require('url'); diff --git a/lib/_http_common.js b/lib/_http_common.js index 7994cdd98d92..8edc6713940c 100644 --- a/lib/_http_common.js +++ b/lib/_http_common.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var FreeList = require('freelist').FreeList; var HTTPParser = process.binding('http_parser').HTTPParser; diff --git a/lib/_http_incoming.js b/lib/_http_incoming.js index 69d3d86ec6a4..a252c114bf84 100644 --- a/lib/_http_incoming.js +++ b/lib/_http_incoming.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var util = require('util'); var Stream = require('stream'); diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index d02bdf7f23e0..7f61aac35eda 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var assert = require('assert').ok; var Stream = require('stream'); var timers = require('timers'); diff --git a/lib/_http_server.js b/lib/_http_server.js index 787fc27bbf14..5927ed26893e 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var util = require('util'); var net = require('net'); var EventEmitter = require('events').EventEmitter; diff --git a/lib/_linklist.js b/lib/_linklist.js index b73bbed22b8e..048e933ee3a7 100644 --- a/lib/_linklist.js +++ b/lib/_linklist.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + function init(list) { list._idleNext = list; list._idlePrev = list; diff --git a/lib/_stream_duplex.js b/lib/_stream_duplex.js index 75cf30d79873..474a31303d97 100644 --- a/lib/_stream_duplex.js +++ b/lib/_stream_duplex.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + // a duplex stream is just a stream that is both readable and writable. // Since JS doesn't have multiple prototypal inheritance, this class // prototypally inherits from Readable, and then parasitically from diff --git a/lib/_stream_passthrough.js b/lib/_stream_passthrough.js index a5e986430d79..7a9102aedc7e 100644 --- a/lib/_stream_passthrough.js +++ b/lib/_stream_passthrough.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + // a passthrough stream. // basically just the most minimal sort of Transform stream. // Every written chunk gets output as-is. diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 5f280b773601..08aad09d813e 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + module.exports = Readable; Readable.ReadableState = ReadableState; diff --git a/lib/_stream_transform.js b/lib/_stream_transform.js index 1843f51b7517..3c6bb9db9683 100644 --- a/lib/_stream_transform.js +++ b/lib/_stream_transform.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + // a transform stream is a readable/writable stream where you do // something with the data. Sometimes it's called a "filter", diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index f39393b06178..70da498da3e2 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + // A bit simpler than readable streams. // Implement an async ._write(chunk, cb), and it'll handle all // the drain event emission and buffering. diff --git a/lib/_tls_common.js b/lib/_tls_common.js index 72648be98433..113abbcc1f60 100644 --- a/lib/_tls_common.js +++ b/lib/_tls_common.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var util = require('util'); var constants = require('constants'); var tls = require('tls'); diff --git a/lib/_tls_legacy.js b/lib/_tls_legacy.js index 9401fc559ad5..2243394778d3 100644 --- a/lib/_tls_legacy.js +++ b/lib/_tls_legacy.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var assert = require('assert'); var events = require('events'); var stream = require('stream'); diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 6e2a430840a9..f4ee762eed4d 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -22,6 +22,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var assert = require('assert'); var crypto = require('crypto'); var net = require('net'); diff --git a/lib/assert.js b/lib/assert.js index 357dd1bb0c6e..58f320d68364 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -22,6 +22,8 @@ // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + // UTILITY var util = require('util'); var b = require('buffer'); diff --git a/lib/buffer.js b/lib/buffer.js index 9b43882e574d..4604ba9898ef 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var buffer = process.binding('buffer'); var smalloc = process.binding('smalloc'); var util = require('util'); diff --git a/lib/child_process.js b/lib/child_process.js index b4a8894734b8..657e065dce65 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var StringDecoder = require('string_decoder').StringDecoder; var EventEmitter = require('events').EventEmitter; var net = require('net'); diff --git a/lib/cluster.js b/lib/cluster.js index 71ebf41c454e..e05de4568bc6 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var EventEmitter = require('events').EventEmitter; var assert = require('assert'); var dgram = require('dgram'); diff --git a/lib/console.js b/lib/console.js index a3c8acb5940b..00e6f315d9e2 100644 --- a/lib/console.js +++ b/lib/console.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var util = require('util'); function Console(stdout, stderr) { diff --git a/lib/constants.js b/lib/constants.js index 1b87b2b2d0c6..816dc853e1bb 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -19,4 +19,6 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + module.exports = process.binding('constants'); diff --git a/lib/crypto.js b/lib/crypto.js index 97cceb67f5c4..8f80fff1594a 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + // Note: In 0.8 and before, crypto functions all defaulted to using // binary-encoded strings rather than buffers. diff --git a/lib/dgram.js b/lib/dgram.js index 764892a90bc4..385ffa288cdb 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var assert = require('assert'); var util = require('util'); var events = require('events'); diff --git a/lib/dns.js b/lib/dns.js index 18023fab1621..453497185213 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var net = require('net'); var util = require('util'); diff --git a/lib/domain.js b/lib/domain.js index f2f9f43ae5af..127869435ddd 100644 --- a/lib/domain.js +++ b/lib/domain.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var util = require('util'); var EventEmitter = require('events'); var inherits = util.inherits; diff --git a/lib/events.js b/lib/events.js index 0cd841b8445a..f8c651feac69 100644 --- a/lib/events.js +++ b/lib/events.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var domain; var util = require('util'); diff --git a/lib/freelist.js b/lib/freelist.js index 588facd25b39..561ca53458c2 100644 --- a/lib/freelist.js +++ b/lib/freelist.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + // This is a free list to avoid creating so many of the same object. exports.FreeList = function(name, max, constructor) { this.name = name; diff --git a/lib/fs.js b/lib/fs.js index bd9fde680df8..cd961242da22 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + // Maintainers, keep in mind that octal literals are not allowed // in strict mode. Use the decimal value and add a comment with // the octal value. Example: diff --git a/lib/http.js b/lib/http.js index d12f12d60ceb..c0b2b0af1128 100644 --- a/lib/http.js +++ b/lib/http.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var util = require('util'); var EventEmitter = require('events').EventEmitter; diff --git a/lib/https.js b/lib/https.js index f9011648fb69..4c2731ab581c 100644 --- a/lib/https.js +++ b/lib/https.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var tls = require('tls'); var url = require('url'); var http = require('http'); diff --git a/lib/module.js b/lib/module.js index 4ac8cfa30a02..0f1f38c7bb0c 100644 --- a/lib/module.js +++ b/lib/module.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var NativeModule = require('native_module'); var util = require('util'); var runInThisContext = require('vm').runInThisContext; diff --git a/lib/net.js b/lib/net.js index 61cb4209522e..3fdc4580ece0 100644 --- a/lib/net.js +++ b/lib/net.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var events = require('events'); var stream = require('stream'); var timers = require('timers'); diff --git a/lib/os.js b/lib/os.js index 814c054ef31a..79cef00a4ae5 100644 --- a/lib/os.js +++ b/lib/os.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var binding = process.binding('os'); var util = require('util'); var isWindows = process.platform === 'win32'; diff --git a/lib/path.js b/lib/path.js index 27c148ab535f..849a82768d3d 100644 --- a/lib/path.js +++ b/lib/path.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var isWindows = process.platform === 'win32'; var util = require('util'); diff --git a/lib/querystring.js b/lib/querystring.js index 04c083d8abcd..0f317fc30b8e 100644 --- a/lib/querystring.js +++ b/lib/querystring.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + // Query String Utilities var QueryString = exports; diff --git a/lib/readline.js b/lib/readline.js index fe2def0350a0..4676bccb3fb2 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + // Inspiration for this code comes from Salvatore Sanfilippo's linenoise. // https://github.com/antirez/linenoise // Reference: diff --git a/lib/repl.js b/lib/repl.js index a8fa060c5930..289aae4f040f 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + /* A repl library that you can include in your own code to get a runtime * interface to your program. * diff --git a/lib/smalloc.js b/lib/smalloc.js index 2b4175e0cb15..994b3f281bae 100644 --- a/lib/smalloc.js +++ b/lib/smalloc.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var smalloc = process.binding('smalloc'); var kMaxLength = smalloc.kMaxLength; var util = require('util'); diff --git a/lib/stream.js b/lib/stream.js index 073c6ed338fa..83815e840497 100644 --- a/lib/stream.js +++ b/lib/stream.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + module.exports = Stream; var EE = require('events').EventEmitter; diff --git a/lib/string_decoder.js b/lib/string_decoder.js index fd11e51c8da8..84ac9a9d4453 100644 --- a/lib/string_decoder.js +++ b/lib/string_decoder.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + function assertEncoding(encoding) { if (encoding && !Buffer.isEncoding(encoding)) { throw new Error('Unknown encoding: ' + encoding); diff --git a/lib/sys.js b/lib/sys.js index cf98a073e6cd..6dc415c31f86 100644 --- a/lib/sys.js +++ b/lib/sys.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + // the sys module was renamed to 'util'. // this shim remains to keep old programs working. module.exports = require('util'); diff --git a/lib/timers.js b/lib/timers.js index 5ef5f37ed763..68f87d7c9f3f 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var Timer = process.binding('timer_wrap').Timer; var L = require('_linklist'); var assert = require('assert').ok; diff --git a/lib/tls.js b/lib/tls.js index a00fbb9d722e..7aad494b1e0d 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var net = require('net'); var url = require('url'); var util = require('util'); diff --git a/lib/tty.js b/lib/tty.js index 74300fc1e4b8..3d5c2a664930 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var inherits = require('util').inherits; var net = require('net'); var TTY = process.binding('tty_wrap').TTY; diff --git a/lib/url.js b/lib/url.js index 07a6c103a474..c5a3793b9a9c 100644 --- a/lib/url.js +++ b/lib/url.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var punycode = require('punycode'); var util = require('util'); diff --git a/lib/util.js b/lib/util.js index e97820c9af37..4fed8311a090 100644 --- a/lib/util.js +++ b/lib/util.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var formatRegExp = /%[sdj%]/g; exports.format = function(f) { if (!isString(f)) { diff --git a/lib/vm.js b/lib/vm.js index 7c6c59c0af49..653c27c0d857 100644 --- a/lib/vm.js +++ b/lib/vm.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var binding = process.binding('contextify'); var Script = binding.ContextifyScript; var util = require('util'); diff --git a/lib/zlib.js b/lib/zlib.js index f80c9833a444..a85e8efb5181 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + var Transform = require('_stream_transform'); var binding = process.binding('zlib'); diff --git a/src/node.js b/src/node.js index 50460383ff71..02aee1708c4f 100644 --- a/src/node.js +++ b/src/node.js @@ -24,6 +24,9 @@ // This file is invoked by node::Load in src/node.cc, and responsible for // bootstrapping the node.js core. Special caution is given to the performance // of the startup process, so many dependencies are invoked lazily. + +'use strict'; + (function(process) { this.global = this; diff --git a/test/simple/test-use-strict-builtin-modules.js b/test/simple/test-use-strict-builtin-modules.js index b4d89d0cfe5e..5172ae8cc9f9 100644 --- a/test/simple/test-use-strict-builtin-modules.js +++ b/test/simple/test-use-strict-builtin-modules.js @@ -27,27 +27,18 @@ var child_process = require('child_process'); var assert = require('assert'); -function getBuiltinModulesPath(builtinModuleFilename) { - return path.join(NODE_LIB_DIR, builtinModuleFilename); -} - -function shouldBeTested(builtinModuleFilename) { - assert(typeof builtinModuleFilename === 'string', - 'builtinModuleFilename must be a string'); - assert(builtinModuleFilename.length > 0, - 'builtinModuleFilename must be a non-empty string'); - - var isInternalModule = builtinModuleFilename.charAt(0) === '_'; - if (isInternalModule || builtinModuleFilename === 'module.js') { - // Do not load "internal" modules as we don't care if they can - // be loaded with --use-strict, since they are not part of the - // public API. - // - // Do not load module.js because: +function shouldBeTested(builtinModuleName) { + assert(typeof builtinModuleName === 'string', + 'builtinModuleName must be a string'); + assert(builtinModuleName.length > 0, + 'builtinModuleName must be a non-empty string'); + + if (builtinModuleName === 'module') { + // Do not load 'module' because: // 1) It's loaded as part of the normal node.js startup process. // 2) Loading it twice is not supported since it requires // that NativeModule.require is the existing require implementation, - // but it overrides it when it's loaded. + // but it overrides it when it's loaded as part of node's bootstrap. return false; } @@ -57,16 +48,6 @@ function shouldBeTested(builtinModuleFilename) { if (process.argv[2] !== 'child') { child_process.fork(__filename, ['child'], { execArgv: ['--use-strict']}); } else { - var fs = require('fs'); - var path = require('path'); - - var NODE_LIB_DIR = path.join(path.resolve(__dirname, '../..'), 'lib'); - - fs.readdir(NODE_LIB_DIR, function onDirRead(err, builtinModules) { - if (err) throw err; - - var builtinModulesPaths = builtinModules.filter(shouldBeTested) - .map(getBuiltinModulesPath); - builtinModulesPaths.forEach(require); - }); + var natives = process.binding('natives'); + Object.keys(natives).filter(shouldBeTested).forEach(require); }