aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2019-12-30 18:13:55 -0500
committerNARUSE, Yui <naruse@airemix.jp>2020-01-16 17:52:04 +0900
commit52bb32d6b71365cb24273de3eed5a712206815f3 (patch)
treed43f323fd83e7bf9cf75b602eca7c99d88b63870 /spec
parentdb4d136889afbf59e69efcfd495fd91cd401f378 (diff)
downloadruby-52bb32d6b71365cb24273de3eed5a712206815f3.tar.gz
Fix Proc#<< spec
[Bug #16406]
Diffstat (limited to 'spec')
-rw-r--r--spec/ruby/core/proc/compose_spec.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/ruby/core/proc/compose_spec.rb b/spec/ruby/core/proc/compose_spec.rb
index 35e949a779..ef9c125ae9 100644
--- a/spec/ruby/core/proc/compose_spec.rb
+++ b/spec/ruby/core/proc/compose_spec.rb
@@ -38,6 +38,36 @@ ruby_version_is "2.6" do
(f << g).lambda?.should == false
end
+ ruby_version_is(''...'2.8') do
+ it "is a Proc when other is lambda" do
+ f = proc { |x| x * x }
+ g = -> x { x + x }
+
+ (f << g).is_a?(Proc).should == true
+ (f << g).lambda?.should == false
+ end
+
+ it "is a lambda when self is lambda" do
+ f = -> x { x * x }
+ g = proc { |x| x + x }
+
+ (f << g).is_a?(Proc).should == true
+ (f << g).lambda?.should == true
+ end
+ end
+
+ ruby_version_is('2.8') do
+ it "is a lambda when parameter is lambda" do
+ f = -> x { x * x }
+ g = proc { |x| x + x }
+ lambda_proc = -> x { x }
+
+ (f << g).is_a?(Proc).should == true
+ (f << g).lambda?.should == false
+ (f << lambda_proc).lambda?.should == true
+ end
+ end
+
it "may accept multiple arguments" do
inc = proc { |n| n + 1 }
mul = proc { |n, m| n * m }
@@ -91,6 +121,22 @@ ruby_version_is "2.6" do
(f >> g).lambda?.should == false
end
+ it "is a Proc when other is lambda" do
+ f = proc { |x| x * x }
+ g = -> x { x + x }
+
+ (f >> g).is_a?(Proc).should == true
+ (f >> g).lambda?.should == false
+ end
+
+ it "is a lambda when self is lambda" do
+ f = -> x { x * x }
+ g = proc { |x| x + x }
+
+ (f >> g).is_a?(Proc).should == true
+ (f >> g).lambda?.should == true
+ end
+
it "may accept multiple arguments" do
inc = proc { |n| n + 1 }
mul = proc { |n, m| n * m }