]> git.donarmstrong.com Git - perltidy.git/blob - t/snippets24.t
New upstream version 20220217
[perltidy.git] / t / snippets24.t
1 # Created with: ./make_t.pl
2
3 # Contents:
4 #1 git54.def
5 #2 git54.git54
6 #3 fpva.def
7 #4 fpva.fpva1
8 #5 fpva.fpva2
9 #6 lpxl.def
10 #7 lpxl.lpxl1
11 #8 lpxl.lpxl3
12 #9 lpxl.lpxl4
13 #10 lpxl.lpxl5
14 #11 git63.def
15 #12 align35.def
16 #13 rt136417.def
17 #14 rt136417.rt136417
18 #15 numbers.def
19 #16 code_skipping.def
20 #17 git51.def
21 #18 git51.git51
22 #19 pretok.def
23
24 # To locate test #13 you can search for its name or the string '#13'
25
26 use strict;
27 use Test::More;
28 use Carp;
29 use Perl::Tidy;
30 my $rparams;
31 my $rsources;
32 my $rtests;
33
34 BEGIN {
35
36     ###########################################
37     # BEGIN SECTION 1: Parameter combinations #
38     ###########################################
39     $rparams = {
40         'def'   => "",
41         'fpva1' => "-sfp",
42         'fpva2' => <<'----------',
43 -sfp -wls='->' -wrs='->' -nfpva
44 ----------
45         'git51' => <<'----------',
46 --maximum-line-length=120
47 --converge
48 --tabs
49 --entab-leading-whitespace=4
50 --continuation-indentation=4
51 --extended-continuation-indentation
52 --no-delete-old-newlines
53 --no-outdent-long-lines
54 --no-outdent-labels
55 --novalign
56 --no-logical-padding
57 --opening-sub-brace-on-new-line
58 --square-bracket-tightness=2
59 --paren-tightness=2
60 --brace-tightness=2
61 --opening-token-right
62
63 -sal='first any sum sum0 reduce'
64 ----------
65         'git54' => "-bbp=3 -bbpi=2 -ci=4 -lp",
66         'lpxl1' => "-lp",
67         'lpxl3' => <<'----------',
68 -lp -lpxl='{ [ ('
69 ----------
70         'lpxl4' => <<'----------',
71 -lp -lpxl='{ [ W(1'
72 ----------
73         'lpxl5' => <<'----------',
74 -lp -lpxl='{ [ F(2'
75 ----------
76         'rt136417' => "-vtc=3",
77     };
78
79     ############################
80     # BEGIN SECTION 2: Sources #
81     ############################
82     $rsources = {
83
84         'align35' => <<'----------',
85 # different module names, do not align commas (fixes rt136416)
86 use File::Spec::Functions 'catfile', 'catdir';
87 use Mojo::Base 'Mojolicious', '-signatures';
88
89 # same module names, align fat commas
90 use constant PI => 4 * atan2 1, 1;
91 use constant TWOPI => 2 * PI;
92 use constant FOURPI => 4 * PI;
93
94 # same module names, align commas
95 use TestCounter '3rd-party', 0, '3rd-party no longer visible';
96 use TestCounter 'replace', 1, 'replacement now visible';
97 use TestCounter 'root';
98
99 # same module name, align fat commas but not commas
100 use constant COUNTDOWN => scalar reverse 1, 2, 3, 4, 5;
101 use constant COUNTUP => reverse 1, 2, 3, 4, 5;
102 use constant COUNTDOWN => scalar reverse 1, 2, 3, 4, 5;
103 ----------
104
105         'code_skipping' => <<'----------',
106 %Hdr=%U2E=%E2U=%Fallback=();
107 $in_charmap=$nerror=$nwarning=0;
108 $.=0;
109 #<<V  code skipping: perltidy will pass this verbatim without error checking
110
111     }}} {{{
112
113 #>>V
114 my $self=shift;
115 my $cloning=shift;
116 ----------
117
118         'fpva' => <<'----------',
119 log_something_with_long_function( 'This is a log message.', 2 );
120 Coro::AnyEvent::sleep( 3, 4 );
121 use Carp ();
122 use File::Spec ();
123 use File::Path ();
124 $self -> method ( 'parameter_0', 'parameter_1' );
125 $self -> method_with_long_name ( 'parameter_0', 'parameter_1' );
126 ----------
127
128         'git51' => <<'----------',
129 Type::Libraries->setup_class(
130         __PACKAGE__,
131         qw(
132                 Types::Standard
133                 Types::Common::Numeric
134                 ), # <--- brace here
135 );
136 ----------
137
138         'git54' => <<'----------',
139 # testing sensitivity to excess commas
140 my $definition =>
141     (
142     {
143         key1 => value1
144     },
145     {
146         key2 => value2
147     },
148     );
149
150 my $definition =>
151     (
152     {
153         key => value
154     }
155     );
156
157 my $definition =>
158     (
159     {
160         key => value
161     },
162     );
163
164 my $definition =>
165     (
166     {
167         key => value,
168     },
169     );
170
171 my $list =
172     (
173       {
174         key => $value,
175         key => $value,
176         key => $value,
177         key => $value,
178         key => $value,
179       },
180     ) ;
181
182 my $list =
183     (
184       {
185         key => $value,
186         key => $value,
187         key => $value,
188         key => $value,
189         key => $value,
190       }
191     ) ;
192 ----------
193
194         'git63' => <<'----------',
195 my $fragment = $parser-> #parse_html_string
196   parse_balanced_chunk($I);
197 ----------
198
199         'lpxl' => <<'----------',
200 # simple function call
201 my $loanlength = getLoanLength(
202                                 $borrower->{'categorycode'},    # sc1
203                                 $iteminformation->{'itemtype'},
204                                 $borrower->{'branchcode'}       # sc3
205 );
206
207 # function call, more than one level deep
208 my $o = very::long::class::name->new(
209     {
210         propA => "a",
211         propB => "b",
212         propC => "c",
213     }
214 );
215
216 # function call with sublist
217 debug(
218       "Connecting to DB.",
219       "Extra-Parameters: " . join("<->", $extra_parms),
220       "Config: " . join("<->", %config)
221      );
222
223 # simple function call with code block
224 $m->command(-label   => 'Save',
225             -command => sub { print "DOS\n"; save_dialog($win); });
226
227 # function call, ternary in list
228 return
229   OptArgs2::Result->usage(
230     $style == OptArgs2::STYLE_FULL ? 'FullUsage' : 'NormalUsage',
231     'usage: ' . $usage . "\n" );
232
233 # not a function call
234 %blastparam = (
235     -run            => \%runparam,
236     -file           => '',
237     -parse          => 1,
238     -signif         => 1e-5,
239 );
240
241 # 'local' is a keyword, not a user function
242     local (
243         $len,    $pts,      @colspec, $char, $cols,
244         $repeat, $celldata, $at_text, $after_text
245     );
246
247 # square bracket with sublists
248 $data = [
249          ListElem->new(id => 0, val => 100),
250          ListElem->new(id => 2, val => 50),
251          ListElem->new(id => 1, val => 10),
252         ];
253
254 # curly brace with sublists
255 $behaviour = {
256               cat   => {nap    => "lap",   eat  => "meat"},
257               dog   => {prowl  => "growl", pool => "drool"},
258               mouse => {nibble => "kibble"},
259              };
260 ----------
261
262         'numbers' => <<'----------',
263 # valid numbers
264 my @vals = (
265
266     12345,
267     12345.67,
268     .23E-10,
269     3.14_15_92,
270     4_294_967_296,
271     0xff,
272     0xdead_beef,
273     0377,
274     0b011011,
275     0x1.999ap-4,
276     1e34,
277     1e+34,
278     1e+034,
279     -1e+034,
280     0.00000000000000000000000000000000000000000000000000000000000000000001,
281     0Xabcdef,
282     0B1101,
283     0o12_345,  # optional 'o' and 'O' added in perl v5.33.5
284     0O12_345,
285 );
286 ----------
287
288         'pretok' => <<'----------',
289 # test sub split_pretoken
290 my$s1=$^??"def":"not def";
291 my$s2=$^ ?"def":"not def";
292 my$s3=$^if($s2);
293 my$s4=$^Oeq"linux";
294 my$s5=$  ^One"linux";
295 my$s6=$
296   ^One"linux";
297 my$s7=%^O;
298 my$s8='hi'.'s'x10if(1);
299 my$s9='merci'x0.1e4.$s8;
300 ----------
301
302         'rt136417' => <<'----------',
303 function(
304   #
305   a, b, c);
306
307 %hash = (
308   a => b,
309   c => d,
310 );
311 ----------
312     };
313
314     ####################################
315     # BEGIN SECTION 3: Expected output #
316     ####################################
317     $rtests = {
318
319         'git54.def' => {
320             source => "git54",
321             params => "def",
322             expect => <<'#1...........',
323 # testing sensitivity to excess commas
324 my $definition => (
325     {
326         key1 => value1
327     },
328     {
329         key2 => value2
330     },
331 );
332
333 my $definition => (
334     {
335         key => value
336     }
337 );
338
339 my $definition => (
340     {
341         key => value
342     },
343 );
344
345 my $definition => (
346     {
347         key => value,
348     },
349 );
350
351 my $list = (
352     {
353         key => $value,
354         key => $value,
355         key => $value,
356         key => $value,
357         key => $value,
358     },
359 );
360
361 my $list = (
362     {
363         key => $value,
364         key => $value,
365         key => $value,
366         key => $value,
367         key => $value,
368     }
369 );
370 #1...........
371         },
372
373         'git54.git54' => {
374             source => "git54",
375             params => "git54",
376             expect => <<'#2...........',
377 # testing sensitivity to excess commas
378 my $definition =>
379     (
380       {
381          key1 => value1
382       },
383       {
384          key2 => value2
385       },
386     );
387
388 my $definition =>
389     (
390       {
391         key => value
392       }
393     );
394
395 my $definition =>
396     (
397       {
398          key => value
399       },
400     );
401
402 my $definition =>
403     (
404       {
405          key => value,
406       },
407     );
408
409 my $list =
410     (
411       {
412          key => $value,
413          key => $value,
414          key => $value,
415          key => $value,
416          key => $value,
417       },
418     );
419
420 my $list =
421     (
422       {
423         key => $value,
424         key => $value,
425         key => $value,
426         key => $value,
427         key => $value,
428       }
429     );
430 #2...........
431         },
432
433         'fpva.def' => {
434             source => "fpva",
435             params => "def",
436             expect => <<'#3...........',
437 log_something_with_long_function( 'This is a log message.', 2 );
438 Coro::AnyEvent::sleep( 3, 4 );
439 use Carp       ();
440 use File::Spec ();
441 use File::Path ();
442 $self->method( 'parameter_0', 'parameter_1' );
443 $self->method_with_long_name( 'parameter_0', 'parameter_1' );
444 #3...........
445         },
446
447         'fpva.fpva1' => {
448             source => "fpva",
449             params => "fpva1",
450             expect => <<'#4...........',
451 log_something_with_long_function ( 'This is a log message.', 2 );
452 Coro::AnyEvent::sleep            ( 3, 4 );
453 use Carp       ();
454 use File::Spec ();
455 use File::Path ();
456 $self->method                ( 'parameter_0', 'parameter_1' );
457 $self->method_with_long_name ( 'parameter_0', 'parameter_1' );
458 #4...........
459         },
460
461         'fpva.fpva2' => {
462             source => "fpva",
463             params => "fpva2",
464             expect => <<'#5...........',
465 log_something_with_long_function ( 'This is a log message.', 2 );
466 Coro::AnyEvent::sleep ( 3, 4 );
467 use Carp ();
468 use File::Spec ();
469 use File::Path ();
470 $self -> method ( 'parameter_0', 'parameter_1' );
471 $self -> method_with_long_name ( 'parameter_0', 'parameter_1' );
472 #5...........
473         },
474
475         'lpxl.def' => {
476             source => "lpxl",
477             params => "def",
478             expect => <<'#6...........',
479 # simple function call
480 my $loanlength = getLoanLength(
481     $borrower->{'categorycode'},    # sc1
482     $iteminformation->{'itemtype'},
483     $borrower->{'branchcode'}       # sc3
484 );
485
486 # function call, more than one level deep
487 my $o = very::long::class::name->new(
488     {
489         propA => "a",
490         propB => "b",
491         propC => "c",
492     }
493 );
494
495 # function call with sublist
496 debug(
497     "Connecting to DB.",
498     "Extra-Parameters: " . join( "<->", $extra_parms ),
499     "Config: " . join( "<->", %config )
500 );
501
502 # simple function call with code block
503 $m->command(
504     -label   => 'Save',
505     -command => sub { print "DOS\n"; save_dialog($win); }
506 );
507
508 # function call, ternary in list
509 return OptArgs2::Result->usage(
510     $style == OptArgs2::STYLE_FULL ? 'FullUsage' : 'NormalUsage',
511     'usage: ' . $usage . "\n" );
512
513 # not a function call
514 %blastparam = (
515     -run    => \%runparam,
516     -file   => '',
517     -parse  => 1,
518     -signif => 1e-5,
519 );
520
521 # 'local' is a keyword, not a user function
522 local (
523     $len,    $pts,      @colspec, $char, $cols,
524     $repeat, $celldata, $at_text, $after_text
525 );
526
527 # square bracket with sublists
528 $data = [
529     ListElem->new( id => 0, val => 100 ),
530     ListElem->new( id => 2, val => 50 ),
531     ListElem->new( id => 1, val => 10 ),
532 ];
533
534 # curly brace with sublists
535 $behaviour = {
536     cat   => { nap    => "lap",   eat  => "meat" },
537     dog   => { prowl  => "growl", pool => "drool" },
538     mouse => { nibble => "kibble" },
539 };
540 #6...........
541         },
542
543         'lpxl.lpxl1' => {
544             source => "lpxl",
545             params => "lpxl1",
546             expect => <<'#7...........',
547 # simple function call
548 my $loanlength = getLoanLength(
549                                 $borrower->{'categorycode'},    # sc1
550                                 $iteminformation->{'itemtype'},
551                                 $borrower->{'branchcode'}       # sc3
552 );
553
554 # function call, more than one level deep
555 my $o = very::long::class::name->new(
556                                       {
557                                         propA => "a",
558                                         propB => "b",
559                                         propC => "c",
560                                       }
561 );
562
563 # function call with sublist
564 debug(
565        "Connecting to DB.",
566        "Extra-Parameters: " . join( "<->", $extra_parms ),
567        "Config: " . join( "<->", %config )
568 );
569
570 # simple function call with code block
571 $m->command( -label   => 'Save',
572              -command => sub { print "DOS\n"; save_dialog($win); } );
573
574 # function call, ternary in list
575 return
576   OptArgs2::Result->usage(
577                    $style == OptArgs2::STYLE_FULL ? 'FullUsage' : 'NormalUsage',
578                    'usage: ' . $usage . "\n" );
579
580 # not a function call
581 %blastparam = (
582                 -run    => \%runparam,
583                 -file   => '',
584                 -parse  => 1,
585                 -signif => 1e-5,
586 );
587
588 # 'local' is a keyword, not a user function
589 local (
590         $len,    $pts,      @colspec, $char, $cols,
591         $repeat, $celldata, $at_text, $after_text
592 );
593
594 # square bracket with sublists
595 $data = [
596           ListElem->new( id => 0, val => 100 ),
597           ListElem->new( id => 2, val => 50 ),
598           ListElem->new( id => 1, val => 10 ),
599 ];
600
601 # curly brace with sublists
602 $behaviour = {
603                cat   => { nap    => "lap",   eat  => "meat" },
604                dog   => { prowl  => "growl", pool => "drool" },
605                mouse => { nibble => "kibble" },
606 };
607 #7...........
608         },
609
610         'lpxl.lpxl3' => {
611             source => "lpxl",
612             params => "lpxl3",
613             expect => <<'#8...........',
614 # simple function call
615 my $loanlength = getLoanLength(
616     $borrower->{'categorycode'},    # sc1
617     $iteminformation->{'itemtype'},
618     $borrower->{'branchcode'}       # sc3
619 );
620
621 # function call, more than one level deep
622 my $o = very::long::class::name->new(
623     {
624         propA => "a",
625         propB => "b",
626         propC => "c",
627     }
628 );
629
630 # function call with sublist
631 debug(
632     "Connecting to DB.",
633     "Extra-Parameters: " . join( "<->", $extra_parms ),
634     "Config: " . join( "<->", %config )
635 );
636
637 # simple function call with code block
638 $m->command(
639     -label   => 'Save',
640     -command => sub { print "DOS\n"; save_dialog($win); }
641 );
642
643 # function call, ternary in list
644 return OptArgs2::Result->usage(
645     $style == OptArgs2::STYLE_FULL ? 'FullUsage' : 'NormalUsage',
646     'usage: ' . $usage . "\n" );
647
648 # not a function call
649 %blastparam = (
650     -run    => \%runparam,
651     -file   => '',
652     -parse  => 1,
653     -signif => 1e-5,
654 );
655
656 # 'local' is a keyword, not a user function
657 local (
658     $len,    $pts,      @colspec, $char, $cols,
659     $repeat, $celldata, $at_text, $after_text
660 );
661
662 # square bracket with sublists
663 $data = [
664     ListElem->new( id => 0, val => 100 ),
665     ListElem->new( id => 2, val => 50 ),
666     ListElem->new( id => 1, val => 10 ),
667 ];
668
669 # curly brace with sublists
670 $behaviour = {
671     cat   => { nap    => "lap",   eat  => "meat" },
672     dog   => { prowl  => "growl", pool => "drool" },
673     mouse => { nibble => "kibble" },
674 };
675 #8...........
676         },
677
678         'lpxl.lpxl4' => {
679             source => "lpxl",
680             params => "lpxl4",
681             expect => <<'#9...........',
682 # simple function call
683 my $loanlength = getLoanLength(
684                                 $borrower->{'categorycode'},    # sc1
685                                 $iteminformation->{'itemtype'},
686                                 $borrower->{'branchcode'}       # sc3
687 );
688
689 # function call, more than one level deep
690 my $o = very::long::class::name->new(
691     {
692         propA => "a",
693         propB => "b",
694         propC => "c",
695     }
696 );
697
698 # function call with sublist
699 debug(
700     "Connecting to DB.",
701     "Extra-Parameters: " . join( "<->", $extra_parms ),
702     "Config: " . join( "<->", %config )
703 );
704
705 # simple function call with code block
706 $m->command( -label   => 'Save',
707              -command => sub { print "DOS\n"; save_dialog($win); } );
708
709 # function call, ternary in list
710 return
711   OptArgs2::Result->usage(
712                    $style == OptArgs2::STYLE_FULL ? 'FullUsage' : 'NormalUsage',
713                    'usage: ' . $usage . "\n" );
714
715 # not a function call
716 %blastparam = (
717     -run    => \%runparam,
718     -file   => '',
719     -parse  => 1,
720     -signif => 1e-5,
721 );
722
723 # 'local' is a keyword, not a user function
724 local (
725         $len,    $pts,      @colspec, $char, $cols,
726         $repeat, $celldata, $at_text, $after_text
727 );
728
729 # square bracket with sublists
730 $data = [
731     ListElem->new( id => 0, val => 100 ),
732     ListElem->new( id => 2, val => 50 ),
733     ListElem->new( id => 1, val => 10 ),
734 ];
735
736 # curly brace with sublists
737 $behaviour = {
738     cat   => { nap    => "lap",   eat  => "meat" },
739     dog   => { prowl  => "growl", pool => "drool" },
740     mouse => { nibble => "kibble" },
741 };
742 #9...........
743         },
744
745         'lpxl.lpxl5' => {
746             source => "lpxl",
747             params => "lpxl5",
748             expect => <<'#10...........',
749 # simple function call
750 my $loanlength = getLoanLength(
751                                 $borrower->{'categorycode'},    # sc1
752                                 $iteminformation->{'itemtype'},
753                                 $borrower->{'branchcode'}       # sc3
754 );
755
756 # function call, more than one level deep
757 my $o = very::long::class::name->new(
758     {
759         propA => "a",
760         propB => "b",
761         propC => "c",
762     }
763 );
764
765 # function call with sublist
766 debug(
767     "Connecting to DB.",
768     "Extra-Parameters: " . join( "<->", $extra_parms ),
769     "Config: " . join( "<->", %config )
770 );
771
772 # simple function call with code block
773 $m->command(
774     -label   => 'Save',
775     -command => sub { print "DOS\n"; save_dialog($win); }
776 );
777
778 # function call, ternary in list
779 return OptArgs2::Result->usage(
780     $style == OptArgs2::STYLE_FULL ? 'FullUsage' : 'NormalUsage',
781     'usage: ' . $usage . "\n" );
782
783 # not a function call
784 %blastparam = (
785     -run    => \%runparam,
786     -file   => '',
787     -parse  => 1,
788     -signif => 1e-5,
789 );
790
791 # 'local' is a keyword, not a user function
792 local (
793     $len,    $pts,      @colspec, $char, $cols,
794     $repeat, $celldata, $at_text, $after_text
795 );
796
797 # square bracket with sublists
798 $data = [
799     ListElem->new( id => 0, val => 100 ),
800     ListElem->new( id => 2, val => 50 ),
801     ListElem->new( id => 1, val => 10 ),
802 ];
803
804 # curly brace with sublists
805 $behaviour = {
806     cat   => { nap    => "lap",   eat  => "meat" },
807     dog   => { prowl  => "growl", pool => "drool" },
808     mouse => { nibble => "kibble" },
809 };
810 #10...........
811         },
812
813         'git63.def' => {
814             source => "git63",
815             params => "def",
816             expect => <<'#11...........',
817 my $fragment = $parser->    #parse_html_string
818   parse_balanced_chunk($I);
819 #11...........
820         },
821
822         'align35.def' => {
823             source => "align35",
824             params => "def",
825             expect => <<'#12...........',
826 # different module names, do not align commas (fixes rt136416)
827 use File::Spec::Functions 'catfile', 'catdir';
828 use Mojo::Base 'Mojolicious', '-signatures';
829
830 # same module names, align fat commas
831 use constant PI     => 4 * atan2 1, 1;
832 use constant TWOPI  => 2 * PI;
833 use constant FOURPI => 4 * PI;
834
835 # same module names, align commas
836 use TestCounter '3rd-party', 0, '3rd-party no longer visible';
837 use TestCounter 'replace',   1, 'replacement now visible';
838 use TestCounter 'root';
839
840 # same module name, align fat commas but not commas
841 use constant COUNTDOWN => scalar reverse 1, 2, 3, 4, 5;
842 use constant COUNTUP   => reverse 1, 2, 3, 4, 5;
843 use constant COUNTDOWN => scalar reverse 1, 2, 3, 4, 5;
844 #12...........
845         },
846
847         'rt136417.def' => {
848             source => "rt136417",
849             params => "def",
850             expect => <<'#13...........',
851 function(
852     #
853     a, b, c
854 );
855
856 %hash = (
857     a => b,
858     c => d,
859 );
860 #13...........
861         },
862
863         'rt136417.rt136417' => {
864             source => "rt136417",
865             params => "rt136417",
866             expect => <<'#14...........',
867 function(
868     #
869     a, b, c );
870
871 %hash = (
872     a => b,
873     c => d,
874 );
875 #14...........
876         },
877
878         'numbers.def' => {
879             source => "numbers",
880             params => "def",
881             expect => <<'#15...........',
882 # valid numbers
883 my @vals = (
884
885     12345,
886     12345.67,
887     .23E-10,
888     3.14_15_92,
889     4_294_967_296,
890     0xff,
891     0xdead_beef,
892     0377,
893     0b011011,
894     0x1.999ap-4,
895     1e34,
896     1e+34,
897     1e+034,
898     -1e+034,
899     0.00000000000000000000000000000000000000000000000000000000000000000001,
900     0Xabcdef,
901     0B1101,
902     0o12_345,    # optional 'o' and 'O' added in perl v5.33.5
903     0O12_345,
904 );
905 #15...........
906         },
907
908         'code_skipping.def' => {
909             source => "code_skipping",
910             params => "def",
911             expect => <<'#16...........',
912 %Hdr        = %U2E    = %E2U      = %Fallback = ();
913 $in_charmap = $nerror = $nwarning = 0;
914 $.          = 0;
915 #<<V  code skipping: perltidy will pass this verbatim without error checking
916
917     }}} {{{
918
919 #>>V
920 my $self    = shift;
921 my $cloning = shift;
922 #16...........
923         },
924
925         'git51.def' => {
926             source => "git51",
927             params => "def",
928             expect => <<'#17...........',
929 Type::Libraries->setup_class(
930     __PACKAGE__,
931     qw(
932       Types::Standard
933       Types::Common::Numeric
934     ),    # <--- brace here
935 );
936 #17...........
937         },
938
939         'git51.git51' => {
940             source => "git51",
941             params => "git51",
942             expect => <<'#18...........',
943 Type::Libraries->setup_class(
944         __PACKAGE__,
945         qw(
946                 Types::Standard
947                 Types::Common::Numeric
948         ),    # <--- brace here
949 );
950 #18...........
951         },
952
953         'pretok.def' => {
954             source => "pretok",
955             params => "def",
956             expect => <<'#19...........',
957 # test sub split_pretoken
958 my $s1 = $^? ? "def" : "not def";
959 my $s2 = $^  ? "def" : "not def";
960 my $s3 = $^ if ($s2);
961 my $s4 = $^O eq "linux";
962 my $s5 = $^O ne "linux";
963 my $s6 = $^O ne "linux";
964 my $s7 = %^O;
965 my $s8 = 'hi' . 's' x 10 if (1);
966 my $s9 = 'merci' x 0.1e4 . $s8;
967 #19...........
968         },
969     };
970
971     my $ntests = 0 + keys %{$rtests};
972     plan tests => $ntests;
973 }
974
975 ###############
976 # EXECUTE TESTS
977 ###############
978
979 foreach my $key ( sort keys %{$rtests} ) {
980     my $output;
981     my $sname  = $rtests->{$key}->{source};
982     my $expect = $rtests->{$key}->{expect};
983     my $pname  = $rtests->{$key}->{params};
984     my $source = $rsources->{$sname};
985     my $params = defined($pname) ? $rparams->{$pname} : "";
986     my $stderr_string;
987     my $errorfile_string;
988     my $err = Perl::Tidy::perltidy(
989         source      => \$source,
990         destination => \$output,
991         perltidyrc  => \$params,
992         argv        => '',             # for safety; hide any ARGV from perltidy
993         stderr      => \$stderr_string,
994         errorfile   => \$errorfile_string,    # not used when -se flag is set
995     );
996     if ( $err || $stderr_string || $errorfile_string ) {
997         print STDERR "Error output received for test '$key'\n";
998         if ($err) {
999             print STDERR "An error flag '$err' was returned\n";
1000             ok( !$err );
1001         }
1002         if ($stderr_string) {
1003             print STDERR "---------------------\n";
1004             print STDERR "<<STDERR>>\n$stderr_string\n";
1005             print STDERR "---------------------\n";
1006             ok( !$stderr_string );
1007         }
1008         if ($errorfile_string) {
1009             print STDERR "---------------------\n";
1010             print STDERR "<<.ERR file>>\n$errorfile_string\n";
1011             print STDERR "---------------------\n";
1012             ok( !$errorfile_string );
1013         }
1014     }
1015     else {
1016         if ( !is( $output, $expect, $key ) ) {
1017             my $leno = length($output);
1018             my $lene = length($expect);
1019             if ( $leno == $lene ) {
1020                 print STDERR
1021 "#> Test '$key' gave unexpected output.  Strings differ but both have length $leno\n";
1022             }
1023             else {
1024                 print STDERR
1025 "#> Test '$key' gave unexpected output.  String lengths differ: output=$leno, expected=$lene\n";
1026             }
1027         }
1028     }
1029 }