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

too_many.js 2.3KB

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 plan != count',
  18. ' ---',
  19. ' operator: fail',
  20. ' expected: 3',
  21. ' actual: 4',
  22. ' at: <anonymous> ($TEST/too_many.js:$LINE:$COL)',
  23. ' stack: |-',
  24. ' Error: plan != count',
  25. ' [... stack stripped ...]',
  26. ' at $TEST/too_many.js:$LINE:$COL',
  27. ' at eval (eval at <anonymous> ($TEST/too_many.js:$LINE:$COL))',
  28. ' at eval (eval at <anonymous> ($TEST/too_many.js:$LINE:$COL))',
  29. ' at Test.<anonymous> ($TEST/too_many.js:$LINE:$COL)',
  30. ' [... stack stripped ...]',
  31. ' ...',
  32. 'ok 6 should be equivalent',
  33. '',
  34. '1..6',
  35. '# tests 6',
  36. '# pass 5',
  37. '# fail 1'
  38. ].join('\n') + '\n');
  39. };
  40. test.createStream().pipe(concat(tc));
  41. test('array', function (t) {
  42. t.plan(3);
  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, 4 ] ], [ 5, 6 ] ]);
  66. }
  67. );
  68. });
  69. });