File: 11_Variable_Rule.t

package info (click to toggle)
libtext-table-perl 1.123-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 152 kB
  • ctags: 58
  • sloc: perl: 633; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 582 bytes parent folder | download
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
use strict;
use warnings;

use Test::More tests => 1;

use Text::Table;

### separators and rules
my $tb = Text::Table->new( \'||', 'aaa', \'|', 'bbb', \'|', 'ccc', \'||');

# TEST
is ($tb->rule(
        sub {
            my ($i, $len) = @_;

            return (($i == 0) ? ("X" x $len) : ($i == 2) ? ("Y" x $len) : 
                ("A" x $len))
            ;
        },
        sub { 
            my ($i, $len) = @_; 
            return (($i == 0) ? "|=" : ($i == 3) ? "=|" : "+");
        },
    ),
    "|=XXX+AAA+YYY=|\n",
    "Create a variable rule based on callbacks.",
);