diff options
author | John Hawthorn <john@hawthorn.email> | 2022-01-05 16:00:21 -0800 |
---|---|---|
committer | John Hawthorn <john@hawthorn.email> | 2022-01-10 10:53:31 -0800 |
commit | 930ebdd7ca4dfb9386fcaa52909dadb970163f8e (patch) | |
tree | 01d4008b7d4d68bf35d63d2e4d7305add5b46362 /bootstraptest | |
parent | a9dc0c59e314de66f56d0a1a551a74c96fd11c8d (diff) | |
download | ruby-930ebdd7ca4dfb9386fcaa52909dadb970163f8e.tar.gz |
YJIT: Support kwargs for cfunc
This adds support for passing keyword arguments to cfuncs. This is done
by calling a helper method to create the hash from the top N values on
the stack (determined by the callinfo) and then moving that value onto
the stack.
Diffstat (limited to 'bootstraptest')
-rw-r--r-- | bootstraptest/test_yjit.rb | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb index a52ed8027d..d124d180d1 100644 --- a/bootstraptest/test_yjit.rb +++ b/bootstraptest/test_yjit.rb @@ -2462,6 +2462,57 @@ assert_equal '[[1, 2, 3, 4]]', %q{ 5.times.map { foo(specified: 2, required: 1) }.uniq } +# cfunc kwargs +assert_equal '{:foo=>123}', %q{ + def foo(bar) + bar.store(:value, foo: 123) + bar[:value] + end + + foo({}) + foo({}) +} + +# cfunc kwargs +assert_equal '{:foo=>123}', %q{ + def foo(bar) + bar.replace(foo: 123) + end + + foo({}) + foo({}) +} + +# cfunc kwargs +assert_equal '{:foo=>123, :bar=>456}', %q{ + def foo(bar) + bar.replace(foo: 123, bar: 456) + end + + foo({}) + foo({}) +} + +# variadic cfunc kwargs +assert_equal '{:foo=>123}', %q{ + def foo(bar) + bar.merge(foo: 123) + end + + foo({}) + foo({}) +} + +# optimized cfunc kwargs +assert_equal 'false', %q{ + def foo + :foo.eql?(foo: :foo) + end + + foo + foo +} + # attr_reader on frozen object assert_equal 'false', %q{ class Foo |