]> granicus.if.org Git - php/commitdiff
Updating tests: remove alternative syntax in tests, added a special
authorSander Roobol <sander@php.net>
Fri, 29 Mar 2002 17:12:11 +0000 (17:12 +0000)
committerSander Roobol <sander@php.net>
Fri, 29 Mar 2002 17:12:11 +0000 (17:12 +0000)
alternative-syntax testfile.

22 files changed:
tests/lang/002.phpt
tests/lang/003.phpt
tests/lang/004.phpt
tests/lang/005.phpt
tests/lang/006.phpt
tests/lang/007.phpt
tests/lang/008.phpt
tests/lang/009.phpt
tests/lang/010.phpt
tests/lang/012.phpt
tests/lang/013.phpt
tests/lang/014.phpt
tests/lang/015.phpt
tests/lang/016.inc
tests/lang/016.phpt
tests/lang/017.phpt
tests/lang/022.phpt
tests/lang/025.phpt
tests/lang/029.phpt
tests/lang/030.phpt
tests/lang/031.phpt
tests/lang/033.phpt [new file with mode: 0644]

index 9197a9762baf55a4c2b8ec5bccd80cc8d6272993..dd2c83b4f60508dd42eba11436dfb9f72a67db87 100644 (file)
@@ -3,10 +3,12 @@ Simple While Loop Test
 --POST--
 --GET--
 --FILE--
-<?php $a=1; 
-  while($a<10):
+<?php
+$a=1; 
+while ($a<10) {
        echo $a;
        $a++;
-  endwhile?>
+}
+?>
 --EXPECT--
 123456789
index 23bc99e9f4b04131135c89b744d99a84667091bb..cb2a3c38cdd32d23060f7c89b7e9ef8808418c53 100644 (file)
@@ -3,17 +3,19 @@ Simple Switch Test
 --POST--
 --GET--
 --FILE--
-<?php $a=1; 
-  switch($a):
-       case 0;
+<?php
+$a=1; 
+switch($a) {
+       case 0:
                echo "bad";     
                break;
-       case 1;
+       case 1:
                echo "good";
                break;
-       default;
+       default:
                echo "bad";
                break;
-  endswitch?>
+}
+?>
 --EXPECT--
 good
index be1f98ade5554907eb449e29d9e7ee5d4403d197..bd47328c162d667b89c2b1a4a6fbf0b3bb2ec6d7 100644 (file)
@@ -3,11 +3,13 @@ Simple If/Else Test
 --POST--
 --GET--
 --FILE--
-<?php $a=1; 
-  if($a==0):
+<?php
+$a=1; 
+if($a==0) {
        echo "bad";
-  else:
+} else {
        echo "good";
-  endif?>      
+}
+?>     
 --EXPECT--
 good
index ea413769b07ad518c360f03e00b19e8c7d238a90..f74590e86079ba279d4867fe3682f6c13f87e9f9 100644 (file)
@@ -3,13 +3,16 @@ Simple If/ElseIf/Else Test
 --POST--
 --GET--
 --FILE--
-<?php $a=1; 
-  if($a==0):
+<?php
+$a=1; 
+
+if($a==0) {
        echo "bad";
-  elseif($a==3):
+} elseif($a==3) {
        echo "bad";
-  else:
+} else {
        echo "good";
-  endif?>      
+}
+?>     
 --EXPECT--
 good
index b0cc9cf0e2ca32495143371d2c2602279814ac72..e9e8c2357f2e35cef3ed8ccdd5a29926879c298b 100644 (file)
@@ -3,19 +3,23 @@ Nested If/ElseIf/Else Test
 --POST--
 --GET--
 --FILE--
-<?php $a=1; $b=2;
-  if($a==0):
+<?php
+$a=1;
+$b=2;
+
+if($a==0) {
        echo "bad";
-  elseif($a==3):
+} elseif($a==3) {
        echo "bad";
-  else:
-       if($b==1):
+} else {
+       if($b==1) {
                echo "bad";
-       elseif($b==2):
+       } elseif($b==2) {
                echo "good";
-       else:
+       } else {
                echo "bad";
-       endif;
-  endif?>      
+       }
+}
+?>     
 --EXPECT--
 good
