From: Steve Hancock Date: Thu, 29 Oct 2020 13:46:17 +0000 (-0700) Subject: added more signature and prototype test cases X-Git-Tag: 20201001.03~28 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=a527ce8d0c6cd48fd3bdb0e994aff94ff073836a;p=perltidy.git added more signature and prototype test cases --- diff --git a/t/snippets/expect/signature.def b/t/snippets/expect/signature.def index 5f11ab9d..b33d07e2 100644 --- a/t/snippets/expect/signature.def +++ b/t/snippets/expect/signature.def @@ -17,3 +17,21 @@ sub t022 ( $p = do { $z += 10; 222 }, $a = do { $z++; 333 } ) { "$p/$a" } my $subref = sub ( $cat, $id = do { state $auto_id = 0; $auto_id++ } ) { ...; }; + +# signature and prototype and attribute +sub foo1 ( $x, $y ) : prototype ( $$ ) : shared { } + +sub foo11 ( $thing, % ) { print $thing } + +sub animal4 ( $cat, $ = ) { } # second argument is optional + +*share = sub ( \[$@%] ) { }; + +# extruded test +sub foo2 ( $first, $, $third ) { + return "first=$first, third=$third"; +} + +# valid attributes +sub fnord (&\%) : switch(10,foo(7,3)) : expensive; +sub plugh () : Ugly('\(") : Bad; diff --git a/t/snippets/packing_list.txt b/t/snippets/packing_list.txt index 02a34131..f6643b75 100644 --- a/t/snippets/packing_list.txt +++ b/t/snippets/packing_list.txt @@ -282,6 +282,8 @@ ../snippets22.t xci.xci2 ../snippets22.t mangle4.def ../snippets22.t mangle4.mangle +../snippets22.t extrude5.def +../snippets22.t extrude5.extrude ../snippets3.t ce_wn1.ce_wn ../snippets3.t ce_wn1.def ../snippets3.t colin.colin @@ -422,5 +424,3 @@ ../snippets9.t rt98902.def ../snippets9.t rt98902.rt98902 ../snippets9.t rt99961.def -../snippets22.t extrude5.def -../snippets22.t extrude5.extrude diff --git a/t/snippets/signature.in b/t/snippets/signature.in index def25b50..2c261598 100644 --- a/t/snippets/signature.in +++ b/t/snippets/signature.in @@ -19,3 +19,34 @@ sub t022 ( my $subref = sub ( $cat, $id = do { state $auto_id = 0; $auto_id++ } ) { ...; }; + +# signature and prototype and attribute +sub foo1 ( $x, $y ) : prototype ( $$ ) : shared { } + +sub foo11 ( $thing, % ) { print $thing } + +sub animal4 ( $cat, $ = ) { } # second argument is optional + +*share = sub +( \[$@%] ) { }; + +# extruded test +sub foo2 + ( + $ + first + , + $ + , + $ + third + ) + { + return + "first=$first, third=$third" + ; + } + +# valid attributes +sub fnord (&\%) : switch(10,foo(7,3)) : expensive; +sub plugh () : Ugly('\(") : Bad; diff --git a/t/snippets17.t b/t/snippets17.t index f2fa32ce..49c0874b 100644 --- a/t/snippets17.t +++ b/t/snippets17.t @@ -247,6 +247,37 @@ sub t022 ( my $subref = sub ( $cat, $id = do { state $auto_id = 0; $auto_id++ } ) { ...; }; + +# signature and prototype and attribute +sub foo1 ( $x, $y ) : prototype ( $$ ) : shared { } + +sub foo11 ( $thing, % ) { print $thing } + +sub animal4 ( $cat, $ = ) { } # second argument is optional + +*share = sub +( \[$@%] ) { }; + +# extruded test +sub foo2 + ( + $ + first + , + $ + , + $ + third + ) + { + return + "first=$first, third=$third" + ; + } + +# valid attributes +sub fnord (&\%) : switch(10,foo(7,3)) : expensive; +sub plugh () : Ugly('\(") : Bad; ---------- 'ternary4' => <<'----------', @@ -957,6 +988,24 @@ sub t022 ( $p = do { $z += 10; 222 }, $a = do { $z++; 333 } ) { "$p/$a" } my $subref = sub ( $cat, $id = do { state $auto_id = 0; $auto_id++ } ) { ...; }; + +# signature and prototype and attribute +sub foo1 ( $x, $y ) : prototype ( $$ ) : shared { } + +sub foo11 ( $thing, % ) { print $thing } + +sub animal4 ( $cat, $ = ) { } # second argument is optional + +*share = sub ( \[$@%] ) { }; + +# extruded test +sub foo2 ( $first, $, $third ) { + return "first=$first, third=$third"; +} + +# valid attributes +sub fnord (&\%) : switch(10,foo(7,3)) : expensive; +sub plugh () : Ugly('\(") : Bad; #17........... },