Andy moved slurp_file() into Parrot::BuildUtil last month.  So I don't
think we need to start a separate module called Parrot::Util -- at least
not yet.

I'm adding one file, t/configure/039-slurp_file.t, to provide unit tests
for Parrot::BuildUtil::slurp_file().  I also spruced up the POD in
BuildUtil.pm a bit.

With this, I think this ticket can be resolved for the time being.  We
can create new tickets for any other issues that have been discussed in
this thread.

kid51
Index: MANIFEST
===================================================================
--- MANIFEST    (revision 21148)
+++ MANIFEST    (working copy)
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Fri Sep  7 23:13:02 2007 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Sun Sep  9 01:46:53 2007 UT
 #
 # See tools/dev/install_files.pl for documentation on the
 # format of this file.
@@ -2916,6 +2916,7 @@
 t/configure/036_config_steps.t                              []
 t/configure/037-run_single_step.t                           []
 t/configure/038-run_single_step.t                           []
+t/configure/039-slurp_file.t                                []
 t/configure/101-init_manifest.01.t                          []
 t/configure/101-init_manifest.02.t                          []
 t/configure/102-init_defaults.01.t                          []
Index: lib/Parrot/BuildUtil.pm
===================================================================
--- lib/Parrot/BuildUtil.pm     (revision 21148)
+++ lib/Parrot/BuildUtil.pm     (working copy)
@@ -7,9 +7,9 @@
 
 =head1 DESCRIPTION
 
-For now, this package contains only one subroutine:  C<parrot_version()>.
-This subroutine is not exported and so must be requested with a fully
-qualified path.
+This package holds two subroutines:  C<parrot_version()> and
+<slurp_file>.  Neither subroutine is exported and so each must be
+requested with a fully qualified path.
 
 =cut
 
@@ -69,7 +69,8 @@
 
 =item C<slurp_file($filename)>
 
-Slurps up the filename and returns the content as one string.
+Slurps up the filename and returns the content as one string.  While
+doing so, it converts all DOS-style line endings to newlines.
 
 =cut
 
Index: t/configure/039-slurp_file.t
===================================================================
--- t/configure/039-slurp_file.t        (revision 0)
+++ t/configure/039-slurp_file.t        (revision 0)
@@ -0,0 +1,90 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 039-slurp_file.t
+
+use strict;
+use warnings;
+
+use Test::More tests => 10;
+use Carp;
+use_ok( 'File::Temp', qw| tempfile | );
+use lib qw( lib );
+use Parrot::BuildUtil;
+
+{
+    my ($fh, $tempfile) = tempfile();
+    open $fh, ">", $tempfile
+        or croak "Unable to open tempfile for writing";
+    print $fh "Testing Parrot::BuildUtil::slurp_file()\n";
+    close $fh or croak "Unable to close tempfile after writing";
+
+    ok(-f $tempfile, "tempfile created for testing");
+    my $str = Parrot::BuildUtil::slurp_file($tempfile);
+    ok($str, "slurpfile() returned true value");
+    like($str, qr/Testing Parrot::BuildUtil::slurp_file/,
+        "Main content of tempfile correctly slurped");
+}
+
+{
+    my ($fh, $tempfile) = tempfile();
+    open $fh, ">", $tempfile
+        or croak "Unable to open tempfile for writing";
+    print $fh "Testing Parrot::BuildUtil::slurp_file()\cM\cJ\n";
+    close $fh or croak "Unable to close tempfile after writing";
+
+    ok(-f $tempfile, "tempfile created for testing");
+    my $str = Parrot::BuildUtil::slurp_file($tempfile);
+    ok($str, "slurpfile() returned true value");
+    like($str, qr/Testing Parrot::BuildUtil::slurp_file/,
+        "Main content of tempfile correctly slurped");
+    like($str, qr/\n{2}/m,
+        "DOS line endings correctly converted during slurp_file");
+}
+
+
+
+{
+    my $phony = q{foobar};
+    my $str;
+    eval { $str = Parrot::BuildUtil::slurp_file($phony); };
+    like($@, qr/open '$phony'/,
+        "Got error message expected upon attempting to slurp non-existent 
file");
+}
+
+
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+039-slurp_file.t - test C<Parrot::BuildUtil::slurp_file()>
+
+=head1 SYNOPSIS
+
+    % prove t/configure/039-slurp_file.t
+
+=head1 DESCRIPTION
+
+The files in this directory test functionality used by F<Configure.pl>.
+
+The tests in this file test C<Parrot::BuildUtil::slurp_file()>.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+Parrot::BuildUtil, F<Configure.pl>.
+
+=cut
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
+

Property changes on: t/configure/039-slurp_file.t
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Reply via email to