a zip code crypto-currency system good for red ONLY

inspect.js 853B

12345678910111213141516171819202122232425262728293031323334353637
  1. var falafel = require('../');
  2. var test = require('tape');
  3. test('inspect', function (t) {
  4. t.plan(6);
  5. var src = '(function () {'
  6. + 'var xs = [ 1, 2, [ 3, 4 ] ];'
  7. + 'var ys = [ 5, 6 ];'
  8. + 'g([ xs, ys ]);'
  9. + '})()';
  10. var output = falafel(src, function (node) {
  11. if (node.type === 'ArrayExpression') {
  12. node.update('fn(' + node.source() + ')');
  13. }
  14. });
  15. t.equal(output.inspect(), output.toString());
  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. });