Repositorio del curso CCOM4030 el semestre B91 del proyecto kilometro0

ok.js 804B

123456789101112131415161718192021222324252627282930313233343536
  1. var falafel = require('falafel');
  2. var test = require('../../');
  3. test('array', function (t) {
  4. t.comment('hi');
  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. var arrays = [
  17. [ 3, 4 ],
  18. [ 1, 2, [ 3, 4 ] ],
  19. [ 5, 6 ],
  20. [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
  21. ];
  22. Function(['fn','g'], output)(
  23. function (xs) {
  24. t.same(arrays.shift(), xs);
  25. return xs;
  26. },
  27. function (xs) {
  28. t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
  29. }
  30. );
  31. });