]> git.donarmstrong.com Git - perltidy.git/commitdiff
activated 'filter_example.t' (caused install problems at one time)
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 6 May 2020 14:07:08 +0000 (07:07 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 6 May 2020 14:07:08 +0000 (07:07 -0700)
t/filter_example.t [new file with mode: 0755]
t/filter_example.t.SKIP [deleted file]

diff --git a/t/filter_example.t b/t/filter_example.t
new file mode 100755 (executable)
index 0000000..825c2c1
--- /dev/null
@@ -0,0 +1,70 @@
+# Test use of prefilter and postfilter parameters
+use strict;
+use Carp;
+use Perl::Tidy;
+use Test::More;
+my $name = 'filter_example';
+
+BEGIN {
+    plan tests => 1;
+}
+
+my $source = <<'ENDS';
+use Method::Signatures::Simple;
+
+ method foo1 { $self->bar }
+
+       # with signature
+    method foo2($bar, %opts) { $self->bar(reverse $bar) if $opts{rev};
+    }
+
+    # attributes
+    method foo3 : lvalue { $self->{foo} 
+}
+
+ # change invocant name
+    method 
+foo4 ($class: $bar) { $class->bar($bar) }
+ENDS
+
+my $expect = <<'ENDE';
+use Method::Signatures::Simple;
+method foo1 { $self->bar }
+
+# with signature
+method foo2 ( $bar, %opts ) {
+    $self->bar( reverse $bar ) if $opts{rev};
+}
+
+# attributes
+method foo3 : lvalue {
+    $self->{foo};
+}
+
+# change invocant name
+method foo4 ($class: $bar) { $class->bar($bar) }
+ENDE
+
+my $output;
+my $stderr_string;
+my $errorfile_string;
+my $params = "";
+my $err    = Perl::Tidy::perltidy(
+
+    #argv => '-npro',  # fix for RT#127679, avoid reading unwanted .perltidyrc
+    argv       => '',
+    perltidyrc => \$params,    # avoid reading unwanted .perltidyrc
+    prefilter =>
+      sub { $_ = $_[0]; s/^\s*method\s+(\w.*)/sub METHOD_$1/gm; return $_ },
+    postfilter  => sub { $_ = $_[0]; s/sub\s+METHOD_/method /gm; return $_ },
+    source      => \$source,
+    destination => \$output,
+    stderr      => \$stderr_string,
+    errorfile => \$errorfile_string,    # not used when -se flag is set
+);
+if ( $err || $stderr_string || $errorfile_string ) {
+    ok(0);
+}
+else {
+    is( $output, $expect, $name );
+}
diff --git a/t/filter_example.t.SKIP b/t/filter_example.t.SKIP
deleted file mode 100755 (executable)
index d6b6394..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-# Test use of prefilter and postfilter parameters 
-use strict;
-use Carp;
-use Perl::Tidy;
-use Test;
-
-BEGIN {
-    plan tests => 1;
-}
-
-my $source = <<'ENDS';
-use Method::Signatures::Simple;
-
- method foo1 { $self->bar }
-
-       # with signature
-    method foo2($bar, %opts) { $self->bar(reverse $bar) if $opts{rev};
-    }
-
-    # attributes
-    method foo3 : lvalue { $self->{foo} 
-}
-
- # change invocant name
-    method 
-foo4 ($class: $bar) { $class->bar($bar) }
-ENDS
-
-my $expect = <<'ENDE';
-use Method::Signatures::Simple;
-method foo1 { $self->bar }
-
-# with signature
-method foo2 ( $bar, %opts ) {
-    $self->bar( reverse $bar ) if $opts{rev};
-}
-
-# attributes
-method foo3 : lvalue {
-    $self->{foo};
-}
-
-# change invocant name
-method foo4 ($class: $bar) { $class->bar($bar) }
-ENDE
-
-my $output;
-my $stderr_string;
-my $errorfile_string;
-my $err = Perl::Tidy::perltidy(
-    argv => '-npro',  # fix for RT#127679, avoid reading unwanted .perltidyrc
-    prefilter =>
-      sub { $_ = $_[0]; s/^\s*method\s+(\w.*)/sub METHOD_$1/gm; return $_ },
-    postfilter  => sub { $_ = $_[0]; s/sub\s+METHOD_/method /gm; return $_ },
-    source      => \$source,
-    destination => \$output,
-    stderr    => \$stderr_string,
-    errorfile => \$errorfile_string,   # not used when -se flag is set
-);
-if ( $err || $stderr_string || $errorfile_string ) {
-    ok(0);
-}
-else {
-    ok( $output, $expect );
-}