diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-06-28 17:50:34 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-06-28 17:50:34 +0000 |
commit | b7fb38421c30b0419a30311c1bde34706aa60fb8 (patch) | |
tree | 57f2bcea8db83589377c8bc0253a10c66df46d72 /t/children.t | |
download | Path-Tiny-tarball-master.tar.gz |
Path-Tiny-0.070HEADPath-Tiny-0.070master
Diffstat (limited to 't/children.t')
-rw-r--r-- | t/children.t | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/t/children.t b/t/children.t new file mode 100644 index 0000000..4c0e266 --- /dev/null +++ b/t/children.t @@ -0,0 +1,51 @@ +use 5.008001; +use strict; +use warnings; +use Test::More 0.96; +use File::Basename (); +use File::Temp (); +use File::Spec::Unix; + +use lib 't/lib'; +use TestUtils qw/exception/; + +use Path::Tiny; + +my $tempdir = File::Temp->newdir; + +my @kids = qw/apple banana carrot/; +path($tempdir)->child($_)->touch for @kids; + +my @expected = map { path( File::Spec::Unix->catfile( $tempdir, $_ ) ) } @kids; + +is_deeply( + [ sort { $a cmp $b } path($tempdir)->children ], + [ sort @expected ], + "children correct" +); + +my $regexp = qr/.a/; +is_deeply( + [ sort { $a cmp $b } path($tempdir)->children($regexp) ], + [ + sort grep { my $child = File::Basename::basename($_); $child =~ /$regexp/ } + @expected + ], + "children correct with Regexp argument" +); + +my $arrayref = []; +eval { path($tempdir)->children($arrayref) }; +like $@, qr/Invalid argument '\Q$arrayref\E' for children()/, + 'children with invalid argument'; + +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 +# |