nested.js 892 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. 'use strict';
  2. var falafel = require('falafel');
  3. var test = require('../');
  4. test('nested array test', function (t) {
  5. t.plan(5);
  6. var src = '(' + function () {
  7. var xs = [1, 2, [3, 4]];
  8. var ys = [5, 6];
  9. g([ xs, ys ]);
  10. } + ')()';
  11. var output = falafel(src, function (node) {
  12. if (node.type === 'ArrayExpression') {
  13. node.update('fn(' + node.source() + ')');
  14. }
  15. });
  16. t.test('inside test', function (q) {
  17. q.plan(2);
  18. q.ok(true, 'inside ok');
  19. setTimeout(function () {
  20. q.ok(true, 'inside delayed');
  21. }, 3000);
  22. });
  23. var arrays = [
  24. [3, 4],
  25. [1, 2, [3, 4]],
  26. [5, 6],
  27. [[ 1, 2, [3, 4]], [5, 6]]
  28. ];
  29. Function(['fn', 'g'], output)(
  30. function (xs) {
  31. t.same(arrays.shift(), xs);
  32. return xs;
  33. },
  34. function (xs) {
  35. t.same(xs, [[1, 2, [3, 4]], [5, 6]]);
  36. }
  37. );
  38. });
  39. test('another', function (t) {
  40. t.plan(1);
  41. setTimeout(function () {
  42. t.ok(true);
  43. }, 100);
  44. });