cvs: qaweb /regtests/test/suite/bin 4254.php arraysort.php recurse.php test_class_inheritance.php testarray.php testarray2.php testclassfunc.php
testobj.php testscanf.php

From: Date: Thu, 10 Aug 2000 21:14:18 +0000
Subject: cvs: qaweb /regtests/test/suite/bin 4254.php arraysort.php recurse.php test_class_inheritance.php testarray.php testarray2.php testclassfunc.php
testobj.php testscanf.php
Groups: php.qa 
Request: Send a blank email to php-qa+get-570@lists.php.net to get a copy of this message
jalal Thu Aug 10 14:14:18 2000 EDT Added files: /qaweb/regtests/test/suite/bin 4254.php arraysort.php recurse.php test_class_inheritance.php testarray.php testarray2.php testclassfunc.php testobj.php testscanf.php Log: Added test for bug 4254 Index: qaweb/regtests/test/suite/bin/4254.php +++ qaweb/regtests/test/suite/bin/4254.php <?php // test of bug 4254 // note, this bug is not (10 Jul 2000) fixed. // the ideal output is taken from a Perl script // running the same code. $var1 = 0x7FFFFFFF; $var2 = 0xFFFFFFFF; $var3 = 0x8FFFFFFF; $var4 = 0x9FFFFFFF; $var5 = 0x8FFFFFF1; $var6 = 0x80000001; $var7 = $var1 + 0x7FFFFFFF; $var8 = (0x08FFFFFF << 4); $var9 = intval("AFFFFFFF", 16); echo $var1; echo "\n"; echo $var2; echo "\n"; echo $var3; echo "\n"; echo $var4; echo "\n"; echo $var5; echo "\n"; echo $var6; echo "\n"; echo $var7; echo "\n"; echo $var8; echo "\n"; echo $var9; echo "\n"; ?> Index: qaweb/regtests/test/suite/bin/arraysort.php +++ qaweb/regtests/test/suite/bin/arraysort.php <?php $a = array("0", "1", "01", "02", "2"); sort($a); while (list ($key, $value) = each ($a)) { echo "$key: $value\n"; } echo "\n"; $a = array("0", "1", "01", "02", "2"); rsort($a); while (list ($key, $value) = each ($a)) { echo "$key: $value\n"; } $a = array("0", "1", "2", "01", "02", "03", "23","044"); // first test sort() echo "sort\n"; sort($a); while (list ($key, $value) = each ($a)) { echo "$key: $value\n"; } $a = array("0", "1", "2", "01", "02", "03", "23","044"); echo "rsort\n"; rsort($a); while (list ($key, $value) = each ($a)) { echo "$key: $value\n"; } $a = array("0", "1", "2", "01", "02", "03", "23","044"); echo "asort\n"; asort($a); while (list ($key, $value) = each ($a)) { echo "$key: $value\n"; } $a = array("0", "1", "2", "01", "02", "03", "23","044"); echo "arsort\n"; arsort($a); while (list ($key, $value) = each ($a)) { echo "$key: $value\n"; } $a = array("0", "1", "2", "01", "02", "03", "23","044"); echo "ksort\n"; ksort($a); while (list ($key, $value) = each ($a)) { echo "$key: $value\n"; } $a = array("able", "baker", "charlie", "ant", "Bill", "Rob", "2luv3","044"); // first test sort() echo "sort\n"; sort($a); while (list ($key, $value) = each ($a)) { echo "$key: $value\n"; } $a = array("able", "baker", "charlie", "ant", "Bill", "Rob", "2luv3","044"); echo "rsort\n"; rsort($a); while (list ($key, $value) = each ($a)) { echo "$key: $value\n"; } $a = array("able", "baker", "charlie", "ant", "Bill", "Rob", "2luv3","044"); echo "asort\n"; asort($a); while (list ($key, $value) = each ($a)) { echo "$key: $value\n"; } $a = array("able", "baker", "charlie", "ant", "Bill", "Rob", "2luv3","044"); echo "arsort\n"; arsort($a); while (list ($key, $value) = each ($a)) { echo "$key: $value\n"; } $a = array("able", "baker", "charlie", "ant", "Bill", "Rob", "2luv3","044"); echo "ksort\n"; ksort($a); while (list ($key, $value) = each ($a)) { echo "$key: $value\n"; } echo "\n\n"; ?> Index: qaweb/regtests/test/suite/bin/recurse.php +++ qaweb/regtests/test/suite/bin/recurse.php <? function factorial($n) { if ($n==0 || $n==1) { return 1; } else { return $n*factorial($n-1); } } for ($k=0; $k<10; $k++): for ($i=0,$sum=0; $i<50; $i++) { $sum = $sum+factorial($i); } endfor; print "\$sum=$sum\n"; Index: qaweb/regtests/test/suite/bin/test_class_inheritance.php +++ qaweb/regtests/test/suite/bin/test_class_inheritance.php <? class BaseClass { var $class_name = "BaseClass"; function BaseClass($value) { print "value is '$value'\n"; } function MyClassName() { return $this->class_name; } }; class ChildClass { var $class_name = "ChildClass"; function ChildClass($value, $new_value) { BaseClass::BaseClass($value); print "new value is '$new_value'\n"; } function MyClassName($a_value) { return BaseClass::MyClassName()." and the value is '$a_value'"; } }; $obj = new ChildClass("Test", "Another test"); print $obj->MyClassName("not interesting"); Index: qaweb/regtests/test/suite/bin/testarray.php +++ qaweb/regtests/test/suite/bin/testarray.php This is a small test.... <? /* * this is a multiline comment... */ for ($j=0; $j<=20; $j++) { for ($i[0][0]=0; $i[0][0]<10000; $i[0][0]++) { $i[1] += $i[0][0]; // this is a single line comment } } /* this is another multi line comment...****** / */ print $i[1]."\n"; Index: qaweb/regtests/test/suite/bin/testarray2.php +++ qaweb/regtests/test/suite/bin/testarray2.php <? for ($i="aaa"; $i<"bbb\nbbb"; $i++) { print $i; } Index: qaweb/regtests/test/suite/bin/testclassfunc.php +++ qaweb/regtests/test/suite/bin/testclassfunc.php <? class foo { function bar() { print "Hey there!\n"; } }; foo::bar(); Index: qaweb/regtests/test/suite/bin/testobj.php +++ qaweb/regtests/test/suite/bin/testobj.php <? define("endl","\n"); class foobar { function foobar() { $this->initialized = 1; } }; class barbara extends foobar { }; $name = "foobar"; $foo = new $name; // or die("Unable to construct foobar\n"); //print $foo->initialized; $boo = new barbara; print get_class($foo).endl; print get_parent_class($foo).endl; print get_class($boo).endl; print get_parent_class($boo).endl; print method_exists($foo,"foobar").endl; print method_exists($boo,"foobar").endl; print method_exists($boo,"barbara").endl; //$word = new COm("word.application"); //$word->visible = true; //sleep(5); //$word->quit(); Index: qaweb/regtests/test/suite/bin/testscanf.php +++ qaweb/regtests/test/suite/bin/testscanf.php <?php $testFileName = "../../input/scan_cases"; function print_value($val,$postfix="<br>") { if (is_array($val)) { for ($i = 0;$i< count($val);$i++) { echo $val[$i] . $postfix; } } else { echo $val . $postfix; } } function do_sscanf($string, $format) { $s = "sscanf(\"" . $string . ",\"" . $format ."\")."; echo "$s<br>"; $s = str_repeat("-", strlen($s)); echo "$s<br>"; $output = sscanf($string,$format); echo "Result : "; print_value( $output ); echo "$s<br><br>"; } function run_sscanf_test_cases() { global $testFileName; echo "<h3><em><br>Running Test Cases from $testFileName<br></em></h3>"; $arr = file( $testFileName ); for ($i=0;$i < count($arr);$i++) { $line_arr = explode("|",$arr[$i]); $format = $line_arr[0]; $string = $line_arr[1]; if (count($arr) > 2) { $comment = $line_arr[2]; } else { $comment = ""; } if ( empty($format) || empty($string) ) { continue; } print("<h4>** Case : $comment ******************************</h4>"); do_sscanf($string,$format); } } function simple_tests() { echo "Testing sscanf with standard ANSI syntax (values returned by reference)-<br>"; $decimal = -1; $string = ""; $hex = 0; $float = 0.0; $octal = 0.0; $int = -1; echo "<h3><em><br>Simple Test<br></em></h3>"; echo "sscanf('10','%d',&\$decimal) <br>"; echo "<br>BEFORE : <br> decimal = $decimal."; $foo = sscanf("10","%d",&$decimal); echo "<br>AFTER : <br> decimal = $decimal <br>"; echo "<h3><em><br>Simple Test 2<br></em></h3>"; echo "sscanf(\"ghost 0xface\",\"%s %x\",&\$string, &\$int)<br>"; echo "<br>BEFORE : <br> string = $string, int = $int<br>"; $foo = sscanf("ghost 0xface","%s %x",&$string, &$int); echo "<br>AFTER : <br> string = $string, int = $int<br>"; echo " sscan reports : "; print_value( $foo,""); echo " conversions <br>"; echo "<h3><em><br>Multiple specifiers<br></em></h3>"; echo "sscanf(\"jabberwocky 1024 0xFF 1.024 644 10\", \"%s %d %x %f %o %i\", &\$string,&\$decimal,&\$hex,&\$float,&\$octal,&\$int);<br>"; echo "<br>BEFORE : <br>"; echo "Decimal = $decimal, String = $string, Hex = $hex<br>"; echo "Octal = $octal , Float = $float, Int = $int<br>"; $foo = sscanf( "jabberwocky 1024 0xFF 1.024 644 10", "%s %d %x %f %o %i", &$string,&$decimal,&$hex,&$float,&$octal,&$int); echo "<br>AFTER :<br>"; echo "decimal = $decimal, string = $string, hex = $hex<br>"; echo "octal = $octal , float = $float, int = $int<br>"; echo " sscan reports : "; print_value( $foo,""); echo " conversions <br>"; echo "----------------------------------------<br>"; } if (!function_exists('sscanf')) { echo "<strong>I'm sorry but sscanf() does not exist !i</strong><br>"; } else { simple_tests(); run_sscanf_test_cases(); } ?>

« previous php.qa (#570) next »