Aucune description

test.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. var assert = require('assert');
  2. var eos = require('./index');
  3. var expected = 6;
  4. var fs = require('fs');
  5. var net = require('net');
  6. var ws = fs.createWriteStream('/dev/null');
  7. eos(ws, function(err) {
  8. expected--;
  9. assert(!!err);
  10. if (!expected) process.exit(0);
  11. });
  12. ws.close();
  13. var rs = fs.createReadStream('/dev/random');
  14. eos(rs, function(err) {
  15. expected--;
  16. assert(!!err);
  17. if (!expected) process.exit(0);
  18. });
  19. rs.close();
  20. var rs = fs.createReadStream(__filename);
  21. eos(rs, function(err) {
  22. expected--;
  23. assert(!err);
  24. if (!expected) process.exit(0);
  25. });
  26. rs.pipe(fs.createWriteStream('/dev/null'));
  27. var socket = net.connect(50000);
  28. eos(socket, function(err) {
  29. expected--;
  30. assert(!!err);
  31. if (!expected) process.exit(0);
  32. });
  33. var server = net.createServer(function(socket) {
  34. eos(socket, function() {
  35. expected--;
  36. if (!expected) process.exit(0);
  37. });
  38. socket.destroy();
  39. }).listen(30000, function() {
  40. var socket = net.connect(30000);
  41. eos(socket, function() {
  42. expected--;
  43. if (!expected) process.exit(0);
  44. });
  45. });
  46. setTimeout(function() {
  47. assert(expected === 0);
  48. process.exit(0);
  49. }, 1000);