File: 20-hostname.t

package info (click to toggle)
libsystem-sub-perl 0.162800-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 196 kB
  • sloc: perl: 253; sh: 6; makefile: 2
file content (22 lines) | stat: -rw-r--r-- 496 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

use strict;
use warnings;

use Test::More (-x '/bin/hostname' ? (tests => 4)
                                   : (skip_all => 'No /bin/hostname'));

use System::Sub hostname => [ '$0' => '/bin/hostname' ];

my $expected = `hostname`;
chomp $expected;

$_ = 'canary';
my $got = hostname;
is($got, $expected, 'scalar context');
is($_, 'canary', '$_ not changed');

my @got = hostname;
is_deeply(\@got, [ $expected ], 'list context');
is($_, 'canary', '$_ not changed');

# vim:set et sw=4 sts=4: