File: slurp.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 (25 lines) | stat: -rwxr-xr-x 529 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
#!/usr/bin/perl

use warnings;
use strict;

use Test::More qw(no_plan);

use File::Fu;

my $d = File::Fu->dir->temp_dir('tmp.');
my $f = $d + 'file';
is($f->basename, 'file');
my $fh = $f->open('>');
print $fh "foo\nbar\n";
close($fh) or die "cannot write '$f' $!";
ok($f->e);

my @lines = $f->read;
is_deeply(\@lines, ["foo\n", "bar\n"], 'slurp array');
is($f->read, "foo\nbar\n", 'slurp scalar');

# TODO something where File::Slurp is not loaded
# (probably in another test file and messing with @INC)

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