Testing the interpreter
Use the existing testsuite of the PHP interpreter itself
The unit tests of the PHP interpreter consists of a log of “.phpt” files which contain a script to be run and it expected output:
1 --TEST--
2 Testing recursive function
3 --FILE--
4 <?php
5
6 function Test()
7 {
8 static $a=1;
9 echo "$a ";
10 $a++;
11 if($a<10): Test(); endif;
12 }
13
14 Test();
15
16 ?>
17 --EXPECT--
18 1 2 3 4 5 6 7 8 9
1 "Testing recursive function" in {
2 // lang/008
3 script(
4 """<?php
5 |
6 |function Test()
7 |{
8 | static $a=1;
9 | echo "$a ";
10 | $a++;
11 | if($a<10): Test(); endif;
12 |}
13 |
14 |Test();
15 |
16 |?>""".stripMargin
17 ).result must haveOutput(
18 """1 2 3 4 5 6 7 8 9 """.stripMargin
19 )
20 }