diff --git a/t/01logon.t b/t/01logon.t index deda93f..42b5011 100644 --- a/t/01logon.t +++ b/t/01logon.t @@ -1,3 +1,4 @@ +use strict; use Test; BEGIN { plan tests => 5 } use DBI; diff --git a/t/03insert.t b/t/03insert.t index c10d791..160d1a8 100644 --- a/t/03insert.t +++ b/t/03insert.t @@ -1,3 +1,4 @@ +use strict; use Test; use DBI; BEGIN { plan tests => 11 } diff --git a/t/04select.t b/t/04select.t index ebc1f93..a7427bc 100644 --- a/t/04select.t +++ b/t/04select.t @@ -1,3 +1,4 @@ +use strict; use Test; BEGIN { plan tests => 21 } use DBI; diff --git a/t/05tran.t b/t/05tran.t index d297e06..27f717f 100644 --- a/t/05tran.t +++ b/t/05tran.t @@ -1,3 +1,4 @@ +use strict; use Test; BEGIN { plan tests => 2 } use DBI; diff --git a/t/06error.t b/t/06error.t index 8269394..b188cc6 100644 --- a/t/06error.t +++ b/t/06error.t @@ -1,3 +1,4 @@ +use strict; use Test; BEGIN { plan tests => 2 } use DBI; diff --git a/t/07busy.t b/t/07busy.t index 68d06cd..2a23f41 100644 --- a/t/07busy.t +++ b/t/07busy.t @@ -1,5 +1,6 @@ #!perl +use strict; use Test; BEGIN { plan tests => 8 } use DBI; diff --git a/t/10dsnlist.t b/t/10dsnlist.t index ef28d2c..36ffe0e 100644 --- a/t/10dsnlist.t +++ b/t/10dsnlist.t @@ -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"; diff --git a/t/12create_collation.t b/t/12create_collation.t index 2f9aea1..f343e6a 100644 --- a/t/12create_collation.t +++ b/t/12create_collation.t @@ -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; diff --git a/t/13progress_handler.t b/t/13progress_handler.t index 0caa7b8..ff46feb 100644 --- a/t/13progress_handler.t +++ b/t/13progress_handler.t @@ -1,3 +1,4 @@ +use strict; use Test; BEGIN { plan tests => 3; } use DBI; diff --git a/t/30insertfetch.t b/t/30insertfetch.t index 3674f2f..160577b 100644 --- a/t/30insertfetch.t +++ b/t/30insertfetch.t @@ -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()) { # diff --git a/t/40bindparam.t b/t/40bindparam.t index 4c144a9..8ff7553 100644 --- a/t/40bindparam.t +++ b/t/40bindparam.t @@ -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 diff --git a/t/40blobs.t b/t/40blobs.t index 738d6ac..98b614d 100644 --- a/t/40blobs.t +++ b/t/40blobs.t @@ -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') { diff --git a/t/40blobtext.t b/t/40blobtext.t index 2cb1e3d..c398ec7 100644 --- a/t/40blobtext.t +++ b/t/40blobtext.t @@ -1,5 +1,6 @@ #!/usr/bin/perl -w +use strict; use Test; BEGIN { plan tests => 26 } use DBI; diff --git a/t/40listfields.t b/t/40listfields.t index cb523fb..353a4aa 100644 --- a/t/40listfields.t +++ b/t/40listfields.t @@ -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"; } } diff --git a/t/40nulls.t b/t/40nulls.t index 8a03ab6..bada335 100644 --- a/t/40nulls.t +++ b/t/40nulls.t @@ -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 diff --git a/t/40numrows.t b/t/40numrows.t index 605623a..ae3e45e 100644 --- a/t/40numrows.t +++ b/t/40numrows.t @@ -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 diff --git a/t/40prepcached.t b/t/40prepcached.t index 7af923c..1f34a15 100644 --- a/t/40prepcached.t +++ b/t/40prepcached.t @@ -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 diff --git a/t/50chopblanks.t b/t/50chopblanks.t index 75e4b51..d577ee6 100644 --- a/t/50chopblanks.t +++ b/t/50chopblanks.t @@ -5,6 +5,7 @@ # This driver should check whether 'ChopBlanks' works. # +use strict; # # Make -w happy diff --git a/t/50commit.t b/t/50commit.t index 9e2ae94..21f9dbf 100644 --- a/t/50commit.t +++ b/t/50commit.t @@ -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) diff --git a/t/60metadata.t b/t/60metadata.t index ec4b17d..f20bb13 100644 --- a/t/60metadata.t +++ b/t/60metadata.t @@ -1,3 +1,4 @@ +use strict; use Test; BEGIN { plan tests => 27 } use DBI; diff --git a/t/90cppcomments.t b/t/90cppcomments.t index e45b3e0..c5d5c4b 100644 --- a/t/90cppcomments.t +++ b/t/90cppcomments.t @@ -1,3 +1,4 @@ +use strict; use Test; use DBI; use Fatal qw(open); diff --git a/t/99cleanup.t b/t/99cleanup.t index 04003a6..d848f29 100644 --- a/t/99cleanup.t +++ b/t/99cleanup.t @@ -1,3 +1,4 @@ +use strict; use Test; BEGIN { plan tests => 2 } ok(-e 'foo'); diff --git a/t/SQLite.dbtest b/t/SQLite.dbtest index dc6b3b4..6affda7 100644 --- a/t/SQLite.dbtest +++ b/t/SQLite.dbtest @@ -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(). diff --git a/t/ak-dbd.t b/t/ak-dbd.t index c415a86..7d095c2 100644 --- a/t/ak-dbd.t +++ b/t/ak-dbd.t @@ -6,6 +6,8 @@ # and modify/extend it. # +use strict; + $^W = 1; $| = 1;