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

« back to all changes in this revision

Viewing changes to t/finder.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
my $topdir = File::Fu->dir('tmp.' . $$);
 
11
END { $topdir->remove; }
 
12
 
 
13
$topdir->subdir('foo')->subdir('bar')->subdir('baz')->create;
 
14
$topdir->file('file.1')->touch;
 
15
$topdir->file('file.2')->touch;
 
16
$topdir->subdir('foo')->file('file.3')->touch;
 
17
$topdir->subdir('foo')->file('file.4')->touch;
 
18
($topdir/'foo'/'bar'/'baz' + 'file.5')->touch;
 
19
($topdir/'foo'/'bar'/'baz' + 'file.6')->touch;
 
20
 
 
21
{
 
22
  my @files = $topdir->find(sub {1});
 
23
  is(scalar(@files), 9, 'find') or die join("\n", @files);
 
24
 
 
25
  my $finder = $topdir->finder(sub {1});
 
26
  my @got;
 
27
  while(defined(my $p = $finder->())) {
 
28
    $p or next;
 
29
    push(@got, $p);
 
30
  }
 
31
  is(scalar(@got), 9, 'finder');
 
32
}
 
33
 
 
34
 
 
35
 
 
36
# vim:ts=2:sw=2:et:sta