diff options
author | Jimmy Miller <jimmy.miller@shopify.com> | 2023-04-13 19:21:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-13 16:21:02 -0700 |
commit | 08413f982cc35cbc7692616dd11ae9bf33de42df (patch) | |
tree | 7e56e65e81375e0037636486ed6cbe7243188278 /bootstraptest | |
parent | f7d41b9d7bd9de48293909c904e95ebc353fc200 (diff) |
YJIT: Add support for rest with option and splat args (#7698)
Notes
Notes:
Merged-By: k0kubun <takashikkbn@gmail.com>
Diffstat (limited to 'bootstraptest')
-rw-r--r-- | bootstraptest/test_yjit.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb index ed8bd94e7c..99de63eafa 100644 --- a/bootstraptest/test_yjit.rb +++ b/bootstraptest/test_yjit.rb @@ -3873,3 +3873,43 @@ assert_equal '2', %q{ entry # call branch_stub_hit (spill temps) entry # doesn't call branch_stub_hit (not spill temps) } + +# Test rest and optional_params +assert_equal '[true, true, true, true]', %q{ + def my_func(stuff, base=nil, sort=true, *args) + [stuff, base, sort, args] + end + + def calling_my_func + results = [] + results << (my_func("test") == ["test", nil, true, []]) + results << (my_func("test", :base) == ["test", :base, true, []]) + results << (my_func("test", :base, false) == ["test", :base, false, []]) + results << (my_func("test", :base, false, "other", "other") == ["test", :base, false, ["other", "other"]]) + results + end + calling_my_func +} + +# Test rest and optional_params and splat +assert_equal '[true, true, true, true, true]', %q{ + def my_func(stuff, base=nil, sort=true, *args) + [stuff, base, sort, args] + end + + def calling_my_func + results = [] + splat = ["test"] + results << (my_func(*splat) == ["test", nil, true, []]) + splat = [:base] + results << (my_func("test", *splat) == ["test", :base, true, []]) + splat = [:base, false] + results << (my_func("test", *splat) == ["test", :base, false, []]) + splat = [:base, false, "other", "other"] + results << (my_func("test", *splat) == ["test", :base, false, ["other", "other"]]) + splat = ["test", :base, false, "other", "other"] + results << (my_func(*splat) == ["test", :base, false, ["other", "other"]]) + results + end + calling_my_func +} |