summaryrefslogtreecommitdiff
path: root/test/parallel/test-stream2-transform.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/parallel/test-stream2-transform.js')
-rw-r--r--test/parallel/test-stream2-transform.js99
1 files changed, 49 insertions, 50 deletions
diff --git a/test/parallel/test-stream2-transform.js b/test/parallel/test-stream2-transform.js
index 11ee45915c..c52d09e9f6 100644
--- a/test/parallel/test-stream2-transform.js
+++ b/test/parallel/test-stream2-transform.js
@@ -54,7 +54,7 @@ test('writable side consumption', function(t) {
};
for (var i = 1; i <= 10; i++) {
- tx.write(new Buffer(i));
+ tx.write(Buffer.allocUnsafe(i));
}
tx.end();
@@ -71,10 +71,10 @@ test('writable side consumption', function(t) {
test('passthrough', function(t) {
var pt = new PassThrough();
- pt.write(new Buffer('foog'));
- pt.write(new Buffer('bark'));
- pt.write(new Buffer('bazy'));
- pt.write(new Buffer('kuel'));
+ pt.write(Buffer.from('foog'));
+ pt.write(Buffer.from('bark'));
+ pt.write(Buffer.from('bazy'));
+ pt.write(Buffer.from('kuel'));
pt.end();
t.equal(pt.read(5).toString(), 'foogb');
@@ -109,16 +109,15 @@ test('object passthrough', function(t) {
test('simple transform', function(t) {
var pt = new Transform();
pt._transform = function(c, e, cb) {
- var ret = new Buffer(c.length);
- ret.fill('x');
+ var ret = Buffer.alloc(c.length, 'x');
pt.push(ret);
cb();
};
- pt.write(new Buffer('foog'));
- pt.write(new Buffer('bark'));
- pt.write(new Buffer('bazy'));
- pt.write(new Buffer('kuel'));
+ pt.write(Buffer.from('foog'));
+ pt.write(Buffer.from('bark'));
+ pt.write(Buffer.from('bazy'));
+ pt.write(Buffer.from('kuel'));
pt.end();
t.equal(pt.read(5).toString(), 'xxxxx');
@@ -163,10 +162,10 @@ test('async passthrough', function(t) {
}, 10);
};
- pt.write(new Buffer('foog'));
- pt.write(new Buffer('bark'));
- pt.write(new Buffer('bazy'));
- pt.write(new Buffer('kuel'));
+ pt.write(Buffer.from('foog'));
+ pt.write(Buffer.from('bark'));
+ pt.write(Buffer.from('bazy'));
+ pt.write(Buffer.from('kuel'));
pt.end();
pt.on('finish', function() {
@@ -192,10 +191,10 @@ test('assymetric transform (expand)', function(t) {
}, 10);
};
- pt.write(new Buffer('foog'));
- pt.write(new Buffer('bark'));
- pt.write(new Buffer('bazy'));
- pt.write(new Buffer('kuel'));
+ pt.write(Buffer.from('foog'));
+ pt.write(Buffer.from('bark'));
+ pt.write(Buffer.from('bazy'));
+ pt.write(Buffer.from('kuel'));
pt.end();
pt.on('finish', function() {
@@ -224,7 +223,7 @@ test('assymetric transform (compress)', function(t) {
setTimeout(function() {
this.state += s.charAt(0);
if (this.state.length === 3) {
- pt.push(new Buffer(this.state));
+ pt.push(Buffer.from(this.state));
this.state = '';
}
cb();
@@ -233,25 +232,25 @@ test('assymetric transform (compress)', function(t) {
pt._flush = function(cb) {
// just output whatever we have.
- pt.push(new Buffer(this.state));
+ pt.push(Buffer.from(this.state));
this.state = '';
cb();
};
- pt.write(new Buffer('aaaa'));
- pt.write(new Buffer('bbbb'));
- pt.write(new Buffer('cccc'));
- pt.write(new Buffer('dddd'));
- pt.write(new Buffer('eeee'));
- pt.write(new Buffer('aaaa'));
- pt.write(new Buffer('bbbb'));
- pt.write(new Buffer('cccc'));
- pt.write(new Buffer('dddd'));
- pt.write(new Buffer('eeee'));
- pt.write(new Buffer('aaaa'));
- pt.write(new Buffer('bbbb'));
- pt.write(new Buffer('cccc'));
- pt.write(new Buffer('dddd'));
+ pt.write(Buffer.from('aaaa'));
+ pt.write(Buffer.from('bbbb'));
+ pt.write(Buffer.from('cccc'));
+ pt.write(Buffer.from('dddd'));
+ pt.write(Buffer.from('eeee'));
+ pt.write(Buffer.from('aaaa'));
+ pt.write(Buffer.from('bbbb'));
+ pt.write(Buffer.from('cccc'));
+ pt.write(Buffer.from('dddd'));
+ pt.write(Buffer.from('eeee'));
+ pt.write(Buffer.from('aaaa'));
+ pt.write(Buffer.from('bbbb'));
+ pt.write(Buffer.from('cccc'));
+ pt.write(Buffer.from('dddd'));
pt.end();
// 'abcdeabcdeabcd'
@@ -285,8 +284,8 @@ test('complex transform', function(t) {
pt.once('readable', function() {
process.nextTick(function() {
- pt.write(new Buffer('d'));
- pt.write(new Buffer('ef'), function() {
+ pt.write(Buffer.from('d'));
+ pt.write(Buffer.from('ef'), function() {
pt.end();
t.end();
});
@@ -295,7 +294,7 @@ test('complex transform', function(t) {
});
});
- pt.write(new Buffer('abc'));
+ pt.write(Buffer.from('abc'));
});
@@ -307,10 +306,10 @@ test('passthrough event emission', function(t) {
emits++;
});
- pt.write(new Buffer('foog'));
+ pt.write(Buffer.from('foog'));
console.error('need emit 0');
- pt.write(new Buffer('bark'));
+ pt.write(Buffer.from('bark'));
console.error('should have emitted readable now 1 === %d', emits);
t.equal(emits, 1);
@@ -320,9 +319,9 @@ test('passthrough event emission', function(t) {
console.error('need emit 1');
- pt.write(new Buffer('bazy'));
+ pt.write(Buffer.from('bazy'));
console.error('should have emitted, but not again');
- pt.write(new Buffer('kuel'));
+ pt.write(Buffer.from('kuel'));
console.error('should have emitted readable now 2 === %d', emits);
t.equal(emits, 2);
@@ -353,9 +352,9 @@ test('passthrough event emission reordered', function(t) {
emits++;
});
- pt.write(new Buffer('foog'));
+ pt.write(Buffer.from('foog'));
console.error('need emit 0');
- pt.write(new Buffer('bark'));
+ pt.write(Buffer.from('bark'));
console.error('should have emitted readable now 1 === %d', emits);
t.equal(emits, 1);
@@ -380,10 +379,10 @@ test('passthrough event emission reordered', function(t) {
});
pt.end();
});
- pt.write(new Buffer('kuel'));
+ pt.write(Buffer.from('kuel'));
});
- pt.write(new Buffer('bazy'));
+ pt.write(Buffer.from('bazy'));
});
test('passthrough facaded', function(t) {
@@ -399,13 +398,13 @@ test('passthrough facaded', function(t) {
t.end();
});
- pt.write(new Buffer('foog'));
+ pt.write(Buffer.from('foog'));
setTimeout(function() {
- pt.write(new Buffer('bark'));
+ pt.write(Buffer.from('bark'));
setTimeout(function() {
- pt.write(new Buffer('bazy'));
+ pt.write(Buffer.from('bazy'));
setTimeout(function() {
- pt.write(new Buffer('kuel'));
+ pt.write(Buffer.from('kuel'));
setTimeout(function() {
pt.end();
}, 10);