@@ -545,6 +545,51 @@ function_form(short::Bool) = string(short ? "short" : "long", "-form")
545545 @test strip_lineno! (c_expr) == strip_lineno! (expr)
546546 end
547547
548+ @testset " (x; y = 0)" begin
549+ f, expr = if short
550+ @audit (x; y = 0 ) -> (x, y)
551+ else
552+ @audit function (x; y = 0 ); (x, y) end
553+ end
554+ @test length (methods (f)) == 1
555+ @test f (0 ) == (0 , 0 )
556+ @test f (0 , y= 1 ) == (0 , 1 )
557+
558+ # Note: the semi-colon is missing from the expression
559+ d = splitdef (expr)
560+ @test keys (d) == Set ([:head , :args , :kwargs , :body ])
561+ @test d[:args ] == [:x ]
562+ @test d[:kwargs ] == [Expr (:kw , :y , 0 )]
563+
564+ c_expr = combinedef (d)
565+ expr = Expr (:-> , Expr (:tuple , Expr (:parameters , Expr (:kw , :y , 0 )), :x ), Expr (:block , :((x, y))))
566+ expr. head = short ? :-> : :function
567+ @test strip_lineno! (c_expr) == strip_lineno! (expr)
568+ end
569+
570+ @testset " (x; y = 0, _...)" begin
571+ f, expr = if short
572+ @audit (x; y = 0 , _... ) -> (x, y)
573+ else
574+ @audit function (x; y = 0 , _... ); (x, y) end
575+ end
576+ @test length (methods (f)) == 1
577+ @test f (0 ) == (0 , 0 )
578+ @test f (0 , y= 1 ) == (0 , 1 )
579+ @test f (0 , y= 1 , z= 2 ) == (0 , 1 )
580+
581+ # Note: the semi-colon is missing from the expression
582+ d = splitdef (expr)
583+ @test keys (d) == Set ([:head , :args , :kwargs , :body ])
584+ @test d[:args ] == [:x ]
585+ @test d[:kwargs ] == [Expr (:kw , :y , 0 ), :(_... )]
586+
587+ c_expr = combinedef (d)
588+ expr = Expr (:-> , Expr (:tuple , Expr (:parameters , Expr (:kw , :y , 0 ), :(_... )), :x ), Expr (:block , :((x, y))))
589+ expr. head = short ? :-> : :function
590+ @test strip_lineno! (c_expr) == strip_lineno! (expr)
591+ end
592+
548593 @testset " Expr(:block, :x, :y)" begin
549594 expr = Expr (:-> , Expr (:block , :x , :y ), Expr (:block , :((x, y))))
550595 expr. head = short ? :-> : :function
0 commit comments