1. Shlomi Fish
  2. perl-Test-TrailingSpace

Commits

Shlomi Fish  committed 6c60962

Add a test.

  • Participants
  • Parent commits dbeedb2
  • Branches default

Comments (0)

Files changed (1)

File Test-TrailingSpace/t/object-test.t

View file
 
 use lib './t/lib';
 
-use Test::Builder::Tester tests => 6;
+use Test::Builder::Tester tests => 7;
 
 use File::Path qw( rmtree );
 
     test_test(title => "with trailing space was reported for abs_path_prune_re", skip_err => 1,);
     rmtree($t->get_path("./$test_dir"))
 }
+
+{
+    my $test_id = "no-trailing-space-with-unrecognized-filename";
+    my $test_dir = "t/sample-data/$test_id";
+    my $tree =
+    {
+        'name' => "$test_id/",
+        'subs' =>
+        [
+            {
+                'name' => "a/",
+                subs =>
+                [
+                    {
+                        'name' => "b.pm",
+                        'contents' => "This file was spotted in the wild.",
+                    },
+                ],
+            },
+
+            {
+                'name' => "foo/",
+                'subs' =>
+                [
+                    {
+                        'name' => "t.door.txt",
+                        'contents' => "A T Door",
+                    },
+                    {
+                        'name' => "yet/",
+                    },
+                ],
+            },
+            {
+                'name' => ".hg/",
+                subs =>
+                [
+                    {
+                        'name' => "foo.pm",
+                        'contents' => "File with trailing space     \nhello\n",
+                    }
+                ],
+            },
+            {
+                'name' => "eclim/",
+                subs =>
+                [
+                    {
+                        'name' => "MyFileWithSpace.tar.gz",
+                        'contents' => "Trailing space===    \nFoo\n",
+                    },
+                ],
+            },
+        ],
+    };
+
+    my $t = File::Find::Object::TreeCreate->new();
+    $t->create_tree("./t/sample-data/", $tree);
+
+    my $finder = Test::TrailingSpace->new(
+        {
+            root => "./$test_dir",
+            filename_regex => qr/\.(?:pm|txt)\z/,
+            abs_path_prune_re => qr#(?:\A|/)lib(?:/|\z)#ms,
+        }
+    );
+
+    test_out("ok 1 - trailing space.");
+    $finder->no_trailing_space("trailing space.");
+    test_test("no trailing space was with unrecognized filename.");
+    rmtree($t->get_path("./$test_dir"))
+}