double_bundle_parallel.js 808 B

123456789101112131415161718192021222324252627282930313233
  1. var browserify = require('../');
  2. var vm = require('vm');
  3. var test = require('tap').test;
  4. test('double bundle parallel', function (t) {
  5. t.plan(7);
  6. var sources = [];
  7. var b = browserify(__dirname + '/entry/main.js');
  8. var pending = 2;
  9. b.bundle(check(0));
  10. b.bundle(check(1));
  11. function check (index) {
  12. return function (err, src) {
  13. t.ifError(err);
  14. var c = {
  15. done : function (one, two) {
  16. t.equal(one, 1);
  17. t.equal(two, 2);
  18. }
  19. };
  20. vm.runInNewContext(src, c);
  21. sources[index] = src.toString('utf8');
  22. if (--pending === 0) done();
  23. };
  24. }
  25. function done () {
  26. t.equal(sources[0], sources[1]);
  27. }
  28. });