mirror of
https://github.com/nodejs/node.git
synced 2025-05-10 06:41:09 +00:00

Code for the new --pending-deprecation flag contains logic to make sure the deprecation warning is emitted only once. However, this was not being tested. Add test coverage for this situation. PR-URL: https://github.com/nodejs/node/pull/12527 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
22 lines
737 B
JavaScript
22 lines
737 B
JavaScript
// 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);
|
|
|
|
// This is used to make sure that a warning is only emitted once even though
|
|
// `new Buffer()` is called twice.
|
|
process.on('warning', common.mustCall());
|
|
|
|
new Buffer(10);
|
|
|
|
new Buffer(10);
|