ruby-changes:60051
From: Alan <ko1@a...>
Date: Thu, 13 Feb 2020 15:23:24 +0900 (JST)
Subject: [ruby-changes:60051] 52bb32d6b7 (ruby_2_7): Fix Proc#<< spec
https://git.ruby-lang.org/ruby.git/commit/?id=52bb32d6b7 From 52bb32d6b71365cb24273de3eed5a712206815f3 Mon Sep 17 00:00:00 2001 From: Alan Wu <XrXr@u...> Date: Mon, 30 Dec 2019 18:13:55 -0500 Subject: Fix Proc#<< spec [Bug #16406] diff --git a/spec/ruby/core/proc/compose_spec.rb b/spec/ruby/core/proc/compose_spec.rb index 35e949a..ef9c125 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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/proc/compose_spec.rb#L38 (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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/proc/compose_spec.rb#L121 (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 } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/