Skip to content

Commit 821b650

Browse files
committed
ZJIT: Test additional arg passing scenarios
1 parent f920013 commit 821b650

1 file changed

Lines changed: 43 additions & 1 deletion

File tree

test/ruby/test_zjit.rb

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,8 @@ def test_send_kwarg
553553
def test(a:, b:) = [a, b]
554554
def entry = test(b: 2, a: 1) # change order
555555
entry
556-
}
556+
entry
557+
}, call_threshold: 2
557558
end
558559

559560
def test_send_kwarg_optional
@@ -565,6 +566,15 @@ def entry = test
565566
}, call_threshold: 2
566567
end
567568

569+
def test_send_kwarg_optional_too_many
570+
assert_compiles '[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]', %q{
571+
def test(a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9, j: 10) = [a, b, c, d, e, f, g, h, i, j]
572+
def entry = test
573+
entry
574+
entry
575+
}, call_threshold: 2
576+
end
577+
568578
def test_send_kwarg_required_and_optional
569579
assert_compiles '[3, 2]', %q{
570580
def test(a:, b: 2) = [a, b]
@@ -592,6 +602,38 @@ def entry = test(a: 3)
592602
}, call_threshold: 2
593603
end
594604

605+
def test_send_req_opt_kwreq_kwopt
606+
assert_compiles '[[1, 2, 3, 4], [-1, -2, -3, -4]]', %q{
607+
def test(a, b = 2, c:, d: 4) = [a, b, c, d]
608+
def entry = [test(1, c: 3), test(-1, -2, d: -4, c: -3)] # specify all, change kw order
609+
entry
610+
entry
611+
}, call_threshold: 2
612+
end
613+
614+
def test_send_unexpected_keyword
615+
assert_compiles ':error', %q{
616+
def test(a: 1) = a*2
617+
def entry
618+
test(z: 2)
619+
rescue ArgumentError
620+
:error
621+
end
622+
623+
entry
624+
entry
625+
}, call_threshold: 2
626+
end
627+
628+
def test_send_all_arg_types
629+
assert_compiles '[:req, :opt, :post, :kwr, :kwo, true]', %q{
630+
def test(a, b = :opt, c, d:, e: :kwo) = [a, b, c, d, e, block_given?]
631+
def entry = test(:req, :post, d: :kwr) {}
632+
entry
633+
entry
634+
}, call_threshold: 2
635+
end
636+
595637
def test_send_ccall_variadic_with_different_receiver_classes
596638
assert_compiles '[true, true]', %q{
597639
def test(obj) = obj.start_with?("a")

0 commit comments

Comments
 (0)