diff options
| author | Takashi Kokubun <takashi.kokubun@shopify.com> | 2025-09-25 16:57:23 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-25 16:57:23 -0700 |
| commit | 61a0de1b652f8e1c79ef762ecf41bdea3f799d25 (patch) | |
| tree | e815352f52e72016067216a30a54f303d1de89b4 /test/ruby/test_zjit.rb | |
| parent | a1a1c9080ff5a948762da54962412c407304f41c (diff) | |
ZJIT: Compile ISEQ with optional arguments (#14653)
Diffstat (limited to 'test/ruby/test_zjit.rb')
| -rw-r--r-- | test/ruby/test_zjit.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/ruby/test_zjit.rb b/test/ruby/test_zjit.rb index 564e62c070..683d53f339 100644 --- a/test/ruby/test_zjit.rb +++ b/test/ruby/test_zjit.rb @@ -308,6 +308,39 @@ class TestZJIT < Test::Unit::TestCase } end + def test_optional_arguments + assert_compiles '[[1, 2, 3], [10, 20, 3], [100, 200, 300]]', %q{ + def test(a, b = 2, c = 3) + [a, b, c] + end + [test(1), test(10, 20), test(100, 200, 300)] + } + end + + def test_optional_arguments_setlocal + assert_compiles '[[2, 2], [1, nil]]', %q{ + def test(a = (b = 2)) + [a, b] + end + [test, test(1)] + } + end + + def test_optional_arguments_cyclic + assert_compiles '[nil, 1]', %q{ + test = proc { |a=a| a } + [test.call, test.call(1)] + } + end + + def test_optional_arguments_side_exit + # This leads to FailedOptionalArguments, so not using assert_compiles + assert_runs '[:foo, nil, 1]', %q{ + def test(a = (def foo = nil)) = a + [test, (undef :foo), test(1)] + } + end + def test_getblockparamproxy assert_compiles '1', %q{ def test(&block) |
