@@ -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]
@@ -583,6 +593,28 @@ def entry = test(a: 3)
583593 } , call_threshold : 2
584594 end
585595
596+ def test_send_kwarg_to_ccall
597+ assert_compiles '["a", "b", "c"]' , %q{
598+ def test(s) = s.each_line(chomp: true).to_a
599+ def entry = test(%(a\nb\nc))
600+ entry
601+ entry
602+ } , call_threshold : 2
603+ end
604+
605+ def test_send_kwarg_and_block_to_ccall
606+ assert_compiles '["a", "b", "c"]' , %q{
607+ def test(s)
608+ a = []
609+ s.each_line(chomp: true) { |l| a << l }
610+ a
611+ end
612+ def entry = test(%(a\nb\nc))
613+ entry
614+ entry
615+ } , call_threshold : 2
616+ end
617+
586618 def test_send_kwrest
587619 assert_compiles '{a: 3}' , %q{
588620 def test(**kwargs) = kwargs
@@ -592,6 +624,47 @@ def entry = test(a: 3)
592624 } , call_threshold : 2
593625 end
594626
627+ def test_send_req_kwreq
628+ assert_compiles '[1, 3]' , %q{
629+ def test(a, c:) = [a, c]
630+ def entry = test(1, c: 3)
631+ entry
632+ entry
633+ } , call_threshold : 2
634+ end
635+
636+ def test_send_req_opt_kwreq_kwopt
637+ assert_compiles '[[1, 2, 3, 4], [-1, -2, -3, -4]]' , %q{
638+ def test(a, b = 2, c:, d: 4) = [a, b, c, d]
639+ def entry = [test(1, c: 3), test(-1, -2, d: -4, c: -3)] # specify all, change kw order
640+ entry
641+ entry
642+ } , call_threshold : 2
643+ end
644+
645+ def test_send_unexpected_keyword
646+ assert_compiles ':error' , %q{
647+ def test(a: 1) = a*2
648+ def entry
649+ test(z: 2)
650+ rescue ArgumentError
651+ :error
652+ end
653+
654+ entry
655+ entry
656+ } , call_threshold : 2
657+ end
658+
659+ def test_send_all_arg_types
660+ assert_compiles '[:req, :opt, :post, :kwr, :kwo, true]' , %q{
661+ def test(a, b = :opt, c, d:, e: :kwo) = [a, b, c, d, e, block_given?]
662+ def entry = test(:req, :post, d: :kwr) {}
663+ entry
664+ entry
665+ } , call_threshold : 2
666+ end
667+
595668 def test_send_ccall_variadic_with_different_receiver_classes
596669 assert_compiles '[true, true]' , %q{
597670 def test(obj) = obj.start_with?("a")
0 commit comments