index f0aa61f876f2f3ab1325766b2f30814f392693c3..04af8111fd44396565556f59e5fa9cf34b63fa4b 100644 (file)
@@ -3,23 +3,27 @@ Function call with global and static variables
 --POST--
 --GET--
 --FILE--
-<?php  error_reporting(0);
-       $a = 10;
-       function Test()
-       {
-               static $a=1;
-               global $b;
-               $c = 1;
-               $b = 5;
-               echo "$a $b ";
-               $a++;
-               $c++;
-               echo "$a $c ";
-       }
-       Test(); 
-       echo "$a $b $c ";
-       Test(); 
-       echo "$a $b $c ";
-       Test()?>
+<?php
+error_reporting(0);
+$a = 10;
+
+function Test()
+{
+       static $a=1;
+       global $b;
+       $c = 1;
+       $b = 5;
+       echo "$a $b ";
+       $a++;
+       $c++;
+       echo "$a $c ";
+}
+
+Test();        
+echo "$a $b $c ";
+Test();        
+echo "$a $b $c ";
+Test();
+?>
 --EXPECT--
 1 5 2 2 10 5  2 5 3 2 10 5  3 5 4 2 
index 145214cbb49f23defa7d5fc69579e91b04ce57a9..1e9c86ff5a9664e88ad577adeb57ebea916472d8 100644 (file)
@@ -3,14 +3,18 @@ Testing recursive function
 --POST--
 --GET--
 --FILE--
-<?php  Function Test()
-       {
-               static $a=1;
+<?php
 
-               echo "$a ";     
-               $a++;
-               if($a<10): Test(); endif;
-       }
-       Test()?>
+function Test()
+{
+       static $a=1;
+       echo "$a ";     
+       $a++;
+       if($a<10): Test(); endif;
+}
+
+Test();
+
+?>
 --EXPECT--
 1 2 3 4 5 6 7 8 9 
index 5498288dcfdfb72a79d6e6e5174b60544e20de56..96278c22b14d5247dac6b1200bc02ad19ba393af 100644 (file)
@@ -3,9 +3,11 @@ Testing function parameter passing
 --POST--
 --GET--
 --FILE--
-<?php  old_function Test $a,$b (
-               echo $a+$b;     
-       );
-       Test(1,2)?>
+<?php
+function test ($a,$b) {
+       echo $a+$b;     
+}
+test(1,2);
+?>
 --EXPECT--
 3
index 03def4b112ffc8587693cbdebbcd91720c9a329b..e414baae6e340177e2deb7a58765649e39225154 100644 (file)
@@ -3,11 +3,13 @@ Testing function parameter passing with a return value
 --POST--
 --GET--
 --FILE--
-<?php  old_function Test $b (
-               $b++;
-               return($b);
-       );
-       $a = Test(1);
-       echo $a?>
+<?php
+function test ($b) {
+       $b++;
+       return($b);
+}
+$a = test(1);
+echo $a;
+?>
 --EXPECT--
 2
index b3c7abbfda56b2e4e2e3f3f96288cbb01cba9565..b54132b906e98fde2bc8e4d354a1b2982cc86f04 100644 (file)
@@ -4,17 +4,17 @@ Testing stack after early function return
 --GET--
 --FILE--
 <?php 
-old_function F ( 
-       if(1):
+function F () { 
+       if(1) {
                return("Hello");
-       endif;
-);
+       }
+}
 
 $i=0;
-while($i<2):
+while ($i<2) {
        echo F();
        $i++;
-endwhile;
+}
 ?>
 --EXPECT--
 HelloHello
index 74a8f197f10abe6afd3e836ce3ad47956ca1042e..4b661c071afb14254b814296b74faf23cdae559a 100644 (file)
@@ -4,9 +4,9 @@ Testing eval function
 --GET--
 --FILE--
 <?php 
