File: 04-links.t

package info (click to toggle)
libdirectory-scratch-perl 0.18-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 404 kB
  • ctags: 25
  • sloc: perl: 1,173; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 977 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl
# 04-links.t 
# Copyright (c) 2006 Jonathan Rockway <jrockway@cpan.org>

use Directory::Scratch;
use Test::More;
use strict;
use warnings;
plan skip_all => "links don't work under Win32" if $^O eq 'MSWin32';
plan tests => 14;

my $t = Directory::Scratch->new;
my $file1 = $t->touch('test', "this is a test");
my $dir   = $t->mkdir('foo');
my $file2 = $t->touch('foo/test', "this is also a test");

ok($file1);
ok($dir);
ok($file2);

ok($t->link('test', 'new_test'));
ok($t->link('foo', 'new_foo'));
ok($t->link('foo/test', 'new_foo_test'));
ok($t->link('new_foo/test', 'newer_test'));

is($t->read('test'), "this is a test");

is($t->read('foo/test'), "this is also a test");
is($t->read('newer_test'), "this is also a test");
is($t->read('new_foo/test'), "this is also a test");

ok($t->touch('bar'));
eval {
    $t->link('test', 'bar');
};
ok($@, 'cannot link over an existing file');

eval {
    $t->link('test', 'test');
};
ok($@, 'cannot link over self');