~ubuntu-branches/ubuntu/maverick/libfile-fu-perl/maverick

« back to all changes in this revision

Viewing changes to t/errors.t

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Yu
  • Date: 2009-07-25 07:10:04 UTC
  • Revision ID: james.westby@ubuntu.com-20090725071004-p7cmwowvpf0f7k81
Tags: upstream-0.0.6
ImportĀ upstreamĀ versionĀ 0.0.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
use warnings;
 
4
use strict;
 
5
 
 
6
use Test::More qw(no_plan);
 
7
 
 
8
use File::Fu;
 
9
 
 
10
{ # invalid ops
 
11
  my $f = File::Fu->dir;
 
12
 
 
13
  eval {my $nope = $f - 8};
 
14
  like($@, qr/^- is not a valid op/);
 
15
 
 
16
  eval {my $nope = $f * 8};
 
17
  like($@, qr/^\* is not a valid op/);
 
18
 
 
19
  eval {my $nope = $f << 8};
 
20
  like($@, qr/^<< is not a valid op/);
 
21
}
 
22
 
 
23
{ # readlink on a non-link
 
24
  my $f = File::Fu->file("blortleblat89");
 
25
  $f->e and $f->unlink;
 
26
  ok(! $f->e, "no $f") or die "where did $f come from?!";
 
27
  eval {my $l = $f->readlink};
 
28
  like($@, qr/^cannot readlink .* No such/, 'no readlink on nil');
 
29
  my $fh = $f->open('>');
 
30
  close($fh) or die "ack $!";
 
31
  eval {my $l = $f->readlink};
 
32
  like($@, qr/^cannot readlink .* Invalid/, 'no readlink on file');
 
33
  $f->unlink;
 
34
}
 
35
 
 
36
# vim:ts=2:sw=2:et:sta