HEX
Server: Apache
System: Linux vps-15179318.kohladvogados.com.br 5.14.0-611.49.2.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Apr 30 09:05:08 EDT 2026 x86_64
User: kohlsol (1004)
PHP: 8.3.32
Disabled: NONE
Upload Files
File: /home/.cpan/build/Path-Tiny-0.150-0/t/children.t
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';

my $raw_tilde = path(".", "~");
my $tilde_child = $raw_tilde->child("rhubarb");
is( $tilde_child, "./~/rhubarb", "child of literal tilde" );

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
#