Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
865 B

  1. var traverse = require('../');
  2. var test = require('tape');
  3. test('subexpr', function (t) {
  4. var obj = [ 'a', 4, 'b', 5, 'c', 6 ];
  5. var r = traverse(obj).map(function (x) {
  6. if (typeof x === 'number') {
  7. this.update([ x - 0.1, x, x + 0.1 ], true);
  8. }
  9. });
  10. t.same(obj, [ 'a', 4, 'b', 5, 'c', 6 ]);
  11. t.same(r, [
  12. 'a', [ 3.9, 4, 4.1 ],
  13. 'b', [ 4.9, 5, 5.1 ],
  14. 'c', [ 5.9, 6, 6.1 ],
  15. ]);
  16. t.end();
  17. });
  18. test('block', function (t) {
  19. var obj = [ [ 1 ], [ 2 ], [ 3 ] ];
  20. var r = traverse(obj).map(function (x) {
  21. if (Array.isArray(x) && !this.isRoot) {
  22. if (x[0] === 5) this.block()
  23. else this.update([ [ x[0] + 1 ] ])
  24. }
  25. });
  26. t.same(r, [
  27. [ [ [ [ [ 5 ] ] ] ] ],
  28. [ [ [ [ 5 ] ] ] ],
  29. [ [ [ 5 ] ] ],
  30. ]);
  31. t.end();
  32. });