summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2020-06-10 17:50:35 -0700
committerJeremy Evans <code@jeremyevans.net>2020-06-11 07:30:48 -0700
commit2188d6d160d3ba82432c87277310a4d417e136d5 (patch)
treef885cb534dc38c06db3431076719436563f96fb9 /test/ruby
parent5349506eb4c0668fa1d6f512e4dae1021a9a7460 (diff)
Warn when passing a non-literal block to Kernel#lambda
Implements [Feature #15973]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3209
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_iterator.rb3
-rw-r--r--test/ruby/test_lambda.rb6
2 files changed, 7 insertions, 2 deletions
diff --git a/test/ruby/test_iterator.rb b/test/ruby/test_iterator.rb
index 54c095338f..820d5591c1 100644
--- a/test/ruby/test_iterator.rb
+++ b/test/ruby/test_iterator.rb
@@ -339,8 +339,7 @@ class TestIterator < Test::Unit::TestCase
marity_test(:marity_test)
marity_test(:p)
- lambda(&method(:assert)).call(true)
- lambda(&get_block{|a,n| assert(a,n)}).call(true, "marity")
+ get_block{|a,n| assert(a,n)}.call(true, "marity")
end
def foo
diff --git a/test/ruby/test_lambda.rb b/test/ruby/test_lambda.rb
index 03b501a6c9..75362e2796 100644
--- a/test/ruby/test_lambda.rb
+++ b/test/ruby/test_lambda.rb
@@ -74,6 +74,12 @@ class TestLambdaParameters < Test::Unit::TestCase
assert_raise(ArgumentError, bug9605) {proc(&plus).call [1,2]}
end
+ def test_warning_for_non_literal_blocks
+ assert_warn(/lambda without a literal block/, '[ruby-core:93482] [Feature #15973]') do
+ lambda(&:symbol)
+ end
+ end
+
def pass_along(&block)
lambda(&block)
end