File: 2basic.t

package info (click to toggle)
libperlio-via-symlink-perl 0.05-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 144 kB
  • sloc: perl: 1,196; makefile: 8
file content (50 lines) | stat: -rw-r--r-- 1,075 bytes parent folder | download | duplicates (5)
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
47
48
49
50
#!/usr/bin/perl
use Config;
use Test::More (
    $Config{d_symlink} ? (tests => 9)
		       : (skip_all => "symlink not available")
);
use PerlIO::via::symlink;
use strict;

use POSIX qw(setlocale LC_ALL);
setlocale (LC_ALL, 'C');

my $fname = 'symlink-test';
unlink ($fname);
open my $fh, '+>:via(symlink)', $fname;
ok ($! =~ m'Invalid argument');

open $fh, '>:via(symlink)', $fname or die $!;
print $fh "link foobar";
close $fh;
ok (-l $fname);
is (readlink $fname, 'foobar');

open $fh, '<:via(symlink)', $fname or die $!;
is (<$fh>, 'link foobar', 'read');
seek $fh, 0, 0;
is (<$fh>, 'link foobar', 'read');

unlink ($fname);

eval {
open my $fh, '>:via(symlink)', $fname or die $!;
print $fh "foobar";
close $fh or die $!;
};
ok ($@ =~ m'Invalid argument');

open $fh, '<:via(symlink)', $fname;
ok ($! =~ m'Bad file (number|descriptor)');

eval {
open my $fh, '>:via(symlink)', $fname or die $!;
`touch $fname`;
print $fh "link foobar";
close $fh or die $!;
};
ok ($@ =~ m'File exists');

open $fh, '<:via(symlink)', $fname;
ok ($! =~ m'Bad file (number|descriptor)');