It will print out extraneous, missing, and invalid packages.
@@ -104,5 +104,5 @@ npm is the package manager for the Node JavaScript platform. It puts
modules in place so that node can find them, and manages dependency
@@ -126,7 +126,7 @@
npm-help(1)
@@ -150,5 +150,5 @@ SEE ALSO
-
+
diff --git a/deps/npm/html/doc/files/npm-folders.html b/deps/npm/html/doc/files/npm-folders.html
index a2845d57bc0c..0937d2a13185 100644
--- a/deps/npm/html/doc/files/npm-folders.html
+++ b/deps/npm/html/doc/files/npm-folders.html
@@ -182,5 +182,5 @@ SEE ALSO
-
+
diff --git a/deps/npm/html/doc/files/npm-global.html b/deps/npm/html/doc/files/npm-global.html
index a2845d57bc0c..0937d2a13185 100644
--- a/deps/npm/html/doc/files/npm-global.html
+++ b/deps/npm/html/doc/files/npm-global.html
@@ -182,5 +182,5 @@ SEE ALSO
-
+
diff --git a/deps/npm/html/doc/files/npm-json.html b/deps/npm/html/doc/files/npm-json.html
index 8ef63d23d998..3894c9ead6aa 100644
--- a/deps/npm/html/doc/files/npm-json.html
+++ b/deps/npm/html/doc/files/npm-json.html
@@ -586,5 +586,5 @@ SEE ALSO
-
+
diff --git a/deps/npm/html/doc/files/npmrc.html b/deps/npm/html/doc/files/npmrc.html
index 22c43e98d6e5..151b0c007903 100644
--- a/deps/npm/html/doc/files/npmrc.html
+++ b/deps/npm/html/doc/files/npmrc.html
@@ -89,5 +89,5 @@ SEE ALSO
-
+
diff --git a/deps/npm/html/doc/files/package.json.html b/deps/npm/html/doc/files/package.json.html
index 8ef63d23d998..3894c9ead6aa 100644
--- a/deps/npm/html/doc/files/package.json.html
+++ b/deps/npm/html/doc/files/package.json.html
@@ -586,5 +586,5 @@ SEE ALSO
-
+
diff --git a/deps/npm/html/doc/index.html b/deps/npm/html/doc/index.html
index 54586601104d..394e371da4cc 100644
--- a/deps/npm/html/doc/index.html
+++ b/deps/npm/html/doc/index.html
@@ -162,5 +162,5 @@
-
+
diff --git a/deps/npm/html/doc/misc/npm-coding-style.html b/deps/npm/html/doc/misc/npm-coding-style.html
index 89b1f95f3ee4..93ab1a0e18cb 100644
--- a/deps/npm/html/doc/misc/npm-coding-style.html
+++ b/deps/npm/html/doc/misc/npm-coding-style.html
@@ -153,5 +153,5 @@ SEE ALSO
-
+
diff --git a/deps/npm/html/doc/misc/npm-config.html b/deps/npm/html/doc/misc/npm-config.html
index 3ba1d3ba6361..75720461f7ef 100644
--- a/deps/npm/html/doc/misc/npm-config.html
+++ b/deps/npm/html/doc/misc/npm-config.html
@@ -864,5 +864,5 @@ SEE ALSO
-
+
diff --git a/deps/npm/html/doc/misc/npm-developers.html b/deps/npm/html/doc/misc/npm-developers.html
index 19c126cba835..2c64e124ce23 100644
--- a/deps/npm/html/doc/misc/npm-developers.html
+++ b/deps/npm/html/doc/misc/npm-developers.html
@@ -194,5 +194,5 @@ SEE ALSO
-
+
diff --git a/deps/npm/html/doc/misc/npm-disputes.html b/deps/npm/html/doc/misc/npm-disputes.html
index 438188021886..69a49b6e7442 100644
--- a/deps/npm/html/doc/misc/npm-disputes.html
+++ b/deps/npm/html/doc/misc/npm-disputes.html
@@ -13,7 +13,7 @@ Handling Module
SYNOPSIS
Get the author email with npm owner ls <pkgname>
-Email the author, CC support@npmjs.com
+Email the author, CC support@npmjs.com
After a few weeks, if there's no resolution, we'll sort it out.
Don't squat on package names. Publish code or move out of the way.
@@ -51,12 +51,12 @@ DESCRIPTION
owner (Bob).
Joe emails Bob, explaining the situation as respectfully as
possible , and what he would like to do with the module name. He
-adds the npm support staff support@npmjs.com to the CC list of
+adds the npm support staff support@npmjs.com to the CC list of
the email. Mention in the email that Bob can run npm owner add
joe foo to add Joe as an owner of the foo package.
After a reasonable amount of time, if Bob has not responded, or if
Bob and Joe can't come to any sort of resolution, email support
-support@npmjs.com and we'll sort it out. ("Reasonable" is
+support@npmjs.com and we'll sort it out. ("Reasonable" is
usually at least 4 weeks, but extra time is allowed around common
holidays.)
@@ -112,5 +112,5 @@ SEE ALSO
-
+
diff --git a/deps/npm/html/doc/misc/npm-index.html b/deps/npm/html/doc/misc/npm-index.html
index 154c0c47657e..702e543023a9 100644
--- a/deps/npm/html/doc/misc/npm-index.html
+++ b/deps/npm/html/doc/misc/npm-index.html
@@ -162,5 +162,5 @@
-
+
diff --git a/deps/npm/html/doc/misc/npm-orgs.html b/deps/npm/html/doc/misc/npm-orgs.html
index b93a0c4bd18d..7d5a7cba3820 100644
--- a/deps/npm/html/doc/misc/npm-orgs.html
+++ b/deps/npm/html/doc/misc/npm-orgs.html
@@ -86,5 +86,5 @@ Team Admins create teams
-
+
diff --git a/deps/npm/html/doc/misc/npm-registry.html b/deps/npm/html/doc/misc/npm-registry.html
index efb9df8099fb..b36cfa5bbe4f 100644
--- a/deps/npm/html/doc/misc/npm-registry.html
+++ b/deps/npm/html/doc/misc/npm-registry.html
@@ -70,5 +70,5 @@ SEE ALSO
-
+
diff --git a/deps/npm/html/doc/misc/npm-scope.html b/deps/npm/html/doc/misc/npm-scope.html
index 6ba363aa1079..aed4efe7d116 100644
--- a/deps/npm/html/doc/misc/npm-scope.html
+++ b/deps/npm/html/doc/misc/npm-scope.html
@@ -94,5 +94,5 @@ SEE ALSO
-
+
diff --git a/deps/npm/html/doc/misc/npm-scripts.html b/deps/npm/html/doc/misc/npm-scripts.html
index 0d01cc59ffc6..172a6cd7489e 100644
--- a/deps/npm/html/doc/misc/npm-scripts.html
+++ b/deps/npm/html/doc/misc/npm-scripts.html
@@ -213,5 +213,5 @@ SEE ALSO
-
+
diff --git a/deps/npm/html/doc/misc/removing-npm.html b/deps/npm/html/doc/misc/removing-npm.html
index 2109aad11a97..6b2f30a72b91 100644
--- a/deps/npm/html/doc/misc/removing-npm.html
+++ b/deps/npm/html/doc/misc/removing-npm.html
@@ -57,5 +57,5 @@ SEE ALSO
-
+
diff --git a/deps/npm/html/doc/misc/semver.html b/deps/npm/html/doc/misc/semver.html
index 8e677c0f9fca..7e053f6228e1 100644
--- a/deps/npm/html/doc/misc/semver.html
+++ b/deps/npm/html/doc/misc/semver.html
@@ -325,5 +325,5 @@ Ranges
-
+
diff --git a/deps/npm/lib/install/deps.js b/deps/npm/lib/install/deps.js
index 4d315ab1880a..d7081296db0d 100644
--- a/deps/npm/lib/install/deps.js
+++ b/deps/npm/lib/install/deps.js
@@ -326,14 +326,16 @@ function andForEachChild (load, next) {
}
}
-function isDepOptional (tree, name) {
+function isDepOptional (tree, name, pkg) {
+ if (pkg.package && pkg.package._optional) return true
if (!tree.package.optionalDependencies) return false
if (tree.package.optionalDependencies[name] != null) return true
return false
}
var failedDependency = exports.failedDependency = function (tree, name_pkg) {
- var name, pkg
+ var name
+ var pkg = {}
if (typeof name_pkg === 'string') {
name = name_pkg
} else {
@@ -342,7 +344,7 @@ var failedDependency = exports.failedDependency = function (tree, name_pkg) {
}
tree.children = tree.children.filter(noModuleNameMatches(name))
- if (isDepOptional(tree, name)) {
+ if (isDepOptional(tree, name, pkg)) {
return false
}
diff --git a/deps/npm/lib/install/inflate-shrinkwrap.js b/deps/npm/lib/install/inflate-shrinkwrap.js
index ab1bdd1f1912..b70e9576bf86 100644
--- a/deps/npm/lib/install/inflate-shrinkwrap.js
+++ b/deps/npm/lib/install/inflate-shrinkwrap.js
@@ -45,14 +45,16 @@ function inflateShrinkwrap (topPath, tree, swdeps, finishInflating) {
return inflateShrinkwrap(topPath, child, dependencies || {}, next)
} else {
var from = sw.from || requested.raw
- return fetchPackageMetadata(requested, topPath, iferr(next, andAddShrinkwrap(from, dependencies, next)))
+ var optional = sw.optional
+ return fetchPackageMetadata(requested, topPath, iferr(next, andAddShrinkwrap(from, optional, dependencies, next)))
}
}
}
- function andAddShrinkwrap (from, dependencies, next) {
+ function andAddShrinkwrap (from, optional, dependencies, next) {
return function (pkg) {
pkg._from = from
+ pkg._optional = optional
addShrinkwrap(pkg, iferr(next, andAddBundled(pkg, dependencies, next)))
}
}
diff --git a/deps/npm/man/man1/npm-README.1 b/deps/npm/man/man1/npm-README.1
index b8c8d69deffe..21f8a365ecb6 100644
--- a/deps/npm/man/man1/npm-README.1
+++ b/deps/npm/man/man1/npm-README.1
@@ -1,4 +1,4 @@
-.TH "NPM" "1" "October 2016" "" ""
+.TH "NPM" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm\fR \- a JavaScript package manager
.P
diff --git a/deps/npm/man/man1/npm-access.1 b/deps/npm/man/man1/npm-access.1
index 01fa5151e42b..30e9d7250614 100644
--- a/deps/npm/man/man1/npm-access.1
+++ b/deps/npm/man/man1/npm-access.1
@@ -1,4 +1,4 @@
-.TH "NPM\-ACCESS" "1" "October 2016" "" ""
+.TH "NPM\-ACCESS" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-access\fR \- Set access level on published packages
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-adduser.1 b/deps/npm/man/man1/npm-adduser.1
index e6b501c0feda..3543fb9616a8 100644
--- a/deps/npm/man/man1/npm-adduser.1
+++ b/deps/npm/man/man1/npm-adduser.1
@@ -1,4 +1,4 @@
-.TH "NPM\-ADDUSER" "1" "October 2016" "" ""
+.TH "NPM\-ADDUSER" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-adduser\fR \- Add a registry user account
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-bin.1 b/deps/npm/man/man1/npm-bin.1
index a990d7181a73..243b06163ecf 100644
--- a/deps/npm/man/man1/npm-bin.1
+++ b/deps/npm/man/man1/npm-bin.1
@@ -1,4 +1,4 @@
-.TH "NPM\-BIN" "1" "October 2016" "" ""
+.TH "NPM\-BIN" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-bin\fR \- Display npm bin folder
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-bugs.1 b/deps/npm/man/man1/npm-bugs.1
index 854432551a25..512e2aa51103 100644
--- a/deps/npm/man/man1/npm-bugs.1
+++ b/deps/npm/man/man1/npm-bugs.1
@@ -1,4 +1,4 @@
-.TH "NPM\-BUGS" "1" "October 2016" "" ""
+.TH "NPM\-BUGS" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-bugs\fR \- Bugs for a package in a web browser maybe
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-build.1 b/deps/npm/man/man1/npm-build.1
index 3dae1eb60285..98960880cb1f 100644
--- a/deps/npm/man/man1/npm-build.1
+++ b/deps/npm/man/man1/npm-build.1
@@ -1,4 +1,4 @@
-.TH "NPM\-BUILD" "1" "October 2016" "" ""
+.TH "NPM\-BUILD" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-build\fR \- Build a package
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-bundle.1 b/deps/npm/man/man1/npm-bundle.1
index 685969cd5a01..573507fbf00a 100644
--- a/deps/npm/man/man1/npm-bundle.1
+++ b/deps/npm/man/man1/npm-bundle.1
@@ -1,4 +1,4 @@
-.TH "NPM\-BUNDLE" "1" "October 2016" "" ""
+.TH "NPM\-BUNDLE" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-bundle\fR \- REMOVED
.SH DESCRIPTION
diff --git a/deps/npm/man/man1/npm-cache.1 b/deps/npm/man/man1/npm-cache.1
index 16a092c555d3..7a0029dfe117 100644
--- a/deps/npm/man/man1/npm-cache.1
+++ b/deps/npm/man/man1/npm-cache.1
@@ -1,4 +1,4 @@
-.TH "NPM\-CACHE" "1" "October 2016" "" ""
+.TH "NPM\-CACHE" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-cache\fR \- Manipulates packages cache
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-completion.1 b/deps/npm/man/man1/npm-completion.1
index d3170d27e848..9001f1f13060 100644
--- a/deps/npm/man/man1/npm-completion.1
+++ b/deps/npm/man/man1/npm-completion.1
@@ -1,4 +1,4 @@
-.TH "NPM\-COMPLETION" "1" "October 2016" "" ""
+.TH "NPM\-COMPLETION" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-completion\fR \- Tab Completion for npm
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-config.1 b/deps/npm/man/man1/npm-config.1
index 2466f5116267..e7ab261037e9 100644
--- a/deps/npm/man/man1/npm-config.1
+++ b/deps/npm/man/man1/npm-config.1
@@ -1,4 +1,4 @@
-.TH "NPM\-CONFIG" "1" "October 2016" "" ""
+.TH "NPM\-CONFIG" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-config\fR \- Manage the npm configuration files
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-dedupe.1 b/deps/npm/man/man1/npm-dedupe.1
index fa57dfd25414..fbe03de9d206 100644
--- a/deps/npm/man/man1/npm-dedupe.1
+++ b/deps/npm/man/man1/npm-dedupe.1
@@ -1,4 +1,4 @@
-.TH "NPM\-DEDUPE" "1" "October 2016" "" ""
+.TH "NPM\-DEDUPE" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-dedupe\fR \- Reduce duplication
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-deprecate.1 b/deps/npm/man/man1/npm-deprecate.1
index 9721a75e972a..2bf5767c8447 100644
--- a/deps/npm/man/man1/npm-deprecate.1
+++ b/deps/npm/man/man1/npm-deprecate.1
@@ -1,4 +1,4 @@
-.TH "NPM\-DEPRECATE" "1" "October 2016" "" ""
+.TH "NPM\-DEPRECATE" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-deprecate\fR \- Deprecate a version of a package
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-dist-tag.1 b/deps/npm/man/man1/npm-dist-tag.1
index aaa58bea8ed5..bb0223be0e77 100644
--- a/deps/npm/man/man1/npm-dist-tag.1
+++ b/deps/npm/man/man1/npm-dist-tag.1
@@ -1,4 +1,4 @@
-.TH "NPM\-DIST\-TAG" "1" "October 2016" "" ""
+.TH "NPM\-DIST\-TAG" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-dist-tag\fR \- Modify package distribution tags
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-docs.1 b/deps/npm/man/man1/npm-docs.1
index 61ad1c464441..6381ca877073 100644
--- a/deps/npm/man/man1/npm-docs.1
+++ b/deps/npm/man/man1/npm-docs.1
@@ -1,4 +1,4 @@
-.TH "NPM\-DOCS" "1" "October 2016" "" ""
+.TH "NPM\-DOCS" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-docs\fR \- Docs for a package in a web browser maybe
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-edit.1 b/deps/npm/man/man1/npm-edit.1
index 6d4ba2d07aee..5d7304cccd9e 100644
--- a/deps/npm/man/man1/npm-edit.1
+++ b/deps/npm/man/man1/npm-edit.1
@@ -1,4 +1,4 @@
-.TH "NPM\-EDIT" "1" "October 2016" "" ""
+.TH "NPM\-EDIT" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-edit\fR \- Edit an installed package
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-explore.1 b/deps/npm/man/man1/npm-explore.1
index 82f8e64c92b8..ec62c4dddba0 100644
--- a/deps/npm/man/man1/npm-explore.1
+++ b/deps/npm/man/man1/npm-explore.1
@@ -1,4 +1,4 @@
-.TH "NPM\-EXPLORE" "1" "October 2016" "" ""
+.TH "NPM\-EXPLORE" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-explore\fR \- Browse an installed package
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-help-search.1 b/deps/npm/man/man1/npm-help-search.1
index 29a9eeff4a58..5a69b934fb8c 100644
--- a/deps/npm/man/man1/npm-help-search.1
+++ b/deps/npm/man/man1/npm-help-search.1
@@ -1,4 +1,4 @@
-.TH "NPM\-HELP\-SEARCH" "1" "October 2016" "" ""
+.TH "NPM\-HELP\-SEARCH" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-help-search\fR \- Search npm help documentation
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-help.1 b/deps/npm/man/man1/npm-help.1
index b4e46be92331..89d4ce958375 100644
--- a/deps/npm/man/man1/npm-help.1
+++ b/deps/npm/man/man1/npm-help.1
@@ -1,4 +1,4 @@
-.TH "NPM\-HELP" "1" "October 2016" "" ""
+.TH "NPM\-HELP" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-help\fR \- Get help on npm
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-init.1 b/deps/npm/man/man1/npm-init.1
index 1f1337a0ef4a..231fcec12003 100644
--- a/deps/npm/man/man1/npm-init.1
+++ b/deps/npm/man/man1/npm-init.1
@@ -1,4 +1,4 @@
-.TH "NPM\-INIT" "1" "October 2016" "" ""
+.TH "NPM\-INIT" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-init\fR \- Interactively create a package\.json file
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-install-test.1 b/deps/npm/man/man1/npm-install-test.1
index c633093ddc52..6f5b110d7ab2 100644
--- a/deps/npm/man/man1/npm-install-test.1
+++ b/deps/npm/man/man1/npm-install-test.1
@@ -1,4 +1,4 @@
-.TH "NPM" "" "October 2016" "" ""
+.TH "NPM" "" "November 2016" "" ""
.SH "NAME"
\fBnpm\fR
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-install.1 b/deps/npm/man/man1/npm-install.1
index 8c3414b6af6d..3b2058025f06 100644
--- a/deps/npm/man/man1/npm-install.1
+++ b/deps/npm/man/man1/npm-install.1
@@ -1,4 +1,4 @@
-.TH "NPM\-INSTALL" "1" "October 2016" "" ""
+.TH "NPM\-INSTALL" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-install\fR \- Install a package
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-link.1 b/deps/npm/man/man1/npm-link.1
index a584daf181c3..38029dd472e3 100644
--- a/deps/npm/man/man1/npm-link.1
+++ b/deps/npm/man/man1/npm-link.1
@@ -1,4 +1,4 @@
-.TH "NPM\-LINK" "1" "October 2016" "" ""
+.TH "NPM\-LINK" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-link\fR \- Symlink a package folder
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-logout.1 b/deps/npm/man/man1/npm-logout.1
index 65cf15b63520..4a4653fb16ee 100644
--- a/deps/npm/man/man1/npm-logout.1
+++ b/deps/npm/man/man1/npm-logout.1
@@ -1,4 +1,4 @@
-.TH "NPM\-LOGOUT" "1" "October 2016" "" ""
+.TH "NPM\-LOGOUT" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-logout\fR \- Log out of the registry
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-ls.1 b/deps/npm/man/man1/npm-ls.1
index 607de78cd27b..601a3610861e 100644
--- a/deps/npm/man/man1/npm-ls.1
+++ b/deps/npm/man/man1/npm-ls.1
@@ -1,4 +1,4 @@
-.TH "NPM\-LS" "1" "October 2016" "" ""
+.TH "NPM\-LS" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-ls\fR \- List installed packages
.SH SYNOPSIS
@@ -22,7 +22,7 @@ For example, running \fBnpm ls promzard\fP in npm's source tree will show:
.P
.RS 2
.nf
-npm@3.10.9 /path/to/npm
+npm@3.10.10 /path/to/npm
└─┬ init\-package\-json@0\.0\.4
└── promzard@0\.1\.5
.fi
diff --git a/deps/npm/man/man1/npm-outdated.1 b/deps/npm/man/man1/npm-outdated.1
index 63d3dd55131d..c12f40fdf553 100644
--- a/deps/npm/man/man1/npm-outdated.1
+++ b/deps/npm/man/man1/npm-outdated.1
@@ -1,4 +1,4 @@
-.TH "NPM\-OUTDATED" "1" "October 2016" "" ""
+.TH "NPM\-OUTDATED" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-outdated\fR \- Check for outdated packages
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-owner.1 b/deps/npm/man/man1/npm-owner.1
index 7cc1ddf09f2b..71834133fb56 100644
--- a/deps/npm/man/man1/npm-owner.1
+++ b/deps/npm/man/man1/npm-owner.1
@@ -1,4 +1,4 @@
-.TH "NPM\-OWNER" "1" "October 2016" "" ""
+.TH "NPM\-OWNER" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-owner\fR \- Manage package owners
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-pack.1 b/deps/npm/man/man1/npm-pack.1
index 97f2cf669bff..44a791ef4991 100644
--- a/deps/npm/man/man1/npm-pack.1
+++ b/deps/npm/man/man1/npm-pack.1
@@ -1,4 +1,4 @@
-.TH "NPM\-PACK" "1" "October 2016" "" ""
+.TH "NPM\-PACK" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-pack\fR \- Create a tarball from a package
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-ping.1 b/deps/npm/man/man1/npm-ping.1
index 3a19287917d8..98d2c548b962 100644
--- a/deps/npm/man/man1/npm-ping.1
+++ b/deps/npm/man/man1/npm-ping.1
@@ -1,4 +1,4 @@
-.TH "NPM\-PING" "1" "October 2016" "" ""
+.TH "NPM\-PING" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-ping\fR \- Ping npm registry
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-prefix.1 b/deps/npm/man/man1/npm-prefix.1
index c8c4fda0aaeb..65ec8f2d9d6f 100644
--- a/deps/npm/man/man1/npm-prefix.1
+++ b/deps/npm/man/man1/npm-prefix.1
@@ -1,4 +1,4 @@
-.TH "NPM\-PREFIX" "1" "October 2016" "" ""
+.TH "NPM\-PREFIX" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-prefix\fR \- Display prefix
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-prune.1 b/deps/npm/man/man1/npm-prune.1
index 38207324c0fe..44baa657ecec 100644
--- a/deps/npm/man/man1/npm-prune.1
+++ b/deps/npm/man/man1/npm-prune.1
@@ -1,4 +1,4 @@
-.TH "NPM\-PRUNE" "1" "October 2016" "" ""
+.TH "NPM\-PRUNE" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-prune\fR \- Remove extraneous packages
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-publish.1 b/deps/npm/man/man1/npm-publish.1
index b26aa7541f6f..435dddf4be28 100644
--- a/deps/npm/man/man1/npm-publish.1
+++ b/deps/npm/man/man1/npm-publish.1
@@ -1,4 +1,4 @@
-.TH "NPM\-PUBLISH" "1" "October 2016" "" ""
+.TH "NPM\-PUBLISH" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-publish\fR \- Publish a package
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-rebuild.1 b/deps/npm/man/man1/npm-rebuild.1
index 0249a584068c..5b5ead00acbf 100644
--- a/deps/npm/man/man1/npm-rebuild.1
+++ b/deps/npm/man/man1/npm-rebuild.1
@@ -1,4 +1,4 @@
-.TH "NPM\-REBUILD" "1" "October 2016" "" ""
+.TH "NPM\-REBUILD" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-rebuild\fR \- Rebuild a package
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-repo.1 b/deps/npm/man/man1/npm-repo.1
index 4b8f808f05a2..3fe2f722c761 100644
--- a/deps/npm/man/man1/npm-repo.1
+++ b/deps/npm/man/man1/npm-repo.1
@@ -1,4 +1,4 @@
-.TH "NPM\-REPO" "1" "October 2016" "" ""
+.TH "NPM\-REPO" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-repo\fR \- Open package repository page in the browser
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-restart.1 b/deps/npm/man/man1/npm-restart.1
index 88ec6716e268..bab238cb16b2 100644
--- a/deps/npm/man/man1/npm-restart.1
+++ b/deps/npm/man/man1/npm-restart.1
@@ -1,4 +1,4 @@
-.TH "NPM\-RESTART" "1" "October 2016" "" ""
+.TH "NPM\-RESTART" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-restart\fR \- Restart a package
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-root.1 b/deps/npm/man/man1/npm-root.1
index 342541a0aa01..b22c6e950df2 100644
--- a/deps/npm/man/man1/npm-root.1
+++ b/deps/npm/man/man1/npm-root.1
@@ -1,4 +1,4 @@
-.TH "NPM\-ROOT" "1" "October 2016" "" ""
+.TH "NPM\-ROOT" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-root\fR \- Display npm root
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-run-script.1 b/deps/npm/man/man1/npm-run-script.1
index 1adb93cfb5cf..ddc7bc0fef90 100644
--- a/deps/npm/man/man1/npm-run-script.1
+++ b/deps/npm/man/man1/npm-run-script.1
@@ -1,4 +1,4 @@
-.TH "NPM\-RUN\-SCRIPT" "1" "October 2016" "" ""
+.TH "NPM\-RUN\-SCRIPT" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-run-script\fR \- Run arbitrary package scripts
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-search.1 b/deps/npm/man/man1/npm-search.1
index a604aed22442..e412bbd62c09 100644
--- a/deps/npm/man/man1/npm-search.1
+++ b/deps/npm/man/man1/npm-search.1
@@ -1,4 +1,4 @@
-.TH "NPM\-SEARCH" "1" "October 2016" "" ""
+.TH "NPM\-SEARCH" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-search\fR \- Search for packages
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-shrinkwrap.1 b/deps/npm/man/man1/npm-shrinkwrap.1
index 8b722d69e9bc..824d67a3e80c 100644
--- a/deps/npm/man/man1/npm-shrinkwrap.1
+++ b/deps/npm/man/man1/npm-shrinkwrap.1
@@ -1,4 +1,4 @@
-.TH "NPM\-SHRINKWRAP" "1" "October 2016" "" ""
+.TH "NPM\-SHRINKWRAP" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-shrinkwrap\fR \- Lock down dependency versions
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-star.1 b/deps/npm/man/man1/npm-star.1
index 5d452759fcf7..427f16a7cd6f 100644
--- a/deps/npm/man/man1/npm-star.1
+++ b/deps/npm/man/man1/npm-star.1
@@ -1,4 +1,4 @@
-.TH "NPM\-STAR" "1" "October 2016" "" ""
+.TH "NPM\-STAR" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-star\fR \- Mark your favorite packages
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-stars.1 b/deps/npm/man/man1/npm-stars.1
index a49f53f43312..33a7e30254d3 100644
--- a/deps/npm/man/man1/npm-stars.1
+++ b/deps/npm/man/man1/npm-stars.1
@@ -1,4 +1,4 @@
-.TH "NPM\-STARS" "1" "October 2016" "" ""
+.TH "NPM\-STARS" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-stars\fR \- View packages marked as favorites
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-start.1 b/deps/npm/man/man1/npm-start.1
index fbfc1f30c629..eec34f4ab390 100644
--- a/deps/npm/man/man1/npm-start.1
+++ b/deps/npm/man/man1/npm-start.1
@@ -1,4 +1,4 @@
-.TH "NPM\-START" "1" "October 2016" "" ""
+.TH "NPM\-START" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-start\fR \- Start a package
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-stop.1 b/deps/npm/man/man1/npm-stop.1
index 671d037a1a44..62ed5caa5fa4 100644
--- a/deps/npm/man/man1/npm-stop.1
+++ b/deps/npm/man/man1/npm-stop.1
@@ -1,4 +1,4 @@
-.TH "NPM\-STOP" "1" "October 2016" "" ""
+.TH "NPM\-STOP" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-stop\fR \- Stop a package
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-tag.1 b/deps/npm/man/man1/npm-tag.1
index d2a99b48bc07..ac9450d1b7c7 100644
--- a/deps/npm/man/man1/npm-tag.1
+++ b/deps/npm/man/man1/npm-tag.1
@@ -1,4 +1,4 @@
-.TH "NPM\-TAG" "1" "October 2016" "" ""
+.TH "NPM\-TAG" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-tag\fR \- Tag a published version
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-team.1 b/deps/npm/man/man1/npm-team.1
index 95f21cc12779..32461b610f7c 100644
--- a/deps/npm/man/man1/npm-team.1
+++ b/deps/npm/man/man1/npm-team.1
@@ -1,4 +1,4 @@
-.TH "NPM\-TEAM" "1" "October 2016" "" ""
+.TH "NPM\-TEAM" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-team\fR \- Manage organization teams and team memberships
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-test.1 b/deps/npm/man/man1/npm-test.1
index 277107521c23..bb7dcdd7d8eb 100644
--- a/deps/npm/man/man1/npm-test.1
+++ b/deps/npm/man/man1/npm-test.1
@@ -1,4 +1,4 @@
-.TH "NPM\-TEST" "1" "October 2016" "" ""
+.TH "NPM\-TEST" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-test\fR \- Test a package
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-uninstall.1 b/deps/npm/man/man1/npm-uninstall.1
index 2bf88c5e8bc3..794344eb01a0 100644
--- a/deps/npm/man/man1/npm-uninstall.1
+++ b/deps/npm/man/man1/npm-uninstall.1
@@ -1,4 +1,4 @@
-.TH "NPM\-UNINSTALL" "1" "October 2016" "" ""
+.TH "NPM\-UNINSTALL" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-uninstall\fR \- Remove a package
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-unpublish.1 b/deps/npm/man/man1/npm-unpublish.1
index 447fb1d80af4..f901b037d617 100644
--- a/deps/npm/man/man1/npm-unpublish.1
+++ b/deps/npm/man/man1/npm-unpublish.1
@@ -1,4 +1,4 @@
-.TH "NPM\-UNPUBLISH" "1" "October 2016" "" ""
+.TH "NPM\-UNPUBLISH" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-unpublish\fR \- Remove a package from the registry
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-update.1 b/deps/npm/man/man1/npm-update.1
index 3e0bad8dd59d..0326821b034b 100644
--- a/deps/npm/man/man1/npm-update.1
+++ b/deps/npm/man/man1/npm-update.1
@@ -1,4 +1,4 @@
-.TH "NPM\-UPDATE" "1" "October 2016" "" ""
+.TH "NPM\-UPDATE" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-update\fR \- Update a package
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-version.1 b/deps/npm/man/man1/npm-version.1
index 5a2e09353e12..a8fdc4dd8ecd 100644
--- a/deps/npm/man/man1/npm-version.1
+++ b/deps/npm/man/man1/npm-version.1
@@ -1,4 +1,4 @@
-.TH "NPM\-VERSION" "1" "October 2016" "" ""
+.TH "NPM\-VERSION" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-version\fR \- Bump a package version
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-view.1 b/deps/npm/man/man1/npm-view.1
index 41a8f0061308..31b408ea2cb5 100644
--- a/deps/npm/man/man1/npm-view.1
+++ b/deps/npm/man/man1/npm-view.1
@@ -1,4 +1,4 @@
-.TH "NPM\-VIEW" "1" "October 2016" "" ""
+.TH "NPM\-VIEW" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-view\fR \- View registry info
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm-whoami.1 b/deps/npm/man/man1/npm-whoami.1
index 6dbfb2754890..1267864269f8 100644
--- a/deps/npm/man/man1/npm-whoami.1
+++ b/deps/npm/man/man1/npm-whoami.1
@@ -1,4 +1,4 @@
-.TH "NPM\-WHOAMI" "1" "October 2016" "" ""
+.TH "NPM\-WHOAMI" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-whoami\fR \- Display npm username
.SH SYNOPSIS
diff --git a/deps/npm/man/man1/npm.1 b/deps/npm/man/man1/npm.1
index ee25dc257d77..1515a7af956f 100644
--- a/deps/npm/man/man1/npm.1
+++ b/deps/npm/man/man1/npm.1
@@ -1,4 +1,4 @@
-.TH "NPM" "1" "October 2016" "" ""
+.TH "NPM" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm\fR \- javascript package manager
.SH SYNOPSIS
@@ -10,7 +10,7 @@ npm [args]
.RE
.SH VERSION
.P
-3.10.9
+3.10.10
.SH DESCRIPTION
.P
npm is the package manager for the Node JavaScript platform\. It puts
diff --git a/deps/npm/man/man5/npm-folders.5 b/deps/npm/man/man5/npm-folders.5
index 28ce304c0e50..e30e11c5a668 100644
--- a/deps/npm/man/man5/npm-folders.5
+++ b/deps/npm/man/man5/npm-folders.5
@@ -1,4 +1,4 @@
-.TH "NPM\-FOLDERS" "5" "October 2016" "" ""
+.TH "NPM\-FOLDERS" "5" "November 2016" "" ""
.SH "NAME"
\fBnpm-folders\fR \- Folder Structures Used by npm
.SH DESCRIPTION
diff --git a/deps/npm/man/man5/npm-global.5 b/deps/npm/man/man5/npm-global.5
index 28ce304c0e50..e30e11c5a668 100644
--- a/deps/npm/man/man5/npm-global.5
+++ b/deps/npm/man/man5/npm-global.5
@@ -1,4 +1,4 @@
-.TH "NPM\-FOLDERS" "5" "October 2016" "" ""
+.TH "NPM\-FOLDERS" "5" "November 2016" "" ""
.SH "NAME"
\fBnpm-folders\fR \- Folder Structures Used by npm
.SH DESCRIPTION
diff --git a/deps/npm/man/man5/npm-json.5 b/deps/npm/man/man5/npm-json.5
index 2f552b73ccdb..fafa100f77f6 100644
--- a/deps/npm/man/man5/npm-json.5
+++ b/deps/npm/man/man5/npm-json.5
@@ -1,4 +1,4 @@
-.TH "PACKAGE\.JSON" "5" "October 2016" "" ""
+.TH "PACKAGE\.JSON" "5" "November 2016" "" ""
.SH "NAME"
\fBpackage.json\fR \- Specifics of npm's package\.json handling
.SH DESCRIPTION
diff --git a/deps/npm/man/man5/npmrc.5 b/deps/npm/man/man5/npmrc.5
index 8d745e32a8dc..b40918d84f96 100644
--- a/deps/npm/man/man5/npmrc.5
+++ b/deps/npm/man/man5/npmrc.5
@@ -1,4 +1,4 @@
-.TH "NPMRC" "5" "October 2016" "" ""
+.TH "NPMRC" "5" "November 2016" "" ""
.SH "NAME"
\fBnpmrc\fR \- The npm config files
.SH DESCRIPTION
diff --git a/deps/npm/man/man5/package.json.5 b/deps/npm/man/man5/package.json.5
index 2f552b73ccdb..fafa100f77f6 100644
--- a/deps/npm/man/man5/package.json.5
+++ b/deps/npm/man/man5/package.json.5
@@ -1,4 +1,4 @@
-.TH "PACKAGE\.JSON" "5" "October 2016" "" ""
+.TH "PACKAGE\.JSON" "5" "November 2016" "" ""
.SH "NAME"
\fBpackage.json\fR \- Specifics of npm's package\.json handling
.SH DESCRIPTION
diff --git a/deps/npm/man/man7/npm-coding-style.7 b/deps/npm/man/man7/npm-coding-style.7
index 7ecbdcc568c3..e5d71c1ac6c6 100644
--- a/deps/npm/man/man7/npm-coding-style.7
+++ b/deps/npm/man/man7/npm-coding-style.7
@@ -1,4 +1,4 @@
-.TH "NPM\-CODING\-STYLE" "7" "October 2016" "" ""
+.TH "NPM\-CODING\-STYLE" "7" "November 2016" "" ""
.SH "NAME"
\fBnpm-coding-style\fR \- npm's "funny" coding style
.SH DESCRIPTION
diff --git a/deps/npm/man/man7/npm-config.7 b/deps/npm/man/man7/npm-config.7
index a6ad79af3dee..b35e9d1ce0a7 100644
--- a/deps/npm/man/man7/npm-config.7
+++ b/deps/npm/man/man7/npm-config.7
@@ -1,4 +1,4 @@
-.TH "NPM\-CONFIG" "7" "October 2016" "" ""
+.TH "NPM\-CONFIG" "7" "November 2016" "" ""
.SH "NAME"
\fBnpm-config\fR \- More than you probably want to know about npm configuration
.SH DESCRIPTION
diff --git a/deps/npm/man/man7/npm-developers.7 b/deps/npm/man/man7/npm-developers.7
index 6c23dd383f8b..fa849ecfdac3 100644
--- a/deps/npm/man/man7/npm-developers.7
+++ b/deps/npm/man/man7/npm-developers.7
@@ -1,4 +1,4 @@
-.TH "NPM\-DEVELOPERS" "7" "October 2016" "" ""
+.TH "NPM\-DEVELOPERS" "7" "November 2016" "" ""
.SH "NAME"
\fBnpm-developers\fR \- Developer Guide
.SH DESCRIPTION
diff --git a/deps/npm/man/man7/npm-disputes.7 b/deps/npm/man/man7/npm-disputes.7
index 2a091216c226..04ce52b2d934 100644
--- a/deps/npm/man/man7/npm-disputes.7
+++ b/deps/npm/man/man7/npm-disputes.7
@@ -1,4 +1,4 @@
-.TH "NPM\-DISPUTES" "7" "October 2016" "" ""
+.TH "NPM\-DISPUTES" "7" "November 2016" "" ""
.SH "NAME"
\fBnpm-disputes\fR \- Handling Module Name Disputes
.SH SYNOPSIS
diff --git a/deps/npm/man/man7/npm-index.7 b/deps/npm/man/man7/npm-index.7
index 0de2ed249398..f2857df9e562 100644
--- a/deps/npm/man/man7/npm-index.7
+++ b/deps/npm/man/man7/npm-index.7
@@ -1,4 +1,4 @@
-.TH "NPM\-INDEX" "7" "October 2016" "" ""
+.TH "NPM\-INDEX" "7" "November 2016" "" ""
.SH "NAME"
\fBnpm-index\fR \- Index of all npm documentation
.SS npm help README
diff --git a/deps/npm/man/man7/npm-orgs.7 b/deps/npm/man/man7/npm-orgs.7
index 6dffbfc5f23b..95f966e0c1d6 100644
--- a/deps/npm/man/man7/npm-orgs.7
+++ b/deps/npm/man/man7/npm-orgs.7
@@ -1,4 +1,4 @@
-.TH "NPM\-ORGS" "7" "October 2016" "" ""
+.TH "NPM\-ORGS" "7" "November 2016" "" ""
.SH "NAME"
\fBnpm-orgs\fR \- Working with Teams & Orgs
.SH DESCRIPTION
diff --git a/deps/npm/man/man7/npm-registry.7 b/deps/npm/man/man7/npm-registry.7
index ac367e4b8467..2710b1d83529 100644
--- a/deps/npm/man/man7/npm-registry.7
+++ b/deps/npm/man/man7/npm-registry.7
@@ -1,4 +1,4 @@
-.TH "NPM\-REGISTRY" "7" "October 2016" "" ""
+.TH "NPM\-REGISTRY" "7" "November 2016" "" ""
.SH "NAME"
\fBnpm-registry\fR \- The JavaScript Package Registry
.SH DESCRIPTION
diff --git a/deps/npm/man/man7/npm-scope.7 b/deps/npm/man/man7/npm-scope.7
index a066ab9a96fc..af4ffc675a4d 100644
--- a/deps/npm/man/man7/npm-scope.7
+++ b/deps/npm/man/man7/npm-scope.7
@@ -1,4 +1,4 @@
-.TH "NPM\-SCOPE" "7" "October 2016" "" ""
+.TH "NPM\-SCOPE" "7" "November 2016" "" ""
.SH "NAME"
\fBnpm-scope\fR \- Scoped packages
.SH DESCRIPTION
diff --git a/deps/npm/man/man7/npm-scripts.7 b/deps/npm/man/man7/npm-scripts.7
index 1b98cb34cb21..60acb3195eec 100644
--- a/deps/npm/man/man7/npm-scripts.7
+++ b/deps/npm/man/man7/npm-scripts.7
@@ -1,4 +1,4 @@
-.TH "NPM\-SCRIPTS" "7" "October 2016" "" ""
+.TH "NPM\-SCRIPTS" "7" "November 2016" "" ""
.SH "NAME"
\fBnpm-scripts\fR \- How npm handles the "scripts" field
.SH DESCRIPTION
diff --git a/deps/npm/man/man7/removing-npm.7 b/deps/npm/man/man7/removing-npm.7
index 2565ce29e09d..b16fcf7d2e00 100644
--- a/deps/npm/man/man7/removing-npm.7
+++ b/deps/npm/man/man7/removing-npm.7
@@ -1,4 +1,4 @@
-.TH "NPM\-REMOVAL" "1" "October 2016" "" ""
+.TH "NPM\-REMOVAL" "1" "November 2016" "" ""
.SH "NAME"
\fBnpm-removal\fR \- Cleaning the Slate
.SH SYNOPSIS
diff --git a/deps/npm/man/man7/semver.7 b/deps/npm/man/man7/semver.7
index b9336120367b..bff76838f53f 100644
--- a/deps/npm/man/man7/semver.7
+++ b/deps/npm/man/man7/semver.7
@@ -1,4 +1,4 @@
-.TH "SEMVER" "7" "October 2016" "" ""
+.TH "SEMVER" "7" "November 2016" "" ""
.SH "NAME"
\fBsemver\fR \- The semantic versioner for npm
.SH Usage
diff --git a/deps/npm/package.json b/deps/npm/package.json
index c1df08e43d4d..8716d59c3ad7 100644
--- a/deps/npm/package.json
+++ b/deps/npm/package.json
@@ -1,5 +1,5 @@
{
- "version": "3.10.9",
+ "version": "3.10.10",
"name": "npm",
"description": "a package manager for JavaScript",
"keywords": [
@@ -202,12 +202,12 @@
"dumpconf": "env | grep npm | sort | uniq",
"prepublish": "node bin/npm-cli.js prune --prefix=. --no-global && rimraf test/*/*/node_modules && make doc-clean && make -j4 doc",
"preversion": "bash scripts/update-authors.sh && git add AUTHORS && git commit -m \"update AUTHORS\" || true",
- "tap": "tap --reporter=classic --timeout 300",
- "tap-cover": "tap --coverage --reporter=classic --timeout 600",
+ "tap": "tap --timeout 300",
+ "tap-cover": "tap --coverage --timeout 600",
"test": "standard && npm run test-tap",
- "test-coverage": "npm run tap-cover -- \"test/tap/*.js\" \"test/network/*.js\"",
- "test-tap": "npm run tap -- \"test/tap/*.js\"",
- "test-node": "\"$NODE\" \"node_modules/.bin/tap\" --timeout 240 \"test/tap/*.js\" \"test/network/*.js\""
+ "test-coverage": "npm run tap-cover -- \"test/tap/*.js\" \"test/network/*.js\" \"test/slow/*.js\" \"test/broken-under-*/*.js\"",
+ "test-tap": "npm run tap -- \"test/tap/*.js\" \"test/network/*.js\" \"test/slow/*.js\" \"test/broken-under-*/*.js\"",
+ "test-node": "\"$NODE\" \"node_modules/.bin/tap\" --timeout 240 \"test/tap/*.js\" \"test/network/*.js\" \"test/slow/*.js\" \"test/broken-under-nyc*/*.js\""
},
"license": "Artistic-2.0"
}
diff --git a/deps/npm/scripts/changelog.js b/deps/npm/scripts/changelog.js
index abbec4b4e9e1..158a79cc463f 100644
--- a/deps/npm/scripts/changelog.js
+++ b/deps/npm/scripts/changelog.js
@@ -5,14 +5,14 @@ Usage:
node scripts/changelog.js [comittish]
Generates changelog entries in our format as best as its able based on
-commits starting at comittish, or if that's not passed, master.
+commits starting at comittish, or if that's not passed, latest.
Ordinarily this is run via the gen-changelog shell script, which appends
the result to the changelog.
*/
const execSync = require('child_process').execSync
-const branch = process.argv[2] || 'master'
+const branch = process.argv[2] || 'origin/latest'
const log = execSync(`git log --reverse --pretty='format:%h %H%d %s (%aN)%n%b%n---%n' ${branch}...`).toString().split(/\n/)
main()
diff --git a/deps/npm/scripts/maketest b/deps/npm/scripts/maketest
index b4f674393baa..a71cadbc8c33 100755
--- a/deps/npm/scripts/maketest
+++ b/deps/npm/scripts/maketest
@@ -40,13 +40,13 @@ var tmpdir = path.join(basedir, 'tmp')
var conf = {
cwd: testdir,
- env: extend({
+ env: extend(extend({}, process.env), {
npm_config_cache: cachedir,
npm_config_tmp: tmpdir,
npm_config_prefix: globaldir,
npm_config_registry: common.registry,
npm_config_loglevel: 'warn'
- }, process.env)
+ })
}
var server
diff --git a/deps/npm/test/tap/lifecycle-path.js b/deps/npm/test/broken-under-nyc-and-travis/lifecycle-path.js
similarity index 93%
rename from deps/npm/test/tap/lifecycle-path.js
rename to deps/npm/test/broken-under-nyc-and-travis/lifecycle-path.js
index 684fd4d3b589..a9d32d15b05e 100644
--- a/deps/npm/test/tap/lifecycle-path.js
+++ b/deps/npm/test/broken-under-nyc-and-travis/lifecycle-path.js
@@ -83,9 +83,9 @@ function checkPath (withDirOfCurrentNode, t) {
// get the ones we tacked on, then the system-specific requirements
var expectedPaths = ['{{ROOT}}/bin/node-gyp-bin',
- '{{ROOT}}/test/tap/lifecycle-path/node_modules/.bin']
+ '{{ROOT}}/test/broken-under-nyc-and-travis/lifecycle-path/node_modules/.bin']
if (withDirOfCurrentNode) {
- expectedPaths.push('{{ROOT}}/test/tap/lifecycle-path/node-bin')
+ expectedPaths.push('{{ROOT}}/test/broken-under-nyc-and-travis/lifecycle-path/node-bin')
}
var expect = expectedPaths.concat(newPATH.split(pathSplit)).map(function (p) {
return p.replace(/\\/g, '/')
diff --git a/deps/npm/test/tap/whoami.js b/deps/npm/test/broken-under-nyc-and-travis/whoami.js
similarity index 100%
rename from deps/npm/test/tap/whoami.js
rename to deps/npm/test/broken-under-nyc-and-travis/whoami.js
diff --git a/deps/npm/test/tap/legacy-npm-self-install.js b/deps/npm/test/slow/legacy-npm-self-install.js
similarity index 100%
rename from deps/npm/test/tap/legacy-npm-self-install.js
rename to deps/npm/test/slow/legacy-npm-self-install.js
diff --git a/deps/npm/test/tap/invalid-cmd-exit-code.js b/deps/npm/test/tap/invalid-cmd-exit-code.js
index f4bb444a1796..b9a42f1be427 100644
--- a/deps/npm/test/tap/invalid-cmd-exit-code.js
+++ b/deps/npm/test/tap/invalid-cmd-exit-code.js
@@ -4,25 +4,31 @@ var common = require('../common-tap.js')
var opts = { cwd: process.cwd() }
test('npm asdf should return exit code 1', function (t) {
- common.npm(['asdf'], opts, function (er, c) {
- if (er) throw er
- t.ok(c, 'exit code should not be zero')
+ common.npm(['asdf'], opts, function (err, code, stdout, stderr) {
+ if (err) throw err
+ t.ok(code, 'exit code should not be zero')
+ if (stdout.trim()) t.comment(stdout.trim())
+ if (stderr.trim()) t.comment(stderr.trim())
t.end()
})
})
test('npm help should return exit code 0', function (t) {
- common.npm(['help'], opts, function (er, c) {
- if (er) throw er
- t.equal(c, 0, 'exit code should be 0')
+ common.npm(['help'], opts, function (err, code, stdout, stderr) {
+ if (err) throw err
+ t.equal(code, 0, 'exit code should be 0')
+ if (stdout.trim()) t.comment(stdout.trim())
+ if (stderr.trim()) t.comment(stderr.trim())
t.end()
})
})
test('npm help fadf should return exit code 0', function (t) {
- common.npm(['help', 'fadf'], opts, function (er, c) {
- if (er) throw er
- t.equal(c, 0, 'exit code should be 0')
+ common.npm(['help', 'fadf'], opts, function (err, code, stdout, stderr) {
+ if (err) throw err
+ t.equal(code, 0, 'exit code should be 0')
+ if (stdout.trim()) t.comment(stdout.trim())
+ if (stderr.trim()) t.comment(stderr.trim())
t.end()
})
})
diff --git a/deps/npm/test/tap/shrinkwrap-optional-platform.js b/deps/npm/test/tap/shrinkwrap-optional-platform.js
index 09d26f778be3..4dced0253fcb 100644
--- a/deps/npm/test/tap/shrinkwrap-optional-platform.js
+++ b/deps/npm/test/tap/shrinkwrap-optional-platform.js
@@ -33,12 +33,21 @@ var fixture = new Tacks(Dir({
'package.json': File({
name: 'mod1',
version: '1.0.0',
- scripts: {
-
+ scripts: {},
+ 'optionalDependencies': {
+ 'mod2': 'file:../mod2'
},
os: ['nosuchos']
})
}),
+ mod2: Dir({
+ 'package.json': File({
+ name: 'mod2',
+ version: '1.0.0',
+ scripts: {},
+ os: ['nosuchos']
+ })
+ }),
'npm-shrinkwrap.json': File({
name: 'shrinkwrap-optional-platform',
version: '1.0.0',
@@ -48,6 +57,12 @@ var fixture = new Tacks(Dir({
from: 'mod1',
resolved: 'file:mod1',
optional: true
+ },
+ mod2: {
+ version: '1.0.0',
+ from: 'mod2',
+ resolved: 'file:mod2',
+ optional: true
}
}
}),
@@ -93,4 +108,3 @@ test('cleanup', function (t) {
cleanup()
t.done()
})
-
diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h
index beb8042d37b5..df187b8307a6 100644
--- a/deps/v8/include/v8-version.h
+++ b/deps/v8/include/v8-version.h
@@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 5
#define V8_MINOR_VERSION 4
#define V8_BUILD_NUMBER 500
-#define V8_PATCH_LEVEL 43
+#define V8_PATCH_LEVEL 44
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
diff --git a/deps/v8/src/bootstrapper.cc b/deps/v8/src/bootstrapper.cc
index 5142817986cc..cfea3208c9d7 100644
--- a/deps/v8/src/bootstrapper.cc
+++ b/deps/v8/src/bootstrapper.cc
@@ -1206,6 +1206,7 @@ void Genesis::InitializeGlobal(Handle global_object,
JSObject::kHeaderSize, MaybeHandle(),
Builtins::kFunctionPrototypeHasInstance,
static_cast(DONT_ENUM | DONT_DELETE | READ_ONLY));
+ native_context()->set_function_has_instance(*has_instance);
// Set the expected parameters for @@hasInstance to 1; required by builtin.
has_instance->shared()->set_internal_formal_parameter_count(1);
diff --git a/deps/v8/src/contexts.h b/deps/v8/src/contexts.h
index d73135f7a440..fd5b006192b4 100644
--- a/deps/v8/src/contexts.h
+++ b/deps/v8/src/contexts.h
@@ -78,6 +78,7 @@ enum ContextLookupFlags {
V(MAP_GET_METHOD_INDEX, JSFunction, map_get) \
V(MAP_HAS_METHOD_INDEX, JSFunction, map_has) \
V(MAP_SET_METHOD_INDEX, JSFunction, map_set) \
+ V(FUNCTION_HAS_INSTANCE_INDEX, JSFunction, function_has_instance) \
V(OBJECT_VALUE_OF, JSFunction, object_value_of) \
V(OBJECT_TO_STRING, JSFunction, object_to_string) \
V(PROMISE_CATCH_INDEX, JSFunction, promise_catch) \
diff --git a/deps/v8/src/crankshaft/hydrogen.cc b/deps/v8/src/crankshaft/hydrogen.cc
index a33d2a612007..f40337e645f9 100644
--- a/deps/v8/src/crankshaft/hydrogen.cc
+++ b/deps/v8/src/crankshaft/hydrogen.cc
@@ -11563,24 +11563,37 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
HConstant::cast(right)->handle(isolate())->IsJSFunction()) {
Handle function =
Handle::cast(HConstant::cast(right)->handle(isolate()));
- // Make sure the prototype of {function} is the %FunctionPrototype%, and
- // it already has a meaningful initial map (i.e. we constructed at least
- // one instance using the constructor {function}).
- // We can only use the fast case if @@hasInstance was not used so far.
- if (function->has_initial_map() &&
- function->map()->prototype() ==
- function->native_context()->closure() &&
- !function->map()->has_non_instance_prototype() &&
- isolate()->IsHasInstanceLookupChainIntact()) {
- Handle initial_map(function->initial_map(), isolate());
- top_info()->dependencies()->AssumeInitialMapCantChange(initial_map);
- top_info()->dependencies()->AssumePropertyCell(
- isolate()->factory()->has_instance_protector());
- HInstruction* prototype =
- Add(handle(initial_map->prototype(), isolate()));
- HHasInPrototypeChainAndBranch* result =
- New(left, prototype);
- return ast_context()->ReturnControl(result, expr->id());
+ // Make sure that the {function} already has a meaningful initial map
+ // (i.e. we constructed at least one instance using the constructor
+ // {function}).
+ if (function->has_initial_map()) {
+ // Lookup @@hasInstance on the {function}.
+ Handle function_map(function->map(), isolate());
+ PropertyAccessInfo has_instance(
+ this, LOAD, function_map,
+ isolate()->factory()->has_instance_symbol());
+ // Check if we are using the Function.prototype[@@hasInstance].
+ if (has_instance.CanAccessMonomorphic() &&
+ has_instance.IsDataConstant() &&
+ has_instance.constant().is_identical_to(
+ isolate()->function_has_instance())) {
+ // Add appropriate receiver map check and prototype chain
+ // checks to guard the @@hasInstance lookup chain.
+ AddCheckMap(right, function_map);
+ if (has_instance.has_holder()) {
+ Handle prototype(
+ JSObject::cast(has_instance.map()->prototype()), isolate());
+ BuildCheckPrototypeMaps(prototype, has_instance.holder());
+ }
+ // Perform the prototype chain walk.
+ Handle initial_map(function->initial_map(), isolate());
+ top_info()->dependencies()->AssumeInitialMapCantChange(initial_map);
+ HInstruction* prototype =
+ Add(handle(initial_map->prototype(), isolate()));
+ HHasInPrototypeChainAndBranch* result =
+ New(left, prototype);
+ return ast_context()->ReturnControl(result, expr->id());
+ }
}
}
diff --git a/doc/api/addons.md b/doc/api/addons.md
index d91f60ae7bf6..44dc69915c42 100644
--- a/doc/api/addons.md
+++ b/doc/api/addons.md
@@ -423,8 +423,8 @@ To test it in JavaScript:
// test.js
const addon = require('./build/Release/addon');
-var obj1 = addon('hello');
-var obj2 = addon('world');
+const obj1 = addon('hello');
+const obj2 = addon('world');
console.log(obj1.msg, obj2.msg);
// Prints: 'hello world'
```
@@ -482,7 +482,7 @@ To test:
// test.js
const addon = require('./build/Release/addon');
-var fn = addon();
+const fn = addon();
console.log(fn());
// Prints: 'hello world'
```
@@ -645,7 +645,7 @@ Test it with:
// test.js
const addon = require('./build/Release/addon');
-var obj = new addon.MyObject(10);
+const obj = new addon.MyObject(10);
console.log(obj.plusOne());
// Prints: 11
console.log(obj.plusOne());
@@ -660,9 +660,9 @@ Alternatively, it is possible to use a factory pattern to avoid explicitly
creating object instances using the JavaScript `new` operator:
```js
-var obj = addon.createObject();
+const obj = addon.createObject();
// instead of:
-// var obj = new addon.Object();
+// const obj = new addon.Object();
```
First, the `createObject()` method is implemented in `addon.cc`:
@@ -840,7 +840,7 @@ Test it with:
// test.js
const createObject = require('./build/Release/addon');
-var obj = createObject(10);
+const obj = createObject(10);
console.log(obj.plusOne());
// Prints: 11
console.log(obj.plusOne());
@@ -848,7 +848,7 @@ console.log(obj.plusOne());
console.log(obj.plusOne());
// Prints: 13
-var obj2 = createObject(20);
+const obj2 = createObject(20);
console.log(obj2.plusOne());
// Prints: 21
console.log(obj2.plusOne());
@@ -1022,9 +1022,9 @@ Test it with:
// test.js
const addon = require('./build/Release/addon');
-var obj1 = addon.createObject(10);
-var obj2 = addon.createObject(20);
-var result = addon.add(obj1, obj2);
+const obj1 = addon.createObject(10);
+const obj2 = addon.createObject(20);
+const result = addon.add(obj1, obj2);
console.log(result);
// Prints: 30
diff --git a/doc/api/buffer.md b/doc/api/buffer.md
index 093be3f09e92..2eef3512a0c2 100644
--- a/doc/api/buffer.md
+++ b/doc/api/buffer.md
@@ -398,8 +398,8 @@ A zero-length `Buffer` will be created if `size <= 0`.
Unlike [`ArrayBuffers`][`ArrayBuffer`], the underlying memory for `Buffer` instances
created in this way is *not initialized*. The contents of a newly created `Buffer`
-are unknown and *could contain sensitive data*. Use [`buf.fill(0)`][`buf.fill()`]
-to initialize a `Buffer` to zeroes.
+are unknown and *could contain sensitive data*. Use
+[`Buffer.alloc(size)`][`Buffer.alloc()`] instead to initialize a `Buffer` to zeroes.
Example:
@@ -517,7 +517,7 @@ be less than or equal to the value of [`buffer.kMaxLength`]. Otherwise, a
The underlying memory for `Buffer` instances created in this way is *not
initialized*. The contents of the newly created `Buffer` are unknown and
-*may contain sensitive data*. Use [`buf.fill(0)`][`buf.fill()`] to initialize such
+*may contain sensitive data*. Use [`Buffer.alloc()`] instead to initialize
`Buffer` instances to zeroes.
Example:
diff --git a/doc/api/child_process.md b/doc/api/child_process.md
index 6c8861b3b2e1..738b916eb6ac 100644
--- a/doc/api/child_process.md
+++ b/doc/api/child_process.md
@@ -278,7 +278,7 @@ allows messages to be passed back and forth between the parent and child. See
It is important to keep in mind that spawned Node.js child processes are
independent of the parent with exception of the IPC communication channel
-that is established between the two. Each process has it's own memory, with
+that is established between the two. Each process has its own memory, with
their own V8 instances. Because of the additional resource allocations
required, spawning a large number of child Node.js processes is not
recommended.
diff --git a/doc/api/crypto.md b/doc/api/crypto.md
index 62588bfa43c0..ef9db7ffc654 100644
--- a/doc/api/crypto.md
+++ b/doc/api/crypto.md
@@ -232,7 +232,7 @@ added: v0.1.94
-->
Updates the cipher with `data`. If the `input_encoding` argument is given,
-it's value must be one of `'utf8'`, `'ascii'`, or `'latin1'` and the `data`
+its value must be one of `'utf8'`, `'ascii'`, or `'latin1'` and the `data`
argument is a string using the specified encoding. If the `input_encoding`
argument is not given, `data` must be a [`Buffer`][]. If `data` is a
[`Buffer`][] then `input_encoding` is ignored.
@@ -317,7 +317,7 @@ added: v0.1.94
-->
Returns any remaining deciphered contents. If `output_encoding`
-parameter is one of `'latin1'`, `'base64'` or `'hex'`, a string is returned.
+parameter is one of `'latin1'`, `'ascii'` or `'utf8'`, a string is returned.
If an `output_encoding` is not provided, a [`Buffer`][] is returned.
Once the `decipher.final()` method has been called, the `Decipher` object can
@@ -330,7 +330,7 @@ added: v1.0.0
-->
When using an authenticated encryption mode (only `GCM` is currently
-supported), the `cipher.setAAD()` method sets the value used for the
+supported), the `decipher.setAAD()` method sets the value used for the
_additional authenticated data_ (AAD) input parameter.
Returns `this` for method chaining.
@@ -371,7 +371,7 @@ added: v0.1.94
-->
Updates the decipher with `data`. If the `input_encoding` argument is given,
-it's value must be one of `'latin1'`, `'base64'`, or `'hex'` and the `data`
+its value must be one of `'latin1'`, `'base64'`, or `'hex'` and the `data`
argument is a string using the specified encoding. If the `input_encoding`
argument is not given, `data` must be a [`Buffer`][]. If `data` is a
[`Buffer`][] then `input_encoding` is ignored.
@@ -935,8 +935,8 @@ of two ways:
- Using the [`verify.update()`][] and [`verify.verify()`][] methods to verify
the signature.
- The [`crypto.createSign()`][] method is used to create `Sign` instances.
- `Sign` objects are not to be created directly using the `new` keyword.
+The [`crypto.createVerify()`][] method is used to create `Verify` instances.
+`Verify` objects are not to be created directly using the `new` keyword.
Example: Using `Verify` objects as streams:
diff --git a/doc/api/debugger.md b/doc/api/debugger.md
index 48761cf04756..c8a61d2ce742 100644
--- a/doc/api/debugger.md
+++ b/doc/api/debugger.md
@@ -4,10 +4,10 @@
-Node.js includes a full-featured out-of-process debugging utility accessible
-via a simple [TCP-based protocol][] and built-in debugging client. To use it,
-start Node.js with the `debug` argument followed by the path to the script to
-debug; a prompt will be displayed indicating successful launch of the debugger:
+Node.js includes an out-of-process debugging utility accessible via a
+[TCP-based protocol][] and built-in debugging client. To use it, start Node.js
+with the `debug` argument followed by the path to the script to debug; a prompt
+will be displayed indicating successful launch of the debugger:
```txt
$ node debug myscript.js
diff --git a/doc/api/fs.md b/doc/api/fs.md
index f799b869e65c..9eeeffa85785 100644
--- a/doc/api/fs.md
+++ b/doc/api/fs.md
@@ -602,7 +602,9 @@ default value of 64 kb for the same parameter.
`options` can include `start` and `end` values to read a range of bytes from
the file instead of the entire file. Both `start` and `end` are inclusive and
-start at 0. The `encoding` can be any one of those accepted by [`Buffer`][].
+start counting at 0. If `fd` is specified and `start` is omitted or `undefined`,
+`fs.createReadStream()` reads sequentially from the current file position.
+The `encoding` can be any one of those accepted by [`Buffer`][].
If `fd` is specified, `ReadStream` will ignore the `path` argument and will use
the specified file descriptor. This means that no `'open'` event will be
diff --git a/doc/api/https.md b/doc/api/https.md
index c2231dca1830..355fd7b133a7 100644
--- a/doc/api/https.md
+++ b/doc/api/https.md
@@ -158,11 +158,11 @@ var req = https.request(options, (res) => {
process.stdout.write(d);
});
});
-req.end();
req.on('error', (e) => {
console.error(e);
});
+req.end();
```
The options argument has the following options
diff --git a/doc/api/modules.md b/doc/api/modules.md
index ad98a0abcc20..8b8a5d65918e 100644
--- a/doc/api/modules.md
+++ b/doc/api/modules.md
@@ -6,16 +6,18 @@
Node.js has a simple module loading system. In Node.js, files and modules
are in one-to-one correspondence (each file is treated as a separate module).
-As an example, `foo.js` loads the module `circle.js` in the same directory.
-The contents of `foo.js`:
+As an example, consider a file named `foo.js`:
```js
const circle = require('./circle.js');
console.log(`The area of a circle of radius 4 is ${circle.area(4)}`);
```
-The contents of `circle.js`:
+On the first line, `foo.js` loads the module `circle.js` that is in the same
+directory as `foo.js`.
+
+Here are the contents of `circle.js`:
```js
const PI = Math.PI;
@@ -23,7 +25,6 @@ const PI = Math.PI;
exports.area = (r) => PI * r * r;
exports.circumference = (r) => 2 * PI * r;
-
```
The module `circle.js` has exported the functions `area()` and
@@ -529,34 +530,51 @@ const x = require('./x');
console.log(x.a);
```
-#### exports alias
+#### exports shortcut
-The `exports` variable that is available within a module starts as a reference
-to `module.exports`. As with any variable, if you assign a new value to it, it
-is no longer bound to the previous value.
+The `exports` variable is available within a module's file-level scope, and is
+assigned the value of `module.exports` before the module is evaluated.
+
+It allows a shortcut, so that `module.exports.f = ...` can be written more
+succinctly as `exports.f = ...`. However, be aware that like any variable, if a
+new value is assigned to `exports`, it is no longer bound to `module.exports`:
+
+```js
+module.exports.hello = true; // Exported from require of module
+exports = { hello: false }; // Not exported, only available in the module
+```
+
+When the `module.exports` property is being completely replaced by a new
+object, it is common to also reassign `exports`, for example:
+
+```js
+module.exports = exports = function Constructor() {
+ // ... etc.
+```
To illustrate the behavior, imagine this hypothetical implementation of
-`require()`:
+`require()`, which is quite similar to what is actually done by `require()`:
```js
function require(...) {
- // ...
+ var module = { exports: {} };
((module, exports) => {
- // Your module code here
- exports = some_func; // re-assigns exports, exports is no longer
- // a shortcut, and nothing is exported.
- module.exports = some_func; // makes your module export 0
+ // Your module code here. In this example, define a function.
+ function some_func() {};
+ exports = some_func;
+ // At this point, exports is no longer a shortcut to module.exports, and
+ // this module will still export an empty default object.
+ module.exports = some_func;
+ // At this point, the module will now export some_func, instead of the
+ // default object.
})(module, module.exports);
- return module;
+ return module.exports;
}
```
-As a guideline, if the relationship between `exports` and `module.exports`
-seems like magic to you, ignore `exports` and only use `module.exports`.
-
### module.filename
+## Notes
+
+1 Node.js 0.12 and older are intentionally omitted from this document as their support is ending soon.
+
+2 It seems that @targos is working on port of this script here https://github.com/targos/update-v8.
diff --git a/doc/guides/writing_tests.md b/doc/guides/writing-tests.md
similarity index 100%
rename from doc/guides/writing_tests.md
rename to doc/guides/writing-tests.md
diff --git a/doc/onboarding-extras.md b/doc/onboarding-extras.md
index 476e00461382..7b7f60fd0070 100644
--- a/doc/onboarding-extras.md
+++ b/doc/onboarding-extras.md
@@ -24,6 +24,7 @@
| `src/node_crypto.*` | @nodejs/crypto |
| `test/*` | @nodejs/testing |
| `tools/eslint`, `.eslintrc` | @silverwind, @trott |
+| async_hooks | @nodejs/diagnostics |
| upgrading V8 | @nodejs/v8, @nodejs/post-mortem |
| upgrading npm | @fishrock123, @thealphanerd |
| upgrading c-ares | @jbergstroem |
diff --git a/doc/onboarding.md b/doc/onboarding.md
index 5d0560e176e7..665890da9686 100644
--- a/doc/onboarding.md
+++ b/doc/onboarding.md
@@ -14,107 +14,98 @@ onboarding session.
* Prior to the onboarding session, add the new Collaborators to
[the Collaborators team](https://github.com/orgs/nodejs/teams/collaborators).
-## **thank you** for doing this
+## Onboarding session
- * going to cover four things:
- * local setup
- * some project goals & values
- * issues, labels, and reviewing code
- * merging code
-
-## setup
-
- * notifications setup
- * use https://github.com/notifications or set up email
- * watching the main repo will flood your inbox, so be prepared
+* **thank you** for doing this
+* will cover:
+ * [local setup](#local-setup)
+ * [project goals & values](#project-goals--values)
+ * [managing the issue tracker](#managing-the-issue-tracker)
+ * [reviewing PRs](#reviewing-prs)
+ * [landing PRs](#landing-prs)
+## Local setup
* git:
* make sure you have whitespace=fix: `git config --global --add core.whitespace fix`
* usually PR from your own github fork
- * [**See "Updating Node.js from Upstream"**](./onboarding-extras.md#updating-nodejs-from-upstream)
+ * [See "Updating Node.js from Upstream"](./onboarding-extras.md#updating-nodejs-from-upstream)
* make new branches for all commits you make!
+ * notifications:
+ * use [https://github.com/notifications](https://github.com/notifications) or set up email
+ * watching the main repo will flood your inbox, so be prepared
- * `#node-dev` on `chat.freenode.net` is the best place to interact with the CTC / other collaborators
+ * `#node-dev` on [webchat.freenode.net](https://webchat.freenode.net/) is the best place to interact with the CTC / other collaborators
-## a little deeper about the project
+## Project goals & values
* collaborators are effectively part owners
* the project has the goals of its contributors
-
* but, there are some higher-level goals and values
* not everything belongs in core (if it can be done reasonably in userland, let it stay in userland)
* empathy towards users matters (this is in part why we onboard people)
* generally: try to be nice to people
-
-## managing the issue tracker
+## Managing the issue tracker
* you have (mostly) free rein – don't hesitate to close an issue if you are confident that it should be closed
- * this will come more naturally over time
- * IMPORTANT: be nice about closing issues, let people know why, and that issues and PRs can be reopened if necessary
- * Still need to follow the Code of Conduct.
-
+ * **IMPORTANT**: be nice about closing issues, let people know why, and that issues and PRs can be reopened if necessary
+ * Still need to follow the Code of Conduct
- * Labels:
+ * [**See "Labels"**](./onboarding-extras.md#labels)
* There is [a bot](https://github.com/nodejs-github-bot/github-bot) that applies subsystem labels (for example, `doc`, `test`, `assert`, or `buffer`) so that we know what parts of the code base the pull request modifies. It is not perfect, of course. Feel free to apply relevant labels and remove irrelevant labels from pull requests and issues.
- * [**See "Labels"**](./onboarding-extras.md#labels)
* Use the `ctc-review` label if a topic is controversial or isn't coming to
a conclusion after an extended time.
* `semver-{minor,major}`:
- * If a change has the remote *chance* of breaking something, use `semver-major`
+ * If a change has the remote *chance* of breaking something, use the `semver-major` label
* When adding a semver label, add a comment explaining why you're adding it. Do it right away so you don't forget!
- * Notifying humans
- * [**See "Who to CC in issues"**](./onboarding-extras.md#who-to-cc-in-issues)
+ * [**See "Who to CC in issues"**](./onboarding-extras.md#who-to-cc-in-issues)
* will also come more naturally over time
-
- * Reviewing:
- * The primary goal is for the codebase to improve.
- * Secondary (but not far off) is for the person submitting code to succeed.
+## Reviewing PRs
+ * The primary goal is for the codebase to improve.
+ * Secondary (but not far off) is for the person submitting code to succeed.
A pull request from a new contributor is an opportunity to grow the
community.
- * Review a bit at a time. Do not overwhelm new contributors.
- * It is tempting to micro-optimize and make everything about relative
+ * Review a bit at a time. Do not overwhelm new contributors.
+ * It is tempting to micro-optimize and make everything about relative
performance. Don't succumb to that temptation. We change V8 often.
Techniques that provide improved performance today may be unnecessary in
the future.
- * Be aware: Your opinion carries a lot of weight!
- * Nits (requests for small changes that are not essential) are fine, but try
- to avoid stalling the pull request.
- * Note that they are nits when you comment: `Nit: change foo() to bar().`
- * If they are stalling the pull request, fix them yourself on merge.
- * Minimum wait for comments time
- * There is a minimum waiting time which we try to respect for non-trivial
+ * Be aware: Your opinion carries a lot of weight!
+ * Nits (requests for small changes that are not essential) are fine, but try
+ to avoid stalling the pull request.
+ * Note that they are nits when you comment: `Nit: change foo() to bar().`
+ * If they are stalling the pull request, fix them yourself on merge.
+ * Minimum wait for comments time
+ * There is a minimum waiting time which we try to respect for non-trivial
changes, so that people who may have important input in such a
distributed project are able to respond.
- * For non-trivial changes, leave the pull request open for at least 48
+ * For non-trivial changes, leave the pull request open for at least 48
hours (72 hours on a weekend).
- * If a pull request is abandoned, check if they'd mind if you took it over
+ * If a pull request is abandoned, check if they'd mind if you took it over
(especially if it just has nits left).
- * Approving a change
- * Collaborators indicate that they have reviewed and approve of the
+ * Approving a change
+ * Collaborators indicate that they have reviewed and approve of the
the changes in a pull request by commenting with `LGTM`, which stands
for "looks good to me".
- * You have the power to `LGTM` another collaborator's (including TSC/CTC
+ * You have the power to `LGTM` another collaborator's (including TSC/CTC
members) work.
- * You may not `LGTM` your own pull requests.
- * You have the power to `LGTM` anyone else's pull requests.
-
+ * You may not `LGTM` your own pull requests.
+ * You have the power to `LGTM` anyone else's pull requests.
- * what belongs in node:
+ * What belongs in node:
* opinions vary, but I find the following helpful:
* if node itself needs it (due to historic reasons), then it belongs in node
* that is to say, url is there because of http, freelist is there because of http, et al
* also, things that cannot be done outside of core, or only with significant pain (example: async-wrap)
-
* Continuous Integration (CI) Testing:
- * https://ci.nodejs.org/
+ * [https://ci.nodejs.org/](https://ci.nodejs.org/)
* It is not automatically run. You need to start it manually.
* Log in on CI is integrated with GitHub. Try to log in now!
* You will be using `node-test-pull-request` most of the time. Go there now!
@@ -130,85 +121,13 @@ onboarding session.
* Use the [Build WG repo](https://github.com/nodejs/build) to file issues for the Build WG members who maintain the CI infrastructure.
-## Landing PRs: Overview
-
- * The [Collaborator Guide](https://github.com/nodejs/node/blob/master/COLLABORATOR_GUIDE.md#technical-howto) is a great resource.
-
-
- * No one (including TSC or CTC members) pushes directly to master without review.
- * An exception is made for release commits only.
-
-
- * One `LGTM` is sufficient, except for semver-major changes.
- * More than one is better.
- * Breaking changes must be LGTM'ed by at least two CTC members.
- * If one or more Collaborators object to a change, it should not land until
- the objection is addressed. The options for such a situation include:
- * Engaging those with objections to determine a viable path forward;
- * Altering the pull request to address the objections;
- * Escalating the discussion to the CTC using the `ctc-review` label. This
- should only be done after the previous options have been exhausted.
-
- * Wait before merging non-trivial changes.
- * 48 hours during the week and 72 hours on weekends.
- * An example of a trivial change would be correcting the misspelling of a single word in a documentation file. This sort of change still needs to receive at least one `LGTM` but it does not need to wait 48 hours before landing.
-
- * **Run the PR through CI before merging!**
- * An exception can be made for documentation-only PRs as long as it does not include the `addons.md` documentation file. (Example code from that document is extracted and built as part of the tests!)
-
- * What if something goes wrong?
- * Ping a CTC member.
- * `#node-dev` on freenode
- * Force-pushing to fix things after is allowed for ~10 minutes. Avoid it if you can.
- * Use `--force-with-lease` to minimize the chance of overwriting someone else's change.
- * Post to `#node-dev` (IRC) if you force push.
-
-
-## Landing PRs: Details
-
-* Please never use GitHub's green ["Merge Pull Request"](https://help.github.com/articles/merging-a-pull-request/#merging-a-pull-request-using-the-github-web-interface) button.
- * If you do, please force-push removing the merge.
- * Reasons for not using the web interface button:
- * The merge method will add an unnecessary merge commit.
- * The rebase & merge method adds metadata to the commit title.
- * The rebase method changes the author.
- * The squash & merge method has been known to add metadata to the commit title.
- * If more than one author has contributed to the PR, only the latest author will be considered during the squashing.
-
-
-Update your `master` branch (or whichever branch you are landing on, almost always `master`)
-
-* [**See "Updating Node.js from Upstream"**](./onboarding-extras.md#updating-nodejs-from-upstream)
-
-Landing a PR
-
-* If it all looks good, `curl -L 'url-of-pr.patch' | git am`
- * If `git am` fails, see [the relevant section of the Onboarding Extras doc](./onboarding-extras.md#if-git-am-fails).
-* `git rebase -i upstream/master`
-* Squash into logical commits if necessary.
-* `./configure && make -j8 test` (`-j8` builds node in parallel with 8 threads. adjust to the number of cores (or processor-level threads) your processor has (or slightly more) for best results.)
-* Amend the commit description.
- * The commit message text must conform to the [commit message guidelines](../CONTRIBUTING.md#step-3-commit).
- * Add required metadata:
- * `PR-URL: `
- * `Reviewed-By: `
- * Easiest to use `git log`, then do a search.
- * In vim: `/Name` + `enter` (+ `n` as much as you need to)
- * Only include collaborators who have commented `LGTM`.
- * Add additional metadata as appropriate:
- * `Fixes: `
- * Full URL of GitHub issue that the PR fixes.
- * This will automatically close the PR when the commit lands in master.
- * `Refs: `
- * Full URL of material that might provide additional useful information or context to someone trying to understand the change set or the thinking behind it.
-* Optional: Force push the amended commit to the branch you used to open the pull request. If your branch is called `bugfix`, then the command would be `git push --force-with-lease origin master:bugfix`. When the pull request is closed, this will cause the pull request to show the purple merged status rather than the red closed status that is usually used for pull requests that weren't merged. Only do this when landing your own contributions.
-* `git push upstream master`
- * Close the pull request with a "Landed in ``" comment.
+## Landing PRs
+ * [See the Collaborator Guide: Technical HOWTO](https://github.com/nodejs/node/blob/master/COLLABORATOR_GUIDE.md#technical-howto)
## Exercise: Make a PR adding yourself to the README
- * Example: https://github.com/nodejs/node/commit/7b09aade8468e1c930f36b9c81e6ac2ed5bc8732
+ * Example: [https://github.com/nodejs/node/commit/7b09aade8468e1c930f36b9c81e6ac2ed5bc8732](https://github.com/nodejs/node/commit/7b09aade8468e1c930f36b9c81e6ac2ed5bc8732)
* For raw commit message: `git log 7b09aade8468e1c930f36b9c81e6ac2ed5bc8732 -1`
* Collaborators are in alphabetical order by GitHub username.
* Label your pull request with the `doc` subsystem label.
@@ -216,18 +135,17 @@ Landing a PR
* After a `LGTM` or two, land the PR.
* Be sure to add the `PR-URL: ` and appropriate `Reviewed-By:` metadata!
-
-## final notes
+## Final notes
* don't worry about making mistakes: everybody makes them, there's a lot to internalize and that takes time (and we recognize that!)
* very few (no?) mistakes are unrecoverable
- * the existing node committers trust you and are grateful for your help!
+ * the existing collaborators trust you and are grateful for your help!
* other repos:
- * https://github.com/nodejs/dev-policy
- * https://github.com/nodejs/NG
- * https://github.com/nodejs/api
- * https://github.com/nodejs/build
- * https://github.com/nodejs/docs
- * https://github.com/nodejs/nodejs.org
- * https://github.com/nodejs/readable-stream
- * https://github.com/nodejs/LTS
+ * [https://github.com/nodejs/dev-policy](https://github.com/nodejs/dev-policy)
+ * [https://github.com/nodejs/NG](https://github.com/nodejs/NG)
+ * [https://github.com/nodejs/api](https://github.com/nodejs/api)
+ * [https://github.com/nodejs/build](https://github.com/nodejs/build)
+ * [https://github.com/nodejs/docs](https://github.com/nodejs/docs)
+ * [https://github.com/nodejs/nodejs.org](https://github.com/nodejs/nodejs.org)
+ * [https://github.com/nodejs/readable-stream](https://github.com/nodejs/readable-stream)
+ * [https://github.com/nodejs/LTS](https://github.com/nodejs/LTS)
diff --git a/doc/topics/event-loop-timers-and-nexttick.md b/doc/topics/event-loop-timers-and-nexttick.md
index ca2e1b555981..d7d0ee96e9c4 100644
--- a/doc/topics/event-loop-timers-and-nexttick.md
+++ b/doc/topics/event-loop-timers-and-nexttick.md
@@ -9,13 +9,13 @@ offloading operations to the system kernel whenever possible.
Since most modern kernels are multi-threaded, they can handle multiple
operations executing in the background. When one of these operations
completes, the kernel tells Node.js so that the appropriate callback
-may added to the **poll** queue to eventually be executed. We'll explain
+may be added to the **poll** queue to eventually be executed. We'll explain
this in further detail later in this topic.
## Event Loop Explained
When Node.js starts, it initializes the event loop, processes the
-provided input script (or drops into the REPL, which is not covered in
+provided input script (or drops into the [REPL][], which is not covered in
this document) which may make async API calls, schedule timers, or call
`process.nextTick()`, then begins processing the event loop.
@@ -144,7 +144,9 @@ the timer's callback. In this example, you will see that the total delay
between the timer being scheduled and its callback being executed will
be 105ms.
-Note: To prevent the **poll** phase from starving the event loop, libuv
+Note: To prevent the **poll** phase from starving the event loop, [libuv]
+(http://libuv.org/) (the C library that implements the Node.js
+event loop and all of the asynchronous behaviors of the platform)
also has a hard maximum (system dependent) before it stops polling for
more events.
@@ -480,3 +482,5 @@ myEmitter.on('event', function() {
console.log('an event occurred!');
});
```
+
+[REPL]: https://nodejs.org/api/repl.html#repl_repl
diff --git a/lib/_debugger.js b/lib/_debugger.js
index 738eb9871bb2..d3bf1f9ffa2d 100644
--- a/lib/_debugger.js
+++ b/lib/_debugger.js
@@ -187,7 +187,7 @@ Client.prototype._addScript = function(desc) {
this.scripts[desc.id] = desc;
if (desc.name) {
desc.isNative = (desc.name.replace('.js', '') in natives) ||
- desc.name == 'node.js';
+ desc.name === 'node.js';
}
};
@@ -202,7 +202,7 @@ Client.prototype._onResponse = function(res) {
var index = -1;
this._reqCallbacks.some(function(fn, i) {
- if (fn.request_seq == res.body.request_seq) {
+ if (fn.request_seq === res.body.request_seq) {
cb = fn;
index = i;
return true;
@@ -212,25 +212,25 @@ Client.prototype._onResponse = function(res) {
var self = this;
var handled = false;
- if (res.headers.Type == 'connect') {
+ if (res.headers.Type === 'connect') {
// Request a list of scripts for our own storage.
self.reqScripts();
self.emit('ready');
handled = true;
- } else if (res.body && res.body.event == 'break') {
+ } else if (res.body && res.body.event === 'break') {
this.emit('break', res.body);
handled = true;
- } else if (res.body && res.body.event == 'exception') {
+ } else if (res.body && res.body.event === 'exception') {
this.emit('exception', res.body);
handled = true;
- } else if (res.body && res.body.event == 'afterCompile') {
+ } else if (res.body && res.body.event === 'afterCompile') {
this._addHandle(res.body.body.script);
handled = true;
- } else if (res.body && res.body.event == 'scriptCollected') {
+ } else if (res.body && res.body.event === 'scriptCollected') {
// ???
this._removeScript(res.body.body.script);
handled = true;
@@ -328,7 +328,7 @@ Client.prototype.reqScopes = function(cb) {
Client.prototype.reqEval = function(expression, cb) {
var self = this;
- if (this.currentFrame == NO_FRAME) {
+ if (this.currentFrame === NO_FRAME) {
// Only need to eval in global scope.
this.reqFrameEval(expression, NO_FRAME, cb);
return;
@@ -358,7 +358,7 @@ Client.prototype.reqEval = function(expression, cb) {
// Finds the first scope in the array in which the expression evals.
Client.prototype._reqFramesEval = function(expression, evalFrames, cb) {
- if (evalFrames.length == 0) {
+ if (evalFrames.length === 0) {
// Just eval in global scope.
this.reqFrameEval(expression, NO_FRAME, cb);
return;
@@ -382,7 +382,7 @@ Client.prototype.reqFrameEval = function(expression, frame, cb) {
arguments: { expression: expression }
};
- if (frame == NO_FRAME) {
+ if (frame === NO_FRAME) {
req.arguments.global = true;
} else {
req.arguments.frame = frame;
@@ -529,9 +529,9 @@ Client.prototype.mirrorObject = function(handle, depth, cb) {
var mirror;
var waiting = 1;
- if (handle.className == 'Array') {
+ if (handle.className === 'Array') {
mirror = [];
- } else if (handle.className == 'Date') {
+ } else if (handle.className === 'Date') {
mirror = new Date(handle.value);
} else {
mirror = {};
@@ -774,10 +774,20 @@ function Interface(stdin, stdout, args) {
process.once('SIGHUP', process.exit.bind(process, 0));
var proto = Interface.prototype;
- const ignored = ['pause', 'resume', 'exitRepl', 'handleBreak',
- 'requireConnection', 'killChild', 'trySpawn',
- 'controlEval', 'debugEval', 'print', 'childPrint',
- 'clearline'];
+ const ignored = [
+ 'pause',
+ 'resume',
+ 'exitRepl',
+ 'handleBreak',
+ 'requireConnection',
+ 'killChild',
+ 'trySpawn',
+ 'controlEval',
+ 'debugEval',
+ 'print',
+ 'childPrint',
+ 'clearline'
+ ];
const shortcut = {
'run': 'r',
'cont': 'c',
@@ -829,7 +839,7 @@ function Interface(stdin, stdout, args) {
// Run script automatically
this.pause();
- setImmediate(() => { this.run(); });
+ setImmediate(() => { this.run(() => this.resume()); });
}
@@ -1097,14 +1107,14 @@ Interface.prototype.list = function(delta) {
var lineno = res.fromLine + i + 1;
if (lineno < from || lineno > to) continue;
- const current = lineno == 1 + client.currentSourceLine;
+ const current = lineno === 1 + client.currentSourceLine;
const breakpoint = client.breakpoints.some(function(bp) {
return (bp.scriptReq === client.currentScript ||
bp.script === client.currentScript) &&
- bp.line == lineno;
+ bp.line === lineno;
});
- if (lineno == 1) {
+ if (lineno === 1) {
// The first line needs to have the module wrapper filtered out of
// it.
var wrapper = Module.wrapper[0];
@@ -1151,7 +1161,7 @@ Interface.prototype.backtrace = function() {
return;
}
- if (bt.totalFrames == 0) {
+ if (bt.totalFrames === 0) {
self.print('(empty stack)');
} else {
const trace = [];
@@ -1193,10 +1203,10 @@ Interface.prototype.scripts = function() {
var script = client.scripts[id];
if (script !== null && typeof script === 'object' && script.name) {
if (displayNatives ||
- script.name == client.currentScript ||
+ script.name === client.currentScript ||
!script.isNative) {
scripts.push(
- (script.name == client.currentScript ? '* ' : ' ') +
+ (script.name === client.currentScript ? '* ' : ' ') +
id + ': ' +
path.basename(script.name)
);
diff --git a/lib/_http_server.js b/lib/_http_server.js
index 99671832ebb2..c5f92d52d54d 100644
--- a/lib/_http_server.js
+++ b/lib/_http_server.js
@@ -525,7 +525,7 @@ function connectionListener(socket) {
}
if (req.headers.expect !== undefined &&
- (req.httpVersionMajor == 1 && req.httpVersionMinor == 1)) {
+ (req.httpVersionMajor === 1 && req.httpVersionMinor === 1)) {
if (continueExpression.test(req.headers.expect)) {
res._expect_continue = true;
diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js
index cd793cb34f0a..d9dafceb950d 100644
--- a/lib/_tls_wrap.js
+++ b/lib/_tls_wrap.js
@@ -545,7 +545,7 @@ TLSSocket.prototype.renegotiate = function(options, callback) {
};
TLSSocket.prototype.setMaxSendFragment = function setMaxSendFragment(size) {
- return this._handle.setMaxSendFragment(size) == 1;
+ return this._handle.setMaxSendFragment(size) === 1;
};
TLSSocket.prototype.getTLSTicket = function getTLSTicket() {
diff --git a/lib/buffer.js b/lib/buffer.js
index b2325098bcbb..3453f5fe8cd6 100644
--- a/lib/buffer.js
+++ b/lib/buffer.js
@@ -72,17 +72,7 @@ function alignPool() {
* much breakage at this time. It's not likely that the Buffer constructors
* would ever actually be removed.
**/
-var newBufferWarned = false;
function Buffer(arg, encodingOrOffset, length) {
- if (!new.target && !newBufferWarned) {
- newBufferWarned = true;
- process.emitWarning(
- 'Using Buffer without `new` will soon stop working. ' +
- 'Use `new Buffer()`, or preferably ' +
- '`Buffer.from()`, `Buffer.allocUnsafe()` or `Buffer.alloc()` instead.',
- 'DeprecationWarning'
- );
- }
// Common case.
if (typeof arg === 'number') {
if (typeof encodingOrOffset === 'string') {
@@ -238,7 +228,7 @@ function fromArrayLike(obj) {
}
function fromArrayBuffer(obj, byteOffset, length) {
- byteOffset >>>= 0;
+ byteOffset = internalUtil.toInteger(byteOffset);
const maxLength = obj.byteLength - byteOffset;
@@ -248,7 +238,7 @@ function fromArrayBuffer(obj, byteOffset, length) {
if (length === undefined) {
length = maxLength;
} else {
- length >>>= 0;
+ length = internalUtil.toLength(length);
if (length > maxLength)
throw new RangeError("'length' is out of bounds");
}
diff --git a/lib/child_process.js b/lib/child_process.js
index afdc5ae551a9..76ec6d3d0f94 100644
--- a/lib/child_process.js
+++ b/lib/child_process.js
@@ -70,10 +70,10 @@ exports._forkChild = function(fd) {
p.open(fd);
p.unref();
const control = setupChannel(process, p);
- process.on('newListener', function(name) {
+ process.on('newListener', function onNewListener(name) {
if (name === 'message' || name === 'disconnect') control.ref();
});
- process.on('removeListener', function(name) {
+ process.on('removeListener', function onRemoveListener(name) {
if (name === 'message' || name === 'disconnect') control.unref();
});
};
@@ -247,7 +247,7 @@ exports.execFile = function(file /*, args, options, callback*/) {
}
if (options.timeout > 0) {
- timeoutId = setTimeout(function() {
+ timeoutId = setTimeout(function delayedKill() {
kill();
timeoutId = null;
}, options.timeout);
@@ -257,7 +257,7 @@ exports.execFile = function(file /*, args, options, callback*/) {
if (encoding)
child.stdout.setEncoding(encoding);
- child.stdout.addListener('data', function(chunk) {
+ child.stdout.on('data', function onChildStdout(chunk) {
stdoutLen += encoding ? Buffer.byteLength(chunk, encoding) : chunk.length;
if (stdoutLen > options.maxBuffer) {
@@ -276,7 +276,7 @@ exports.execFile = function(file /*, args, options, callback*/) {
if (encoding)
child.stderr.setEncoding(encoding);
- child.stderr.addListener('data', function(chunk) {
+ child.stderr.on('data', function onChildStderr(chunk) {
stderrLen += encoding ? Buffer.byteLength(chunk, encoding) : chunk.length;
if (stderrLen > options.maxBuffer) {
@@ -297,12 +297,14 @@ exports.execFile = function(file /*, args, options, callback*/) {
return child;
};
-var _deprecatedCustomFds = internalUtil.deprecate(function(options) {
- options.stdio = options.customFds.map(function(fd) {
- return fd === -1 ? 'pipe' : fd;
- });
-}, 'child_process: options.customFds option is deprecated. ' +
- 'Use options.stdio instead.');
+const _deprecatedCustomFds = internalUtil.deprecate(
+ function deprecateCustomFds(options) {
+ options.stdio = options.customFds.map(function mapCustomFds(fd) {
+ return fd === -1 ? 'pipe' : fd;
+ });
+ }, 'child_process: options.customFds option is deprecated. ' +
+ 'Use options.stdio instead.'
+);
function _convertCustomFds(options) {
if (options.customFds && !options.stdio) {
diff --git a/lib/constants.js b/lib/constants.js
index deebf90513da..fec7e13d9414 100644
--- a/lib/constants.js
+++ b/lib/constants.js
@@ -5,7 +5,7 @@
// are most relevant.
const constants = process.binding('constants');
Object.assign(exports,
- constants.os.errors,
+ constants.os.errno,
constants.os.signals,
constants.fs,
constants.crypto);
diff --git a/lib/https.js b/lib/https.js
index b8969b684524..26b6cbf279a1 100644
--- a/lib/https.js
+++ b/lib/https.js
@@ -31,7 +31,7 @@ function Server(opts, requestListener) {
this.addListener('request', requestListener);
}
- this.addListener('tlsClientError', function(err, conn) {
+ this.addListener('tlsClientError', function addListener(err, conn) {
if (!this.emit('clientError', err, conn))
conn.destroy(err);
});
@@ -43,7 +43,7 @@ exports.Server = Server;
Server.prototype.setTimeout = http.Server.prototype.setTimeout;
-exports.createServer = function(opts, requestListener) {
+exports.createServer = function createServer(opts, requestListener) {
return new Server(opts, requestListener);
};
@@ -112,7 +112,7 @@ function Agent(options) {
inherits(Agent, http.Agent);
Agent.prototype.createConnection = createConnection;
-Agent.prototype.getName = function(options) {
+Agent.prototype.getName = function getName(options) {
var name = http.Agent.prototype.getName.call(this, options);
name += ':';
@@ -186,7 +186,7 @@ const globalAgent = new Agent();
exports.globalAgent = globalAgent;
exports.Agent = Agent;
-exports.request = function(options, cb) {
+exports.request = function request(options, cb) {
if (typeof options === 'string') {
options = url.parse(options);
if (!options.hostname) {
@@ -199,7 +199,7 @@ exports.request = function(options, cb) {
return http.request(options, cb);
};
-exports.get = function(options, cb) {
+exports.get = function get(options, cb) {
var req = exports.request(options, cb);
req.end();
return req;
diff --git a/lib/internal/process/promises.js b/lib/internal/process/promises.js
index 3da1011541bf..83dee491a55c 100644
--- a/lib/internal/process/promises.js
+++ b/lib/internal/process/promises.js
@@ -8,6 +8,11 @@ let lastPromiseId = 1;
exports.setup = setupPromises;
+function getAsynchronousRejectionWarningObject(uid) {
+ return new Error('Promise rejection was handled ' +
+ `asynchronously (rejection id: ${uid})`);
+}
+
function setupPromises(scheduleMicrotasks) {
process._setupPromises(function(event, promise, reason) {
if (event === promiseRejectEvent.unhandled)
@@ -31,10 +36,15 @@ function setupPromises(scheduleMicrotasks) {
const uid = promiseToGuidProperty.get(promise);
promiseToGuidProperty.delete(promise);
if (hasBeenNotified === true) {
+ let warning = null;
+ if (!process.listenerCount('rejectionHandled')) {
+ // Generate the warning object early to get a good stack trace.
+ warning = getAsynchronousRejectionWarningObject(uid);
+ }
process.nextTick(function() {
if (!process.emit('rejectionHandled', promise)) {
- const warning = new Error('Promise rejection was handled ' +
- `asynchronously (rejection id: ${uid})`);
+ if (warning === null)
+ warning = getAsynchronousRejectionWarningObject(uid);
warning.name = 'PromiseRejectionHandledWarning';
warning.id = uid;
process.emitWarning(warning);
@@ -50,6 +60,9 @@ function setupPromises(scheduleMicrotasks) {
`(rejection id: ${uid}): ${reason}`);
warning.name = 'UnhandledPromiseRejectionWarning';
warning.id = uid;
+ if (reason instanceof Error) {
+ warning.stack = reason.stack;
+ }
process.emitWarning(warning);
if (!deprecationWarned) {
deprecationWarned = true;
diff --git a/lib/internal/util.js b/lib/internal/util.js
index 4ada8dd0cc16..238eb6589136 100644
--- a/lib/internal/util.js
+++ b/lib/internal/util.js
@@ -112,15 +112,15 @@ exports.normalizeEncoding = function normalizeEncoding(enc) {
case 'utf-8':
return 'utf8';
case 'ucs2':
- case 'utf16le':
case 'ucs-2':
+ case 'utf16le':
case 'utf-16le':
return 'utf16le';
+ case 'latin1':
case 'binary':
return 'latin1';
case 'base64':
case 'ascii':
- case 'latin1':
case 'hex':
return enc;
default:
@@ -161,3 +161,21 @@ exports.cachedResult = function cachedResult(fn) {
return result;
};
};
+
+/*
+ * Implementation of ToInteger as per ECMAScript Specification
+ * Refer: http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger
+ */
+const toInteger = exports.toInteger = function toInteger(argument) {
+ const number = +argument;
+ return Number.isNaN(number) ? 0 : Math.trunc(number);
+};
+
+/*
+ * Implementation of ToLength as per ECMAScript Specification
+ * Refer: http://www.ecma-international.org/ecma-262/6.0/#sec-tolength
+ */
+exports.toLength = function toLength(argument) {
+ const len = toInteger(argument);
+ return len <= 0 ? 0 : Math.min(len, Number.MAX_SAFE_INTEGER);
+};
diff --git a/lib/repl.js b/lib/repl.js
index 7a735371ffd6..2bb25e8ca339 100644
--- a/lib/repl.js
+++ b/lib/repl.js
@@ -93,6 +93,7 @@ class LineParser {
this.shouldFail = false;
this.blockComment = false;
this.regExpLiteral = false;
+ this.prevTokenChar = null;
}
parseLine(line) {
@@ -132,7 +133,11 @@ class LineParser {
if (previous === '/') {
if (current === '*') {
this.blockComment = true;
- } else {
+ } else if (
+ // Distinguish between a division operator and the start of a regex
+ // by examining the non-whitespace character that precedes the /
+ [null, '(', '[', '{', '}', ';'].includes(this.prevTokenChar)
+ ) {
this.regExpLiteral = true;
}
previous = null;
@@ -147,6 +152,8 @@ class LineParser {
this._literal = this._literal || current;
}
+ if (current.trim() && current !== '/') this.prevTokenChar = current;
+
previous = current;
}
@@ -238,7 +245,33 @@ function REPLServer(prompt,
eval_ = eval_ || defaultEval;
+ function preprocess(code) {
+ let cmd = code;
+ if (/^\s*\{/.test(cmd) && /\}\s*$/.test(cmd)) {
+ // It's confusing for `{ a : 1 }` to be interpreted as a block
+ // statement rather than an object literal. So, we first try
+ // to wrap it in parentheses, so that it will be interpreted as
+ // an expression.
+ cmd = `(${cmd})`;
+ self.wrappedCmd = true;
+ } else {
+ // Mitigate https://github.com/nodejs/node/issues/548
+ cmd = cmd.replace(
+ /^\s*function(?:\s*(\*)\s*|\s+)([^(]+)/,
+ (_, genStar, name) => `var ${name} = function ${genStar || ''}${name}`
+ );
+ }
+ // Append a \n so that it will be either
+ // terminated, or continued onto the next expression if it's an
+ // unexpected end of input.
+ return `${cmd}\n`;
+ }
+
function defaultEval(code, context, file, cb) {
+ // Remove trailing new line
+ code = code.replace(/\n$/, '');
+ code = preprocess(code);
+
var err, result, retry = false, input = code, wrappedErr;
// first, create the Script object to check the syntax
@@ -506,8 +539,7 @@ function REPLServer(prompt,
}
}
- var evalCmd = self.bufferedCommand + cmd;
- evalCmd = preprocess(evalCmd);
+ const evalCmd = self.bufferedCommand + cmd + '\n';
debug('eval %j', evalCmd);
self.eval(evalCmd, self.context, 'repl', finish);
@@ -564,26 +596,6 @@ function REPLServer(prompt,
// Display prompt again
self.displayPrompt();
}
-
- function preprocess(code) {
- let cmd = code;
- if (/^\s*\{/.test(cmd) && /\}\s*$/.test(cmd)) {
- // It's confusing for `{ a : 1 }` to be interpreted as a block
- // statement rather than an object literal. So, we first try
- // to wrap it in parentheses, so that it will be interpreted as
- // an expression.
- cmd = `(${cmd})`;
- self.wrappedCmd = true;
- } else {
- // Mitigate https://github.com/nodejs/node/issues/548
- cmd = cmd.replace(/^\s*function\s+([^(]+)/,
- (_, name) => `var ${name} = function ${name}`);
- }
- // Append a \n so that it will be either
- // terminated, or continued onto the next expression if it's an
- // unexpected end of input.
- return `${cmd}\n`;
- }
});
self.on('SIGCONT', function onSigCont() {
diff --git a/lib/url.js b/lib/url.js
index a199f4b581dc..03a9fb03dfcc 100644
--- a/lib/url.js
+++ b/lib/url.js
@@ -44,7 +44,7 @@ const protocolPattern = /^([a-z0-9.+-]+:)/i;
const portPattern = /:[0-9]*$/;
// Special case for a simple path URL
-const simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/;
+const simplePathPattern = /^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/;
const hostnameMaxLen = 255;
// protocols that can allow "unsafe" and "unwise" chars.
@@ -437,105 +437,111 @@ function validateHostname(self, rest, hostname) {
}
}
+// Automatically escape all delimiters and unwise characters from RFC 2396.
+// Also escape single quotes in case of an XSS attack.
+// Return undefined if the string doesn't need escaping,
+// otherwise return the escaped string.
function autoEscapeStr(rest) {
- var newRest = '';
- var lastPos = 0;
+ var escaped = '';
+ var lastEscapedPos = 0;
for (var i = 0; i < rest.length; ++i) {
- // Automatically escape all delimiters and unwise characters from RFC 2396
- // Also escape single quotes in case of an XSS attack
+ // Manual switching is faster than using a Map/Object.
+ // `escaped` contains substring up to the last escaped cahracter.
switch (rest.charCodeAt(i)) {
case 9: // '\t'
- if (i - lastPos > 0)
- newRest += rest.slice(lastPos, i);
- newRest += '%09';
- lastPos = i + 1;
+ // Concat if there are ordinary characters in the middle.
+ if (i > lastEscapedPos)
+ escaped += rest.slice(lastEscapedPos, i);
+ escaped += '%09';
+ lastEscapedPos = i + 1;
break;
case 10: // '\n'
- if (i - lastPos > 0)
- newRest += rest.slice(lastPos, i);
- newRest += '%0A';
- lastPos = i + 1;
+ if (i > lastEscapedPos)
+ escaped += rest.slice(lastEscapedPos, i);
+ escaped += '%0A';
+ lastEscapedPos = i + 1;
break;
case 13: // '\r'
- if (i - lastPos > 0)
- newRest += rest.slice(lastPos, i);
- newRest += '%0D';
- lastPos = i + 1;
+ if (i > lastEscapedPos)
+ escaped += rest.slice(lastEscapedPos, i);
+ escaped += '%0D';
+ lastEscapedPos = i + 1;
break;
case 32: // ' '
- if (i - lastPos > 0)
- newRest += rest.slice(lastPos, i);
- newRest += '%20';
- lastPos = i + 1;
+ if (i > lastEscapedPos)
+ escaped += rest.slice(lastEscapedPos, i);
+ escaped += '%20';
+ lastEscapedPos = i + 1;
break;
case 34: // '"'
- if (i - lastPos > 0)
- newRest += rest.slice(lastPos, i);
- newRest += '%22';
- lastPos = i + 1;
+ if (i > lastEscapedPos)
+ escaped += rest.slice(lastEscapedPos, i);
+ escaped += '%22';
+ lastEscapedPos = i + 1;
break;
case 39: // '\''
- if (i - lastPos > 0)
- newRest += rest.slice(lastPos, i);
- newRest += '%27';
- lastPos = i + 1;
+ if (i > lastEscapedPos)
+ escaped += rest.slice(lastEscapedPos, i);
+ escaped += '%27';
+ lastEscapedPos = i + 1;
break;
case 60: // '<'
- if (i - lastPos > 0)
- newRest += rest.slice(lastPos, i);
- newRest += '%3C';
- lastPos = i + 1;
+ if (i > lastEscapedPos)
+ escaped += rest.slice(lastEscapedPos, i);
+ escaped += '%3C';
+ lastEscapedPos = i + 1;
break;
case 62: // '>'
- if (i - lastPos > 0)
- newRest += rest.slice(lastPos, i);
- newRest += '%3E';
- lastPos = i + 1;
+ if (i > lastEscapedPos)
+ escaped += rest.slice(lastEscapedPos, i);
+ escaped += '%3E';
+ lastEscapedPos = i + 1;
break;
case 92: // '\\'
- if (i - lastPos > 0)
- newRest += rest.slice(lastPos, i);
- newRest += '%5C';
- lastPos = i + 1;
+ if (i > lastEscapedPos)
+ escaped += rest.slice(lastEscapedPos, i);
+ escaped += '%5C';
+ lastEscapedPos = i + 1;
break;
case 94: // '^'
- if (i - lastPos > 0)
- newRest += rest.slice(lastPos, i);
- newRest += '%5E';
- lastPos = i + 1;
+ if (i > lastEscapedPos)
+ escaped += rest.slice(lastEscapedPos, i);
+ escaped += '%5E';
+ lastEscapedPos = i + 1;
break;
case 96: // '`'
- if (i - lastPos > 0)
- newRest += rest.slice(lastPos, i);
- newRest += '%60';
- lastPos = i + 1;
+ if (i > lastEscapedPos)
+ escaped += rest.slice(lastEscapedPos, i);
+ escaped += '%60';
+ lastEscapedPos = i + 1;
break;
case 123: // '{'
- if (i - lastPos > 0)
- newRest += rest.slice(lastPos, i);
- newRest += '%7B';
- lastPos = i + 1;
+ if (i > lastEscapedPos)
+ escaped += rest.slice(lastEscapedPos, i);
+ escaped += '%7B';
+ lastEscapedPos = i + 1;
break;
case 124: // '|'
- if (i - lastPos > 0)
- newRest += rest.slice(lastPos, i);
- newRest += '%7C';
- lastPos = i + 1;
+ if (i > lastEscapedPos)
+ escaped += rest.slice(lastEscapedPos, i);
+ escaped += '%7C';
+ lastEscapedPos = i + 1;
break;
case 125: // '}'
- if (i - lastPos > 0)
- newRest += rest.slice(lastPos, i);
- newRest += '%7D';
- lastPos = i + 1;
+ if (i > lastEscapedPos)
+ escaped += rest.slice(lastEscapedPos, i);
+ escaped += '%7D';
+ lastEscapedPos = i + 1;
break;
}
}
- if (lastPos === 0)
+ if (lastEscapedPos === 0) // Nothing has been escaped.
return;
- if (lastPos < rest.length)
- return newRest + rest.slice(lastPos);
- else
- return newRest;
+ // There are ordinary characters at the end.
+ if (lastEscapedPos < rest.length)
+ return escaped + rest.slice(lastEscapedPos);
+ else // The last character is escaped.
+ return escaped;
}
// format a parsed object into a url string
diff --git a/node.gyp b/node.gyp
index 2254a6e89136..f59037737c90 100644
--- a/node.gyp
+++ b/node.gyp
@@ -928,7 +928,15 @@
'targets': [
{
'target_name': 'node',
- 'type': 'executable',
+ 'conditions': [
+ ['node_shared=="true"', {
+ 'type': 'shared_library',
+ 'ldflags': ['--shared'],
+ 'product_extension': '<(shlib_suffix)',
+ }, {
+ 'type': 'executable',
+ }],
+ ],
'dependencies': ['<(node_core_target_name)', 'node_exp'],
'include_dirs': [
diff --git a/src/async-wrap-inl.h b/src/async-wrap-inl.h
index 85e31b1ed09d..64b5f0916123 100644
--- a/src/async-wrap-inl.h
+++ b/src/async-wrap-inl.h
@@ -15,77 +15,6 @@
namespace node {
-inline AsyncWrap::AsyncWrap(Environment* env,
- v8::Local object,
- ProviderType provider,
- AsyncWrap* parent)
- : BaseObject(env, object), bits_(static_cast(provider) << 1),
- uid_(env->get_async_wrap_uid()) {
- CHECK_NE(provider, PROVIDER_NONE);
- CHECK_GE(object->InternalFieldCount(), 1);
-
- // Shift provider value over to prevent id collision.
- persistent().SetWrapperClassId(NODE_ASYNC_ID_OFFSET + provider);
-
- v8::Local init_fn = env->async_hooks_init_function();
-
- // No init callback exists, no reason to go on.
- if (init_fn.IsEmpty())
- return;
-
- // If async wrap callbacks are disabled and no parent was passed that has
- // run the init callback then return.
- if (!env->async_wrap_callbacks_enabled() &&
- (parent == nullptr || !parent->ran_init_callback()))
- return;
-
- v8::HandleScope scope(env->isolate());
-
- v8::Local argv[] = {
- v8::Number::New(env->isolate(), get_uid()),
- v8::Int32::New(env->isolate(), provider),
- Null(env->isolate()),
- Null(env->isolate())
- };
-
- if (parent != nullptr) {
- argv[2] = v8::Number::New(env->isolate(), parent->get_uid());
- argv[3] = parent->object();
- }
-
- v8::TryCatch try_catch(env->isolate());
-
- v8::MaybeLocal ret =
- init_fn->Call(env->context(), object, arraysize(argv), argv);
-
- if (ret.IsEmpty()) {
- ClearFatalExceptionHandlers(env);
- FatalException(env->isolate(), try_catch);
- }
-
- bits_ |= 1; // ran_init_callback() is true now.
-}
-
-
-inline AsyncWrap::~AsyncWrap() {
- if (!ran_init_callback())
- return;
-
- v8::Local fn = env()->async_hooks_destroy_function();
- if (!fn.IsEmpty()) {
- v8::HandleScope scope(env()->isolate());
- v8::Local uid = v8::Number::New(env()->isolate(), get_uid());
- v8::TryCatch try_catch(env()->isolate());
- v8::MaybeLocal ret =
- fn->Call(env()->context(), v8::Null(env()->isolate()), 1, &uid);
- if (ret.IsEmpty()) {
- ClearFatalExceptionHandlers(env());
- FatalException(env()->isolate(), try_catch);
- }
- }
-}
-
-
inline bool AsyncWrap::ran_init_callback() const {
return static_cast(bits_ & 1);
}
diff --git a/src/async-wrap.cc b/src/async-wrap.cc
index 60124e47ad88..42463bd22b31 100644
--- a/src/async-wrap.cc
+++ b/src/async-wrap.cc
@@ -5,6 +5,7 @@
#include "util.h"
#include "util-inl.h"
+#include "uv.h"
#include "v8.h"
#include "v8-profiler.h"
@@ -14,6 +15,7 @@ using v8::Function;
using v8::FunctionCallbackInfo;
using v8::HandleScope;
using v8::HeapProfiler;
+using v8::Int32;
using v8::Integer;
using v8::Isolate;
using v8::Local;
@@ -155,9 +157,9 @@ static void SetupHooks(const FunctionCallbackInfo& args) {
}
-static void Initialize(Local target,
- Local unused,
- Local context) {
+void AsyncWrap::Initialize(Local target,
+ Local unused,
+ Local context) {
Environment* env = Environment::GetCurrent(context);
Isolate* isolate = env->isolate();
HandleScope scope(isolate);
@@ -181,6 +183,38 @@ static void Initialize(Local target,
}
+void AsyncWrap::DestroyIdsCb(uv_idle_t* handle) {
+ uv_idle_stop(handle);
+
+ Environment* env = Environment::from_destroy_ids_idle_handle(handle);
+ // None of the V8 calls done outside the HandleScope leak a handle. If this
+ // changes in the future then the SealHandleScope wrapping the uv_run()
+ // will catch this can cause the process to abort.
+ HandleScope handle_scope(env->isolate());
+ Context::Scope context_scope(env->context());
+ Local fn = env->async_hooks_destroy_function();
+
+ if (fn.IsEmpty())
+ return env->destroy_ids_list()->clear();
+
+ TryCatch try_catch(env->isolate());
+
+ for (auto current_id : *env->destroy_ids_list()) {
+ // Want each callback to be cleaned up after itself, instead of cleaning
+ // them all up after the while() loop completes.
+ HandleScope scope(env->isolate());
+ Local argv = Number::New(env->isolate(), current_id);
+ MaybeLocal ret = fn->Call(
+ env->context(), Undefined(env->isolate()), 1, &argv);
+
+ if (ret.IsEmpty()) {
+ ClearFatalExceptionHandlers(env);
+ FatalException(env->isolate(), try_catch);
+ }
+ }
+}
+
+
void LoadAsyncWrapperInfo(Environment* env) {
HeapProfiler* heap_profiler = env->isolate()->GetHeapProfiler();
#define V(PROVIDER) \
@@ -191,6 +225,69 @@ void LoadAsyncWrapperInfo(Environment* env) {
}
+AsyncWrap::AsyncWrap(Environment* env,
+ Local object,
+ ProviderType provider,
+ AsyncWrap* parent)
+ : BaseObject(env, object), bits_(static_cast(provider) << 1),
+ uid_(env->get_async_wrap_uid()) {
+ CHECK_NE(provider, PROVIDER_NONE);
+ CHECK_GE(object->InternalFieldCount(), 1);
+
+ // Shift provider value over to prevent id collision.
+ persistent().SetWrapperClassId(NODE_ASYNC_ID_OFFSET + provider);
+
+ Local init_fn = env->async_hooks_init_function();
+
+ // No init callback exists, no reason to go on.
+ if (init_fn.IsEmpty())
+ return;
+
+ // If async wrap callbacks are disabled and no parent was passed that has
+ // run the init callback then return.
+ if (!env->async_wrap_callbacks_enabled() &&
+ (parent == nullptr || !parent->ran_init_callback()))
+ return;
+
+ HandleScope scope(env->isolate());
+
+ Local argv[] = {
+ Number::New(env->isolate(), get_uid()),
+ Int32::New(env->isolate(), provider),
+ Null(env->isolate()),
+ Null(env->isolate())
+ };
+
+ if (parent != nullptr) {
+ argv[2] = Number::New(env->isolate(), parent->get_uid());
+ argv[3] = parent->object();
+ }
+
+ TryCatch try_catch(env->isolate());
+
+ MaybeLocal ret =
+ init_fn->Call(env->context(), object, arraysize(argv), argv);
+
+ if (ret.IsEmpty()) {
+ ClearFatalExceptionHandlers(env);
+ FatalException(env->isolate(), try_catch);
+ }
+
+ bits_ |= 1; // ran_init_callback() is true now.
+}
+
+
+AsyncWrap::~AsyncWrap() {
+ if (!ran_init_callback())
+ return;
+
+ if (env()->destroy_ids_list()->empty())
+ uv_idle_start(env()->destroy_ids_idle_handle(), DestroyIdsCb);
+
+ env()->destroy_ids_list()->push_back(get_uid());
+}
+
+
Local AsyncWrap::MakeCallback(const Local cb,
int argc,
Local* argv) {
@@ -290,4 +387,4 @@ Local AsyncWrap::MakeCallback(const Local cb,
} // namespace node
-NODE_MODULE_CONTEXT_AWARE_BUILTIN(async_wrap, node::Initialize)
+NODE_MODULE_CONTEXT_AWARE_BUILTIN(async_wrap, node::AsyncWrap::Initialize)
diff --git a/src/async-wrap.h b/src/async-wrap.h
index e1ea383d9f1a..d01c6ce9f9b7 100644
--- a/src/async-wrap.h
+++ b/src/async-wrap.h
@@ -4,6 +4,7 @@
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
#include "base-object.h"
+#include "uv.h"
#include "v8.h"
#include
@@ -49,12 +50,18 @@ class AsyncWrap : public BaseObject {
#undef V
};
- inline AsyncWrap(Environment* env,
- v8::Local object,
- ProviderType provider,
- AsyncWrap* parent = nullptr);
+ AsyncWrap(Environment* env,
+ v8::Local object,
+ ProviderType provider,
+ AsyncWrap* parent = nullptr);
- inline virtual ~AsyncWrap();
+ virtual ~AsyncWrap();
+
+ static void Initialize(v8::Local target,
+ v8::Local unused,
+ v8::Local context);
+
+ static void DestroyIdsCb(uv_idle_t* handle);
inline ProviderType provider_type() const;
diff --git a/src/env-inl.h b/src/env-inl.h
index 74e427e40353..83db3d33b6d1 100644
--- a/src/env-inl.h
+++ b/src/env-inl.h
@@ -194,6 +194,8 @@ inline Environment::Environment(IsolateData* isolate_data,
RB_INIT(&cares_task_list_);
AssignToContext(context);
+
+ destroy_ids_list_.reserve(512);
}
inline Environment::~Environment() {
@@ -247,6 +249,15 @@ inline uv_idle_t* Environment::immediate_idle_handle() {
return &immediate_idle_handle_;
}
+inline Environment* Environment::from_destroy_ids_idle_handle(
+ uv_idle_t* handle) {
+ return ContainerOf(&Environment::destroy_ids_idle_handle_, handle);
+}
+
+inline uv_idle_t* Environment::destroy_ids_idle_handle() {
+ return &destroy_ids_idle_handle_;
+}
+
inline void Environment::RegisterHandleCleanup(uv_handle_t* handle,
HandleCleanupCb cb,
void *arg) {
@@ -301,6 +312,10 @@ inline int64_t Environment::get_async_wrap_uid() {
return ++async_wrap_uid_;
}
+inline std::vector* Environment::destroy_ids_list() {
+ return &destroy_ids_list_;
+}
+
inline uint32_t* Environment::heap_statistics_buffer() const {
CHECK_NE(heap_statistics_buffer_, nullptr);
return heap_statistics_buffer_;
diff --git a/src/env.cc b/src/env.cc
index efa2d53f0435..40f0c9ebd66a 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -49,6 +49,9 @@ void Environment::Start(int argc,
uv_unref(reinterpret_cast(&idle_prepare_handle_));
uv_unref(reinterpret_cast(&idle_check_handle_));
+ uv_idle_init(event_loop(), destroy_ids_idle_handle());
+ uv_unref(reinterpret_cast(destroy_ids_idle_handle()));
+
auto close_and_finish = [](Environment* env, uv_handle_t* handle, void* arg) {
handle->data = env;
diff --git a/src/env.h b/src/env.h
index 51049ed2bea4..b99bb45f819e 100644
--- a/src/env.h
+++ b/src/env.h
@@ -16,6 +16,7 @@
#include "v8.h"
#include
+#include
// Caveat emptor: we're going slightly crazy with macros here but the end
// hopefully justifies the means. We have a lot of per-context properties
@@ -431,8 +432,10 @@ class Environment {
inline uint32_t watched_providers() const;
static inline Environment* from_immediate_check_handle(uv_check_t* handle);
+ static inline Environment* from_destroy_ids_idle_handle(uv_idle_t* handle);
inline uv_check_t* immediate_check_handle();
inline uv_idle_t* immediate_idle_handle();
+ inline uv_idle_t* destroy_ids_idle_handle();
// Register clean-up cb to be called on environment destruction.
inline void RegisterHandleCleanup(uv_handle_t* handle,
@@ -463,6 +466,9 @@ class Environment {
inline int64_t get_async_wrap_uid();
+ // List of id's that have been destroyed and need the destroy() cb called.
+ inline std::vector* destroy_ids_list();
+
inline uint32_t* heap_statistics_buffer() const;
inline void set_heap_statistics_buffer(uint32_t* pointer);
@@ -548,6 +554,7 @@ class Environment {
IsolateData* const isolate_data_;
uv_check_t immediate_check_handle_;
uv_idle_t immediate_idle_handle_;
+ uv_idle_t destroy_ids_idle_handle_;
uv_prepare_t idle_prepare_handle_;
uv_check_t idle_check_handle_;
AsyncHooks async_hooks_;
@@ -562,6 +569,7 @@ class Environment {
bool trace_sync_io_;
size_t makecallback_cntr_;
int64_t async_wrap_uid_;
+ std::vector destroy_ids_list_;
debugger::Agent debugger_agent_;
#if HAVE_INSPECTOR
inspector::Agent inspector_agent_;
diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc
index a01ec0c2f5e2..fd7968ff68ce 100644
--- a/src/inspector_agent.cc
+++ b/src/inspector_agent.cc
@@ -89,23 +89,30 @@ void OnBufferAlloc(uv_handle_t* handle, size_t len, uv_buf_t* buf) {
buf->len = len;
}
-void SendHttpResponse(InspectorSocket* socket, const std::string& response) {
+void SendHttpResponse(InspectorSocket* socket, const char* response,
+ size_t size) {
const char HEADERS[] = "HTTP/1.0 200 OK\r\n"
"Content-Type: application/json; charset=UTF-8\r\n"
"Cache-Control: no-cache\r\n"
"Content-Length: %zu\r\n"
"\r\n";
char header[sizeof(HEADERS) + 20];
- int header_len = snprintf(header, sizeof(header), HEADERS, response.size());
+ int header_len = snprintf(header, sizeof(header), HEADERS, size);
inspector_write(socket, header, header_len);
- inspector_write(socket, response.data(), response.size());
+ inspector_write(socket, response, size);
+}
+
+void SendHttpResponse(InspectorSocket* socket, const std::string& response) {
+ SendHttpResponse(socket, response.data(), response.size());
}
void SendVersionResponse(InspectorSocket* socket) {
- std::map response;
- response["Browser"] = "node.js/" NODE_VERSION;
- response["Protocol-Version"] = "1.1";
- SendHttpResponse(socket, MapToString(response));
+ static const char response[] =
+ "{\n"
+ " \"Browser\": \"node.js/" NODE_VERSION "\",\n"
+ " \"Protocol-Version\": \"1.1\"\n"
+ "}\n";
+ SendHttpResponse(socket, response, sizeof(response) - 1);
}
std::string GetProcessTitle() {
diff --git a/src/node_i18n.cc b/src/node_i18n.cc
index bab06cfcdfc4..a98fdca4d1bf 100644
--- a/src/node_i18n.cc
+++ b/src/node_i18n.cc
@@ -179,7 +179,7 @@ MaybeLocal TranscodeToUcs2(Isolate* isolate,
MaybeLocal ret;
MaybeStackBuffer destbuf(source_length);
Converter from(fromEncoding);
- const size_t length_in_chars = source_length * sizeof(*destbuf);
+ const size_t length_in_chars = source_length * sizeof(UChar);
ucnv_toUChars(from.conv, *destbuf, length_in_chars,
source, source_length, status);
if (U_SUCCESS(*status))
diff --git a/src/node_url.cc b/src/node_url.cc
index 001475b04c9f..7502461114a7 100644
--- a/src/node_url.cc
+++ b/src/node_url.cc
@@ -472,10 +472,8 @@ namespace url {
uint16_t* piece = &host->value.ipv6[n];
if (compress_pointer == piece) {
*dest += n == 0 ? "::" : ":";
- while (*piece == 0 && n < 8) {
- n++;
+ while (*piece == 0 && ++n < 8)
piece = &host->value.ipv6[n];
- }
if (n == 8)
break;
}
diff --git a/src/node_version.h b/src/node_version.h
index 11ad14764f8f..31ac3fac814e 100644
--- a/src/node_version.h
+++ b/src/node_version.h
@@ -3,7 +3,7 @@
#define NODE_MAJOR_VERSION 7
#define NODE_MINOR_VERSION 2
-#define NODE_PATCH_VERSION 1
+#define NODE_PATCH_VERSION 2
#define NODE_VERSION_IS_RELEASE 0
diff --git a/test/README.md b/test/README.md
index 93f1090fef73..1c3303435db5 100644
--- a/test/README.md
+++ b/test/README.md
@@ -205,11 +205,6 @@ Checks if there are multiple localhosts available.
Throws an `AssertionError` with `msg`
-### faketimeCli
-* return [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
-
-Return the path to the fake.
-
### fileExists(pathname)
* pathname [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
@@ -365,12 +360,6 @@ Synchronous version of `spawnCat`.
Synchronous version of `spawnPwd`.
-### testDir
-
-* return [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
-
-Path to the 'test' directory.
-
### tmpDir
* return [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
diff --git a/test/addons/async-hello-world/test.js b/test/addons/async-hello-world/test.js
index bbc81bfbf8c9..7c27382c1c60 100644
--- a/test/addons/async-hello-world/test.js
+++ b/test/addons/async-hello-world/test.js
@@ -4,7 +4,7 @@ var assert = require('assert');
const binding = require(`./build/${common.buildType}/binding`);
binding(5, common.mustCall(function(err, val) {
- assert.equal(null, err);
- assert.equal(10, val);
+ assert.strictEqual(err, null);
+ assert.strictEqual(val, 10);
process.nextTick(common.mustCall(function() {}));
}));
diff --git a/test/addons/hello-world-function-export/test.js b/test/addons/hello-world-function-export/test.js
index 89127fc787c9..74ea66c79c54 100644
--- a/test/addons/hello-world-function-export/test.js
+++ b/test/addons/hello-world-function-export/test.js
@@ -2,5 +2,5 @@
const common = require('../../common');
var assert = require('assert');
const binding = require(`./build/${common.buildType}/binding`);
-assert.equal('world', binding());
+assert.strictEqual(binding(), 'world');
console.log('binding.hello() =', binding());
diff --git a/test/addons/hello-world/test.js b/test/addons/hello-world/test.js
index 8d5c12387700..32066388efe6 100644
--- a/test/addons/hello-world/test.js
+++ b/test/addons/hello-world/test.js
@@ -2,5 +2,5 @@
const common = require('../../common');
var assert = require('assert');
const binding = require(`./build/${common.buildType}/binding`);
-assert.equal('world', binding.hello());
+assert.strictEqual(binding.hello(), 'world');
console.log('binding.hello() =', binding.hello());
diff --git a/test/addons/load-long-path/test.js b/test/addons/load-long-path/test.js
index 2f09f2b3ff00..b17942b45a6f 100644
--- a/test/addons/load-long-path/test.js
+++ b/test/addons/load-long-path/test.js
@@ -34,4 +34,4 @@ fs.writeFileSync(addonDestinationPath, contents);
// Attempt to load at long path destination
var addon = require(addonDestinationPath);
assert.notEqual(addon, null);
-assert.equal(addon.hello(), 'world');
+assert.strictEqual(addon.hello(), 'world');
diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-at-max.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-at-max.js
index bd71f05d61bf..2ce695852e25 100644
--- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-at-max.js
+++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-at-max.js
@@ -30,4 +30,4 @@ if (!binding.ensureAllocation(2 * kStringMaxLength)) {
}
const maxString = buf.toString('latin1');
-assert.equal(maxString.length, kStringMaxLength);
+assert.strictEqual(maxString.length, kStringMaxLength);
diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js
index c54706fd46c5..51324a3f3377 100644
--- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js
+++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js
@@ -34,9 +34,9 @@ assert.throws(function() {
}, /"toString\(\)" failed/);
var maxString = buf.toString('latin1', 1);
-assert.equal(maxString.length, kStringMaxLength);
+assert.strictEqual(maxString.length, kStringMaxLength);
// Free the memory early instead of at the end of the next assignment
maxString = undefined;
maxString = buf.toString('latin1', 0, kStringMaxLength);
-assert.equal(maxString.length, kStringMaxLength);
+assert.strictEqual(maxString.length, kStringMaxLength);
diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-2.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-2.js
index 11f23ff1bf76..0fab606e4663 100644
--- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-2.js
+++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-2.js
@@ -30,4 +30,4 @@ if (!binding.ensureAllocation(2 * kStringMaxLength)) {
}
const maxString = buf.toString('utf16le');
-assert.equal(maxString.length, (kStringMaxLength + 2) / 2);
+assert.strictEqual(maxString.length, (kStringMaxLength + 2) / 2);
diff --git a/test/cctest/test_inspector_socket.cc b/test/cctest/test_inspector_socket.cc
index 697fa2bacca8..c7a282b75b4b 100644
--- a/test/cctest/test_inspector_socket.cc
+++ b/test/cctest/test_inspector_socket.cc
@@ -1,10 +1,17 @@
#include "inspector_socket.h"
-
#include "gtest/gtest.h"
#define PORT 9444
-using namespace node::inspector;
+namespace {
+
+using node::inspector::InspectorSocket;
+using node::inspector::inspector_from_stream;
+using node::inspector::inspector_handshake_event;
+using node::inspector::kInspectorHandshakeFailed;
+using node::inspector::kInspectorHandshakeHttpGet;
+using node::inspector::kInspectorHandshakeUpgraded;
+using node::inspector::kInspectorHandshakeUpgrading;
static const int MAX_LOOP_ITERATIONS = 10000;
@@ -24,7 +31,7 @@ static enum inspector_handshake_event last_event = kInspectorHandshakeHttpGet;
static uv_loop_t loop;
static uv_tcp_t server, client_socket;
static InspectorSocket inspector;
-static std::string last_path;
+static std::string last_path; // NOLINT(runtime/string)
static void (*handshake_delegate)(enum inspector_handshake_event state,
const std::string& path,
bool* should_continue);
@@ -45,7 +52,7 @@ static const char HANDSHAKE_REQ[] = "GET /ws/path HTTP/1.1\r\n"
"Sec-WebSocket-Version: 13\r\n\r\n";
class Timeout {
-public:
+ public:
explicit Timeout(uv_loop_t* loop) : timed_out(false), done_(false) {
uv_timer_init(loop, &timer_);
uv_timer_start(&timer_, Timeout::set_flag, 5000, 0);
@@ -58,8 +65,10 @@ class Timeout {
uv_run(&loop, UV_RUN_NOWAIT);
}
}
+
bool timed_out;
-private:
+
+ private:
static void set_flag(uv_timer_t* timer) {
Timeout* t = node::ContainerOf(&Timeout::timer_, timer);
t->timed_out = true;
@@ -128,7 +137,7 @@ static void check_data_cb(read_expects* expectation, ssize_t nread,
EXPECT_TRUE(nread >= 0 && nread != UV_EOF);
ssize_t i;
char c, actual;
- ASSERT_TRUE(expectation->expected_len > 0);
+ ASSERT_GT(expectation->expected_len, 0);
for (i = 0; i < nread && expectation->pos <= expectation->expected_len; i++) {
c = expectation->expected[expectation->pos++];
actual = buf->base[i];
@@ -175,7 +184,7 @@ static void fail_callback(uv_stream_t* stream, ssize_t nread,
} else {
fprintf(stderr, "Read %zd bytes\n", nread);
}
- ASSERT_TRUE(false); // Shouldn't have been called
+ ASSERT_TRUE(false); // Shouldn't have been called
}
static void expect_nothing_on_client() {
@@ -238,7 +247,7 @@ static void grow_expects_buffer(uv_handle_t* stream, size_t size, uv_buf_t* b) {
static void save_read_data(uv_stream_t* stream, ssize_t nread,
const uv_buf_t* buf) {
- expectations* expects =static_cast(
+ expectations* expects = static_cast(
inspector_from_stream(stream)->data);
expects->err_code = nread < 0 ? nread : 0;
if (nread > 0) {
@@ -343,7 +352,7 @@ static void on_connection(uv_connect_t* connect, int status) {
}
class InspectorSocketTest : public ::testing::Test {
-protected:
+ protected:
virtual void SetUp() {
inspector.reinit();
handshake_delegate = stop_if_stop_path;
@@ -367,7 +376,7 @@ class InspectorSocketTest : public ::testing::Test {
connect.data = nullptr;
uv_tcp_connect(&connect, &client_socket,
reinterpret_cast(&addr), on_connection);
- uv_tcp_nodelay(&client_socket, 1); // The buffering messes up the test
+ uv_tcp_nodelay(&client_socket, 1); // The buffering messes up the test
SPIN_WHILE(!connect.data || !connected);
really_close(reinterpret_cast(&server));
}
@@ -419,7 +428,6 @@ TEST_F(InspectorSocketTest, ReadsAndWritesInspectorMessage) {
}
TEST_F(InspectorSocketTest, BufferEdgeCases) {
-
do_write(const_cast(HANDSHAKE_REQ), sizeof(HANDSHAKE_REQ) - 1);
expect_handshake();
@@ -497,7 +505,8 @@ TEST_F(InspectorSocketTest, AcceptsRequestInSeveralWrites) {
SPIN_WHILE(!inspector_ready);
expect_handshake();
inspector_read_stop(&inspector);
- GTEST_ASSERT_EQ(uv_is_active(reinterpret_cast(&client_socket)), 0);
+ GTEST_ASSERT_EQ(uv_is_active(reinterpret_cast(&client_socket)),
+ 0);
manual_inspector_socket_cleanup();
}
@@ -530,7 +539,6 @@ TEST_F(InspectorSocketTest, RequestWithoutKey) {
"Upgrade: websocket\r\n"
"Connection: Upgrade\r\n"
"Sec-WebSocket-Version: 13\r\n\r\n";
- ;
do_write(const_cast(BROKEN_REQUEST), sizeof(BROKEN_REQUEST) - 1);
SPIN_WHILE(last_event != kInspectorHandshakeFailed);
@@ -548,7 +556,8 @@ TEST_F(InspectorSocketTest, KillsConnectionOnProtocolViolation) {
const char SERVER_FRAME[] = "I'm not a good WS frame. Nope!";
do_write(SERVER_FRAME, sizeof(SERVER_FRAME));
expect_server_read_error();
- GTEST_ASSERT_EQ(uv_is_active(reinterpret_cast(&client_socket)), 0);
+ GTEST_ASSERT_EQ(uv_is_active(reinterpret_cast(&client_socket)),
+ 0);
}
TEST_F(InspectorSocketTest, CanStopReadingFromInspector) {
@@ -862,7 +871,7 @@ TEST_F(InspectorSocketTest, Send1Mb) {
outgoing.resize(outgoing.size() + message.size());
mask_message(message, &outgoing[sizeof(FRAME_TO_SERVER_HEADER)], MASK);
- setup_inspector_expecting(); // Buffer on the client side.
+ setup_inspector_expecting(); // Buffer on the client side.
do_write(&outgoing[0], outgoing.size());
expect_on_server(&message[0], message.size());
@@ -895,3 +904,5 @@ TEST_F(InspectorSocketTest, ErrorCleansUpTheSocket) {
SPIN_WHILE(err > 0);
EXPECT_EQ(UV_EPROTO, err);
}
+
+} // anonymous namespace
diff --git a/test/common.js b/test/common.js
index 3bbf7d87300c..3c769345dd6b 100644
--- a/test/common.js
+++ b/test/common.js
@@ -12,8 +12,7 @@ const Timer = process.binding('timer_wrap').Timer;
const testRoot = process.env.NODE_TEST_DIR ?
path.resolve(process.env.NODE_TEST_DIR) : __dirname;
-exports.testDir = __dirname;
-exports.fixturesDir = path.join(exports.testDir, 'fixtures');
+exports.fixturesDir = path.join(__dirname, 'fixtures');
exports.tmpDirName = 'tmp';
// PORT should match the definition in test/testpy/__init__.py.
exports.PORT = +process.env.NODE_COMMON_PORT || 12346;
@@ -195,13 +194,6 @@ if (exports.isWindows) {
exports.PIPE = exports.tmpDir + '/test.sock';
}
-if (exports.isWindows) {
- exports.faketimeCli = false;
-} else {
- exports.faketimeCli = path.join(__dirname, '..', 'tools', 'faketime', 'src',
- 'faketime');
-}
-
var ifaces = os.networkInterfaces();
exports.hasIPv6 = Object.keys(ifaces).some(function(name) {
return /lo/.test(name) && ifaces[name].some(function(info) {
@@ -285,17 +277,19 @@ exports.platformTimeout = function(ms) {
return ms; // ARMv8+
};
-var knownGlobals = [setTimeout,
- setInterval,
- setImmediate,
- clearTimeout,
- clearInterval,
- clearImmediate,
- console,
- constructor, // Enumerable in V8 3.21.
- Buffer,
- process,
- global];
+var knownGlobals = [
+ Buffer,
+ clearImmediate,
+ clearInterval,
+ clearTimeout,
+ console,
+ constructor, // Enumerable in V8 3.21.
+ global,
+ process,
+ setImmediate,
+ setInterval,
+ setTimeout
+];
if (global.gc) {
knownGlobals.push(global.gc);
@@ -360,7 +354,7 @@ function leakedGlobals() {
var leaked = [];
for (var val in global)
- if (-1 === knownGlobals.indexOf(global[val]))
+ if (!knownGlobals.includes(global[val]))
leaked.push(val);
return leaked;
@@ -375,7 +369,7 @@ process.on('exit', function() {
var leaked = leakedGlobals();
if (leaked.length > 0) {
console.error('Unknown globals: %s', leaked);
- assert.ok(false, 'Unknown global found');
+ fail('Unknown global found');
}
});
@@ -440,9 +434,10 @@ exports.fileExists = function(pathname) {
}
};
-exports.fail = function(msg) {
+function fail(msg) {
assert.fail(null, null, msg);
-};
+}
+exports.fail = fail;
exports.skip = function(msg) {
console.log(`1..0 # Skipped: ${msg}`);
@@ -493,9 +488,9 @@ exports.nodeProcessAborted = function nodeProcessAborted(exitCode, signal) {
// one of them (exit code or signal) needs to be set to one of
// the expected exit codes or signals.
if (signal !== null) {
- return expectedSignals.indexOf(signal) > -1;
+ return expectedSignals.includes(signal);
} else {
- return expectedExitCodes.indexOf(exitCode) > -1;
+ return expectedExitCodes.includes(exitCode);
}
};
diff --git a/test/debugger/test-debugger-client.js b/test/debugger/test-debugger-client.js
index fbe7ad1f0609..04823113ec32 100644
--- a/test/debugger/test-debugger-client.js
+++ b/test/debugger/test-debugger-client.js
@@ -25,40 +25,40 @@ p.execute('Type: connect\r\n' +
'Protocol-Version: 1\r\n' +
'Embedding-Host: node v0.3.3-pre\r\n' +
'Content-Length: 0\r\n\r\n');
-assert.equal(1, resCount);
+assert.strictEqual(resCount, 1);
// Make sure split messages go in.
var parts = [];
parts.push('Content-Length: 336\r\n');
-assert.equal(21, parts[0].length);
+assert.strictEqual(parts[0].length, 21);
parts.push('\r\n');
-assert.equal(2, parts[1].length);
+assert.strictEqual(parts[1].length, 2);
var bodyLength = 0;
parts.push('{"seq":12,"type":"event","event":"break","body":' +
'{"invocationText":"#');
-assert.equal(78, parts[2].length);
+assert.strictEqual(parts[2].length, 78);
bodyLength += parts[2].length;
parts.push('.[anonymous](req=#, ' +
'res=#)","sourceLine"');
-assert.equal(78, parts[3].length);
+assert.strictEqual(parts[3].length, 78);
bodyLength += parts[3].length;
parts.push(':45,"sourceColumn":4,"sourceLineText":" debugger;",' +
'"script":{"id":24,"name":"/home/ryan/projects/node/' +
'benchmark/http_simple.js","lineOffset":0,"columnOffset":0,' +
'"lineCount":98}}}');
-assert.equal(180, parts[4].length);
+assert.strictEqual(parts[4].length, 180);
bodyLength += parts[4].length;
-assert.equal(336, bodyLength);
+assert.strictEqual(bodyLength, 336);
for (var i = 0; i < parts.length; i++) {
p.execute(parts[i]);
}
-assert.equal(2, resCount);
+assert.strictEqual(resCount, 2);
// Make sure that if we get backed up, we still manage to get all the
@@ -77,7 +77,7 @@ var d = 'Content-Length: 466\r\n\r\n' +
'{"seq":11,"type":"event","event":"scriptCollected","success":true,' +
'"body":{"script":{"id":26}},"refs":[],"running":true}';
p.execute(d);
-assert.equal(4, resCount);
+assert.strictEqual(resCount, 4);
var expectedConnections = 0;
var tests = [];
@@ -91,7 +91,7 @@ addTest(function(client, done) {
client.reqVersion(function(err, v) {
assert.ok(!err);
console.log('version: %s', v);
- assert.equal(process.versions.v8, v);
+ assert.strictEqual(process.versions.v8, v);
done();
});
});
@@ -120,8 +120,8 @@ addTest(function(client, done) {
client.reqEval('2+2', function(err, res) {
console.error(res);
assert.ok(!err);
- assert.equal('4', res.text);
- assert.equal(4, res.value);
+ assert.strictEqual(res.text, '4');
+ assert.strictEqual(res.value, 4);
done();
});
});
@@ -212,5 +212,5 @@ run();
process.on('exit', function(code) {
if (!code)
- assert.equal(expectedConnections, connectCount);
+ assert.strictEqual(connectCount, expectedConnections);
});
diff --git a/test/inspector/inspector-helper.js b/test/inspector/inspector-helper.js
index a02b6b9a5bc5..3e517123fe27 100644
--- a/test/inspector/inspector-helper.js
+++ b/test/inspector/inspector-helper.js
@@ -286,7 +286,7 @@ TestSession.prototype.disconnect = function(childDone) {
this.expectClose_ = true;
this.harness_.childInstanceDone =
this.harness_.childInstanceDone || childDone;
- this.socket_.end();
+ this.socket_.destroy();
console.log('[test]', 'Connection terminated');
callback();
});
diff --git a/test/inspector/inspector.status b/test/inspector/inspector.status
index 69865843c940..ed6a782b9031 100644
--- a/test/inspector/inspector.status
+++ b/test/inspector/inspector.status
@@ -7,4 +7,3 @@ prefix inspector
[true] # This section applies to all platforms
[$system==win32]
-test-inspector : PASS,FLAKY
diff --git a/test/inspector/test-inspector.js b/test/inspector/test-inspector.js
index 75c645bb2227..7e53eaa55fff 100644
--- a/test/inspector/test-inspector.js
+++ b/test/inspector/test-inspector.js
@@ -17,6 +17,12 @@ function checkListResponse(err, response) {
function checkVersion(err, response) {
assert.ifError(err);
assert.ok(response);
+ const expected = {
+ 'Browser': 'node.js/' + process.version,
+ 'Protocol-Version': '1.1',
+ };
+ assert.strictEqual(JSON.stringify(response),
+ JSON.stringify(expected));
}
function checkBadPath(err, response) {
diff --git a/test/message/unhandled_promise_trace_warnings.js b/test/message/unhandled_promise_trace_warnings.js
new file mode 100644
index 000000000000..48450fb21e21
--- /dev/null
+++ b/test/message/unhandled_promise_trace_warnings.js
@@ -0,0 +1,5 @@
+// Flags: --trace-warnings
+'use strict';
+require('../common');
+const p = Promise.reject(new Error('This was rejected'));
+setImmediate(() => p.catch(() => {}));
diff --git a/test/message/unhandled_promise_trace_warnings.out b/test/message/unhandled_promise_trace_warnings.out
new file mode 100644
index 000000000000..80cf948cf118
--- /dev/null
+++ b/test/message/unhandled_promise_trace_warnings.out
@@ -0,0 +1,31 @@
+(node:*) Error: This was rejected
+ at * (*test*message*unhandled_promise_trace_warnings.js:*)
+ at *
+ at *
+ at *
+ at *
+ at *
+ at *
+ at *
+ at *
+ at *
+(node:*) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
+ at *
+ at *
+ at *
+ at *
+ at *
+ at *
+ at *
+ at *
+ at *
+(node:*) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
+ at getAsynchronousRejectionWarningObject (internal/process/promises.js:*)
+ at rejectionHandled (internal/process/promises.js:*)
+ at *
+ at Promise.then (native)
+ at Promise.catch (native)
+ at Immediate.setImmediate (*test*message*unhandled_promise_trace_warnings.js:*)
+ at *
+ at *
+ at *
diff --git a/test/parallel/test-async-wrap-uid.js b/test/parallel/test-async-wrap-uid.js
index 5bf3a8856e0e..3497c3b0768d 100644
--- a/test/parallel/test-async-wrap-uid.js
+++ b/test/parallel/test-async-wrap-uid.js
@@ -6,7 +6,7 @@ const assert = require('assert');
const async_wrap = process.binding('async_wrap');
const storage = new Map();
-async_wrap.setupHooks({ init, pre, post, destroy });
+async_wrap.setupHooks({ init, pre, post });
async_wrap.enable();
function init(uid) {
@@ -14,7 +14,6 @@ function init(uid) {
init: true,
pre: false,
post: false,
- destroy: false
});
}
@@ -26,10 +25,6 @@ function post(uid) {
storage.get(uid).post = true;
}
-function destroy(uid) {
- storage.get(uid).destroy = true;
-}
-
fs.access(__filename, function(err) {
assert.ifError(err);
});
@@ -51,7 +46,6 @@ process.once('exit', function() {
init: true,
pre: true,
post: true,
- destroy: true
});
}
});
diff --git a/test/parallel/test-beforeexit-event.js b/test/parallel/test-beforeexit-event.js
index d50ef67190c4..4decbcf9f921 100644
--- a/test/parallel/test-beforeexit-event.js
+++ b/test/parallel/test-beforeexit-event.js
@@ -37,6 +37,6 @@ function tryListen() {
}
process.on('exit', function() {
- assert.equal(4, deaths);
- assert.equal(3, revivals);
+ assert.strictEqual(4, deaths);
+ assert.strictEqual(3, revivals);
});
diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js
index 760ad2e37c05..6e97cf56b330 100644
--- a/test/parallel/test-buffer-alloc.js
+++ b/test/parallel/test-buffer-alloc.js
@@ -138,7 +138,7 @@ assert.doesNotThrow(() => Buffer.alloc(1).write('', 1, 0));
const sliceA = b.slice(offset, offset + asciiString.length);
const sliceB = b.slice(offset, offset + asciiString.length);
for (let i = 0; i < asciiString.length; i++) {
- assert.equal(sliceA[i], sliceB[i]);
+ assert.strictEqual(sliceA[i], sliceB[i]);
}
}
@@ -149,7 +149,7 @@ assert.doesNotThrow(() => Buffer.alloc(1).write('', 1, 0));
b.write(utf8String, 0, Buffer.byteLength(utf8String), 'utf8');
let utf8Slice = b.toString('utf8', 0, Buffer.byteLength(utf8String));
- assert.equal(utf8String, utf8Slice);
+ assert.strictEqual(utf8String, utf8Slice);
assert.strictEqual(Buffer.byteLength(utf8String),
b.write(utf8String, offset, 'utf8'));
@@ -1027,7 +1027,8 @@ assert(Buffer.allocUnsafe(1).parent instanceof ArrayBuffer);
Buffer.poolSize = ps;
// Test Buffer.copy() segfault
-assert.throws(() => Buffer.allocUnsafe(10).copy());
+assert.throws(() => Buffer.allocUnsafe(10).copy(),
+ /TypeError: argument should be a Buffer/);
const regErrorMsg = new RegExp('First argument must be a string, Buffer, ' +
'ArrayBuffer, Array, or array-like object.');
@@ -1036,10 +1037,10 @@ assert.throws(() => Buffer.from(), regErrorMsg);
assert.throws(() => Buffer.from(null), regErrorMsg);
// Test prototype getters don't throw
-assert.equal(Buffer.prototype.parent, undefined);
-assert.equal(Buffer.prototype.offset, undefined);
-assert.equal(SlowBuffer.prototype.parent, undefined);
-assert.equal(SlowBuffer.prototype.offset, undefined);
+assert.strictEqual(Buffer.prototype.parent, undefined);
+assert.strictEqual(Buffer.prototype.offset, undefined);
+assert.strictEqual(SlowBuffer.prototype.parent, undefined);
+assert.strictEqual(SlowBuffer.prototype.offset, undefined);
{
@@ -1065,7 +1066,7 @@ assert.throws(() => {
const a = Buffer.alloc(1);
const b = Buffer.alloc(1);
a.copy(b, 0, 0x100000000, 0x100000001);
-}), /out of range index/;
+}, /out of range index/);
// Unpooled buffer (replaces SlowBuffer)
{
diff --git a/test/parallel/test-buffer-bytelength.js b/test/parallel/test-buffer-bytelength.js
index de122b4fc7c7..e31e514ffa11 100644
--- a/test/parallel/test-buffer-bytelength.js
+++ b/test/parallel/test-buffer-bytelength.js
@@ -8,13 +8,13 @@ const vm = require('vm');
// coerce values to string
assert.throws(() => { Buffer.byteLength(32, 'latin1'); },
- '"string" must be a string, Buffer, or ArrayBuffer');
+ /"string" must be a string, Buffer, or ArrayBuffer/);
assert.throws(() => { Buffer.byteLength(NaN, 'utf8'); },
- '"string" must be a string, Buffer, or ArrayBuffer');
+ /"string" must be a string, Buffer, or ArrayBuffer/);
assert.throws(() => { Buffer.byteLength({}, 'latin1'); },
- '"string" must be a string, Buffer, or ArrayBuffer');
+ /"string" must be a string, Buffer, or ArrayBuffer/);
assert.throws(() => { Buffer.byteLength(); },
- '"string" must be a string, Buffer, or ArrayBuffer');
+ /"string" must be a string, Buffer, or ArrayBuffer/);
assert(ArrayBuffer.isView(new Buffer(10)));
assert(ArrayBuffer.isView(new SlowBuffer(10)));
@@ -31,7 +31,7 @@ assert.strictEqual(Buffer.byteLength(ascii), 3);
// ArrayBuffer
var buffer = new ArrayBuffer(8);
-assert.equal(Buffer.byteLength(buffer), 8);
+assert.strictEqual(Buffer.byteLength(buffer), 8);
// TypedArray
var int8 = new Int8Array(8);
diff --git a/test/parallel/test-buffer-creation-regression.js b/test/parallel/test-buffer-creation-regression.js
new file mode 100644
index 000000000000..650fbf48f12a
--- /dev/null
+++ b/test/parallel/test-buffer-creation-regression.js
@@ -0,0 +1,41 @@
+'use strict';
+
+const common = require('../common');
+const assert = require('assert');
+
+function test(arrayBuffer, offset, length) {
+ const uint8Array = new Uint8Array(arrayBuffer, offset, length);
+ for (let i = 0; i < length; i += 1) {
+ uint8Array[i] = 1;
+ }
+
+ const buffer = Buffer.from(arrayBuffer, offset, length);
+ for (let i = 0; i < length; i += 1) {
+ assert.strictEqual(buffer[i], 1);
+ }
+}
+
+const acceptableOOMErrors = [
+ 'Array buffer allocation failed',
+ 'Invalid array buffer length'
+];
+
+const testCases = [
+ [200, 50, 100],
+ [4294967296 /* 1 << 32 */, 2147483648 /* 1 << 31 */, 1000],
+ [8589934592 /* 1 << 33 */, 4294967296 /* 1 << 32 */, 1000]
+];
+
+for (let index = 0, arrayBuffer; index < testCases.length; index += 1) {
+ const [size, offset, length] = testCases[index];
+
+ try {
+ arrayBuffer = new ArrayBuffer(size);
+ } catch (e) {
+ if (e instanceof RangeError && acceptableOOMErrors.includes(e.message))
+ return common.skip(`Unable to allocate ${size} bytes for ArrayBuffer`);
+ throw e;
+ }
+
+ test(arrayBuffer, offset, length);
+}
diff --git a/test/parallel/test-buffer-deprecated.js b/test/parallel/test-buffer-deprecated.js
deleted file mode 100644
index ec49321de439..000000000000
--- a/test/parallel/test-buffer-deprecated.js
+++ /dev/null
@@ -1,11 +0,0 @@
-'use strict';
-const common = require('../common');
-
-const expected =
- 'Using Buffer without `new` will soon stop working. ' +
- 'Use `new Buffer()`, or preferably ' +
- '`Buffer.from()`, `Buffer.allocUnsafe()` or `Buffer.alloc()` instead.';
-common.expectWarning('DeprecationWarning', expected);
-
-Buffer(1);
-Buffer(1);
diff --git a/test/parallel/test-buffer-fill.js b/test/parallel/test-buffer-fill.js
index c61ad59d7e9c..4272d686940c 100644
--- a/test/parallel/test-buffer-fill.js
+++ b/test/parallel/test-buffer-fill.js
@@ -49,7 +49,7 @@ testBufs('\u0222aa', 8, 1, 'utf8');
testBufs('a\u0234b\u0235c\u0236', 4, -1, 'utf8');
testBufs('a\u0234b\u0235c\u0236', 4, 1, 'utf8');
testBufs('a\u0234b\u0235c\u0236', 12, 1, 'utf8');
-assert.equal(Buffer.allocUnsafe(1).fill(0).fill('\u0222')[0], 0xc8);
+assert.strictEqual(Buffer.allocUnsafe(1).fill(0).fill('\u0222')[0], 0xc8);
// BINARY
@@ -112,8 +112,8 @@ testBufs('\u0222aa', 8, 1, 'ucs2');
testBufs('a\u0234b\u0235c\u0236', 4, -1, 'ucs2');
testBufs('a\u0234b\u0235c\u0236', 4, 1, 'ucs2');
testBufs('a\u0234b\u0235c\u0236', 12, 1, 'ucs2');
-assert.equal(Buffer.allocUnsafe(1).fill('\u0222', 'ucs2')[0],
- os.endianness() === 'LE' ? 0x22 : 0x02);
+assert.strictEqual(Buffer.allocUnsafe(1).fill('\u0222', 'ucs2')[0],
+ os.endianness() === 'LE' ? 0x22 : 0x02);
// HEX
@@ -137,7 +137,8 @@ testBufs('61c8b462c8b563c8b6', 4, 1, 'hex');
testBufs('61c8b462c8b563c8b6', 12, 1, 'hex');
// Make sure this operation doesn't go on forever
buf1.fill('yKJh', 'hex');
-assert.throws(() => buf1.fill('\u0222', 'hex'));
+assert.throws(() =>
+ buf1.fill('\u0222', 'hex'), /^TypeError: Invalid hex string$/);
// BASE64
@@ -183,14 +184,25 @@ deepStrictEqualValues(genBuffer(4, [hexBufFill, 1, -1]), [0, 0, 0, 0]);
// Check exceptions
-assert.throws(() => buf1.fill(0, -1));
-assert.throws(() => buf1.fill(0, 0, buf1.length + 1));
-assert.throws(() => buf1.fill('', -1));
-assert.throws(() => buf1.fill('', 0, buf1.length + 1));
-assert.throws(() => buf1.fill('a', 0, buf1.length, 'node rocks!'));
-assert.throws(() => buf1.fill('a', 0, 0, NaN));
-assert.throws(() => buf1.fill('a', 0, 0, null));
-assert.throws(() => buf1.fill('a', 0, 0, 'foo'));
+assert.throws(() => buf1.fill(0, -1), /^RangeError: Out of range index$/);
+assert.throws(() =>
+ buf1.fill(0, 0, buf1.length + 1),
+ /^RangeError: Out of range index$/);
+assert.throws(() => buf1.fill('', -1), /^RangeError: Out of range index$/);
+assert.throws(() =>
+ buf1.fill('', 0, buf1.length + 1),
+ /^RangeError: Out of range index$/);
+assert.throws(() =>
+ buf1.fill('a', 0, buf1.length, 'node rocks!'),
+ /^TypeError: Unknown encoding: node rocks!$/);
+assert.throws(() =>
+ buf1.fill('a', 0, 0, NaN),
+ /^TypeError: encoding must be a string$/);
+assert.throws(() =>
+ buf1.fill('a', 0, 0, null),
+ /^TypeError: encoding must be a string$/);
+assert.throws(() =>
+ buf1.fill('a', 0, 0, 'foo'), /^TypeError: Unknown encoding: foo$/);
function genBuffer(size, args) {
@@ -269,8 +281,12 @@ function testBufs(string, offset, length, encoding) {
}
// Make sure these throw.
-assert.throws(() => Buffer.allocUnsafe(8).fill('a', -1));
-assert.throws(() => Buffer.allocUnsafe(8).fill('a', 0, 9));
+assert.throws(() =>
+ Buffer.allocUnsafe(8).fill('a', -1),
+ /^RangeError: Out of range index$/);
+assert.throws(() =>
+ Buffer.allocUnsafe(8).fill('a', 0, 9),
+ /^RangeError: Out of range index$/);
// Make sure this doesn't hang indefinitely.
Buffer.allocUnsafe(8).fill('');
@@ -369,7 +385,7 @@ assert.throws(() => {
}
};
Buffer.alloc(1).fill(Buffer.alloc(1), 0, end);
- });
+ }, /^RangeError: out of range index$/);
// Make sure -1 is making it to Buffer::Fill().
assert.ok(elseWasLast,
'internal API changed, -1 no longer in correct location');
@@ -389,4 +405,4 @@ assert.throws(() => {
enumerable: true
});
buf.fill('');
-});
+}, /^RangeError: out of range index$/);
diff --git a/test/parallel/test-buffer-indexof.js b/test/parallel/test-buffer-indexof.js
index 5757200c2b04..746a2723167a 100644
--- a/test/parallel/test-buffer-indexof.js
+++ b/test/parallel/test-buffer-indexof.js
@@ -11,65 +11,65 @@ const buf_f = Buffer.from('f');
const buf_z = Buffer.from('z');
const buf_empty = Buffer.from('');
-assert.equal(b.indexOf('a'), 0);
-assert.equal(b.indexOf('a', 1), -1);
-assert.equal(b.indexOf('a', -1), -1);
-assert.equal(b.indexOf('a', -4), -1);
-assert.equal(b.indexOf('a', -b.length), 0);
-assert.equal(b.indexOf('a', NaN), 0);
-assert.equal(b.indexOf('a', -Infinity), 0);
-assert.equal(b.indexOf('a', Infinity), -1);
-assert.equal(b.indexOf('bc'), 1);
-assert.equal(b.indexOf('bc', 2), -1);
-assert.equal(b.indexOf('bc', -1), -1);
-assert.equal(b.indexOf('bc', -3), -1);
-assert.equal(b.indexOf('bc', -5), 1);
-assert.equal(b.indexOf('bc', NaN), 1);
-assert.equal(b.indexOf('bc', -Infinity), 1);
-assert.equal(b.indexOf('bc', Infinity), -1);
-assert.equal(b.indexOf('f'), b.length - 1);
-assert.equal(b.indexOf('z'), -1);
-assert.equal(b.indexOf(''), -1);
-assert.equal(b.indexOf('', 1), -1);
-assert.equal(b.indexOf('', b.length + 1), -1);
-assert.equal(b.indexOf('', Infinity), -1);
-assert.equal(b.indexOf(buf_a), 0);
-assert.equal(b.indexOf(buf_a, 1), -1);
-assert.equal(b.indexOf(buf_a, -1), -1);
-assert.equal(b.indexOf(buf_a, -4), -1);
-assert.equal(b.indexOf(buf_a, -b.length), 0);
-assert.equal(b.indexOf(buf_a, NaN), 0);
-assert.equal(b.indexOf(buf_a, -Infinity), 0);
-assert.equal(b.indexOf(buf_a, Infinity), -1);
-assert.equal(b.indexOf(buf_bc), 1);
-assert.equal(b.indexOf(buf_bc, 2), -1);
-assert.equal(b.indexOf(buf_bc, -1), -1);
-assert.equal(b.indexOf(buf_bc, -3), -1);
-assert.equal(b.indexOf(buf_bc, -5), 1);
-assert.equal(b.indexOf(buf_bc, NaN), 1);
-assert.equal(b.indexOf(buf_bc, -Infinity), 1);
-assert.equal(b.indexOf(buf_bc, Infinity), -1);
-assert.equal(b.indexOf(buf_f), b.length - 1);
-assert.equal(b.indexOf(buf_z), -1);
-assert.equal(b.indexOf(buf_empty), -1);
-assert.equal(b.indexOf(buf_empty, 1), -1);
-assert.equal(b.indexOf(buf_empty, b.length + 1), -1);
-assert.equal(b.indexOf(buf_empty, Infinity), -1);
-assert.equal(b.indexOf(0x61), 0);
-assert.equal(b.indexOf(0x61, 1), -1);
-assert.equal(b.indexOf(0x61, -1), -1);
-assert.equal(b.indexOf(0x61, -4), -1);
-assert.equal(b.indexOf(0x61, -b.length), 0);
-assert.equal(b.indexOf(0x61, NaN), 0);
-assert.equal(b.indexOf(0x61, -Infinity), 0);
-assert.equal(b.indexOf(0x61, Infinity), -1);
-assert.equal(b.indexOf(0x0), -1);
+assert.strictEqual(b.indexOf('a'), 0);
+assert.strictEqual(b.indexOf('a', 1), -1);
+assert.strictEqual(b.indexOf('a', -1), -1);
+assert.strictEqual(b.indexOf('a', -4), -1);
+assert.strictEqual(b.indexOf('a', -b.length), 0);
+assert.strictEqual(b.indexOf('a', NaN), 0);
+assert.strictEqual(b.indexOf('a', -Infinity), 0);
+assert.strictEqual(b.indexOf('a', Infinity), -1);
+assert.strictEqual(b.indexOf('bc'), 1);
+assert.strictEqual(b.indexOf('bc', 2), -1);
+assert.strictEqual(b.indexOf('bc', -1), -1);
+assert.strictEqual(b.indexOf('bc', -3), -1);
+assert.strictEqual(b.indexOf('bc', -5), 1);
+assert.strictEqual(b.indexOf('bc', NaN), 1);
+assert.strictEqual(b.indexOf('bc', -Infinity), 1);
+assert.strictEqual(b.indexOf('bc', Infinity), -1);
+assert.strictEqual(b.indexOf('f'), b.length - 1);
+assert.strictEqual(b.indexOf('z'), -1);
+assert.strictEqual(b.indexOf(''), -1);
+assert.strictEqual(b.indexOf('', 1), -1);
+assert.strictEqual(b.indexOf('', b.length + 1), -1);
+assert.strictEqual(b.indexOf('', Infinity), -1);
+assert.strictEqual(b.indexOf(buf_a), 0);
+assert.strictEqual(b.indexOf(buf_a, 1), -1);
+assert.strictEqual(b.indexOf(buf_a, -1), -1);
+assert.strictEqual(b.indexOf(buf_a, -4), -1);
+assert.strictEqual(b.indexOf(buf_a, -b.length), 0);
+assert.strictEqual(b.indexOf(buf_a, NaN), 0);
+assert.strictEqual(b.indexOf(buf_a, -Infinity), 0);
+assert.strictEqual(b.indexOf(buf_a, Infinity), -1);
+assert.strictEqual(b.indexOf(buf_bc), 1);
+assert.strictEqual(b.indexOf(buf_bc, 2), -1);
+assert.strictEqual(b.indexOf(buf_bc, -1), -1);
+assert.strictEqual(b.indexOf(buf_bc, -3), -1);
+assert.strictEqual(b.indexOf(buf_bc, -5), 1);
+assert.strictEqual(b.indexOf(buf_bc, NaN), 1);
+assert.strictEqual(b.indexOf(buf_bc, -Infinity), 1);
+assert.strictEqual(b.indexOf(buf_bc, Infinity), -1);
+assert.strictEqual(b.indexOf(buf_f), b.length - 1);
+assert.strictEqual(b.indexOf(buf_z), -1);
+assert.strictEqual(b.indexOf(buf_empty), -1);
+assert.strictEqual(b.indexOf(buf_empty, 1), -1);
+assert.strictEqual(b.indexOf(buf_empty, b.length + 1), -1);
+assert.strictEqual(b.indexOf(buf_empty, Infinity), -1);
+assert.strictEqual(b.indexOf(0x61), 0);
+assert.strictEqual(b.indexOf(0x61, 1), -1);
+assert.strictEqual(b.indexOf(0x61, -1), -1);
+assert.strictEqual(b.indexOf(0x61, -4), -1);
+assert.strictEqual(b.indexOf(0x61, -b.length), 0);
+assert.strictEqual(b.indexOf(0x61, NaN), 0);
+assert.strictEqual(b.indexOf(0x61, -Infinity), 0);
+assert.strictEqual(b.indexOf(0x61, Infinity), -1);
+assert.strictEqual(b.indexOf(0x0), -1);
// test offsets
-assert.equal(b.indexOf('d', 2), 3);
-assert.equal(b.indexOf('f', 5), 5);
-assert.equal(b.indexOf('f', -1), 5);
-assert.equal(b.indexOf('f', 6), -1);
+assert.strictEqual(b.indexOf('d', 2), 3);
+assert.strictEqual(b.indexOf('f', 5), 5);
+assert.strictEqual(b.indexOf('f', -1), 5);
+assert.strictEqual(b.indexOf('f', 6), -1);
assert.equal(b.indexOf(Buffer.from('d'), 2), 3);
assert.equal(b.indexOf(Buffer.from('f'), 5), 5);
diff --git a/test/parallel/test-buffer-slice.js b/test/parallel/test-buffer-slice.js
index 076bf33fb077..2489420c33e6 100644
--- a/test/parallel/test-buffer-slice.js
+++ b/test/parallel/test-buffer-slice.js
@@ -3,52 +3,83 @@
require('../common');
const assert = require('assert');
-assert.strictEqual(0, Buffer.from('hello').slice(0, 0).length);
-assert.strictEqual(0, Buffer('hello').slice(0, 0).length);
+assert.strictEqual(0, Buffer.from('hello', 'utf8').slice(0, 0).length);
+assert.strictEqual(0, Buffer('hello', 'utf8').slice(0, 0).length);
-const buf = Buffer.from('0123456789');
-assert.equal(buf.slice(-10, 10), '0123456789');
-assert.equal(buf.slice(-20, 10), '0123456789');
-assert.equal(buf.slice(-20, -10), '');
-assert.equal(buf.slice(), '0123456789');
-assert.equal(buf.slice(0), '0123456789');
-assert.equal(buf.slice(0, 0), '');
-assert.equal(buf.slice(undefined), '0123456789');
-assert.equal(buf.slice('foobar'), '0123456789');
-assert.equal(buf.slice(undefined, undefined), '0123456789');
+const buf = Buffer.from('0123456789', 'utf8');
+assert.strictEqual(0, Buffer.compare(buf.slice(-10, 10),
+ Buffer.from('0123456789', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice(-20, 10),
+ Buffer.from('0123456789', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice(-20, -10),
+ Buffer.from('', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice(),
+ Buffer.from('0123456789', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice(0),
+ Buffer.from('0123456789', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice(0, 0),
+ Buffer.from('', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice(undefined),
+ Buffer.from('0123456789', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice('foobar'),
+ Buffer.from('0123456789', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice(undefined, undefined),
+ Buffer.from('0123456789', 'utf8')));
-assert.equal(buf.slice(2), '23456789');
-assert.equal(buf.slice(5), '56789');
-assert.equal(buf.slice(10), '');
-assert.equal(buf.slice(5, 8), '567');
-assert.equal(buf.slice(8, -1), '8');
-assert.equal(buf.slice(-10), '0123456789');
-assert.equal(buf.slice(0, -9), '0');
-assert.equal(buf.slice(0, -10), '');
-assert.equal(buf.slice(0, -1), '012345678');
-assert.equal(buf.slice(2, -2), '234567');
-assert.equal(buf.slice(0, 65536), '0123456789');
-assert.equal(buf.slice(65536, 0), '');
-assert.equal(buf.slice(-5, -8), '');
-assert.equal(buf.slice(-5, -3), '56');
-assert.equal(buf.slice(-10, 10), '0123456789');
-for (let i = 0, s = buf.toString(); i < buf.length; ++i) {
- assert.equal(buf.slice(i), s.slice(i));
- assert.equal(buf.slice(0, i), s.slice(0, i));
- assert.equal(buf.slice(-i), s.slice(-i));
- assert.equal(buf.slice(0, -i), s.slice(0, -i));
+assert.strictEqual(0, Buffer.compare(buf.slice(2),
+ Buffer.from('23456789', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice(5),
+ Buffer.from('56789', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice(10),
+ Buffer.from('', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice(5, 8),
+ Buffer.from('567', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice(8, -1),
+ Buffer.from('8', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice(-10),
+ Buffer.from('0123456789', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice(0, -9),
+ Buffer.from('0', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice(0, -10),
+ Buffer.from('', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice(0, -1),
+ Buffer.from('012345678', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice(2, -2),
+ Buffer.from('234567', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice(0, 65536),
+ Buffer.from('0123456789', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice(65536, 0),
+ Buffer.from('', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice(-5, -8),
+ Buffer.from('', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice(-5, -3),
+ Buffer.from('56', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice(-10, 10),
+ Buffer.from('0123456789', 'utf8')));
+for (let i = 0, s = buf; i < buf.length; ++i) {
+ assert.strictEqual(0, Buffer.compare(buf.slice(i), s.slice(i)));
+ assert.strictEqual(0, Buffer.compare(buf.slice(0, i), s.slice(0, i)));
+ assert.strictEqual(0, Buffer.compare(buf.slice(-i), s.slice(-i)));
+ assert.strictEqual(0, Buffer.compare(buf.slice(0, -i), s.slice(0, -i)));
}
const utf16Buf = Buffer.from('0123456789', 'utf16le');
assert.deepStrictEqual(utf16Buf.slice(0, 6), Buffer.from('012', 'utf16le'));
-assert.equal(buf.slice('0', '1'), '0');
-assert.equal(buf.slice('-5', '10'), '56789');
-assert.equal(buf.slice('-10', '10'), '0123456789');
-assert.equal(buf.slice('-10', '-5'), '01234');
-assert.equal(buf.slice('-10', '-0'), '');
-assert.equal(buf.slice('111'), '');
-assert.equal(buf.slice('0', '-111'), '');
+assert.strictEqual(0, Buffer.compare(buf.slice('0', '1'),
+ Buffer.from('0', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice('-5', '10'),
+ Buffer.from('56789', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice('-10', '10'),
+ Buffer.from('0123456789', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice('-10', '-5'),
+ Buffer.from('01234', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice('-10', '-0'),
+ Buffer.from('', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice('111'),
+ Buffer.from('', 'utf8')));
+assert.strictEqual(0, Buffer.compare(buf.slice('0', '-111'),
+ Buffer.from('', 'utf8')));
// try to slice a zero length Buffer
// see https://github.com/joyent/node/issues/5881
@@ -57,16 +88,17 @@ assert.strictEqual(Buffer.alloc(0).slice(0, 1).length, 0);
{
// Single argument slice
- assert.strictEqual('bcde', Buffer.from('abcde').slice(1).toString());
+ assert.strictEqual('bcde',
+ Buffer.from('abcde', 'utf8').slice(1).toString('utf8'));
}
// slice(0,0).length === 0
-assert.strictEqual(0, Buffer.from('hello').slice(0, 0).length);
+assert.strictEqual(0, Buffer.from('hello', 'utf8').slice(0, 0).length);
{
// Regression tests for https://github.com/nodejs/node/issues/9096
- const buf = Buffer.from('abcd');
- assert.strictEqual(buf.slice(buf.length / 3).toString(), 'bcd');
+ const buf = Buffer.from('abcd', 'utf8');
+ assert.strictEqual(buf.slice(buf.length / 3).toString('utf8'), 'bcd');
assert.strictEqual(
buf.slice(buf.length / 3, buf.length).toString(),
'bcd'
@@ -74,13 +106,14 @@ assert.strictEqual(0, Buffer.from('hello').slice(0, 0).length);
}
{
- const buf = Buffer.from('abcdefg');
- assert.strictEqual(buf.slice(-(-1 >>> 0) - 1).toString(), buf.toString());
+ const buf = Buffer.from('abcdefg', 'utf8');
+ assert.strictEqual(buf.slice(-(-1 >>> 0) - 1).toString('utf8'),
+ buf.toString('utf8'));
}
{
- const buf = Buffer.from('abc');
- assert.strictEqual(buf.slice(-0.5).toString(), buf.toString());
+ const buf = Buffer.from('abc', 'utf8');
+ assert.strictEqual(buf.slice(-0.5).toString('utf8'), buf.toString('utf8'));
}
{
diff --git a/test/parallel/test-buffer-slow.js b/test/parallel/test-buffer-slow.js
index 24bd9e1cfd31..7d27a9be1115 100644
--- a/test/parallel/test-buffer-slow.js
+++ b/test/parallel/test-buffer-slow.js
@@ -35,7 +35,7 @@ try {
assert.strictEqual(
SlowBuffer(buffer.kMaxLength).length, buffer.kMaxLength);
} catch (e) {
- assert.equal(e.message, 'Array buffer allocation failed');
+ assert.strictEqual(e.message, 'Array buffer allocation failed');
}
// should work with number-coercible values
@@ -51,10 +51,10 @@ assert.strictEqual(SlowBuffer('string').length, 0);
// should throw with invalid length
assert.throws(function() {
SlowBuffer(Infinity);
-}, 'invalid Buffer length');
+}, /^RangeError: Invalid array buffer length$/);
assert.throws(function() {
SlowBuffer(-1);
-}, 'invalid Buffer length');
+}, /^RangeError: Invalid array buffer length$/);
assert.throws(function() {
SlowBuffer(buffer.kMaxLength + 1);
-}, 'invalid Buffer length');
+}, /^RangeError: (Invalid typed array length|Array buffer allocation failed)$/);
diff --git a/test/parallel/test-child-process-constructor.js b/test/parallel/test-child-process-constructor.js
index 6980810485c9..0abf1289f073 100644
--- a/test/parallel/test-child-process-constructor.js
+++ b/test/parallel/test-child-process-constructor.js
@@ -4,7 +4,7 @@ require('../common');
var assert = require('assert');
var child_process = require('child_process');
var ChildProcess = child_process.ChildProcess;
-assert.equal(typeof ChildProcess, 'function');
+assert.strictEqual(typeof ChildProcess, 'function');
// test that we can call spawn
var child = new ChildProcess();
@@ -15,11 +15,11 @@ child.spawn({
stdio: 'pipe'
});
-assert.equal(child.hasOwnProperty('pid'), true);
+assert.strictEqual(child.hasOwnProperty('pid'), true);
// try killing with invalid signal
assert.throws(function() {
child.kill('foo');
}, /Unknown signal: foo/);
-assert.equal(child.kill(), true);
+assert.strictEqual(child.kill(), true);
diff --git a/test/parallel/test-child-process-double-pipe.js b/test/parallel/test-child-process-double-pipe.js
index 2d9805d68763..c5b7c093af8a 100644
--- a/test/parallel/test-child-process-double-pipe.js
+++ b/test/parallel/test-child-process-double-pipe.js
@@ -91,5 +91,5 @@ sed.stdout.on('data', function(data) {
});
sed.stdout.on('end', function(code) {
- assert.equal(result, 'hellO' + os.EOL + 'nOde' + os.EOL + 'wOrld' + os.EOL);
+ assert.strictEqual(result, `hellO${os.EOL}nOde${os.EOL}wOrld${os.EOL}`);
});
diff --git a/test/parallel/test-child-process-exec-error.js b/test/parallel/test-child-process-exec-error.js
index 006a2eebb912..f937fec5d252 100644
--- a/test/parallel/test-child-process-exec-error.js
+++ b/test/parallel/test-child-process-exec-error.js
@@ -1,12 +1,12 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var child_process = require('child_process');
+const common = require('../common');
+const assert = require('assert');
+const child_process = require('child_process');
-function test(fun, code) {
- fun('does-not-exist', common.mustCall(function(err) {
- assert.equal(err.code, code);
- assert(/does\-not\-exist/.test(err.cmd));
+function test(fn, code) {
+ fn('does-not-exist', common.mustCall(function(err) {
+ assert.strictEqual(err.code, code);
+ assert(err.cmd.includes('does-not-exist'));
}));
}
diff --git a/test/parallel/test-child-process-fork-exec-path.js b/test/parallel/test-child-process-fork-exec-path.js
index e42b72f2b858..e2f7e4b4d20e 100644
--- a/test/parallel/test-child-process-fork-exec-path.js
+++ b/test/parallel/test-child-process-fork-exec-path.js
@@ -9,7 +9,7 @@ var copyPath = path.join(common.tmpDir, 'node-copy.exe');
if (process.env.FORK) {
assert(process.send);
- assert.equal(process.argv[0], copyPath);
+ assert.strictEqual(process.argv[0], copyPath);
process.send(msg);
process.exit();
} else {
@@ -34,6 +34,6 @@ if (process.env.FORK) {
}));
child.on('exit', common.mustCall(function(code) {
fs.unlinkSync(copyPath);
- assert.equal(code, 0);
+ assert.strictEqual(code, 0);
}));
}
diff --git a/test/parallel/test-child-process-spawn-error.js b/test/parallel/test-child-process-spawn-error.js
index eaf9c1303966..6cd3c47eef46 100644
--- a/test/parallel/test-child-process-spawn-error.js
+++ b/test/parallel/test-child-process-spawn-error.js
@@ -1,17 +1,17 @@
'use strict';
-var common = require('../common');
-var spawn = require('child_process').spawn;
-var assert = require('assert');
+const common = require('../common');
+const spawn = require('child_process').spawn;
+const assert = require('assert');
-var enoentPath = 'foo123';
-var spawnargs = ['bar'];
-assert.equal(common.fileExists(enoentPath), false);
+const enoentPath = 'foo123';
+const spawnargs = ['bar'];
+assert.strictEqual(common.fileExists(enoentPath), false);
-var enoentChild = spawn(enoentPath, spawnargs);
+const enoentChild = spawn(enoentPath, spawnargs);
enoentChild.on('error', common.mustCall(function(err) {
- assert.equal(err.code, 'ENOENT');
- assert.equal(err.errno, 'ENOENT');
- assert.equal(err.syscall, 'spawn ' + enoentPath);
- assert.equal(err.path, enoentPath);
+ assert.strictEqual(err.code, 'ENOENT');
+ assert.strictEqual(err.errno, 'ENOENT');
+ assert.strictEqual(err.syscall, 'spawn ' + enoentPath);
+ assert.strictEqual(err.path, enoentPath);
assert.deepStrictEqual(err.spawnargs, spawnargs);
}));
diff --git a/test/parallel/test-child-process-stdio-inherit.js b/test/parallel/test-child-process-stdio-inherit.js
index 409c0af7ca0d..dc3bb3e9aa93 100644
--- a/test/parallel/test-child-process-stdio-inherit.js
+++ b/test/parallel/test-child-process-stdio-inherit.js
@@ -22,10 +22,10 @@ function grandparent() {
child.stdin.end(input);
child.on('close', function(code, signal) {
- assert.equal(code, 0);
- assert.equal(signal, null);
+ assert.strictEqual(code, 0);
+ assert.strictEqual(signal, null);
// cat on windows adds a \r\n at the end.
- assert.equal(output.trim(), input.trim());
+ assert.strictEqual(output.trim(), input.trim());
});
}
diff --git a/test/parallel/test-child-process-validate-stdio.js b/test/parallel/test-child-process-validate-stdio.js
index 09d000467404..384efdf15a14 100644
--- a/test/parallel/test-child-process-validate-stdio.js
+++ b/test/parallel/test-child-process-validate-stdio.js
@@ -19,10 +19,10 @@ assert.throws(function() {
{
const stdio1 = [];
const result = _validateStdio(stdio1, false);
- assert.equal(stdio1.length, 3);
- assert.equal(result.hasOwnProperty('stdio'), true);
- assert.equal(result.hasOwnProperty('ipc'), true);
- assert.equal(result.hasOwnProperty('ipcFd'), true);
+ assert.strictEqual(stdio1.length, 3);
+ assert.strictEqual(result.hasOwnProperty('stdio'), true);
+ assert.strictEqual(result.hasOwnProperty('ipc'), true);
+ assert.strictEqual(result.hasOwnProperty('ipcFd'), true);
}
// should throw if stdio has ipc and sync is true
diff --git a/test/parallel/test-cli-eval-event.js b/test/parallel/test-cli-eval-event.js
index b19bdd38680f..df356e50d37b 100644
--- a/test/parallel/test-cli-eval-event.js
+++ b/test/parallel/test-cli-eval-event.js
@@ -10,6 +10,6 @@ const child = spawn(process.execPath, ['-e', `
`]);
child.once('exit', common.mustCall(function(exitCode, signalCode) {
- assert.equal(exitCode, 0);
- assert.equal(signalCode, null);
+ assert.strictEqual(exitCode, 0);
+ assert.strictEqual(signalCode, null);
}));
diff --git a/test/parallel/test-cli-eval.js b/test/parallel/test-cli-eval.js
index 3c38afd2ac45..0198a0f1beda 100644
--- a/test/parallel/test-cli-eval.js
+++ b/test/parallel/test-cli-eval.js
@@ -19,15 +19,15 @@ var filename = __filename.replace(/\\/g, '/');
// assert that nothing is written to stdout
child.exec(nodejs + ' --eval 42',
function(err, stdout, stderr) {
- assert.equal(stdout, '');
- assert.equal(stderr, '');
+ assert.strictEqual(stdout, '');
+ assert.strictEqual(stderr, '');
});
// assert that "42\n" is written to stderr
child.exec(nodejs + ' --eval "console.error(42)"',
function(err, stdout, stderr) {
- assert.equal(stdout, '');
- assert.equal(stderr, '42\n');
+ assert.strictEqual(stdout, '');
+ assert.strictEqual(stderr, '42\n');
});
// assert that the expected output is written to stdout
@@ -36,21 +36,21 @@ child.exec(nodejs + ' --eval "console.error(42)"',
child.exec(cmd + '42',
function(err, stdout, stderr) {
- assert.equal(stdout, '42\n');
- assert.equal(stderr, '');
+ assert.strictEqual(stdout, '42\n');
+ assert.strictEqual(stderr, '');
});
child.exec(cmd + "'[]'", common.mustCall(
function(err, stdout, stderr) {
- assert.equal(stdout, '[]\n');
- assert.equal(stderr, '');
+ assert.strictEqual(stdout, '[]\n');
+ assert.strictEqual(stderr, '');
}));
});
// assert that module loading works
child.exec(nodejs + ' --eval "require(\'' + filename + '\')"',
function(status, stdout, stderr) {
- assert.equal(status.code, 42);
+ assert.strictEqual(status.code, 42);
});
// Check that builtin modules are pre-defined.
@@ -63,7 +63,7 @@ child.exec(nodejs + ' --print "os.platform()"',
// module path resolve bug, regression test
child.exec(nodejs + ' --eval "require(\'./test/parallel/test-cli-eval.js\')"',
function(status, stdout, stderr) {
- assert.equal(status.code, 42);
+ assert.strictEqual(status.code, 42);
});
// Missing argument should not crash
@@ -74,28 +74,29 @@ child.exec(nodejs + ' -e', common.mustCall(function(status, stdout, stderr) {
// empty program should do nothing
child.exec(nodejs + ' -e ""', function(status, stdout, stderr) {
- assert.equal(stdout, '');
- assert.equal(stderr, '');
+ assert.strictEqual(stdout, '');
+ assert.strictEqual(stderr, '');
});
// "\\-42" should be interpreted as an escaped expression, not a switch
child.exec(nodejs + ' -p "\\-42"',
function(err, stdout, stderr) {
- assert.equal(stdout, '-42\n');
- assert.equal(stderr, '');
+ assert.strictEqual(stdout, '-42\n');
+ assert.strictEqual(stderr, '');
});
child.exec(nodejs + ' --use-strict -p process.execArgv',
function(status, stdout, stderr) {
- assert.equal(stdout, "[ '--use-strict', '-p', 'process.execArgv' ]\n");
+ assert.strictEqual(stdout,
+ "[ '--use-strict', '-p', 'process.execArgv' ]\n");
});
// Regression test for https://github.com/nodejs/node/issues/3574
const emptyFile = path.join(common.fixturesDir, 'empty.js');
child.exec(nodejs + ` -e 'require("child_process").fork("${emptyFile}")'`,
function(status, stdout, stderr) {
- assert.equal(stdout, '');
- assert.equal(stderr, '');
+ assert.strictEqual(stdout, '');
+ assert.strictEqual(stderr, '');
});
// Regression test for https://github.com/nodejs/node/issues/8534.
diff --git a/test/parallel/test-cli-syntax.js b/test/parallel/test-cli-syntax.js
index 7718c42f31fa..839e50d7d94b 100644
--- a/test/parallel/test-cli-syntax.js
+++ b/test/parallel/test-cli-syntax.js
@@ -29,9 +29,9 @@ var syntaxArgs = [
var c = spawnSync(node, _args, {encoding: 'utf8'});
// no output should be produced
- assert.equal(c.stdout, '', 'stdout produced');
- assert.equal(c.stderr, '', 'stderr produced');
- assert.equal(c.status, 0, 'code == ' + c.status);
+ assert.strictEqual(c.stdout, '', 'stdout produced');
+ assert.strictEqual(c.stderr, '', 'stderr produced');
+ assert.strictEqual(c.status, 0, 'code == ' + c.status);
});
});
@@ -50,13 +50,13 @@ var syntaxArgs = [
var c = spawnSync(node, _args, {encoding: 'utf8'});
// no stdout should be produced
- assert.equal(c.stdout, '', 'stdout produced');
+ assert.strictEqual(c.stdout, '', 'stdout produced');
// stderr should have a syntax error message
var match = c.stderr.match(/^SyntaxError: Unexpected identifier$/m);
assert(match, 'stderr incorrect');
- assert.equal(c.status, 1, 'code == ' + c.status);
+ assert.strictEqual(c.status, 1, 'code == ' + c.status);
});
});
@@ -73,12 +73,12 @@ var syntaxArgs = [
var c = spawnSync(node, _args, {encoding: 'utf8'});
// no stdout should be produced
- assert.equal(c.stdout, '', 'stdout produced');
+ assert.strictEqual(c.stdout, '', 'stdout produced');
// stderr should have a module not found error message
var match = c.stderr.match(/^Error: Cannot find module/m);
assert(match, 'stderr incorrect');
- assert.equal(c.status, 1, 'code == ' + c.status);
+ assert.strictEqual(c.status, 1, 'code == ' + c.status);
});
});
diff --git a/test/parallel/test-cluster-dgram-2.js b/test/parallel/test-cluster-dgram-2.js
index 179b1ee15327..863e0fa358c7 100644
--- a/test/parallel/test-cluster-dgram-2.js
+++ b/test/parallel/test-cluster-dgram-2.js
@@ -57,6 +57,13 @@ function worker() {
// send(), explicitly bind them to an ephemeral port.
socket.bind(0);
- for (var i = 0; i < PACKETS_PER_WORKER; i++)
+ // There is no guarantee that a sent dgram packet will be received so keep
+ // sending until disconnect.
+ const interval = setInterval(() => {
socket.send(buf, 0, buf.length, common.PORT, '127.0.0.1');
+ }, 1);
+
+ cluster.worker.on('disconnect', () => {
+ clearInterval(interval);
+ });
}
diff --git a/test/parallel/test-cluster-send-deadlock.js b/test/parallel/test-cluster-send-deadlock.js
index 90b8c9169535..fa3e11382482 100644
--- a/test/parallel/test-cluster-send-deadlock.js
+++ b/test/parallel/test-cluster-send-deadlock.js
@@ -10,7 +10,7 @@ var net = require('net');
if (cluster.isMaster) {
var worker = cluster.fork();
worker.on('exit', function(code, signal) {
- assert.equal(code, 0, 'Worker exited with an error code');
+ assert.strictEqual(code, 0, 'Worker exited with an error code');
assert(!signal, 'Worker exited by a signal');
server.close();
});
diff --git a/test/parallel/test-cluster-setup-master-argv.js b/test/parallel/test-cluster-setup-master-argv.js
index c42291417f9e..32c5a91b3caa 100644
--- a/test/parallel/test-cluster-setup-master-argv.js
+++ b/test/parallel/test-cluster-setup-master-argv.js
@@ -1,16 +1,16 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var cluster = require('cluster');
+const common = require('../common');
+const assert = require('assert');
+const cluster = require('cluster');
setTimeout(common.fail.bind(assert, 'setup not emitted'), 1000).unref();
-cluster.on('setup', function() {
+cluster.on('setup', common.mustCall(function() {
var clusterArgs = cluster.settings.args;
var realArgs = process.argv;
- assert.equal(clusterArgs[clusterArgs.length - 1],
- realArgs[realArgs.length - 1]);
-});
+ assert.strictEqual(clusterArgs[clusterArgs.length - 1],
+ realArgs[realArgs.length - 1]);
+}));
assert.notStrictEqual(process.argv[process.argv.length - 1], 'OMG,OMG');
process.argv.push('OMG,OMG');
diff --git a/test/parallel/test-cluster-shared-handle-bind-error.js b/test/parallel/test-cluster-shared-handle-bind-error.js
index f5a08a1ed848..99573ef9539f 100644
--- a/test/parallel/test-cluster-shared-handle-bind-error.js
+++ b/test/parallel/test-cluster-shared-handle-bind-error.js
@@ -12,7 +12,7 @@ if (cluster.isMaster) {
var server = this;
var worker = cluster.fork();
worker.on('exit', common.mustCall(function(exitCode) {
- assert.equal(exitCode, 0);
+ assert.strictEqual(exitCode, 0);
server.close();
}));
});
@@ -20,7 +20,7 @@ if (cluster.isMaster) {
var s = net.createServer(common.fail);
s.listen(common.PORT, common.fail.bind(null, 'listen should have failed'));
s.on('error', common.mustCall(function(err) {
- assert.equal(err.code, 'EADDRINUSE');
+ assert.strictEqual(err.code, 'EADDRINUSE');
process.disconnect();
}));
}
diff --git a/test/parallel/test-cluster-shared-handle-bind-privileged-port.js b/test/parallel/test-cluster-shared-handle-bind-privileged-port.js
index 9dc0e4ea7731..c58aa5393519 100644
--- a/test/parallel/test-cluster-shared-handle-bind-privileged-port.js
+++ b/test/parallel/test-cluster-shared-handle-bind-privileged-port.js
@@ -1,8 +1,8 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var cluster = require('cluster');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const cluster = require('cluster');
+const net = require('net');
if (common.isWindows) {
common.skip('not reliable on Windows');
@@ -18,13 +18,13 @@ if (cluster.isMaster) {
// Master opens and binds the socket and shares it with the worker.
cluster.schedulingPolicy = cluster.SCHED_NONE;
cluster.fork().on('exit', common.mustCall(function(exitCode) {
- assert.equal(exitCode, 0);
+ assert.strictEqual(exitCode, 0);
}));
} else {
- var s = net.createServer(common.fail);
+ const s = net.createServer(common.fail);
s.listen(42, common.fail.bind(null, 'listen should have failed'));
s.on('error', common.mustCall(function(err) {
- assert.equal(err.code, 'EACCES');
+ assert.strictEqual(err.code, 'EACCES');
process.disconnect();
}));
}
diff --git a/test/parallel/test-cluster-worker-events.js b/test/parallel/test-cluster-worker-events.js
index fadfd5356540..08bf456a735b 100644
--- a/test/parallel/test-cluster-worker-events.js
+++ b/test/parallel/test-cluster-worker-events.js
@@ -10,7 +10,7 @@ if (cluster.isMaster) {
var worker = cluster.fork();
worker.on('exit', function(code) {
- assert.equal(code, OK);
+ assert.strictEqual(code, OK);
process.exit(0);
});
@@ -50,7 +50,7 @@ function check(m) {
assert.deepStrictEqual(messages[0], messages[1]);
cluster.worker.once('error', function(e) {
- assert.equal(e, 'HI');
+ assert.strictEqual(e, 'HI');
process.exit(OK);
});
diff --git a/test/parallel/test-console-instance.js b/test/parallel/test-console-instance.js
index b8d988086553..4d2727d96b1a 100644
--- a/test/parallel/test-console-instance.js
+++ b/test/parallel/test-console-instance.js
@@ -15,7 +15,7 @@ process.stdout.write = process.stderr.write = function() {
};
// make sure that the "Console" function exists
-assert.equal('function', typeof Console);
+assert.strictEqual('function', typeof Console);
// make sure that the Console constructor throws
// when not given a writable stream instance
@@ -35,7 +35,7 @@ out.write = err.write = function(d) {};
var c = new Console(out, err);
out.write = err.write = function(d) {
- assert.equal(d, 'test\n');
+ assert.strictEqual(d, 'test\n');
called = true;
};
@@ -48,7 +48,7 @@ c.error('test');
assert(called);
out.write = function(d) {
- assert.equal('{ foo: 1 }\n', d);
+ assert.strictEqual('{ foo: 1 }\n', d);
called = true;
};
@@ -60,10 +60,10 @@ assert(called);
called = 0;
out.write = function(d) {
called++;
- assert.equal(d, called + ' ' + (called - 1) + ' [ 1, 2, 3 ]\n');
+ assert.strictEqual(d, called + ' ' + (called - 1) + ' [ 1, 2, 3 ]\n');
};
[1, 2, 3].forEach(c.log);
-assert.equal(3, called);
+assert.strictEqual(3, called);
// Console() detects if it is called without `new` keyword
assert.doesNotThrow(function() {
diff --git a/test/parallel/test-console.js b/test/parallel/test-console.js
index 2c8a498a331b..ee7170bd9101 100644
--- a/test/parallel/test-console.js
+++ b/test/parallel/test-console.js
@@ -5,8 +5,8 @@ const assert = require('assert');
assert.ok(process.stdout.writable);
assert.ok(process.stderr.writable);
// Support legacy API
-assert.equal('number', typeof process.stdout.fd);
-assert.equal('number', typeof process.stderr.fd);
+assert.strictEqual('number', typeof process.stdout.fd);
+assert.strictEqual('number', typeof process.stderr.fd);
assert.doesNotThrow(function() {
process.once('warning', common.mustCall((warning) => {
@@ -35,28 +35,28 @@ global.process.stderr.write = function(string) {
errStrings.push(string);
};
-// test console.log()
+// test console.log() goes to stdout
console.log('foo');
console.log('foo', 'bar');
console.log('%s %s', 'foo', 'bar', 'hop');
console.log({slashes: '\\\\'});
console.log(custom_inspect);
-// test console.info()
+// test console.info() goes to stdout
console.info('foo');
console.info('foo', 'bar');
console.info('%s %s', 'foo', 'bar', 'hop');
console.info({slashes: '\\\\'});
console.info(custom_inspect);
-// test console.error()
+// test console.error() goes to stderr
console.error('foo');
console.error('foo', 'bar');
console.error('%s %s', 'foo', 'bar', 'hop');
console.error({slashes: '\\\\'});
console.error(custom_inspect);
-// test console.warn()
+// test console.warn() goes to stderr
console.warn('foo');
console.warn('foo', 'bar');
console.warn('%s %s', 'foo', 'bar', 'hop');
@@ -102,29 +102,31 @@ const expectedStrings = [
];
for (const expected of expectedStrings) {
- assert.equal(expected + '\n', strings.shift()); // console.log (stdout)
- assert.equal(expected + '\n', errStrings.shift()); // console.error (stderr)
+ assert.strictEqual(expected + '\n', strings.shift());
+ assert.strictEqual(expected + '\n', errStrings.shift());
}
for (const expected of expectedStrings) {
- assert.equal(expected + '\n', strings.shift()); // console.info (stdout)
- assert.equal(expected + '\n', errStrings.shift()); // console.warn (stderr)
+ assert.strictEqual(expected + '\n', strings.shift());
+ assert.strictEqual(expected + '\n', errStrings.shift());
}
-assert.equal("{ foo: 'bar', inspect: [Function: inspect] }\n", strings.shift());
-assert.equal("{ foo: 'bar', inspect: [Function: inspect] }\n", strings.shift());
+assert.strictEqual("{ foo: 'bar', inspect: [Function: inspect] }\n",
+ strings.shift());
+assert.strictEqual("{ foo: 'bar', inspect: [Function: inspect] }\n",
+ strings.shift());
assert.notEqual(-1, strings.shift().indexOf('foo: [Object]'));
-assert.equal(-1, strings.shift().indexOf('baz'));
+assert.strictEqual(-1, strings.shift().indexOf('baz'));
assert.ok(/^label: \d+\.\d{3}ms$/.test(strings.shift().trim()));
assert.ok(/^__proto__: \d+\.\d{3}ms$/.test(strings.shift().trim()));
assert.ok(/^constructor: \d+\.\d{3}ms$/.test(strings.shift().trim()));
assert.ok(/^hasOwnProperty: \d+\.\d{3}ms$/.test(strings.shift().trim()));
-assert.equal('Trace: This is a {"formatted":"trace"} 10 foo',
- errStrings.shift().split('\n').shift());
+assert.strictEqual('Trace: This is a {"formatted":"trace"} 10 foo',
+ errStrings.shift().split('\n').shift());
-assert.equal(strings.length, 0);
-assert.equal(errStrings.length, 0);
+assert.strictEqual(strings.length, 0);
+assert.strictEqual(errStrings.length, 0);
assert.throws(() => {
console.assert(false, 'should throw');
diff --git a/test/parallel/test-constants.js b/test/parallel/test-constants.js
index ea0b93ba7fab..c11935783f86 100644
--- a/test/parallel/test-constants.js
+++ b/test/parallel/test-constants.js
@@ -1,12 +1,26 @@
'use strict';
require('../common');
-const constants = process.binding('constants');
+const binding = process.binding('constants');
+const constants = require('constants');
const assert = require('assert');
-assert.ok(constants);
-assert.ok(constants.os);
-assert.ok(constants.os.signals);
-assert.ok(constants.os.errno);
-assert.ok(constants.fs);
-assert.ok(constants.crypto);
+assert.ok(binding);
+assert.ok(binding.os);
+assert.ok(binding.os.signals);
+assert.ok(binding.os.errno);
+assert.ok(binding.fs);
+assert.ok(binding.crypto);
+
+['os', 'fs', 'crypto'].forEach((l) => {
+ Object.keys(binding[l]).forEach((k) => {
+ if (typeof binding[l][k] === 'object') { // errno and signals
+ Object.keys(binding[l][k]).forEach((j) => {
+ assert.strictEqual(binding[l][k][j], constants[j]);
+ });
+ }
+ if (l !== 'os') { // top level os constant isn't currently copied
+ assert.strictEqual(binding[l][k], constants[k]);
+ }
+ });
+});
diff --git a/test/parallel/test-crypto-binary-default.js b/test/parallel/test-crypto-binary-default.js
index 3b3603157786..33a0783fe999 100644
--- a/test/parallel/test-crypto-binary-default.js
+++ b/test/parallel/test-crypto-binary-default.js
@@ -3,30 +3,30 @@
// to use buffers by default.
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var crypto = require('crypto');
-var tls = require('tls');
+
+const assert = require('assert');
+const crypto = require('crypto');
+const fs = require('fs');
+const path = require('path');
+const tls = require('tls');
const DH_NOT_SUITABLE_GENERATOR = crypto.constants.DH_NOT_SUITABLE_GENERATOR;
crypto.DEFAULT_ENCODING = 'latin1';
-var fs = require('fs');
-var path = require('path');
-
// Test Certificates
-var certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
-var certPfx = fs.readFileSync(common.fixturesDir + '/test_cert.pfx');
-var keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
-var rsaPubPem = fs.readFileSync(common.fixturesDir + '/test_rsa_pubkey.pem',
- 'ascii');
-var rsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_rsa_privkey.pem',
- 'ascii');
+const certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
+const certPfx = fs.readFileSync(common.fixturesDir + '/test_cert.pfx');
+const keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
+const rsaPubPem = fs.readFileSync(common.fixturesDir + '/test_rsa_pubkey.pem',
+ 'ascii');
+const rsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_rsa_privkey.pem',
+ 'ascii');
// PFX tests
assert.doesNotThrow(function() {
@@ -35,22 +35,22 @@ assert.doesNotThrow(function() {
assert.throws(function() {
tls.createSecureContext({pfx: certPfx});
-}, 'mac verify failure');
+}, /^Error: mac verify failure$/);
assert.throws(function() {
tls.createSecureContext({pfx: certPfx, passphrase: 'test'});
-}, 'mac verify failure');
+}, /^Error: mac verify failure$/);
assert.throws(function() {
tls.createSecureContext({pfx: 'sample', passphrase: 'test'});
-}, 'not enough data');
+}, /^Error: not enough data$/);
// Test HMAC
const hmacHash = crypto.createHmac('sha1', 'Node')
.update('some data')
.update('to hmac')
.digest('hex');
-assert.equal(hmacHash, '19fd6e1ba73d9ed2224dd5094a71babe85d9a892', 'test HMAC');
+assert.strictEqual(hmacHash, '19fd6e1ba73d9ed2224dd5094a71babe85d9a892');
// Test HMAC-SHA-* (rfc 4231 Test Cases)
var rfc4231 = [
@@ -74,7 +74,7 @@ var rfc4231 = [
{
key: Buffer.from('4a656665', 'hex'), // 'Jefe'
data: Buffer.from('7768617420646f2079612077616e7420666f72206e6f74686' +
- '96e673f', 'hex'), // 'what do ya want for nothing?'
+ '96e673f', 'hex'), // 'what do ya want for nothing?'
hmac: {
sha224: 'a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44',
sha256:
@@ -92,8 +92,8 @@ var rfc4231 = [
{
key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
data: Buffer.from('ddddddddddddddddddddddddddddddddddddddddddddddddd' +
- 'ddddddddddddddddddddddddddddddddddddddddddddddddddd',
- 'hex'),
+ 'ddddddddddddddddddddddddddddddddddddddddddddddddddd',
+ 'hex'),
hmac: {
sha224: '7fb3cb3588c6c1f6ffa9694d7d6ad2649365b0c1f65d69d1ec8333ea',
sha256:
@@ -110,10 +110,10 @@ var rfc4231 = [
},
{
key: Buffer.from('0102030405060708090a0b0c0d0e0f10111213141516171819',
- 'hex'),
- data: Buffer.from('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc' +
- 'dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd',
'hex'),
+ data: Buffer.from('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc' +
+ 'dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd',
+ 'hex'),
hmac: {
sha224: '6c11506874013cac6a2abc1bb382627cec6a90d86efc012de7afec5a',
sha256:
@@ -143,15 +143,15 @@ var rfc4231 = [
},
{
key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaa', 'hex'),
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaa', 'hex'),
// 'Test Using Larger Than Block-Size Key - Hash Key First'
data: Buffer.from('54657374205573696e67204c6172676572205468616e20426' +
- 'c6f636b2d53697a65204b6579202d2048617368204b657920' +
- '4669727374', 'hex'),
+ 'c6f636b2d53697a65204b6579202d2048617368204b657920' +
+ '4669727374', 'hex'),
hmac: {
sha224: '95e9a0db962095adaebe9b2d6f0dbce2d499f112f2d2b7273fa6870e',
sha256:
@@ -168,21 +168,21 @@ var rfc4231 = [
},
{
key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaa', 'hex'),
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaa', 'hex'),
// 'This is a test using a larger than block-size key and a larger ' +
// 'than block-size data. The key needs to be hashed before being ' +
// 'used by the HMAC algorithm.'
data: Buffer.from('5468697320697320612074657374207573696e672061206c6' +
- '172676572207468616e20626c6f636b2d73697a65206b6579' +
- '20616e642061206c6172676572207468616e20626c6f636b2' +
- 'd73697a6520646174612e20546865206b6579206e65656473' +
- '20746f20626520686173686564206265666f7265206265696' +
- 'e6720757365642062792074686520484d414320616c676f72' +
- '6974686d2e', 'hex'),
+ '172676572207468616e20626c6f636b2d73697a65206b6579' +
+ '20616e642061206c6172676572207468616e20626c6f636b2' +
+ 'd73697a6520646174612e20546865206b6579206e65656473' +
+ '20746f20626520686173686564206265666f7265206265696' +
+ 'e6720757365642062792074686520484d414320616c676f72' +
+ '6974686d2e', 'hex'),
hmac: {
sha224: '3a854166ac5d9f023f54d517d0b39dbd946770db9c2b95c9f6f565d1',
sha256:
@@ -207,9 +207,11 @@ for (let i = 0, l = rfc4231.length; i < l; i++) {
if (rfc4231[i]['truncate']) {
result = result.substr(0, 32); // first 128 bits == 32 hex chars
}
- assert.equal(rfc4231[i]['hmac'][hash],
- result,
- 'Test HMAC-' + hash + ': Test case ' + (i + 1) + ' rfc 4231');
+ assert.strictEqual(
+ rfc4231[i]['hmac'][hash],
+ result,
+ `Test HMAC-${hash}: Test case ${i + 1} rfc 4231`
+ );
}
}
@@ -228,17 +230,17 @@ var rfc2202_md5 = [
{
key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
data: Buffer.from('ddddddddddddddddddddddddddddddddddddddddddddddddd' +
- 'ddddddddddddddddddddddddddddddddddddddddddddddddddd',
- 'hex'),
+ 'ddddddddddddddddddddddddddddddddddddddddddddddddddd',
+ 'hex'),
hmac: '56be34521d144c88dbb8c733f0e8b3f6'
},
{
key: Buffer.from('0102030405060708090a0b0c0d0e0f10111213141516171819',
- 'hex'),
- data: Buffer.from('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc' +
- 'dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd' +
- 'cdcdcdcdcd',
'hex'),
+ data: Buffer.from('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc' +
+ 'dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd' +
+ 'cdcdcdcdcd',
+ 'hex'),
hmac: '697eaf0aca3a3aea3a75164746ffaa79'
},
{
@@ -248,19 +250,19 @@ var rfc2202_md5 = [
},
{
key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaaaaaaaaaaaa',
- 'hex'),
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaa',
+ 'hex'),
data: 'Test Using Larger Than Block-Size Key - Hash Key First',
hmac: '6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd'
},
{
key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaaaaaaaaaaaa',
- 'hex'),
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaa',
+ 'hex'),
data:
'Test Using Larger Than Block-Size Key and Larger Than One ' +
'Block-Size Data',
@@ -281,18 +283,18 @@ var rfc2202_sha1 = [
{
key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
data: Buffer.from('ddddddddddddddddddddddddddddddddddddddddddddd' +
- 'ddddddddddddddddddddddddddddddddddddddddddddd' +
- 'dddddddddd',
- 'hex'),
+ 'ddddddddddddddddddddddddddddddddddddddddddddd' +
+ 'dddddddddd',
+ 'hex'),
hmac: '125d7342b9ac11cd91a39af48aa17b4f63f175d3'
},
{
key: Buffer.from('0102030405060708090a0b0c0d0e0f10111213141516171819',
- 'hex'),
- data: Buffer.from('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc' +
- 'dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd' +
- 'cdcdcdcdcd',
'hex'),
+ data: Buffer.from('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc' +
+ 'dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd' +
+ 'cdcdcdcdcd',
+ 'hex'),
hmac: '4c9007f4026250c6bc8414f9bf50c86c2d7235da'
},
{
@@ -302,19 +304,19 @@ var rfc2202_sha1 = [
},
{
key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaaaaaaaaaaaa',
- 'hex'),
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaa',
+ 'hex'),
data: 'Test Using Larger Than Block-Size Key - Hash Key First',
hmac: 'aa4ae5e15272d00e95705637ce8a3b55ed402112'
},
{
key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
- 'aaaaaaaaaaaaaaaaaaaaaa',
- 'hex'),
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaa',
+ 'hex'),
data:
'Test Using Larger Than Block-Size Key and Larger Than One ' +
'Block-Size Data',
@@ -329,7 +331,7 @@ for (let i = 0, l = rfc2202_md5.length; i < l; i++) {
crypto.createHmac('md5', rfc2202_md5[i]['key'])
.update(rfc2202_md5[i]['data'])
.digest('hex'),
- 'Test HMAC-MD5 : Test case ' + (i + 1) + ' rfc 2202'
+ `Test HMAC-MD5 : Test case ${i + 1} rfc 2202`
);
}
}
@@ -339,7 +341,7 @@ for (let i = 0, l = rfc2202_sha1.length; i < l; i++) {
crypto.createHmac('sha1', rfc2202_sha1[i]['key'])
.update(rfc2202_sha1[i]['data'])
.digest('hex'),
- 'Test HMAC-SHA1 : Test case ' + (i + 1) + ' rfc 2202'
+ `Test HMAC-SHA1 : Test case ${i + 1} rfc 2202`
);
}
@@ -351,24 +353,27 @@ var a4 = crypto.createHash('sha1').update('Test123').digest('buffer');
if (!common.hasFipsCrypto) {
var a0 = crypto.createHash('md5').update('Test123').digest('latin1');
- assert.equal(
+ assert.strictEqual(
a0,
'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca\u00bd\u008c',
'Test MD5 as latin1'
);
}
-assert.equal(a1, '8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'Test SHA1');
+assert.strictEqual(a1, '8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'Test SHA1');
-assert.equal(a2, '2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=',
- 'Test SHA256 as base64');
+assert.strictEqual(a2, '2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=',
+ 'Test SHA256 as base64');
-assert.equal(a3, '\u00c1(4\u00f1\u0003\u001fd\u0097!O\'\u00d4C/&Qz\u00d4' +
- '\u0094\u0015l\u00b8\u008dQ+\u00db\u001d\u00c4\u00b5}\u00b2' +
- '\u00d6\u0092\u00a3\u00df\u00a2i\u00a1\u009b\n\n*\u000f' +
- '\u00d7\u00d6\u00a2\u00a8\u0085\u00e3<\u0083\u009c\u0093' +
- '\u00c2\u0006\u00da0\u00a1\u00879(G\u00ed\'',
- 'Test SHA512 as assumed latin1');
+assert.strictEqual(
+ a3,
+ '\u00c1(4\u00f1\u0003\u001fd\u0097!O\'\u00d4C/&Qz\u00d4' +
+ '\u0094\u0015l\u00b8\u008dQ+\u00db\u001d\u00c4\u00b5}\u00b2' +
+ '\u00d6\u0092\u00a3\u00df\u00a2i\u00a1\u009b\n\n*\u000f' +
+ '\u00d7\u00d6\u00a2\u00a8\u0085\u00e3<\u0083\u009c\u0093' +
+ '\u00c2\u0006\u00da0\u00a1\u00879(G\u00ed\'',
+ 'Test SHA512 as assumed latin1'
+);
assert.deepStrictEqual(
a4,
@@ -379,7 +384,7 @@ assert.deepStrictEqual(
// Test multiple updates to same hash
var h1 = crypto.createHash('sha1').update('Test123').digest('hex');
var h2 = crypto.createHash('sha1').update('Test').update('123').digest('hex');
-assert.equal(h1, h2, 'multipled updates');
+assert.strictEqual(h1, h2, 'multipled updates');
// Test hashing for binary files
var fn = path.join(common.fixturesDir, 'sample.png');
@@ -388,16 +393,18 @@ var fileStream = fs.createReadStream(fn);
fileStream.on('data', function(data) {
sha1Hash.update(data);
});
-fileStream.on('close', function() {
- assert.equal(sha1Hash.digest('hex'),
- '22723e553129a336ad96e10f6aecdf0f45e4149e',
- 'Test SHA1 of sample.png');
-});
+fileStream.on('close', common.mustCall(function() {
+ assert.strictEqual(
+ sha1Hash.digest('hex'),
+ '22723e553129a336ad96e10f6aecdf0f45e4149e',
+ 'Test SHA1 of sample.png'
+ );
+}));
// Issue #2227: unknown digest method should throw an error.
assert.throws(function() {
crypto.createHash('xyzzy');
-});
+}, /^Error: Digest method not supported$/);
// Test signing and verifying
var s1 = crypto.createSign('RSA-SHA1')
@@ -443,7 +450,7 @@ function testCipher1(key) {
var txt = decipher.update(ciph, 'hex', 'utf8');
txt += decipher.final('utf8');
- assert.equal(txt, plaintext, 'encryption and decryption');
+ assert.strictEqual(txt, plaintext, 'encryption and decryption');
}
@@ -465,7 +472,7 @@ function testCipher2(key) {
var txt = decipher.update(ciph, 'base64', 'utf8');
txt += decipher.final('utf8');
- assert.equal(txt, plaintext, 'encryption and decryption with Base64');
+ assert.strictEqual(txt, plaintext, 'encryption and decryption with Base64');
}
@@ -483,7 +490,8 @@ function testCipher3(key, iv) {
var txt = decipher.update(ciph, 'hex', 'utf8');
txt += decipher.final('utf8');
- assert.equal(txt, plaintext, 'encryption and decryption with key and iv');
+ assert.strictEqual(txt, plaintext,
+ 'encryption and decryption with key and iv');
}
@@ -501,7 +509,8 @@ function testCipher4(key, iv) {
var txt = decipher.update(ciph, 'buffer', 'utf8');
txt += decipher.final('utf8');
- assert.equal(txt, plaintext, 'encryption and decryption with key and iv');
+ assert.strictEqual(txt, plaintext,
+ 'encryption and decryption with key and iv');
}
if (!common.hasFipsCrypto) {
@@ -523,7 +532,7 @@ testCipher4(Buffer.from('0123456789abcd0123456789'), Buffer.from('12345678'));
// update() should only take buffers / strings
assert.throws(function() {
crypto.createHash('sha1').update({foo: 'bar'});
-}, /buffer/);
+}, /^TypeError: Data must be a string or a buffer$/);
// Test Diffie-Hellman with two parties sharing a secret,
@@ -536,7 +545,7 @@ var key2 = dh2.generateKeys('hex');
var secret1 = dh1.computeSecret(key2, 'hex', 'base64');
var secret2 = dh2.computeSecret(key1, 'latin1', 'buffer');
-assert.equal(secret1, secret2.toString('base64'));
+assert.strictEqual(secret1, secret2.toString('base64'));
// Create "another dh1" using generated keys from dh1,
// and compute secret again
@@ -545,14 +554,14 @@ var privkey1 = dh1.getPrivateKey();
dh3.setPublicKey(key1);
dh3.setPrivateKey(privkey1);
-assert.equal(dh1.getPrime(), dh3.getPrime());
-assert.equal(dh1.getGenerator(), dh3.getGenerator());
-assert.equal(dh1.getPublicKey(), dh3.getPublicKey());
-assert.equal(dh1.getPrivateKey(), dh3.getPrivateKey());
+assert.strictEqual(dh1.getPrime(), dh3.getPrime());
+assert.strictEqual(dh1.getGenerator(), dh3.getGenerator());
+assert.strictEqual(dh1.getPublicKey(), dh3.getPublicKey());
+assert.strictEqual(dh1.getPrivateKey(), dh3.getPrivateKey());
var secret3 = dh3.computeSecret(key2, 'hex', 'base64');
-assert.equal(secret1, secret3);
+assert.strictEqual(secret1, secret3);
// https://github.com/joyent/node/issues/2338
var p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' +
@@ -560,22 +569,24 @@ var p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' +
'4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' +
'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF';
var d = crypto.createDiffieHellman(p, 'hex');
-assert.equal(d.verifyError, DH_NOT_SUITABLE_GENERATOR);
+assert.strictEqual(d.verifyError, DH_NOT_SUITABLE_GENERATOR);
// Test RSA key signing/verification
var rsaSign = crypto.createSign('RSA-SHA1');
var rsaVerify = crypto.createVerify('RSA-SHA1');
-assert.ok(rsaSign);
-assert.ok(rsaVerify);
+assert.ok(rsaSign instanceof crypto.Sign);
+assert.ok(rsaVerify instanceof crypto.Verify);
rsaSign.update(rsaPubPem);
var rsaSignature = rsaSign.sign(rsaKeyPem, 'hex');
-assert.equal(rsaSignature,
- '5c50e3145c4e2497aadb0eabc83b342d0b0021ece0d4c4a064b7c' +
- '8f020d7e2688b122bfb54c724ac9ee169f83f66d2fe90abeb95e8' +
- 'e1290e7e177152a4de3d944cf7d4883114a20ed0f78e70e25ef0f' +
- '60f06b858e6af42a2f276ede95bbc6bc9a9bbdda15bd663186a6f' +
- '40819a7af19e577bb2efa5e579a1f5ce8a0d4ca8b8f6');
+assert.strictEqual(
+ rsaSignature,
+ '5c50e3145c4e2497aadb0eabc83b342d0b0021ece0d4c4a064b7c' +
+ '8f020d7e2688b122bfb54c724ac9ee169f83f66d2fe90abeb95e8' +
+ 'e1290e7e177152a4de3d944cf7d4883114a20ed0f78e70e25ef0f' +
+ '60f06b858e6af42a2f276ede95bbc6bc9a9bbdda15bd663186a6f' +
+ '40819a7af19e577bb2efa5e579a1f5ce8a0d4ca8b8f6'
+);
rsaVerify.update(rsaPubPem);
assert.strictEqual(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), true);
@@ -642,12 +653,14 @@ assert.strictEqual(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), true);
// Test PBKDF2 with RFC 6070 test vectors (except #4)
//
function testPBKDF2(password, salt, iterations, keylen, expected) {
- var actual = crypto.pbkdf2Sync(password, salt, iterations, keylen, 'sha256');
- assert.equal(actual, expected);
+ const actual = crypto.pbkdf2Sync(password, salt, iterations, keylen,
+ 'sha256');
+ assert.strictEqual(actual, expected);
- crypto.pbkdf2(password, salt, iterations, keylen, 'sha256', (err, actual) => {
- assert.equal(actual, expected);
+ const cb = common.mustCall((err, actual) => {
+ assert.strictEqual(actual, expected);
});
+ crypto.pbkdf2(password, salt, iterations, keylen, 'sha256', cb);
}
diff --git a/test/parallel/test-crypto-certificate.js b/test/parallel/test-crypto-certificate.js
index 66a5da040738..1dfb2c73b0ec 100644
--- a/test/parallel/test-crypto-certificate.js
+++ b/test/parallel/test-crypto-certificate.js
@@ -19,20 +19,20 @@ var spkacPem = fs.readFileSync(common.fixturesDir + '/spkac.pem');
var certificate = new crypto.Certificate();
-assert.equal(certificate.verifySpkac(spkacValid), true);
-assert.equal(certificate.verifySpkac(spkacFail), false);
+assert.strictEqual(certificate.verifySpkac(spkacValid), true);
+assert.strictEqual(certificate.verifySpkac(spkacFail), false);
-assert.equal(
+assert.strictEqual(
stripLineEndings(certificate.exportPublicKey(spkacValid).toString('utf8')),
stripLineEndings(spkacPem.toString('utf8'))
);
-assert.equal(certificate.exportPublicKey(spkacFail), '');
+assert.strictEqual(certificate.exportPublicKey(spkacFail), '');
-assert.equal(
+assert.strictEqual(
certificate.exportChallenge(spkacValid).toString('utf8'),
'fb9ab814-6677-42a4-a60c-f905d1a6924d'
);
-assert.equal(certificate.exportChallenge(spkacFail), '');
+assert.strictEqual(certificate.exportChallenge(spkacFail), '');
function stripLineEndings(obj) {
return obj.replace(/\n/g, '');
diff --git a/test/parallel/test-crypto-cipher-decipher.js b/test/parallel/test-crypto-cipher-decipher.js
index be03eee86022..c63bcd6f9e26 100644
--- a/test/parallel/test-crypto-cipher-decipher.js
+++ b/test/parallel/test-crypto-cipher-decipher.js
@@ -27,7 +27,7 @@ function testCipher1(key) {
var txt = decipher.update(ciph, 'hex', 'utf8');
txt += decipher.final('utf8');
- assert.equal(txt, plaintext, 'encryption and decryption');
+ assert.strictEqual(txt, plaintext, 'encryption and decryption');
// streaming cipher interface
// NB: In real life, it's not guaranteed that you can get all of it
@@ -41,7 +41,7 @@ function testCipher1(key) {
dStream.end(ciph);
txt = dStream.read().toString('utf8');
- assert.equal(txt, plaintext, 'encryption and decryption with streams');
+ assert.strictEqual(txt, plaintext, 'encryption and decryption with streams');
}
@@ -63,7 +63,7 @@ function testCipher2(key) {
var txt = decipher.update(ciph, 'base64', 'utf8');
txt += decipher.final('utf8');
- assert.equal(txt, plaintext, 'encryption and decryption with Base64');
+ assert.strictEqual(txt, plaintext, 'encryption and decryption with Base64');
}
testCipher1('MySecretKey123');
diff --git a/test/parallel/test-crypto-cipheriv-decipheriv.js b/test/parallel/test-crypto-cipheriv-decipheriv.js
index a3a14738c43e..6f22dbe71aff 100644
--- a/test/parallel/test-crypto-cipheriv-decipheriv.js
+++ b/test/parallel/test-crypto-cipheriv-decipheriv.js
@@ -1,60 +1,60 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var crypto = require('crypto');
+const crypto = require('crypto');
function testCipher1(key, iv) {
// Test encyrption and decryption with explicit key and iv
- var plaintext =
- '32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' +
- 'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ' +
- 'jAfaFg**';
- var cipher = crypto.createCipheriv('des-ede3-cbc', key, iv);
- var ciph = cipher.update(plaintext, 'utf8', 'hex');
+ const plaintext =
+ '32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' +
+ 'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ' +
+ 'jAfaFg**';
+ const cipher = crypto.createCipheriv('des-ede3-cbc', key, iv);
+ let ciph = cipher.update(plaintext, 'utf8', 'hex');
ciph += cipher.final('hex');
- var decipher = crypto.createDecipheriv('des-ede3-cbc', key, iv);
- var txt = decipher.update(ciph, 'hex', 'utf8');
+ const decipher = crypto.createDecipheriv('des-ede3-cbc', key, iv);
+ let txt = decipher.update(ciph, 'hex', 'utf8');
txt += decipher.final('utf8');
- assert.equal(txt, plaintext, 'encryption and decryption with key and iv');
+ assert.strictEqual(txt, plaintext, 'encryption/decryption with key and iv');
// streaming cipher interface
// NB: In real life, it's not guaranteed that you can get all of it
// in a single read() like this. But in this case, we know it's
// quite small, so there's no harm.
- var cStream = crypto.createCipheriv('des-ede3-cbc', key, iv);
+ const cStream = crypto.createCipheriv('des-ede3-cbc', key, iv);
cStream.end(plaintext);
ciph = cStream.read();
- var dStream = crypto.createDecipheriv('des-ede3-cbc', key, iv);
+ const dStream = crypto.createDecipheriv('des-ede3-cbc', key, iv);
dStream.end(ciph);
txt = dStream.read().toString('utf8');
- assert.equal(txt, plaintext, 'streaming cipher iv');
+ assert.strictEqual(txt, plaintext, 'streaming cipher iv');
}
function testCipher2(key, iv) {
// Test encyrption and decryption with explicit key and iv
- var plaintext =
- '32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' +
- 'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ' +
- 'jAfaFg**';
- var cipher = crypto.createCipheriv('des-ede3-cbc', key, iv);
- var ciph = cipher.update(plaintext, 'utf8', 'buffer');
+ const plaintext =
+ '32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' +
+ 'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ' +
+ 'jAfaFg**';
+ const cipher = crypto.createCipheriv('des-ede3-cbc', key, iv);
+ let ciph = cipher.update(plaintext, 'utf8', 'buffer');
ciph = Buffer.concat([ciph, cipher.final('buffer')]);
- var decipher = crypto.createDecipheriv('des-ede3-cbc', key, iv);
- var txt = decipher.update(ciph, 'buffer', 'utf8');
+ const decipher = crypto.createDecipheriv('des-ede3-cbc', key, iv);
+ let txt = decipher.update(ciph, 'buffer', 'utf8');
txt += decipher.final('utf8');
- assert.equal(txt, plaintext, 'encryption and decryption with key and iv');
+ assert.strictEqual(txt, plaintext, 'encryption/decryption with key and iv');
}
testCipher1('0123456789abcd0123456789', '12345678');
diff --git a/test/parallel/test-crypto-domain.js b/test/parallel/test-crypto-domain.js
index 9bb6c0229648..ec9985719933 100644
--- a/test/parallel/test-crypto-domain.js
+++ b/test/parallel/test-crypto-domain.js
@@ -13,7 +13,7 @@ function test(fn) {
var ex = new Error('BAM');
var d = domain.create();
d.on('error', common.mustCall(function(err) {
- assert.equal(err, ex);
+ assert.strictEqual(err, ex);
}));
var cb = common.mustCall(function() {
throw ex;
diff --git a/test/parallel/test-crypto-ecb.js b/test/parallel/test-crypto-ecb.js
index dbdb486e9bcf..655246d0586c 100644
--- a/test/parallel/test-crypto-ecb.js
+++ b/test/parallel/test-crypto-ecb.js
@@ -1,6 +1,6 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
@@ -10,24 +10,25 @@ if (common.hasFipsCrypto) {
common.skip('BF-ECB is not FIPS 140-2 compatible');
return;
}
-var crypto = require('crypto');
+const crypto = require('crypto');
crypto.DEFAULT_ENCODING = 'buffer';
// Testing whether EVP_CipherInit_ex is functioning correctly.
// Reference: bug#1997
-(function() {
- var encrypt = crypto.createCipheriv('BF-ECB', 'SomeRandomBlahz0c5GZVnR', '');
- var hex = encrypt.update('Hello World!', 'ascii', 'hex');
+{
+ const encrypt =
+ crypto.createCipheriv('BF-ECB', 'SomeRandomBlahz0c5GZVnR', '');
+ let hex = encrypt.update('Hello World!', 'ascii', 'hex');
hex += encrypt.final('hex');
- assert.equal(hex.toUpperCase(), '6D385F424AAB0CFBF0BB86E07FFB7D71');
-}());
+ assert.strictEqual(hex.toUpperCase(), '6D385F424AAB0CFBF0BB86E07FFB7D71');
+}
-(function() {
- var decrypt = crypto.createDecipheriv('BF-ECB', 'SomeRandomBlahz0c5GZVnR',
- '');
- var msg = decrypt.update('6D385F424AAB0CFBF0BB86E07FFB7D71', 'hex', 'ascii');
+{
+ const decrypt =
+ crypto.createDecipheriv('BF-ECB', 'SomeRandomBlahz0c5GZVnR', '');
+ let msg = decrypt.update('6D385F424AAB0CFBF0BB86E07FFB7D71', 'hex', 'ascii');
msg += decrypt.final('ascii');
- assert.equal(msg, 'Hello World!');
-}());
+ assert.strictEqual(msg, 'Hello World!');
+}
diff --git a/test/parallel/test-crypto-hash-stream-pipe.js b/test/parallel/test-crypto-hash-stream-pipe.js
index 0ad9f18b0b45..33aa0f74566b 100644
--- a/test/parallel/test-crypto-hash-stream-pipe.js
+++ b/test/parallel/test-crypto-hash-stream-pipe.js
@@ -1,20 +1,21 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var crypto = require('crypto');
-var stream = require('stream');
-var s = new stream.PassThrough();
-var h = crypto.createHash('sha1');
-var expect = '15987e60950cf22655b9323bc1e281f9c4aff47e';
+const assert = require('assert');
+const crypto = require('crypto');
+
+const stream = require('stream');
+const s = new stream.PassThrough();
+const h = crypto.createHash('sha1');
+const expect = '15987e60950cf22655b9323bc1e281f9c4aff47e';
s.pipe(h).on('data', common.mustCall(function(c) {
- assert.equal(c, expect);
+ assert.strictEqual(c, expect);
})).setEncoding('hex');
s.end('aoeu');
diff --git a/test/parallel/test-crypto-hash.js b/test/parallel/test-crypto-hash.js
index 81ee1d60c539..9e2124434532 100644
--- a/test/parallel/test-crypto-hash.js
+++ b/test/parallel/test-crypto-hash.js
@@ -39,15 +39,15 @@ a8 = a8.read();
if (!common.hasFipsCrypto) {
var a0 = crypto.createHash('md5').update('Test123').digest('latin1');
- assert.equal(
+ assert.strictEqual(
a0,
'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca\u00bd\u008c',
'Test MD5 as latin1'
);
}
-assert.equal(a1, '8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'Test SHA1');
-assert.equal(a2, '2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=',
- 'Test SHA256 as base64');
+assert.strictEqual(a1, '8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'Test SHA1');
+assert.strictEqual(a2, '2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=',
+ 'Test SHA256 as base64');
assert.deepStrictEqual(
a3,
Buffer.from(
@@ -73,7 +73,7 @@ assert.notEqual(a8, undefined, 'empty string should generate data');
// Test multiple updates to same hash
var h1 = crypto.createHash('sha1').update('Test123').digest('hex');
var h2 = crypto.createHash('sha1').update('Test').update('123').digest('hex');
-assert.equal(h1, h2, 'multipled updates');
+assert.strictEqual(h1, h2, 'multipled updates');
// Test hashing for binary files
var fn = path.join(common.fixturesDir, 'sample.png');
@@ -83,19 +83,19 @@ fileStream.on('data', function(data) {
sha1Hash.update(data);
});
fileStream.on('close', function() {
- assert.equal(sha1Hash.digest('hex'),
- '22723e553129a336ad96e10f6aecdf0f45e4149e',
- 'Test SHA1 of sample.png');
+ assert.strictEqual(sha1Hash.digest('hex'),
+ '22723e553129a336ad96e10f6aecdf0f45e4149e',
+ 'Test SHA1 of sample.png');
});
// Issue #2227: unknown digest method should throw an error.
assert.throws(function() {
crypto.createHash('xyzzy');
-});
+}, /Digest method not supported/);
// Default UTF-8 encoding
var hutf8 = crypto.createHash('sha512').update('УТФ-8 text').digest('hex');
-assert.equal(
+assert.strictEqual(
hutf8,
'4b21bbd1a68e690a730ddcb5a8bc94ead9879ffe82580767ad7ec6fa8ba2dea6' +
'43a821af66afa9a45b6a78c712fecf0e56dc7f43aef4bcfc8eb5b4d8dca6ea5b');
diff --git a/test/parallel/test-crypto-padding.js b/test/parallel/test-crypto-padding.js
index 7822df64d9e2..70905a8a9bd1 100644
--- a/test/parallel/test-crypto-padding.js
+++ b/test/parallel/test-crypto-padding.js
@@ -1,12 +1,12 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var crypto = require('crypto');
+const crypto = require('crypto');
crypto.DEFAULT_ENCODING = 'buffer';
@@ -21,7 +21,7 @@ const EVEN_LENGTH_PLAIN = 'Hello node world!AbC09876dDeFgHi';
const KEY_PLAIN = 'S3c.r.e.t.K.e.Y!';
const IV_PLAIN = 'blahFizz2011Buzz';
-var CIPHER_NAME = 'aes-128-cbc';
+const CIPHER_NAME = 'aes-128-cbc';
/*
@@ -31,20 +31,20 @@ var CIPHER_NAME = 'aes-128-cbc';
// echo -n 'Hello node world!' | \
// openssl enc -aes-128-cbc -e -K 5333632e722e652e742e4b2e652e5921 \
// -iv 626c616846697a7a3230313142757a7a | xxd -p -c256
-var ODD_LENGTH_ENCRYPTED =
+const ODD_LENGTH_ENCRYPTED =
'7f57859550d4d2fdb9806da2a750461a9fe77253cd1cbd4b07beee4e070d561f';
// echo -n 'Hello node world!AbC09876dDeFgHi' | \
// openssl enc -aes-128-cbc -e -K 5333632e722e652e742e4b2e652e5921 \
// -iv 626c616846697a7a3230313142757a7a | xxd -p -c256
-var EVEN_LENGTH_ENCRYPTED =
+const EVEN_LENGTH_ENCRYPTED =
'7f57859550d4d2fdb9806da2a750461ab46e71b3d78ebe2d9684dfc87f7575b988' +
'6119866912cb8c7bcaf76c5ebc2378';
// echo -n 'Hello node world!AbC09876dDeFgHi' | \
// openssl enc -aes-128-cbc -e -K 5333632e722e652e742e4b2e652e5921 \
// -iv 626c616846697a7a3230313142757a7a -nopad | xxd -p -c256
-var EVEN_LENGTH_ENCRYPTED_NOPAD =
+const EVEN_LENGTH_ENCRYPTED_NOPAD =
'7f57859550d4d2fdb9806da2a750461ab46e' +
'71b3d78ebe2d9684dfc87f7575b9';
@@ -54,17 +54,17 @@ var EVEN_LENGTH_ENCRYPTED_NOPAD =
*/
function enc(plain, pad) {
- var encrypt = crypto.createCipheriv(CIPHER_NAME, KEY_PLAIN, IV_PLAIN);
+ const encrypt = crypto.createCipheriv(CIPHER_NAME, KEY_PLAIN, IV_PLAIN);
encrypt.setAutoPadding(pad);
- var hex = encrypt.update(plain, 'ascii', 'hex');
+ let hex = encrypt.update(plain, 'ascii', 'hex');
hex += encrypt.final('hex');
return hex;
}
function dec(encd, pad) {
- var decrypt = crypto.createDecipheriv(CIPHER_NAME, KEY_PLAIN, IV_PLAIN);
+ const decrypt = crypto.createDecipheriv(CIPHER_NAME, KEY_PLAIN, IV_PLAIN);
decrypt.setAutoPadding(pad);
- var plain = decrypt.update(encd, 'hex');
+ let plain = decrypt.update(encd, 'hex');
plain += decrypt.final('latin1');
return plain;
}
@@ -74,16 +74,18 @@ function dec(encd, pad) {
* Test encryption
*/
-assert.equal(enc(ODD_LENGTH_PLAIN, true), ODD_LENGTH_ENCRYPTED);
-assert.equal(enc(EVEN_LENGTH_PLAIN, true), EVEN_LENGTH_ENCRYPTED);
+assert.strictEqual(enc(ODD_LENGTH_PLAIN, true), ODD_LENGTH_ENCRYPTED);
+assert.strictEqual(enc(EVEN_LENGTH_PLAIN, true), EVEN_LENGTH_ENCRYPTED);
assert.throws(function() {
// input must have block length %
enc(ODD_LENGTH_PLAIN, false);
-});
+}, /data not multiple of block length/);
assert.doesNotThrow(function() {
- assert.equal(enc(EVEN_LENGTH_PLAIN, false), EVEN_LENGTH_ENCRYPTED_NOPAD);
+ assert.strictEqual(
+ enc(EVEN_LENGTH_PLAIN, false), EVEN_LENGTH_ENCRYPTED_NOPAD
+ );
});
@@ -91,21 +93,23 @@ assert.doesNotThrow(function() {
* Test decryption
*/
-assert.equal(dec(ODD_LENGTH_ENCRYPTED, true), ODD_LENGTH_PLAIN);
-assert.equal(dec(EVEN_LENGTH_ENCRYPTED, true), EVEN_LENGTH_PLAIN);
+assert.strictEqual(dec(ODD_LENGTH_ENCRYPTED, true), ODD_LENGTH_PLAIN);
+assert.strictEqual(dec(EVEN_LENGTH_ENCRYPTED, true), EVEN_LENGTH_PLAIN);
assert.doesNotThrow(function() {
// returns including original padding
- assert.equal(dec(ODD_LENGTH_ENCRYPTED, false).length, 32);
- assert.equal(dec(EVEN_LENGTH_ENCRYPTED, false).length, 48);
+ assert.strictEqual(dec(ODD_LENGTH_ENCRYPTED, false).length, 32);
+ assert.strictEqual(dec(EVEN_LENGTH_ENCRYPTED, false).length, 48);
});
assert.throws(function() {
// must have at least 1 byte of padding (PKCS):
- assert.equal(dec(EVEN_LENGTH_ENCRYPTED_NOPAD, true), EVEN_LENGTH_PLAIN);
-});
+ assert.strictEqual(dec(EVEN_LENGTH_ENCRYPTED_NOPAD, true), EVEN_LENGTH_PLAIN);
+}, /bad decrypt/);
assert.doesNotThrow(function() {
// no-pad encrypted string should return the same:
- assert.equal(dec(EVEN_LENGTH_ENCRYPTED_NOPAD, false), EVEN_LENGTH_PLAIN);
+ assert.strictEqual(
+ dec(EVEN_LENGTH_ENCRYPTED_NOPAD, false), EVEN_LENGTH_PLAIN
+ );
});
diff --git a/test/parallel/test-crypto-pbkdf2.js b/test/parallel/test-crypto-pbkdf2.js
index f9fa7aa48631..20ea5c729819 100644
--- a/test/parallel/test-crypto-pbkdf2.js
+++ b/test/parallel/test-crypto-pbkdf2.js
@@ -1,22 +1,23 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var crypto = require('crypto');
+const crypto = require('crypto');
//
// Test PBKDF2 with RFC 6070 test vectors (except #4)
//
function testPBKDF2(password, salt, iterations, keylen, expected) {
- var actual = crypto.pbkdf2Sync(password, salt, iterations, keylen, 'sha256');
- assert.equal(actual.toString('latin1'), expected);
+ const actual =
+ crypto.pbkdf2Sync(password, salt, iterations, keylen, 'sha256');
+ assert.strictEqual(actual.toString('latin1'), expected);
crypto.pbkdf2(password, salt, iterations, keylen, 'sha256', (err, actual) => {
- assert.equal(actual.toString('latin1'), expected);
+ assert.strictEqual(actual.toString('latin1'), expected);
});
}
@@ -44,46 +45,46 @@ testPBKDF2('pass\0word', 'sa\0lt', 4096, 16,
'\x89\xb6\x9d\x05\x16\xf8\x29\x89\x3c\x69\x62\x26\x65' +
'\x0a\x86\x87');
-var expected =
+const expected =
'64c486c55d30d4c5a079b8823b7d7cb37ff0556f537da8410233bcec330ed956';
-var key = crypto.pbkdf2Sync('password', 'salt', 32, 32, 'sha256');
-assert.equal(key.toString('hex'), expected);
+const key = crypto.pbkdf2Sync('password', 'salt', 32, 32, 'sha256');
+assert.strictEqual(key.toString('hex'), expected);
crypto.pbkdf2('password', 'salt', 32, 32, 'sha256', common.mustCall(ondone));
function ondone(err, key) {
if (err) throw err;
- assert.equal(key.toString('hex'), expected);
+ assert.strictEqual(key.toString('hex'), expected);
}
// Error path should not leak memory (check with valgrind).
assert.throws(function() {
crypto.pbkdf2('password', 'salt', 1, 20, null);
-});
+}, /^Error: No callback provided to pbkdf2$/);
// Should not work with Infinity key length
assert.throws(function() {
crypto.pbkdf2('password', 'salt', 1, Infinity, 'sha256', common.fail);
-}, /Bad key length/);
+}, /^TypeError: Bad key length$/);
// Should not work with negative Infinity key length
assert.throws(function() {
crypto.pbkdf2('password', 'salt', 1, -Infinity, 'sha256', common.fail);
-}, /Bad key length/);
+}, /^TypeError: Bad key length$/);
// Should not work with NaN key length
assert.throws(function() {
crypto.pbkdf2('password', 'salt', 1, NaN, 'sha256', common.fail);
-}, /Bad key length/);
+}, /^TypeError: Bad key length$/);
// Should not work with negative key length
assert.throws(function() {
crypto.pbkdf2('password', 'salt', 1, -1, 'sha256', common.fail);
-}, /Bad key length/);
+}, /^TypeError: Bad key length$/);
// Should not work with key length that does not fit into 32 signed bits
assert.throws(function() {
crypto.pbkdf2('password', 'salt', 1, 4073741824, 'sha256', common.fail);
-}, /Bad key length/);
+}, /^TypeError: Bad key length$/);
// Should not get FATAL ERROR with empty password and salt
// https://github.com/nodejs/node/issues/8571
diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js
index 77ecda30534a..6df41409f0e6 100644
--- a/test/parallel/test-crypto-sign-verify.js
+++ b/test/parallel/test-crypto-sign-verify.js
@@ -21,7 +21,7 @@ var keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
let s1stream = crypto.createSign('RSA-SHA1');
s1stream.end('Test123');
s1stream = s1stream.sign(keyPem, 'base64');
- assert.equal(s1, s1stream, 'Stream produces same output');
+ assert.strictEqual(s1, s1stream, 'Stream produces same output');
const verified = crypto.createVerify('RSA-SHA1')
.update('Test')
@@ -37,7 +37,7 @@ var keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
let s2stream = crypto.createSign('RSA-SHA256');
s2stream.end('Test123');
s2stream = s2stream.sign(keyPem, 'latin1');
- assert.equal(s2, s2stream, 'Stream produces same output');
+ assert.strictEqual(s2, s2stream, 'Stream produces same output');
let verified = crypto.createVerify('RSA-SHA256')
.update('Test')
diff --git a/test/parallel/test-crypto-stream.js b/test/parallel/test-crypto-stream.js
index 10271e27da41..1720cc7c4e0a 100644
--- a/test/parallel/test-crypto-stream.js
+++ b/test/parallel/test-crypto-stream.js
@@ -30,8 +30,10 @@ if (!common.hasFipsCrypto) {
// Create an md5 hash of "Hallo world"
var hasher1 = crypto.createHash('md5');
hasher1.pipe(new Stream2buffer(common.mustCall(function end(err, hash) {
- assert.equal(err, null);
- assert.equal(hash.toString('hex'), '06460dadb35d3d503047ce750ceb2d07');
+ assert.strictEqual(err, null);
+ assert.strictEqual(
+ hash.toString('hex'), '06460dadb35d3d503047ce750ceb2d07'
+ );
})));
hasher1.end('Hallo world');
diff --git a/test/parallel/test-crypto.js b/test/parallel/test-crypto.js
index b9634b650ac1..13401e4ac594 100644
--- a/test/parallel/test-crypto.js
+++ b/test/parallel/test-crypto.js
@@ -1,34 +1,33 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var util = require('util');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var crypto = require('crypto');
-crypto.DEFAULT_ENCODING = 'buffer';
+const assert = require('assert');
+const crypto = require('crypto');
+const fs = require('fs');
+const tls = require('tls');
-var fs = require('fs');
+crypto.DEFAULT_ENCODING = 'buffer';
// Test Certificates
-var caPem = fs.readFileSync(common.fixturesDir + '/test_ca.pem', 'ascii');
-var certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
-var certPfx = fs.readFileSync(common.fixturesDir + '/test_cert.pfx');
-var keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
-var tls = require('tls');
+const caPem = fs.readFileSync(common.fixturesDir + '/test_ca.pem', 'ascii');
+const certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
+const certPfx = fs.readFileSync(common.fixturesDir + '/test_cert.pfx');
+const keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
// 'this' safety
// https://github.com/joyent/node/issues/6690
assert.throws(function() {
- var options = {key: keyPem, cert: certPem, ca: caPem};
- var credentials = crypto.createCredentials(options);
- var context = credentials.context;
- var notcontext = { setOptions: context.setOptions, setKey: context.setKey };
- crypto.createCredentials({ secureOptions: 1 }, notcontext);
-}, TypeError);
+ const options = {key: keyPem, cert: certPem, ca: caPem};
+ const credentials = tls.createSecureContext(options);
+ const context = credentials.context;
+ const notcontext = { setOptions: context.setOptions, setKey: context.setKey };
+ tls.createSecureContext({ secureOptions: 1 }, notcontext);
+}, /^TypeError: Illegal invocation$/);
// PFX tests
assert.doesNotThrow(function() {
@@ -37,55 +36,55 @@ assert.doesNotThrow(function() {
assert.throws(function() {
tls.createSecureContext({pfx: certPfx});
-}, 'mac verify failure');
+}, /^Error: mac verify failure$/);
assert.throws(function() {
tls.createSecureContext({pfx: certPfx, passphrase: 'test'});
-}, 'mac verify failure');
+}, /^Error: mac verify failure$/);
assert.throws(function() {
tls.createSecureContext({pfx: 'sample', passphrase: 'test'});
-}, 'not enough data');
+}, /^Error: not enough data$/);
// update() should only take buffers / strings
assert.throws(function() {
crypto.createHash('sha1').update({foo: 'bar'});
-}, /buffer/);
+}, /^TypeError: Data must be a string or a buffer$/);
function assertSorted(list) {
// Array#sort() modifies the list in place so make a copy.
- var sorted = util._extend([], list).sort();
+ const sorted = list.slice().sort();
assert.deepStrictEqual(list, sorted);
}
// Assume that we have at least AES-128-CBC.
-assert.notEqual(0, crypto.getCiphers().length);
-assert.notEqual(-1, crypto.getCiphers().indexOf('aes-128-cbc'));
-assert.equal(-1, crypto.getCiphers().indexOf('AES-128-CBC'));
+assert.notStrictEqual(0, crypto.getCiphers().length);
+assert(crypto.getCiphers().includes('aes-128-cbc'));
+assert(!crypto.getCiphers().includes('AES-128-CBC'));
assertSorted(crypto.getCiphers());
// Assume that we have at least AES256-SHA.
-assert.notEqual(0, tls.getCiphers().length);
-assert.notEqual(-1, tls.getCiphers().indexOf('aes256-sha'));
-assert.equal(-1, tls.getCiphers().indexOf('AES256-SHA'));
+assert.notStrictEqual(0, tls.getCiphers().length);
+assert(tls.getCiphers().includes('aes256-sha'));
+assert(!tls.getCiphers().includes('AES256-SHA'));
assertSorted(tls.getCiphers());
// Assert that we have sha and sha1 but not SHA and SHA1.
-assert.notEqual(0, crypto.getHashes().length);
-assert.notEqual(-1, crypto.getHashes().indexOf('sha1'));
-assert.notEqual(-1, crypto.getHashes().indexOf('sha'));
-assert.equal(-1, crypto.getHashes().indexOf('SHA1'));
-assert.equal(-1, crypto.getHashes().indexOf('SHA'));
-assert.notEqual(-1, crypto.getHashes().indexOf('RSA-SHA1'));
-assert.equal(-1, crypto.getHashes().indexOf('rsa-sha1'));
+assert.notStrictEqual(0, crypto.getHashes().length);
+assert(crypto.getHashes().includes('sha1'));
+assert(crypto.getHashes().includes('sha'));
+assert(!crypto.getHashes().includes('SHA1'));
+assert(!crypto.getHashes().includes('SHA'));
+assert(crypto.getHashes().includes('RSA-SHA1'));
+assert(!crypto.getHashes().includes('rsa-sha1'));
assertSorted(crypto.getHashes());
// Assume that we have at least secp384r1.
-assert.notEqual(0, crypto.getCurves().length);
-assert.notEqual(-1, crypto.getCurves().indexOf('secp384r1'));
-assert.equal(-1, crypto.getCurves().indexOf('SECP384R1'));
+assert.notStrictEqual(0, crypto.getCurves().length);
+assert(crypto.getCurves().includes('secp384r1'));
+assert(!crypto.getCurves().includes('SECP384R1'));
assertSorted(crypto.getCurves());
// Regression tests for #5725: hex input that's not a power of two should
@@ -100,18 +99,18 @@ assert.throws(function() {
assert.throws(function() {
crypto.createHash('sha1').update('0', 'hex');
-}, /Bad input string/);
+}, /^TypeError: Bad input string$/);
assert.throws(function() {
crypto.createSign('RSA-SHA1').update('0', 'hex');
-}, /Bad input string/);
+}, /^TypeError: Bad input string$/);
assert.throws(function() {
crypto.createVerify('RSA-SHA1').update('0', 'hex');
-}, /Bad input string/);
+}, /^TypeError: Bad input string$/);
assert.throws(function() {
- var priv = [
+ const priv = [
'-----BEGIN RSA PRIVATE KEY-----',
'MIGrAgEAAiEA+3z+1QNF2/unumadiwEr+C5vfhezsb3hp4jAnCNRpPcCAwEAAQIgQNriSQK4',
'EFwczDhMZp2dvbcz7OUUyt36z3S4usFPHSECEQD/41K7SujrstBfoCPzwC1xAhEA+5kt4BJy',
@@ -121,7 +120,7 @@ assert.throws(function() {
''
].join('\n');
crypto.createSign('RSA-SHA256').update('test').sign(priv);
-}, /digest too big for rsa key/);
+}, /digest too big for rsa key$/);
assert.throws(function() {
// The correct header inside `test_bad_rsa_privkey.pem` should have been
@@ -133,7 +132,7 @@ assert.throws(function() {
// $ openssl pkcs8 -topk8 -inform PEM -outform PEM -in mykey.pem \
// -out private_key.pem -nocrypt;
// Then open private_key.pem and change its header and footer.
- var sha1_privateKey = fs.readFileSync(common.fixturesDir +
+ const sha1_privateKey = fs.readFileSync(common.fixturesDir +
'/test_bad_rsa_privkey.pem', 'ascii');
// this would inject errors onto OpenSSL's error stack
crypto.createSign('sha1').sign(sha1_privateKey);
@@ -144,4 +143,4 @@ console.log(crypto.randomBytes(16));
assert.throws(function() {
tls.createSecureContext({ crl: 'not a CRL' });
-}, '/Failed to parse CRL/');
+}, /^Error: Failed to parse CRL$/);
diff --git a/test/parallel/test-cwd-enoent.js b/test/parallel/test-cwd-enoent.js
index f5c04fe068e9..c671ef2be461 100644
--- a/test/parallel/test-cwd-enoent.js
+++ b/test/parallel/test-cwd-enoent.js
@@ -21,6 +21,6 @@ proc.stdout.pipe(process.stdout);
proc.stderr.pipe(process.stderr);
proc.once('exit', common.mustCall(function(exitCode, signalCode) {
- assert.equal(exitCode, 0);
- assert.equal(signalCode, null);
+ assert.strictEqual(exitCode, 0);
+ assert.strictEqual(signalCode, null);
}));
diff --git a/test/parallel/test-debug-args.js b/test/parallel/test-debug-args.js
index e5f9f3716119..a4ed4f9f1ee7 100644
--- a/test/parallel/test-debug-args.js
+++ b/test/parallel/test-debug-args.js
@@ -2,6 +2,6 @@
// Flags: --debug-code
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-assert.notEqual(process.execArgv.indexOf('--debug-code'), -1);
+assert(process.execArgv.includes('--debug-code'));
diff --git a/test/parallel/test-debug-prompt.js b/test/parallel/test-debug-prompt.js
new file mode 100644
index 000000000000..fdc3b4c27f4d
--- /dev/null
+++ b/test/parallel/test-debug-prompt.js
@@ -0,0 +1,13 @@
+'use strict';
+
+const assert = require('assert');
+const common = require('../common');
+const spawn = require('child_process').spawn;
+
+const proc = spawn(process.execPath, ['debug', 'foo']);
+proc.stdout.setEncoding('utf8');
+
+proc.stdout.once('data', common.mustCall((data) => {
+ assert.strictEqual(data, 'debug> ');
+ proc.kill();
+}));
diff --git a/test/parallel/test-debugger-util-regression.js b/test/parallel/test-debugger-util-regression.js
index 6378ea3e9b17..07e52545814b 100644
--- a/test/parallel/test-debugger-util-regression.js
+++ b/test/parallel/test-debugger-util-regression.js
@@ -46,8 +46,8 @@ proc.stdout.on('data', (data) => {
proc.stderr.on('data', (data) => stderr += data);
process.on('exit', (code) => {
- assert.equal(code, 0, 'the program should exit cleanly');
- assert.equal(stdout.includes('{ a: \'b\' }'), true,
- 'the debugger should print the result of util.inspect');
- assert.equal(stderr, '', 'stderr should be empty');
+ assert.strictEqual(code, 0, 'the program should exit cleanly');
+ assert.strictEqual(stdout.includes('{ a: \'b\' }'), true,
+ 'the debugger should print the result of util.inspect');
+ assert.strictEqual(stderr, '', 'stderr should be empty');
});
diff --git a/test/parallel/test-dgram-empty-packet.js b/test/parallel/test-dgram-empty-packet.js
deleted file mode 100644
index 34bce4e07aed..000000000000
--- a/test/parallel/test-dgram-empty-packet.js
+++ /dev/null
@@ -1,40 +0,0 @@
-'use strict';
-const common = require('../common');
-const dgram = require('dgram');
-
-let callbacks = 0;
-let timer;
-
-if (common.isOSX) {
- common.skip('because of 17894467 Apple bug');
- return;
-}
-
-const client = dgram.createSocket('udp4');
-
-client.bind(0, function() {
-
- function callback() {
- callbacks++;
- if (callbacks === 2) {
- clearTimeout(timer);
- client.close();
- } else if (callbacks > 2) {
- throw new Error('the callbacks should be called only two times');
- }
- }
-
- client.on('message', function(buffer, bytes) {
- callback();
- });
-
- const port = this.address().port;
- client.send(
- Buffer.allocUnsafe(1), 0, 0, port, '127.0.0.1', (err, len) => {
- callback();
- });
-
- timer = setTimeout(function() {
- throw new Error('Timeout');
- }, 200);
-});
diff --git a/test/parallel/test-dgram-error-message-address.js b/test/parallel/test-dgram-error-message-address.js
index d27b0043321a..3a87e8cabf3c 100644
--- a/test/parallel/test-dgram-error-message-address.js
+++ b/test/parallel/test-dgram-error-message-address.js
@@ -1,35 +1,35 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var dgram = require('dgram');
+const common = require('../common');
+const assert = require('assert');
+const dgram = require('dgram');
// IPv4 Test
-var socket_ipv4 = dgram.createSocket('udp4');
+const socket_ipv4 = dgram.createSocket('udp4');
socket_ipv4.on('listening', common.fail);
socket_ipv4.on('error', common.mustCall(function(e) {
assert.strictEqual(e.port, undefined);
- assert.equal(e.message, 'bind EADDRNOTAVAIL 1.1.1.1');
- assert.equal(e.address, '1.1.1.1');
- assert.equal(e.code, 'EADDRNOTAVAIL');
+ assert.strictEqual(e.message, 'bind EADDRNOTAVAIL 1.1.1.1');
+ assert.strictEqual(e.address, '1.1.1.1');
+ assert.strictEqual(e.code, 'EADDRNOTAVAIL');
socket_ipv4.close();
}));
socket_ipv4.bind(0, '1.1.1.1');
// IPv6 Test
-var socket_ipv6 = dgram.createSocket('udp6');
+const socket_ipv6 = dgram.createSocket('udp6');
socket_ipv6.on('listening', common.fail);
socket_ipv6.on('error', common.mustCall(function(e) {
// EAFNOSUPPORT or EPROTONOSUPPORT means IPv6 is disabled on this system.
- var allowed = ['EADDRNOTAVAIL', 'EAFNOSUPPORT', 'EPROTONOSUPPORT'];
- assert.notEqual(allowed.indexOf(e.code), -1);
+ const allowed = ['EADDRNOTAVAIL', 'EAFNOSUPPORT', 'EPROTONOSUPPORT'];
+ assert.notStrictEqual(allowed.indexOf(e.code), -1);
assert.strictEqual(e.port, undefined);
- assert.equal(e.message, 'bind ' + e.code + ' 111::1');
- assert.equal(e.address, '111::1');
+ assert.strictEqual(e.message, 'bind ' + e.code + ' 111::1');
+ assert.strictEqual(e.address, '111::1');
socket_ipv6.close();
}));
diff --git a/test/parallel/test-dgram-exclusive-implicit-bind.js b/test/parallel/test-dgram-exclusive-implicit-bind.js
index 9a3cb91b3ac1..c8799cf058b9 100644
--- a/test/parallel/test-dgram-exclusive-implicit-bind.js
+++ b/test/parallel/test-dgram-exclusive-implicit-bind.js
@@ -45,7 +45,7 @@ if (cluster.isMaster) {
var ports = {};
process.on('exit', function() {
- assert.equal(pass, true);
+ assert.strictEqual(pass, true);
});
var target = dgram.createSocket('udp4');
@@ -55,12 +55,12 @@ if (cluster.isMaster) {
ports[rinfo.port] = true;
if (common.isWindows && messages === 2) {
- assert.equal(Object.keys(ports).length, 2);
+ assert.strictEqual(Object.keys(ports).length, 2);
done();
}
if (!common.isWindows && messages === 4) {
- assert.equal(Object.keys(ports).length, 3);
+ assert.strictEqual(Object.keys(ports).length, 3);
done();
}
diff --git a/test/parallel/test-dgram-msgsize.js b/test/parallel/test-dgram-msgsize.js
index ec4021b99fd8..6cc415e83c00 100644
--- a/test/parallel/test-dgram-msgsize.js
+++ b/test/parallel/test-dgram-msgsize.js
@@ -1,18 +1,18 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var dgram = require('dgram');
+const common = require('../common');
+const assert = require('assert');
+const dgram = require('dgram');
// Send a too big datagram. The destination doesn't matter because it's
// not supposed to get sent out anyway.
-var buf = Buffer.allocUnsafe(256 * 1024);
-var sock = dgram.createSocket('udp4');
+const buf = Buffer.allocUnsafe(256 * 1024);
+const sock = dgram.createSocket('udp4');
sock.send(buf, 0, buf.length, 12345, '127.0.0.1', common.mustCall(cb));
function cb(err) {
assert(err instanceof Error);
- assert.equal(err.code, 'EMSGSIZE');
- assert.equal(err.address, '127.0.0.1');
- assert.equal(err.port, 12345);
- assert.equal(err.message, 'send EMSGSIZE 127.0.0.1:12345');
+ assert.strictEqual(err.code, 'EMSGSIZE');
+ assert.strictEqual(err.address, '127.0.0.1');
+ assert.strictEqual(err.port, 12345);
+ assert.strictEqual(err.message, 'send EMSGSIZE 127.0.0.1:12345');
sock.close();
}
diff --git a/test/parallel/test-dgram-send-callback-recursive.js b/test/parallel/test-dgram-send-callback-recursive.js
index c54b05c3f86b..bca888a46785 100644
--- a/test/parallel/test-dgram-send-callback-recursive.js
+++ b/test/parallel/test-dgram-send-callback-recursive.js
@@ -37,7 +37,7 @@ client.on('message', function(buf, info) {
});
client.on('close', common.mustCall(function() {
- assert.equal(received, limit);
+ assert.strictEqual(received, limit);
}));
client.bind(0);
diff --git a/test/parallel/test-dgram-send-empty-array.js b/test/parallel/test-dgram-send-empty-array.js
index f9de345f1122..442803e6db86 100644
--- a/test/parallel/test-dgram-send-empty-array.js
+++ b/test/parallel/test-dgram-send-empty-array.js
@@ -1,24 +1,30 @@
'use strict';
const common = require('../common');
-const assert = require('assert');
-const dgram = require('dgram');
if (common.isOSX) {
common.skip('because of 17894467 Apple bug');
return;
}
+const assert = require('assert');
+const dgram = require('dgram');
+
const client = dgram.createSocket('udp4');
+var interval;
+
client.on('message', common.mustCall(function onMessage(buf, info) {
const expected = Buffer.alloc(0);
assert.ok(buf.equals(expected), 'message was received correctly');
+ clearInterval(interval);
client.close();
}));
-client.on('listening', function() {
- client.send([], this.address().port, common.localhostIPv4);
-});
+client.on('listening', common.mustCall(function() {
+ interval = setInterval(function() {
+ client.send([], client.address().port, common.localhostIPv4);
+ }, 10);
+}));
client.bind(0);
diff --git a/test/parallel/test-dgram-send-empty-buffer.js b/test/parallel/test-dgram-send-empty-buffer.js
index ac541a9c2439..70e7e46e0a32 100644
--- a/test/parallel/test-dgram-send-empty-buffer.js
+++ b/test/parallel/test-dgram-send-empty-buffer.js
@@ -1,26 +1,27 @@
'use strict';
const common = require('../common');
-const dgram = require('dgram');
+const assert = require('assert');
if (common.isOSX) {
common.skip('because of 17894467 Apple bug');
return;
}
+const dgram = require('dgram');
+
const client = dgram.createSocket('udp4');
-client.bind(0, function() {
+client.bind(0, common.mustCall(function() {
const port = this.address().port;
- client.on('message', common.mustCall(function onMessage(buffer, bytes) {
- clearTimeout(timer);
+ client.on('message', common.mustCall(function onMessage(buffer) {
+ assert.strictEqual(buffer.length, 0);
+ clearInterval(interval);
client.close();
}));
const buf = Buffer.alloc(0);
- client.send(buf, 0, 0, port, '127.0.0.1', function(err, len) { });
-
- const timer = setTimeout(function() {
- throw new Error('Timeout');
- }, common.platformTimeout(200));
-});
+ var interval = setInterval(function() {
+ client.send(buf, 0, 0, port, '127.0.0.1', common.mustCall(function() {}));
+ }, 10);
+}));
diff --git a/test/parallel/test-dgram-send-empty-packet.js b/test/parallel/test-dgram-send-empty-packet.js
new file mode 100644
index 000000000000..131e808aec0b
--- /dev/null
+++ b/test/parallel/test-dgram-send-empty-packet.js
@@ -0,0 +1,34 @@
+'use strict';
+const common = require('../common');
+const assert = require('assert');
+
+if (common.isOSX) {
+ common.skip('because of 17894467 Apple bug');
+ return;
+}
+
+const dgram = require('dgram');
+
+const client = dgram.createSocket('udp4');
+
+client.bind(0, common.mustCall(function() {
+
+ client.on('message', common.mustCall(callback));
+
+ const port = this.address().port;
+ const buf = Buffer.alloc(1);
+
+ const interval = setInterval(function() {
+ client.send(buf, 0, 0, port, '127.0.0.1', common.mustCall(callback));
+ }, 10);
+
+ function callback(firstArg) {
+ // If client.send() callback, firstArg should be null.
+ // If client.on('message') listener, firstArg should be a 0-length buffer.
+ if (firstArg instanceof Buffer) {
+ assert.strictEqual(firstArg.length, 0);
+ clearInterval(interval);
+ client.close();
+ }
+ }
+}));
diff --git a/test/parallel/test-dgram-send-multi-buffer-copy.js b/test/parallel/test-dgram-send-multi-buffer-copy.js
index 0b7f003335b5..2ee87494b028 100644
--- a/test/parallel/test-dgram-send-multi-buffer-copy.js
+++ b/test/parallel/test-dgram-send-multi-buffer-copy.js
@@ -7,7 +7,7 @@ const dgram = require('dgram');
const client = dgram.createSocket('udp4');
const onMessage = common.mustCall(function(err, bytes) {
- assert.equal(bytes, buf1.length + buf2.length);
+ assert.strictEqual(bytes, buf1.length + buf2.length);
});
const buf1 = Buffer.alloc(256, 'x');
diff --git a/test/parallel/test-dns.js b/test/parallel/test-dns.js
index 5fcc045b2e3f..9ee2e9f974f6 100644
--- a/test/parallel/test-dns.js
+++ b/test/parallel/test-dns.js
@@ -5,7 +5,7 @@ const assert = require('assert');
const dns = require('dns');
const existing = dns.getServers();
-assert(existing.length);
+assert(existing.length > 0);
// Verify that setServers() handles arrays with holes and other oddities
assert.doesNotThrow(() => {
@@ -42,7 +42,8 @@ const goog = [
];
assert.doesNotThrow(() => dns.setServers(goog));
assert.deepStrictEqual(dns.getServers(), goog);
-assert.throws(() => dns.setServers(['foobar']));
+assert.throws(() => dns.setServers(['foobar']),
+ /^Error: IP address is not properly formatted: foobar$/);
assert.deepStrictEqual(dns.getServers(), goog);
const goog6 = [
@@ -77,20 +78,18 @@ assert.throws(() => {
}, 'Unexpected error');
// dns.lookup should accept falsey and string values
-assert.throws(() => dns.lookup({}, noop),
- 'invalid arguments: hostname must be a string or falsey');
+const errorReg =
+ /^TypeError: Invalid arguments: hostname must be a string or falsey$/;
-assert.throws(() => dns.lookup([], noop),
- 'invalid arguments: hostname must be a string or falsey');
+assert.throws(() => dns.lookup({}, noop), errorReg);
-assert.throws(() => dns.lookup(true, noop),
- 'invalid arguments: hostname must be a string or falsey');
+assert.throws(() => dns.lookup([], noop), errorReg);
-assert.throws(() => dns.lookup(1, noop),
- 'invalid arguments: hostname must be a string or falsey');
+assert.throws(() => dns.lookup(true, noop), errorReg);
-assert.throws(() => dns.lookup(noop, noop),
- 'invalid arguments: hostname must be a string or falsey');
+assert.throws(() => dns.lookup(1, noop), errorReg);
+
+assert.throws(() => dns.lookup(noop, noop), errorReg);
assert.doesNotThrow(() => dns.lookup('', noop));
@@ -114,13 +113,13 @@ assert.doesNotThrow(() => dns.lookup(NaN, noop));
assert.throws(() => {
dns.lookup('www.google.com', { hints: (dns.V4MAPPED | dns.ADDRCONFIG) + 1 },
noop);
-});
+}, /^TypeError: Invalid argument: hints must use valid flags$/);
assert.throws(() => dns.lookup('www.google.com'),
- 'invalid arguments: callback must be passed');
+ /^TypeError: Invalid arguments: callback must be passed$/);
assert.throws(() => dns.lookup('www.google.com', 4),
- 'invalid arguments: callback must be passed');
+ /^TypeError: Invalid arguments: callback must be passed$/);
assert.doesNotThrow(() => dns.lookup('www.google.com', 6, noop));
@@ -143,26 +142,29 @@ assert.doesNotThrow(() => {
}, noop);
});
-assert.throws(() => dns.lookupService('0.0.0.0'), /Invalid arguments/);
+assert.throws(() => dns.lookupService('0.0.0.0'),
+ /^Error: Invalid arguments$/);
assert.throws(() => dns.lookupService('fasdfdsaf', 0, noop),
- /"host" argument needs to be a valid IP address/);
+ /^TypeError: "host" argument needs to be a valid IP address$/);
assert.doesNotThrow(() => dns.lookupService('0.0.0.0', '0', noop));
assert.doesNotThrow(() => dns.lookupService('0.0.0.0', 0, noop));
assert.throws(() => dns.lookupService('0.0.0.0', null, noop),
- /"port" should be >= 0 and < 65536, got "null"/);
+ /^TypeError: "port" should be >= 0 and < 65536, got "null"$/);
-assert.throws(() => dns.lookupService('0.0.0.0', undefined, noop),
- /"port" should be >= 0 and < 65536, got "undefined"/);
+assert.throws(
+ () => dns.lookupService('0.0.0.0', undefined, noop),
+ /^TypeError: "port" should be >= 0 and < 65536, got "undefined"$/
+);
assert.throws(() => dns.lookupService('0.0.0.0', 65538, noop),
- /"port" should be >= 0 and < 65536, got "65538"/);
+ /^TypeError: "port" should be >= 0 and < 65536, got "65538"$/);
assert.throws(() => dns.lookupService('0.0.0.0', 'test', noop),
- /"port" should be >= 0 and < 65536, got "test"/);
+ /^TypeError: "port" should be >= 0 and < 65536, got "test"$/);
assert.throws(() => dns.lookupService('0.0.0.0', 80, null),
/^TypeError: "callback" argument must be a function$/);
diff --git a/test/parallel/test-domain-abort-on-uncaught.js b/test/parallel/test-domain-abort-on-uncaught.js
index 2a5eb804bc34..d61debc06067 100644
--- a/test/parallel/test-domain-abort-on-uncaught.js
+++ b/test/parallel/test-domain-abort-on-uncaught.js
@@ -227,7 +227,7 @@ if (process.argv[2] === 'child') {
tests[testIndex]();
process.on('exit', function onExit() {
- assert.equal(errorHandlerCalled, true);
+ assert.strictEqual(errorHandlerCalled, true);
});
} else {
@@ -248,7 +248,7 @@ if (process.argv[2] === 'child') {
var child = child_process.exec(testCmd);
child.on('exit', function onExit(code, signal) {
- assert.equal(code, 0, 'Test at index ' + testIndex +
+ assert.strictEqual(code, 0, 'Test at index ' + testIndex +
' should have exited with exit code 0 but instead exited with code ' +
code + ' and signal ' + signal);
});
diff --git a/test/parallel/test-domain-http-server.js b/test/parallel/test-domain-http-server.js
index e6e4b294cfef..26264e8ec987 100644
--- a/test/parallel/test-domain-http-server.js
+++ b/test/parallel/test-domain-http-server.js
@@ -88,7 +88,7 @@ function next() {
}
process.on('exit', function() {
- assert.equal(serverCaught, 2);
- assert.equal(clientCaught, 2);
+ assert.strictEqual(serverCaught, 2);
+ assert.strictEqual(clientCaught, 2);
console.log('ok');
});
diff --git a/test/parallel/test-domain-multi.js b/test/parallel/test-domain-multi.js
index 1b0af1dd3f43..cf85dbca4601 100644
--- a/test/parallel/test-domain-multi.js
+++ b/test/parallel/test-domain-multi.js
@@ -70,8 +70,8 @@ var server = http.createServer(function(req, res) {
});
process.on('exit', function() {
- assert.equal(caughtA, false);
- assert.equal(caughtB, true);
- assert.equal(caughtC, true);
+ assert.strictEqual(caughtA, false);
+ assert.strictEqual(caughtB, true);
+ assert.strictEqual(caughtC, true);
console.log('ok - Errors went where they were supposed to go');
});
diff --git a/test/parallel/test-domain-timers.js b/test/parallel/test-domain-timers.js
index faa57df12770..d42afa747179 100644
--- a/test/parallel/test-domain-timers.js
+++ b/test/parallel/test-domain-timers.js
@@ -8,21 +8,22 @@ var timeout;
var timeoutd = domain.create();
timeoutd.on('error', common.mustCall(function(e) {
- assert.equal(e.message, 'Timeout UNREFd', 'Domain should catch timer error');
+ assert.strictEqual(e.message, 'Timeout UNREFd',
+ 'Domain should catch timer error');
clearTimeout(timeout);
}));
timeoutd.run(function() {
setTimeout(function() {
throw new Error('Timeout UNREFd');
- }).unref();
+ }, 0).unref();
});
var immediated = domain.create();
immediated.on('error', common.mustCall(function(e) {
- assert.equal(e.message, 'Immediate Error',
- 'Domain should catch immediate error');
+ assert.strictEqual(e.message, 'Immediate Error',
+ 'Domain should catch immediate error');
}));
immediated.run(function() {
diff --git a/test/parallel/test-domain.js b/test/parallel/test-domain.js
index 19cd964a2892..69521108f6e4 100644
--- a/test/parallel/test-domain.js
+++ b/test/parallel/test-domain.js
@@ -31,67 +31,67 @@ d.on('error', function(er) {
switch (er_message) {
case 'emitted':
- assert.equal(er.domain, d);
- assert.equal(er.domainEmitter, e);
- assert.equal(er.domainThrown, false);
+ assert.strictEqual(er.domain, d);
+ assert.strictEqual(er.domainEmitter, e);
+ assert.strictEqual(er.domainThrown, false);
break;
case 'bound':
assert.ok(!er.domainEmitter);
- assert.equal(er.domain, d);
- assert.equal(er.domainBound, fn);
- assert.equal(er.domainThrown, false);
+ assert.strictEqual(er.domain, d);
+ assert.strictEqual(er.domainBound, fn);
+ assert.strictEqual(er.domainThrown, false);
break;
case 'thrown':
assert.ok(!er.domainEmitter);
- assert.equal(er.domain, d);
- assert.equal(er.domainThrown, true);
+ assert.strictEqual(er.domain, d);
+ assert.strictEqual(er.domainThrown, true);
break;
case "ENOENT: no such file or directory, open 'this file does not exist'":
- assert.equal(er.domain, d);
- assert.equal(er.domainThrown, false);
- assert.equal(typeof er.domainBound, 'function');
+ assert.strictEqual(er.domain, d);
+ assert.strictEqual(er.domainThrown, false);
+ assert.strictEqual(typeof er.domainBound, 'function');
assert.ok(!er.domainEmitter);
- assert.equal(er.code, 'ENOENT');
- assert.equal(er_path, 'this file does not exist');
- assert.equal(typeof er.errno, 'number');
+ assert.strictEqual(er.code, 'ENOENT');
+ assert.strictEqual(er_path, 'this file does not exist');
+ assert.strictEqual(typeof er.errno, 'number');
break;
case
"ENOENT: no such file or directory, open 'stream for nonexistent file'":
- assert.equal(typeof er.errno, 'number');
- assert.equal(er.code, 'ENOENT');
- assert.equal(er_path, 'stream for nonexistent file');
- assert.equal(er.domain, d);
- assert.equal(er.domainEmitter, fst);
+ assert.strictEqual(typeof er.errno, 'number');
+ assert.strictEqual(er.code, 'ENOENT');
+ assert.strictEqual(er_path, 'stream for nonexistent file');
+ assert.strictEqual(er.domain, d);
+ assert.strictEqual(er.domainEmitter, fst);
assert.ok(!er.domainBound);
- assert.equal(er.domainThrown, false);
+ assert.strictEqual(er.domainThrown, false);
break;
case 'implicit':
- assert.equal(er.domainEmitter, implicit);
- assert.equal(er.domain, d);
- assert.equal(er.domainThrown, false);
+ assert.strictEqual(er.domainEmitter, implicit);
+ assert.strictEqual(er.domain, d);
+ assert.strictEqual(er.domainThrown, false);
assert.ok(!er.domainBound);
break;
case 'implicit timer':
- assert.equal(er.domain, d);
- assert.equal(er.domainThrown, true);
+ assert.strictEqual(er.domain, d);
+ assert.strictEqual(er.domainThrown, true);
assert.ok(!er.domainEmitter);
assert.ok(!er.domainBound);
break;
case 'Cannot read property \'isDirectory\' of undefined':
- assert.equal(er.domain, d);
+ assert.strictEqual(er.domain, d);
assert.ok(!er.domainEmitter);
assert.ok(!er.domainBound);
break;
case 'nextTick execution loop':
- assert.equal(er.domain, d);
+ assert.strictEqual(er.domain, d);
assert.ok(!er.domainEmitter);
assert.ok(!er.domainBound);
break;
@@ -107,7 +107,8 @@ d.on('error', function(er) {
process.on('exit', function() {
console.error('exit', caught, expectCaught);
- assert.equal(caught, expectCaught, 'caught the expected number of errors');
+ assert.strictEqual(caught, expectCaught,
+ 'caught the expected number of errors');
console.log('ok');
});
@@ -172,7 +173,7 @@ expectCaught++;
// intercepted should never pass first argument to callback
function fn2(data) {
- assert.equal(data, 'data', 'should not be null err argument');
+ assert.strictEqual(data, 'data', 'should not be null err argument');
}
bound = d.intercept(fn2);
@@ -181,8 +182,8 @@ bound(null, 'data');
// intercepted should never pass first argument to callback
// even if arguments length is more than 2.
function fn3(data, data2) {
- assert.equal(data, 'data', 'should not be null err argument');
- assert.equal(data2, 'data2', 'should not be data argument');
+ assert.strictEqual(data, 'data', 'should not be null err argument');
+ assert.strictEqual(data2, 'data2', 'should not be data argument');
}
bound = d.intercept(fn3);
@@ -225,14 +226,14 @@ expectCaught++;
var result = d.run(function() {
return 'return value';
});
-assert.equal(result, 'return value');
+assert.strictEqual(result, 'return value');
// check if the executed function take in count the applied parameters
result = d.run(function(a, b) {
return a + ' ' + b;
}, 'return', 'value');
-assert.equal(result, 'return value');
+assert.strictEqual(result, 'return value');
var fst = fs.createReadStream('stream for nonexistent file');
diff --git a/test/parallel/test-event-emitter-listeners.js b/test/parallel/test-event-emitter-listeners.js
index cfb2dafb121e..8aedd8fc3766 100644
--- a/test/parallel/test-event-emitter-listeners.js
+++ b/test/parallel/test-event-emitter-listeners.js
@@ -3,9 +3,12 @@
require('../common');
const assert = require('assert');
const events = require('events');
+const util = require('util');
function listener() {}
function listener2() {}
+class TestStream { constructor() { } }
+util.inherits(TestStream, events.EventEmitter);
{
const ee = new events.EventEmitter();
@@ -49,3 +52,14 @@ function listener2() {}
ee.once('foo', listener2);
assert.deepStrictEqual(ee.listeners('foo'), [listener, listener2]);
}
+
+{
+ const ee = new events.EventEmitter();
+ ee._events = undefined;
+ assert.deepStrictEqual(ee.listeners('foo'), []);
+}
+
+{
+ const s = new TestStream();
+ assert.deepStrictEqual(s.listeners('foo'), []);
+}
diff --git a/test/parallel/test-exception-handler.js b/test/parallel/test-exception-handler.js
index d163fb18916f..e0e1b0086d9a 100644
--- a/test/parallel/test-exception-handler.js
+++ b/test/parallel/test-exception-handler.js
@@ -6,12 +6,12 @@ var MESSAGE = 'catch me if you can';
process.on('uncaughtException', common.mustCall(function(e) {
console.log('uncaught exception! 1');
- assert.equal(MESSAGE, e.message);
+ assert.strictEqual(MESSAGE, e.message);
}));
process.on('uncaughtException', common.mustCall(function(e) {
console.log('uncaught exception! 2');
- assert.equal(MESSAGE, e.message);
+ assert.strictEqual(MESSAGE, e.message);
}));
setTimeout(function() {
diff --git a/test/parallel/test-file-write-stream3.js b/test/parallel/test-file-write-stream3.js
index 1243460f9f31..961f51ba82be 100644
--- a/test/parallel/test-file-write-stream3.js
+++ b/test/parallel/test-file-write-stream3.js
@@ -9,7 +9,7 @@ const filepath = path.join(common.tmpDir, 'write_pos.txt');
const cb_expected = 'write open close write open close write open close ';
-var cb_occurred = '';
+let cb_occurred = '';
const fileDataInitial = 'abcdefghijklmnopqrstuvwxyz';
@@ -34,10 +34,8 @@ common.refreshTmpDir();
function run_test_1() {
- var file, buffer, options;
-
- options = {};
- file = fs.createWriteStream(filepath, options);
+ const options = {};
+ const file = fs.createWriteStream(filepath, options);
console.log(' (debug: start ', file.start);
console.log(' (debug: pos ', file.pos);
@@ -51,10 +49,10 @@ function run_test_1() {
console.log(' (debug: start ', file.start);
console.log(' (debug: pos ', file.pos);
assert.strictEqual(file.bytesWritten, buffer.length);
- var fileData = fs.readFileSync(filepath, 'utf8');
+ const fileData = fs.readFileSync(filepath, 'utf8');
console.log(' (debug: file data ', fileData);
console.log(' (debug: expected ', fileDataExpected_1);
- assert.equal(fileData, fileDataExpected_1);
+ assert.strictEqual(fileData, fileDataExpected_1);
run_test_2();
});
@@ -65,7 +63,7 @@ function run_test_1() {
throw err;
});
- buffer = Buffer.from(fileDataInitial);
+ const buffer = Buffer.from(fileDataInitial);
file.write(buffer);
cb_occurred += 'write ';
@@ -74,13 +72,12 @@ function run_test_1() {
function run_test_2() {
- var file, buffer, options;
- buffer = Buffer.from('123456');
+ const buffer = Buffer.from('123456');
- options = { start: 10,
- flags: 'r+' };
- file = fs.createWriteStream(filepath, options);
+ const options = { start: 10,
+ flags: 'r+' };
+ const file = fs.createWriteStream(filepath, options);
console.log(' (debug: start ', file.start);
console.log(' (debug: pos ', file.pos);
@@ -94,10 +91,10 @@ function run_test_2() {
console.log(' (debug: start ', file.start);
console.log(' (debug: pos ', file.pos);
assert.strictEqual(file.bytesWritten, buffer.length);
- var fileData = fs.readFileSync(filepath, 'utf8');
+ const fileData = fs.readFileSync(filepath, 'utf8');
console.log(' (debug: file data ', fileData);
console.log(' (debug: expected ', fileDataExpected_2);
- assert.equal(fileData, fileDataExpected_2);
+ assert.strictEqual(fileData, fileDataExpected_2);
run_test_3();
});
@@ -116,13 +113,12 @@ function run_test_2() {
function run_test_3() {
- var file, options;
const data = '\u2026\u2026'; // 3 bytes * 2 = 6 bytes in UTF-8
- options = { start: 10,
- flags: 'r+' };
- file = fs.createWriteStream(filepath, options);
+ const options = { start: 10,
+ flags: 'r+' };
+ const file = fs.createWriteStream(filepath, options);
console.log(' (debug: start ', file.start);
console.log(' (debug: pos ', file.pos);
@@ -139,7 +135,7 @@ function run_test_3() {
const fileData = fs.readFileSync(filepath, 'utf8');
console.log(' (debug: file data ', fileData);
console.log(' (debug: expected ', fileDataExpected_3);
- assert.equal(fileData, fileDataExpected_3);
+ assert.strictEqual(fileData, fileDataExpected_3);
run_test_4();
});
diff --git a/test/parallel/test-freelist.js b/test/parallel/test-freelist.js
index feb5dcc9a96a..65758bd7114d 100644
--- a/test/parallel/test-freelist.js
+++ b/test/parallel/test-freelist.js
@@ -6,8 +6,8 @@ require('../common');
const assert = require('assert');
const freelist = require('internal/freelist');
-assert.equal(typeof freelist, 'object');
-assert.equal(typeof freelist.FreeList, 'function');
+assert.strictEqual(typeof freelist, 'object');
+assert.strictEqual(typeof freelist.FreeList, 'function');
const flist1 = new freelist.FreeList('flist1', 3, String);
diff --git a/test/parallel/test-fs-append-file-sync.js b/test/parallel/test-fs-append-file-sync.js
index d337e6ff3269..c13fc8953ed5 100644
--- a/test/parallel/test-fs-append-file-sync.js
+++ b/test/parallel/test-fs-append-file-sync.js
@@ -1,83 +1,82 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var join = require('path').join;
-var fs = require('fs');
-
-var currentFileData = 'ABCD';
-
-var num = 220;
-var data = '南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、' +
- '广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。' +
- '南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。' +
- '前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,' +
- '南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,' +
- '历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,' +
- '它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n';
+const common = require('../common');
+const assert = require('assert');
+const join = require('path').join;
+const fs = require('fs');
+
+const currentFileData = 'ABCD';
+const m = 0o600;
+const num = 220;
+const data = '南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、' +
+ '广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。' +
+ '南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。' +
+ '前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,' +
+ '南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,' +
+ '历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,' +
+ '它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n';
common.refreshTmpDir();
// test that empty file will be created and have content added
-var filename = join(common.tmpDir, 'append-sync.txt');
+const filename = join(common.tmpDir, 'append-sync.txt');
fs.appendFileSync(filename, data);
-var fileData = fs.readFileSync(filename);
+const fileData = fs.readFileSync(filename);
-assert.equal(Buffer.byteLength(data), fileData.length);
+assert.strictEqual(Buffer.byteLength(data), fileData.length);
// test that appends data to a non empty file
-var filename2 = join(common.tmpDir, 'append-sync2.txt');
+const filename2 = join(common.tmpDir, 'append-sync2.txt');
fs.writeFileSync(filename2, currentFileData);
fs.appendFileSync(filename2, data);
-var fileData2 = fs.readFileSync(filename2);
+const fileData2 = fs.readFileSync(filename2);
-assert.equal(Buffer.byteLength(data) + currentFileData.length,
- fileData2.length);
+assert.strictEqual(Buffer.byteLength(data) + currentFileData.length,
+ fileData2.length);
// test that appendFileSync accepts buffers
-var filename3 = join(common.tmpDir, 'append-sync3.txt');
+const filename3 = join(common.tmpDir, 'append-sync3.txt');
fs.writeFileSync(filename3, currentFileData);
-var buf = Buffer.from(data, 'utf8');
+const buf = Buffer.from(data, 'utf8');
fs.appendFileSync(filename3, buf);
-var fileData3 = fs.readFileSync(filename3);
+const fileData3 = fs.readFileSync(filename3);
-assert.equal(buf.length + currentFileData.length, fileData3.length);
+assert.strictEqual(buf.length + currentFileData.length, fileData3.length);
// test that appendFile accepts numbers.
-var filename4 = join(common.tmpDir, 'append-sync4.txt');
+const filename4 = join(common.tmpDir, 'append-sync4.txt');
fs.writeFileSync(filename4, currentFileData, { mode: m });
-var m = 0o600;
fs.appendFileSync(filename4, num, { mode: m });
// windows permissions aren't unix
if (!common.isWindows) {
- var st = fs.statSync(filename4);
- assert.equal(st.mode & 0o700, m);
+ const st = fs.statSync(filename4);
+ assert.strictEqual(st.mode & 0o700, m);
}
-var fileData4 = fs.readFileSync(filename4);
+const fileData4 = fs.readFileSync(filename4);
-assert.equal(Buffer.byteLength('' + num) + currentFileData.length,
- fileData4.length);
+assert.strictEqual(Buffer.byteLength('' + num) + currentFileData.length,
+ fileData4.length);
// test that appendFile accepts file descriptors
-var filename5 = join(common.tmpDir, 'append-sync5.txt');
+const filename5 = join(common.tmpDir, 'append-sync5.txt');
fs.writeFileSync(filename5, currentFileData);
-var filename5fd = fs.openSync(filename5, 'a+', 0o600);
+const filename5fd = fs.openSync(filename5, 'a+', 0o600);
fs.appendFileSync(filename5fd, data);
fs.closeSync(filename5fd);
-var fileData5 = fs.readFileSync(filename5);
+const fileData5 = fs.readFileSync(filename5);
-assert.equal(Buffer.byteLength(data) + currentFileData.length,
- fileData5.length);
+assert.strictEqual(Buffer.byteLength(data) + currentFileData.length,
+ fileData5.length);
//exit logic for cleanup
diff --git a/test/parallel/test-fs-append-file.js b/test/parallel/test-fs-append-file.js
index 5970c8cec151..00691b1e74e6 100644
--- a/test/parallel/test-fs-append-file.js
+++ b/test/parallel/test-fs-append-file.js
@@ -1,129 +1,130 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var fs = require('fs');
-var join = require('path').join;
+const common = require('../common');
+const assert = require('assert');
+const fs = require('fs');
+const join = require('path').join;
-var filename = join(common.tmpDir, 'append.txt');
+const filename = join(common.tmpDir, 'append.txt');
-var currentFileData = 'ABCD';
+const currentFileData = 'ABCD';
-var n = 220;
-var s = '南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、' +
- '广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。' +
- '南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。' +
- '前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,' +
- '南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,' +
- '历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,' +
- '它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n';
+const n = 220;
+const s = '南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、' +
+ '广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。' +
+ '南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。' +
+ '前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,' +
+ '南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,' +
+ '历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,' +
+ '它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n';
-var ncallbacks = 0;
+let ncallbacks = 0;
common.refreshTmpDir();
// test that empty file will be created and have content added
fs.appendFile(filename, s, function(e) {
- if (e) throw e;
+ assert.ifError(e);
ncallbacks++;
fs.readFile(filename, function(e, buffer) {
- if (e) throw e;
+ assert.ifError(e);
ncallbacks++;
- assert.equal(Buffer.byteLength(s), buffer.length);
+ assert.strictEqual(Buffer.byteLength(s), buffer.length);
});
});
// test that appends data to a non empty file
-var filename2 = join(common.tmpDir, 'append2.txt');
+const filename2 = join(common.tmpDir, 'append2.txt');
fs.writeFileSync(filename2, currentFileData);
fs.appendFile(filename2, s, function(e) {
- if (e) throw e;
+ assert.ifError(e);
ncallbacks++;
fs.readFile(filename2, function(e, buffer) {
- if (e) throw e;
+ assert.ifError(e);
ncallbacks++;
- assert.equal(Buffer.byteLength(s) + currentFileData.length, buffer.length);
+ assert.strictEqual(Buffer.byteLength(s) + currentFileData.length,
+ buffer.length);
});
});
// test that appendFile accepts buffers
-var filename3 = join(common.tmpDir, 'append3.txt');
+const filename3 = join(common.tmpDir, 'append3.txt');
fs.writeFileSync(filename3, currentFileData);
-var buf = Buffer.from(s, 'utf8');
+const buf = Buffer.from(s, 'utf8');
fs.appendFile(filename3, buf, function(e) {
- if (e) throw e;
+ assert.ifError(e);
ncallbacks++;
fs.readFile(filename3, function(e, buffer) {
- if (e) throw e;
+ assert.ifError(e);
ncallbacks++;
- assert.equal(buf.length + currentFileData.length, buffer.length);
+ assert.strictEqual(buf.length + currentFileData.length, buffer.length);
});
});
// test that appendFile accepts numbers.
-var filename4 = join(common.tmpDir, 'append4.txt');
+const filename4 = join(common.tmpDir, 'append4.txt');
fs.writeFileSync(filename4, currentFileData);
-var m = 0o600;
+const m = 0o600;
fs.appendFile(filename4, n, { mode: m }, function(e) {
- if (e) throw e;
+ assert.ifError(e);
ncallbacks++;
// windows permissions aren't unix
if (!common.isWindows) {
- var st = fs.statSync(filename4);
- assert.equal(st.mode & 0o700, m);
+ const st = fs.statSync(filename4);
+ assert.strictEqual(st.mode & 0o700, m);
}
fs.readFile(filename4, function(e, buffer) {
- if (e) throw e;
+ assert.ifError(e);
ncallbacks++;
- assert.equal(Buffer.byteLength('' + n) + currentFileData.length,
- buffer.length);
+ assert.strictEqual(Buffer.byteLength('' + n) + currentFileData.length,
+ buffer.length);
});
});
// test that appendFile accepts file descriptors
-var filename5 = join(common.tmpDir, 'append5.txt');
+const filename5 = join(common.tmpDir, 'append5.txt');
fs.writeFileSync(filename5, currentFileData);
fs.open(filename5, 'a+', function(e, fd) {
- if (e) throw e;
+ assert.ifError(e);
ncallbacks++;
fs.appendFile(fd, s, function(e) {
- if (e) throw e;
+ assert.ifError(e);
ncallbacks++;
fs.close(fd, function(e) {
- if (e) throw e;
+ assert.ifError(e);
ncallbacks++;
fs.readFile(filename5, function(e, buffer) {
- if (e) throw e;
+ assert.ifError(e);
ncallbacks++;
- assert.equal(Buffer.byteLength(s) + currentFileData.length,
- buffer.length);
+ assert.strictEqual(Buffer.byteLength(s) + currentFileData.length,
+ buffer.length);
});
});
});
});
process.on('exit', function() {
- assert.equal(12, ncallbacks);
+ assert.strictEqual(12, ncallbacks);
fs.unlinkSync(filename);
fs.unlinkSync(filename2);
diff --git a/test/parallel/test-fs-non-number-arguments-throw.js b/test/parallel/test-fs-non-number-arguments-throw.js
index 8f34a1fcbb92..b13041ca3eec 100644
--- a/test/parallel/test-fs-non-number-arguments-throw.js
+++ b/test/parallel/test-fs-non-number-arguments-throw.js
@@ -15,17 +15,20 @@ const saneEmitter = fs.createReadStream(tempFile, { start: 4, end: 6 });
assert.throws(function() {
fs.createReadStream(tempFile, { start: '4', end: 6 });
-}, "start as string didn't throw an error for createReadStream");
+}, /^TypeError: "start" option must be a Number$/,
+ "start as string didn't throw an error for createReadStream");
assert.throws(function() {
fs.createReadStream(tempFile, { start: 4, end: '6' });
-}, "end as string didn't throw an error");
+}, /^TypeError: "end" option must be a Number$/,
+ "end as string didn't throw an error for createReadStream");
assert.throws(function() {
fs.createWriteStream(tempFile, { start: '4' });
-}, "start as string didn't throw an error for createWriteStream");
+}, /^TypeError: "start" option must be a Number$/,
+ "start as string didn't throw an error for createWriteStream");
-saneEmitter.on('data', function(data) {
+saneEmitter.on('data', common.mustCall(function(data) {
assert.strictEqual(sanity, data.toString('utf8'), 'read ' +
data.toString('utf8') + ' instead of ' + sanity);
-});
+}));
diff --git a/test/parallel/test-fs-read-file-sync.js b/test/parallel/test-fs-read-file-sync.js
index d34bf7748cea..45d08f40111f 100644
--- a/test/parallel/test-fs-read-file-sync.js
+++ b/test/parallel/test-fs-read-file-sync.js
@@ -1,13 +1,13 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var path = require('path');
-var fs = require('fs');
+const common = require('../common');
+const assert = require('assert');
+const path = require('path');
+const fs = require('fs');
-var fn = path.join(common.fixturesDir, 'elipses.txt');
+const fn = path.join(common.fixturesDir, 'elipses.txt');
-var s = fs.readFileSync(fn, 'utf8');
-for (var i = 0; i < s.length; i++) {
- assert.equal('\u2026', s[i]);
+const s = fs.readFileSync(fn, 'utf8');
+for (let i = 0; i < s.length; i++) {
+ assert.strictEqual('\u2026', s[i]);
}
-assert.equal(10000, s.length);
+assert.strictEqual(10000, s.length);
diff --git a/test/parallel/test-fs-read-stream-err.js b/test/parallel/test-fs-read-stream-err.js
index 1bc2b6f0b023..32e9b02455e2 100644
--- a/test/parallel/test-fs-read-stream-err.js
+++ b/test/parallel/test-fs-read-stream-err.js
@@ -1,43 +1,42 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var fs = require('fs');
+const common = require('../common');
+const assert = require('assert');
+const fs = require('fs');
-var stream = fs.createReadStream(__filename, {
+const stream = fs.createReadStream(__filename, {
bufferSize: 64
});
-var err = new Error('BAM');
+const err = new Error('BAM');
-stream.on('error', common.mustCall(function errorHandler(err_) {
- console.error('error event');
- process.nextTick(function() {
- assert.equal(stream.fd, null);
- assert.equal(err_, err);
- });
+stream.on('error', common.mustCall((err_) => {
+ process.nextTick(common.mustCall(() => {
+ assert.strictEqual(stream.fd, null);
+ assert.strictEqual(err_, err);
+ }));
}));
-fs.close = common.mustCall(function(fd_, cb) {
- assert.equal(fd_, stream.fd);
+fs.close = common.mustCall((fd_, cb) => {
+ assert.strictEqual(fd_, stream.fd);
process.nextTick(cb);
});
-var read = fs.read;
+const read = fs.read;
fs.read = function() {
// first time is ok.
read.apply(fs, arguments);
// then it breaks
- fs.read = function() {
- var cb = arguments[arguments.length - 1];
- process.nextTick(function() {
+ fs.read = common.mustCall(function() {
+ const cb = arguments[arguments.length - 1];
+ process.nextTick(() => {
cb(err);
});
// and should not be called again!
- fs.read = function() {
+ fs.read = () => {
throw new Error('BOOM!');
};
- };
+ });
};
-stream.on('data', function(buf) {
- stream.on('data', common.fail); // no more 'data' events should follow
+stream.on('data', (buf) => {
+ stream.on('data', () => common.fail("no more 'data' events should follow"));
});
diff --git a/test/parallel/test-fs-read-stream-inherit.js b/test/parallel/test-fs-read-stream-inherit.js
index c4216f4e1390..40ec5ed88382 100644
--- a/test/parallel/test-fs-read-stream-inherit.js
+++ b/test/parallel/test-fs-read-stream-inherit.js
@@ -1,22 +1,22 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
-var path = require('path');
-var fs = require('fs');
-var fn = path.join(common.fixturesDir, 'elipses.txt');
-var rangeFile = path.join(common.fixturesDir, 'x.txt');
+const path = require('path');
+const fs = require('fs');
+const fn = path.join(common.fixturesDir, 'elipses.txt');
+const rangeFile = path.join(common.fixturesDir, 'x.txt');
-var callbacks = { open: 0, end: 0, close: 0 };
+const callbacks = { open: 0, end: 0, close: 0 };
-var paused = false;
+let paused = false;
-var file = fs.ReadStream(fn);
+const file = fs.ReadStream(fn);
file.on('open', function(fd) {
file.length = 0;
callbacks.open++;
- assert.equal('number', typeof fd);
+ assert.strictEqual(typeof fd, 'number');
assert.ok(file.readable);
// GH-535
@@ -48,19 +48,17 @@ file.on('end', function(chunk) {
file.on('close', function() {
callbacks.close++;
-
- //assert.equal(fs.readFileSync(fn), fileContent);
});
-var file3 = fs.createReadStream(fn, Object.create({encoding: 'utf8'}));
+const file3 = fs.createReadStream(fn, Object.create({encoding: 'utf8'}));
file3.length = 0;
file3.on('data', function(data) {
- assert.equal('string', typeof data);
+ assert.strictEqual(typeof data, 'string');
file3.length += data.length;
- for (var i = 0; i < data.length; i++) {
+ for (let i = 0; i < data.length; i++) {
// http://www.fileformat.info/info/unicode/char/2026/index.htm
- assert.equal('\u2026', data[i]);
+ assert.strictEqual(data[i], '\u2026');
}
});
@@ -69,57 +67,57 @@ file3.on('close', function() {
});
process.on('exit', function() {
- assert.equal(1, callbacks.open);
- assert.equal(1, callbacks.end);
- assert.equal(2, callbacks.close);
- assert.equal(30000, file.length);
- assert.equal(10000, file3.length);
+ assert.strictEqual(callbacks.open, 1);
+ assert.strictEqual(callbacks.end, 1);
+ assert.strictEqual(callbacks.close, 2);
+ assert.strictEqual(file.length, 30000);
+ assert.strictEqual(file3.length, 10000);
console.error('ok');
});
-var file4 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1,
- start: 1, end: 2}));
-assert.equal(file4.start, 1);
-assert.equal(file4.end, 2);
-var contentRead = '';
+const file4 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1,
+ start: 1, end: 2}));
+assert.strictEqual(file4.start, 1);
+assert.strictEqual(file4.end, 2);
+let contentRead = '';
file4.on('data', function(data) {
contentRead += data.toString('utf-8');
});
file4.on('end', function(data) {
- assert.equal(contentRead, 'yz');
+ assert.strictEqual(contentRead, 'yz');
});
-var file5 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1,
- start: 1}));
-assert.equal(file5.start, 1);
+const file5 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1,
+ start: 1}));
+assert.strictEqual(file5.start, 1);
file5.data = '';
file5.on('data', function(data) {
file5.data += data.toString('utf-8');
});
file5.on('end', function() {
- assert.equal(file5.data, 'yz\n');
+ assert.strictEqual(file5.data, 'yz\n');
});
// https://github.com/joyent/node/issues/2320
-var file6 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1.23,
- start: 1}));
-assert.equal(file6.start, 1);
+const file6 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1.23,
+ start: 1}));
+assert.strictEqual(file6.start, 1);
file6.data = '';
file6.on('data', function(data) {
file6.data += data.toString('utf-8');
});
file6.on('end', function() {
- assert.equal(file6.data, 'yz\n');
+ assert.strictEqual(file6.data, 'yz\n');
});
assert.throws(function() {
fs.createReadStream(rangeFile, Object.create({start: 10, end: 2}));
}, /"start" option must be <= "end" option/);
-var stream = fs.createReadStream(rangeFile, Object.create({ start: 0,
- end: 0 }));
-assert.equal(stream.start, 0);
-assert.equal(stream.end, 0);
+const stream = fs.createReadStream(rangeFile, Object.create({ start: 0,
+ end: 0 }));
+assert.strictEqual(stream.start, 0);
+assert.strictEqual(stream.end, 0);
stream.data = '';
stream.on('data', function(chunk) {
@@ -127,16 +125,16 @@ stream.on('data', function(chunk) {
});
stream.on('end', function() {
- assert.equal('x', stream.data);
+ assert.strictEqual(stream.data, 'x');
});
// pause and then resume immediately.
-var pauseRes = fs.createReadStream(rangeFile);
+const pauseRes = fs.createReadStream(rangeFile);
pauseRes.pause();
pauseRes.resume();
-var file7 = fs.createReadStream(rangeFile, Object.create({autoClose: false }));
-assert.equal(file7.autoClose, false);
+let file7 = fs.createReadStream(rangeFile, Object.create({autoClose: false }));
+assert.strictEqual(file7.autoClose, false);
file7.on('data', function() {});
file7.on('end', function() {
process.nextTick(function() {
@@ -154,18 +152,18 @@ function file7Next() {
file7.data += data;
});
file7.on('end', function(err) {
- assert.equal(file7.data, 'xyz\n');
+ assert.strictEqual(file7.data, 'xyz\n');
});
}
// Just to make sure autoClose won't close the stream because of error.
-var file8 = fs.createReadStream(null, Object.create({fd: 13337,
- autoClose: false }));
+const file8 = fs.createReadStream(null, Object.create({fd: 13337,
+ autoClose: false }));
file8.on('data', function() {});
file8.on('error', common.mustCall(function() {}));
// Make sure stream is destroyed when file does not exist.
-var file9 = fs.createReadStream('/path/to/file/that/does/not/exist');
+const file9 = fs.createReadStream('/path/to/file/that/does/not/exist');
file9.on('data', function() {});
file9.on('error', common.mustCall(function() {}));
diff --git a/test/parallel/test-fs-read-stream-resume.js b/test/parallel/test-fs-read-stream-resume.js
index abac0686c119..3ff89644e5c0 100644
--- a/test/parallel/test-fs-read-stream-resume.js
+++ b/test/parallel/test-fs-read-stream-resume.js
@@ -1,13 +1,13 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
-var fs = require('fs');
-var path = require('path');
+const fs = require('fs');
+const path = require('path');
-var file = path.join(common.fixturesDir, 'x.txt');
-var data = '';
-var first = true;
+const file = path.join(common.fixturesDir, 'x.txt');
+let data = '';
+let first = true;
var stream = fs.createReadStream(file);
stream.setEncoding('utf8');
@@ -27,5 +27,5 @@ process.nextTick(function() {
});
process.on('exit', function() {
- assert.equal(data, 'xyz\n');
+ assert.strictEqual(data, 'xyz\n');
});
diff --git a/test/parallel/test-fs-symlink-dir-junction.js b/test/parallel/test-fs-symlink-dir-junction.js
index 1dd3a9030341..58ddb7ca38ae 100644
--- a/test/parallel/test-fs-symlink-dir-junction.js
+++ b/test/parallel/test-fs-symlink-dir-junction.js
@@ -1,12 +1,12 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var path = require('path');
-var fs = require('fs');
+const common = require('../common');
+const assert = require('assert');
+const path = require('path');
+const fs = require('fs');
// test creating and reading symbolic link
-var linkData = path.join(common.fixturesDir, 'cycles/');
-var linkPath = path.join(common.tmpDir, 'cycles_link');
+const linkData = path.join(common.fixturesDir, 'cycles/');
+const linkPath = path.join(common.tmpDir, 'cycles_link');
common.refreshTmpDir();
@@ -22,7 +22,7 @@ fs.symlink(linkData, linkPath, 'junction', common.mustCall(function(err) {
fs.readlink(linkPath, common.mustCall(function(err, destination) {
if (err) throw err;
- assert.equal(destination, linkData);
+ assert.strictEqual(destination, linkData);
fs.unlink(linkPath, common.mustCall(function(err) {
if (err) throw err;
diff --git a/test/parallel/test-fs-truncate-fd.js b/test/parallel/test-fs-truncate-fd.js
index 2514b80f0989..526612870d9f 100644
--- a/test/parallel/test-fs-truncate-fd.js
+++ b/test/parallel/test-fs-truncate-fd.js
@@ -1,17 +1,17 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var path = require('path');
-var fs = require('fs');
-var tmp = common.tmpDir;
+const common = require('../common');
+const assert = require('assert');
+const path = require('path');
+const fs = require('fs');
+const tmp = common.tmpDir;
common.refreshTmpDir();
-var filename = path.resolve(tmp, 'truncate-file.txt');
+const filename = path.resolve(tmp, 'truncate-file.txt');
fs.writeFileSync(filename, 'hello world', 'utf8');
-var fd = fs.openSync(filename, 'r+');
+const fd = fs.openSync(filename, 'r+');
fs.truncate(fd, 5, common.mustCall(function(err) {
assert.ok(!err);
- assert.equal(fs.readFileSync(filename, 'utf8'), 'hello');
+ assert.strictEqual(fs.readFileSync(filename, 'utf8'), 'hello');
}));
process.on('exit', function() {
diff --git a/test/parallel/test-fs-write-file.js b/test/parallel/test-fs-write-file.js
index 5ec95c8219aa..acc69764fe14 100644
--- a/test/parallel/test-fs-write-file.js
+++ b/test/parallel/test-fs-write-file.js
@@ -1,81 +1,81 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var fs = require('fs');
-var join = require('path').join;
+const common = require('../common');
+const assert = require('assert');
+const fs = require('fs');
+const join = require('path').join;
common.refreshTmpDir();
-var filename = join(common.tmpDir, 'test.txt');
+const filename = join(common.tmpDir, 'test.txt');
-var n = 220;
-var s = '南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、' +
- '广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。' +
- '南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。' +
- '前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,' +
- '南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,' +
- '历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,' +
- '它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n';
+const n = 220;
+const s = '南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、' +
+ '广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。' +
+ '南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。' +
+ '前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,' +
+ '南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,' +
+ '历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,' +
+ '它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n';
fs.writeFile(filename, s, common.mustCall(function(e) {
- if (e) throw e;
+ assert.ifError(e);
fs.readFile(filename, common.mustCall(function(e, buffer) {
- if (e) throw e;
- assert.equal(Buffer.byteLength(s), buffer.length);
+ assert.ifError(e);
+ assert.strictEqual(Buffer.byteLength(s), buffer.length);
}));
}));
// test that writeFile accepts buffers
-var filename2 = join(common.tmpDir, 'test2.txt');
-var buf = Buffer.from(s, 'utf8');
+const filename2 = join(common.tmpDir, 'test2.txt');
+const buf = Buffer.from(s, 'utf8');
fs.writeFile(filename2, buf, common.mustCall(function(e) {
- if (e) throw e;
+ assert.ifError(e);
fs.readFile(filename2, common.mustCall(function(e, buffer) {
- if (e) throw e;
+ assert.ifError(e);
- assert.equal(buf.length, buffer.length);
+ assert.strictEqual(buf.length, buffer.length);
}));
}));
// test that writeFile accepts numbers.
-var filename3 = join(common.tmpDir, 'test3.txt');
+const filename3 = join(common.tmpDir, 'test3.txt');
-var m = 0o600;
+const m = 0o600;
fs.writeFile(filename3, n, { mode: m }, common.mustCall(function(e) {
- if (e) throw e;
+ assert.ifError(e);
// windows permissions aren't unix
if (!common.isWindows) {
- var st = fs.statSync(filename3);
- assert.equal(st.mode & 0o700, m);
+ const st = fs.statSync(filename3);
+ assert.strictEqual(st.mode & 0o700, m);
}
fs.readFile(filename3, common.mustCall(function(e, buffer) {
- if (e) throw e;
+ assert.ifError(e);
- assert.equal(Buffer.byteLength('' + n), buffer.length);
+ assert.strictEqual(Buffer.byteLength('' + n), buffer.length);
}));
}));
// test that writeFile accepts file descriptors
-var filename4 = join(common.tmpDir, 'test4.txt');
+const filename4 = join(common.tmpDir, 'test4.txt');
fs.open(filename4, 'w+', common.mustCall(function(e, fd) {
- if (e) throw e;
+ assert.ifError(e);
fs.writeFile(fd, s, common.mustCall(function(e) {
- if (e) throw e;
+ assert.ifError(e);
fs.close(fd, common.mustCall(function(e) {
- if (e) throw e;
+ assert.ifError(e);
fs.readFile(filename4, common.mustCall(function(e, buffer) {
- if (e) throw e;
+ assert.ifError(e);
- assert.equal(Buffer.byteLength(s), buffer.length);
+ assert.strictEqual(Buffer.byteLength(s), buffer.length);
}));
}));
}));
diff --git a/test/parallel/test-fs-write.js b/test/parallel/test-fs-write.js
index 766cb0b2cea1..9960a91a4f75 100644
--- a/test/parallel/test-fs-write.js
+++ b/test/parallel/test-fs-write.js
@@ -1,13 +1,13 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var path = require('path');
-var Buffer = require('buffer').Buffer;
-var fs = require('fs');
-var fn = path.join(common.tmpDir, 'write.txt');
-var fn2 = path.join(common.tmpDir, 'write2.txt');
-var expected = 'ümlaut.';
-var constants = fs.constants;
+const common = require('../common');
+const assert = require('assert');
+const path = require('path');
+const Buffer = require('buffer').Buffer;
+const fs = require('fs');
+const fn = path.join(common.tmpDir, 'write.txt');
+const fn2 = path.join(common.tmpDir, 'write2.txt');
+const expected = 'ümlaut.';
+const constants = fs.constants;
common.refreshTmpDir();
@@ -15,12 +15,12 @@ fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) {
if (err) throw err;
console.log('open done');
fs.write(fd, '', 0, 'utf8', function(err, written) {
- assert.equal(0, written);
+ assert.strictEqual(0, written);
});
fs.write(fd, expected, 0, 'utf8', common.mustCall(function(err, written) {
console.log('write done');
if (err) throw err;
- assert.equal(Buffer.byteLength(expected), written);
+ assert.strictEqual(Buffer.byteLength(expected), written);
fs.closeSync(fd);
const found = fs.readFileSync(fn, 'utf8');
console.log('expected: "%s"', expected);
@@ -36,12 +36,12 @@ fs.open(fn2, constants.O_CREAT | constants.O_WRONLY | constants.O_TRUNC, 0o644,
if (err) throw err;
console.log('open done');
fs.write(fd, '', 0, 'utf8', (err, written) => {
- assert.equal(0, written);
+ assert.strictEqual(0, written);
});
fs.write(fd, expected, 0, 'utf8', common.mustCall((err, written) => {
console.log('write done');
if (err) throw err;
- assert.equal(Buffer.byteLength(expected), written);
+ assert.strictEqual(Buffer.byteLength(expected), written);
fs.closeSync(fd);
const found = fs.readFileSync(fn2, 'utf8');
console.log('expected: "%s"', expected);
diff --git a/test/parallel/test-http-dns-error.js b/test/parallel/test-http-dns-error.js
index f1f144a60a24..5e15ab9a3fa0 100644
--- a/test/parallel/test-http-dns-error.js
+++ b/test/parallel/test-http-dns-error.js
@@ -1,8 +1,8 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
-var http = require('http');
+const http = require('http');
if (common.hasCrypto) {
var https = require('https');
@@ -10,7 +10,7 @@ if (common.hasCrypto) {
common.skip('missing crypto');
}
-var host = '*'.repeat(256);
+const host = '*'.repeat(256);
function do_not_call() {
throw new Error('This function should not have been called.');
@@ -20,15 +20,15 @@ function test(mod) {
// Bad host name should not throw an uncatchable exception.
// Ensure that there is time to attach an error listener.
- var req1 = mod.get({host: host, port: 42}, do_not_call);
+ const req1 = mod.get({host: host, port: 42}, do_not_call);
req1.on('error', common.mustCall(function(err) {
- assert.equal(err.code, 'ENOTFOUND');
+ assert.strictEqual(err.code, 'ENOTFOUND');
}));
// http.get() called req1.end() for us
- var req2 = mod.request({method: 'GET', host: host, port: 42}, do_not_call);
+ const req2 = mod.request({method: 'GET', host: host, port: 42}, do_not_call);
req2.on('error', common.mustCall(function(err) {
- assert.equal(err.code, 'ENOTFOUND');
+ assert.strictEqual(err.code, 'ENOTFOUND');
}));
req2.end();
}
diff --git a/test/parallel/test-http-request-invalid-method-error.js b/test/parallel/test-http-request-invalid-method-error.js
new file mode 100644
index 000000000000..febb340eacd2
--- /dev/null
+++ b/test/parallel/test-http-request-invalid-method-error.js
@@ -0,0 +1,12 @@
+'use strict';
+require('../common');
+const assert = require('assert');
+const http = require('http');
+
+assert.throws(
+ () => { http.request({method: '\0'}); },
+ (error) => {
+ return (error instanceof TypeError) &&
+ /Method must be a valid HTTP token/.test(error);
+ }
+);
diff --git a/test/parallel/test-http-status-reason-invalid-chars.js b/test/parallel/test-http-status-reason-invalid-chars.js
index 7a8564a90613..9950eeeee9cd 100644
--- a/test/parallel/test-http-status-reason-invalid-chars.js
+++ b/test/parallel/test-http-status-reason-invalid-chars.js
@@ -3,10 +3,11 @@
const common = require('../common');
const assert = require('assert');
const http = require('http');
+const net = require('net');
function explicit(req, res) {
assert.throws(() => {
- res.writeHead(200, `OK\r\nContent-Type: text/html\r\n`);
+ res.writeHead(200, 'OK\r\nContent-Type: text/html\r\n');
}, /Invalid character in statusMessage/);
assert.throws(() => {
@@ -19,7 +20,7 @@ function explicit(req, res) {
function implicit(req, res) {
assert.throws(() => {
- res.statusMessage = `OK\r\nContent-Type: text/html\r\n`;
+ res.statusMessage = 'OK\r\nContent-Type: text/html\r\n';
res.writeHead(200);
}, /Invalid character in statusMessage/);
res.statusMessage = 'OK';
@@ -32,13 +33,15 @@ const server = http.createServer((req, res) => {
} else {
implicit(req, res);
}
-}).listen(common.PORT, common.mustCall(() => {
- const url = `http://localhost:${common.PORT}`;
+}).listen(0, common.mustCall(() => {
+ const addr = server.address().address;
+ const hostname = net.isIPv6(addr) ? `[${addr}1]` : addr;
+ const url = `http://${hostname}:${server.address().port}`;
let left = 2;
const check = common.mustCall((res) => {
left--;
- assert.notEqual(res.headers['content-type'], 'text/html');
- assert.notEqual(res.headers['content-type'], 'gotcha');
+ assert.notStrictEqual(res.headers['content-type'], 'text/html');
+ assert.notStrictEqual(res.headers['content-type'], 'gotcha');
if (left === 0) server.close();
}, 2);
http.get(`${url}/explicit`, check).end();
diff --git a/test/parallel/test-https-truncate.js b/test/parallel/test-https-truncate.js
index 26f133b4a5b4..4101a8c974e7 100644
--- a/test/parallel/test-https-truncate.js
+++ b/test/parallel/test-https-truncate.js
@@ -1,34 +1,34 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var fs = require('fs');
+const fs = require('fs');
-var key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem');
-var cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem');
+const key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem');
+const cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem');
// number of bytes discovered empirically to trigger the bug
-var data = Buffer.allocUnsafe(1024 * 32 + 1);
+const data = Buffer.allocUnsafe(1024 * 32 + 1);
httpsTest();
function httpsTest() {
- var sopt = { key: key, cert: cert };
+ const sopt = { key: key, cert: cert };
- var server = https.createServer(sopt, function(req, res) {
+ const server = https.createServer(sopt, function(req, res) {
res.setHeader('content-length', data.length);
res.end(data);
server.close();
});
server.listen(0, function() {
- var opts = { port: this.address().port, rejectUnauthorized: false };
+ const opts = { port: this.address().port, rejectUnauthorized: false };
https.get(opts).on('response', function(res) {
test(res);
});
@@ -38,14 +38,14 @@ function httpsTest() {
function test(res) {
res.on('end', function() {
- assert.equal(res._readableState.length, 0);
- assert.equal(bytes, data.length);
+ assert.strictEqual(res._readableState.length, 0);
+ assert.strictEqual(bytes, data.length);
console.log('ok');
});
// Pause and then resume on each chunk, to ensure that there will be
// a lone byte hanging out at the very end.
- var bytes = 0;
+ let bytes = 0;
res.on('data', function(chunk) {
bytes += chunk.length;
this.pause();
diff --git a/test/parallel/test-icu-transcode.js b/test/parallel/test-icu-transcode.js
index f45b9974367a..2cdd4078a2cc 100644
--- a/test/parallel/test-icu-transcode.js
+++ b/test/parallel/test-icu-transcode.js
@@ -46,3 +46,13 @@ assert.throws(
() => buffer.transcode(Buffer.from('a'), 'uf8', 'b'),
/Unable to transcode Buffer \[U_ILLEGAL_ARGUMENT_ERROR\]/
);
+
+assert.deepStrictEqual(
+ buffer.transcode(Buffer.from('hi', 'ascii'), 'ascii', 'utf16le'),
+ Buffer.from('hi', 'utf16le'));
+assert.deepStrictEqual(
+ buffer.transcode(Buffer.from('hi', 'latin1'), 'latin1', 'utf16le'),
+ Buffer.from('hi', 'utf16le'));
+assert.deepStrictEqual(
+ buffer.transcode(Buffer.from('hä', 'latin1'), 'latin1', 'utf16le'),
+ Buffer.from('hä', 'utf16le'));
diff --git a/test/parallel/test-internal-util-toInteger.js b/test/parallel/test-internal-util-toInteger.js
new file mode 100644
index 000000000000..57a411964da9
--- /dev/null
+++ b/test/parallel/test-internal-util-toInteger.js
@@ -0,0 +1,32 @@
+// Flags: --expose-internals
+'use strict';
+
+require('../common');
+const assert = require('assert');
+const {toInteger} = require('internal/util');
+
+const expectZero = [
+ '0', '-0', NaN, {}, [], {'a': 'b'}, [1, 2], '0x', '0o', '0b', false,
+ '', ' ', undefined, null
+];
+expectZero.forEach(function(value) {
+ assert.strictEqual(toInteger(value), 0);
+});
+
+assert.strictEqual(toInteger(Infinity), Infinity);
+assert.strictEqual(toInteger(-Infinity), -Infinity);
+
+const expectSame = [
+ '0x100', '0o100', '0b100', 0x100, -0x100, 0o100, -0o100, 0b100, -0b100, true
+];
+expectSame.forEach(function(value) {
+ assert.strictEqual(toInteger(value), +value, `${value} is not an Integer`);
+});
+
+const expectIntegers = new Map([
+ [[1], 1], [[-1], -1], [['1'], 1], [['-1'], -1],
+ [3.14, 3], [-3.14, -3], ['3.14', 3], ['-3.14', -3],
+]);
+expectIntegers.forEach(function(expected, value) {
+ assert.strictEqual(toInteger(value), expected);
+});
diff --git a/test/parallel/test-internal-util-toLength.js b/test/parallel/test-internal-util-toLength.js
new file mode 100644
index 000000000000..ce594c47c1db
--- /dev/null
+++ b/test/parallel/test-internal-util-toLength.js
@@ -0,0 +1,35 @@
+// Flags: --expose-internals
+'use strict';
+
+require('../common');
+const assert = require('assert');
+const {toLength} = require('internal/util');
+const maxValue = Number.MAX_SAFE_INTEGER;
+
+const expectZero = [
+ '0', '-0', NaN, {}, [], {'a': 'b'}, [1, 2], '0x', '0o', '0b', false,
+ '', ' ', undefined, null, -1, -1.25, -1.1, -1.9, -Infinity
+];
+expectZero.forEach(function(value) {
+ assert.strictEqual(toLength(value), 0);
+});
+
+assert.strictEqual(toLength(maxValue - 1), maxValue - 1);
+assert.strictEqual(maxValue, maxValue);
+assert.strictEqual(toLength(Infinity), maxValue);
+assert.strictEqual(toLength(maxValue + 1), maxValue);
+
+
+[
+ '0x100', '0o100', '0b100', 0x100, -0x100, 0o100, -0o100, 0b100, -0b100, true
+].forEach(function(value) {
+ assert.strictEqual(toLength(value), +value > 0 ? +value : 0);
+});
+
+const expectIntegers = new Map([
+ [[1], 1], [[-1], 0], [['1'], 1], [['-1'], 0],
+ [3.14, 3], [-3.14, 0], ['3.14', 3], ['-3.14', 0],
+]);
+expectIntegers.forEach(function(expected, value) {
+ assert.strictEqual(toLength(value), expected);
+});
diff --git a/test/parallel/test-net-better-error-messages-listen-path.js b/test/parallel/test-net-better-error-messages-listen-path.js
index 41d22c3fb9a4..50ed80a5e3cd 100644
--- a/test/parallel/test-net-better-error-messages-listen-path.js
+++ b/test/parallel/test-net-better-error-messages-listen-path.js
@@ -1,10 +1,10 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var net = require('net');
-var fp = '/blah/fadfa';
-var server = net.createServer(common.fail);
+const common = require('../common');
+const assert = require('assert');
+const net = require('net');
+const fp = '/blah/fadfa';
+const server = net.createServer(common.fail);
server.listen(fp, common.fail);
server.on('error', common.mustCall(function(e) {
- assert.equal(e.address, fp);
+ assert.strictEqual(e.address, fp);
}));
diff --git a/test/parallel/test-net-better-error-messages-listen.js b/test/parallel/test-net-better-error-messages-listen.js
index 44adce71a7d5..15ef4036aaa8 100644
--- a/test/parallel/test-net-better-error-messages-listen.js
+++ b/test/parallel/test-net-better-error-messages-listen.js
@@ -1,12 +1,12 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const net = require('net');
-var server = net.createServer(common.fail);
+const server = net.createServer(common.fail);
server.listen(1, '1.1.1.1', common.fail);
server.on('error', common.mustCall(function(e) {
- assert.equal(e.address, '1.1.1.1');
- assert.equal(e.port, 1);
- assert.equal(e.syscall, 'listen');
+ assert.strictEqual(e.address, '1.1.1.1');
+ assert.strictEqual(e.port, 1);
+ assert.strictEqual(e.syscall, 'listen');
}));
diff --git a/test/parallel/test-net-better-error-messages-port-hostname.js b/test/parallel/test-net-better-error-messages-port-hostname.js
index 23089baf448a..b08c35f3e63e 100644
--- a/test/parallel/test-net-better-error-messages-port-hostname.js
+++ b/test/parallel/test-net-better-error-messages-port-hostname.js
@@ -1,14 +1,14 @@
'use strict';
-var common = require('../common');
-var net = require('net');
-var assert = require('assert');
+const common = require('../common');
+const net = require('net');
+const assert = require('assert');
-var c = net.createConnection(common.PORT, '***');
+const c = net.createConnection(common.PORT, '***');
c.on('connect', common.fail);
c.on('error', common.mustCall(function(e) {
- assert.equal(e.code, 'ENOTFOUND');
- assert.equal(e.port, common.PORT);
- assert.equal(e.hostname, '***');
+ assert.strictEqual(e.code, 'ENOTFOUND');
+ assert.strictEqual(e.port, common.PORT);
+ assert.strictEqual(e.hostname, '***');
}));
diff --git a/test/parallel/test-net-better-error-messages-port.js b/test/parallel/test-net-better-error-messages-port.js
index 514e317fbb0b..9d74438c5f92 100644
--- a/test/parallel/test-net-better-error-messages-port.js
+++ b/test/parallel/test-net-better-error-messages-port.js
@@ -1,14 +1,14 @@
'use strict';
-var common = require('../common');
-var net = require('net');
-var assert = require('assert');
+const common = require('../common');
+const net = require('net');
+const assert = require('assert');
-var c = net.createConnection(common.PORT);
+const c = net.createConnection(common.PORT);
c.on('connect', common.fail);
c.on('error', common.mustCall(function(e) {
- assert.equal(e.code, 'ECONNREFUSED');
- assert.equal(e.port, common.PORT);
- assert.equal(e.address, '127.0.0.1');
+ assert.strictEqual(e.code, 'ECONNREFUSED');
+ assert.strictEqual(e.port, common.PORT);
+ assert.strictEqual(e.address, '127.0.0.1');
}));
diff --git a/test/parallel/test-net-connect-handle-econnrefused.js b/test/parallel/test-net-connect-handle-econnrefused.js
index bbfb5c1bec18..09b17ad29deb 100644
--- a/test/parallel/test-net-connect-handle-econnrefused.js
+++ b/test/parallel/test-net-connect-handle-econnrefused.js
@@ -1,18 +1,17 @@
'use strict';
-var common = require('../common');
-var net = require('net');
-var assert = require('assert');
+const common = require('../common');
+const net = require('net');
+const assert = require('assert');
// Hopefully nothing is running on common.PORT
-var c = net.createConnection(common.PORT);
+const c = net.createConnection(common.PORT);
c.on('connect', function() {
- console.error('connected?!');
- assert.ok(false);
+ common.fail('connected?!');
});
c.on('error', common.mustCall(function(e) {
console.error('couldn\'t connect.');
- assert.equal('ECONNREFUSED', e.code);
+ assert.strictEqual('ECONNREFUSED', e.code);
}));
diff --git a/test/parallel/test-net-dns-custom-lookup.js b/test/parallel/test-net-dns-custom-lookup.js
index 8d91bcba6687..07eb71c5ed58 100644
--- a/test/parallel/test-net-dns-custom-lookup.js
+++ b/test/parallel/test-net-dns-custom-lookup.js
@@ -18,9 +18,9 @@ function check(addressType, cb) {
family: addressType,
lookup: lookup
}).on('lookup', common.mustCall(function(err, ip, type) {
- assert.equal(err, null);
- assert.equal(address, ip);
- assert.equal(type, addressType);
+ assert.strictEqual(err, null);
+ assert.strictEqual(address, ip);
+ assert.strictEqual(type, addressType);
}));
}));
diff --git a/test/parallel/test-net-listen-fd0.js b/test/parallel/test-net-listen-fd0.js
index b484c6306f84..f34f12ec22c7 100644
--- a/test/parallel/test-net-listen-fd0.js
+++ b/test/parallel/test-net-listen-fd0.js
@@ -1,20 +1,12 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const net = require('net');
-var gotError = false;
-
-process.on('exit', function() {
- assert(gotError instanceof Error);
-});
-
-// this should fail with an async EINVAL error, not throw an exception
-net.createServer(common.fail).listen({fd: 0}).on('error', function(e) {
- switch (e.code) {
- case 'EINVAL':
- case 'ENOTSOCK':
- gotError = e;
- break;
- }
-});
+// This should fail with an async EINVAL error, not throw an exception
+net.createServer(common.fail)
+ .listen({fd: 0})
+ .on('error', common.mustCall(function(e) {
+ assert(e instanceof Error);
+ assert(['EINVAL', 'ENOTSOCK'].includes(e.code));
+ }));
diff --git a/test/parallel/test-net-local-address-port.js b/test/parallel/test-net-local-address-port.js
index 5eebdb16be37..56f8eab5855c 100644
--- a/test/parallel/test-net-local-address-port.js
+++ b/test/parallel/test-net-local-address-port.js
@@ -1,11 +1,11 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const net = require('net');
var server = net.createServer(common.mustCall(function(socket) {
- assert.equal(socket.localAddress, common.localhostIPv4);
- assert.equal(socket.localPort, this.address().port);
+ assert.strictEqual(socket.localAddress, common.localhostIPv4);
+ assert.strictEqual(socket.localPort, this.address().port);
socket.on('end', function() {
server.close();
});
diff --git a/test/parallel/test-net-localerror.js b/test/parallel/test-net-localerror.js
index ed7c9471e039..184e55c890b2 100644
--- a/test/parallel/test-net-localerror.js
+++ b/test/parallel/test-net-localerror.js
@@ -1,19 +1,19 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const net = require('net');
connect({
host: 'localhost',
port: common.PORT,
localPort: 'foobar',
-}, 'localPort should be a number: foobar');
+}, /^TypeError: "localPort" option should be a number: foobar$/);
connect({
host: 'localhost',
port: common.PORT,
localAddress: 'foobar',
-}, 'localAddress should be a valid IP: foobar');
+}, /^TypeError: "localAddress" option must be a valid IP: foobar$/);
function connect(opts, msg) {
assert.throws(function() {
diff --git a/test/parallel/test-net-pingpong.js b/test/parallel/test-net-pingpong.js
index 33fbafd8f978..b49b3a787787 100644
--- a/test/parallel/test-net-pingpong.js
+++ b/test/parallel/test-net-pingpong.js
@@ -1,87 +1,87 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-
-var net = require('net');
-
-var tests_run = 0;
+const common = require('../common');
+const assert = require('assert');
+const net = require('net');
function pingPongTest(port, host) {
- var N = 1000;
+ const N = 1000;
var count = 0;
var sentPongs = 0;
var sent_final_ping = false;
- var server = net.createServer({ allowHalfOpen: true }, function(socket) {
- console.log('connection: ' + socket.remoteAddress);
- assert.equal(server, socket.server);
- assert.equal(1, server.connections);
+ const server = net.createServer(
+ { allowHalfOpen: true },
+ common.mustCall(onSocket)
+ );
+
+ function onSocket(socket) {
+ assert.strictEqual(socket.server, server);
+ server.getConnections(common.mustCall(function(err, connections) {
+ assert.ifError(err);
+ assert.strictEqual(connections, 1);
+ }));
socket.setNoDelay();
socket.timeout = 0;
socket.setEncoding('utf8');
- socket.on('data', function(data) {
+ socket.on('data', common.mustCall(function(data) {
// Since we never queue data (we're always waiting for the PING
// before sending a pong) the writeQueueSize should always be less
// than one message.
assert.ok(0 <= socket.bufferSize && socket.bufferSize <= 4);
- assert.equal(true, socket.writable);
- assert.equal(true, socket.readable);
- assert.equal(true, count <= N);
- assert.equal(data, 'PING');
+ assert.strictEqual(socket.writable, true);
+ assert.strictEqual(socket.readable, true);
+ assert.ok(count <= N);
+ assert.strictEqual(data, 'PING');
- socket.write('PONG', function() {
+ socket.write('PONG', common.mustCall(function() {
sentPongs++;
- });
- });
+ }));
+ }, N + 1));
- socket.on('end', function() {
- assert.equal(true, socket.allowHalfOpen);
- assert.equal(true, socket.writable); // because allowHalfOpen
- assert.equal(false, socket.readable);
+ socket.on('end', common.mustCall(function() {
+ assert.strictEqual(socket.allowHalfOpen, true);
+ assert.strictEqual(socket.writable, true); // because allowHalfOpen
+ assert.strictEqual(socket.readable, false);
socket.end();
- });
+ }));
- socket.on('error', function(e) {
- throw e;
- });
+ socket.on('error', common.fail);
- socket.on('close', function() {
- console.log('server socket.end');
- assert.equal(false, socket.writable);
- assert.equal(false, socket.readable);
+ socket.on('close', common.mustCall(function() {
+ assert.strictEqual(socket.writable, false);
+ assert.strictEqual(socket.readable, false);
socket.server.close();
- });
- });
+ }));
+ }
- server.listen(port, host, function() {
+ server.listen(port, host, common.mustCall(function() {
if (this.address().port)
port = this.address().port;
- console.log(`server listening on ${port} ${host}`);
- var client = net.createConnection(port, host);
+ const client = net.createConnection(port, host);
client.setEncoding('ascii');
- client.on('connect', function() {
- assert.equal(true, client.readable);
- assert.equal(true, client.writable);
+ client.on('connect', common.mustCall(function() {
+ assert.strictEqual(client.readable, true);
+ assert.strictEqual(client.writable, true);
client.write('PING');
- });
+ }));
- client.on('data', function(data) {
- assert.equal('PONG', data);
+ client.on('data', common.mustCall(function(data) {
+ assert.strictEqual(data, 'PONG');
count += 1;
if (sent_final_ping) {
- assert.equal(false, client.writable);
- assert.equal(true, client.readable);
+ assert.strictEqual(client.writable, false);
+ assert.strictEqual(client.readable, true);
return;
} else {
- assert.equal(true, client.writable);
- assert.equal(true, client.readable);
+ assert.strictEqual(client.writable, true);
+ assert.strictEqual(client.readable, true);
}
if (count < N) {
@@ -91,20 +91,16 @@ function pingPongTest(port, host) {
client.write('PING');
client.end();
}
- });
-
- client.on('close', function() {
- console.log('client.end');
- assert.equal(N + 1, count);
- assert.equal(N + 1, sentPongs);
- assert.equal(true, sent_final_ping);
- tests_run += 1;
- });
-
- client.on('error', function(e) {
- throw e;
- });
- });
+ }, N + 1));
+
+ client.on('close', common.mustCall(function() {
+ assert.strictEqual(count, N + 1);
+ assert.strictEqual(sentPongs, N + 1);
+ assert.strictEqual(sent_final_ping, true);
+ }));
+
+ client.on('error', common.fail);
+ }));
}
/* All are run at once, so run on different ports */
@@ -114,11 +110,3 @@ pingPongTest(0);
pingPongTest(0, 'localhost');
if (common.hasIPv6)
pingPongTest(0, '::1');
-
-process.on('exit', function() {
- if (common.hasIPv6)
- assert.equal(4, tests_run);
- else
- assert.equal(3, tests_run);
- console.log('done');
-});
diff --git a/test/parallel/test-npm-install.js b/test/parallel/test-npm-install.js
index 60c590f40c0a..c7f216fce5f2 100644
--- a/test/parallel/test-npm-install.js
+++ b/test/parallel/test-npm-install.js
@@ -17,7 +17,8 @@ const installDir = path.join(common.tmpDir, 'install-dir');
fs.mkdirSync(installDir);
const npmPath = path.join(
- common.testDir,
+ __dirname,
+ '..',
'..',
'deps',
'npm',
diff --git a/test/parallel/test-preload.js b/test/parallel/test-preload.js
index e60b29dfbe7e..f849bc3dda32 100644
--- a/test/parallel/test-preload.js
+++ b/test/parallel/test-preload.js
@@ -37,7 +37,7 @@ childProcess.exec(nodeBinary + ' '
+ fixtureB,
function(err, stdout, stderr) {
if (err) throw err;
- assert.equal(stdout, 'A\nB\n');
+ assert.strictEqual(stdout, 'A\nB\n');
});
// test preloading multiple modules works
@@ -46,7 +46,7 @@ childProcess.exec(nodeBinary + ' '
+ fixtureC,
function(err, stdout, stderr) {
if (err) throw err;
- assert.equal(stdout, 'A\nB\nC\n');
+ assert.strictEqual(stdout, 'A\nB\nC\n');
});
// test that preloading a throwing module aborts
@@ -55,7 +55,7 @@ childProcess.exec(nodeBinary + ' '
+ fixtureB,
function(err, stdout, stderr) {
if (err) {
- assert.equal(stdout, 'A\n');
+ assert.strictEqual(stdout, 'A\n');
} else {
throw new Error('Preload should have failed');
}
@@ -67,7 +67,7 @@ childProcess.exec(nodeBinary + ' '
+ '-e "console.log(\'hello\');"',
function(err, stdout, stderr) {
if (err) throw err;
- assert.equal(stdout, 'A\nhello\n');
+ assert.strictEqual(stdout, 'A\nhello\n');
});
// test that preload can be used with stdin
@@ -76,14 +76,14 @@ const stdinProc = childProcess.spawn(
['--require', fixtureA],
{stdio: 'pipe'}
);
-stdinProc.stdin.end('console.log(\'hello\');');
+stdinProc.stdin.end("console.log('hello');");
var stdinStdout = '';
stdinProc.stdout.on('data', function(d) {
stdinStdout += d;
});
stdinProc.on('close', function(code) {
- assert.equal(code, 0);
- assert.equal(stdinStdout, 'A\nhello\n');
+ assert.strictEqual(code, 0);
+ assert.strictEqual(stdinStdout, 'A\nhello\n');
});
// test that preload can be used with repl
@@ -98,12 +98,12 @@ replProc.stdout.on('data', function(d) {
replStdout += d;
});
replProc.on('close', function(code) {
- assert.equal(code, 0);
+ assert.strictEqual(code, 0);
const output = [
'A',
'> '
].join('\n');
- assert.equal(replStdout, output);
+ assert.strictEqual(replStdout, output);
});
// test that preload placement at other points in the cmdline
@@ -114,7 +114,7 @@ childProcess.exec(nodeBinary + ' '
+ preloadOption([fixtureA, fixtureB]),
function(err, stdout, stderr) {
if (err) throw err;
- assert.equal(stdout, 'A\nB\nhello\n');
+ assert.strictEqual(stdout, 'A\nB\nhello\n');
});
// test that preload works with -i
@@ -123,7 +123,7 @@ const interactive = childProcess.exec(nodeBinary + ' '
+ '-i',
common.mustCall(function(err, stdout, stderr) {
assert.ifError(err);
- assert.strictEqual(stdout, `> 'test'\n> `);
+ assert.strictEqual(stdout, "> 'test'\n> ");
}));
interactive.stdin.write('a\n');
diff --git a/test/parallel/test-punycode.js b/test/parallel/test-punycode.js
index abd495e4a995..e869e6a33bf0 100644
--- a/test/parallel/test-punycode.js
+++ b/test/parallel/test-punycode.js
@@ -1,153 +1,224 @@
'use strict';
require('../common');
-var punycode = require('punycode');
-var assert = require('assert');
+const punycode = require('punycode');
+const assert = require('assert');
-assert.equal(punycode.encode('ü'), 'tda');
-assert.equal(punycode.encode('Goethe'), 'Goethe-');
-assert.equal(punycode.encode('Bücher'), 'Bcher-kva');
-assert.equal(punycode.encode(
+assert.strictEqual(punycode.encode('ü'), 'tda');
+assert.strictEqual(punycode.encode('Goethe'), 'Goethe-');
+assert.strictEqual(punycode.encode('Bücher'), 'Bcher-kva');
+assert.strictEqual(punycode.encode(
'Willst du die Blüthe des frühen, die Früchte des späteren Jahres'),
'Willst du die Blthe des frhen, die Frchte des spteren Jahres-x9e96lkal');
-assert.equal(punycode.encode('日本語'), 'wgv71a119e');
+assert.strictEqual(punycode.encode('日本語'), 'wgv71a119e');
-assert.equal(punycode.decode('tda'), 'ü');
-assert.equal(punycode.decode('Goethe-'), 'Goethe');
-assert.equal(punycode.decode('Bcher-kva'), 'Bücher');
-assert.equal(punycode.decode(
+assert.strictEqual(punycode.decode('tda'), 'ü');
+assert.strictEqual(punycode.decode('Goethe-'), 'Goethe');
+assert.strictEqual(punycode.decode('Bcher-kva'), 'Bücher');
+assert.strictEqual(punycode.decode(
'Willst du die Blthe des frhen, die Frchte des spteren Jahres-x9e96lkal'),
'Willst du die Blüthe des frühen, die Früchte des späteren Jahres');
-assert.equal(punycode.decode('wgv71a119e'), '日本語');
+assert.strictEqual(punycode.decode('wgv71a119e'), '日本語');
// http://tools.ietf.org/html/rfc3492#section-7.1
-var tests = {
+const tests = [
// (A) Arabic (Egyptian)
- 'egbpdaj6bu4bxfgehfvwxn':
- '\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644\u0645\u0648' +
- '\u0634\u0639\u0631\u0628\u064A\u061F',
+ {
+ encoded: 'egbpdaj6bu4bxfgehfvwxn',
+ decoded: '\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644\u0645' +
+ '\u0648\u0634\u0639\u0631\u0628\u064A\u061F'
+ },
// (B) Chinese (simplified)
- 'ihqwcrb4cv8a8dqg056pqjye':
- '\u4ED6\u4EEC\u4E3A\u4EC0\u4E48\u4E0D\u8BF4\u4E2D\u6587',
+ {
+ encoded: 'ihqwcrb4cv8a8dqg056pqjye',
+ decoded: '\u4ED6\u4EEC\u4E3A\u4EC0\u4E48\u4E0D\u8BF4\u4E2D\u6587'
+ },
// (C) Chinese (traditional)
- 'ihqwctvzc91f659drss3x8bo0yb':
- '\u4ED6\u5011\u7232\u4EC0\u9EBD\u4E0D\u8AAA\u4E2D\u6587',
+ {
+ encoded: 'ihqwctvzc91f659drss3x8bo0yb',
+ decoded: '\u4ED6\u5011\u7232\u4EC0\u9EBD\u4E0D\u8AAA\u4E2D\u6587'
+ },
// (D) Czech: Proprostnemluvesky
- 'Proprostnemluvesky-uyb24dma41a':
- '\u0050\u0072\u006F\u010D\u0070\u0072\u006F\u0073\u0074\u011B\u006E' +
- '\u0065\u006D\u006C\u0075\u0076\u00ED\u010D\u0065\u0073\u006B\u0079',
+ {
+ encoded: 'Proprostnemluvesky-uyb24dma41a',
+ decoded: '\u0050\u0072\u006F\u010D\u0070\u0072\u006F\u0073\u0074\u011B' +
+ '\u006E\u0065\u006D\u006C\u0075\u0076\u00ED\u010D\u0065\u0073\u006B\u0079'
+ },
// (E) Hebrew
- '4dbcagdahymbxekheh6e0a7fei0b':
- '\u05DC\u05DE\u05D4\u05D4\u05DD\u05E4\u05E9\u05D5\u05D8\u05DC\u05D0' +
- '\u05DE\u05D3\u05D1\u05E8\u05D9\u05DD\u05E2\u05D1\u05E8\u05D9\u05EA',
+ {
+ encoded: '4dbcagdahymbxekheh6e0a7fei0b',
+ decoded: '\u05DC\u05DE\u05D4\u05D4\u05DD\u05E4\u05E9\u05D5\u05D8\u05DC' +
+ '\u05D0\u05DE\u05D3\u05D1\u05E8\u05D9\u05DD\u05E2\u05D1\u05E8\u05D9\u05EA'
+ },
// (F) Hindi (Devanagari)
- 'i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd':
- '\u092F\u0939\u0932\u094B\u0917\u0939\u093F\u0928\u094D\u0926\u0940' +
- '\u0915\u094D\u092F\u094B\u0902\u0928\u0939\u0940\u0902\u092C\u094B' +
- '\u0932\u0938\u0915\u0924\u0947\u0939\u0948\u0902',
+ {
+ encoded: 'i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd',
+ decoded: '\u092F\u0939\u0932\u094B\u0917\u0939\u093F\u0928\u094D\u0926' +
+ '\u0940\u0915\u094D\u092F\u094B\u0902\u0928\u0939\u0940\u0902\u092C' +
+ '\u094B\u0932\u0938\u0915\u0924\u0947\u0939\u0948\u0902'
+ },
// (G) Japanese (kanji and hiragana)
- 'n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa':
- '\u306A\u305C\u307F\u3093\u306A\u65E5\u672C\u8A9E\u3092\u8A71\u3057' +
- '\u3066\u304F\u308C\u306A\u3044\u306E\u304B',
+ {
+ encoded: 'n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa',
+ decoded: '\u306A\u305C\u307F\u3093\u306A\u65E5\u672C\u8A9E\u3092\u8A71' +
+ '\u3057\u3066\u304F\u308C\u306A\u3044\u306E\u304B'
+ },
// (H) Korean (Hangul syllables)
- '989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5jpsd879ccm6fea98c':
- '\uC138\uACC4\uC758\uBAA8\uB4E0\uC0AC\uB78C\uB4E4\uC774\uD55C\uAD6D' +
- '\uC5B4\uB97C\uC774\uD574\uD55C\uB2E4\uBA74\uC5BC\uB9C8\uB098\uC88B' +
- '\uC744\uAE4C',
+ {
+ encoded: '989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5jpsd879' +
+ 'ccm6fea98c',
+ decoded: '\uC138\uACC4\uC758\uBAA8\uB4E0\uC0AC\uB78C\uB4E4\uC774\uD55C' +
+ '\uAD6D\uC5B4\uB97C\uC774\uD574\uD55C\uB2E4\uBA74\uC5BC\uB9C8\uB098' +
+ '\uC88B\uC744\uAE4C'
+ },
// (I) Russian (Cyrillic)
- 'b1abfaaepdrnnbgefbadotcwatmq2g4l':
- '\u043F\u043E\u0447\u0435\u043C\u0443\u0436\u0435\u043E\u043D\u0438' +
- '\u043D\u0435\u0433\u043E\u0432\u043E\u0440\u044F\u0442\u043F\u043E' +
- '\u0440\u0443\u0441\u0441\u043A\u0438',
+ {
+ encoded: 'b1abfaaepdrnnbgefbadotcwatmq2g4l',
+ decoded: '\u043F\u043E\u0447\u0435\u043C\u0443\u0436\u0435\u043E\u043D' +
+ '\u0438\u043D\u0435\u0433\u043E\u0432\u043E\u0440\u044F\u0442\u043F' +
+ '\u043E\u0440\u0443\u0441\u0441\u043A\u0438'
+ },
// (J) Spanish: PorqunopuedensimplementehablarenEspaol
- 'PorqunopuedensimplementehablarenEspaol-fmd56a':
- '\u0050\u006F\u0072\u0071\u0075\u00E9\u006E\u006F\u0070\u0075\u0065' +
- '\u0064\u0065\u006E\u0073\u0069\u006D\u0070\u006C\u0065\u006D\u0065' +
- '\u006E\u0074\u0065\u0068\u0061\u0062\u006C\u0061\u0072\u0065\u006E' +
- '\u0045\u0073\u0070\u0061\u00F1\u006F\u006C',
+ {
+ encoded: 'PorqunopuedensimplementehablarenEspaol-fmd56a',
+ decoded: '\u0050\u006F\u0072\u0071\u0075\u00E9\u006E\u006F\u0070\u0075' +
+ '\u0065\u0064\u0065\u006E\u0073\u0069\u006D\u0070\u006C\u0065\u006D' +
+ '\u0065\u006E\u0074\u0065\u0068\u0061\u0062\u006C\u0061\u0072\u0065' +
+ '\u006E\u0045\u0073\u0070\u0061\u00F1\u006F\u006C'
+ },
// (K) Vietnamese: Tisaohkhngth
// chnitingVit
- 'TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g':
- '\u0054\u1EA1\u0069\u0073\u0061\u006F\u0068\u1ECD\u006B\u0068\u00F4' +
- '\u006E\u0067\u0074\u0068\u1EC3\u0063\u0068\u1EC9\u006E\u00F3\u0069' +
- '\u0074\u0069\u1EBF\u006E\u0067\u0056\u0069\u1EC7\u0074',
+ {
+ encoded: 'TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g',
+ decoded: '\u0054\u1EA1\u0069\u0073\u0061\u006F\u0068\u1ECD\u006B\u0068' +
+ '\u00F4\u006E\u0067\u0074\u0068\u1EC3\u0063\u0068\u1EC9\u006E\u00F3' +
+ '\u0069\u0074\u0069\u1EBF\u006E\u0067\u0056\u0069\u1EC7\u0074'
+ },
// (L) 3B
- '3B-ww4c5e180e575a65lsy2b':
- '\u0033\u5E74\u0042\u7D44\u91D1\u516B\u5148\u751F',
+ {
+ encoded: '3B-ww4c5e180e575a65lsy2b',
+ decoded: '\u0033\u5E74\u0042\u7D44\u91D1\u516B\u5148\u751F'
+ },
// (M) -with-SUPER-MONKEYS
- '-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n':
- '\u5B89\u5BA4\u5948\u7F8E\u6075\u002D\u0077\u0069\u0074\u0068\u002D' +
- '\u0053\u0055\u0050\u0045\u0052\u002D\u004D\u004F\u004E\u004B\u0045' +
- '\u0059\u0053',
+ {
+ encoded: '-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n',
+ decoded: '\u5B89\u5BA4\u5948\u7F8E\u6075\u002D\u0077\u0069\u0074\u0068' +
+ '\u002D\u0053\u0055\u0050\u0045\u0052\u002D\u004D\u004F\u004E\u004B' +
+ '\u0045\u0059\u0053'
+ },
// (N) Hello-Another-Way-
- 'Hello-Another-Way--fc4qua05auwb3674vfr0b':
- '\u0048\u0065\u006C\u006C\u006F\u002D\u0041\u006E\u006F\u0074\u0068' +
- '\u0065\u0072\u002D\u0057\u0061\u0079\u002D\u305D\u308C\u305E\u308C' +
- '\u306E\u5834\u6240',
+ {
+ encoded: 'Hello-Another-Way--fc4qua05auwb3674vfr0b',
+ decoded: '\u0048\u0065\u006C\u006C\u006F\u002D\u0041\u006E\u006F\u0074' +
+ '\u0068\u0065\u0072\u002D\u0057\u0061\u0079\u002D\u305D\u308C\u305E' +
+ '\u308C\u306E\u5834\u6240'
+ },
// (O) 2
- '2-u9tlzr9756bt3uc0v':
- '\u3072\u3068\u3064\u5C4B\u6839\u306E\u4E0B\u0032',
+ {
+ encoded: '2-u9tlzr9756bt3uc0v',
+ decoded: '\u3072\u3068\u3064\u5C4B\u6839\u306E\u4E0B\u0032'
+ },
// (P) MajiKoi5
- 'MajiKoi5-783gue6qz075azm5e':
- '\u004D\u0061\u006A\u0069\u3067\u004B\u006F\u0069\u3059\u308B\u0035' +
- '\u79D2\u524D',
+ {
+ encoded: 'MajiKoi5-783gue6qz075azm5e',
+ decoded: '\u004D\u0061\u006A\u0069\u3067\u004B\u006F\u0069\u3059\u308B' +
+ '\u0035\u79D2\u524D'
+ },
// (Q) de
- 'de-jg4avhby1noc0d':
- '\u30D1\u30D5\u30A3\u30FC\u0064\u0065\u30EB\u30F3\u30D0',
+ {
+ encoded: 'de-jg4avhby1noc0d',
+ decoded: '\u30D1\u30D5\u30A3\u30FC\u0064\u0065\u30EB\u30F3\u30D0'
+ },
// (R)
- 'd9juau41awczczp':
- '\u305D\u306E\u30B9\u30D4\u30FC\u30C9\u3067',
+ {
+ encoded: 'd9juau41awczczp',
+ decoded: '\u305D\u306E\u30B9\u30D4\u30FC\u30C9\u3067'
+ },
// (S) -> $1.00 <-
- '-> $1.00 <--':
- '\u002D\u003E\u0020\u0024\u0031\u002E\u0030\u0030\u0020\u003C\u002D'
+ {
+ encoded: '-> $1.00 <--',
+ decoded: '\u002D\u003E\u0020\u0024\u0031\u002E\u0030\u0030\u0020\u003C' +
+ '\u002D'
+ }
+];
+
+let errors = 0;
+const handleError = (error, name) => {
+ console.error(
+ 'FAIL: %s expected %j, got %j',
+ name,
+ error.expected,
+ error.actual
+ );
+ errors++;
};
-var errors = 0;
+const regexNonASCII = /[^\x20-\x7E]/;
+const testBattery = {
+ encode: (test) => assert.strictEqual(
+ punycode.encode(test.decoded),
+ test.encoded
+ ),
+ decode: (test) => assert.strictEqual(
+ punycode.decode(test.encoded),
+ test.decoded
+ ),
+ toASCII: (test) => assert.strictEqual(
+ punycode.toASCII(test.decoded),
+ regexNonASCII.test(test.decoded)
+ ? `xn--${test.encoded}`
+ : test.decoded
+ ),
+ toUnicode: (test) => assert.strictEqual(
+ punycode.toUnicode(
+ regexNonASCII.test(test.decoded)
+ ? `xn--${test.encoded}`
+ : test.decoded
+ ),
+ regexNonASCII.test(test.decoded)
+ ? test.decoded.toLowerCase()
+ : test.decoded
+ )
+};
-for (var encoded in tests) {
- var decoded = tests[encoded];
- try {
- assert.equal(punycode.encode(decoded), encoded);
- } catch (e) {
- console.error('FAIL: expected %j, got %j', e.expected, e.actual);
- errors++;
- }
- try {
- assert.equal(punycode.decode(encoded), decoded);
- } catch (e) {
- console.error('FAIL: expected %j, got %j', e.expected, e.actual);
- errors++;
- }
-}
+tests.forEach((testCase) => {
+ Object.keys(testBattery).forEach((key) => {
+ try {
+ testBattery[key](testCase);
+ } catch (error) {
+ handleError(error, key);
+ }
+ });
+});
// BMP code point
-assert.equal(punycode.ucs2.encode([0x61]), 'a');
+assert.strictEqual(punycode.ucs2.encode([0x61]), 'a');
// supplementary code point (surrogate pair)
-assert.equal(punycode.ucs2.encode([0x1D306]), '\uD834\uDF06');
+assert.strictEqual(punycode.ucs2.encode([0x1D306]), '\uD834\uDF06');
// high surrogate
-assert.equal(punycode.ucs2.encode([0xD800]), '\uD800');
+assert.strictEqual(punycode.ucs2.encode([0xD800]), '\uD800');
// high surrogate followed by non-surrogates
-assert.equal(punycode.ucs2.encode([0xD800, 0x61, 0x62]), '\uD800ab');
+assert.strictEqual(punycode.ucs2.encode([0xD800, 0x61, 0x62]), '\uD800ab');
// low surrogate
-assert.equal(punycode.ucs2.encode([0xDC00]), '\uDC00');
+assert.strictEqual(punycode.ucs2.encode([0xDC00]), '\uDC00');
// low surrogate followed by non-surrogates
-assert.equal(punycode.ucs2.encode([0xDC00, 0x61, 0x62]), '\uDC00ab');
+assert.strictEqual(punycode.ucs2.encode([0xDC00, 0x61, 0x62]), '\uDC00ab');
-assert.equal(errors, 0);
+assert.strictEqual(errors, 0);
diff --git a/test/parallel/test-repl-eval.js b/test/parallel/test-repl-eval.js
index 7e5c7d39946c..1eb4e2371c70 100644
--- a/test/parallel/test-repl-eval.js
+++ b/test/parallel/test-repl-eval.js
@@ -10,7 +10,8 @@ const repl = require('repl');
eval: common.mustCall((cmd, context) => {
// Assertions here will not cause the test to exit with an error code
// so set a boolean that is checked in process.on('exit',...) instead.
- evalCalledWithExpectedArgs = (cmd === 'foo\n' && context.foo === 'bar');
+ evalCalledWithExpectedArgs = (cmd === 'function f() {}\n' &&
+ context.foo === 'bar');
})
};
@@ -18,7 +19,12 @@ const repl = require('repl');
r.context = {foo: 'bar'};
try {
- r.write('foo\n');
+ // Default preprocessor transforms
+ // function f() {} to
+ // var f = function f() {}
+ // Test to ensure that original input is preserved.
+ // Reference: https://github.com/nodejs/node/issues/9743
+ r.write('function f() {}\n');
} finally {
r.write('.exit\n');
}
diff --git a/test/parallel/test-repl-mode.js b/test/parallel/test-repl-mode.js
index 08b296c2c341..00e9cd577ece 100644
--- a/test/parallel/test-repl-mode.js
+++ b/test/parallel/test-repl-mode.js
@@ -1,12 +1,12 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var Stream = require('stream');
-var repl = require('repl');
+const common = require('../common');
+const assert = require('assert');
+const Stream = require('stream');
+const repl = require('repl');
common.globalCheck = false;
-var tests = [
+const tests = [
testSloppyMode,
testStrictMode,
testAutoMode
@@ -17,22 +17,22 @@ tests.forEach(function(test) {
});
function testSloppyMode() {
- var cli = initRepl(repl.REPL_MODE_SLOPPY);
+ const cli = initRepl(repl.REPL_MODE_SLOPPY);
cli.input.emit('data', `
x = 3
`.trim() + '\n');
- assert.equal(cli.output.accumulator.join(''), '> 3\n> ');
+ assert.strictEqual(cli.output.accumulator.join(''), '> 3\n> ');
cli.output.accumulator.length = 0;
cli.input.emit('data', `
let y = 3
`.trim() + '\n');
- assert.equal(cli.output.accumulator.join(''), 'undefined\n> ');
+ assert.strictEqual(cli.output.accumulator.join(''), 'undefined\n> ');
}
function testStrictMode() {
- var cli = initRepl(repl.REPL_MODE_STRICT);
+ const cli = initRepl(repl.REPL_MODE_STRICT);
cli.input.emit('data', `
x = 3
@@ -44,30 +44,30 @@ function testStrictMode() {
cli.input.emit('data', `
let y = 3
`.trim() + '\n');
- assert.equal(cli.output.accumulator.join(''), 'undefined\n> ');
+ assert.strictEqual(cli.output.accumulator.join(''), 'undefined\n> ');
}
function testAutoMode() {
- var cli = initRepl(repl.REPL_MODE_MAGIC);
+ const cli = initRepl(repl.REPL_MODE_MAGIC);
cli.input.emit('data', `
x = 3
`.trim() + '\n');
- assert.equal(cli.output.accumulator.join(''), '> 3\n> ');
+ assert.strictEqual(cli.output.accumulator.join(''), '> 3\n> ');
cli.output.accumulator.length = 0;
cli.input.emit('data', `
let y = 3
`.trim() + '\n');
- assert.equal(cli.output.accumulator.join(''), 'undefined\n> ');
+ assert.strictEqual(cli.output.accumulator.join(''), 'undefined\n> ');
}
function initRepl(mode) {
- var input = new Stream();
+ const input = new Stream();
input.write = input.pause = input.resume = function() {};
input.readable = true;
- var output = new Stream();
+ const output = new Stream();
output.write = output.pause = output.resume = function(buf) {
output.accumulator.push(buf);
};
diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js
index 29c85e36076d..70aac915f6b5 100644
--- a/test/parallel/test-repl.js
+++ b/test/parallel/test-repl.js
@@ -1,6 +1,6 @@
/* eslint-disable max-len, strict */
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
common.globalCheck = false;
common.refreshTmpDir();
@@ -15,11 +15,11 @@ const prompt_npm = 'npm should be run outside of the ' +
'node repl, in your normal shell.\n' +
'(Press Control-D to exit.)\n';
const expect_npm = prompt_npm + prompt_unix;
-var server_tcp, server_unix, client_tcp, client_unix, replServer;
+let server_tcp, server_unix, client_tcp, client_unix, replServer;
// absolute path to test/fixtures/a.js
-var moduleFilename = require('path').join(common.fixturesDir, 'a');
+const moduleFilename = require('path').join(common.fixturesDir, 'a');
console.error('repl test');
@@ -30,7 +30,7 @@ global.invoke_me = function(arg) {
function send_expect(list) {
if (list.length > 0) {
- var cur = list.shift();
+ const cur = list.shift();
console.error('sending ' + JSON.stringify(cur.send));
@@ -56,8 +56,8 @@ function strict_mode_error_test() {
function error_test() {
// The other stuff is done so reuse unix socket
- var read_buffer = '';
- var run_strict_test = true;
+ let read_buffer = '';
+ let run_strict_test = true;
client_unix.removeAllListeners('data');
client_unix.on('data', function(data) {
@@ -70,7 +70,7 @@ function error_test() {
if (read_buffer.indexOf(prompt_unix) !== -1) {
// if it's an exact match, then don't do the regexp
if (read_buffer !== client_unix.expect) {
- var expect = client_unix.expect;
+ let expect = client_unix.expect;
if (expect === prompt_multiline)
expect = /[.]{3} /;
assert.ok(read_buffer.match(expect));
@@ -339,6 +339,29 @@ function error_test() {
// Avoid emitting stack trace
{ client: client_unix, send: 'a = 3.5e',
expect: /^(?!\s+at\s)/gm },
+
+ // https://github.com/nodejs/node/issues/9850
+ { client: client_unix, send: 'function* foo() {}; foo().next();',
+ expect: '{ value: undefined, done: true }' },
+
+ { client: client_unix, send: 'function *foo() {}; foo().next();',
+ expect: '{ value: undefined, done: true }' },
+
+ { client: client_unix, send: 'function*foo() {}; foo().next();',
+ expect: '{ value: undefined, done: true }' },
+
+ { client: client_unix, send: 'function * foo() {}; foo().next()',
+ expect: '{ value: undefined, done: true }' },
+
+ // https://github.com/nodejs/node/issues/9300
+ { client: client_unix, send: 'function foo() {\nvar bar = 1 / 1; // "/"\n}',
+ expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix },
+
+ { client: client_unix, send: '(function() {\nreturn /foo/ / /bar/;\n}())',
+ expect: prompt_multiline + prompt_multiline + 'NaN\n' + prompt_unix },
+
+ { client: client_unix, send: '(function() {\nif (false) {} /bar"/;\n}())',
+ expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix }
]);
}
@@ -354,13 +377,13 @@ function tcp_test() {
});
server_tcp.listen(0, function() {
- var read_buffer = '';
+ let read_buffer = '';
client_tcp = net.createConnection(this.address().port);
client_tcp.on('connect', function() {
- assert.equal(true, client_tcp.readable);
- assert.equal(true, client_tcp.writable);
+ assert.strictEqual(true, client_tcp.readable);
+ assert.strictEqual(true, client_tcp.writable);
send_expect([
{ client: client_tcp, send: '',
@@ -423,13 +446,13 @@ function unix_test() {
});
server_unix.on('listening', function() {
- var read_buffer = '';
+ let read_buffer = '';
client_unix = net.createConnection(common.PIPE);
client_unix.on('connect', function() {
- assert.equal(true, client_unix.readable);
- assert.equal(true, client_unix.writable);
+ assert.strictEqual(true, client_unix.readable);
+ assert.strictEqual(true, client_unix.writable);
send_expect([
{ client: client_unix, send: '',
diff --git a/test/parallel/test-require-exceptions.js b/test/parallel/test-require-exceptions.js
index 0e61ad2f3fd7..e6b7977b4877 100644
--- a/test/parallel/test-require-exceptions.js
+++ b/test/parallel/test-require-exceptions.js
@@ -1,16 +1,16 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
// A module with an error in it should throw
assert.throws(function() {
require(common.fixturesDir + '/throws_error');
-});
+}, /^Error: blah$/);
// Requiring the same module again should throw as well
assert.throws(function() {
require(common.fixturesDir + '/throws_error');
-});
+}, /^Error: blah$/);
// Requiring a module that does not exist should throw an
// error with its `code` set to MODULE_NOT_FOUND
diff --git a/test/parallel/test-require-extensions-main.js b/test/parallel/test-require-extensions-main.js
index 0376082262dd..e8420cd26cd5 100644
--- a/test/parallel/test-require-extensions-main.js
+++ b/test/parallel/test-require-extensions-main.js
@@ -1,4 +1,10 @@
'use strict';
-var common = require('../common');
+const assert = require('assert');
+const common = require('../common');
+const fixturesRequire = require(`${common.fixturesDir}/require-bin/bin/req.js`);
-require(common.fixturesDir + '/require-bin/bin/req.js');
+assert.strictEqual(
+ fixturesRequire,
+ '',
+ 'test-require-extensions-main failed to import fixture requirements'
+);
diff --git a/test/parallel/test-require-extensions-same-filename-as-dir.js b/test/parallel/test-require-extensions-same-filename-as-dir.js
index 41051dad45e1..ff95a47b9a83 100644
--- a/test/parallel/test-require-extensions-same-filename-as-dir.js
+++ b/test/parallel/test-require-extensions-same-filename-as-dir.js
@@ -1,9 +1,9 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
-var content = require(common.fixturesDir +
+const content = require(common.fixturesDir +
'/json-with-directory-name-module/module-stub/one/two/three.js');
-assert.notEqual(content.rocko, 'artischocko');
-assert.equal(content, 'hello from module-stub!');
+assert.notStrictEqual(content.rocko, 'artischocko');
+assert.strictEqual(content, 'hello from module-stub!');
diff --git a/test/parallel/test-require-json.js b/test/parallel/test-require-json.js
index 75cdb98855e6..f2c74dc57d74 100644
--- a/test/parallel/test-require-json.js
+++ b/test/parallel/test-require-json.js
@@ -1,12 +1,12 @@
'use strict';
-var common = require('../common');
-var path = require('path');
-var assert = require('assert');
+const common = require('../common');
+const path = require('path');
+const assert = require('assert');
try {
require(path.join(common.fixturesDir, 'invalid.json'));
} catch (err) {
- var re = /test[/\\]fixtures[/\\]invalid.json: Unexpected string/;
- var i = err.message.match(re);
+ const re = /test[/\\]fixtures[/\\]invalid.json: Unexpected string/;
+ const i = err.message.match(re);
assert.notStrictEqual(null, i, 'require() json error should include path');
}
diff --git a/test/parallel/test-require-resolve.js b/test/parallel/test-require-resolve.js
index 13897c74da17..202f3c5ef87f 100644
--- a/test/parallel/test-require-resolve.js
+++ b/test/parallel/test-require-resolve.js
@@ -1,18 +1,18 @@
'use strict';
-var common = require('../common');
-var fixturesDir = common.fixturesDir;
-var assert = require('assert');
-var path = require('path');
+const common = require('../common');
+const fixturesDir = common.fixturesDir;
+const assert = require('assert');
+const path = require('path');
-assert.equal(
+assert.strictEqual(
path.join(__dirname, '../fixtures/a.js').toLowerCase(),
require.resolve('../fixtures/a').toLowerCase());
-assert.equal(
+assert.strictEqual(
path.join(fixturesDir, 'a.js').toLowerCase(),
require.resolve(path.join(fixturesDir, 'a')).toLowerCase());
-assert.equal(
+assert.strictEqual(
path.join(fixturesDir, 'nested-index', 'one', 'index.js').toLowerCase(),
require.resolve('../fixtures/nested-index/one').toLowerCase());
-assert.equal('path', require.resolve('path'));
+assert.strictEqual('path', require.resolve('path'));
console.log('ok');
diff --git a/test/parallel/test-signal-unregister.js b/test/parallel/test-signal-unregister.js
index b65ade73db94..88c6a367a9cb 100644
--- a/test/parallel/test-signal-unregister.js
+++ b/test/parallel/test-signal-unregister.js
@@ -1,13 +1,13 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var spawn = require('child_process').spawn;
+const common = require('../common');
+const assert = require('assert');
+const spawn = require('child_process').spawn;
-var child = spawn(process.argv[0], [common.fixturesDir + '/should_exit.js']);
+const child = spawn(process.argv[0], [common.fixturesDir + '/should_exit.js']);
child.stdout.once('data', function() {
child.kill('SIGINT');
});
child.on('exit', common.mustCall(function(exitCode, signalCode) {
- assert.equal(exitCode, null);
- assert.equal(signalCode, 'SIGINT');
+ assert.strictEqual(exitCode, null);
+ assert.strictEqual(signalCode, 'SIGINT');
}));
diff --git a/test/parallel/test-stdout-to-file.js b/test/parallel/test-stdout-to-file.js
index 5dce369aadb5..10391c481a82 100644
--- a/test/parallel/test-stdout-to-file.js
+++ b/test/parallel/test-stdout-to-file.js
@@ -1,13 +1,14 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var path = require('path');
-var childProcess = require('child_process');
-var fs = require('fs');
+const common = require('../common');
+const assert = require('assert');
+const path = require('path');
+const childProcess = require('child_process');
+const fs = require('fs');
-var scriptString = path.join(common.fixturesDir, 'print-chars.js');
-var scriptBuffer = path.join(common.fixturesDir, 'print-chars-from-buffer.js');
-var tmpFile = path.join(common.tmpDir, 'stdout.txt');
+const scriptString = path.join(common.fixturesDir, 'print-chars.js');
+const scriptBuffer = path.join(common.fixturesDir,
+ 'print-chars-from-buffer.js');
+const tmpFile = path.join(common.tmpDir, 'stdout.txt');
common.refreshTmpDir();
@@ -24,22 +25,22 @@ function test(size, useBuffer, cb) {
fs.unlinkSync(tmpFile);
} catch (e) {}
- console.log(size + ' chars to ' + tmpFile + '...');
+ console.log(`${size} chars to ${tmpFile}...`);
- childProcess.exec(cmd, function(err) {
+ childProcess.exec(cmd, common.mustCall(function(err) {
if (err) throw err;
console.log('done!');
var stat = fs.statSync(tmpFile);
- console.log(tmpFile + ' has ' + stat.size + ' bytes');
+ console.log(`${tmpFile} has ${stat.size} bytes`);
- assert.equal(size, stat.size);
+ assert.strictEqual(size, stat.size);
fs.unlinkSync(tmpFile);
cb();
- });
+ }));
}
test(1024 * 1024, false, common.mustCall(function() {
diff --git a/test/parallel/test-stream-pipe-unpipe-streams.js b/test/parallel/test-stream-pipe-unpipe-streams.js
index c51c100d0f68..79719add3700 100644
--- a/test/parallel/test-stream-pipe-unpipe-streams.js
+++ b/test/parallel/test-stream-pipe-unpipe-streams.js
@@ -25,6 +25,9 @@ source.unpipe(dest2);
assert.strictEqual(source._readableState.pipes, dest1);
assert.notStrictEqual(source._readableState.pipes, dest2);
+dest2.on('unpipe', common.fail);
+source.unpipe(dest2);
+
source.unpipe(dest1);
assert.strictEqual(source._readableState.pipes, null);
diff --git a/test/parallel/test-timers-clear-null-does-not-throw-error.js b/test/parallel/test-timers-clear-null-does-not-throw-error.js
new file mode 100644
index 000000000000..a15072a4c63f
--- /dev/null
+++ b/test/parallel/test-timers-clear-null-does-not-throw-error.js
@@ -0,0 +1,18 @@
+'use strict';
+require('../common');
+const assert = require('assert');
+
+// This test makes sure clearing timers with
+// 'null' or no input does not throw error
+
+assert.doesNotThrow(() => clearInterval(null));
+
+assert.doesNotThrow(() => clearInterval());
+
+assert.doesNotThrow(() => clearTimeout(null));
+
+assert.doesNotThrow(() => clearTimeout());
+
+assert.doesNotThrow(() => clearImmediate(null));
+
+assert.doesNotThrow(() => clearImmediate());
diff --git a/test/parallel/test-tls-client-reject.js b/test/parallel/test-tls-client-reject.js
index 1b33f5525dc4..5868472c1215 100644
--- a/test/parallel/test-tls-client-reject.js
+++ b/test/parallel/test-tls-client-reject.js
@@ -1,64 +1,64 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
-var path = require('path');
+const fs = require('fs');
+const path = require('path');
-var options = {
+const options = {
key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')),
cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))
};
-var server = tls.createServer(options, common.mustCall(function(socket) {
+const server = tls.createServer(options, common.mustCall(function(socket) {
socket.on('data', function(data) {
console.error(data.toString());
- assert.equal(data, 'ok');
+ assert.strictEqual(data.toString(), 'ok');
});
}, 3)).listen(0, function() {
unauthorized();
});
function unauthorized() {
- var socket = tls.connect({
+ const socket = tls.connect({
port: server.address().port,
servername: 'localhost',
rejectUnauthorized: false
- }, function() {
+ }, common.mustCall(function() {
assert(!socket.authorized);
socket.end();
rejectUnauthorized();
- });
+ }));
socket.on('error', common.fail);
socket.write('ok');
}
function rejectUnauthorized() {
- var socket = tls.connect(server.address().port, {
+ const socket = tls.connect(server.address().port, {
servername: 'localhost'
}, common.fail);
- socket.on('error', function(err) {
+ socket.on('error', common.mustCall(function(err) {
console.error(err);
authorized();
- });
+ }));
socket.write('ng');
}
function authorized() {
- var socket = tls.connect(server.address().port, {
+ const socket = tls.connect(server.address().port, {
ca: [fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))],
servername: 'localhost'
- }, function() {
+ }, common.mustCall(function() {
assert(socket.authorized);
socket.end();
server.close();
- });
+ }));
socket.on('error', common.fail);
socket.write('ok');
}
diff --git a/test/parallel/test-tls-connect-address-family.js b/test/parallel/test-tls-connect-address-family.js
index 35216d91f6e4..f22831f395a8 100644
--- a/test/parallel/test-tls-connect-address-family.js
+++ b/test/parallel/test-tls-connect-address-family.js
@@ -18,10 +18,10 @@ function runTest() {
const ciphers = 'AECDH-NULL-SHA';
tls.createServer({ ciphers }, common.mustCall(function() {
this.close();
- })).listen(common.PORT, '::1', common.mustCall(function() {
+ })).listen(0, '::1', common.mustCall(function() {
const options = {
host: 'localhost',
- port: common.PORT,
+ port: this.address().port,
family: 6,
ciphers: ciphers,
rejectUnauthorized: false,
diff --git a/test/parallel/test-tls-connect-simple.js b/test/parallel/test-tls-connect-simple.js
index 5b18f7693ff7..a6bcfcab519f 100644
--- a/test/parallel/test-tls-connect-simple.js
+++ b/test/parallel/test-tls-connect-simple.js
@@ -1,58 +1,43 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
+const fs = require('fs');
-var clientConnected = 0;
-var serverConnected = 0;
-var serverCloseCallbacks = 0;
-var serverCloseEvents = 0;
+let serverConnected = 0;
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
-var server = tls.Server(options, function(socket) {
+const server = tls.Server(options, common.mustCall(function(socket) {
if (++serverConnected === 2) {
- server.close(function() {
- ++serverCloseCallbacks;
- });
- server.on('close', function() {
- ++serverCloseEvents;
- });
+ server.close(common.mustCall(function() {}));
+ server.on('close', common.mustCall(function() {}));
}
-});
+}, 2));
server.listen(0, function() {
- var client1 = tls.connect({
+ const client1options = {
port: this.address().port,
rejectUnauthorized: false
- }, function() {
- ++clientConnected;
+ };
+ const client1 = tls.connect(client1options, common.mustCall(function() {
client1.end();
- });
+ }));
- var client2 = tls.connect({
+ const client2options = {
port: this.address().port,
rejectUnauthorized: false
- });
- client2.on('secureConnect', function() {
- ++clientConnected;
+ };
+ const client2 = tls.connect(client2options);
+ client2.on('secureConnect', common.mustCall(function() {
client2.end();
- });
-});
-
-process.on('exit', function() {
- assert.equal(clientConnected, 2);
- assert.equal(serverConnected, 2);
- assert.equal(serverCloseCallbacks, 1);
- assert.equal(serverCloseEvents, 1);
+ }));
});
diff --git a/test/parallel/test-tls-destroy-whilst-write.js b/test/parallel/test-tls-destroy-whilst-write.js
index 4f6ede968be4..b4f9766d9986 100644
--- a/test/parallel/test-tls-destroy-whilst-write.js
+++ b/test/parallel/test-tls-destroy-whilst-write.js
@@ -1,26 +1,26 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
-var stream = require('stream');
+const tls = require('tls');
+const stream = require('stream');
-var delay = new stream.Duplex({
+const delay = new stream.Duplex({
read: function read() {
},
write: function write(data, enc, cb) {
console.log('pending');
- setTimeout(function() {
+ setImmediate(function() {
console.log('done');
cb();
- }, 200);
+ });
}
});
-var secure = tls.connect({
+const secure = tls.connect({
socket: delay
});
setImmediate(function() {
diff --git a/test/parallel/test-tls-ecdh.js b/test/parallel/test-tls-ecdh.js
index e37552247ebd..99c6e108ab73 100644
--- a/test/parallel/test-tls-ecdh.js
+++ b/test/parallel/test-tls-ecdh.js
@@ -1,31 +1,31 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const assert = require('assert');
+const tls = require('tls');
-var exec = require('child_process').exec;
-var fs = require('fs');
+const exec = require('child_process').exec;
+const fs = require('fs');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem'),
ciphers: '-ALL:ECDHE-RSA-AES128-SHA256',
ecdhCurve: 'prime256v1'
};
-var reply = 'I AM THE WALRUS'; // something recognizable
+const reply = 'I AM THE WALRUS'; // something recognizable
-var server = tls.createServer(options, common.mustCall(function(conn) {
+const server = tls.createServer(options, common.mustCall(function(conn) {
conn.end(reply);
}));
server.listen(0, '127.0.0.1', common.mustCall(function() {
- var cmd = '"' + common.opensslCli + '" s_client -cipher ' + options.ciphers +
+ let cmd = '"' + common.opensslCli + '" s_client -cipher ' + options.ciphers +
` -connect 127.0.0.1:${this.address().port}`;
// for the performance and stability issue in s_client on Windows
@@ -34,7 +34,7 @@ server.listen(0, '127.0.0.1', common.mustCall(function() {
exec(cmd, common.mustCall(function(err, stdout, stderr) {
if (err) throw err;
- assert.notEqual(stdout.indexOf(reply), -1);
+ assert(stdout.includes(reply));
server.close();
}));
}));
diff --git a/test/parallel/test-tls-friendly-error-message.js b/test/parallel/test-tls-friendly-error-message.js
index c53dd7cbc072..9ae69f4016e3 100644
--- a/test/parallel/test-tls-friendly-error-message.js
+++ b/test/parallel/test-tls-friendly-error-message.js
@@ -1,26 +1,26 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
+const fs = require('fs');
-var key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem');
-var cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem');
+const key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem');
+const cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem');
-tls.createServer({ key: key, cert: cert }, function(conn) {
+tls.createServer({ key: key, cert: cert }, common.mustCall(function(conn) {
conn.end();
this.close();
-}).listen(0, function() {
+})).listen(0, common.mustCall(function() {
var options = { port: this.address().port, rejectUnauthorized: true };
tls.connect(options).on('error', common.mustCall(function(err) {
- assert.equal(err.code, 'UNABLE_TO_VERIFY_LEAF_SIGNATURE');
- assert.equal(err.message, 'unable to verify the first certificate');
+ assert.strictEqual(err.code, 'UNABLE_TO_VERIFY_LEAF_SIGNATURE');
+ assert.strictEqual(err.message, 'unable to verify the first certificate');
this.destroy();
}));
-});
+}));
diff --git a/test/parallel/test-tls-getcipher.js b/test/parallel/test-tls-getcipher.js
index 4ecacb1e9f2f..b5205d48778f 100644
--- a/test/parallel/test-tls-getcipher.js
+++ b/test/parallel/test-tls-getcipher.js
@@ -1,37 +1,37 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const assert = require('assert');
+const tls = require('tls');
-var fs = require('fs');
-var cipher_list = ['AES128-SHA256', 'AES256-SHA256'];
-var cipher_version_pattern = /TLS|SSL/;
-var options = {
+const fs = require('fs');
+const cipher_list = ['AES128-SHA256', 'AES256-SHA256'];
+const cipher_version_pattern = /TLS|SSL/;
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem'),
ciphers: cipher_list.join(':'),
honorCipherOrder: true
};
-var server = tls.createServer(options,
- common.mustCall(function(cleartextStream) {}));
+const server = tls.createServer(options,
+ common.mustCall(function(cleartextStream) {}));
-server.listen(0, '127.0.0.1', function() {
- var client = tls.connect({
+server.listen(0, '127.0.0.1', common.mustCall(function() {
+ const client = tls.connect({
host: '127.0.0.1',
port: this.address().port,
ciphers: cipher_list.join(':'),
rejectUnauthorized: false
- }, function() {
- var cipher = client.getCipher();
- assert.equal(cipher.name, cipher_list[0]);
+ }, common.mustCall(function() {
+ const cipher = client.getCipher();
+ assert.strictEqual(cipher.name, cipher_list[0]);
assert(cipher_version_pattern.test(cipher.version));
client.end();
server.close();
- });
-});
+ }));
+}));
diff --git a/test/parallel/test-tls-hello-parser-failure.js b/test/parallel/test-tls-hello-parser-failure.js
index e5e43c408abf..f9c280f5e57a 100644
--- a/test/parallel/test-tls-hello-parser-failure.js
+++ b/test/parallel/test-tls-hello-parser-failure.js
@@ -1,46 +1,43 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
-var net = require('net');
-var fs = require('fs');
+const assert = require('assert');
+const tls = require('tls');
+
+const net = require('net');
+const fs = require('fs');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/test_key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/test_cert.pem')
};
-var bonkers = Buffer.alloc(1024 * 1024, 42);
+const bonkers = Buffer.alloc(1024 * 1024, 42);
-var server = tls.createServer(options, function(c) {
+const server = tls.createServer(options, function(c) {
-}).listen(0, function() {
- var client = net.connect(this.address().port, function() {
+}).listen(0, common.mustCall(function() {
+ const client = net.connect(this.address().port, common.mustCall(function() {
client.write(bonkers);
- });
+ }));
- var once = false;
-
- var writeAgain = setTimeout(function() {
+ const writeAgain = setImmediate(function() {
client.write(bonkers);
});
- client.on('error', function(err) {
- if (!once) {
- clearTimeout(writeAgain);
- once = true;
- client.destroy();
- server.close();
- }
- });
+ client.once('error', common.mustCall(function(err) {
+ clearImmediate(writeAgain);
+ client.destroy();
+ server.close();
+ }));
- client.on('close', function(hadError) {
+ client.on('close', common.mustCall(function(hadError) {
assert.strictEqual(hadError, true, 'Client never errored');
- });
-});
+ }));
+}));
diff --git a/test/parallel/test-tls-junk-closes-server.js b/test/parallel/test-tls-junk-closes-server.js
index f12393515cbe..38f90498f84e 100644
--- a/test/parallel/test-tls-junk-closes-server.js
+++ b/test/parallel/test-tls-junk-closes-server.js
@@ -1,34 +1,30 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
-var fs = require('fs');
-var net = require('net');
+const tls = require('tls');
+const fs = require('fs');
+const net = require('net');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem')
};
-var server = tls.createServer(options, function(s) {
- s.write('welcome!\n');
- s.pipe(s);
-});
+const server = tls.createServer(options, common.fail);
-server.listen(0, function() {
- var c = net.createConnection(this.address().port);
+server.listen(0, common.mustCall(function() {
+ const c = net.createConnection(this.address().port);
- c.on('connect', function() {
+ c.on('connect', common.mustCall(function() {
c.write('blah\nblah\nblah\n');
- });
+ }));
- c.on('end', function() {
+ c.on('end', common.mustCall(function() {
server.close();
- });
-
-});
+ }));
+}));
diff --git a/test/parallel/test-tls-key-mismatch.js b/test/parallel/test-tls-key-mismatch.js
index f0eb8121bd68..65cac6f07a29 100644
--- a/test/parallel/test-tls-key-mismatch.js
+++ b/test/parallel/test-tls-key-mismatch.js
@@ -1,15 +1,15 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
-var fs = require('fs');
+const assert = require('assert');
+const tls = require('tls');
+const fs = require('fs');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem')
};
diff --git a/test/parallel/test-tls-no-sslv3.js b/test/parallel/test-tls-no-sslv3.js
index c284356ce37b..16a722ef85b9 100644
--- a/test/parallel/test-tls-no-sslv3.js
+++ b/test/parallel/test-tls-no-sslv3.js
@@ -1,30 +1,30 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
-var spawn = require('child_process').spawn;
+const fs = require('fs');
+const spawn = require('child_process').spawn;
if (common.opensslCli === false) {
common.skip('node compiled without OpenSSL CLI.');
return;
}
-var cert = fs.readFileSync(common.fixturesDir + '/test_cert.pem');
-var key = fs.readFileSync(common.fixturesDir + '/test_key.pem');
-var server = tls.createServer({ cert: cert, key: key }, common.fail);
-var errors = [];
-var stderr = '';
+const cert = fs.readFileSync(common.fixturesDir + '/test_cert.pem');
+const key = fs.readFileSync(common.fixturesDir + '/test_key.pem');
+const server = tls.createServer({ cert: cert, key: key }, common.fail);
+const errors = [];
+let stderr = '';
server.listen(0, '127.0.0.1', function() {
- var address = this.address().address + ':' + this.address().port;
- var args = ['s_client',
+ const address = this.address().address + ':' + this.address().port;
+ const args = ['s_client',
'-ssl3',
'-connect', address];
@@ -32,14 +32,14 @@ server.listen(0, '127.0.0.1', function() {
if (common.isWindows)
args.push('-no_rand_screen');
- var client = spawn(common.opensslCli, args, { stdio: 'pipe' });
+ const client = spawn(common.opensslCli, args, { stdio: 'pipe' });
client.stdout.pipe(process.stdout);
client.stderr.pipe(process.stderr);
client.stderr.setEncoding('utf8');
client.stderr.on('data', (data) => stderr += data);
client.once('exit', common.mustCall(function(exitCode) {
- assert.equal(exitCode, 1);
+ assert.strictEqual(exitCode, 1);
server.close();
}));
});
@@ -50,7 +50,7 @@ process.on('exit', function() {
if (/unknown option -ssl3/.test(stderr)) {
common.skip('`openssl s_client -ssl3` not supported.');
} else {
- assert.equal(errors.length, 1);
+ assert.strictEqual(errors.length, 1);
assert(/:wrong version number/.test(errors[0].message));
}
});
diff --git a/test/parallel/test-tls-ocsp-callback.js b/test/parallel/test-tls-ocsp-callback.js
index 442f54791a0f..c008613c2ccf 100644
--- a/test/parallel/test-tls-ocsp-callback.js
+++ b/test/parallel/test-tls-ocsp-callback.js
@@ -1,5 +1,5 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
if (!process.features.tls_ocsp) {
common.skip('node compiled without OpenSSL or ' +
@@ -15,33 +15,33 @@ if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var assert = require('assert');
-var fs = require('fs');
-var join = require('path').join;
+const assert = require('assert');
+const fs = require('fs');
+const join = require('path').join;
const SSL_OP_NO_TICKET = require('crypto').constants.SSL_OP_NO_TICKET;
-var pfx = fs.readFileSync(join(common.fixturesDir, 'keys', 'agent1-pfx.pem'));
+const pfx = fs.readFileSync(join(common.fixturesDir, 'keys', 'agent1-pfx.pem'));
function test(testOptions, cb) {
- var keyFile = join(common.fixturesDir, 'keys', 'agent1-key.pem');
- var certFile = join(common.fixturesDir, 'keys', 'agent1-cert.pem');
- var caFile = join(common.fixturesDir, 'keys', 'ca1-cert.pem');
- var key = fs.readFileSync(keyFile);
- var cert = fs.readFileSync(certFile);
- var ca = fs.readFileSync(caFile);
- var options = {
+ const keyFile = join(common.fixturesDir, 'keys', 'agent1-key.pem');
+ const certFile = join(common.fixturesDir, 'keys', 'agent1-cert.pem');
+ const caFile = join(common.fixturesDir, 'keys', 'ca1-cert.pem');
+ const key = fs.readFileSync(keyFile);
+ const cert = fs.readFileSync(certFile);
+ const ca = fs.readFileSync(caFile);
+ const options = {
key: key,
cert: cert,
ca: [ca]
};
- var requestCount = 0;
- var clientSecure = 0;
- var ocspCount = 0;
- var ocspResponse;
+ let requestCount = 0;
+ let clientSecure = 0;
+ let ocspCount = 0;
+ let ocspResponse;
if (testOptions.pfx) {
delete options.key;
@@ -50,7 +50,7 @@ function test(testOptions, cb) {
options.passphrase = testOptions.passphrase;
}
- var server = tls.createServer(options, function(cleartext) {
+ const server = tls.createServer(options, function(cleartext) {
cleartext.on('error', function(er) {
// We're ok with getting ECONNRESET in this test, but it's
// timing-dependent, and thus unreliable. Any other errors
@@ -73,7 +73,7 @@ function test(testOptions, cb) {
}, 100);
});
server.listen(0, function() {
- var client = tls.connect({
+ const client = tls.connect({
port: this.address().port,
requestOCSP: testOptions.ocsp !== false,
secureOptions: testOptions.ocsp === false ?
@@ -94,23 +94,23 @@ function test(testOptions, cb) {
process.on('exit', function() {
if (testOptions.ocsp === false) {
- assert.equal(requestCount, clientSecure);
- assert.equal(requestCount, 1);
+ assert.strictEqual(requestCount, clientSecure);
+ assert.strictEqual(requestCount, 1);
return;
}
if (testOptions.response) {
- assert.equal(ocspResponse.toString(), testOptions.response);
+ assert.strictEqual(ocspResponse.toString(), testOptions.response);
} else {
- assert.ok(ocspResponse === null);
+ assert.strictEqual(ocspResponse, null);
}
- assert.equal(requestCount, testOptions.response ? 0 : 1);
- assert.equal(clientSecure, requestCount);
- assert.equal(ocspCount, 1);
+ assert.strictEqual(requestCount, testOptions.response ? 0 : 1);
+ assert.strictEqual(clientSecure, requestCount);
+ assert.strictEqual(ocspCount, 1);
});
}
-var tests = [
+const tests = [
{ response: false },
{ response: 'hello world' },
{ ocsp: false }
diff --git a/test/parallel/test-tls-peer-certificate.js b/test/parallel/test-tls-peer-certificate.js
index 59d1a4fdbccc..ddbbf72a6309 100644
--- a/test/parallel/test-tls-peer-certificate.js
+++ b/test/parallel/test-tls-peer-certificate.js
@@ -1,32 +1,32 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
-var util = require('util');
-var join = require('path').join;
+const fs = require('fs');
+const util = require('util');
+const join = require('path').join;
-var options = {
+const options = {
key: fs.readFileSync(join(common.fixturesDir, 'keys', 'agent1-key.pem')),
cert: fs.readFileSync(join(common.fixturesDir, 'keys', 'agent1-cert.pem')),
ca: [ fs.readFileSync(join(common.fixturesDir, 'keys', 'ca1-cert.pem')) ]
};
-var server = tls.createServer(options, function(cleartext) {
+const server = tls.createServer(options, function(cleartext) {
cleartext.end('World');
});
server.listen(0, common.mustCall(function() {
- var socket = tls.connect({
+ const socket = tls.connect({
port: this.address().port,
rejectUnauthorized: false
}, common.mustCall(function() {
- var peerCert = socket.getPeerCertificate();
+ let peerCert = socket.getPeerCertificate();
assert.ok(!peerCert.issuerCertificate);
// Verify that detailed return value has all certs
@@ -34,17 +34,19 @@ server.listen(0, common.mustCall(function() {
assert.ok(peerCert.issuerCertificate);
console.error(util.inspect(peerCert));
- assert.equal(peerCert.subject.emailAddress, 'ry@tinyclouds.org');
- assert.equal(peerCert.serialNumber, '9A84ABCFB8A72AC0');
- assert.equal(peerCert.exponent, '0x10001');
- assert.equal(peerCert.fingerprint,
- '8D:06:3A:B3:E5:8B:85:29:72:4F:7D:1B:54:CD:95:19:3C:EF:6F:AA');
+ assert.strictEqual(peerCert.subject.emailAddress, 'ry@tinyclouds.org');
+ assert.strictEqual(peerCert.serialNumber, '9A84ABCFB8A72AC0');
+ assert.strictEqual(peerCert.exponent, '0x10001');
+ assert.strictEqual(
+ peerCert.fingerprint,
+ '8D:06:3A:B3:E5:8B:85:29:72:4F:7D:1B:54:CD:95:19:3C:EF:6F:AA'
+ );
assert.deepStrictEqual(peerCert.infoAccess['OCSP - URI'],
[ 'http://ocsp.nodejs.org/' ]);
- var issuer = peerCert.issuerCertificate;
- assert.ok(issuer.issuerCertificate === issuer);
- assert.equal(issuer.serialNumber, '8DF21C01468AF393');
+ const issuer = peerCert.issuerCertificate;
+ assert.strictEqual(issuer.issuerCertificate, issuer);
+ assert.strictEqual(issuer.serialNumber, '8DF21C01468AF393');
server.close();
}));
socket.end('Hello');
diff --git a/test/parallel/test-tls-server-verify.js b/test/parallel/test-tls-server-verify.js
index a51aef515646..04c1547384c6 100644
--- a/test/parallel/test-tls-server-verify.js
+++ b/test/parallel/test-tls-server-verify.js
@@ -1,5 +1,5 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
if (!common.opensslCli) {
common.skip('node compiled without OpenSSL CLI.');
@@ -14,7 +14,7 @@ if (!common.opensslCli) {
// - accepted and "unauthorized", or
// - accepted and "authorized".
-var testCases =
+const testCases =
[{ title: 'Do not request certs. Everyone is unauthorized.',
requestCert: false,
rejectUnauthorized: false,
@@ -102,14 +102,14 @@ if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION =
require('crypto').constants.SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION;
-var assert = require('assert');
-var fs = require('fs');
-var spawn = require('child_process').spawn;
+const assert = require('assert');
+const fs = require('fs');
+const spawn = require('child_process').spawn;
function filenamePEM(n) {
@@ -122,8 +122,8 @@ function loadPEM(n) {
}
-var serverKey = loadPEM('agent2-key');
-var serverCert = loadPEM('agent2-cert');
+const serverKey = loadPEM('agent2-key');
+const serverCert = loadPEM('agent2-cert');
function runClient(prefix, port, options, cb) {
@@ -133,7 +133,7 @@ function runClient(prefix, port, options, cb) {
// - Certificate, but not signed by CA.
// - Certificate signed by CA.
- var args = ['s_client', '-connect', '127.0.0.1:' + port];
+ const args = ['s_client', '-connect', '127.0.0.1:' + port];
// for the performance issue in s_client on Windows
if (common.isWindows)
@@ -184,13 +184,13 @@ function runClient(prefix, port, options, cb) {
}
// To test use: openssl s_client -connect localhost:8000
- var client = spawn(common.opensslCli, args);
+ const client = spawn(common.opensslCli, args);
- var out = '';
+ let out = '';
- var rejected = true;
- var authed = false;
- var goodbye = false;
+ let rejected = true;
+ let authed = false;
+ let goodbye = false;
client.stdout.setEncoding('utf8');
client.stdout.on('data', function(d) {
@@ -219,12 +219,12 @@ function runClient(prefix, port, options, cb) {
//assert.equal(0, code, prefix + options.name +
// ": s_client exited with error code " + code);
if (options.shouldReject) {
- assert.equal(true, rejected, prefix + options.name +
+ assert.strictEqual(true, rejected, prefix + options.name +
' NOT rejected, but should have been');
} else {
- assert.equal(false, rejected, prefix + options.name +
+ assert.strictEqual(false, rejected, prefix + options.name +
' rejected, but should NOT have been');
- assert.equal(options.shouldAuth, authed, prefix +
+ assert.strictEqual(options.shouldAuth, authed, prefix +
options.name + ' authed is ' + authed +
' but should have been ' + options.shouldAuth);
}
@@ -235,19 +235,19 @@ function runClient(prefix, port, options, cb) {
// Run the tests
-var successfulTests = 0;
+let successfulTests = 0;
function runTest(port, testIndex) {
- var prefix = testIndex + ' ';
- var tcase = testCases[testIndex];
+ const prefix = testIndex + ' ';
+ const tcase = testCases[testIndex];
if (!tcase) return;
console.error(prefix + "Running '%s'", tcase.title);
- var cas = tcase.CAs.map(loadPEM);
+ const cas = tcase.CAs.map(loadPEM);
- var crl = tcase.crl ? loadPEM(tcase.crl) : null;
+ const crl = tcase.crl ? loadPEM(tcase.crl) : null;
- var serverOptions = {
+ const serverOptions = {
key: serverKey,
cert: serverCert,
ca: cas,
@@ -265,8 +265,8 @@ function runTest(port, testIndex) {
SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION;
}
- var renegotiated = false;
- var server = tls.Server(serverOptions, function handleConnection(c) {
+ let renegotiated = false;
+ const server = tls.Server(serverOptions, function handleConnection(c) {
c.on('error', function(e) {
// child.kill() leads ECONNRESET errro in the TLS connection of
// openssl s_client via spawn(). A Test result is already
@@ -301,7 +301,7 @@ function runTest(port, testIndex) {
});
function runNextClient(clientIndex) {
- var options = tcase.clients[clientIndex];
+ const options = tcase.clients[clientIndex];
if (options) {
runClient(prefix + clientIndex + ' ', port, options, function() {
runNextClient(clientIndex + 1);
@@ -321,8 +321,8 @@ function runTest(port, testIndex) {
if (tcase.renegotiate) {
runNextClient(0);
} else {
- var clientsCompleted = 0;
- for (var i = 0; i < tcase.clients.length; i++) {
+ let clientsCompleted = 0;
+ for (let i = 0; i < tcase.clients.length; i++) {
runClient(prefix + i + ' ', port, tcase.clients[i], function() {
clientsCompleted++;
if (clientsCompleted === tcase.clients.length) {
@@ -338,11 +338,11 @@ function runTest(port, testIndex) {
}
-var nextTest = 0;
+let nextTest = 0;
runTest(0, nextTest++);
runTest(0, nextTest++);
process.on('exit', function() {
- assert.equal(successfulTests, testCases.length);
+ assert.strictEqual(successfulTests, testCases.length);
});
diff --git a/test/parallel/test-tls-set-ciphers.js b/test/parallel/test-tls-set-ciphers.js
index 4d9274b18423..5a85e3b22e4c 100644
--- a/test/parallel/test-tls-set-ciphers.js
+++ b/test/parallel/test-tls-set-ciphers.js
@@ -1,5 +1,5 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
if (!common.opensslCli) {
common.skip('node compiled without OpenSSL CLI.');
@@ -11,25 +11,25 @@ if (!common.hasCrypto) {
return;
}
-var assert = require('assert');
-var exec = require('child_process').exec;
-var tls = require('tls');
-var fs = require('fs');
+const assert = require('assert');
+const exec = require('child_process').exec;
+const tls = require('tls');
+const fs = require('fs');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem'),
ciphers: 'DES-CBC3-SHA'
};
-var reply = 'I AM THE WALRUS'; // something recognizable
-var response = '';
+const reply = 'I AM THE WALRUS'; // something recognizable
+let response = '';
process.on('exit', function() {
assert.notEqual(response.indexOf(reply), -1);
});
-var server = tls.createServer(options, common.mustCall(function(conn) {
+const server = tls.createServer(options, common.mustCall(function(conn) {
conn.end(reply);
}));
diff --git a/test/parallel/test-tls-set-encoding.js b/test/parallel/test-tls-set-encoding.js
index 013a5799fa1a..5eb58132bc2b 100644
--- a/test/parallel/test-tls-set-encoding.js
+++ b/test/parallel/test-tls-set-encoding.js
@@ -1,38 +1,41 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
+const fs = require('fs');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem')
};
-var message = 'hello world\n';
+// Contains a UTF8 only character
+const messageUtf8 = 'x√ab c';
+// The same string above represented with ASCII
+const messageAscii = 'xb\b\u001aab c';
-var server = tls.Server(options, common.mustCall(function(socket) {
- socket.end(message);
+const server = tls.Server(options, common.mustCall(function(socket) {
+ socket.end(messageUtf8);
}));
server.listen(0, function() {
- var client = tls.connect({
+ const client = tls.connect({
port: this.address().port,
rejectUnauthorized: false
});
- var buffer = '';
+ let buffer = '';
- client.setEncoding('utf8');
+ client.setEncoding('ascii');
client.on('data', function(d) {
assert.ok(typeof d === 'string');
@@ -44,10 +47,16 @@ server.listen(0, function() {
// readyState is deprecated but we want to make
// sure this isn't triggering an assert in lib/net.js
// See issue #1069.
- assert.equal('closed', client.readyState);
+ assert.strictEqual('closed', client.readyState);
+
+ // Confirming the buffer string is encoded in ASCII
+ // and thus does NOT match the UTF8 string
+ assert.notStrictEqual(buffer, messageUtf8);
+
+ // Confirming the buffer string is encoded in ASCII
+ // and thus does equal the ASCII string representation
+ assert.strictEqual(buffer, messageAscii);
- assert.equal(buffer, message);
- console.log(message);
server.close();
});
});
diff --git a/test/parallel/test-tls-timeout-server-2.js b/test/parallel/test-tls-timeout-server-2.js
index a054f41f6234..1613e9fc4e06 100644
--- a/test/parallel/test-tls-timeout-server-2.js
+++ b/test/parallel/test-tls-timeout-server-2.js
@@ -1,32 +1,32 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
+const fs = require('fs');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
-var server = tls.createServer(options, function(cleartext) {
- var s = cleartext.setTimeout(50, function() {
+const server = tls.createServer(options, common.mustCall(function(cleartext) {
+ const s = cleartext.setTimeout(50, function() {
cleartext.destroy();
server.close();
});
assert.ok(s instanceof tls.TLSSocket);
-});
+}));
-server.listen(0, function() {
+server.listen(0, common.mustCall(function() {
tls.connect({
host: '127.0.0.1',
port: this.address().port,
rejectUnauthorized: false
});
-});
+}));
diff --git a/test/parallel/test-tls-timeout-server.js b/test/parallel/test-tls-timeout-server.js
index f72f39b392e2..72ee6d016294 100644
--- a/test/parallel/test-tls-timeout-server.js
+++ b/test/parallel/test-tls-timeout-server.js
@@ -1,28 +1,28 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var net = require('net');
-var fs = require('fs');
+const net = require('net');
+const fs = require('fs');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'),
handshakeTimeout: 50
};
-var server = tls.createServer(options, common.fail);
+const server = tls.createServer(options, common.fail);
server.on('tlsClientError', common.mustCall(function(err, conn) {
conn.destroy();
server.close();
}));
-server.listen(0, function() {
+server.listen(0, common.mustCall(function() {
net.connect({ host: '127.0.0.1', port: this.address().port });
-});
+}));
diff --git a/test/parallel/test-url-domain-ascii-unicode.js b/test/parallel/test-url-domain-ascii-unicode.js
new file mode 100644
index 000000000000..f9a6be462504
--- /dev/null
+++ b/test/parallel/test-url-domain-ascii-unicode.js
@@ -0,0 +1,27 @@
+'use strict';
+
+require('../common');
+const strictEqual = require('assert').strictEqual;
+const url = require('url');
+
+const domainToASCII = url.URL.domainToASCII;
+const domainToUnicode = url.URL.domainToUnicode;
+
+const domainWithASCII = [
+ ['ıídيٴ', 'xn--d-iga7ro0q9f'],
+ ['www.ϧƽəʐ.com', 'www.xn--cja62apfr6c.com'],
+ ['новини.com', 'xn--b1amarcd.com'],
+ ['名がドメイン.com', 'xn--v8jxj3d1dzdz08w.com'],
+ ['افغانستا.icom.museum', 'xn--mgbaal8b0b9b2b.icom.museum'],
+ ['الجزائر.icom.fake', 'xn--lgbbat1ad8j.icom.fake'],
+ ['भारत.org', 'xn--h2brj9c.org']
+];
+
+domainWithASCII.forEach((pair) => {
+ const domain = pair[0];
+ const ascii = pair[1];
+ const domainConvertedToASCII = domainToASCII(domain);
+ strictEqual(domainConvertedToASCII, ascii);
+ const asciiConvertedToUnicode = domainToUnicode(ascii);
+ strictEqual(asciiConvertedToUnicode, domain);
+});
diff --git a/test/parallel/test-url.js b/test/parallel/test-url.js
index 8bbc71947323..c97caa36429a 100644
--- a/test/parallel/test-url.js
+++ b/test/parallel/test-url.js
@@ -834,6 +834,20 @@ var parseTests = {
query: '@c'
},
+ 'http://a.b/\tbc\ndr\ref g"hq\'j?mn\\op^q=r`99{st|uv}wz': {
+ protocol: 'http:',
+ slashes: true,
+ host: 'a.b',
+ port: null,
+ hostname: 'a.b',
+ hash: null,
+ pathname: '/%09bc%0Adr%0Def%20g%22hq%27j%3Ckl%3E',
+ path: '/%09bc%0Adr%0Def%20g%22hq%27j%3Ckl%3E?mn%5Cop%5Eq=r%6099%7Bst%7Cuv%7Dwz',
+ search: '?mn%5Cop%5Eq=r%6099%7Bst%7Cuv%7Dwz',
+ query: 'mn%5Cop%5Eq=r%6099%7Bst%7Cuv%7Dwz',
+ href: 'http://a.b/%09bc%0Adr%0Def%20g%22hq%27j%3Ckl%3E?mn%5Cop%5Eq=r%6099%7Bst%7Cuv%7Dwz'
+ },
+
'http://a\r" \t\n<\'b:b@c\r\nd/e?f': {
protocol: 'http:',
slashes: true,
diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js
index f730ec1c9830..1118065f1a09 100644
--- a/test/parallel/test-util-inspect.js
+++ b/test/parallel/test-util-inspect.js
@@ -143,12 +143,12 @@ for (const showHidden of [true, false]) {
assert.strictEqual(
util.inspect(array, true),
`${constructor.name} [\n` +
- ` 65,\n` +
- ` 97,\n` +
+ ' 65,\n' +
+ ' 97,\n' +
` [BYTES_PER_ELEMENT]: ${constructor.BYTES_PER_ELEMENT},\n` +
` [length]: ${length},\n` +
` [byteLength]: ${byteLength},\n` +
- ` [byteOffset]: 0,\n` +
+ ' [byteOffset]: 0,\n' +
` [buffer]: ArrayBuffer { byteLength: ${byteLength} } ]`);
assert.strictEqual(
util.inspect(array, false),
@@ -168,23 +168,21 @@ for (const showHidden of [true, false]) {
Uint8ClampedArray ].forEach((constructor) => {
const length = 2;
const byteLength = length * constructor.BYTES_PER_ELEMENT;
- const array = vm.runInNewContext('new constructor(new ArrayBuffer(' +
- 'byteLength), 0, length)',
- { constructor: constructor,
- byteLength: byteLength,
- length: length
- });
+ const array = vm.runInNewContext(
+ 'new constructor(new ArrayBuffer(byteLength), 0, length)',
+ { constructor, byteLength, length }
+ );
array[0] = 65;
array[1] = 97;
assert.strictEqual(
util.inspect(array, true),
`${constructor.name} [\n` +
- ` 65,\n` +
- ` 97,\n` +
+ ' 65,\n' +
+ ' 97,\n' +
` [BYTES_PER_ELEMENT]: ${constructor.BYTES_PER_ELEMENT},\n` +
` [length]: ${length},\n` +
` [byteLength]: ${byteLength},\n` +
- ` [byteOffset]: 0,\n` +
+ ' [byteOffset]: 0,\n' +
` [buffer]: ArrayBuffer { byteLength: ${byteLength} } ]`);
assert.strictEqual(
util.inspect(array, false),
@@ -208,8 +206,8 @@ for (const showHidden of [true, false]) {
// Objects without prototype
{
const out = util.inspect(Object.create(null,
- { name: {value: 'Tim', enumerable: true},
- hidden: {value: 'secret'}}), true);
+ { name: {value: 'Tim', enumerable: true},
+ hidden: {value: 'secret'}}), true);
if (out !== "{ [hidden]: 'secret', name: 'Tim' }" &&
out !== "{ name: 'Tim', [hidden]: 'secret' }") {
common.fail(`unexpected value for out ${out}`);
@@ -696,7 +694,14 @@ assert.strictEqual(
// test Promise
assert.strictEqual(util.inspect(Promise.resolve(3)), 'Promise { 3 }');
-assert.strictEqual(util.inspect(Promise.reject(3)), 'Promise { 3 }');
+
+{
+ const rejected = Promise.reject(3);
+ assert.strictEqual(util.inspect(rejected), 'Promise { 3 }');
+ // squelch UnhandledPromiseRejection
+ rejected.catch(() => {});
+}
+
assert.strictEqual(
util.inspect(new Promise(function() {})),
'Promise { }'
@@ -831,7 +836,7 @@ checkAlignment(new Map(big_array.map(function(y) { return [y, null]; })));
{
const x = Array(101);
- assert(/^\[ ... 101 more items \]$/.test(
+ assert(/^\[ ... 101 more items ]$/.test(
util.inspect(x, {maxArrayLength: 0})));
}
@@ -847,7 +852,7 @@ checkAlignment(new Map(big_array.map(function(y) { return [y, null]; })));
{
const x = new Uint8Array(101);
- assert(/\[ ... 101 more items \]$/.test(
+ assert(/\[ ... 101 more items ]$/.test(
util.inspect(x, {maxArrayLength: 0})));
}
diff --git a/test/parallel/test-vm-debug-context.js b/test/parallel/test-vm-debug-context.js
index 9b8da58756c8..5cc23bb6f391 100644
--- a/test/parallel/test-vm-debug-context.js
+++ b/test/parallel/test-vm-debug-context.js
@@ -1,9 +1,9 @@
/* eslint-disable no-debugger */
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var vm = require('vm');
-var spawn = require('child_process').spawn;
+const common = require('../common');
+const assert = require('assert');
+const vm = require('vm');
+const spawn = require('child_process').spawn;
assert.throws(function() {
vm.runInDebugContext('*');
@@ -21,8 +21,8 @@ assert.throws(function() {
vm.runInDebugContext('(function(f) { f(f) })(function(f) { f(f) })');
}, /RangeError/);
-assert.equal(typeof vm.runInDebugContext('this'), 'object');
-assert.equal(typeof vm.runInDebugContext('Debug'), 'object');
+assert.strictEqual(typeof vm.runInDebugContext('this'), 'object');
+assert.strictEqual(typeof vm.runInDebugContext('Debug'), 'object');
assert.strictEqual(vm.runInDebugContext(), undefined);
assert.strictEqual(vm.runInDebugContext(0), 0);
@@ -46,11 +46,11 @@ assert.strictEqual(vm.runInDebugContext(undefined), undefined);
debugger;
}
- assert.equal(breaks, 0);
+ assert.strictEqual(breaks, 0);
Debug.setListener(ondebugevent);
- assert.equal(breaks, 0);
+ assert.strictEqual(breaks, 0);
breakpoint();
- assert.equal(breaks, 1);
+ assert.strictEqual(breaks, 1);
}
// Can set listeners and breakpoints on a single line file
@@ -73,24 +73,24 @@ assert.strictEqual(vm.runInDebugContext(undefined), undefined);
// See https://github.com/nodejs/node/issues/1190, fatal errors should not
// crash the process.
-var script = common.fixturesDir + '/vm-run-in-debug-context.js';
-var proc = spawn(process.execPath, [script]);
-var data = [];
+const script = common.fixturesDir + '/vm-run-in-debug-context.js';
+let proc = spawn(process.execPath, [script]);
+const data = [];
proc.stdout.on('data', common.fail);
proc.stderr.on('data', data.push.bind(data));
proc.stderr.once('end', common.mustCall(function() {
- var haystack = Buffer.concat(data).toString('utf8');
+ const haystack = Buffer.concat(data).toString('utf8');
assert(/SyntaxError: Unexpected token \*/.test(haystack));
}));
proc.once('exit', common.mustCall(function(exitCode, signalCode) {
- assert.equal(exitCode, 1);
- assert.equal(signalCode, null);
+ assert.strictEqual(exitCode, 1);
+ assert.strictEqual(signalCode, null);
}));
proc = spawn(process.execPath, [script, 'handle-fatal-exception']);
proc.stdout.on('data', common.fail);
proc.stderr.on('data', common.fail);
proc.once('exit', common.mustCall(function(exitCode, signalCode) {
- assert.equal(exitCode, 42);
- assert.equal(signalCode, null);
+ assert.strictEqual(exitCode, 42);
+ assert.strictEqual(signalCode, null);
}));
diff --git a/test/parallel/test-vm-static-this.js b/test/parallel/test-vm-static-this.js
index a3cf2d820c34..c4f10c183b6e 100644
--- a/test/parallel/test-vm-static-this.js
+++ b/test/parallel/test-vm-static-this.js
@@ -5,21 +5,21 @@ var vm = require('vm');
common.globalCheck = false;
-console.error('run a string');
+// Run a string
var result = vm.runInThisContext('\'passed\';');
-assert.equal('passed', result);
+assert.strictEqual('passed', result);
-console.error('thrown error');
+// thrown error
assert.throws(function() {
vm.runInThisContext('throw new Error(\'test\');');
}, /test/);
global.hello = 5;
vm.runInThisContext('hello = 2');
-assert.equal(2, global.hello);
+assert.strictEqual(2, global.hello);
-console.error('pass values');
+// pass values
var code = 'foo = 1;' +
'bar = 2;' +
'if (typeof baz !== \'undefined\') throw new Error(\'test fail\');';
@@ -28,11 +28,11 @@ global.obj = { foo: 0, baz: 3 };
/* eslint-disable no-unused-vars */
var baz = vm.runInThisContext(code);
/* eslint-enable no-unused-vars */
-assert.equal(0, global.obj.foo);
-assert.equal(2, global.bar);
-assert.equal(1, global.foo);
+assert.strictEqual(0, global.obj.foo);
+assert.strictEqual(2, global.bar);
+assert.strictEqual(1, global.foo);
-console.error('call a function');
+// call a function
global.f = function() { global.foo = 100; };
vm.runInThisContext('f()');
-assert.equal(100, global.foo);
+assert.strictEqual(100, global.foo);
diff --git a/test/parallel/test-vm-syntax-error-stderr.js b/test/parallel/test-vm-syntax-error-stderr.js
index 7c3c5ff1351d..43ed8d882804 100644
--- a/test/parallel/test-vm-syntax-error-stderr.js
+++ b/test/parallel/test-vm-syntax-error-stderr.js
@@ -1,22 +1,22 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var path = require('path');
-var child_process = require('child_process');
+const common = require('../common');
+const assert = require('assert');
+const path = require('path');
+const child_process = require('child_process');
-var wrong_script = path.join(common.fixturesDir, 'cert.pem');
+const wrong_script = path.join(common.fixturesDir, 'cert.pem');
-var p = child_process.spawn(process.execPath, [
+const p = child_process.spawn(process.execPath, [
'-e',
'require(process.argv[1]);',
wrong_script
]);
p.stdout.on('data', function(data) {
- assert(false, 'Unexpected stdout data: ' + data);
+ common.fail('Unexpected stdout data: ' + data);
});
-var output = '';
+let output = '';
p.stderr.on('data', function(data) {
output += data;
diff --git a/test/parallel/test-zlib-truncated.js b/test/parallel/test-zlib-truncated.js
index 3fac824bbf9e..92a18a538c1e 100644
--- a/test/parallel/test-zlib-truncated.js
+++ b/test/parallel/test-zlib-truncated.js
@@ -24,17 +24,18 @@ const inputString = 'ΩΩLorem ipsum dolor sit amet, consectetur adipiscing eli'
zlib[methods.comp](inputString, function(err, compressed) {
assert(!err);
const truncated = compressed.slice(0, compressed.length / 2);
+ const toUTF8 = (buffer) => buffer.toString('utf-8');
// sync sanity
assert.doesNotThrow(function() {
const decompressed = zlib[methods.decompSync](compressed);
- assert.equal(decompressed, inputString);
+ assert.strictEqual(toUTF8(decompressed), inputString);
});
// async sanity
zlib[methods.decomp](compressed, function(err, result) {
assert.ifError(err);
- assert.equal(result, inputString);
+ assert.strictEqual(toUTF8(result), inputString);
});
// sync truncated input test
@@ -51,17 +52,15 @@ const inputString = 'ΩΩLorem ipsum dolor sit amet, consectetur adipiscing eli'
// sync truncated input test, finishFlush = Z_SYNC_FLUSH
assert.doesNotThrow(function() {
- const result = zlib[methods.decompSync](truncated, syncFlushOpt)
- .toString();
- assert.equal(result, inputString.substr(0, result.length));
+ const result = toUTF8(zlib[methods.decompSync](truncated, syncFlushOpt));
+ assert.strictEqual(result, inputString.substr(0, result.length));
});
// async truncated input test, finishFlush = Z_SYNC_FLUSH
zlib[methods.decomp](truncated, syncFlushOpt, function(err, decompressed) {
assert.ifError(err);
-
- const result = decompressed.toString();
- assert.equal(result, inputString.substr(0, result.length));
+ const result = toUTF8(decompressed);
+ assert.strictEqual(result, inputString.substr(0, result.length));
});
});
});
diff --git a/test/pseudo-tty/pseudo-tty.status b/test/pseudo-tty/pseudo-tty.status
index 27c6f75e1064..e16bb28cd7be 100644
--- a/test/pseudo-tty/pseudo-tty.status
+++ b/test/pseudo-tty/pseudo-tty.status
@@ -3,3 +3,4 @@ prefix pseudo-tty
[$system==aix]
# test issue only, covered under https://github.com/nodejs/node/issues/7973
no_dropped_stdio : SKIP
+no_interleaved_stdio : SKIP
diff --git a/test/pseudo-tty/stdin-setrawmode.js b/test/pseudo-tty/stdin-setrawmode.js
new file mode 100644
index 000000000000..015c769a9b61
--- /dev/null
+++ b/test/pseudo-tty/stdin-setrawmode.js
@@ -0,0 +1,9 @@
+'use strict';
+require('../common');
+const assert = require('assert');
+
+process.stdin.setRawMode(true);
+assert.strictEqual(process.stdin.isRaw, true);
+
+process.stdin.setRawMode(false);
+assert.strictEqual(process.stdin.isRaw, false);
diff --git a/test/sequential/test-crypto-timing-safe-equal.js b/test/sequential/test-crypto-timing-safe-equal.js
index 6e15a577188c..9c4265a672cc 100644
--- a/test/sequential/test-crypto-timing-safe-equal.js
+++ b/test/sequential/test-crypto-timing-safe-equal.js
@@ -23,12 +23,15 @@ assert.strictEqual(
assert.throws(function() {
crypto.timingSafeEqual(Buffer.from([1, 2, 3]), Buffer.from([1, 2]));
-}, 'should throw when given buffers with different lengths');
+}, /^TypeError: Input buffers must have the same length$/,
+ 'should throw when given buffers with different lengths');
assert.throws(function() {
crypto.timingSafeEqual('not a buffer', Buffer.from([1, 2]));
-}, 'should throw if the first argument is not a buffer');
+}, /^TypeError: First argument must be a buffer$/,
+ 'should throw if the first argument is not a buffer');
assert.throws(function() {
crypto.timingSafeEqual(Buffer.from([1, 2]), 'not a buffer');
-}, 'should throw if the second argument is not a buffer');
+}, /^TypeError: Second argument must be a buffer$/,
+ 'should throw if the second argument is not a buffer');
diff --git a/tools/doc/generate.js b/tools/doc/generate.js
index 077e740432c8..31b23c52a08b 100644
--- a/tools/doc/generate.js
+++ b/tools/doc/generate.js
@@ -13,14 +13,14 @@ let inputFile = null;
let nodeVersion = null;
args.forEach(function(arg) {
- if (!arg.match(/^\-\-/)) {
+ if (!arg.match(/^--/)) {
inputFile = arg;
- } else if (arg.match(/^\-\-format=/)) {
- format = arg.replace(/^\-\-format=/, '');
- } else if (arg.match(/^\-\-template=/)) {
- template = arg.replace(/^\-\-template=/, '');
- } else if (arg.match(/^\-\-node\-version=/)) {
- nodeVersion = arg.replace(/^\-\-node\-version=/, '');
+ } else if (arg.match(/^--format=/)) {
+ format = arg.replace(/^--format=/, '');
+ } else if (arg.match(/^--template=/)) {
+ template = arg.replace(/^--template=/, '');
+ } else if (arg.match(/^--node-version=/)) {
+ nodeVersion = arg.replace(/^--node-version=/, '');
}
});
diff --git a/tools/doc/html.js b/tools/doc/html.js
index daa230cb926e..c0790ffca5f0 100644
--- a/tools/doc/html.js
+++ b/tools/doc/html.js
@@ -90,7 +90,7 @@ function loadGtoc(cb) {
function toID(filename) {
return filename
.replace('.html', '')
- .replace(/[^\w\-]/g, '-')
+ .replace(/[^\w-]/g, '-')
.replace(/-+/g, '-');
}
@@ -284,7 +284,7 @@ function linkJsTypeDocs(text) {
// Handle types, for example the source Markdown might say
// "This argument should be a {Number} or {String}"
for (i = 0; i < parts.length; i += 2) {
- typeMatches = parts[i].match(/\{([^\}]+)\}/g);
+ typeMatches = parts[i].match(/\{([^}]+)\}/g);
if (typeMatches) {
typeMatches.forEach(function(typeMatch) {
parts[i] = parts[i].replace(typeMatch, typeParser.toLink(typeMatch));
diff --git a/tools/doc/json.js b/tools/doc/json.js
index a782c54028d7..f8210ef17fda 100644
--- a/tools/doc/json.js
+++ b/tools/doc/json.js
@@ -31,7 +31,7 @@ function doJSON(input, filename, cb) {
//
// This is for cases where the markdown semantic structure is lacking.
if (type === 'paragraph' || type === 'html') {
- var metaExpr = /\n*/g;
+ var metaExpr = /\n*/g;
text = text.replace(metaExpr, function(_0, k, v) {
current[k.trim()] = v.trim();
return '';
@@ -371,7 +371,7 @@ function parseListItem(item) {
item.name = 'return';
text = text.replace(retExpr, '');
} else {
- var nameExpr = /^['`"]?([^'`": \{]+)['`"]?\s*:?\s*/;
+ var nameExpr = /^['`"]?([^'`": {]+)['`"]?\s*:?\s*/;
var name = text.match(nameExpr);
if (name) {
item.name = name[1];
@@ -388,7 +388,7 @@ function parseListItem(item) {
}
text = text.trim();
- var typeExpr = /^\{([^\}]+)\}/;
+ var typeExpr = /^\{([^}]+)\}/;
var type = text.match(typeExpr);
if (type) {
item.type = type[1];
@@ -551,7 +551,7 @@ var classMethExpr =
/^class\s*method\s*:?[^.]+\.([^ .()]+)\([^)]*\)\s*?$/i;
var methExpr =
/^(?:method:?\s*)?(?:[^.]+\.)?([^ .()]+)\([^)]*\)\s*?$/i;
-var newExpr = /^new ([A-Z][a-zA-Z]+)\([^\)]*\)\s*?$/;
+var newExpr = /^new ([A-Z][a-zA-Z]+)\([^)]*\)\s*?$/;
var paramExpr = /\((.*)\);?$/;
function newSection(tok) {
diff --git a/tools/eslint-rules/assert-throws-arguments.js b/tools/eslint-rules/assert-throws-arguments.js
new file mode 100644
index 000000000000..434a0ca455b4
--- /dev/null
+++ b/tools/eslint-rules/assert-throws-arguments.js
@@ -0,0 +1,59 @@
+/**
+ * @fileoverview Check that assert.throws is never called with a string as
+ * second argument.
+ * @author Michaël Zasso
+ */
+'use strict';
+
+//------------------------------------------------------------------------------
+// Rule Definition
+//------------------------------------------------------------------------------
+
+function checkThrowsArguments(context, node) {
+ if (node.callee.type === 'MemberExpression' &&
+ node.callee.object.name === 'assert' &&
+ node.callee.property.name === 'throws') {
+ const args = node.arguments;
+ if (args.length > 3) {
+ context.report({
+ message: 'Too many arguments',
+ node: node
+ });
+ } else if (args.length > 1) {
+ const error = args[1];
+ if (error.type === 'Literal' && typeof error.value === 'string') {
+ context.report({
+ message: 'Unexpected string as second argument',
+ node: error
+ });
+ }
+ } else {
+ if (context.options[0].requireTwo) {
+ context.report({
+ message: 'Expected at least two arguments',
+ node: node
+ });
+ }
+ }
+ }
+}
+
+module.exports = {
+ meta: {
+ schema: [
+ {
+ type: 'object',
+ properties: {
+ requireTwo: {
+ type: 'boolean'
+ }
+ }
+ }
+ ]
+ },
+ create: function(context) {
+ return {
+ CallExpression: (node) => checkThrowsArguments(context, node)
+ };
+ }
+};
diff --git a/tools/eslint-rules/no-useless-regex-char-class-escape.js b/tools/eslint-rules/no-useless-regex-char-class-escape.js
new file mode 100644
index 000000000000..934a3fa193b5
--- /dev/null
+++ b/tools/eslint-rules/no-useless-regex-char-class-escape.js
@@ -0,0 +1,190 @@
+/**
+ * @fileoverview Disallow useless escape in regex character class
+ * Based on 'no-useless-escape' rule
+ */
+'use strict';
+
+//------------------------------------------------------------------------------
+// Rule Definition
+//------------------------------------------------------------------------------
+
+const REGEX_CHARCLASS_ESCAPES = new Set('\\bcdDfnrsStvwWxu0123456789]');
+
+/**
+ * Parses a regular expression into a list of regex character class list.
+ * @param {string} regExpText raw text used to create the regular expression
+ * @returns {Object[]} A list of character classes tokens with index and
+ * escape info
+ * @example
+ *
+ * parseRegExpCharClass('a\\b[cd-]')
+ *
+ * returns:
+ * [
+ * {
+ * empty: false,
+ * start: 4,
+ * end: 6,
+ * chars: [
+ * {text: 'c', index: 4, escaped: false},
+ * {text: 'd', index: 5, escaped: false},
+ * {text: '-', index: 6, escaped: false}
+ * ]
+ * }
+ * ]
+ */
+
+function parseRegExpCharClass(regExpText) {
+ const charList = [];
+ let charListIdx = -1;
+ const initState = {
+ escapeNextChar: false,
+ inCharClass: false,
+ startingCharClass: false
+ };
+
+ regExpText.split('').reduce((state, char, index) => {
+ if (!state.escapeNextChar) {
+ if (char === '\\') {
+ return Object.assign(state, { escapeNextChar: true });
+ }
+ if (char === '[' && !state.inCharClass) {
+ charListIdx += 1;
+ charList.push({ start: index + 1, chars: [], end: -1 });
+ return Object.assign(state, {
+ inCharClass: true,
+ startingCharClass: true
+ });
+ }
+ if (char === ']' && state.inCharClass) {
+ const charClass = charList[charListIdx];
+ charClass.empty = charClass.chars.length === 0;
+ if (charClass.empty) {
+ charClass.start = charClass.end = -1;
+ } else {
+ charList[charListIdx].end = index - 1;
+ }
+ return Object.assign(state, {
+ inCharClass: false,
+ startingCharClass: false
+ });
+ }
+ }
+ if (state.inCharClass) {
+ charList[charListIdx].chars.push({
+ text: char,
+ index, escaped:
+ state.escapeNextChar
+ });
+ }
+ return Object.assign(state, {
+ escapeNextChar: false,
+ startingCharClass: false
+ });
+ }, initState);
+
+ return charList;
+}
+
+module.exports = {
+ meta: {
+ docs: {
+ description: 'disallow unnecessary regex characer class escape sequences',
+ category: 'Best Practices',
+ recommended: false
+ },
+ fixable: 'code',
+ schema: [{
+ 'type': 'object',
+ 'properties': {
+ 'override': {
+ 'type': 'array',
+ 'items': { 'type': 'string' },
+ 'uniqueItems': true
+ }
+ },
+ 'additionalProperties': false
+ }]
+ },
+
+ create(context) {
+ const overrideSet = new Set(context.options.length
+ ? context.options[0].override || []
+ : []);
+
+ /**
+ * Reports a node
+ * @param {ASTNode} node The node to report
+ * @param {number} startOffset The backslash's offset
+ * from the start of the node
+ * @param {string} character The uselessly escaped character
+ * (not including the backslash)
+ * @returns {void}
+ */
+ function report(node, startOffset, character) {
+ context.report({
+ node,
+ loc: {
+ line: node.loc.start.line,
+ column: node.loc.start.column + startOffset
+ },
+ message: 'Unnecessary regex escape in character' +
+ ' class: \\{{character}}',
+ data: { character },
+ fix: (fixer) => {
+ const start = node.range[0] + startOffset;
+ return fixer.replaceTextRange([start, start + 1], '');
+ }
+ });
+ }
+
+ /**
+ * Checks if a node has superflous escape character
+ * in regex character class.
+ *
+ * @param {ASTNode} node - node to check.
+ * @returns {void}
+ */
+ function check(node) {
+ if (node.regex) {
+ parseRegExpCharClass(node.regex.pattern)
+ .forEach((charClass) => {
+ charClass
+ .chars
+ // The '-' character is a special case if is not at
+ // either edge of the character class. To account for this,
+ // filter out '-' characters that appear in the middle of a
+ // character class.
+ .filter((charInfo) => !(charInfo.text === '-' &&
+ (charInfo.index !== charClass.start &&
+ charInfo.index !== charClass.end)))
+
+ // The '^' character is a special case if it's at the beginning
+ // of the character class. To account for this, filter out '^'
+ // characters that appear at the start of a character class.
+ //
+ .filter((charInfo) => !(charInfo.text === '^' &&
+ charInfo.index === charClass.start))
+
+ // Filter out characters that aren't escaped.
+ .filter((charInfo) => charInfo.escaped)
+
+ // Filter out characters that are valid to escape, based on
+ // their position in the regular expression.
+ .filter((charInfo) => !REGEX_CHARCLASS_ESCAPES.has(charInfo.text))
+
+ // Filter out overridden character list.
+ .filter((charInfo) => !overrideSet.has(charInfo.text))
+
+ // Report all the remaining characters.
+ .forEach((charInfo) =>
+ report(node, charInfo.index, charInfo.text));
+ });
+ }
+ }
+
+ return {
+ Literal: check
+ };
+ }
+};
diff --git a/tools/gyp/AUTHORS b/tools/gyp/AUTHORS
index 9389ca0a23e4..dcd231ceb2d3 100644
--- a/tools/gyp/AUTHORS
+++ b/tools/gyp/AUTHORS
@@ -1,9 +1,10 @@
# Names should be added to this file like so:
# Name or Organization
-Google Inc.
-Bloomberg Finance L.P.
-Yandex LLC
+Google Inc. <*@google.com>
+Bloomberg Finance L.P. <*@bloomberg.net>
+IBM Inc. <*@*.ibm.com>
+Yandex LLC <*@yandex-team.ru>
Steven Knight
Ryan Norton
diff --git a/tools/gyp/PRESUBMIT.py b/tools/gyp/PRESUBMIT.py
index dde025383c32..f6c8a357afe1 100644
--- a/tools/gyp/PRESUBMIT.py
+++ b/tools/gyp/PRESUBMIT.py
@@ -73,23 +73,15 @@
]
-def CheckChangeOnUpload(input_api, output_api):
- report = []
- report.extend(input_api.canned_checks.PanProjectChecks(
- input_api, output_api))
- return report
-
-
-def CheckChangeOnCommit(input_api, output_api):
- report = []
-
+def _LicenseHeader(input_api):
# Accept any year number from 2009 to the current year.
current_year = int(input_api.time.strftime('%Y'))
allowed_years = (str(s) for s in reversed(xrange(2009, current_year + 1)))
+
years_re = '(' + '|'.join(allowed_years) + ')'
# The (c) is deprecated, but tolerate it until it's removed from all files.
- license = (
+ return (
r'.*? Copyright (\(c\) )?%(year)s Google Inc\. All rights reserved\.\n'
r'.*? Use of this source code is governed by a BSD-style license that '
r'can be\n'
@@ -98,8 +90,18 @@ def CheckChangeOnCommit(input_api, output_api):
'year': years_re,
}
+def CheckChangeOnUpload(input_api, output_api):
+ report = []
+ report.extend(input_api.canned_checks.PanProjectChecks(
+ input_api, output_api, license_header=_LicenseHeader(input_api)))
+ return report
+
+
+def CheckChangeOnCommit(input_api, output_api):
+ report = []
+
report.extend(input_api.canned_checks.PanProjectChecks(
- input_api, output_api, license_header=license))
+ input_api, output_api, license_header=_LicenseHeader(input_api)))
report.extend(input_api.canned_checks.CheckTreeIsOpen(
input_api, output_api,
'http://gyp-status.appspot.com/status',
diff --git a/tools/gyp/pylib/gyp/generator/make.py b/tools/gyp/pylib/gyp/generator/make.py
index 4a6b283f1523..39373b9844e4 100644
--- a/tools/gyp/pylib/gyp/generator/make.py
+++ b/tools/gyp/pylib/gyp/generator/make.py
@@ -92,7 +92,10 @@ def CalculateVariables(default_variables, params):
if flavor == 'android':
operating_system = 'linux' # Keep this legacy behavior for now.
default_variables.setdefault('OS', operating_system)
- default_variables.setdefault('SHARED_LIB_SUFFIX', '.so')
+ if flavor == 'aix':
+ default_variables.setdefault('SHARED_LIB_SUFFIX', '.a')
+ else:
+ default_variables.setdefault('SHARED_LIB_SUFFIX', '.so')
default_variables.setdefault('SHARED_LIB_DIR','$(builddir)/lib.$(TOOLSET)')
default_variables.setdefault('LIB_DIR', '$(obj).$(TOOLSET)')
@@ -1349,7 +1352,10 @@ def ComputeOutputBasename(self, spec):
if target[:3] == 'lib':
target = target[3:]
target_prefix = 'lib'
- target_ext = '.so'
+ if self.flavor == 'aix':
+ target_ext = '.a'
+ else:
+ target_ext = '.so'
elif self.type == 'none':
target = '%s.stamp' % target
elif self.type != 'executable':
diff --git a/tools/license2rtf.js b/tools/license2rtf.js
index 694e1c605014..4b3d71fe5b99 100644
--- a/tools/license2rtf.js
+++ b/tools/license2rtf.js
@@ -122,7 +122,7 @@ function ParagraphParser() {
// Detect separator "lines" within a block. These mark a paragraph break
// and are stripped from the output.
- if (/^\s*[=*\-]{5,}\s*$/.test(line)) {
+ if (/^\s*[=*-]{5,}\s*$/.test(line)) {
flushParagraph();
return;
}
@@ -286,7 +286,7 @@ function RtfGenerator() {
function rtfEscape(string) {
return string
- .replace(/[\\\{\}]/g, function(m) {
+ .replace(/[\\{}]/g, function(m) {
return '\\' + m;
})
.replace(/\t/g, function() {
diff --git a/tools/test.py b/tools/test.py
index 6e1840b76720..4a272475ccff 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -298,7 +298,7 @@ def HasRun(self, output):
if output.HasCrashed():
self.severity = 'crashed'
- exit_code = output.output.exit_code
+ exit_code = output.output.exit_code
self.traceback = "oh no!\nexit code: " + PrintCrashed(exit_code)
if output.HasTimedOut():
@@ -1461,6 +1461,13 @@ def SplitPath(s):
stripped = [ c.strip() for c in s.split('/') ]
return [ Pattern(s) for s in stripped if len(s) > 0 ]
+def NormalizePath(path):
+ # strip the extra path information of the specified test
+ if path.startswith('test/'):
+ path = path[5:]
+ if path.endswith('.js'):
+ path = path[:-3]
+ return path
def GetSpecialCommandProcessor(value):
if (not value) or (value.find('@') == -1):
@@ -1534,7 +1541,7 @@ def Main():
else:
paths = [ ]
for arg in args:
- path = SplitPath(arg)
+ path = SplitPath(NormalizePath(arg))
paths.append(path)
# Check for --valgrind option. If enabled, we overwrite the special