a zip code crypto-currency system good for red ONLY

polyfill.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. 'use strict';
  2. var aFrom = require('es5-ext/array/from')
  3. , toArray = require('es5-ext/array/to-array');
  4. module.exports = function (T, a) {
  5. var arr = [['raz', 'one'], ['dwa', 'two'], ['trzy', 'three']]
  6. , map = new T(arr), x = {}, y = {}, i = 0;
  7. a(map instanceof T, true, "Map");
  8. a(map.size, 3, "Size");
  9. a(map.get('raz'), 'one', "Get: contained");
  10. a(map.get(x), undefined, "Get: not contained");
  11. a(map.has('raz'), true, "Has: contained");
  12. a(map.has(x), false, "Has: not contained");
  13. a(map.set(x, y), map, "Set: return");
  14. a(map.has(x), true, "Set: has");
  15. a(map.get(x), y, "Set: get");
  16. a(map.size, 4, "Set: Size");
  17. map.set('dwa', x);
  18. a(map.get('dwa'), x, "Overwrite: get");
  19. a(map.size, 4, "Overwrite: size");
  20. a(map.delete({}), false, "Delete: false");
  21. arr.push([x, y]);
  22. arr[1][1] = x;
  23. map.forEach(function () {
  24. a.deep(aFrom(arguments), [arr[i][1], arr[i][0], map],
  25. "ForEach: Arguments: #" + i);
  26. a(this, y, "ForEach: Context: #" + i);
  27. if (i === 0) {
  28. a(map.delete('raz'), true, "Delete: true");
  29. a(map.has('raz'), false, "Delete");
  30. a(map.size, 3, "Delete: size");
  31. map.set('cztery', 'four');
  32. arr.push(['cztery', 'four']);
  33. }
  34. i++;
  35. }, y);
  36. arr.splice(0, 1);
  37. a.deep(toArray(map.entries()), [['dwa', x], ['trzy', 'three'], [x, y],
  38. ['cztery', 'four']], "Entries");
  39. a.deep(toArray(map.keys()), ['dwa', 'trzy', x, 'cztery'], "Keys");
  40. a.deep(toArray(map.values()), [x, 'three', y, 'four'], "Values");
  41. a.deep(toArray(map), [['dwa', x], ['trzy', 'three'], [x, y],
  42. ['cztery', 'four']], "Iterator");
  43. map.clear();
  44. a(map.size, 0, "Clear: size");
  45. a(map.has('trzy'), false, "Clear: has");
  46. a.deep(toArray(map), [], "Clear: Values");
  47. a.h1("Empty initialization");
  48. map = new T();
  49. map.set('foo', 'bar');
  50. a(map.size, 1);
  51. a(map.get('foo'), 'bar');
  52. };