Sha256: bddc3944ef6ef1fc0d40535f316e187735c92ec0508800b303ac9a3f10cb035f

Contents?: true

Size: 474 Bytes

Versions: 2

Compression:

Stored size: 474 Bytes

Contents

require'mathn'

describe "Prime#each" do
  it "enumerates the elements" do
    primes = Prime.new
    result = []

    primes.each { |p|
      result << p
      break if p > 10
    }

    result.should == [2, 3, 5, 7, 11]
  end

  it "don't rewind the generator, each loop start at the current value" do
    primes = Prime.new
    primes.next
    result = []

    primes.each { |p|
      result << p
      break if p > 10
    }

    result.should == [3, 5, 7, 11]
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubysl-mathn-1.0.0 spec/prime/each_spec.rb
rubysl-mathn-2.0.0 spec/prime/each_spec.rb