File: errors.t

package info (click to toggle)
libfile-fu-perl 0.0.7-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 244 kB
  • ctags: 165
  • sloc: perl: 1,421; makefile: 2
file content (36 lines) | stat: -rwxr-xr-x 781 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
#!/usr/bin/perl

use warnings;
use strict;

use Test::More qw(no_plan);

use File::Fu;

{ # invalid ops
  my $f = File::Fu->dir;

  eval {my $nope = $f - 8};
  like($@, qr/^- is not a valid op/);

  eval {my $nope = $f * 8};
  like($@, qr/^\* is not a valid op/);

  eval {my $nope = $f << 8};
  like($@, qr/^<< is not a valid op/);
}

{ # readlink on a non-link
  my $f = File::Fu->file("blortleblat89");
  $f->e and $f->unlink;
  ok(! $f->e, "no $f") or die "where did $f come from?!";
  eval {my $l = $f->readlink};
  like($@, qr/^cannot readlink .* No such/, 'no readlink on nil');
  my $fh = $f->open('>');
  close($fh) or die "ack $!";
  eval {my $l = $f->readlink};
  like($@, qr/^cannot readlink .* Invalid/, 'no readlink on file');
  $f->unlink;
}

# vim:ts=2:sw=2:et:sta