-       error_reporting(0);
-       $a="echo \"Hello\";";
-       eval($a);
+error_reporting(0);
+$a="echo \"Hello\";";
+eval($a);
 ?>
 --EXPECT--
 Hello
index a03aa4787078a3dcd6c3e094c9a6804ed818c913..6338d7c23c5c3b19eb41f80ba4266574ffd57d76 100644 (file)
@@ -4,9 +4,9 @@ Testing eval function inside user-defined function
 --GET--
 --FILE--
 <?php 
-old_function F $a ( 
+function F ($a) { 
        eval($a);
-);
+}
 
 error_reporting(0);
 F("echo \"Hello\";");
index e6376067cdc657979d1e18382aa1d4080fdd4b5b..399f80286624c036af5c0ab886c337052dcbb1c6 100644 (file)
@@ -3,8 +3,8 @@ Testing include
 --POST--
 --GET--
 --FILE--
-<?php 
-       include "015.inc";
+<?php
+include "015.inc";
 ?>
 --EXPECT--
 Hello
index 7039e3f39594ff6a17f1fcc71e2c25315de1d5e6..b73333f7b02003caec0fc2430ac8e1ba6d32d774 100755 (executable)
@@ -1,5 +1,5 @@
 <?php 
-       old_function MyFunc $a (
-               echo $a;
-       );
+function MyFunc ($a) {
+       echo $a;
+}
 ?>
index 238fc29a6137ac850dc13b5fd5c52de38fe5df78..49c4d4d1a675082e48578c6701648cd28c89feb1 100644 (file)
@@ -4,8 +4,8 @@ Testing user-defined function in included file
 --GET--
 --FILE--
 <?php 
-       include "016.inc";
-       MyFunc("Hello");
+include "016.inc";
+MyFunc("Hello");
 ?>
 --EXPECT--
 Hello
index 1fc8429a82cfb506e3f8a315414bdeea6803baac..bb18194e5d170d0f35bc186a59f8ded84e9e6d2e 100644 (file)
@@ -3,16 +3,18 @@ Testing user-defined function falling out of an If into another
 --POST--
 --GET--
 --FILE--
-<?php $a = 1;
-old_function Test $a (
-       if($a<3):
+<?php
+$a = 1;
+function Test ($a) {
+       if ($a<3) {
                return(3);
-       endif;
-);
+       }
+}
 
-if($a < Test($a)):
+if ($a < Test($a)) {
        echo "$a\n";
        $a++;
-endif?>
+}
+?>
 --EXPECT--
 1
index 1465396926a1c51b153a21791ceb3e501832f7e1..e1847b2c0e2133bfa896aa2ad403be7658c47020 100644 (file)
@@ -7,7 +7,7 @@ Switch test 3
 
 function switchtest ($i, $j)
 {
-       switch ($i):
+       switch ($i) {
                case 0:
                                switch($j) {
                                        case 0:
@@ -24,7 +24,7 @@ function switchtest ($i, $j)
                                break;
                default:
                                echo "Default taken\n";
-       endswitch;
+       }
 }
 for ($i=0; $i<3; $i++) {
   for ($k=0; $k<10; $k++) {
index 34e0e8d6f4766c7d8b324b70b8c018ef85258529..4f5397d5a8c382dd88c1a467f47bf29abeec3dec 100644 (file)
@@ -4,24 +4,17 @@ Mean recursion test
 --GET--
 --FILE--
 <?php 
-old_function RekTest $nr (
-
-echo " $nr ";
-
-
-$j=$nr+1;
-while ($j < 10)
-{
-  echo " a ";
-  RekTest($j);
-  $j++;
-  echo " b $j ";
-};
-echo "\n";
-
-
-
-);
+function RekTest ($nr) {
+       echo " $nr ";
+       $j=$nr+1;
+       while ($j < 10) {
+         echo " a ";
+         RekTest($j);
+         $j++;
+         echo " b $j ";
+       }
+       echo "\n";
+}
 
 RekTest(0);
 ?>
index 6226d42880db64d26d07c4ca3afdd81b381b1d65..4fcaa3811a7f850374ef22168b3a7480b06ddf6e 100644 (file)
@@ -6,11 +6,7 @@ OO Bug Test (Bug #7515)
 <?php
 class obj {
        function method() {}
-    }
-
-function test($o_copy) {
-       $o_copy->root->set_in_copied_o=TRUE;
-       var_dump($o_copy);?><BR><?php }
+}
 
 $o->root=new obj();
 
index 162997fca91a0bf23931f5da37a3d91d6412e290..ba809c8e31c74a01a8c130974882992f703678bc 100644 (file)
@@ -8,13 +8,17 @@ class foo {
        function foo($name) {
        $GLOBALS['List']= &$this;
        $this->Name = $name;
-               $GLOBALS['List']->echoName(); }
+               $GLOBALS['List']->echoName();
+       }
 
        function echoName() {
-       $GLOBALS['names'][]=$this->Name; } }
+       $GLOBALS['names'][]=$this->Name;
+       }
+}
 
