Sha256: 841e9b6d4bc3eacd474c01b8602a7f6ab8335cb56eaadf6f9c982a0d9c8ffdd3
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'hamster/list' describe Hamster::List do describe "#all?" do describe "doesn't run out of stack space on a really big" do before do @interval = Hamster.interval(0, 10000) end it "stream" do @list = @interval end it "list" do @list = @interval.reduce(Hamster.list) { |list, i| list.cons(i) } end after do @interval.all? { true } end end describe "when empty" do before do @list = Hamster.list end it "with a block returns true" do @list.all? {}.should be_true end it "with no block returns true" do @list.all?.should be_true end end describe "when not empty" do describe "with a block" do before do @list = Hamster.list("A", "B", "C") end it "returns true if the block always returns true" do @list.all? { |item| true }.should be_true end it "returns false if the block ever returns false" do @list.all? { |item| item == "D" }.should be_false end end describe "with no block" do it "returns true if all values are truthy" do Hamster.list(true, "A").all?.should be_true end [nil, false].each do |value| it "returns false if any value is #{value.inspect}" do Hamster.list(value, true, "A").all?.should be_false end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hamster-0.1.16 | spec/hamster/list/all_spec.rb |