File: 14_overload.t

package info (click to toggle)
libtext-table-perl 1.135-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 264 kB
  • sloc: perl: 906; makefile: 5
file content (27 lines) | stat: -rw-r--r-- 581 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
use strict;
use warnings;
no warnings "redefine";

use Test::More tests => 4;

use Text::Table;

my %res;
local *Text::Table::stringify = sub { return $res{called} = "1"; };
my $table = Text::Table->new;

$table->add(1,1);
# TEST
ok(! delete $res{called}, "add in void context doesn't stringify()");

$table->load([1,1]);
# TEST
ok(! delete $res{called}, "load in void context doesn't stringify()");

if ( $table ) {}
# TEST
ok(! delete $res{called}, "use as a boolean doesn't stringify()");

my $var = "$table";
# TEST
ok(delete $res{called}, "use as a string calls stringify()");