File: no_source.t

package info (click to toggle)
libperl6-slurp-perl 0.051005-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 148 kB
  • sloc: perl: 148; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 892 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use Test::More "no_plan";
use utf8;
BEGIN {use_ok(Perl6::Slurp)};

my $FILENAME = 'no_source.t.data';

my $desc;
sub TEST { $desc = $_[0] };

open FH, '>:utf8', $FILENAME 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", $FILENAME or exit;
	$data{$layer} = <FH>;
	$len{$layer}  = length $data{$layer};
	close FH;
}

$_ = $FILENAME;

%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 implied \$_, $layer";
	$str = slurp @{$opts{$layer}};
	is $data{$layer}, $str, $desc;
	ok length($str) == $len{$layer}, "length of $desc";
}

unlink $FILENAME;