a zip code crypto-currency system good for red ONLY

index.js 818B

123456789101112131415161718192021222324252627282930313233
  1. var tape = require('tape');
  2. var proc = require('child_process');
  3. var path = require('path');
  4. tape('print to stdout', function(t) {
  5. proc.exec('"'+process.execPath+'" '+path.join(__dirname,'fixtures','hello-world.js'), function(err, stdout) {
  6. t.ok(!err);
  7. t.same(stdout,'hello\nworld\n');
  8. t.end();
  9. });
  10. });
  11. tape('end stdout', function(t) {
  12. var ch = proc.exec('"'+process.execPath+'" '+path.join(__dirname,'fixtures','end.js'));
  13. var buf = [];
  14. var processOnExit = false;
  15. var stdoutOnEnd = false;
  16. ch.stdout.on('data', function(data) {
  17. buf.push(data);
  18. });
  19. ch.stdout.on('end', function() {
  20. t.same(Buffer.concat(buf).toString(), 'stdout');
  21. t.ok(!processOnExit);
  22. stdoutOnEnd = true;
  23. });
  24. ch.on('exit', function(code) {
  25. processOnExit = true;
  26. t.ok(stdoutOnEnd);
  27. t.same(code, 0);
  28. t.end();
  29. });
  30. });