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

📄 30_overloaded.t

📁 SinFP是一种新的识别对方计算机操作系统类型的工具
💻 T
📖 第 1 页 / 共 2 页
字号:
$n++;if ($set->Min() == 1){print "ok $n\n";} else {print "not ok $n\n";}$n++;if ($set->Max() == 1){print "ok $n\n";} else {print "not ok $n\n";}$n++;if ($set){print "ok $n\n";} else {print "not ok $n\n";}$n++;if (--$set){print "ok $n\n";} else {print "not ok $n\n";}$n++;if (abs($set) == 1){print "ok $n\n";} else {print "not ok $n\n";}$n++;if ($set->Min() == 0){print "ok $n\n";} else {print "not ok $n\n";}$n++;if ($set->Max() == 0){print "ok $n\n";} else {print "not ok $n\n";}$n++;if ($set){print "ok $n\n";} else {print "not ok $n\n";}$n++;unless (--$set){print "ok $n\n";} else {print "not ok $n\n";}$n++;if (abs($set) == 0){print "ok $n\n";} else {print "not ok $n\n";}$n++;if ($set->Min() >= 500){print "ok $n\n";} else {print "not ok $n\n";}$n++;if ($set->Max() < 0){print "ok $n\n";} else {print "not ok $n\n";}$n++;unless ($set){print "ok $n\n";} else {print "not ok $n\n";}$n++;if (--$set){print "ok $n\n";} else {print "not ok $n\n";}$n++;if (abs($set) == 500){print "ok $n\n";} else {print "not ok $n\n";}$n++;if ($set->Min() == 0){print "ok $n\n";} else {print "not ok $n\n";}$n++;if ($set->Max() == 499){print "ok $n\n";} else {print "not ok $n\n";}$n++;if ($set){print "ok $n\n";} else {print "not ok $n\n";}$n++;unless (++$set){print "ok $n\n";} else {print "not ok $n\n";}$n++;if (abs($set) == 0){print "ok $n\n";} else {print "not ok $n\n";}$n++;if ($set->Min() >= 500){print "ok $n\n";} else {print "not ok $n\n";}$n++;if ($set->Max() < 0){print "ok $n\n";} else {print "not ok $n\n";}$n++;unless ($set){print "ok $n\n";} else {print "not ok $n\n";}$n++;$set->Empty();unless ($set++){print "ok $n\n";} else {print "not ok $n\n";}$n++;$set->Empty();if (++$set){print "ok $n\n";} else {print "not ok $n\n";}$n++;$set->Empty();unless ($set--){print "ok $n\n";} else {print "not ok $n\n";}$n++;$set->Empty();if (--$set){print "ok $n\n";} else {print "not ok $n\n";}$n++;$set->Empty();if (($set++)->Norm() == 0){print "ok $n\n";} else {print "not ok $n\n";}$n++;$set->Empty();if ((++$set)->Norm() == 1){print "ok $n\n";} else {print "not ok $n\n";}$n++;$set->Empty();if (($set--)->Norm() == 0){print "ok $n\n";} else {print "not ok $n\n";}$n++;$set->Empty();if ((--$set)->Norm() == 500){print "ok $n\n";} else {print "not ok $n\n";}$n++;if (($primes cmp $odd) == -1){print "ok $n\n";} else {print "not ok $n\n";}$n++;if (($odd cmp $primes) == 1){print "ok $n\n";} else {print "not ok $n\n";}$n++;if ((($odd + $even) cmp $full) == 0){print "ok $n\n";} else {print "not ok $n\n";}$n++;if ((($odd * $even) cmp 2) == 0){print "ok $n\n";} else {print "not ok $n\n";}$n++;if ((2 cmp ($odd * $even)) == 0){print "ok $n\n";} else {print "not ok $n\n";}$n++;if (($odd ^= 2) == ($full - $even)){print "ok $n\n";} else {print "not ok $n\n";}$n++;# systematic tests:$temp = $odd + $even;if ($temp == $full){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp->Copy($odd);if ($temp == $odd){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp += $even;if ($temp == $full){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp = $odd + 2;if (abs($temp) == abs($odd) + 1){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp->Copy($odd);$temp += 4;if (abs($temp) == abs($odd) + 1){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp = $odd | $even;if ($temp == $full){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp->Copy($odd);if ($temp == $odd){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp |= $even;if ($temp == $full){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp = $odd | 2;if (abs($temp) == abs($odd) + 1){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp->Copy($odd);$temp |= 4;if (abs($temp) == abs($odd) + 1){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp = $full - $even;if ($temp == $odd){print "ok $n\n";} else {print "not ok $n\n";}$n++;$empty = $temp->new($limit+1);$temp -= $odd;if ($temp == $empty){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp = $even - 2;if (abs($temp) == abs($even) - 1){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp->Copy($even);if ($temp == $even){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp -= 8;if (abs($temp) == abs($even) - 1){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp = $primes * $even;if ($temp == 2){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp->Copy($primes);if ($temp == $primes){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp *= $even;if ($temp == 2){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp = $primes * 2;if ($temp == 2){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp->Copy($primes);$temp *= 2;if ($temp == 2){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp = $primes & $even;if ($temp == 2){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp->Copy($primes);if ($temp == $primes){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp &= $even;if ($temp == 2){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp = $primes & 2;if ($temp == 2){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp->Copy($primes);$temp &= 2;if ($temp == 2){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp = $odd ^ $even;if ($temp == $full){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp->Copy($odd);if ($temp == $odd){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp ^= $even;if ($temp == $full){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp = $odd ^ 2;if (abs($temp) == abs($odd) + 1){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp->Copy($odd);$temp ^= 4;if (abs($temp) == abs($odd) + 1){print "ok $n\n";} else {print "not ok $n\n";}$n++;if (($odd cmp $even) == -1){print "ok $n\n";} else {print "not ok $n\n";}$n++;if (($even cmp $odd) == 1){print "ok $n\n";} else {print "not ok $n\n";}$n++;$temp ^= 4;if ($temp == $odd){print "ok $n\n";} else {print "not ok $n\n";}$n++;if (($temp cmp $odd) == 0){print "ok $n\n";} else {print "not ok $n\n";}$n++;if (($odd cmp $temp) == 0){print "ok $n\n";} else {print "not ok $n\n";}$n++;if ($odd eq $temp){print "ok $n\n";} else {print "not ok $n\n";}$n++;if (!($odd ne $temp)){print "ok $n\n";} else {print "not ok $n\n";}$n++;if (!($primes eq $odd)){print "ok $n\n";} else {print "not ok $n\n";}$n++;if ($primes ne $odd){print "ok $n\n";} else {print "not ok $n\n";}$n++;if ($odd lt $even){print "ok $n\n";} else {print "not ok $n\n";}$n++;if ($odd le $even){print "ok $n\n";} else {print "not ok $n\n";}$n++;if (!($even lt $odd)){print "ok $n\n";} else {print "not ok $n\n";}$n++;if (!($even le $odd)){print "ok $n\n";} else {print "not ok $n\n";}$n++;if (!($odd gt $even)){print "ok $n\n";} else {print "not ok $n\n";}$n++;if (!($odd ge $even)){print "ok $n\n";} else {print "not ok $n\n";}$n++;if ($even gt $odd){print "ok $n\n";} else {print "not ok $n\n";}$n++;if ($even ge $odd){print "ok $n\n";} else {print "not ok $n\n";}$n++;# wrong parameter checks:$set = Bit::Vector->new(500);if ($set->Norm() == 0){print "ok $n\n";} else {print "not ok $n\n";}$n++;$set->Fill();if ($set->Norm() == 500){print "ok $n\n";} else {print "not ok $n\n";}$n++;foreach $operator (keys %operator_list){    $parms = $operator_list{$operator};    $obj = 0x000E9CE0;    $fake = \$obj;    if (ref($fake) eq 'SCALAR')    {print "ok $n\n";} else {print "not ok $n\n";}    $n++;    &test_fake($parms);    $fake = [ ];    if (ref($fake) eq 'ARRAY')    {print "ok $n\n";} else {print "not ok $n\n";}    $n++;    &test_fake($parms);    $fake = { };    if (ref($fake) eq 'HASH')    {print "ok $n\n";} else {print "not ok $n\n";}    $n++;    &test_fake($parms);    $fake = sub { };    if (ref($fake) eq 'CODE')    {print "ok $n\n";} else {print "not ok $n\n";}    $n++;    &test_fake($parms);    $obj = { };    $fake = \$obj;    if (ref($fake) eq 'REF')    {print "ok $n\n";} else {print "not ok $n\n";}    $n++;    &test_fake($parms);}# bit shift operator tests:foreach $bits (0,1,2,3,4,16,32,61,97,256,257,499,512){    $shift = ($primes << $bits);    &verify($bits);    $shift = $primes->Clone();    $shift <<= $bits;    &verify($bits);    $shift = ($primes >> $bits);    &verify(-$bits);    $shift = $primes->Clone();    $shift >>= $bits;    &verify(-$bits);}eval { $shift = (0 << $primes); };if ($@ =~ /\billegal reversed operands in overloaded '<<' operator\b/){print "ok $n\n";} else {print "not ok $n\n";}$n++;eval { $shift = (1 << $primes); };if ($@ =~ /\billegal reversed operands in overloaded '<<' operator\b/){print "ok $n\n";} else {print "not ok $n\n";}$n++;eval { $shift = (0 >> $primes); };if ($@ =~ /\billegal reversed operands in overloaded '>>' operator\b/){print "ok $n\n";} else {print "not ok $n\n";}$n++;eval { $shift = (1 >> $primes); };if ($@ =~ /\billegal reversed operands in overloaded '>>' operator\b/){print "ok $n\n";} else {print "not ok $n\n";}$n++;eval { $shift = (0 x $primes); };if ($@ =~ /\billegal reversed operands in overloaded 'x' operator\b/){print "ok $n\n";} else {print "not ok $n\n";}$n++;eval { $shift = (1 x $primes); };if ($@ =~ /\billegal reversed operands in overloaded 'x' operator\b/){print "ok $n\n";} else {print "not ok $n\n";}$n++;exit;sub test_fake{    my($parms) = @_;    my($op,$message);    $op = $operator;    $op =~ s/^[a-wyz]+$/cmp/;    $message = quotemeta("illegal operand type in overloaded '$op' operator");    if ($parms == 1)    {        $action = "\$set $operator \$fake";        eval "$action";        if ($@ =~ /$message/)        {print "ok $n\n";} else {print "not ok $n\n";}        $n++;    }    elsif ($parms == 2)    {        $action = "\$temp = \$set $operator \$fake";        eval "$action";        if ($@ =~ /$message/)        {print "ok $n\n";} else {print "not ok $n\n";}        $n++;        $action = "\$temp = \$fake $operator \$set";        eval "$action";        if ($@ =~ /$message/)        {print "ok $n\n";} else {print "not ok $n)\n";}        $n++;    }    else { }}sub verify{    my($offset) = @_;    my($i,$j);    for ( $i = 0; $i <= $limit; $i++ )    {        if ($primes->contains($i))        {            $j = $i + $offset;            if (($j >= 0) && ($j <= $limit))            {                if ($shift->contains($j))                {print "ok $n\n";} else {print "not ok $n\n";}                $n++;            }        }        if ($shift->contains($i))        {            $j = $i - $offset;            if (($j >= 0) && ($j <= $limit))            {                if ($primes->contains($j))                {print "ok $n\n";} else {print "not ok $n\n";}                $n++;            }        }    }}__END__

⌨️ 快捷键说明

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