Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. test.createStream().pipe(concat(function (rows) {
  9. tt.same(rows.toString('utf8'), [
  10. 'TAP version 13',
  11. '# array',
  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. '',
  18. '1..5',
  19. '# tests 5',
  20. '# pass 5',
  21. '',
  22. '# ok'
  23. ].join('\n') + '\n');
  24. }));
  25. test('array', function (t) {
  26. t.plan(5);
  27. var src = '(' + function () {
  28. var xs = [ 1, 2, [ 3, 4 ] ];
  29. var ys = [ 5, 6 ];
  30. g([ xs, ys ]);
  31. } + ')()';
  32. var output = falafel(src, function (node) {
  33. if (node.type === 'ArrayExpression') {
  34. node.update('fn(' + node.source() + ')');
  35. }
  36. });
  37. var arrays = [
  38. [ 3, 4 ],
  39. [ 1, 2, [ 3, 4 ] ],
  40. [ 5, 6 ],
  41. [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
  42. ];
  43. Function(['fn','g'], output)(
  44. function (xs) {
  45. t.same(arrays.shift(), xs);
  46. return xs;
  47. },
  48. function (xs) {
  49. t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
  50. }
  51. );
  52. });
  53. });