1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 14:19:10 -04:00

DBD-SQLite: added "use strict"s (and some "use vars"s and "my"s) to the tests

This commit is contained in:
Kenichi Ishigaki 2009-04-02 11:04:42 +00:00
parent 9bdfb9c0bb
commit fbedeb1a93
24 changed files with 68 additions and 22 deletions

View file

@ -1,3 +1,4 @@
use strict;
use Test;
BEGIN { plan tests => 5 }
use DBI;

View file

@ -1,3 +1,4 @@
use strict;
use Test;
use DBI;
BEGIN { plan tests => 11 }

View file

@ -1,3 +1,4 @@
use strict;
use Test;
BEGIN { plan tests => 21 }
use DBI;

View file

@ -1,3 +1,4 @@
use strict;
use Test;
BEGIN { plan tests => 2 }
use DBI;

View file

@ -1,3 +1,4 @@
use strict;
use Test;
BEGIN { plan tests => 2 }
use DBI;

View file

@ -1,5 +1,6 @@
#!perl
use strict;
use Test;
BEGIN { plan tests => 8 }
use DBI;

View file

@ -6,13 +6,15 @@
# after listdsn.
#
use strict;
use vars qw($test_dsn $test_user $test_password $mdriver $state);
#
# Include lib.pl
#
require DBI;
$mdriver = "";
foreach $file ("lib.pl", "t/lib.pl", "DBD-~DBD_DRIVER~/t/lib.pl") {
foreach my $file ("lib.pl", "t/lib.pl", "DBD-~DBD_DRIVER~/t/lib.pl") {
do $file; if ($@) { print STDERR "Error while executing lib.pl: $@\n";
exit 10;
}
@ -39,18 +41,18 @@ sub ServerError() {
#
# Main loop; leave this untouched, put tests into the loop
#
my @dsn;
while (Testing()) {
# Check if the server is awake.
$dbh = undef;
my $dbh = undef;
Test($state or ($dbh = DBI->connect($test_dsn, $test_user,
$test_password)))
or ServerError();
Test($state or (@dsn = DBI->data_sources($mdriver)) >= 0);
if (!$state) {
my $d;
print "List of $mdriver data sources:\n";
foreach $d (@dsn) {
foreach my $d (@dsn) {
print " $d\n";
}
print "List ends.\n";
@ -67,8 +69,7 @@ while (Testing()) {
"DBI:$mdriver:test;localhost",
"DBI:$mdriver:database=test;host=localhost");
}
my($dsn);
foreach $dsn (@dsnList) {
foreach my $dsn (@dsnList) {
Test($state or ($dbh = DBI->connect($dsn, $test_user,
$test_password)))
or print "Cannot connect to DSN $dsn: ${DBI::errstr}\n";

View file

@ -6,6 +6,7 @@ BEGIN {
}
}
use strict;
use Test::More tests => 8;
use DBI;
use Encode qw/decode/;
@ -27,7 +28,7 @@ my @words = qw/berger Berg
fétu fête fève ferme/;
# my @words_utf8 = map {decode("iso-8859-1", $_)} @words;
@words_utf8 = @words;
my @words_utf8 = @words;
utf8::upgrade($_) foreach @words_utf8;

View file

@ -1,3 +1,4 @@
use strict;
use Test;
BEGIN { plan tests => 3; }
use DBI;

View file

@ -4,6 +4,9 @@
#
# This is a simple insert/fetch test.
#
use strict;
use vars qw($test_dsn $test_user $test_password $mdriver $state);
$^W = 1;
#
@ -19,7 +22,7 @@ $test_password = '';
#
use DBI;
$mdriver = "";
foreach $file ("lib.pl", "t/lib.pl", "DBD-~DBD_DRIVER~/t/lib.pl") {
foreach my $file ("lib.pl", "t/lib.pl", "DBD-~DBD_DRIVER~/t/lib.pl") {
do $file; if ($@) { print STDERR "Error while executing lib.pl: $@\n";
exit 10;
}
@ -42,6 +45,7 @@ sub ServerError() {
# Main loop; leave this untouched, put tests after creating
# the new table.
#
my ($dbh, $def, $table, $cursor);
while (Testing()) {
#

View file

@ -6,6 +6,8 @@
# and modify/extend it.
#
use strict;
use vars qw($test_dsn $test_user $test_password $mdriver $state);
$^W = 1;
#
@ -22,7 +24,7 @@ $test_password = '';
require DBI;
use vars qw($COL_NULLABLE);
$mdriver = "";
foreach $file ("lib.pl", "t/lib.pl") {
foreach my $file ("lib.pl", "t/lib.pl") {
do $file; if ($@) { print STDERR "Error while executing lib.pl: $@\n";
exit 10;
}
@ -57,6 +59,7 @@ if (!defined(&SQL_INTEGER)) {
# Main loop; leave this untouched, put tests after creating
# the new table.
#
my ($dbh, $def, $table, $cursor, $id, $name, $ref);
while (Testing()) {
#
# Connect to the database

View file

@ -6,6 +6,8 @@
# is expected to work correctly.
#
use strict;
use vars qw($test_dsn $test_user $test_password $mdriver $dbdriver $state);
$^W = 1;
@ -24,7 +26,7 @@ $test_password = '';
use DBI qw(:sql_types);
$mdriver = "";
foreach $file ("lib.pl", "t/lib.pl") {
foreach my $file ("lib.pl", "t/lib.pl") {
do $file; if ($@) { print STDERR "Error while executing lib.pl: $@\n";
exit 10;
}
@ -74,6 +76,7 @@ sub ShowBlob($) {
# Main loop; leave this untouched, put tests after creating
# the new table.
#
my ($dbh, $table, $cursor, $row);
while (Testing()) {
#
# Connect to the database
@ -90,7 +93,7 @@ while (Testing()) {
or DbiError($dbh->error, $dbh->errstr);
my($def);
foreach $size (128) {
foreach my $size (128) {
#
# Create a new table
#
@ -110,10 +113,10 @@ while (Testing()) {
my ($blob, $qblob) = "";
if (!$state) {
my $b = "";
for ($j = 0; $j < 256; $j++) {
for (my $j = 0; $j < 256; $j++) {
$b .= chr($j);
}
for ($i = 0; $i < $size; $i++) {
for (my $i = 0; $i < $size; $i++) {
$blob .= $b;
}
if ($mdriver eq 'pNET') {

View file

@ -1,5 +1,6 @@
#!/usr/bin/perl -w
use strict;
use Test;
BEGIN { plan tests => 26 }
use DBI;

View file

@ -5,6 +5,8 @@
# This is a test for statement attributes being present appropriately.
#
use strict;
use vars qw($test_dsn $test_user $test_password $mdriver $dbdriver $state $COL_KEY $COL_NULLABLE);
#
# Make -w happy
@ -22,7 +24,7 @@ use DBI;
use vars qw($verbose);
$dbdriver = "";
foreach $file ("lib.pl", "t/lib.pl") {
foreach my $file ("lib.pl", "t/lib.pl") {
do $file; if ($@) { print STDERR "Error while executing lib.pl: $@\n";
exit 10;
}
@ -32,7 +34,7 @@ foreach $file ("lib.pl", "t/lib.pl") {
}
@table_def = (
my @table_def = (
["id", "INTEGER", 4, $COL_KEY],
["name", "CHAR", 64, $COL_NULLABLE]
);
@ -51,6 +53,7 @@ sub ServerError() {
# Main loop; leave this untouched, put tests after creating
# the new table.
#
my ($dbh, $table, $def, $cursor, $ref);
while (Testing()) {
#
# Connect to the database
@ -90,7 +93,7 @@ while (Testing()) {
or DbiError($cursor->err, $cursor->errstr);
if (!$state && $verbose) {
print "Names:\n";
for ($i = 0; $i < @$ref; $i++) {
for (my $i = 0; $i < @$ref; $i++) {
print " ", $$ref[$i], "\n";
}
}
@ -103,7 +106,7 @@ while (Testing()) {
or DbiError($cursor->err, $cursor->errstr);
if (!$state && $verbose) {
print "Nullable:\n";
for ($i = 0; $i < @$ref; $i++) {
for (my $i = 0; $i < @$ref; $i++) {
print " ", ($$ref[$i] & $COL_NULLABLE) ? "yes" : "no", "\n";
}
}

View file

@ -5,6 +5,8 @@
# This is a test for correctly handling NULL values.
#
use strict;
use vars qw($test_dsn $test_user $test_password $mdriver $dbdriver $state);
#
# Make -w happy
@ -21,7 +23,7 @@ use DBI;
use vars qw($COL_NULLABLE);
$mdriver = "";
foreach $file ("lib.pl", "t/lib.pl") {
foreach my $file ("lib.pl", "t/lib.pl") {
do $file; if ($@) { print STDERR "Error while executing lib.pl: $@\n";
exit 10;
}
@ -44,6 +46,7 @@ sub ServerError() {
# Main loop; leave this untouched, put tests after creating
# the new table.
#
my ($dbh, $table, $def, $cursor, $rv);
while (Testing()) {
#
# Connect to the database

View file

@ -5,6 +5,9 @@
# This tests, whether the number of rows can be retrieved.
#
use strict;
use vars qw($test_dsn $test_user $test_password $mdriver $state);
$^W = 1;
$| = 1;
@ -22,7 +25,7 @@ $test_password = '';
#
use DBI;
$mdriver = "";
foreach $file ("lib.pl", "t/lib.pl", "DBD-~DBD_DRIVER~/t/lib.pl") {
foreach my $file ("lib.pl", "t/lib.pl", "DBD-~DBD_DRIVER~/t/lib.pl") {
do $file; if ($@) { print STDERR "Error while executing lib.pl: $@\n";
exit 10;
}
@ -56,6 +59,7 @@ sub TrueRows($) {
# Main loop; leave this untouched, put tests after creating
# the new table.
#
my ($dbh, $table, $def, $cursor, $numrows);
while (Testing()) {
#
# Connect to the database

View file

@ -6,6 +6,9 @@
# http://rt.cpan.org/Public/Bug/Display.html?id=15186
# About re-using statements with prepare_cached().
use strict;
use vars qw($test_dsn $test_user $test_password $mdriver $state);
$^W = 1;
$| = 1;
@ -23,7 +26,7 @@ $test_password = '';
#
use DBI;
$mdriver = "";
foreach $file ("lib.pl", "t/lib.pl", "DBD-~DBD_DRIVER~/t/lib.pl") {
foreach my $file ("lib.pl", "t/lib.pl", "DBD-~DBD_DRIVER~/t/lib.pl") {
do $file; if ($@) { print STDERR "Error while executing lib.pl: $@\n";
exit 10;
}
@ -57,6 +60,7 @@ sub TrueRows($) {
# Main loop; leave this untouched, put tests after creating
# the new table.
#
my ($dbh, $table, $def, $cursor, $sth);
while (Testing()) {
#
# Connect to the database

View file

@ -5,6 +5,7 @@
# This driver should check whether 'ChopBlanks' works.
#
use strict;
#
# Make -w happy

View file

@ -4,6 +4,10 @@
#
# This is testing the transaction support.
#
use strict;
use vars qw($test_dsn $test_user $test_password $mdriver $state);
$^W = 1;
@ -12,7 +16,7 @@ $^W = 1;
#
require DBI;
$mdriver = "";
foreach $file ("lib.pl", "t/lib.pl") {
foreach my $file ("lib.pl", "t/lib.pl") {
do $file; if ($@) { print STDERR "Error while executing lib.pl: $@\n";
exit 10;
}
@ -58,6 +62,7 @@ sub NumRows($$$) {
# Main loop; leave this untouched, put tests after creating
# the new table.
#
my ($dbh, $def, $table, $msg);
while (Testing()) {
#
# Connect to the database
@ -105,7 +110,7 @@ while (Testing()) {
Test($state or $dbh->do("INSERT INTO $table VALUES (1, 'Jochen')"))
or ErrMsgF("Failed to insert value: err %s, errstr %s.\n",
$dbh->err, $dbh->errstr);
my $msg;
Test($state or !($msg = NumRows($dbh, $table, 1)))
or ErrMsg($msg);
Test($state or $dbh->rollback)

View file

@ -1,3 +1,4 @@
use strict;
use Test;
BEGIN { plan tests => 27 }
use DBI;

View file

@ -1,3 +1,4 @@
use strict;
use Test;
use DBI;
use Fatal qw(open);

View file

@ -1,3 +1,4 @@
use strict;
use Test;
BEGIN { plan tests => 2 }
ok(-e 'foo');

View file

@ -4,6 +4,7 @@
#
# database specific definitions for a 'CSV' database
use strict;
# This function generates a mapping of ANSI type names to
# database specific type names; it is called by TableDefinition().

View file

@ -6,6 +6,8 @@
# and modify/extend it.
#
use strict;
$^W = 1;
$| = 1;