intersection.js 705 B

123456789101112131415161718192021222324
  1. 'use strict';
  2. var toArray = require('../../../array/to-array');
  3. module.exports = {
  4. __generic: function (t, a) {
  5. a.deep(t.call(this, this, this), toArray(this));
  6. },
  7. "": function (t, a) {
  8. var x = {}, y = {}, p, r;
  9. a.deep(t.call([], [2, 3, 4]), [], "Empty #1");
  10. a.deep(t.call([2, 3, 4], []), [], "Empty #2");
  11. a.deep(t.call([2, 3, x], [y, 5, 7]), [], "Different");
  12. p = t.call([3, 5, 'raz', {}, 'dwa', x], [1, 3, 'raz', 'dwa', 'trzy', x, {}],
  13. [3, 'raz', x, 65]);
  14. r = [3, 'raz', x];
  15. p.sort();
  16. r.sort();
  17. a.deep(p, r, "Same parts");
  18. a.deep(t.call(r, r), r, "Same");
  19. a.deep(t.call([1, 2, x, 4, 5, y, 7], [7, y, 5, 4, x, 2, 1]),
  20. [1, 2, x, 4, 5, y, 7], "Long reverse same");
  21. }
  22. };