summaryrefslogtreecommitdiff
path: root/bootstraptest
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2022-10-27 05:57:59 +1030
committerGitHub <noreply@github.com>2022-10-26 15:27:59 -0400
commitc746f380f278683e98262883ed69319bd9fa680e (patch)
treea082096e7303a5fd439773f7ff3f8b27ed45de2a /bootstraptest
parentfa0adbad92fc1216ba0d1757fe40f0453e3a6574 (diff)
YJIT: Support nil and blockparamproxy as blockarg in send (#6492)
Co-authored-by: John Hawthorn <john@hawthorn.email> Co-authored-by: John Hawthorn <john@hawthorn.email>
Notes
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
Diffstat (limited to 'bootstraptest')
-rw-r--r--bootstraptest/test_yjit.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb
index 2dc460c628..7361d2a725 100644
--- a/bootstraptest/test_yjit.rb
+++ b/bootstraptest/test_yjit.rb
@@ -3337,3 +3337,46 @@ assert_equal '[[1, nil, 2]]', %q{
5.times.map { opt_and_kwargs(1, c: 2) }.uniq
}
+
+# bmethod with forwarded block
+assert_equal '2', %q{
+ define_method(:foo) do |&block|
+ block.call
+ end
+
+ def bar(&block)
+ foo(&block)
+ end
+
+ bar { 1 }
+ bar { 2 }
+}
+
+# bmethod with forwarded block and arguments
+assert_equal '5', %q{
+ define_method(:foo) do |n, &block|
+ n + block.call
+ end
+
+ def bar(n, &block)
+ foo(n, &block)
+ end
+
+ bar(0) { 1 }
+ bar(3) { 2 }
+}
+
+# bmethod with forwarded unwanted block
+assert_equal '1', %q{
+ one = 1
+ define_method(:foo) do
+ one
+ end
+
+ def bar(&block)
+ foo(&block)
+ end
+
+ bar { }
+ bar { }
+}