File: other_output_seperator.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 (30 lines) | stat: -rw-r--r-- 891 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl
# other_output_seperator.t 
# Copyright (c) 2006 Jonathan Rockway <jrockway@cpan.org>

use Test::More tests => 8;
use Directory::Scratch;
use Path::Tiny;

my $tmp = Directory::Scratch->new;

local $, = '!';
local $/ = '!';

ok($tmp->touch('foo', qw(these are some lines)), 'create foo');
my $file = path(''. $tmp->exists('foo'))->slurp;
ok($file, 'read it back in');
is($file, 'these!are!some!lines!', 'lines end in !');

my @file = $tmp->read('foo');
is_deeply(\@file, [qw(these are some lines)], 'works in array context too');

ok($tmp->append('foo', qw(now there are more)), 'add more lines');

$file = path(''. $tmp->exists('foo'))->slurp;
ok($file, 'read it back in');
is($file, 'these!are!some!lines!now!there!are!more!', 'lines end in !');

@file = $tmp->read('foo');
is_deeply(\@file, [qw(these are some lines now there are more)], 
	  'works in array context too');