summaryrefslogtreecommitdiff
path: root/spec/ruby/language/block_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/language/block_spec.rb')
-rw-r--r--spec/ruby/language/block_spec.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/ruby/language/block_spec.rb b/spec/ruby/language/block_spec.rb
index 8f3c39df31..bf613433e7 100644
--- a/spec/ruby/language/block_spec.rb
+++ b/spec/ruby/language/block_spec.rb
@@ -217,6 +217,12 @@ describe "A block" do
it "does not raise an exception when values are yielded" do
@y.s(0) { 1 }.should == 1
end
+
+ ruby_version_is "2.5" do
+ it "may include a rescue clause" do
+ eval("@y.z do raise ArgumentError; rescue ArgumentError; 7; end").should == 7
+ end
+ end
end
describe "taking || arguments" do
@@ -227,6 +233,12 @@ describe "A block" do
it "does not raise an exception when values are yielded" do
@y.s(0) { || 1 }.should == 1
end
+
+ ruby_version_is "2.5" do
+ it "may include a rescue clause" do
+ eval('@y.z do || raise ArgumentError; rescue ArgumentError; 7; end').should == 7
+ end
+ end
end
describe "taking |a| arguments" do
@@ -252,6 +264,12 @@ describe "A block" do
it "does not destructure a single Array value" do
@y.s([1, 2]) { |a| a }.should == [1, 2]
end
+
+ ruby_version_is "2.5" do
+ it "may include a rescue clause" do
+ eval('@y.s(1) do |x| raise ArgumentError; rescue ArgumentError; 7; end').should == 7
+ end
+ end
end
describe "taking |a, b| arguments" do
@@ -626,6 +644,12 @@ describe "A block" do
end
end
+ describe "taking |*a, b:|" do
+ it "merges the hash into the splatted array" do
+ @y.k { |*a, b:| [a, b] }.should == [[], true]
+ end
+ end
+
describe "arguments with _" do
it "extracts arguments with _" do
@y.m([[1, 2, 3], 4]) { |(_, a, _), _| a }.should == 2