From bf452677a355ca7dcb894f0434aa51b3b8ae7112 Mon Sep 17 00:00:00 2001 From: Peter Oliver Date: Mon, 30 Sep 2024 14:59:51 +0100 Subject: [PATCH] Add TODO test for detecting tied packages Currently, a package is believed to be unused if it is only used in a `tie` statement. --- t/tie.t | 21 +++++++++++++++++++++ test-data/tie.pl | 6 ++++++ 2 files changed, 27 insertions(+) create mode 100644 t/tie.t create mode 100644 test-data/tie.pl diff --git a/t/tie.t b/t/tie.t new file mode 100644 index 0000000..6c8abd3 --- /dev/null +++ b/t/tie.t @@ -0,0 +1,21 @@ +use strict; +use warnings; + +use lib 't/lib'; + +use Path::Tiny qw( path ); +use TestHelper qw( doc ); +use Test::More import => [qw( done_testing is $TODO )]; + +my $filename = 'test-data/tie.pl'; +my ($doc) = doc( + filename => $filename, + preserve_unused => 0, +); + +TODO: { + local $TODO = 'Cannot yet see packages used by tie'; + is( $doc->tidied_document, path($filename)->slurp, 'tie observed' ); +} + +done_testing(); diff --git a/test-data/tie.pl b/test-data/tie.pl new file mode 100644 index 0000000..0f798bd --- /dev/null +++ b/test-data/tie.pl @@ -0,0 +1,6 @@ +use strict; +use warnings; + +use Tie::SubstrHash (); + +tie my %hash, 'Tie::SubstrHash', 1, 1, 1;