r185 - in packages: . libperl6-slurp-perl libperl6-slurp-perl/branches libperl6-slurp-perl/branches/upstream libperl6-slurp-perl/branches/upstream/current libperl6-slurp-perl/branches/upstream/current/t

Allard Hoeve hoeve-guest@haydn.debian.org
Thu, 10 Jun 2004 09:36:55 -0600


Author: hoeve-guest
Date: 2004-06-10 09:36:52 -0600 (Thu, 10 Jun 2004)
New Revision: 185

Added:
   packages/libperl6-slurp-perl/
   packages/libperl6-slurp-perl/branches/
   packages/libperl6-slurp-perl/branches/upstream/
   packages/libperl6-slurp-perl/branches/upstream/current/
   packages/libperl6-slurp-perl/branches/upstream/current/Changes
   packages/libperl6-slurp-perl/branches/upstream/current/MANIFEST
   packages/libperl6-slurp-perl/branches/upstream/current/Makefile.PL
   packages/libperl6-slurp-perl/branches/upstream/current/README
   packages/libperl6-slurp-perl/branches/upstream/current/Slurp.pm
   packages/libperl6-slurp-perl/branches/upstream/current/t/
   packages/libperl6-slurp-perl/branches/upstream/current/t/chomp.t
   packages/libperl6-slurp-perl/branches/upstream/current/t/errors.t
   packages/libperl6-slurp-perl/branches/upstream/current/t/filehandle.t
   packages/libperl6-slurp-perl/branches/upstream/current/t/filename.t
   packages/libperl6-slurp-perl/branches/upstream/current/t/ioderfile.t
   packages/libperl6-slurp-perl/branches/upstream/current/t/iofile.t
   packages/libperl6-slurp-perl/branches/upstream/current/t/ipc.t
   packages/libperl6-slurp-perl/branches/upstream/current/t/irs.t
   packages/libperl6-slurp-perl/branches/upstream/current/t/layers.t
   packages/libperl6-slurp-perl/branches/upstream/current/t/lexfilehandle.t
   packages/libperl6-slurp-perl/branches/upstream/current/t/string.t
   packages/libperl6-slurp-perl/tags/
Log:
[svn-inject] Installing original source of libperl6-slurp-perl

Added: packages/libperl6-slurp-perl/branches/upstream/current/Changes
===================================================================
--- packages/libperl6-slurp-perl/branches/upstream/current/Changes	2004-06-10 15:35:50 UTC (rev 184)
+++ packages/libperl6-slurp-perl/branches/upstream/current/Changes	2004-06-10 15:36:52 UTC (rev 185)
@@ -0,0 +1,20 @@
+Revision history for Perl extension Perl6::Slurp.
+0.01  Wed Nov 26 21:58:48 2003
+	- original version; created by h2xs 1.22 with options
+		-A -P -X -f -n Perl6::Slurp
+
+
+
+0.02	Tue Mar  9 03:00:44 2004
+
+	- Cleaned up some redundant vestigal code (thanks Steffen)
+
+	- Updated internals to mirror interface changes in Perl6::Export
+
+
+
+0.03	Thu Mar 11 04:46:22 2004
+
+    - Updated Makefile.PL to note Perl6::Export 0.07 dependency
+
+	- Added correct behaviour when no source specified


Property changes on: packages/libperl6-slurp-perl/branches/upstream/current/Changes
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libperl6-slurp-perl/branches/upstream/current/MANIFEST
===================================================================
--- packages/libperl6-slurp-perl/branches/upstream/current/MANIFEST	2004-06-10 15:35:50 UTC (rev 184)
+++ packages/libperl6-slurp-perl/branches/upstream/current/MANIFEST	2004-06-10 15:36:52 UTC (rev 185)
@@ -0,0 +1,16 @@
+Changes
+Makefile.PL
+MANIFEST
+README
+Slurp.pm
+t/chomp.t
+t/errors.t
+t/filehandle.t
+t/filename.t
+t/ioderfile.t
+t/iofile.t
+t/ipc.t
+t/irs.t
+t/layers.t
+t/lexfilehandle.t
+t/string.t


Property changes on: packages/libperl6-slurp-perl/branches/upstream/current/MANIFEST
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libperl6-slurp-perl/branches/upstream/current/Makefile.PL
===================================================================
--- packages/libperl6-slurp-perl/branches/upstream/current/Makefile.PL	2004-06-10 15:35:50 UTC (rev 184)
+++ packages/libperl6-slurp-perl/branches/upstream/current/Makefile.PL	2004-06-10 15:36:52 UTC (rev 185)
@@ -0,0 +1,8 @@
+
+use ExtUtils::MakeMaker;
+WriteMakefile(
+		NAME	=> q[Perl6::Slurp],
+		VERSION => q[0.03],
+		PREREQ_PM => { Perl6::Export=>0.07 },
+
+	     );


Property changes on: packages/libperl6-slurp-perl/branches/upstream/current/Makefile.PL
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libperl6-slurp-perl/branches/upstream/current/README
===================================================================
--- packages/libperl6-slurp-perl/branches/upstream/current/README	2004-06-10 15:35:50 UTC (rev 184)
+++ packages/libperl6-slurp-perl/branches/upstream/current/README	2004-06-10 15:36:52 UTC (rev 185)
@@ -0,0 +1,51 @@
+==============================================================================
+                   Release of version 0.03 of Perl6::Slurp
+==============================================================================
+
+
+Perl6/Form version 0.01
+=======================
+
+Implements the Perl 6 'slurp' function (see Exegesis 7)
+
+=head1 WARNING
+
+The syntax and semantics of Perl 6 is still being finalized
+and consequently is at any time subject to change. That means the
+same caveat applies to this module.
+
+
+=head1 DEPENDENCIES
+
+Requires: Perl 5.8.0, Perl6::Export.
+
+
+=head1 AUTHOR
+
+Damian Conway (damian@conway.org)
+
+
+=head1 COPYRIGHT
+
+ Copyright (c) 2003, Damian Conway. All Rights Reserved.
+ This module is free software. It may be used, redistributed
+    and/or modified under the same terms as Perl itself.
+
+
+==============================================================================
+
+CHANGES IN VERSION 0.03
+
+
+    - Updated Makefile.PL to note Perl6::Export 0.07 dependency
+
+	- Added correct behaviour when no source specified
+
+
+==============================================================================
+
+AVAILABILITY
+
+Perl6::Slurp has been uploaded to the CPAN
+
+==============================================================================


