2 # Copyright (C) 2001-2006, The Perl Foundation.
7 use lib qw( . lib ../lib ../../lib );
10 use Parrot::Test tests => 7;
16 use File::Spec::Functions;
18 my $tempdir = File::Temp::tempdir( CLEANUP => 1 );
20 our ( $MSWin32, $cygwin );
21 $MSWin32 = 1 if $^O =~ m!MSWin32!;
22 $cygwin = 1 if $^O =~ m!cygwin!;
26 t/pmc/file.t - Files functions
34 Tests the C<File> PMC.
38 my $xpto = catdir( $tempdir, 'xpto' );
39 mkdir $xpto unless -d $xpto;
41 my $otpx = catfile( $xpto, 'otpx' );
43 open my $fh, '>', $otpx or die $!;
48 pir_output_is( <<"CODE", <<"OUT", "Test is_dir" );
53 \$I1 = \$P1."is_dir"(\$S1)
62 \$I1 = \$P1."is_dir"(\$S1)
79 pir_output_is( <<"CODE", <<"OUT", "Test is_file" );
84 \$I1 = \$P1."is_file"(\$S1)
94 \$I1 = \$P1."is_file"(\$S1)
110 skip "Links not available under Windows", 1 if $MSWin32;
112 my $lotpx = catfile( $xpto, 'lotpx' );
113 symlink $otpx, $lotpx;
116 pir_output_is( <<"CODE", <<"OUT", "Test is_link with links to files" );
121 \$I1 = \$P1."is_link"(\$S1)
129 \$I1 = \$P1."is_link"(\$S1)
145 skip "Links not available under Windows", 1 if $MSWin32;
147 my $xptol = catdir( $xpto, 'xptol' );
148 symlink $xpto, $xptol;
151 pir_output_is( <<"CODE", <<"OUT", "Test is_link with links to directories" );
156 \$I1 = \$P1."is_link"(\$S1)
164 \$I1 = \$P1."is_link"(\$S1)
178 my $otpxcopy = catdir( $xpto, 'otpxcopy' );
181 pir_output_is( <<"CODE", <<"OUT", "Test copy for files" );
189 \$P1."copy"(\$S1,\$S2)
192 \$P3 = \$P2."stat"(\$S1)
193 \$P4 = \$P2."stat"(\$S2)
198 if \$I1 == \$I2 goto ok
212 skip 'file exists', 1 if $MSWin32;
214 pir_output_is( <<"CODE", <<"OUT", "Test rename for files" );
222 \$P3 = \$P2."stat"(\$S1)
225 \$P1."rename"(\$S1,\$S2)
228 \$P4 = \$P2."stat"(\$S2)
231 if \$I1 == \$I2 goto ok
244 my $bad_file = catfile( $xpto, 'not a file' );
247 pir_output_is( <<"CODE", <<"OUT", "Test rename for files" );
250 \$I1 = \$P1.'exists'( '$otpxcopy' )
252 if \$I1 goto file_exists
256 print "ok 1 - file exists\\n"
258 \$I1 = \$P1.'exists'( '$xpto' )
260 if \$I1 goto dir_exists
264 print "ok 2 - directory exists\\n"
266 \$I1 = \$P1.'exists'( '$bad_file' )
268 if \$I1 == 0 goto file_does_not_exist
272 print "ok 3 - file does not exist\\n"
278 ok 2 - directory exists
279 ok 3 - file does not exist
284 # cperl-indent-level: 4
287 # vim: expandtab shiftwidth=4: