mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@875a09e
This commit is contained in:
parent
a06301b103
commit
5c276e1cc9
1247 changed files with 5316 additions and 5028 deletions
|
@ -40,7 +40,7 @@ describe "Enumerator::Lazy#drop_while" do
|
|||
end
|
||||
|
||||
it "raises an ArgumentError when not given a block" do
|
||||
lambda { @yieldsmixed.drop_while }.should raise_error(ArgumentError)
|
||||
-> { @yieldsmixed.drop_while }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
describe "on a nested Lazy" do
|
||||
|
|
|
@ -33,6 +33,39 @@ describe "Enumerator::Lazy#grep" do
|
|||
Enumerator::Lazy.new(Object.new, 100) {}.grep(Object).size.should == nil
|
||||
end
|
||||
|
||||
it "sets $~ in the block" do
|
||||
"z" =~ /z/ # Reset $~
|
||||
["abc", "def"].lazy.grep(/b/) { |e|
|
||||
e.should == "abc"
|
||||
$&.should == "b"
|
||||
}.force
|
||||
|
||||
# Set by the failed match of "def"
|
||||
$~.should == nil
|
||||
end
|
||||
|
||||
it "sets $~ in the next block with each" do
|
||||
"z" =~ /z/ # Reset $~
|
||||
["abc", "def"].lazy.grep(/b/).each { |e|
|
||||
e.should == "abc"
|
||||
$&.should == "b"
|
||||
}
|
||||
|
||||
# Set by the failed match of "def"
|
||||
$~.should == nil
|
||||
end
|
||||
|
||||
it "sets $~ in the next block with map" do
|
||||
"z" =~ /z/ # Reset $~
|
||||
["abc", "def"].lazy.grep(/b/).map { |e|
|
||||
e.should == "abc"
|
||||
$&.should == "b"
|
||||
}.force
|
||||
|
||||
# Set by the failed match of "def"
|
||||
$~.should == nil
|
||||
end
|
||||
|
||||
describe "when the returned lazy enumerator is evaluated by Enumerable#first" do
|
||||
it "stops after specified times when not given a block" do
|
||||
(0..Float::INFINITY).lazy.grep(Integer).first(3).should == [0, 1, 2]
|
||||
|
|
|
@ -31,6 +31,39 @@ describe "Enumerator::Lazy#grep_v" do
|
|||
Enumerator::Lazy.new(Object.new, 100) {}.grep_v(Object).size.should == nil
|
||||
end
|
||||
|
||||
it "sets $~ in the block" do
|
||||
"z" =~ /z/ # Reset $~
|
||||
["abc", "def"].lazy.grep_v(/e/) { |e|
|
||||
e.should == "abc"
|
||||
$~.should == nil
|
||||
}.force
|
||||
|
||||
# Set by the match of "def"
|
||||
$&.should == "e"
|
||||
end
|
||||
|
||||
it "sets $~ in the next block with each" do
|
||||
"z" =~ /z/ # Reset $~
|
||||
["abc", "def"].lazy.grep_v(/e/).each { |e|
|
||||
e.should == "abc"
|
||||
$~.should == nil
|
||||
}
|
||||
|
||||
# Set by the match of "def"
|
||||
$&.should == "e"
|
||||
end
|
||||
|
||||
it "sets $~ in the next block with map" do
|
||||
"z" =~ /z/ # Reset $~
|
||||
["abc", "def"].lazy.grep_v(/e/).map { |e|
|
||||
e.should == "abc"
|
||||
$~.should == nil
|
||||
}.force
|
||||
|
||||
# Set by the match of "def"
|
||||
$&.should == "e"
|
||||
end
|
||||
|
||||
describe "when the returned lazy enumerator is evaluated by Enumerable#first" do
|
||||
it "stops after specified times when not given a block" do
|
||||
(0..Float::INFINITY).lazy.grep_v(3..5).first(3).should == [0, 1, 2]
|
||||
|
|
|
@ -48,16 +48,16 @@ describe "Enumerator::Lazy#initialize" do
|
|||
end
|
||||
|
||||
it "sets given size to own size if the given size is a Proc" do
|
||||
@uninitialized.send(:initialize, @receiver, lambda { 200 }) {}.size.should == 200
|
||||
@uninitialized.send(:initialize, @receiver, -> { 200 }) {}.size.should == 200
|
||||
end
|
||||
|
||||
it "raises an ArgumentError when block is not given" do
|
||||
lambda { @uninitialized.send :initialize, @receiver }.should raise_error(ArgumentError)
|
||||
-> { @uninitialized.send :initialize, @receiver }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
describe "on frozen instance" do
|
||||
it "raises a RuntimeError" do
|
||||
lambda { @uninitialized.freeze.send(:initialize, @receiver) {} }.should raise_error(RuntimeError)
|
||||
-> { @uninitialized.freeze.send(:initialize, @receiver) {} }.should raise_error(RuntimeError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -52,7 +52,7 @@ describe "Enumerator::Lazy#reject" do
|
|||
end
|
||||
|
||||
it "raises an ArgumentError when not given a block" do
|
||||
lambda { @yieldsmixed.reject }.should raise_error(ArgumentError)
|
||||
-> { @yieldsmixed.reject }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
describe "on a nested Lazy" do
|
||||
|
|
|
@ -46,7 +46,7 @@ describe :enumerator_lazy_collect_concat, shared: true do
|
|||
end
|
||||
|
||||
it "raises an ArgumentError when not given a block" do
|
||||
lambda { @yieldsmixed.send(@method) }.should raise_error(ArgumentError)
|
||||
-> { @yieldsmixed.send(@method) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
describe "on a nested Lazy" do
|
||||
|
|
|
@ -40,7 +40,7 @@ describe :enumerator_lazy_select, shared: true do
|
|||
end
|
||||
|
||||
it "raises an ArgumentError when not given a block" do
|
||||
lambda { @yieldsmixed.send(@method) }.should raise_error(ArgumentError)
|
||||
-> { @yieldsmixed.send(@method) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
describe "on a nested Lazy" do
|
||||
|
|
|
@ -40,7 +40,7 @@ describe "Enumerator::Lazy#take_while" do
|
|||
end
|
||||
|
||||
it "raises an ArgumentError when not given a block" do
|
||||
lambda { @yieldsmixed.take_while }.should raise_error(ArgumentError)
|
||||
-> { @yieldsmixed.take_while }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
describe "on a nested Lazy" do
|
||||
|
|
|
@ -44,7 +44,7 @@ describe "Enumerator::Lazy#zip" do
|
|||
end
|
||||
|
||||
it "raises a TypeError if arguments contain non-list object" do
|
||||
lambda { @yieldsmixed.zip [], Object.new, [] }.should raise_error(TypeError)
|
||||
-> { @yieldsmixed.zip [], Object.new, [] }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
describe "on a nested Lazy" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue