File: 10-new-with-arguments.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-- 728 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
#!/usr/bin/perl
# 10-new-with-arguments.t 
# Copyright (c) 2006 Jonathan Rockway <jrockway@cpan.org>

use strict;
use warnings;
use Test::More tests => 5;
use Directory::Scratch;
use File::Spec;

my $tmp = Directory::Scratch->new(
				  TEMPLATE => 'foo_bar_baz_XXXX',
				 );
ok($tmp);

my $dir = $tmp->base;
like($dir, qr/[^\w]foo_bar_baz_....[^\w]?$/, 'base matches template');

$tmp    = Directory::Scratch->new(
				  DIR      => File::Spec->tmpdir,
				  TEMPLATE => 'foo_bar_baz_XXXX',
				 );
ok($tmp);

my $new_dir = $tmp->base;
like($new_dir, qr/[^\w]foo_bar_baz_....[^\w]?$/, 'base matches template');
$dir =~ s/....$//;
$new_dir =~ s/....$//;
is($dir, $new_dir, 'DIR = tmpdir, and no DIR produce identical paths');