From: Steve Hancock Date: Sat, 23 May 2020 13:48:14 +0000 (-0700) Subject: remove vertical alignment anonymous sub braces; update test cases X-Git-Tag: 20200619~27 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=df55049cd9780dd690b69c56dbdee17b615f09af;p=perltidy.git remove vertical alignment anonymous sub braces; update test cases --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 8032b832..5acd53a3 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -12308,6 +12308,17 @@ sub get_seqno { $alignment_type = $vert_last_nonblank_type; } + #-------------------------------------------------------- + # Undo alignment in special cases + #-------------------------------------------------------- + if ($alignment_type) { + + # do not align the opening brace of an anonymous sub + if ( $token eq '{' && $block_type =~ /$ASUB_PATTERN/ ) { + $alignment_type = ""; + } + } + #-------------------------------------------------------- # then store the value #-------------------------------------------------------- diff --git a/t/snippets/coverage_values.txt b/t/snippets/coverage_values.txt index ce53982f..7748adb8 100644 --- a/t/snippets/coverage_values.txt +++ b/t/snippets/coverage_values.txt @@ -1,167 +1,148 @@ $VAR1 = { - 'brace-left-and-indent-list' => [ - 'if' - ], - 'opening-anonymous-sub-brace-on-new-line' => [ - 0, - 1 - ], - 'maximum-fields-per-table' => [ - 0 - ], - 'blank-lines-after-opening-block' => [ - 2 - ], - 'starting-indentation-level' => [ - 0 - ], - 'cuddled-else' => [ - 0, - 1 - ], - 'paren-tightness' => [ - 0, - 1, - 2 - ], - 'perl-syntax-check-flags' => [ - '-c -T' - ], - 'outdent-labels' => [ - 0, - 1 - ], - 'space-function-paren' => [ - 0, - 1 - ], - 'timestamp' => [ + 'opening-brace-on-new-line' => [ + 0, + 1 + ], + 'brace-left-and-indent' => [ + 0, + 1 + ], + 'delete-old-newlines' => [ + 0, + 1 + ], + 'recombine' => [ 0, 1 ], - 'closing-side-comment-maximum-text' => [ - 20, - 40 - ], - 'ignore-old-breakpoints' => [ - 0, - 1 - ], - 'closing-brace-indentation' => [ - 0, - 1, - 2 - ], - 'blank-lines-before-closing-block' => [ - 1 - ], - 'break-at-old-comma-breakpoints' => [ - 0, - 1 - ], - 'delete-pod' => [ - 0, - 1 - ], - 'brace-vertical-tightness-closing' => [ - 0, - 2 - ], - 'want-right-space' => [ - '= .= =~ !~ ? :', - '= / *' - ], 'keyword-group-blanks-delete' => [ 0, 1 ], - 'indent-columns' => [ - 0, - 2, - 4 - ], - 'weld-nested-containers' => [ - 0, - 1 - ], - 'closing-side-comments' => [ - 0, - 1 - ], - 'cuddled-break-option' => [ - 1 - ], - 'space-prototype-paren' => [ - 0, - 1, - 2 - ], - 'stack-opening-hash-brace' => [ + 'space-terminal-semicolon' => [ 0, 1 ], - 'add-whitespace' => [ - 0, - 1 - ], - 'static-block-comments' => [ - 0, - 1 - ], - 'trim-pod' => [ - 0, - 1 - ], - 'closing-side-comments-balanced' => [ + 'brace-vertical-tightness' => [ + 0, + 1, + 2 + ], + 'backup-and-modify-in-place' => [ + 0, + 1 + ], + 'brace-left-and-indent-list' => [ + 'if' + ], + 'block-brace-vertical-tightness' => [ 0, 1 ], + 'cuddled-break-option' => [ + 1 + ], + 'square-bracket-vertical-tightness-closing' => [ + 0, + 2 + ], 'long-block-line-count' => [ 8 ], - 'maximum-line-length' => [ - 0, - 1, - 100, - 100000, - 160, - 77, - 78, - 80 + 'opening-brace-always-on-right' => [ + 0, + 1 + ], + 'keep-old-blank-lines' => [ + 0, + 1, + 2 + ], + 'short-concatenation-item-length' => [ + 12, + 8 + ], + 'format-skipping-end' => [ + '#>{2,}' ], - 'backup-and-modify-in-place' => [ - 0, - 1 - ], - 'delete-semicolons' => [ - 0, - 1 + 'want-break-before' => [ + ' ', + '% + - * / x != == >= <= =~ !~ < > | & = **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x=', + '% + - * / x != == >= <= =~ < > | & **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x=', + '=' ], - 'outdent-long-comments' => [ + 'stack-opening-square-bracket' => [ + 0, + 1 + ], + 'indent-closing-brace' => [ + 0, + 1 + ], + 'outdent-static-block-comments' => [ + 0, + 1 + ], + 'block-brace-tightness' => [ 0, - 1 + 1, + 2 ], 'check-syntax' => [ 0, 1 ], - 'delete-side-comments' => [ + 'static-block-comments' => [ + 0, + 1 + ], + 'maximum-consecutive-blank-lines' => [ + 0, + 1, + 2 + ], + 'maximum-fields-per-table' => [ + 0 + ], + 'space-function-paren' => [ 0, 1 ], - 'hanging-side-comments' => [ + 'space-after-keyword' => [ + 'push' + ], + 'want-right-space' => [ + '= .= =~ !~ ? :', + '= / *' + ], + 'standard-error-output' => [ 0, 1 ], - 'entab-leading-whitespace' => [ - 8 + 'square-bracket-tightness' => [ + 0, + 1, + 2 ], - 'one-line-block-semicolons' => [ - 0, - 1, - 2 - ], - 'stack-closing-block-brace' => [ + 'format-skipping' => [ + 0, + 1 + ], + 'closing-side-comment-maximum-text' => [ + 20, + 40 + ], + 'sub-alias-list' => [ + 'method fun' + ], + 'backup-file-extension' => [ + 'bak', + '~' + ], + 'fixed-position-side-comment' => [ + 40 + ], + 'break-after-all-operators' => [ 0, 1 ], @@ -169,370 +150,391 @@ $VAR1 = { 0, 1 ], - 'keyword-group-blanks-before' => [ - 1, - 2 + 'weld-nested-containers' => [ + 0, + 1 + ], + 'ignore-side-comment-lengths' => [ + 0, + 1 ], - 'indent-spaced-block-comments' => [ - 0, - 1 - ], - 'indent-closing-brace' => [ - 0, - 1 - ], - 'character-encoding' => [ - 'guess' - ], - 'opening-sub-brace-on-new-line' => [ - 0, - 1 - ], + 'keyword-group-blanks-repeat-count' => [ + 0 + ], + 'format-skipping-begin' => [ + '#<{2,}' + ], 'add-semicolons' => [ 0, 1 ], - 'paren-vertical-tightness-closing' => [ - 0, - 2 - ], - 'nospace-after-keyword' => [ - 'my for' - ], - 'delete-old-newlines' => [ + 'maximum-line-length' => [ 0, - 1 + 1, + 100, + 100000, + 160, + 77, + 78, + 80 ], - 'paren-vertical-tightness' => [ - 0, - 1, - 2 - ], - 'nowant-right-space' => [ - '+ -', - '++ --', - '..', - '= + - / *', - 'A' - ], - 'format-skipping' => [ - 0, - 1 - ], - 'brace-left-and-indent' => [ + 'outdent-labels' => [ + 0, + 1 + ], + 'space-prototype-paren' => [ 0, - 1 + 1, + 2 ], - 'delete-closing-side-comments' => [ + 'closing-square-bracket-indentation' => [ + 0, + 1, + 2 + ], + 'stack-closing-hash-brace' => [ + 0, + 1 + ], + 'blank-lines-before-subs' => [ + 0, + 1 + ], + 'indent-spaced-block-comments' => [ 0, 1 ], - 'closing-side-comment-else-flag' => [ - 0 - ], - 'opening-paren-right' => [ + 'want-break-after' => [ + '% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x= . << >> -> && ||' + ], + 'outdent-long-quotes' => [ 0, 1 ], - 'outdent-static-block-comments' => [ - 0, - 1 - ], - 'keep-old-blank-lines' => [ - 0, - 1, - 2 - ], - 'break-before-all-operators' => [ - 0, - 1 - ], + 'opening-square-bracket-right' => [ + 0, + 1 + ], + 'tight-secret-operators' => [ + 0, + 1 + ], + 'closing-paren-indentation' => [ + 0, + 1, + 2 + ], + 'trim-pod' => [ + 0, + 1 + ], + 'delete-semicolons' => [ + 0, + 1 + ], + 'paren-vertical-tightness-closing' => [ + 0, + 2 + ], + 'brace-tightness' => [ + 0, + 1, + 2 + ], + 'break-at-old-method-breakpoints' => [ + 0, + 1 + ], + 'nowant-left-space' => [ + '+ - / *', + '++ -- ?', + '..', + '= + - / *', + '= / *' + ], + 'stack-closing-block-brace' => [ + 0, + 1 + ], 'space-for-semicolon' => [ 0, 1 ], - 'want-break-before' => [ - ' ', - '% + - * / x != == >= <= =~ !~ < > | & = **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x=', - '% + - * / x != == >= <= =~ < > | & **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x=', - '=' - ], - 'blank-lines-before-subs' => [ - 0, - 1 - ], + 'warning-output' => [ + 0, + 1 + ], 'one-line-block-nesting' => [ 0, 1 ], - 'space-after-keyword' => [ - 'push' - ], - 'break-after-all-operators' => [ - 0, - 1 - ], - 'opening-square-bracket-right' => [ + 'starting-indentation-level' => [ + 0 + ], + 'static-side-comments' => [ + 0, + 1 + ], + 'stack-closing-square-bracket' => [ 0, 1 ], - 'outdent-long-quotes' => [ + 'blanks-before-blocks' => [ + 0, + 1 + ], + 'nospace-after-keyword' => [ + 'my for' + ], + 'delete-pod' => [ + 0, + 1 + ], + 'timestamp' => [ + 0, + 1 + ], + 'stack-closing-paren' => [ 0, 1 ], - 'stack-opening-paren' => [ + 'outdent-long-comments' => [ + 0, + 1 + ], + 'format' => [ + 'html', + 'tidy' + ], + 'line-up-parentheses' => [ 0, 1 ], - 'maximum-consecutive-blank-lines' => [ - 0, - 1, - 2 - ], - 'stack-closing-hash-brace' => [ - 0, - 1 - ], - 'comma-arrow-breakpoints' => [ - 1, - 5 - ], - 'fixed-position-side-comment' => [ - 40 - ], - 'blank-lines-before-closing-block-list' => [ - '*' - ], - 'keyword-group-blanks-inside' => [ - 0, - 1 - ], - 'want-break-after' => [ - '% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x= . << >> -> && ||' - ], - 'square-bracket-vertical-tightness-closing' => [ - 0, - 2 - ], - 'square-bracket-tightness' => [ + 'opening-anonymous-sub-brace-on-new-line' => [ + 0, + 1 + ], + 'paren-vertical-tightness' => [ 0, 1, 2 ], - 'break-at-old-method-breakpoints' => [ - 0, - 1 - ], - 'square-bracket-vertical-tightness' => [ - 0, - 1, - 2 - ], - 'default-tabsize' => [ - 8 - ], - 'ignore-side-comment-lengths' => [ - 0, - 1 - ], + 'cuddled-else' => [ + 0, + 1 + ], 'iterations' => [ 1 ], - 'closing-square-bracket-indentation' => [ - 0, - 1, - 2 - ], - 'continuation-indentation' => [ - 0, - 2, - 4 - ], - 'nowant-left-space' => [ - '++ -- ?', - '..', - '= + - / *', - '= / *' - ], - 'standard-error-output' => [ - 0, - 1 - ], - 'blanks-before-blocks' => [ - 0, - 1 - ], - 'closing-paren-indentation' => [ - 0, - 1, - 2 - ], - 'format-skipping-end' => [ - '#>{2,}' + 'stack-opening-paren' => [ + 0, + 1 ], - 'keyword-group-blanks-repeat-count' => [ - 0 - ], - 'backup-file-extension' => [ - 'bak', - '~' - ], - 'keyword-group-blanks-after' => [ - 1, - 2 - ], - 'keep-interior-semicolons' => [ - 0, - 1 - ], - 'keyword-group-blanks-size' => [ - '5' - ], - 'space-terminal-semicolon' => [ + 'outdent-keywords' => [ + 0, + 1 + ], + 'closing-side-comment-interval' => [ + 2, + 20, + 6 + ], + 'continuation-indentation' => [ 0, - 1 + 2, + 4 ], - 'outdent-keywords' => [ - 0, - 1 - ], - 'indent-block-comments' => [ + 'keyword-group-blanks-after' => [ + 1, + 2 + ], + 'ignore-old-breakpoints' => [ + 0, + 1 + ], + 'add-whitespace' => [ + 0, + 1 + ], + 'minimum-space-to-comment' => [ + 10, + 2, + 4 + ], + 'character-encoding' => [ + 'guess' + ], + 'delete-block-comments' => [ 0, 1 ], - 'blank-lines-before-packages' => [ - 0, - 1 - ], - 'recombine' => [ - 0, - 1 - ], - 'blank-lines-after-opening-block-list' => [ - '*' - ], - 'stack-opening-square-bracket' => [ + 'indent-columns' => [ + 0, + 2, + 4 + ], + 'nowant-right-space' => [ + '+ -', + '+ - / *', + '++ --', + '..', + '= + - / *', + 'A' + ], + 'break-at-old-semicolon-breakpoints' => [ + 0, + 1 + ], + 'variable-maximum-line-length' => [ 0, 1 ], + 'break-before-all-operators' => [ + 0, + 1 + ], 'cuddled-block-list' => [ 'map,sort,grep', 'sort,map,grep' ], - 'space-backslash-quote' => [ - 0, - 1, - 2 - ], - 'want-left-space' => [ - '+ -', - '= .= =~ !~ :' + 'closing-side-comments-balanced' => [ + 0, + 1 + ], + 'opening-hash-brace-right' => [ + 0, + 1 + ], + 'paren-tightness' => [ + 0, + 1, + 2 ], - 'format' => [ - 'html', - 'tidy' - ], 'fuzzy-line-length' => [ 0, 1 ], - 'block-brace-tightness' => [ + 'delete-side-comments' => [ + 0, + 1 + ], + 'brace-vertical-tightness-closing' => [ + 0, + 2 + ], + 'indent-block-comments' => [ + 0, + 1 + ], + 'space-backslash-quote' => [ 0, 1, 2 ], - 'warning-output' => [ - 0, - 1 - ], - 'stack-closing-square-bracket' => [ - 0, - 1 - ], - 'opening-hash-brace-right' => [ - 0, - 1 - ], - 'block-brace-vertical-tightness' => [ - 0, - 1 + 'closing-side-comments' => [ + 0, + 1 + ], + 'closing-side-comment-else-flag' => [ + 0 ], - 'minimum-space-to-comment' => [ - 10, - 2, - 4 - ], - 'opening-brace-always-on-right' => [ - 0, - 1 - ], - 'break-at-old-semicolon-breakpoints' => [ - 0, - 1 - ], 'blanks-before-comments' => [ 0, 1 ], + 'entab-leading-whitespace' => [ + 8 + ], + 'hanging-side-comments' => [ + 0, + 1 + ], 'delete-old-whitespace' => [ 0, 1 ], - 'closing-side-comment-interval' => [ - 2, - 20, - 6 + 'keyword-group-blanks-size' => [ + '5' + ], + 'one-line-block-semicolons' => [ + 0, + 1, + 2 + ], + 'break-at-old-comma-breakpoints' => [ + 0, + 1 + ], + 'default-tabsize' => [ + 8 + ], + 'comma-arrow-breakpoints' => [ + 1, + 5 + ], + 'square-bracket-vertical-tightness' => [ + 0, + 1, + 2 + ], + 'opening-sub-brace-on-new-line' => [ + 0, + 1 ], - 'tight-secret-operators' => [ - 0, - 1 - ], - 'brace-vertical-tightness' => [ + 'want-left-space' => [ + '+ -', + '= .= =~ !~ :' + ], + 'blank-lines-before-closing-block' => [ + 1 + ], + 'stack-opening-hash-brace' => [ 0, - 1, - 2 + 1 ], - 'space-keyword-paren' => [ + 'blank-lines-before-packages' => [ + 0, + 1 + ], + 'perl-syntax-check-flags' => [ + '-c -T' + ], + 'keep-interior-semicolons' => [ + 0, + 1 + ], + 'keyword-group-blanks-inside' => [ + 0, + 1 + ], + 'opening-paren-right' => [ 0, 1 ], - 'variable-maximum-line-length' => [ + 'closing-brace-indentation' => [ + 0, + 1, + 2 + ], + 'blank-lines-before-closing-block-list' => [ + '*' + ], + 'blank-lines-after-opening-block-list' => [ + '*' + ], + 'delete-closing-side-comments' => [ 0, 1 ], - 'short-concatenation-item-length' => [ - 12, - 8 + 'blank-lines-after-opening-block' => [ + 2 ], - 'delete-block-comments' => [ - 0, - 1 - ], - 'opening-brace-on-new-line' => [ - 0, - 1 - ], - 'sub-alias-list' => [ - 'method fun' - ], - 'brace-tightness' => [ - 0, - 1, - 2 - ], - 'line-up-parentheses' => [ - 0, - 1 - ], - 'format-skipping-begin' => [ - '#<{2,}' - ], - 'stack-closing-paren' => [ + 'keyword-group-blanks-before' => [ + 1, + 2 + ], + 'space-keyword-paren' => [ 0, 1 - ], - 'static-side-comments' => [ - 0, - 1 - ] + ] }; diff --git a/t/snippets/expect/almost3.def b/t/snippets/expect/almost3.def index 25e95218..c68b6df8 100644 --- a/t/snippets/expect/almost3.def +++ b/t/snippets/expect/almost3.def @@ -1,6 +1,6 @@ # not a good alignment sub head { match_on_type @_ => Null => sub { die "Cannot get head of Null" }, - ArrayRef => sub { $_->[0] }; + ArrayRef => sub { $_->[0] }; } diff --git a/t/snippets/expect/git25.def b/t/snippets/expect/git25.def new file mode 100644 index 00000000..2ffb09c0 --- /dev/null +++ b/t/snippets/expect/git25.def @@ -0,0 +1,45 @@ +# example for git #25; use -l=0; was losing alignment; sub 'fix_ragged_lists' was added to fix this +my $mapping = [ + + # ... + { 'is_col' => 'dsstdat', 'cr_col' => 'enroll_isaric_date', 'trans' => 0, }, + { 'is_col' => 'corona_ieorres', 'cr_col' => '', 'trans' => 0, }, + { + 'is_col' => 'symptoms_fever', + 'cr_col' => 'elig_fever', + 'trans' => 1, + 'manually_reviewed' => '@TODO', + 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, + }, + { + 'is_col' => 'symptoms_cough', + 'cr_col' => 'elig_cough', + 'trans' => 1, + 'manually_reviewed' => '@TODO', + 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, + }, + { + 'is_col' => 'symptoms_dys_tachy_noea', + 'cr_col' => 'elig_dyspnea', + 'trans' => 1, + 'manually_reviewed' => '@TODO', + 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, + }, + { + 'is_col' => 'symptoms_clinical_susp', + 'cr_col' => 'elig_ari', + 'trans' => 0, + }, + { + 'is_col' => 'sex', + 'cr_col' => 'sex', + 'trans' => 1, + 'manually_reviewed' => 1, + 'map' => { '0' => '1', '1' => '2' }, + }, + { 'is_col' => 'age', 'cr_col' => '', 'trans' => 0, }, + { 'is_col' => 'ageu', 'cr_col' => '', 'trans' => 0, }, + + # ... +]; + diff --git a/t/snippets/expect/git25.git25 b/t/snippets/expect/git25.git25 new file mode 100644 index 00000000..ccecaef9 --- /dev/null +++ b/t/snippets/expect/git25.git25 @@ -0,0 +1,17 @@ +# example for git #25; use -l=0; was losing alignment; sub 'fix_ragged_lists' was added to fix this +my $mapping = [ + + # ... + { 'is_col' => 'dsstdat', 'cr_col' => 'enroll_isaric_date', 'trans' => 0, }, + { 'is_col' => 'corona_ieorres', 'cr_col' => '', 'trans' => 0, }, + { 'is_col' => 'symptoms_fever', 'cr_col' => 'elig_fever', 'trans' => 1, 'manually_reviewed' => '@TODO', 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, }, + { 'is_col' => 'symptoms_cough', 'cr_col' => 'elig_cough', 'trans' => 1, 'manually_reviewed' => '@TODO', 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, }, + { 'is_col' => 'symptoms_dys_tachy_noea', 'cr_col' => 'elig_dyspnea', 'trans' => 1, 'manually_reviewed' => '@TODO', 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, }, + { 'is_col' => 'symptoms_clinical_susp', 'cr_col' => 'elig_ari', 'trans' => 0, }, + { 'is_col' => 'sex', 'cr_col' => 'sex', 'trans' => 1, 'manually_reviewed' => 1, 'map' => { '0' => '1', '1' => '2' }, }, + { 'is_col' => 'age', 'cr_col' => '', 'trans' => 0, }, + { 'is_col' => 'ageu', 'cr_col' => '', 'trans' => 0, }, + + # ... +]; + diff --git a/t/snippets/expect/smart.def b/t/snippets/expect/smart.def index d0278562..54e5d307 100644 --- a/t/snippets/expect/smart.def +++ b/t/snippets/expect/smart.def @@ -1,31 +1,31 @@ \&foo !~~ \&foo; -\&foo ~~ \&foo; -\&foo ~~ \&foo; -\&foo ~~ sub { }; -sub { } ~~ \&foo; -\&foo ~~ \&bar; -\&bar ~~ \&foo; -1 ~~ sub { shift }; -sub { shift } ~~ 1; -0 ~~ sub { shift }; -sub { shift } ~~ 0; -1 ~~ sub { scalar @_ }; +\&foo ~~ \&foo; +\&foo ~~ \&foo; +\&foo ~~ sub { }; +sub { } ~~ \&foo; +\&foo ~~ \&bar; +\&bar ~~ \&foo; +1 ~~ sub { shift }; +sub { shift } ~~ 1; +0 ~~ sub { shift }; +sub { shift } ~~ 0; +1 ~~ sub { scalar @_ }; sub { scalar @_ } ~~ 1; -[] ~~ \&bar; -\&bar ~~ []; -{} ~~ \&bar; -\&bar ~~ {}; -qr// ~~ \&bar; -\&bar ~~ qr//; -a_const ~~ "a constant"; -"a constant" ~~ a_const; -a_const ~~ a_const; -a_const ~~ a_const; -a_const ~~ b_const; -b_const ~~ a_const; -{} ~~ {}; -{} ~~ {}; -{} ~~ { 1 => 2 }; +[] ~~ \&bar; +\&bar ~~ []; +{} ~~ \&bar; +\&bar ~~ {}; +qr// ~~ \&bar; +\&bar ~~ qr//; +a_const ~~ "a constant"; +"a constant" ~~ a_const; +a_const ~~ a_const; +a_const ~~ a_const; +a_const ~~ b_const; +b_const ~~ a_const; +{} ~~ {}; +{} ~~ {}; +{} ~~ { 1 => 2 }; { 1 => 2 } ~~ {}; { 1 => 2 } ~~ { 1 => 2 }; { 1 => 2 } ~~ { 1 => 2 }; diff --git a/t/snippets/git25.in b/t/snippets/git25.in new file mode 100644 index 00000000..233d2aba --- /dev/null +++ b/t/snippets/git25.in @@ -0,0 +1,15 @@ +# example for git #25; use -l=0; was losing alignment; sub 'fix_ragged_lists' was added to fix this +my $mapping = [ +# ... + { 'is_col' => 'dsstdat', 'cr_col' => 'enroll_isaric_date', 'trans' => 0, }, + { 'is_col' => 'corona_ieorres', 'cr_col' => '', 'trans' => 0, }, + { 'is_col' => 'symptoms_fever', 'cr_col' => 'elig_fever', 'trans' => 1, 'manually_reviewed' => '@TODO', 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, }, + { 'is_col' => 'symptoms_cough', 'cr_col' => 'elig_cough', 'trans' => 1, 'manually_reviewed' => '@TODO', 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, }, + { 'is_col' => 'symptoms_dys_tachy_noea', 'cr_col' => 'elig_dyspnea', 'trans' => 1, 'manually_reviewed' => '@TODO', 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, }, + { 'is_col' => 'symptoms_clinical_susp', 'cr_col' => 'elig_ari', 'trans' => 0, }, + { 'is_col' => 'sex', 'cr_col' => 'sex', 'trans' => 1, 'manually_reviewed' => 1, 'map' => { '0' => '1', '1' => '2' }, }, + { 'is_col' => 'age', 'cr_col' => '', 'trans' => 0, }, + { 'is_col' => 'ageu', 'cr_col' => '', 'trans' => 0, }, +# ... +]; + diff --git a/t/snippets/git25.par b/t/snippets/git25.par new file mode 100644 index 00000000..7e615cc5 --- /dev/null +++ b/t/snippets/git25.par @@ -0,0 +1 @@ +-l=0 diff --git a/t/snippets/packing_list.txt b/t/snippets/packing_list.txt index 3e63a2d9..0aa1dd11 100644 --- a/t/snippets/packing_list.txt +++ b/t/snippets/packing_list.txt @@ -240,6 +240,8 @@ ../snippets20.t wc.wc2 ../snippets20.t ce2.ce ../snippets20.t ce2.def +../snippets20.t gnu6.def +../snippets20.t gnu6.gnu ../snippets3.t ce_wn1.ce_wn ../snippets3.t ce_wn1.def ../snippets3.t colin.colin @@ -380,5 +382,5 @@ ../snippets9.t rt98902.def ../snippets9.t rt98902.rt98902 ../snippets9.t rt99961.def -../snippets20.t gnu6.def -../snippets20.t gnu6.gnu +../snippets20.t git25.def +../snippets20.t git25.git25 diff --git a/t/snippets10.t b/t/snippets10.t index 231cbcc9..762ce753 100644 --- a/t/snippets10.t +++ b/t/snippets10.t @@ -494,33 +494,33 @@ foreach ( split( //, $input ) ) { } params => "def", expect => <<'#8...........', \&foo !~~ \&foo; -\&foo ~~ \&foo; -\&foo ~~ \&foo; -\&foo ~~ sub { }; -sub { } ~~ \&foo; -\&foo ~~ \&bar; -\&bar ~~ \&foo; -1 ~~ sub { shift }; -sub { shift } ~~ 1; -0 ~~ sub { shift }; -sub { shift } ~~ 0; -1 ~~ sub { scalar @_ }; +\&foo ~~ \&foo; +\&foo ~~ \&foo; +\&foo ~~ sub { }; +sub { } ~~ \&foo; +\&foo ~~ \&bar; +\&bar ~~ \&foo; +1 ~~ sub { shift }; +sub { shift } ~~ 1; +0 ~~ sub { shift }; +sub { shift } ~~ 0; +1 ~~ sub { scalar @_ }; sub { scalar @_ } ~~ 1; -[] ~~ \&bar; -\&bar ~~ []; -{} ~~ \&bar; -\&bar ~~ {}; -qr// ~~ \&bar; -\&bar ~~ qr//; -a_const ~~ "a constant"; -"a constant" ~~ a_const; -a_const ~~ a_const; -a_const ~~ a_const; -a_const ~~ b_const; -b_const ~~ a_const; -{} ~~ {}; -{} ~~ {}; -{} ~~ { 1 => 2 }; +[] ~~ \&bar; +\&bar ~~ []; +{} ~~ \&bar; +\&bar ~~ {}; +qr// ~~ \&bar; +\&bar ~~ qr//; +a_const ~~ "a constant"; +"a constant" ~~ a_const; +a_const ~~ a_const; +a_const ~~ a_const; +a_const ~~ b_const; +b_const ~~ a_const; +{} ~~ {}; +{} ~~ {}; +{} ~~ { 1 => 2 }; { 1 => 2 } ~~ {}; { 1 => 2 } ~~ { 1 => 2 }; { 1 => 2 } ~~ { 1 => 2 }; diff --git a/t/snippets16.t b/t/snippets16.t index 768304f9..a11bdf4c 100644 --- a/t/snippets16.t +++ b/t/snippets16.t @@ -298,7 +298,7 @@ my $incname = $indname . ( $indtot > 1 ? $indno : "" ); # not a good alignment sub head { match_on_type @_ => Null => sub { die "Cannot get head of Null" }, - ArrayRef => sub { $_->[0] }; + ArrayRef => sub { $_->[0] }; } #10........... diff --git a/t/snippets20.t b/t/snippets20.t index 4be39332..eaa747a2 100644 --- a/t/snippets20.t +++ b/t/snippets20.t @@ -11,6 +11,8 @@ #8 ce2.def #9 gnu6.def #10 gnu6.gnu +#11 git25.def +#12 git25.git25 # To locate test #13 you can search for its name or the string '#13' @@ -30,6 +32,7 @@ BEGIN { $rparams = { 'ce' => "-cuddled-blocks", 'def' => "", + 'git25' => "-l=0", 'gnu' => "-gnu", 'space6' => <<'----------', -nwrs="+ - / *" @@ -65,6 +68,24 @@ else { # Is Perl being run from a slave editor or graphical debugger? ... } +---------- + + 'git25' => <<'----------', +# example for git #25; use -l=0; was losing alignment; sub 'fix_ragged_lists' was added to fix this +my $mapping = [ +# ... + { 'is_col' => 'dsstdat', 'cr_col' => 'enroll_isaric_date', 'trans' => 0, }, + { 'is_col' => 'corona_ieorres', 'cr_col' => '', 'trans' => 0, }, + { 'is_col' => 'symptoms_fever', 'cr_col' => 'elig_fever', 'trans' => 1, 'manually_reviewed' => '@TODO', 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, }, + { 'is_col' => 'symptoms_cough', 'cr_col' => 'elig_cough', 'trans' => 1, 'manually_reviewed' => '@TODO', 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, }, + { 'is_col' => 'symptoms_dys_tachy_noea', 'cr_col' => 'elig_dyspnea', 'trans' => 1, 'manually_reviewed' => '@TODO', 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, }, + { 'is_col' => 'symptoms_clinical_susp', 'cr_col' => 'elig_ari', 'trans' => 0, }, + { 'is_col' => 'sex', 'cr_col' => 'sex', 'trans' => 1, 'manually_reviewed' => 1, 'map' => { '0' => '1', '1' => '2' }, }, + { 'is_col' => 'age', 'cr_col' => '', 'trans' => 0, }, + { 'is_col' => 'ageu', 'cr_col' => '', 'trans' => 0, }, +# ... +]; + ---------- 'gnu6' => <<'----------', @@ -335,6 +356,82 @@ else { #10........... }, + + 'git25.def' => { + source => "git25", + params => "def", + expect => <<'#11...........', +# example for git #25; use -l=0; was losing alignment; sub 'fix_ragged_lists' was added to fix this +my $mapping = [ + + # ... + { 'is_col' => 'dsstdat', 'cr_col' => 'enroll_isaric_date', 'trans' => 0, }, + { 'is_col' => 'corona_ieorres', 'cr_col' => '', 'trans' => 0, }, + { + 'is_col' => 'symptoms_fever', + 'cr_col' => 'elig_fever', + 'trans' => 1, + 'manually_reviewed' => '@TODO', + 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, + }, + { + 'is_col' => 'symptoms_cough', + 'cr_col' => 'elig_cough', + 'trans' => 1, + 'manually_reviewed' => '@TODO', + 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, + }, + { + 'is_col' => 'symptoms_dys_tachy_noea', + 'cr_col' => 'elig_dyspnea', + 'trans' => 1, + 'manually_reviewed' => '@TODO', + 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, + }, + { + 'is_col' => 'symptoms_clinical_susp', + 'cr_col' => 'elig_ari', + 'trans' => 0, + }, + { + 'is_col' => 'sex', + 'cr_col' => 'sex', + 'trans' => 1, + 'manually_reviewed' => 1, + 'map' => { '0' => '1', '1' => '2' }, + }, + { 'is_col' => 'age', 'cr_col' => '', 'trans' => 0, }, + { 'is_col' => 'ageu', 'cr_col' => '', 'trans' => 0, }, + + # ... +]; + +#11........... + }, + + 'git25.git25' => { + source => "git25", + params => "git25", + expect => <<'#12...........', +# example for git #25; use -l=0; was losing alignment; sub 'fix_ragged_lists' was added to fix this +my $mapping = [ + + # ... + { 'is_col' => 'dsstdat', 'cr_col' => 'enroll_isaric_date', 'trans' => 0, }, + { 'is_col' => 'corona_ieorres', 'cr_col' => '', 'trans' => 0, }, + { 'is_col' => 'symptoms_fever', 'cr_col' => 'elig_fever', 'trans' => 1, 'manually_reviewed' => '@TODO', 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, }, + { 'is_col' => 'symptoms_cough', 'cr_col' => 'elig_cough', 'trans' => 1, 'manually_reviewed' => '@TODO', 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, }, + { 'is_col' => 'symptoms_dys_tachy_noea', 'cr_col' => 'elig_dyspnea', 'trans' => 1, 'manually_reviewed' => '@TODO', 'map' => { '0' => '0', '1' => '1', '9' => '@TODO' }, }, + { 'is_col' => 'symptoms_clinical_susp', 'cr_col' => 'elig_ari', 'trans' => 0, }, + { 'is_col' => 'sex', 'cr_col' => 'sex', 'trans' => 1, 'manually_reviewed' => 1, 'map' => { '0' => '1', '1' => '2' }, }, + { 'is_col' => 'age', 'cr_col' => '', 'trans' => 0, }, + { 'is_col' => 'ageu', 'cr_col' => '', 'trans' => 0, }, + + # ... +]; + +#12........... + }, }; my $ntests = 0 + keys %{$rtests};