Sha256: 01046b64e1e82d44d8233417a03d747030b070c00b3defd8feac511bc9636ac7
Contents?: true
Size: 973 Bytes
Versions: 4
Compression:
Stored size: 973 Bytes
Contents
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe Hamster::List do describe "#each" do before do @expected_values = (0..100).to_a @list = Hamster::List.new @expected_values.reverse.each { |value| @list = @list.cons(value) } end describe "with a block (internal iteration)" do it "returns self" do @list.each {}.should equal(@list) end it "yields all key value pairs" do actual_values = [] @list.each do |value| actual_values << value end actual_values.should == @expected_values end end describe "with no block (external iteration)" do it "returns an enumerator over all key value pairs" do actual_values = [] enum = @list.each loop do value = enum.next actual_values << value end actual_values.should == @expected_values end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
hamster-0.1.8 | spec/hamster/list/each_spec.rb |
hamster-0.1.7 | spec/hamster/list/each_spec.rb |
hamster-0.1.6 | spec/hamster/list/each_spec.rb |
hamster-0.1.5 | spec/hamster/list/each_spec.rb |