Sha256: fe5be5657ccae371d8695a4ee32e30f3eff4b62fb4bd3a3c7fe345282e442a09

Contents?: true

Size: 731 Bytes

Versions: 10

Compression:

Stored size: 731 Bytes

Contents

describe "Enumerator#next" do
  before :each do
    @enum = enumerator_class.new(1, :upto, 3)
  end

  it "returns the next element of the enumeration" do
    @enum.next.should == 1
    @enum.next.should == 2
    @enum.next.should == 3
  end

  it "raises a StopIteration exception at the end of the stream" do
    3.times { @enum.next }
    lambda { @enum.next }.should raise_error(StopIteration)
  end

  it "cannot be called again until the enumerator is rewound" do
    3.times { @enum.next }
    lambda { @enum.next }.should raise_error(StopIteration)
    lambda { @enum.next }.should raise_error(StopIteration)
    lambda { @enum.next }.should raise_error(StopIteration)
    @enum.rewind
    @enum.next.should == 1
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
opal-0.4.4 spec/rubyspec/core/enumerator/next_spec.rb
opal-0.4.3 spec/rubyspec/core/enumerator/next_spec.rb
opal-0.4.2 spec/rubyspec/core/enumerator/next_spec.rb
opal-0.4.1 spec/rubyspec/core/enumerator/next_spec.rb
opal-0.4.0 spec/rubyspec/core/enumerator/next_spec.rb
opal-0.3.44 spec/rubyspec/core/enumerator/next_spec.rb
opal-0.3.43 spec/rubyspec/core/enumerator/next_spec.rb
opal-0.3.42 spec/core/enumerator/next_spec.rb
opal-0.3.41 spec/core/enumerator/next_spec.rb
opal-0.3.40 spec/core/enumerator/next_spec.rb