⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 07kids.t

📁 SinFP是一种新的识别对方计算机操作系统类型的工具
💻 T
字号:
#!perl -wuse strict;use Test::More;use DBI;BEGIN {	plan skip_all => '$h->{Kids} attribute not supported for DBI::PurePerl'		if $DBI::PurePerl && $DBI::PurePerl; # doubled to avoid typo warning	plan tests => 20;}## ----------------------------------------------------------------------------## 07kids.t## ----------------------------------------------------------------------------# This test check the Kids and the ActiveKids attributes and how they act# in various situations.## Check the database handle's kids:#   - upon creation of handle#   - upon creation of statement handle#   - after execute of statement handle#   - after finish of statement handle#   - after destruction of statement handle# Check the driver handle's kids:#   - after creation of database handle#   - after disconnection of database handle#   - after destruction of database handle## ----------------------------------------------------------------------------# Connect to the example driver and create a database handlemy $dbh = DBI->connect('dbi:ExampleP:dummy', '', '',						   { 							 PrintError => 1,							 RaiseError => 0						   });# check our database handle to make sure its goodisa_ok($dbh, 'DBI::db');# check that it has no Kids or ActiveKids yetcmp_ok($dbh->{Kids}, '==', 0, '... database handle has 0 Kid(s) at start');cmp_ok($dbh->{ActiveKids}, '==', 0, '... database handle has 0 ActiveKid(s) at start');# create a scope for our $sth to live and die indo { 	# create a statement handle	my $sth = $dbh->prepare('select uid from ./');	# verify that it is a correct statement handle	isa_ok($sth, "DBI::st");	# check our Kids and ActiveKids after prepare	cmp_ok($dbh->{Kids}, '==', 1, '... database handle has 1 Kid(s) after $dbh->prepare');	cmp_ok($dbh->{ActiveKids}, '==', 0, '... database handle has 0 ActiveKid(s) after $dbh->prepare');	$sth->execute();	# check our Kids and ActiveKids after execute	cmp_ok($dbh->{Kids}, '==', 1, '... database handle has 1 Kid(s) after $sth->execute');	cmp_ok($dbh->{ActiveKids}, '==', 1, '... database handle has 1 ActiveKid(s) after $sth->execute');	$sth->finish();	# check our Kids and Activekids after finish	cmp_ok($dbh->{Kids}, '==', 1, '... database handle has 1 Kid(s) after $sth->finish');	cmp_ok($dbh->{ActiveKids}, '==', 0, '... database handle has 0 ActiveKid(s) after $sth->finish');};# now check it after the statement handle has been destroyedcmp_ok($dbh->{Kids}, '==', 0, '... database handle has 0 Kid(s) after $sth is destroyed');cmp_ok($dbh->{ActiveKids}, '==', 0, '... database handle has 0 ActiveKid(s) after $sth is destroyed');# get the database handles driver Drivermy $drh = $dbh->{Driver};# check that is it a correct driver handleisa_ok($drh, "DBI::dr");# check the driver's Kids and ActiveKids cmp_ok( $drh->{Kids}, '==', 1, '... driver handle has 1 Kid(s)');cmp_ok( $drh->{ActiveKids}, '==', 1, '... driver handle has 1 ActiveKid(s)');$dbh->disconnect;# check the driver's Kids and ActiveKids after $dbh->disconnectcmp_ok( $drh->{Kids}, '==', 1, '... driver handle has 1 Kid(s) after $dbh->disconnect');cmp_ok( $drh->{ActiveKids}, '==', 0, '... driver handle has 0 ActiveKid(s) after $dbh->disconnect');undef $dbh;ok(!defined($dbh), '... lets be sure that $dbh is not undefined');# check the driver's Kids and ActiveKids after undef $dbhcmp_ok( $drh->{Kids}, '==', 0, '... driver handle has 0 Kid(s) after undef $dbh');cmp_ok( $drh->{ActiveKids}, '==', 0, '... driver handle has 0 ActiveKid(s) after undef $dbh');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -