Repositorio del curso CCOM4030 el semestre B91 del proyecto Paz para la Mujer

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. var falafel = require('falafel');
  2. var tape = require('../');
  3. var tap = require('tap');
  4. var concat = require('concat-stream');
  5. var stripFullStack = require('./common').stripFullStack;
  6. tap.test('array test', function (tt) {
  7. tt.plan(1);
  8. var test = tape.createHarness({ exit : false });
  9. var tc = function (rows) {
  10. tt.same(stripFullStack(rows.toString('utf8')), [
  11. 'TAP version 13',
  12. '# array',
  13. 'ok 1 should be equivalent',
  14. 'ok 2 should be equivalent',
  15. 'ok 3 should be equivalent',
  16. 'ok 4 should be equivalent',
  17. 'not ok 5 should be equivalent',
  18. ' ---',
  19. ' operator: deepEqual',
  20. ' expected: [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]',
  21. ' actual: [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]',
  22. ' at: <anonymous> ($TEST/fail.js:$LINE:$COL)',
  23. ' stack: |-',
  24. ' Error: should be equivalent',
  25. ' [... stack stripped ...]',
  26. ' at $TEST/fail.js:$LINE:$COL',
  27. ' at eval (eval at <anonymous> ($TEST/fail.js:$LINE:$COL))',
  28. ' at eval (eval at <anonymous> ($TEST/fail.js:$LINE:$COL))',
  29. ' at Test.<anonymous> ($TEST/fail.js:$LINE:$COL)',
  30. ' [... stack stripped ...]',
  31. ' ...',
  32. '',
  33. '1..5',
  34. '# tests 5',
  35. '# pass 4',
  36. '# fail 1',
  37. ''
  38. ].join('\n'));
  39. };
  40. test.createStream().pipe(concat(tc));
  41. test('array', function (t) {
  42. t.plan(5);
  43. var src = '(' + function () {
  44. var xs = [ 1, 2, [ 3, 4 ] ];
  45. var ys = [ 5, 6 ];
  46. g([ xs, ys ]);
  47. } + ')()';
  48. var output = falafel(src, function (node) {
  49. if (node.type === 'ArrayExpression') {
  50. node.update('fn(' + node.source() + ')');
  51. }
  52. });
  53. var arrays = [
  54. [ 3, 4 ],
  55. [ 1, 2, [ 3, 4 ] ],
  56. [ 5, 6 ],
  57. [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
  58. ];
  59. Function(['fn','g'], output)(
  60. function (xs) {
  61. t.same(arrays.shift(), xs);
  62. return xs;
  63. },
  64. function (xs) {
  65. t.same(xs, [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]);
  66. }
  67. );
  68. });
  69. });