Skip to content

Commit 1b8b8b5

Browse files
committed
ZJIT: Add tests for sending to methods with keyword args
1 parent 0e60462 commit 1b8b8b5

1 file changed

Lines changed: 37 additions & 1 deletion

File tree

test/ruby/test_zjit.rb

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,11 +498,47 @@ def entry(arr) = test(*arr)
498498
def test_send_kwarg
499499
assert_runs '[1, 2]', %q{
500500
def test(a:, b:) = [a, b]
501-
def entry = test(a: 1, b: 2)
501+
def entry = test(b: 2, a: 1) # change order
502502
entry
503503
}
504504
end
505505

506+
def test_send_kwarg_optional
507+
assert_compiles '[1, 2]', %q{
508+
def test(a: 1, b: 2) = [a, b]
509+
def entry = test
510+
entry
511+
entry
512+
}, call_threshold: 2
513+
end
514+
515+
def test_send_kwarg_required_and_optional
516+
assert_compiles '[3, 2]', %q{
517+
def test(a:, b: 2) = [a, b]
518+
def entry = test(a: 3)
519+
entry
520+
entry
521+
}, call_threshold: 2
522+
end
523+
524+
def test_send_kwarg_to_hash
525+
assert_compiles '{a: 3}', %q{
526+
def test(hash) = hash
527+
def entry = test(a: 3)
528+
entry
529+
entry
530+
}, call_threshold: 2
531+
end
532+
533+
def test_send_kwrest
534+
assert_compiles '{a: 3}', %q{
535+
def test(**kwargs) = kwargs
536+
def entry = test(a: 3)
537+
entry
538+
entry
539+
}, call_threshold: 2
540+
end
541+
506542
def test_send_ccall_variadic_with_different_receiver_classes
507543
assert_compiles '[true, true]', %q{
508544
def test(obj) = obj.start_with?("a")

0 commit comments

Comments
 (0)