Property changes on: packages/libperl6-slurp-perl/branches/upstream/current/README
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libperl6-slurp-perl/branches/upstream/current/Slurp.pm
===================================================================
--- packages/libperl6-slurp-perl/branches/upstream/current/Slurp.pm	2004-06-10 15:35:50 UTC (rev 184)
+++ packages/libperl6-slurp-perl/branches/upstream/current/Slurp.pm	2004-06-10 15:36:52 UTC (rev 185)
@@ -0,0 +1,409 @@
+package Perl6::Slurp;
+use 5.008;
+use Perl6::Export;
+use Carp;
+use warnings;
+
+our $VERSION = '0.03';
+
+my $mode_pat = qr{
+	^ \s* ( (?: < | \+< | \+>>? ) &? ) \s*
+}x;
+
+my $mode_plus_layers = qr{
+	(?: $mode_pat | ^ \s* -\| \s* )
+	( (?: :[^\W\d]\w* \s* )* )
+	\s* 
+	\z
+}x;
+
+sub slurp is export(:DEFAULT) {
+	my $list_context = wantarray;
+	my $default = $_;
+	croak "Useless use of &slurp in a void context"
+		unless defined $list_context;
+
+	my @layers;
+	for (my $i=0; $i<@_; $i++) {
+		my $type = ref $_[$i] or next;
+		if ($type eq 'HASH') {
+			push @layers, splice @_, $i--, 1
+		}
+		elsif ($type eq 'ARRAY') {
+			my @array = @{splice @_, $i--, 1};
+			while (@array) {
+				my ($layer, $value) = splice @array, 0, 2;
+				croak "Incomplete layer specification for :$layer",
+				 	  "\n(did you mean: $layer=>1)\n "
+							unless $value;
+				push @layers, { $layer=>$value };
+			}
+		}
+	}
+
+	my ($mode, $source, @args) = @_;
+	$mode = defined $default ? $default
+		  : @ARGV            ? \*ARGV
+		  :                    "-"
+		unless defined $mode;
+	if (ref $mode) {
+		$source = $mode;
+		$mode   = "<";
+	}
+	elsif ($mode !~ /$mode_plus_layers/x) {
+		$source = $mode;
+		$mode = $source =~ s/$mode_pat//x  ?  "$1"
+			  : $source =~ s/ \| \s* $//x  ?  "-|"
+			  :                               "<"
+			  ;
+	}
+
+	my $ref = ref $source;
+	if ($ref) {
+		croak "Can't use $ref as a data source"
+				unless $ref eq 'SCALAR' 
+					|| $ref eq 'GLOB'
+					|| UNIVERSAL::isa($source, 'IO::Handle');
+	}
+
+	local $/ = "\n";
+	my ($chomp, $chomp_to, $layers) = (0, "", "");
+
+	for (@layers) {
+		if (exists $_->{irs}) {
+			$/ = $_->{irs};
+			delete $_->{irs};
+		}
+		if (exists $_->{chomp}) {
+			$chomp = 1;
+			$chomp_to = $_->{chomp}
+				if defined $_->{chomp} && $_->{chomp} ne "1";
+			delete $_->{chomp};
+		}
+		$layers .= join " ", map ":$_", keys %$_;
+	}
+
+	$mode .= " $layers";
+
+	my $FH;
+	if ($ref && $ref ne 'SCALAR') {
+		$FH = $source;
+	}
+	else {
+		open $FH, $mode, $source, @args or croak "Can't open '$source': $!";
+	}
+
+	my $chomp_into = ref $chomp_to eq 'CODE' ? $chomp_to : sub{ $chomp_to };
+
+	my $data = $FH == \*ARGV ? join("",<>) : do { local $/; <$FH> };
+
+	my $irs = ref($/)		? $/
+			: defined($/)	? qr{\Q$/\E}
+			:				  qr{(?!)};
+
+	if ($list_context) {
+		return () unless defined $data;
+		my @lines = split /($irs)/, $data;
+		my $reps = @lines/2-1;
+		$reps = -1 if $reps<0;
+		for my $i (0..$reps) {
+			my $sep = splice @lines, $i+1, 1;
+			$sep = $chomp_into->($sep) if $chomp;
+			$lines[$i] .= $sep if defined $sep;
+		}
+		return @lines;
+	}
+	else {
+		return "" unless defined $data;
+		$data =~ s{($irs)}{$chomp_into->($1)}ge if $chomp;
+		return $data;
+	}
+}
+
+1;
+__END__
+
+
+=head1 NAME
+
+Perl6::Slurp - Implements the Perl 6 'slurp' built-in
+
+
+=head1 SYNOPSIS
+
+    use Perl6::Slurp;
+     
+	# Slurp a file by name...
+     
+	$file_contents = slurp 'filename';
+	$file_contents = slurp '<filename';
+	$file_contents = slurp '<', 'filename';
+	$file_contents = slurp '+<', 'filename';
+     
+     
+	# Slurp a file via an (already open!) handle...
+     
+	$file_contents = slurp \*STDIN;
+	$file_contents = slurp $filehandle;
+	$file_contents = slurp IO::File->new('filename');
+     
+     
+	# Slurp a string...
+     
+	$str_contents = slurp \$string;
+	$str_contents = slurp '<', \$string;
+     
+     
+	# Slurp a pipe...
+     
+	$str_contents = slurp 'tail -20 $filename |';
+	$str_contents = slurp '-|', 'tail', -20, $filename;
+     
+
+	# Slurp with no source slurps from whatever $_ indicates...
+
+	for (@files) {
+		$contents .= slurp;
+	}
+
+	# ...or from the entire ARGV list, if $_ is undefined...
+
+	$_ = undef;
+	$ARGV_contents = slurp;
+
+     
+	# Specify I/O layers as part of mode...
+     
+	$file_contents = slurp '<:raw', $file;
+	$file_contents = slurp '<:utf8', $file;
+	$file_contents = slurp '<:raw :utf8', $file;
+     
+     
+	# Specify I/O layers as separate options...
+     
+	$file_contents = slurp $file, {raw=>1};
+	$file_contents = slurp $file, {utf8=>1};
+	$file_contents = slurp $file, {raw=>1}, {utf8=>1};
+	$file_contents = slurp $file, [raw=>1, utf8=>1];
+     
+     
+	# Specify input record separator...
+       
+	$file_contents = slurp $file, {irs=>"\n\n"};
+	$file_contents = slurp '<', $file, {irs=>"\n\n"};
+	$file_contents = slurp {irs=>"\n\n"}, $file;
+       
+       
+	# Input record separator can be regex...
+       
+	$file_contents = slurp $file, {irs=>qr/\n+/};
+	$file_contents = slurp '<', $file, {irs=>qr/\n+|\t{2,}};
+       
+       
+	# Specify autochomping...
+       
+	$file_contents = slurp $file, {chomp=>1};
+	$file_contents = slurp {chomp=>1}, $file;
+	$file_contents = slurp $file, {chomp=>1, irs=>"\n\n"};
+	$file_contents = slurp $file, {chomp=>1, irs=>qr/\n+/};
+       
+       
+	# Specify autochomping that replaces irs
+	# with another string...
+       
+	$file_contents = slurp $file, {irs=>"\n\n", chomp=>"\n"};
+	$file_contents = slurp $file, {chomp=>"\n\n"}, {irs=>qr/\n+/};
+       
+       
+	# Specify autochomping that replaces
+	# irs with a dynamically computed string...
+       
+	my $n = 1;
+	$file_contents = slurp $file, {chomp=>sub{ "\n#line ".$n++."\n"};
+       
+       
+	# Slurp in a list context...
+       
+	@lines = slurp 'filename';
+	@lines = slurp $filehandle;
+	@lines = slurp \$string;
+	@lines = slurp '<:utf8', 'filename', {irs=>"\x{2020}", chomp=>"\n"};
+
+
+=head1 DESCRIPTION
+
+C<slurp> takes:
+
+=over
+
+=item * 
+
+a filename,
+
+=item * 
+
+a filehandle,
+
+=item * 
+
+a typeglob reference,
+
+=item * 
+
+an IO::File object, or
+
+=item * 
+
+a scalar reference,
+
+=back 
+
+converts it to an input stream if necessary, and reads in the entire stream.
+If C<slurp> fails to set up or read the stream, it throws an exception.
+
+If no data source is specified C<slurp> uses the value of C<$_> as the
+source. If C<$_> is undefined, C<slurp> uses the C<@ARGV> list,
+and magically slurps the contents of I<all> the sources listed in C<@ARGV>.
+Note that the same magic is also applied if you explicitly slurp <*ARGV>, so
+the following three input operations:
+
+	$contents = join "", <ARGV>;
+
+	$contents = slurp \*ARGV;
+
+	$/ = undef;
+	$contents = slurp;
+
+are identical in effect.
+
+In a scalar context C<slurp> returns the stream contents as a single string.
+If the stream is at EOF, it returns an empty string.
+In a list context, it splits the contents after the appropriate input
+record separator and returns the resulting list of strings.
+
+You can set the input record separator (S<< C<< { irs => $your_irs_here}
+>> >>) for the input operation. The separator can be specified as a
+string or a regex. Note that an explicit input record separator has no
+effect in a scalar context, since C<slurp> always reads in everything anyway.
+
+In a list context, changing the separator can change how the input is
+broken up within the list that is returned.
+
+If an input record separator is not explicitly specified, C<slurp> 
+defaults to C<"\n"> (I<not> to the current value of C<$/> E<ndash> since 
+Perl 6 doesn't I<have> a C<$/>);
+
+You can also tell C<slurp> to automagically C<chomp> the input as it is
+read in, by specifying: (S<< C<< { chomp => 1 } >> >>)
+
+Better still, you can tell C<slurp> to automagically
+C<chomp> the input and I<replace> what it chomps with another string,
+by specifying: (S<< C<< { chomp => "another string" } >> >>)
+
+You can also tell C<slurp> to compute the replacement string on-the-fly
+by specifying a subroutine as the C<chomp> value:
+(S<< C<< { chomp => sub{...} } >> >>). This subroutine is passed the string
+being chomped off, so for example you could squeeze single newlines to a
+single space and multiple conseqcutive newlines to a two newlines with:
+
+	sub squeeze { 
+		my ($removed) = @_;
+		if ($removed =~ tr/\n/\n/ == 1) { return " " }
+		else                            { return "\n\n"; }
+	}
+
+	print slurp(\*DATA, {irs=>qr/[ \t]*\n+/, chomp=>\&squeeze}), "\n";
+
+Which would transform:
+
+	This is the 
+	first paragraph
+     		
+     		
+	This is the 
+	second
+	paragraph
+     		
+	This, the
+	third
+     		
+     		
+     		
+     		
+	This one is
+	the
+	very 
+	last
+
+to:
+
+	This is the first paragraph
+     
+	This is the second paragraph
+     
+	This, the third
+     
+	This one is the very last 
+
+
+Autochomping works in both scalar and list contexts. In scalar contexts every
+instance of the input record separator will be removed (or replaced) within
+the returned string. In list context, each list item returned with its
+terminating separator removed (or replaced).
+
+You can specify I/O layers, either using the Perl 5 notation:
+
+    slurp "<:layer1 :layer2 :etc", $filename;
+
+or as an array of options:
+
+    slurp $filename, [layer1=>1, layer2=>1, etc=>1];
+    slurp [layer1=>1, layer2=>1, etc=>1], $filename;
+
+or as individual options (each of which must be in a separate hash):
+
+    slurp $filename, {layer1=>1}, {layer2=>1}, {etc=>1};
+    slurp {layer1=>1}, {layer2=>1}, {etc=>1}, $filename;
+
+(...which, of course, would look much cooler in Perl 6:
+
+    # Perl 6 only :-(
+
+    slurp $filename, :layer1 :layer2 :etc;
+    slurp :layer1 :layer2 :etc, $filename;
+
+)
+
+A common mistake is to put all the options together in one hash:
+
+    slurp $filename, {layer1=>1, layer2=>1, etc=>1};
+
+This is almost always a disaster, since the order of I/O layers is usually
+critical, and placing them all in one hash effectively randomizes that order.
+Use an array instead:
+
+    slurp $filename, [layer1=>1, layer2=>1, etc=>1];
+
+
+=head1 WARNING
+
+The syntax and semantics of Perl 6 is still being finalized
+and consequently is at any time subject to change. That means the
+same caveat applies to this module.
+
+
+=head1 DEPENDENCIES
+
+Requires: Perl 5.8.0, Perl6::Export
+
+
+=head1 AUTHOR
+
+Damian Conway (damian@conway.org)
+
+
+=head1 COPYRIGHT
+
+ Copyright (c) 2003, Damian Conway. All Rights Reserved.
+ This module is free software. It may be used, redistributed
+    and/or modified under the same terms as Perl itself.


Property changes on: packages/libperl6-slurp-perl/branches/upstream/current/Slurp.pm
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libperl6-slurp-perl/branches/upstream/current/t/chomp.t
===================================================================
--- packages/libperl6-slurp-perl/branches/upstream/current/t/chomp.t	2004-06-10 15:35:50 UTC (rev 184)
+++ packages/libperl6-slurp-perl/branches/upstream/current/t/chomp.t	2004-06-10 15:36:52 UTC (rev 185)
@@ -0,0 +1,124 @@
+use Test::More "no_plan";
+BEGIN {use_ok(Perl6::Slurp)};
+
+my $desc;
+sub TEST { $desc = $_[0] };
+
+my $line1 = "line 1";
+my $line2 = "line 2";
+my $line3 = "line 3";
+my $line4 = "line 4";
+
+my $para1 = $line1."\n".$line2."\n\n";
+my $para2 = $line3."\n".$line4."\n";
+
+my $data = $para1.$para2;
+
+TEST "scalar slurp no chomp";
+$str = slurp \$data;
+is $str, $data, $desc;
+
+TEST "list slurp no chomp";
+@str = slurp \$data;
+is_deeply \@str, ["$line1\n", "$line2\n", "\n", "$line3\n", "$line4\n"], $desc;
+
+# Regular chomp
+
+TEST "scalar slurp with chomp";
+$str = slurp \$data, {chomp=>1};
+is $str, $line1.$line2.$line3.$line4, $desc;
+
+TEST "list slurp with chomp";
+@str = slurp \$data, {chomp=>1};
+is_deeply \@str, [$line1, $line2, "", $line3, $line4], $desc;
+
+TEST "scalar slurp with chomp and :irs(\"\\n\")";
+$str = slurp \$data, {irs=>"\n", chomp=>1};
+is $str, $line1.$line2.$line3.$line4, $desc;
+
+TEST "list slurp with chomp :irs(\"\\n\")";
+@str = slurp \$data, {irs=>"\n", chomp=>1};
+is_deeply \@str, [$line1, $line2, "", $line3, $line4], $desc;
+
+TEST "scalar slurp with chomp :irs(\"\\n\\n\")";
+$str = slurp \$data, {chomp=>1, irs=>"\n\n"};
+is $str, $line1."\n".$line2.$line3."\n".$line4."\n", $desc;
+
+TEST "list slurp with chomp :irs(\"\\n\\n\")";
+@str = slurp \$data, {chomp=>1, irs=>"\n\n"};
+is_deeply \@str, [$line1."\n".$line2, $line3."\n".$line4."\n"], $desc;
+
+TEST "scalar slurp with chomp :irs(undef)";
+$str = slurp \$data, {chomp=>1, irs=>undef};
+is $str, $data, $desc;
+
+TEST "list slurp with chomp :irs(undef)";
+@str = slurp \$data, {chomp=>1, irs=>undef};
+is_deeply \@str, [$data], $desc;
+
+TEST "scalar slurp with chomp :irs('ne')";
+$str = slurp \$data, {chomp=>1, irs=>'ne'};
+is $str, "li 1\nli 2\n\nli 3\nli 4\n", $desc;
+
+TEST "list slurp with chomp :irs('ne')";
+@str = slurp \$data, {chomp=>1, irs=>'ne'};
+is_deeply \@str, [split /ne/, $data], $desc;
+
+TEST "scalar slurp with chomp :irs(qr/\\n+|3/)";
+$str = slurp \$data, {irs=>qr/\n+|3/, chomp=>1};
+is $str, "line 1line 2line line 4", $desc;
+
+TEST "list slurp with chomp :irs(qr/\\n+|3/)";
+@str = slurp \$data, {irs=>qr/\n+|3/, chomp=>1};
+is_deeply \@str, ["line 1","line 2","line ","","line 4"], $desc;
+
+# Chomp with substitution
+
+TEST "scalar slurp with substitution chomp";
+$str = slurp \$data, {chomp=>"foo"};
+is $str, $line1."foo".$line2."foofoo".$line3."foo".$line4."foo", $desc;
+
+TEST "list slurp with substitution chomp";
+@str = slurp \$data, {chomp=>"foo"};
+is_deeply \@str, [$line1."foo", $line2."foo", "foo", $line3."foo", $line4."foo"], $desc;
+
+TEST "scalar slurp with substitution chomp and :irs(\"\\n\")";
+$str = slurp \$data, {irs=>"\n", chomp=>"foo"};
+is $str, $line1."foo".$line2."foofoo".$line3."foo".$line4."foo", $desc;
+
+TEST "list slurp with substitution chomp :irs(\"\\n\")";
+@str = slurp \$data, {irs=>"\n", chomp=>"foo"};
+is_deeply \@str, [$line1."foo", $line2."foo", "foo", $line3."foo", $line4."foo"], $desc;
+
+TEST "scalar slurp with substitution chomp :irs(\"\\n\\n\")";
+$str = slurp \$data, {chomp=>"foo", irs=>"\n\n"};
+is $str, $line1."\n".$line2."foo".$line3."\n".$line4."\n", $desc;
+
+TEST "list slurp with substitution chomp :irs(\"\\n\\n\")";
+@str = slurp \$data, {chomp=>"foo", irs=>"\n\n"};
+is_deeply \@str, [$line1."\n".$line2."foo", $line3."\n".$line4."\n"], $desc;
+
+TEST "scalar slurp with substitution chomp :irs(undef)";
+$str = slurp \$data, {chomp=>"foo", irs=>undef};
+is $str, $data, $desc;
+
+TEST "list slurp with substitution chomp :irs(undef)";
+@str = slurp \$data, {chomp=>"foo", irs=>undef};
+is_deeply \@str, [$data], $desc;
+
+TEST "scalar slurp with substitution chomp :irs('ne')";
+$str = slurp \$data, {chomp=>"foo", irs=>'ne'};
+is $str, "lifoo 1\nlifoo 2\n\nlifoo 3\nlifoo 4\n", $desc;
+
+TEST "list slurp with substitution chomp :irs('ne')";
+@str = slurp \$data, {chomp=>"foo", irs=>'ne'};
+is_deeply \@str, ["lifoo", " 1\nlifoo", " 2\n\nlifoo", " 3\nlifoo", " 4\n"], $desc;
+
+TEST "scalar slurp with substitution chomp :irs(qr/\\n+|3/)";
+$str = slurp \$data, {irs=>qr/\n+|3/, chomp=>"foo"};
+is $str, "line 1fooline 2fooline foofooline 4foo", $desc;
+
+TEST "list slurp with substitution chomp :irs(qr/\\n+|3/)";
+@str = slurp \$data, {irs=>qr/\n+|3/, chomp=>"foo"};
+is_deeply \@str, ["line 1foo","line 2foo","line foo","foo","line 4foo"], $desc;
+


Property changes on: packages/libperl6-slurp-perl/branches/upstream/current/t/chomp.t
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libperl6-slurp-perl/branches/upstream/current/t/errors.t
===================================================================
--- packages/libperl6-slurp-perl/branches/upstream/current/t/errors.t	2004-06-10 15:35:50 UTC (rev 184)
+++ packages/libperl6-slurp-perl/branches/upstream/current/t/errors.t	2004-06-10 15:36:52 UTC (rev 185)
@@ -0,0 +1,28 @@
+use Test::More "no_plan";
+BEGIN {use_ok(Perl6::Slurp)};
+
+my $desc;
+sub TEST { $desc = $_[0] };
+
+TEST "can't slurp in void context";
+
+eval{;slurp $0;1}
+	? ok 0, $desc
+	: like $@,
+		   qr/void context/,
+		   $desc;
+
+TEST "shouldn't be able to slurp non-existent file";
+
+eval{slurp "non-existent file"}
+	? ok 0, $desc
+	: like $@,
+		   qr/^Can't open 'non-existent file': No such file or directory/,
+		   $desc;
+
+TEST "shouldn't be able to read from unreadable filehandle";
+open *FILE, ">-";
+
+slurp(\*FILE)
+	? ok 0, $desc
+	: ok 1, $desc;


Property changes on: packages/libperl6-slurp-perl/branches/upstream/current/t/errors.t
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libperl6-slurp-perl/branches/upstream/current/t/filehandle.t
===================================================================
--- packages/libperl6-slurp-perl/branches/upstream/current/t/filehandle.t	2004-06-10 15:35:50 UTC (rev 184)
+++ packages/libperl6-slurp-perl/branches/upstream/current/t/filehandle.t	2004-06-10 15:36:52 UTC (rev 185)
@@ -0,0 +1,53 @@
+use Test::More "no_plan";
+BEGIN {use_ok(Perl6::Slurp)};
+
+my $desc;
+sub TEST { $desc = $_[0] };
+
+open FH, '>data' or exit;
+print FH map "data $_\n", 1..20;
+close FH;
+
+open FH, 'data' or exit;
+my $pos = tell *FH;
+
+my $data = do { local $/; <FH> };
+seek *FH, 0, 0;
+my @data = <FH>;
+close FH;
+
+open FH, 'data' or exit;
+
+TEST "scalar slurp from filehandle ";
+$str = slurp \*FH;
+is $str, $data, $desc;
+
+open FH, 'data' or exit;
+
+TEST "list slurp from filehandle ";
+@str = slurp \*FH;
+is_deeply \@str, \@data, $desc;
+
+for my $mode (qw( < +< )) {
+	open FH, 'data' or exit;
+
+	TEST "scalar slurp from '$mode', filehandle  ";
+	$str = slurp $mode, \*FH;
+	is $str, $data, $desc;
+
+	TEST "scalar slurp from empty filehandle";
+	$str = slurp $mode, \*FH;
+	is $str, "", $desc;
+
+	open FH, 'data' or exit;
+
+	TEST "list slurp from '$mode', filehandle ";
+	@str = slurp $mode, \*FH;
+	is_deeply \@str, \@data, $desc;
+
+	TEST "list slurp from empty filehandle";
+	@str = slurp $mode, \*FH;
+	is_deeply \@str, [], $desc;
+}
+
+unlink 'data';


Property changes on: packages/libperl6-slurp-perl/branches/upstream/current/t/filehandle.t
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libperl6-slurp-perl/branches/upstream/current/t/filename.t
===================================================================
--- packages/libperl6-slurp-perl/branches/upstream/current/t/filename.t	2004-06-10 15:35:50 UTC (rev 184)
+++ packages/libperl6-slurp-perl/branches/upstream/current/t/filename.t	2004-06-10 15:36:52 UTC (rev 185)
@@ -0,0 +1,66 @@
+use Test::More "no_plan";
+BEGIN {use_ok(Perl6::Slurp)};
+
+my $desc;
+sub TEST { $desc = $_[0] };
+
+open FH, '>data' or exit;
+print FH map "data $_\n", 1..20;
+close FH;
+
+open FH, 'data' or exit;
+my $pos = tell *FH;
+
+my $data = do { local $/; <FH> };
+seek *FH, 0, 0;
+my @data = <FH>;
+close FH;
+
+TEST "scalar slurp from 'data' in main";
+$str = slurp 'data';
+is $str, $data, $desc;
+
+TEST "list slurp from 'data' in main";
+@str = slurp 'data';
+is_deeply \@str, \@data, $desc;
+
+for my $mode (qw( < +< )) {
+	TEST "scalar slurp from '${mode}data' in main";
+	$str = slurp "${mode}data";
+	is $str, $data, $desc;
+
+	TEST "scalar slurp from '$mode data' in main";
+	$str = slurp "$mode data";
+	is $str, $data, $desc;
+
+	TEST "scalar slurp from '$mode', 'data' in main";
+	$str = slurp $mode, 'data';
+	is $str, $data, $desc;
+
+	TEST "list slurp from '${mode}data' in main";
+	@str = slurp "${mode}data";
+	is_deeply \@str, \@data, $desc;
+
+	TEST "list slurp from '$mode data' in main";
+	@str = slurp "$mode data";
+	is_deeply \@str, \@data, $desc;
+
+	TEST "list slurp from '$mode', 'data' in main";
+	@str = slurp $mode, 'data';
+	is_deeply \@str, \@data, $desc;
+}
+
+TEST "scalar slurp from \$_ in main";
+for ('data') {
+	$str = slurp;
+	is $str, $data, $desc;
+}
+
+local $/;
+@ARGV = qw(data data);
+
+TEST "scalar slurp from ARGV in main";
+$str = slurp;
+is $str, $data.$data, $desc;
+
+unlink 'data';


Property changes on: packages/libperl6-slurp-perl/branches/upstream/current/t/filename.t
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libperl6-slurp-perl/branches/upstream/current/t/ioderfile.t
===================================================================
--- packages/libperl6-slurp-perl/branches/upstream/current/t/ioderfile.t	2004-06-10 15:35:50 UTC (rev 184)
+++ packages/libperl6-slurp-perl/branches/upstream/current/t/ioderfile.t	2004-06-10 15:36:52 UTC (rev 185)
@@ -0,0 +1,60 @@
+use Test::More "no_plan";
+BEGIN {use_ok(Perl6::Slurp)};
+
+package IO::DerFile;
+use base 'IO::File';
+
+package main;
+
+my $desc;
+sub TEST { $desc = $_[0] };
+
+my $FH;
+
+$FH = IO::DerFile->new('>data') or exit;
+print $FH map "data $_\n", 1..20;
+close $FH;
+
+$FH = IO::DerFile->new('data') or exit;
+my $pos = $FH->tell;
+
+my $data = do { local $/; <$FH> };
+$FH->seek(0, 0);
+my @data = <$FH>;
+$FH->close;
+
+$FH = IO::DerFile->new('data') or exit;
+
+TEST "scalar slurp from IO::DerFile object ";
+$str = slurp $FH;
+is $str, $data, $desc;
+
+$FH = IO::DerFile->new('data') or exit;
+
+TEST "list slurp from IO::DerFile object ";
+@str = slurp $FH;
+is_deeply \@str, \@data, $desc;
+
+for my $mode (qw( < +< )) {
+	$FH = IO::DerFile->new('data') or exit;
+
+	TEST "scalar slurp from '$mode', IO::DerFile object  ";
+	$str = slurp $mode, $FH;
+	is $str, $data, $desc;
+
+	TEST "scalar slurp from empty IO::DerFile object";
+	$str = slurp $mode, $FH;
+	is $str, "", $desc;
+
+	$FH = IO::DerFile->new('data') or exit;
+
+	TEST "list slurp from '$mode', IO::DerFile object ";
+	@str = slurp $mode, $FH;
+	is_deeply \@str, \@data, $desc;
+
+	TEST "list slurp from empty IO::DerFile object";
+	@str = slurp $mode, $FH;
+	is_deeply \@str, [], $desc;
+}
+
+unlink 'data';


Property changes on: packages/libperl6-slurp-perl/branches/upstream/current/t/ioderfile.t
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libperl6-slurp-perl/branches/upstream/current/t/iofile.t
===================================================================
--- packages/libperl6-slurp-perl/branches/upstream/current/t/iofile.t	2004-06-10 15:35:50 UTC (rev 184)
+++ packages/libperl6-slurp-perl/branches/upstream/current/t/iofile.t	2004-06-10 15:36:52 UTC (rev 185)
@@ -0,0 +1,56 @@
+use Test::More "no_plan";
+use IO::File;
+BEGIN {use_ok(Perl6::Slurp)};
+
+my $desc;
+sub TEST { $desc = $_[0] };
+
+my $FH;
+
+$FH = IO::File->new('>data') or exit;
+print $FH map "data $_\n", 1..20;
+close $FH;
+
+$FH = IO::File->new('data') or exit;
+my $pos = $FH->tell;
+
+my $data = do { local $/; <$FH> };
+$FH->seek(0, 0);
+my @data = <$FH>;
+$FH->close;
+
+$FH = IO::File->new('data') or exit;
+
+TEST "scalar slurp from IO::File object ";
+$str = slurp $FH;
+is $str, $data, $desc;
+
+$FH = IO::File->new('data') or exit;
+
+TEST "list slurp from IO::File object ";
+@str = slurp $FH;
+is_deeply \@str, \@data, $desc;
+
+for my $mode (qw( < +< )) {
+	$FH = IO::File->new('data') or exit;
+
+	TEST "scalar slurp from '$mode', IO::File object  ";
+	$str = slurp $mode, $FH;
+	is $str, $data, $desc;
+
+	TEST "scalar slurp from empty IO::File object";
+	$str = slurp $mode, $FH;
+	is $str, "", $desc;
+
+	$FH = IO::File->new('data') or exit;
+
+	TEST "list slurp from '$mode', IO::File object ";
+	@str = slurp $mode, $FH;
+	is_deeply \@str, \@data, $desc;
+
+	TEST "list slurp from empty IO::File object";
+	@str = slurp $mode, $FH;
+	is_deeply \@str, [], $desc;
+}
+
+unlink 'data';


Property changes on: packages/libperl6-slurp-perl/branches/upstream/current/t/iofile.t
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libperl6-slurp-perl/branches/upstream/current/t/ipc.t
===================================================================
--- packages/libperl6-slurp-perl/branches/upstream/current/t/ipc.t	2004-06-10 15:35:50 UTC (rev 184)
+++ packages/libperl6-slurp-perl/branches/upstream/current/t/ipc.t	2004-06-10 15:36:52 UTC (rev 185)
@@ -0,0 +1,34 @@
+use Test::More "no_plan";
+BEGIN {use_ok(Perl6::Slurp)};
+
+my $desc;
+sub TEST { $desc = $_[0] };
+
+my $data = "input data\n";
+
+{
+	my $TEST;
+	{ local *STDERR;
+	  open STDERR, '>', \my $err;
+	  open $TEST, "echo $data|" or exit;
+	}
+	$test = <$TEST>;
+	exit unless $test eq $data;
+	ok 1, "test reads from pipe";
+}
+
+TEST "scalar slurp from 'system command|'";
+$str = slurp 'echo input data|';
+is $str, $data, $desc;
+
+TEST "scalar slurp from '-|', 'system command'";
+$str = slurp '-|', 'echo input data';
+is $str, $data, $desc;
+
+TEST "scalar slurp from '-|', 'system', 'command', 'etc'";
+$str = slurp '-|', qw(echo input data);
+is $str, $data, $desc;
+
+TEST "scalar slurp from '-|', 'system', 'command', 'etc'";
+$str = slurp '-|', qw(echo input data);
+is $str, $data, $desc;


Property changes on: packages/libperl6-slurp-perl/branches/upstream/current/t/ipc.t
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libperl6-slurp-perl/branches/upstream/current/t/irs.t
===================================================================
--- packages/libperl6-slurp-perl/branches/upstream/current/t/irs.t	2004-06-10 15:35:50 UTC (rev 184)
+++ packages/libperl6-slurp-perl/branches/upstream/current/t/irs.t	2004-06-10 15:36:52 UTC (rev 185)
@@ -0,0 +1,63 @@
+use Test::More "no_plan";
+BEGIN {use_ok(Perl6::Slurp)};
+
+my $desc;
+sub TEST { $desc = $_[0] };
+
+my $line1 = "line 1\n";
+my $line2 = "line 2\n";
+my $line3 = "line 3\n";
+my $line4 = "line 4\n";
+
+my $para1 = $line1.$line2."\n";
+my $para2 = $line3.$line4;
+
+my $data = $para1.$para2;
+
+TEST "scalar slurp no irs";
+$str = slurp \$data;
+is $str, $data, $desc;
+
+TEST "list slurp no irs";
+@str = slurp \$data;
+is_deeply \@str, [$line1, $line2, "\n", $line3, $line4], $desc;
+
+TEST "scalar slurp :irs(\"\\n\")";
+$str = slurp \$data, {irs=>"\n"};
+is $str, $data, $desc;
+
+TEST "list slurp :irs(\"\\n\")";
+@str = slurp \$data, {irs=>"\n"};
+is_deeply \@str, [$line1, $line2, "\n", $line3, $line4], $desc;
+
+TEST "scalar slurp :irs(\"\\n\\n\")";
+$str = slurp \$data, {irs=>"\n\n"};
+is $str, $data, $desc;
+
+TEST "list slurp :irs(\"\\n\\n\")";
+@str = slurp \$data, {irs=>"\n\n"};
+is_deeply \@str, [$para1, $para2], $desc;
+
+TEST "scalar slurp :irs(undef)";
+$str = slurp \$data, {irs=>undef};
+is $str, $data, $desc;
+
+TEST "list slurp :irs(undef)";
+@str = slurp \$data, {irs=>undef};
+is_deeply \@str, [$data], $desc;
+
+TEST "scalar slurp :irs('ne')";
+$str = slurp \$data, {irs=>'ne'};
+is $str, $data, $desc;
+
+TEST "list slurp :irs('ne')";
+@str = slurp \$data, {irs=>'ne'};
+is_deeply \@str, [split /(?<=ne)/, $data], $desc;
+
+TEST "scalar slurp :irs(qr/\\n+|3/)";
+$str = slurp \$data, {irs=>qr/\n+|3/};
+is $str, $data, $desc;
+
+TEST "list slurp :irs(qr/\\n+|3/)";
+@str = slurp \$data, {irs=>qr/\n+|3/};
+is_deeply \@str, ["line 1\n","line 2\n\n","line 3","\n","line 4\n"], $desc;


Property changes on: packages/libperl6-slurp-perl/branches/upstream/current/t/irs.t
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libperl6-slurp-perl/branches/upstream/current/t/layers.t
===================================================================
--- packages/libperl6-slurp-perl/branches/upstream/current/t/layers.t	2004-06-10 15:35:50 UTC (rev 184)
+++ packages/libperl6-slurp-perl/branches/upstream/current/t/layers.t	2004-06-10 15:36:52 UTC (rev 185)
@@ -0,0 +1,60 @@
+use Test::More "no_plan";
+use utf8;
+BEGIN {use_ok(Perl6::Slurp)};
+
+my $desc;
+sub TEST { $desc = $_[0] };
+
+open FH, '>:utf8', 'data' or exit;
+print FH map chr, 0..0x1FF;
+close FH;
+
+undef $/;
+
+my @layers = ( qw(:raw :bytes :unix :stdio :perlio :crlf :utf8),
+			   ":raw :utf8",
+			   ":raw:utf8",
+			 );
+
+
+for my $layer (@layers) {
+	open FH, "<$layer", 'data' or exit;
+	$data{$layer} = <FH>;
+	$len{$layer}  = length $data{$layer};
+	close FH;
+}
+
+for my $layer (@layers) {
+	TEST "scalar slurp from '<$layer', 'data'";
+	$str = slurp "<$layer", 'data';
+	is $data{$layer}, $str, $desc;
+	ok length($str) == $len{$layer}, "length of $desc";
+
+	TEST "scalar slurp from '< $layer', 'data'";
+	$str = slurp "< $layer", 'data';
+	is $data{$layer}, $str, $desc;
+	ok length($str) == $len{$layer}, "length of $desc";
+}
+
+%opts = (
+	':raw'       => [{raw=>1}],
+	':utf8'      => [{utf8=>1}],
+	':raw :utf8' => [{raw=>1}, {utf8=>1}],
+	':raw:utf8'  => [[raw=>1, utf8=>1]],
+);
+
+for my $layer (keys %opts) {
+	local $" = ", ";
+	TEST "scalar option slurp from 'data', $layer";
+	$str = slurp 'data', @{$opts{$layer}};
+	is $data{$layer}, $str, $desc;
+	ok length($str) == $len{$layer}, "length of $desc";
+
+	TEST "scalar option slurp from $layer, 'data'";
+	$str = slurp @{$opts{$layer}}, 'data';
+	is $data{$layer}, $str, $desc;
+	ok length($str) == $len{$layer}, "length of $desc";
+
+}
+
+unlink 'data';


Property changes on: packages/libperl6-slurp-perl/branches/upstream/current/t/layers.t
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libperl6-slurp-perl/branches/upstream/current/t/lexfilehandle.t
===================================================================
--- packages/libperl6-slurp-perl/branches/upstream/current/t/lexfilehandle.t	2004-06-10 15:35:50 UTC (rev 184)
+++ packages/libperl6-slurp-perl/branches/upstream/current/t/lexfilehandle.t	2004-06-10 15:36:52 UTC (rev 185)
@@ -0,0 +1,55 @@
+use Test::More "no_plan";
+BEGIN {use_ok(Perl6::Slurp)};
+
+my $desc;
+sub TEST { $desc = $_[0] };
+
+my $FH;
+
+undef $FH; open $FH, '>data' or exit;
+print $FH map "data $_\n", 1..20;
+close $FH;
+
+undef $FH; open $FH, 'data' or exit;
+my $pos = tell $FH;
+
+my $data = do { local $/; <$FH> };
+seek $FH, 0, 0;
+my @data = <$FH>;
+close $FH;
+
+undef $FH; open $FH, 'data' or exit;
+
+TEST "scalar slurp from lexical filehandle ";
+$str = slurp $FH;
+is $str, $data, $desc;
+
+undef $FH; open $FH, 'data' or exit;
+
+TEST "list slurp from lexical filehandle ";
+@str = slurp $FH;
+is_deeply \@str, \@data, $desc;
+
+for my $mode (qw( < +< )) {
+	undef $FH; open $FH, 'data' or exit;
+
+	TEST "scalar slurp from '$mode', lexical filehandle  ";
+	$str = slurp $mode, $FH;
+	is $str, $data, $desc;
+
+	TEST "scalar slurp from empty lexical filehandle";
+	$str = slurp $mode, $FH;
+	is $str, "", $desc;
+
+	undef $FH; open $FH, 'data' or exit;
+
+	TEST "list slurp from '$mode', lexical filehandle ";
+	@str = slurp $mode, $FH;
+	is_deeply \@str, \@data, $desc;
+
+	TEST "list slurp from empty lexical filehandle";
+	@str = slurp $mode, $FH;
+	is_deeply \@str, [], $desc;
+}
+
+unlink 'data';


Property changes on: packages/libperl6-slurp-perl/branches/upstream/current/t/lexfilehandle.t
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libperl6-slurp-perl/branches/upstream/current/t/string.t
===================================================================
--- packages/libperl6-slurp-perl/branches/upstream/current/t/string.t	2004-06-10 15:35:50 UTC (rev 184)
+++ packages/libperl6-slurp-perl/branches/upstream/current/t/string.t	2004-06-10 15:36:52 UTC (rev 185)
@@ -0,0 +1,26 @@
+use Test::More "no_plan";
+BEGIN {use_ok(Perl6::Slurp)};
+
+my $desc;
+sub TEST { $desc = $_[0] };
+
+@data = map "data $_\n", 1..20;
+$data = join "", @data;
+
+TEST "scalar slurp from string";
+$str = slurp \$data;
+is $str, $data, $desc;
+
+TEST "list slurp from string ";
+@str = slurp \$data;
+is_deeply \@str, \@data, $desc;
+
+for my $mode (qw( < +< )) {
+	TEST "scalar slurp from '$mode', string  ";
+	$str = slurp $mode, \$data;
+	is $str, $data, $desc;
+
+	TEST "list slurp from '$mode', string ";
+	@str = slurp $mode, \$data;
+	is_deeply \@str, \@data, $desc;
+}


Property changes on: packages/libperl6-slurp-perl/branches/upstream/current/t/string.t
___________________________________________________________________
Name: svn:executable
   +