From 842fdbac2f76af3ee4a4a4d053048ce9877b7bdf Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sun, 17 Jul 2022 07:02:10 -0700 Subject: [PATCH] add test for -D flag --- t/test_DEBUG.t | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 t/test_DEBUG.t diff --git a/t/test_DEBUG.t b/t/test_DEBUG.t new file mode 100755 index 00000000..0bf0be70 --- /dev/null +++ b/t/test_DEBUG.t @@ -0,0 +1,55 @@ +# Test that the -D (-DEBUG) flag works +use strict; +use Carp; +use Perl::Tidy; +use Test::More; +my $name = 'DEBUG test'; + +BEGIN { + plan tests => 2; +} + +my $source = <<'EOM'; +my @words = qw( +alpha beta gamma +); +EOM + +my $expect = <<'EOM'; +my @words = qw( + alpha beta gamma +); +EOM + +my $debug_expect = <<'EOM'; +Use -dump-token-types (-dtt) to get a list of token type codes +1: my @words = qw( +1: kkbiiiiiib=bqqq +2: alpha beta gamma +2: qqqqqqqqqqqqqqqq +3: ); +3: q; +EOM + +my $output; +my $stderr_string; +my $errorfile_string; +my $debug_string; +my $perltidyrc = ""; +my $err = Perl::Tidy::perltidy( + argv => '-D -npro', + perltidyrc => \$perltidyrc, # avoid reading unwanted .perltidyrc + source => \$source, + destination => \$output, + stderr => \$stderr_string, + errorfile => \$errorfile_string, # not used when -se flag is set + debugfile => \$debug_string, +); + +if ( $err || $stderr_string || $errorfile_string ) { + ok(0); +} +else { + is( $output, $expect, $name ); + is( $debug_string, $debug_expect, $name ); +} -- 2.39.5