File: 01_basic.t

package info (click to toggle)
libterm-size-perl-perl 0.029-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 136 kB
  • ctags: 36
  • sloc: perl: 150; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 1,171 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

use Test::More tests => 17;
#use Test::More no_plan => 1;

BEGIN { use_ok('Term::Size::Perl'); }

my @handles = (
    # name args handle
    [ 'implicit STDIN', [], *STDIN ], # default: implicit STDIN
    [ 'STDIN', [*STDIN], *STDIN ],
    [ 'STDERR', [*STDERR], *STDERR ],
    [ 'STDOUT', [*STDOUT], *STDOUT ],
);

for (@handles) {
    my $h_name = $_->[0];
    my @args = @{$_->[1]};
    my $h = $_->[2];

SKIP: {
    skip "$h_name is not tty", 4 unless -t $h;

    my @chars = Term::Size::Perl::chars @args;
    is(scalar @chars, 2, "$h_name: chars return (cols, rows) - $h_name");

    my $cols = Term::Size::Perl::chars @args;
    is($cols, $chars[0], "$h_name: chars return cols");

    my @pixels = Term::Size::Perl::pixels @args;
    is(scalar @pixels, 2, "$h_name: pixels return (x, y)");

    my $x = Term::Size::Perl::pixels @args;
    is($x, $pixels[0], "$h_name: pixels return x");

}

}

if (-t STDIN) {
    # this is not at test, only a show-off
    my @chars = Term::Size::Perl::chars;
    my @pixels = Term::Size::Perl::pixels;
    diag("This terminal is $chars[0]x$chars[1] characters,"),
    diag("             and $pixels[0]x$pixels[1] pixels.");

}