a zip code crypto-currency system good for red ONLY

opts.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. var falafel = require('../');
  2. var test = require('tape');
  3. test('first opts arg', function (t) {
  4. t.plan(5);
  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({ source: src }, function (node) {
  11. if (node.type === 'ArrayExpression') {
  12. node.update('fn(' + node.source() + ')');
  13. }
  14. });
  15. var arrays = [
  16. [ 3, 4 ],
  17. [ 1, 2, [ 3, 4 ] ],
  18. [ 5, 6 ],
  19. [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
  20. ];
  21. Function(['fn','g'], output)(
  22. function (xs) {
  23. t.same(arrays.shift(), xs);
  24. return xs;
  25. },
  26. function (xs) {
  27. t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
  28. }
  29. );
  30. });
  31. test('opts.source', function (t) {
  32. t.plan(5);
  33. var src = '(function () {'
  34. + 'var xs = [ 1, 2, [ 3, 4 ] ];'
  35. + 'var ys = [ 5, 6 ];'
  36. + 'g([ xs, ys ]);'
  37. + '})()';
  38. var output = falafel(undefined, { source: src }, function (node) {
  39. if (node.type === 'ArrayExpression') {
  40. node.update('fn(' + node.source() + ')');
  41. }
  42. });
  43. var arrays = [
  44. [ 3, 4 ],
  45. [ 1, 2, [ 3, 4 ] ],
  46. [ 5, 6 ],
  47. [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
  48. ];
  49. Function(['fn','g'], output)(
  50. function (xs) {
  51. t.same(arrays.shift(), xs);
  52. return xs;
  53. },
  54. function (xs) {
  55. t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
  56. }
  57. );
  58. });
  59. test('Buffer opts.source', function (t) {
  60. t.plan(5);
  61. var src = Buffer('(function () {'
  62. + 'var xs = [ 1, 2, [ 3, 4 ] ];'
  63. + 'var ys = [ 5, 6 ];'
  64. + 'g([ xs, ys ]);'
  65. + '})()');
  66. var output = falafel({ source: src }, function (node) {
  67. if (node.type === 'ArrayExpression') {
  68. node.update('fn(' + node.source() + ')');
  69. }
  70. });
  71. var arrays = [
  72. [ 3, 4 ],
  73. [ 1, 2, [ 3, 4 ] ],
  74. [ 5, 6 ],
  75. [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
  76. ];
  77. Function(['fn','g'], output)(
  78. function (xs) {
  79. t.same(arrays.shift(), xs);
  80. return xs;
  81. },
  82. function (xs) {
  83. t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
  84. }
  85. );
  86. });
  87. test('Buffer source', function (t) {
  88. t.plan(5);
  89. var src = Buffer('(function () {'
  90. + 'var xs = [ 1, 2, [ 3, 4 ] ];'
  91. + 'var ys = [ 5, 6 ];'
  92. + 'g([ xs, ys ]);'
  93. + '})()');
  94. var output = falafel(src, function (node) {
  95. if (node.type === 'ArrayExpression') {
  96. node.update('fn(' + node.source() + ')');
  97. }
  98. });
  99. var arrays = [
  100. [ 3, 4 ],
  101. [ 1, 2, [ 3, 4 ] ],
  102. [ 5, 6 ],
  103. [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
  104. ];
  105. Function(['fn','g'], output)(
  106. function (xs) {
  107. t.same(arrays.shift(), xs);
  108. return xs;
  109. },
  110. function (xs) {
  111. t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
  112. }
  113. );
  114. });