-function &foo2(&$foo)  {
-       return $foo; }
+function &foo2(&$foo) {
+       return $foo;
+}
 
 
 $bar1 =& new foo('constructor');
@@ -28,6 +32,7 @@ $bar1->echoName();
 
 $List->echoName();
 
-print ($names==array('constructor','outside','outside','constructor','outside','outside')) ? 'success':'failure'; ?>
+print ($names==array('constructor','outside','outside','constructor','outside','outside')) ? 'success':'failure';
+?>
 --EXPECT--
-success
\ No newline at end of file
+success
index b74d1357484f71fb6ad91d0e1703de7ecb7e7e9f..bb3d7762390196fea82ef6c3df2ff730f8ef381e 100644 (file)
@@ -5,17 +5,16 @@ Internal hash position bug on assignment (Bug #16227)
 --FILE--
 <?php
 // reported by php.net@alienbill.com
-       $outsidearray = array("key1","key2");
-       $insidearray = array("0","1");
+$outsidearray = array("key1","key2");
+$insidearray = array("0","1");
 
-           while(list(,$outerval) = each($outsidearray)){
-               $placeholder = $insidearray;
-               while(list(,$innerval) = each($insidearray)){
-                       print "inloop $innerval for $outerval\n";
-               }
-       }
+while(list(,$outerval) = each($outsidearray)){
+       $placeholder = $insidearray;
+       while(list(,$innerval) = each($insidearray)){
+               print "inloop $innerval for $outerval\n";
+       }
+}
 ?>
 --EXPECT--
 inloop 0 for key1
 inloop 1 for key1
-
diff --git a/tests/lang/033.phpt b/tests/lang/033.phpt
new file mode 100644 (file)
index 0000000..0fb639a
--- /dev/null
@@ -0,0 +1,53 @@
+--TEST--
+Alternative syntaxes test
+--POST--
+--GET--
+--FILE--
+<?php
+$a = 1;
+
+echo "If: ";
+if ($a) echo 1; else echo 0;
+if ($a):
+       echo 1;
+else:
+       echo 0;
+endif;
+
+echo "\nWhile: ";
+while ($a<5) echo $a++;
+while ($a<9):
+       echo ++$a;
+endwhile;
+
+echo "\nFor: ";
+for($a=0;$a<5;$a++) echo $a;
+for($a=0;$a<5;$a++):
+       echo $a;
+endfor;
+
+echo "\nSwitch: ";
+switch ($a):
+       case 0;
+               echo 0;
+               break;
+       case 5:
+               echo 1;
+               break;
+       default;
+               echo 0;
+               break;
+endswitch;
+
+echo "\nold_function: ";
+old_function foo $bar, $baz (
+       return sprintf("foo(%s, %s);\n", $bar, $baz);
+);
+echo foo(1,2);
+?>
+--EXPECT--
+If: 11
+While: 12346789
+For: 0123401234
+Switch: 1
+old_function: foo(1, 2);