diff options
| author | Stan Lo <stan.lo@shopify.com> | 2025-08-07 23:41:05 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-07 15:41:05 -0700 |
| commit | 2edc944702ef8aa04e10f7832ba36f410fbfa513 (patch) | |
| tree | 3b467202a3c5480847d78498c0ed568897f9bbd1 /test/ruby/test_zjit.rb | |
| parent | c41c323f1a001ab62c69add4bf01c6a887641f2a (diff) | |
ZJIT: Implement `defined?` codegen for non-yield calls (#14101)
Diffstat (limited to 'test/ruby/test_zjit.rb')
| -rw-r--r-- | test/ruby/test_zjit.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_zjit.rb b/test/ruby/test_zjit.rb index 5c4875e3dd..9eca30c787 100644 --- a/test/ruby/test_zjit.rb +++ b/test/ruby/test_zjit.rb @@ -1043,6 +1043,26 @@ class TestZJIT < Test::Unit::TestCase } end + def test_defined_with_defined_values + assert_compiles '["constant", "method", "global-variable"]', %q{ + class Foo; end + def bar; end + $ruby = 1 + + def test = return defined?(Foo), defined?(bar), defined?($ruby) + + test + }, insns: [:defined] + end + + def test_defined_with_undefined_values + assert_compiles '[nil, nil, nil]', %q{ + def test = return defined?(Foo), defined?(bar), defined?($ruby) + + test + }, insns: [:defined] + end + def test_defined_yield assert_compiles "nil", "defined?(yield)" assert_compiles '[nil, nil, "yield"]', %q{ |
