summaryrefslogtreecommitdiff
path: root/t/basename.t
diff options
context:
space:
mode:
Diffstat (limited to 't/basename.t')
-rw-r--r--t/basename.t39
1 files changed, 39 insertions, 0 deletions
diff --git a/t/basename.t b/t/basename.t
new file mode 100644
index 0000000..58a0bda
--- /dev/null
+++ b/t/basename.t
@@ -0,0 +1,39 @@
+use 5.008001;
+use strict;
+use warnings;
+use Test::More 0.96;
+
+use lib 't/lib';
+use TestUtils qw/exception/;
+
+use Path::Tiny;
+use Cwd;
+
+my $IS_WIN32 = $^O eq 'MSWin32';
+
+my @cases = (
+ [ 'foo.txt', [ '.txt', '.png' ], 'foo' ],
+ [ 'foo.png', [ '.txt', '.png' ], 'foo' ],
+ [ 'foo.txt', [ qr/\.txt/, qr/\.png/ ], 'foo' ],
+ [ 'foo.png', [ qr/\.txt/, qr/\.png/ ], 'foo' ],
+ [ 'foo.txt', ['.jpeg'], 'foo.txt' ],
+ [ 'foo/.txt/bar.txt', [ qr/\.txt/, qr/\.png/ ], 'bar' ],
+);
+
+for my $c (@cases) {
+ my ( $input, $args, $result ) = @$c;
+ my $path = path($input);
+ my $base = $path->basename(@$args);
+ is( $base, $result, "$path -> $result" );
+}
+
+done_testing;
+#
+# This file is part of Path-Tiny
+#
+# This software is Copyright (c) 2014 by David Golden.
+#
+# This is free software, licensed under:
+#
+# The Apache License, Version 2.0, January 2004
+#