diff options
author | James M Snell <jasnell@gmail.com> | 2017-03-11 12:32:25 -0800 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-04-19 09:15:57 -0700 |
commit | d2d32ea5a22a30f428a6e08bcb707c3538558933 (patch) | |
tree | 3e92010fd8c30259ea3fa3af6aac6ea90b6c15b3 /test | |
parent | a16b570f8c1283db81b85ff78ce73608a4265f61 (diff) | |
download | android-node-v8-d2d32ea5a22a30f428a6e08bcb707c3538558933.tar.gz android-node-v8-d2d32ea5a22a30f428a6e08bcb707c3538558933.tar.bz2 android-node-v8-d2d32ea5a22a30f428a6e08bcb707c3538558933.zip |
buffer: add pending deprecation warning
The pending deprecation warning is off by default.
Launch the node process with --pending-deprecation
or NODE_PENDING_DEPRECATION=1 env var set.
PR-URL: https://github.com/nodejs/node/pull/11968
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-buffer-nopendingdep-map.js | 14 | ||||
-rw-r--r-- | test/parallel/test-buffer-pending-deprecation.js | 15 |
2 files changed, 29 insertions, 0 deletions
diff --git a/test/parallel/test-buffer-nopendingdep-map.js b/test/parallel/test-buffer-nopendingdep-map.js new file mode 100644 index 0000000000..90a24a625b --- /dev/null +++ b/test/parallel/test-buffer-nopendingdep-map.js @@ -0,0 +1,14 @@ +// Flags: --no-warnings --pending-deprecation +'use strict'; + +const common = require('../common'); +const Buffer = require('buffer').Buffer; + +process.on('warning', common.mustNotCall('A warning should not be emitted')); + +// With the --pending-deprecation flag, the deprecation warning for +// new Buffer() should not be emitted when Uint8Array methods are called. + +Buffer.from('abc').map((i) => i); +Buffer.from('abc').filter((i) => i); +Buffer.from('abc').slice(1, 2); diff --git a/test/parallel/test-buffer-pending-deprecation.js b/test/parallel/test-buffer-pending-deprecation.js new file mode 100644 index 0000000000..fcce8814cd --- /dev/null +++ b/test/parallel/test-buffer-pending-deprecation.js @@ -0,0 +1,15 @@ +// Flags: --pending-deprecation --no-warnings +'use strict'; + +const common = require('../common'); +const Buffer = require('buffer').Buffer; + +const bufferWarning = 'The Buffer() and new Buffer() constructors are not ' + + 'recommended for use due to security and usability ' + + 'concerns. Please use the new Buffer.alloc(), ' + + 'Buffer.allocUnsafe(), or Buffer.from() construction ' + + 'methods instead.'; + +common.expectWarning('DeprecationWarning', bufferWarning); + +new Buffer(10); |