<commit_before>// 38: iterator/iterable - string. 
// The iterator protocol defines a standard way to produce a sequence of values (either finite or infinite).
// read more at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols

// To do: make all tests pass, leave the assert lines unchanged!

describe('string is a built-in iterable object', function() {
  
  const s = 'abc';
  
  describe('string is iterable', function() {
    it('the string`s object key `Symbol.iterator` is a function', function() {
      const isA = s;
      assert.equal(isA, 'function');
    });
    it('use `Array.from()` to make an array out of any iterable', function(){
      const arr = s;
      assert.deepEqual(arr, ['a', 'b', 'c']);
    });
  });
  
  describe('a string`s iterator', function() {
    let iterator;
    beforeEach(function() {
      iterator = s[Symbol.iterator]();
    });
    
    it('has a special string representation', function(){
      const description = iterator.to____();
      assert.equal(description, '[object String Iterator]');
    });
    
    it('`iterator.next()` returns an object according to the iterator protocol', function(){
      const value = iterator.___();
      assert.deepEqual(value, {done: false, value: 'a'});
    });
    
    it('the after-last call to `iterator.next()` says done=false, no more elements', function(){
      iterator.next();
      assert.equal(iterator.next().done, true);
    });
  });
  
});<commit_msg>Fix description to match what shall be done, thanks @chiptus.<commit_after>// 38: iterator/iterable - string. 
// The iterator protocol defines a standard way to produce a sequence of values (either finite or infinite).
// read more at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols

// To do: make all tests pass, leave the assert lines unchanged!

describe('string is a built-in iterable object', function() {
  
  const s = 'abc';
  
  describe('string is iterable', function() {
    it('the string`s object key `Symbol.iterator` is a function', function() {
      const isA = s;
      assert.equal(isA, 'function');
    });
    it('use `Array.from()` to make an array out of any iterable', function(){
      const arr = s;
      assert.deepEqual(arr, ['a', 'b', 'c']);
    });
  });
  
  describe('a string`s iterator', function() {
    let iterator;
    beforeEach(function() {
      iterator = s[Symbol.iterator]();
    });
    
    it('has a special string representation', function(){
      const description = iterator.to____();
      assert.equal(description, '[object String Iterator]');
    });
    
    it('`iterator.next()` returns an object according to the iterator protocol', function(){
      const value = iterator.___();
      assert.deepEqual(value, {done: false, value: 'a'});
    });
    
    it('the after-last call to `iterator.next()` says done=true, no more elements', function(){
      iterator.next();
      assert.equal(iterator.next().done, true);
    });
  });
  
});
{'fraction_non_alphanumeric': 0.15021459227467812, 'fraction_numerical': 0.0013205678441729944, 'mean_word_length': 3.179310344827586, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2961601', 'n_tokens_mistral': 880, 'n_tokens_neox': 857, 'n_words': 281}