Repositorio del curso CCOM4030 el semestre B91 del proyecto kilometro0

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. var falafel = require('falafel');
  2. var tape = require('../');
  3. var tap = require('tap');
  4. var concat = require('concat-stream');
  5. tap.test('array test', function (tt) {
  6. tt.plan(1);
  7. var test = tape.createHarness();
  8. var tc = function (rows) {
  9. tt.same(rows.toString('utf8'), [
  10. 'TAP version 13',
  11. '# nested array test',
  12. 'ok 1 should be equivalent',
  13. 'ok 2 should be equivalent',
  14. 'ok 3 should be equivalent',
  15. 'ok 4 should be equivalent',
  16. 'ok 5 should be equivalent',
  17. '# inside test',
  18. 'ok 6 should be truthy',
  19. 'ok 7 should be truthy',
  20. '# another',
  21. 'ok 8 should be truthy',
  22. '',
  23. '1..8',
  24. '# tests 8',
  25. '# pass 8',
  26. '',
  27. '# ok'
  28. ].join('\n') + '\n');
  29. };
  30. test.createStream().pipe(concat(tc));
  31. test('nested array test', function (t) {
  32. t.plan(6);
  33. var src = '(' + function () {
  34. var xs = [ 1, 2, [ 3, 4 ] ];
  35. var ys = [ 5, 6 ];
  36. g([ xs, ys ]);
  37. } + ')()';
  38. var output = falafel(src, function (node) {
  39. if (node.type === 'ArrayExpression') {
  40. node.update('fn(' + node.source() + ')');
  41. }
  42. });
  43. t.test('inside test', function (q) {
  44. q.plan(2);
  45. q.ok(true);
  46. setTimeout(function () {
  47. q.ok(true);
  48. }, 100);
  49. });
  50. var arrays = [
  51. [ 3, 4 ],
  52. [ 1, 2, [ 3, 4 ] ],
  53. [ 5, 6 ],
  54. [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
  55. ];
  56. Function(['fn','g'], output)(
  57. function (xs) {
  58. t.same(arrays.shift(), xs);
  59. return xs;
  60. },
  61. function (xs) {
  62. t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
  63. }
  64. );
  65. });
  66. test('another', function (t) {
  67. t.plan(1);
  68. setTimeout(function () {
  69. t.ok(true);
  70. }, 50);
  71. });
  72. });