Skip to content

Commit 2a1c15a

Browse files
committed
Explicit commenting of test cases
1 parent e19b5ab commit 2a1c15a

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

t/xx_sponge.t

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,44 @@ use Test::More tests => 17;
99
use Storable qw(dclone);
1010
use DBI qw(:sql_types);
1111

12-
our @ROWS = (['foo', undef, 'bazooka'],
13-
['foolery', 'bar', undef ],
14-
[undef, 'barrowman', 'baz' ]);
12+
# our reference table:
13+
#
14+
# A1 B1 C2
15+
# ------- --------- -------
16+
# foo NULL bazooka
17+
# foolery bar NULL
18+
# NULL barrowman baz
19+
#
20+
21+
our @NAMES = ( 'A0', 'B1', 'C2' );
22+
our @ROWS = (['foo', undef, 'bazooka'],
23+
['foolery', 'bar', undef ],
24+
[undef, 'barrowman', 'baz' ]);
1525

1626
my $dbh = DBI->connect("dbi:Sponge:", '', '');
1727
ok($dbh, "connect(dbi:Sponge:) succeeds");
1828

1929
my $sth = $dbh->prepare("simple, correct sponge", {
2030
rows => dclone( \@ROWS ),
21-
NAME => [ qw(A0 B1 C2) ],
31+
NAME => [ @NAMES ],
2232
});
2333

2434
ok($sth, "prepare() of 3x3 result succeeded");
2535
is_deeply($sth->{NAME}, ['A0', 'B1', 'C2'], "column NAMEs as expected");
2636
is_deeply($sth->{TYPE}, [SQL_VARCHAR, SQL_VARCHAR, SQL_VARCHAR],
2737
"column TYPEs default to SQL_VARCHAR");
38+
#
39+
# Old versions of DBD-Sponge defaulted PRECISION (data "length") to
40+
# length of the field _names_ rather than the length of the _data_.
41+
#
2842
is_deeply($sth->{PRECISION}, [7, 9, 7],
2943
"column PRECISION matches lengths of longest field data");
3044
is_deeply($sth->fetch(), $ROWS[0], "first row fetch as expected");
3145
is_deeply($sth->fetch(), $ROWS[1], "second row fetch as expected");
3246
is_deeply($sth->fetch(), $ROWS[2], "third row fetch as expected");
3347
ok(!defined($sth->fetch()), "fourth fetch returns undef");
3448

35-
49+
# Test that DBD-Sponge preserves bogus user-supplied attributes
3650
$sth = $dbh->prepare('user-supplied silly TYPE and PRECISION', {
3751
rows => dclone( \@ROWS ),
3852
NAME => [qw( first_col second_col third_col )],

0 commit comments

Comments
 (0)