summaryrefslogtreecommitdiff
path: root/test/simple/test-fs-write-file.js
diff options
context:
space:
mode:
authorAaron Heckmann <aaron.heckmann@gmail.com>2010-06-16 00:52:15 -0400
committerRyan Dahl <ry@tinyclouds.org>2010-06-15 23:58:32 -0700
commit1d088fb9062bf67d7285a801a5c1630740d1357f (patch)
tree0eb9c87bc7813cc154cbd318470b090605f45946 /test/simple/test-fs-write-file.js
parentc2e2479cc51465ae18357d73f7d4aa7ba98ea0b3 (diff)
downloadnode-new-1d088fb9062bf67d7285a801a5c1630740d1357f.tar.gz
fs.writeFile accepts Buffers
Diffstat (limited to 'test/simple/test-fs-write-file.js')
-rw-r--r--test/simple/test-fs-write-file.js25
1 files changed, 23 insertions, 2 deletions
diff --git a/test/simple/test-fs-write-file.js b/test/simple/test-fs-write-file.js
index cc0fdfabfe..32ae96155e 100644
--- a/test/simple/test-fs-write-file.js
+++ b/test/simple/test-fs-write-file.js
@@ -26,9 +26,30 @@ fs.writeFile(filename, s, function (e) {
});
});
+// test that writeFile accepts buffers
+filename2 = join(fixturesDir, 'test2.txt');
+buf = new Buffer(s, 'utf8');
+error('writing to ' + filename2);
+
+fs.writeFile(filename2, s, function (e) {
+ if (e) throw e;
+
+ ncallbacks++;
+ error('file2 written');
+
+ fs.readFile(filename2, function (e, buffer) {
+ if (e) throw e;
+ error('file2 read');
+ ncallbacks++;
+ assert.equal(buf.length, buffer.length);
+ });
+});
+
process.addListener('exit', function () {
error('done');
+ assert.equal(4, ncallbacks);
- assert.equal(2, ncallbacks);
-}); \ No newline at end of file
+ fs.unlinkSync(filename);
+ fs.unlinkSync(filename2);
+});