for-of.js 996 B

1234567891011121314151617181920212223242526272829303132333435
  1. 'use strict';
  2. var ArrayIterator = require('../array')
  3. , slice = Array.prototype.slice;
  4. module.exports = function (t, a) {
  5. var i = 0, x = ['raz', 'dwa', 'trzy'], y = {}, called = 0;
  6. t(x, function () {
  7. a.deep(slice.call(arguments, 0, 1), [x[i]], "Array " + i + "#");
  8. a(this, y, "Array: context: " + (i++) + "#");
  9. }, y);
  10. i = 0;
  11. t(x = 'foo', function () {
  12. a.deep(slice.call(arguments, 0, 1), [x[i]], "String " + i + "#");
  13. a(this, y, "Regular String: context: " + (i++) + "#");
  14. }, y);
  15. i = 0;
  16. x = ['r', '💩', 'z'];
  17. t('r💩z', function () {
  18. a.deep(slice.call(arguments, 0, 1), [x[i]], "String " + i + "#");
  19. a(this, y, "Unicode String: context: " + (i++) + "#");
  20. }, y);
  21. i = 0;
  22. t(new ArrayIterator(x), function () {
  23. a.deep(slice.call(arguments, 0, 1), [x[i]], "Iterator " + i + "#");
  24. a(this, y, "Iterator: context: " + (i++) + "#");
  25. }, y);
  26. t(x = ['raz', 'dwa', 'trzy'], function (value, doBreak) {
  27. ++called;
  28. return doBreak();
  29. });
  30. a(called, 1, "Break");
  31. };