$VAR1 = {
- 'short-concatenation-item-length' => [
- 12,
- 8
- ],
- 'line-up-parentheses' => [
- 0,
- 1
- ],
- 'blank-lines-before-subs' => [
- 0,
- 1
- ],
- 'closing-side-comments' => [
- 0,
- 1
- ],
- 'stack-closing-hash-brace' => [
- 0,
- 1
- ],
- 'closing-paren-indentation' => [
- 0,
- 1,
- 2
- ],
- 'delete-side-comments' => [
- 0,
+ 'cuddled-break-option' => [
1
],
- 'backup-and-modify-in-place' => [
- 0,
- 1
- ],
- 'space-backslash-quote' => [
- 0,
- 1,
- 2
- ],
- 'warning-output' => [
- 0,
- 1
- ],
- 'outdent-keywords' => [
- 0,
- 1
- ],
+ 'nowant-right-space' => [
+ '+ -',
+ '+ - / *',
+ '++ --',
+ '..',
+ '= + - / *',
+ 'A'
+ ],
+ 'iterations' => [
+ 1,
+ 4
+ ],
+ 'break-at-old-ternary-breakpoints' => [
+ 0,
+ 1
+ ],
+ 'square-bracket-vertical-tightness-closing' => [
+ 0,
+ 1,
+ 2
+ ],
+ 'format' => [
+ 'html',
+ 'tidy'
+ ],
+ 'keyword-group-blanks-delete' => [
+ 0,
+ 1
+ ],
+ 'break-at-old-attribute-breakpoints' => [
+ 0,
+ 1
+ ],
+ 'comma-arrow-breakpoints' => [
+ 1,
+ 5
+ ],
'maximum-line-length' => [
0,
1,
100,
100000,
160,
+ 33,
77,
78,
80
],
- 'paren-tightness' => [
- 0,
- 1,
- 2
- ],
- 'starting-indentation-level' => [
- 0
- ],
- 'break-before-all-operators' => [
- 0,
- 1
- ],
- 'outdent-static-block-comments' => [
- 0,
- 1
- ],
- 'delete-closing-side-comments' => [
+ 'opening-square-bracket-right' => [
0,
1
],
- 'ignore-old-breakpoints' => [
- 0,
- 1
- ],
- 'fuzzy-line-length' => [
- 0,
- 1
+ 'line-up-parentheses' => [
+ 0,
+ 1
+ ],
+ 'brace-vertical-tightness' => [
+ 0,
+ 1,
+ 2
+ ],
+ 'brace-left-and-indent-list' => [
+ '*',
+ 'if'
+ ],
+ 'nowant-left-space' => [
+ '+ - / *',
+ '++ -- ?',
+ '..',
+ '= + - / *',
+ '= / *'
],
- 'add-newlines' => [
+ 'opening-sub-brace-on-new-line' => [
+ 0,
+ 1
+ ],
+ 'want-right-space' => [
+ '->',
+ '= .= =~ !~ ? :',
+ '= / *'
+ ],
+ 'cuddled-else' => [
0,
1
],
- 'keep-interior-semicolons' => [
+ 'paren-tightness' => [
+ 0,
+ 1,
+ 2
+ ],
+ 'indent-columns' => [
+ 0,
+ 2,
+ 4
+ ],
+ 'paren-vertical-tightness' => [
+ 0,
+ 1,
+ 2
+ ],
+ 'break-at-old-semicolon-breakpoints' => [
+ 0,
+ 1
+ ],
+ 'space-keyword-paren' => [
+ 0,
+ 1
+ ],
+ 'opening-paren-right' => [
+ 0,
+ 1
+ ],
+ 'maximum-file-size-mb' => [
+ 10
+ ],
+ 'outdent-long-quotes' => [
+ 0,
+ 1
+ ],
+ 'maximum-consecutive-blank-lines' => [
+ 0,
+ 1,
+ 2
+ ],
+ 'space-terminal-semicolon' => [
0,
1
],
- 'closing-brace-indentation' => [
+ 'stack-opening-hash-brace' => [
+ 0,
+ 1
+ ],
+ 'closing-paren-indentation' => [
0,
1,
2
],
- 'closing-square-bracket-indentation' => [
- 0,
- 1,
- 2
- ],
- 'trim-pod' => [
- 0,
- 1
- ],
- 'format-skipping' => [
- 0,
- 1
- ],
'keyword-group-blanks-inside' => [
0,
1
],
- 'tight-secret-operators' => [
+ 'maximum-unexpected-errors' => [
+ 0
+ ],
+ 'non-indenting-brace-prefix' => [
+ '#\\+\\+'
+ ],
+ 'delete-old-whitespace' => [
+ 0,
+ 1
+ ],
+ 'brace-left-and-indent' => [
+ 0,
+ 1
+ ],
+ 'static-side-comments' => [
+ 0,
+ 1
+ ],
+ 'opening-anonymous-sub-brace-on-new-line' => [
+ 0,
+ 1
+ ],
+ 'default-tabsize' => [
+ 8
+ ],
+ 'break-before-all-operators' => [
+ 0,
+ 1
+ ],
+ 'closing-side-comment-interval' => [
+ 2,
+ 20,
+ 6
+ ],
+ 'fuzzy-line-length' => [
+ 0,
+ 1
+ ],
+ 'break-before-square-bracket-and-indent' => [
+ 0
+ ],
+ 'one-line-block-nesting' => [
0,
1
],
- 'indent-columns' => [
- 0,
- 2,
- 4
- ],
- 'closing-side-comment-maximum-text' => [
- 20,
- 40
- ],
- 'timestamp' => [
- 0,
- 1
- ],
- 'outdent-long-quotes' => [
+ 'stack-opening-paren' => [
0,
1
],
- 'stack-closing-block-brace' => [
+ 'keep-old-breakpoints-after' => [
+ '=>'
+ ],
+ 'opening-brace-always-on-right' => [
+ 0,
+ 1
+ ],
+ 'logical-padding' => [
+ 0,
+ 1
+ ],
+ 'indent-block-comments' => [
+ 0,
+ 1
+ ],
+ 'brace-vertical-tightness-closing' => [
+ 0,
+ 1,
+ 2
+ ],
+ 'closing-brace-indentation' => [
0,
- 1
+ 1,
+ 2
],
- 'hanging-side-comments' => [
+ 'break-at-old-comma-breakpoints' => [
+ 0,
+ 1
+ ],
+ 'break-at-old-method-breakpoints' => [
+ 0,
+ 1
+ ],
+ 'opening-hash-brace-right' => [
+ 0,
+ 1
+ ],
+ 'indent-closing-brace' => [
+ 0,
+ 1
+ ],
+ 'keyword-group-blanks-after' => [
+ 1,
+ 2
+ ],
+ 'delete-pod' => [
+ 0,
+ 1
+ ],
+ 'sub-alias-list' => [
+ 'method',
+ 'method fun'
+ ],
+ 'add-semicolons' => [
+ 0,
+ 1
+ ],
+ 'static-block-comments' => [
0,
1
],
- 'closing-side-comment-else-flag' => [
- 0
- ],
- 'weld-nested-containers' => [
- 0,
- 1
- ],
'square-bracket-tightness' => [
0,
1,
2
],
- 'want-break-before' => [
- ' ',
- '% + - * / x != == >= <= =~ !~ < > | & = **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x=',
- '% + - * / x != == >= <= =~ < > | & **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x=',
- '='
- ],
- 'delete-semicolons' => [
- 0,
- 1
- ],
- 'square-bracket-vertical-tightness-closing' => [
- 0,
- 2
- ],
- 'recombine' => [
- 0,
- 1
- ],
- 'delete-block-comments' => [
+ 'cuddled-block-list' => [
+ 'map,sort,grep',
+ 'sort,map,grep'
+ ],
+ 'closing-side-comments' => [
0,
1
],
- 'add-whitespace' => [
- 0,
- 1
- ],
- 'default-tabsize' => [
- 8
- ],
- 'format-skipping-end' => [
- '#>{2,}'
- ],
- 'stack-closing-square-bracket' => [
+ 'backup-and-modify-in-place' => [
+ 0,
+ 1
+ ],
+ 'block-brace-tightness' => [
+ 0,
+ 1,
+ 2
+ ],
+ 'trim-pod' => [
+ 0,
+ 1
+ ],
+ 'block-brace-vertical-tightness' => [
+ 0,
+ 1
+ ],
+ 'delete-closing-side-comments' => [
0,
1
],
- 'backup-file-extension' => [
- 'bak',
- '~'
- ],
- 'outdent-keyword-list' => [
- 'next'
- ],
- 'brace-vertical-tightness' => [
+ 'short-concatenation-item-length' => [
+ 12,
+ 8
+ ],
+ 'stack-closing-block-brace' => [
+ 0,
+ 1
+ ],
+ 'continuation-indentation' => [
0,
- 1,
- 2
+ 2,
+ 4
],
- 'want-right-space' => [
- '= .= =~ !~ ? :',
- '= / *'
- ],
- 'static-block-comments' => [
- 0,
- 1
- ],
- 'closing-side-comment-interval' => [
- 2,
- 20,
- 6
- ],
- 'long-block-line-count' => [
- 8
- ],
- 'add-semicolons' => [
- 0,
- 1
- ],
+ 'format-skipping' => [
+ 0,
+ 1
+ ],
'nospace-after-keyword' => [
'my for'
],
- 'space-keyword-paren' => [
- 0,
- 1
- ],
- 'nowant-left-space' => [
- '+ - / *',
- '++ -- ?',
- '..',
- '= + - / *',
- '= / *'
- ],
- 'space-function-paren' => [
- 0,
+ 'keyword-paren-inner-tightness-list' => [
+ 'return factorial'
+ ],
+ 'maximum-level-errors' => [
1
],
- 'opening-sub-brace-on-new-line' => [
- 0,
- 1
- ],
- 'variable-maximum-line-length' => [
+ 'want-left-space' => [
+ '+ -',
+ '->',
+ '= .= =~ !~ :'
+ ],
+ 'fixed-position-side-comment' => [
+ 40
+ ],
+ 'keep-interior-semicolons' => [
+ 0,
+ 1
+ ],
+ 'outdent-keywords' => [
+ 0,
+ 1
+ ],
+ 'stack-opening-square-bracket' => [
0,
1
],
- 'delete-pod' => [
- 0,
- 1
- ],
- 'maximum-fields-per-table' => [
- 0
- ],
- 'paren-vertical-tightness-closing' => [
- 0,
- 2
- ],
'ignore-side-comment-lengths' => [
0,
1
],
- 'delete-old-whitespace' => [
+ 'want-break-before' => [
+ ' ',
+ '% + - * / x != == >= <= =~ !~ < > | & = **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x=',
+ '% + - * / x != == >= <= =~ < > | & **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x=',
+ '='
+ ],
+ 'non-indenting-braces' => [
+ 0,
+ 1
+ ],
+ 'timestamp' => [
+ 0,
+ 1
+ ],
+ 'opening-brace-on-new-line' => [
+ 0,
+ 1
+ ],
+ 'delete-semicolons' => [
+ 0,
+ 1
+ ],
+ 'keyword-group-blanks-size' => [
+ '5'
+ ],
+ 'ignore-old-breakpoints' => [
+ 0,
+ 1
+ ],
+ 'delete-block-comments' => [
0,
1
],
- 'check-syntax' => [
+ 'closing-side-comment-maximum-text' => [
+ 20,
+ 40
+ ],
+ 'add-newlines' => [
0,
1
],
+ 'stack-closing-paren' => [
+ 0,
+ 1
+ ],
'entab-leading-whitespace' => [
8
],
- 'whitespace-cycle' => [
- 4
- ],
- 'block-brace-tightness' => [
- 0,
- 1,
- 2
+ 'perl-syntax-check-flags' => [
+ '-c -T'
+ ],
+ 'blank-lines-before-packages' => [
+ 0,
+ 1
+ ],
+ 'long-block-line-count' => [
+ 8
],
'keyword-group-blanks-before' => [
1,
2
],
- 'cuddled-else' => [
- 0,
- 1
- ],
- 'keyword-group-blanks-repeat-count' => [
- 0
- ],
- 'cuddled-block-list' => [
- 'map,sort,grep',
- 'sort,map,grep'
- ],
- 'nowant-right-space' => [
- '+ -',
- '+ - / *',
- '++ --',
- '..',
- '= + - / *',
- 'A'
- ],
- 'stack-closing-paren' => [
- 0,
- 1
- ],
- 'maximum-consecutive-blank-lines' => [
- 0,
- 1,
- 2
- ],
- 'outdent-labels' => [
- 0,
- 1
- ],
- 'cuddled-break-option' => [
+ 'stack-closing-square-bracket' => [
+ 0,
+ 1
+ ],
+ 'break-at-old-keyword-breakpoints' => [
+ 0,
+ 1
+ ],
+ 'space-function-paren' => [
+ 0,
1
],
+ 'keep-old-breakpoints-before' => [
+ '=> ,'
+ ],
+ 'tight-secret-operators' => [
+ 0,
+ 1
+ ],
+ 'space-after-keyword' => [
+ 'push'
+ ],
'indent-spaced-block-comments' => [
0,
1
],
- 'closing-side-comments-balanced' => [
- 0,
- 1
- ],
- 'blank-lines-before-closing-block' => [
- 1
- ],
- 'brace-vertical-tightness-closing' => [
+ 'break-before-paren-and-indent' => [
+ 0,
+ 1,
+ 2
+ ],
+ 'paren-vertical-tightness-closing' => [
0,
+ 1,
2
],
- 'opening-brace-on-new-line' => [
- 0,
- 1
- ],
- 'blank-lines-after-opening-block-list' => [
- '*'
- ],
- 'one-line-block-semicolons' => [
- 0,
- 1,
- 2
- ],
- 'perl-syntax-check-flags' => [
- '-c -T'
- ],
- 'comma-arrow-breakpoints' => [
- 1,
- 5
- ],
- 'opening-paren-right' => [
+ 'delete-old-newlines' => [
0,
1
],
- 'opening-hash-brace-right' => [
- 0,
- 1
- ],
- 'static-side-comments' => [
- 0,
- 1
- ],
- 'keyword-group-blanks-after' => [
- 1,
- 2
+ 'starting-indentation-level' => [
+ 0
],
- 'blanks-before-blocks' => [
+ 'weld-nested-containers' => [
+ 0,
+ 1
+ ],
+ 'check-syntax' => [
+ 0,
+ 1
+ ],
+ 'backup-file-extension' => [
+ 'bak',
+ '~'
+ ],
+ 'look-for-hash-bang' => [
+ 0,
+ 1
+ ],
+ 'break-before-hash-brace-and-indent' => [
+ 0,
+ 1,
+ 2
+ ],
+ 'blank-lines-before-subs' => [
+ 0,
+ 1
+ ],
+ 'blank-lines-before-closing-block-list' => [
+ '*'
+ ],
+ 'delete-side-comments' => [
0,
1
],
- 'format-skipping-begin' => [
- '#<{2,}'
+ 'one-line-block-semicolons' => [
+ 0,
+ 1,
+ 2
+ ],
+ 'keyword-group-blanks-repeat-count' => [
+ 0
+ ],
+ 'break-before-square-bracket' => [
+ 0
+ ],
+ 'static-block-comment-prefix' => [
+ '#x#'
+ ],
+ 'space-backslash-quote' => [
+ 0,
+ 1,
+ 2
],
- 'one-line-block-nesting' => [
- 0,
- 1
- ],
- 'opening-square-bracket-right' => [
- 0,
- 1
- ],
+ 'closing-side-comments-balanced' => [
+ 0,
+ 1
+ ],
+ 'outdent-labels' => [
+ 0,
+ 1
+ ],
+ 'closing-square-bracket-indentation' => [
+ 0,
+ 1,
+ 2
+ ],
+ 'add-whitespace' => [
+ 0,
+ 1
+ ],
+ 'recombine' => [
+ 0,
+ 1
+ ],
+ 'format-skipping-end' => [
+ '#>{2,}'
+ ],
'break-after-all-operators' => [
0,
1
],
- 'outdent-long-comments' => [
- 0,
- 1
- ],
- 'opening-brace-always-on-right' => [
+ 'character-encoding' => [
+ 'guess'
+ ],
+ 'want-break-after' => [
+ '% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x= . << >> -> && ||'
+ ],
+ 'blank-lines-before-closing-block' => [
+ 1
+ ],
+ 'whitespace-cycle' => [
+ 4
+ ],
+ 'keyword-paren-inner-tightness' => [
0,
1
],
- 'keyword-group-blanks-size' => [
- '5'
- ],
- 'keep-old-blank-lines' => [
- 0,
- 1,
- 2
- ],
- 'paren-vertical-tightness' => [
- 0,
- 1,
- 2
- ],
- 'indent-closing-brace' => [
+ 'break-before-hash-brace' => [
+ 0,
+ 2,
+ 3
+ ],
+ 'blanks-before-blocks' => [
0,
1
],
- 'stack-opening-square-bracket' => [
- 0,
- 1
- ],
- 'blanks-before-comments' => [
- 0,
- 1
- ],
- 'stack-opening-paren' => [
- 0,
- 1
- ],
- 'brace-left-and-indent' => [
+ 'maximum-fields-per-table' => [
+ 0
+ ],
+ 'closing-side-comment-list' => [
+ 'sub'
+ ],
+ 'hanging-side-comments' => [
0,
1
],
- 'block-brace-vertical-tightness' => [
- 0,
- 1
- ],
- 'brace-left-and-indent-list' => [
- 'if'
- ],
- 'standard-error-output' => [
+ 'outdent-long-comments' => [
0,
1
],
- 'want-left-space' => [
- '+ -',
- '= .= =~ !~ :'
- ],
- 'keyword-paren-inner-tightness' => [
- 0,
- 1
- ],
- 'brace-tightness' => [
- 0,
- 1,
- 2
- ],
- 'blank-lines-before-packages' => [
- 0,
- 1
- ],
- 'blank-lines-before-closing-block-list' => [
- '*'
- ],
- 'iterations' => [
- 1,
- 4
- ],
- 'continuation-indentation' => [
- 0,
- 2,
- 4
- ],
+ 'format-skipping-begin' => [
+ '#<{2,}'
+ ],
+ 'blanks-before-comments' => [
+ 0,
+ 1
+ ],
+ 'keep-old-blank-lines' => [
+ 0,
+ 1,
+ 2
+ ],
'space-prototype-paren' => [
0,
1,
0,
1
],
- 'break-at-old-method-breakpoints' => [
- 0,
- 1
- ],
- 'keyword-group-blanks-delete' => [
- 0,
- 1
- ],
- 'break-at-old-semicolon-breakpoints' => [
- 0,
- 1
- ],
- 'want-break-after' => [
- '% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x= . << >> -> && ||'
- ],
- 'minimum-space-to-comment' => [
- 10,
- 2,
- 4
- ],
- 'break-at-old-comma-breakpoints' => [
- 0,
- 1
- ],
- 'logical-padding' => [
- 0,
- 1
- ],
- 'space-terminal-semicolon' => [
+ 'break-at-old-logical-breakpoints' => [
+ 0,
+ 1
+ ],
+ 'outdent-static-block-comments' => [
+ 0,
+ 1
+ ],
+ 'stack-closing-hash-brace' => [
0,
1
],
- 'format' => [
- 'html',
- 'tidy'
- ],
- 'indent-block-comments' => [
+ 'blank-lines-after-opening-block-list' => [
+ '*'
+ ],
+ 'standard-error-output' => [
0,
1
],
- 'space-after-keyword' => [
- 'push'
+ 'space-for-semicolon' => [
+ 0,
+ 1
],
+ 'minimum-space-to-comment' => [
+ 10,
+ 2,
+ 4
+ ],
+ 'warning-output' => [
+ 0,
+ 1
+ ],
+ 'break-before-paren' => [
+ 0,
+ 2,
+ 3
+ ],
+ 'closing-side-comment-else-flag' => [
+ 0
+ ],
'square-bracket-vertical-tightness' => [
0,
1,
2
],
- 'sub-alias-list' => [
- 'method fun'
- ],
- 'delete-old-newlines' => [
- 0,
- 1
- ],
- 'opening-anonymous-sub-brace-on-new-line' => [
- 0,
- 1
- ],
- 'space-for-semicolon' => [
- 0,
- 1
- ],
- 'fixed-position-side-comment' => [
- 40
- ],
- 'keyword-paren-inner-tightness-list' => [
- 'return factorial'
- ],
- 'character-encoding' => [
- 'guess'
- ],
'blank-lines-after-opening-block' => [
2
],
- 'stack-opening-hash-brace' => [
- 0,
- 1
- ]
+ 'extended-continuation-indentation' => [
+ 0,
+ 1
+ ],
+ 'brace-tightness' => [
+ 0,
+ 1,
+ 2
+ ],
+ 'outdent-keyword-list' => [
+ 'next'
+ ],
+ 'variable-maximum-line-length' => [
+ 0,
+ 1
+ ]
};
--- /dev/null
+# Created with: ./make_t.pl
+
+# Contents:
+#1 boa.def
+#2 bol.bol
+#3 bol.def
+#4 bot.bot
+#5 bot.def
+#6 hash_bang.def
+#7 hash_bang.hash_bang
+#8 listop1.listop1
+#9 sbcp.def
+#10 sbcp.sbcp1
+
+# To locate test #13 you can search for its name or the string '#13'
+
+use strict;
+use Test::More;
+use Carp;
+use Perl::Tidy;
+my $rparams;
+my $rsources;
+my $rtests;
+
+BEGIN {
+
+ ###########################################
+ # BEGIN SECTION 1: Parameter combinations #
+ ###########################################
+ $rparams = {
+ 'bol' => <<'----------',
+# -bol is default, so test -nbol
+-nbol
+----------
+ 'bot' => <<'----------',
+# -bot is default so we test -nbot
+-nbot
+----------
+ 'def' => "",
+ 'hash_bang' => "-x",
+ 'listop1' => <<'----------',
+# -bok is default so we test nbok
+-nbok
+----------
+ 'sbcp1' => <<'----------',
+-sbc -sbcp='#x#'
+----------
+ };
+
+ ############################
+ # BEGIN SECTION 2: Sources #
+ ############################
+ $rsources = {
+
+ 'boa' => <<'----------',
+my @field
+ : field
+ : Default(1)
+ : Get('Name' => 'foo')
+ : Set('Name');
+----------
+
+ 'bol' => <<'----------',
+return unless $cmd = $cmd || ($dot
+ && $Last_Shell) || &prompt('|');
+----------
+
+ 'bot' => <<'----------',
+$foo =
+ $condition
+ ? undef
+ : 1;
+----------
+
+ 'hash_bang' => <<'----------',
+
+
+
+
+# above spaces will be retained with -x but not by default
+#!/usr/bin/perl
+my $date = localtime();
+----------
+
+ 'listop1' => <<'----------',
+my @sorted = map { $_->[0] }
+ sort { $a->[1] <=> $b->[1] }
+ map { [ $_, rand ] } @list;
+----------
+
+ 'sbcp' => <<'----------',
+@month_of_year = (
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
+#x# 'Dec', 'Nov'
+## 'Dec', 'Nov'
+ 'Nov', 'Dec'
+);
+----------
+ };
+
+ ####################################
+ # BEGIN SECTION 3: Expected output #
+ ####################################
+ $rtests = {
+
+ 'boa.def' => {
+ source => "boa",
+ params => "def",
+ expect => <<'#1...........',
+my @field
+ : field
+ : Default(1)
+ : Get('Name' => 'foo')
+ : Set('Name');
+#1...........
+ },
+
+ 'bol.bol' => {
+ source => "bol",
+ params => "bol",
+ expect => <<'#2...........',
+return unless $cmd = $cmd || ( $dot && $Last_Shell ) || &prompt('|');
+#2...........
+ },
+
+ 'bol.def' => {
+ source => "bol",
+ params => "def",
+ expect => <<'#3...........',
+return
+ unless $cmd = $cmd
+ || ( $dot
+ && $Last_Shell )
+ || &prompt('|');
+#3...........
+ },
+
+ 'bot.bot' => {
+ source => "bot",
+ params => "bot",
+ expect => <<'#4...........',
+$foo = $condition ? undef : 1;
+#4...........
+ },
+
+ 'bot.def' => {
+ source => "bot",
+ params => "def",
+ expect => <<'#5...........',
+$foo =
+ $condition
+ ? undef
+ : 1;
+#5...........
+ },
+
+ 'hash_bang.def' => {
+ source => "hash_bang",
+ params => "def",
+ expect => <<'#6...........',
+
+# above spaces will be retained with -x but not by default
+#!/usr/bin/perl
+my $date = localtime();
+#6...........
+ },
+
+ 'hash_bang.hash_bang' => {
+ source => "hash_bang",
+ params => "hash_bang",
+ expect => <<'#7...........',
+
+
+
+
+# above spaces will be retained with -x but not by default
+#!/usr/bin/perl
+my $date = localtime();
+#7...........
+ },
+
+ 'listop1.listop1' => {
+ source => "listop1",
+ params => "listop1",
+ expect => <<'#8...........',
+my @sorted =
+ map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_, rand ] } @list;
+#8...........
+ },
+
+ 'sbcp.def' => {
+ source => "sbcp",
+ params => "def",
+ expect => <<'#9...........',
+@month_of_year = (
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
+
+ #x# 'Dec', 'Nov'
+## 'Dec', 'Nov'
+ 'Nov', 'Dec'
+);
+#9...........
+ },
+
+ 'sbcp.sbcp1' => {
+ source => "sbcp",
+ params => "sbcp1",
+ expect => <<'#10...........',
+@month_of_year = (
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
+#x# 'Dec', 'Nov'
+ ## 'Dec', 'Nov'
+ 'Nov', 'Dec'
+);
+#10...........
+ },
+ };
+
+ my $ntests = 0 + keys %{$rtests};
+ plan tests => $ntests;
+}
+
+###############
+# EXECUTE TESTS
+###############
+
+foreach my $key ( sort keys %{$rtests} ) {
+ my $output;
+ my $sname = $rtests->{$key}->{source};
+ my $expect = $rtests->{$key}->{expect};
+ my $pname = $rtests->{$key}->{params};
+ my $source = $rsources->{$sname};
+ my $params = defined($pname) ? $rparams->{$pname} : "";
+ my $stderr_string;
+ my $errorfile_string;
+ my $err = Perl::Tidy::perltidy(
+ source => \$source,
+ destination => \$output,
+ perltidyrc => \$params,
+ argv => '', # for safety; hide any ARGV from perltidy
+ stderr => \$stderr_string,
+ errorfile => \$errorfile_string, # not used when -se flag is set
+ );
+ if ( $err || $stderr_string || $errorfile_string ) {
+ print STDERR "Error output received for test '$key'\n";
+ if ($err) {
+ print STDERR "An error flag '$err' was returned\n";
+ ok( !$err );
+ }
+ if ($stderr_string) {
+ print STDERR "---------------------\n";
+ print STDERR "<<STDERR>>\n$stderr_string\n";
+ print STDERR "---------------------\n";
+ ok( !$stderr_string );
+ }
+ if ($errorfile_string) {
+ print STDERR "---------------------\n";
+ print STDERR "<<.ERR file>>\n$errorfile_string\n";
+ print STDERR "---------------------\n";
+ ok( !$errorfile_string );
+ }
+ }
+ else {
+ if ( !is( $output, $expect, $key ) ) {
+ my $leno = length($output);
+ my $lene = length($expect);
+ if ( $leno == $lene ) {
+ print STDERR
+"#> Test '$key' gave unexpected output. Strings differ but both have length $leno\n";
+ }
+ else {
+ print STDERR
+"#> Test '$key' gave unexpected output. String lengths differ: output=$leno, expected=$lene\n";
+ }
+ }
+ }
+}