iliaa Sat Aug 9 12:48:30 2003 EDT
Added files: (Branch: PHP_4_3)
/php-src/tests/lang bug24951.phpt
/php-src/ext/standard/tests/array bug24980.phpt
Modified files:
/php-src/ext/standard/tests/math bug24142.phpt
/php-src/ext/standard/tests/serialize bug24063.phpt
Log:
MFH: Added/improved tests for bugs 24142, 24063, 24951, 24980
Index: php-src/ext/standard/tests/math/bug24142.phpt
diff -u php-src/ext/standard/tests/math/bug24142.phpt:1.1.2.2
php-src/ext/standard/tests/math/bug24142.phpt:1.1.2.3
--- php-src/ext/standard/tests/math/bug24142.phpt:1.1.2.2 Mon Jun 16 16:00:11
2003
+++ php-src/ext/standard/tests/math/bug24142.phpt Sat Aug 9 12:48:30 2003
@@ -1,10 +1,20 @@
--TEST--
Bug #24142 (round() problems)
--FILE--
-<?php // $Id: bug24142.phpt,v 1.1.2.2 2003/06/16 20:00:11 sniper Exp $ vim600:syn=php
-echo round(5.045, 2). "\n";
-echo round(5.055, 2). "\n";
+<?php // $Id: bug24142.phpt,v 1.1.2.3 2003/08/09 16:48:30 iliaa Exp $ vim600:syn=php
+$v = 0.005;
+for ($i = 1; $i < 10; $i++) {
+ echo "round({$v}, 2) -> ".round($v, 2)."\n";
+ $v += 0.01;
+}
?>
--EXPECT--
-5.05
-5.06
+round(0.005, 2) -> 0.01
+round(0.015, 2) -> 0.02
+round(0.025, 2) -> 0.03
+round(0.035, 2) -> 0.04
+round(0.045, 2) -> 0.05
+round(0.055, 2) -> 0.06
+round(0.065, 2) -> 0.07
+round(0.075, 2) -> 0.08
+round(0.085, 2) -> 0.09
Index: php-src/ext/standard/tests/serialize/bug24063.phpt
diff -u php-src/ext/standard/tests/serialize/bug24063.phpt:1.1.2.1
php-src/ext/standard/tests/serialize/bug24063.phpt:1.1.2.2
--- php-src/ext/standard/tests/serialize/bug24063.phpt:1.1.2.1 Sun Jun 29 21:05:02
2003
+++ php-src/ext/standard/tests/serialize/bug24063.phpt Sat Aug 9 12:48:30 2003
@@ -5,10 +5,19 @@
precision=12
--FILE--
<?php
-$f = 1.0e-6;
-$s = serialize($f);
-var_dump($s, unserialize($s));
+$v = 1;
+for ($i = 1; $i < 10; $i++) {
+ $v /= 10;
+ echo "{$v} ".unserialize(serialize($v))."\n";
+}
?>
--EXPECT--
-string(9) "d:1.0E-6;"
-float(1.0E-6)
+0.1 0.1
+0.01 0.01
+0.001 0.001
+0.0001 0.0001
+1E-05 1E-05
+1E-06 1E-06
+1E-07 1E-07
+1E-08 1E-08
+1E-09 1E-09
Index: php-src/tests/lang/bug24951.phpt
+++ php-src/tests/lang/bug24951.phpt
--TEST--
Bug #24951 (ob_flush() destroys output handler)
--FILE--
<?php
function test($s, $mode)
{
return (($mode & PHP_OUTPUT_HANDLER_START)?"[":"") . $s . (($mode &
PHP_OUTPUT_HANDLER_END)?"]\n":"");
}
function t1()
{
ob_start("test");
echo "Hello from t1 1 ";
echo "Hello from t1 2 ";
ob_end_flush();
}
function t2()
{
ob_start("test");
echo "Hello from t2 1 ";
ob_flush();
echo "Hello from t2 2 ";
ob_end_flush();
}
function t3()
{
ob_start("test");
echo "Hello from t3 1 ";
ob_clean();
echo "Hello from t3 2 ";
ob_end_flush();
}
t1(); echo "\n";
t2(); echo "\n";
t3(); echo "\n";
?>
--EXPECT--
[Hello from t1 1 Hello from t1 2 ]
[Hello from t2 1 Hello from t2 2 ]
Hello from t3 2 ]
Index: php-src/ext/standard/tests/array/bug24980.phpt
+++ php-src/ext/standard/tests/array/bug24980.phpt
--TEST--
Bug #24980 (array_reduce() uses first element as default running total)
--FILE--
<?php
/* test #1: numeric data */
function add_up($running_total, $current_value)
{
echo "running_total is ".(int)$running_total.", current_value is
{$current_value}\n";
$running_total += $current_value * $current_value;
return $running_total;
}
$numbers = array (2,3,5,7);
$total = array_reduce($numbers, 'add_up');
print "Total is $total\n";
/* test #2: string data */
$a = array("a", "b", "c");
function foo ($a, $b)
{
return $a . $b;
}
var_dump(array_reduce($a, "foo"));
/* test #3: basic test (used to leak memory) */
function rsum($v, $w)
{
$v += $w;
return $v;
}
function rmul($v, $w)
{
$v *= $w;
return $v;
}
$a = array(1, 2, 3, 4, 5);
$x = array();
$b = array_reduce($a, "rsum");
$c = array_reduce($a, "rmul", 10);
$d = array_reduce($x, "rsum", 1);
var_dump($b, $c, $d);
?>
--EXPECT--
running_total is 0, current_value is 2
running_total is 4, current_value is 3
running_total is 13, current_value is 5
running_total is 38, current_value is 7
Total is 87
string(3) "abc"
int(15)
int(1200)
int(1)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php