<commit_before>require File.expand_path('../../../spec_helper', __FILE__)

ruby_version_is "1.9" do
  describe "Enumerator#peek_values" do
    before(:each) do
      o = Object.new
      def o.each
        yield :a
        yield :b1, :b2
        yield :c
        yield :d1, :d2
        yield :e1, :e2, :e3
      end

      @e = o.to_enum
    end

    it "returns the next element in self" do
      @e.peek_values.should == [:a]
    end

    it "does not advance the position of the current element" do
      @e.next.should == :a
      @e.peek_values.should == [:b1, :b2]
      @e.next.should == [:b1, :b2]
    end

    it "can be called repeatedly without advancing the position of the current element" do
      @e.peek_values
      @e.peek_values
      @e.peek_values.should == [:a]
      @e.next.should == :a
    end

    it "works in concert with #rewind" do
      @e.next
      @e.next
      @e.rewind
      @e.peek_values.should == [:a]
    end

    it "raises StopIteration if called on a finished enumerator" do
      5.times { @e.next }
      lambda { @e.peek_values }.should raise_error(StopIteration)
    end
  end
end<commit_msg>Add specs for Enumerator#peek_values<commit_after>require File.expand_path('../../../spec_helper', __FILE__)

ruby_version_is "1.9" do
  describe "Enumerator#peek_values" do
    before(:each) do
      o = Object.new
      def o.each
        yield :a
        yield :b1, :b2
        yield :c
        yield :d1, :d2
        yield :e1, :e2, :e3
        yield nil
        yield
      end

      @e = o.to_enum
    end

    it "returns the next element in self" do
      @e.peek_values.should == [:a]
    end

    it "does not advance the position of the current element" do
      @e.next.should == :a
      @e.peek_values.should == [:b1, :b2]
      @e.next.should == [:b1, :b2]
    end

    it "can be called repeatedly without advancing the position of the current element" do
      @e.peek_values
      @e.peek_values
      @e.peek_values.should == [:a]
      @e.next.should == :a
    end

    it "works in concert with #rewind" do
      @e.next
      @e.next
      @e.rewind
      @e.peek_values.should == [:a]
    end

    it "returns an array with only nil if yield is called with nil" do
      5.times { @e.next }
      @e.peek_values.should == [nil]
    end

    it "returns an empty array if yield is called without arguments" do
      6.times { @e.next }
      @e.peek_values.should == []
    end

    it "raises StopIteration if called on a finished enumerator" do
      7.times { @e.next }
      lambda { @e.peek_values }.should raise_error(StopIteration)
    end
  end
end
{'fraction_non_alphanumeric': 0.11416571210385644, 'fraction_numerical': 0.011454753722794959, 'mean_word_length': 2.050058207217695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '5881768', 'n_tokens_mistral': 937, 'n_tokens_neox': 919, 'n_words': 274}