2 # Copyright (C) 2007, Parrot Foundation.
9 use Test::More tests => 9;
11 use File::Temp qw| tempfile |;
13 use Parrot::BuildUtil;
16 my ( $fh, $tempfile ) = tempfile( UNLINK => 1 );
17 open $fh, ">", $tempfile
18 or croak "Unable to open tempfile for writing";
19 print $fh "Testing Parrot::BuildUtil::slurp_file()\n";
20 close $fh or croak "Unable to close tempfile after writing";
22 ok( -f $tempfile, "tempfile created for testing" );
23 my $str = Parrot::BuildUtil::slurp_file($tempfile);
24 ok( $str, "slurpfile() returned true value" );
27 qr/Testing Parrot::BuildUtil::slurp_file/,
28 "Main content of tempfile correctly slurped"
33 my ( $fh, $tempfile ) = tempfile( UNLINK => 1 );
34 open $fh, ">", $tempfile
35 or croak "Unable to open tempfile for writing";
36 print $fh "Testing Parrot::BuildUtil::slurp_file()\cM\cJ\n";
37 close $fh or croak "Unable to close tempfile after writing";
39 ok( -f $tempfile, "tempfile created for testing" );
40 my $str = Parrot::BuildUtil::slurp_file($tempfile);
41 ok( $str, "slurpfile() returned true value" );
44 qr/Testing Parrot::BuildUtil::slurp_file/,
45 "Main content of tempfile correctly slurped"
47 like( $str, qr/\n{2}/m, "DOS line endings correctly converted during slurp_file" );
53 eval { $str = Parrot::BuildUtil::slurp_file($phony); };
57 "Got error message expected upon attempting to slurp non-existent file"
61 pass("Completed all tests in $0");
63 ################### DOCUMENTATION ###################
67 044-slurp_file.t - test C<Parrot::BuildUtil::slurp_file()>
71 % prove t/configure/044-slurp_file.t
75 The files in this directory test functionality used by F<Configure.pl>.
77 The tests in this file test C<Parrot::BuildUtil::slurp_file()>.
85 Parrot::BuildUtil, F<Configure.pl>.
91 # cperl-indent-level: 4
94 # vim: expandtab shiftwidth=4: