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
|
#!./perl -w
use strict;
use warnings;
use Data::Dumper;
use Test::More tests => 4;
my ($a, $b, $obj);
my (@values, @names);
my (@newvalues, $objagain, %newvalues);
$a = 'alpha';
$b = 'beta';
$obj = Data::Dumper->new([$a,$b], [qw(a b)]);
@values = $obj->Values;
is_deeply(\@values, [$a,$b], "Values() returned expected list");
@newvalues = ( qw| gamma delta epsilon | );
$objagain = $obj->Values(\@newvalues);
is($objagain, $obj, "Values returned same object");
is_deeply($objagain->{todump}, \@newvalues,
"Able to use Values() to set values to be dumped");
$obj = Data::Dumper->new([$a,$b], [qw(a b)]);
%newvalues = ( gamma => 'delta', epsilon => 'zeta' );
eval { @values = $obj->Values(\%newvalues); };
like($@, qr/Argument to Values, if provided, must be array ref/,
"Got expected error message: bad argument to Values()");
|