summaryrefslogtreecommitdiff
path: root/test/ruby/test_zjit.rb
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2025-06-27 01:26:17 +0900
committerAlan Wu <XrXr@users.noreply.github.com>2025-06-28 00:03:42 +0900
commit0828dff3f8bb345e8d79d5cdbbe0a207f8e2a7b7 (patch)
tree2a51ef29a064ba85156e229e6ca2cb0e42853869 /test/ruby/test_zjit.rb
parent32def149807852804272b027f4c711a669f2fbf1 (diff)
ZJIT: Codegen for `defined?(yield)`
Lots of stdlib methods such as Integer#times and Kernel#then use this, so at least this will make writing tests slightly easier.
Diffstat (limited to 'test/ruby/test_zjit.rb')
-rw-r--r--test/ruby/test_zjit.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/ruby/test_zjit.rb b/test/ruby/test_zjit.rb
index 5cb6d1f03e..d9130c3116 100644
--- a/test/ruby/test_zjit.rb
+++ b/test/ruby/test_zjit.rb
@@ -781,6 +781,29 @@ class TestZJIT < Test::Unit::TestCase
}, call_threshold: 2
end
+ def test_defined_yield
+ assert_compiles "nil", "defined?(yield)"
+ assert_compiles '[nil, nil, "yield"]', %q{
+ def test = defined?(yield)
+ [test, test, test{}]
+ }, call_threshold: 2, insns: [:defined]
+ end
+
+ def test_defined_yield_from_block
+ # This will do some EP hopping to find the local EP,
+ # so it's slightly different than doing it outside of a block.
+
+ omit 'Test fails at the moment due to missing Send codegen'
+
+ assert_compiles '[nil, nil, "yield"]', %q{
+ def test
+ yield_self { yield_self { defined?(yield) } }
+ end
+
+ [test, test, test{}]
+ }, call_threshold: 2, insns: [:defined]
+ end
+
def test_putspecialobject_vm_core_and_cbase
assert_compiles '10', %q{
def test