-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
1,581 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--TEST-- | ||
Test include() with PHP code | ||
--SKIPIF-- | ||
<?php | ||
$dir = dirname(__FILE__).'/'; | ||
require($dir.'test-helper.php'); | ||
make_phpcode($dir.'a10-include.phpt', $dir.'a10-include.phb'); | ||
?> | ||
--FILE-- | ||
<?php | ||
include("a10-include.phb"); | ||
unlink(dirname(__FILE__).'/a10-include.phb'); | ||
exit; | ||
//--CODE-- | ||
echo "ok\n"; | ||
?> | ||
--EXPECT-- | ||
ok |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--TEST-- | ||
Test include() with empty file | ||
--SKIPIF-- | ||
<?php | ||
$dir = dirname(__FILE__).'/'; | ||
require($dir.'test-helper.php'); | ||
touch($dir.'a11-include.phb'); | ||
?> | ||
--FILE-- | ||
<?php | ||
include("a11-include.phb"); | ||
unlink(dirname(__FILE__).'/a11-include.phb'); | ||
exit; | ||
//--CODE-- | ||
?> | ||
--EXPECT-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--TEST-- | ||
Test include() with simple bytecode | ||
--SKIPIF-- | ||
<?php | ||
$dir = dirname(__FILE__).'/'; | ||
require($dir.'test-helper.php'); | ||
make_bytecode($dir.'a12-include_bc.phpt', $dir.'a12-include_bc.phb'); | ||
?> | ||
--FILE-- | ||
<?php | ||
include("a12-include_bc.phb"); | ||
unlink(dirname(__FILE__).'/a12-include_bc.phb'); | ||
exit; | ||
//--CODE-- | ||
echo "ok\n"; | ||
?> | ||
--EXPECT-- | ||
ok |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--TEST-- | ||
Test get_included_files() | ||
--SKIPIF-- | ||
<?php | ||
$dir = dirname(__FILE__).'/'; | ||
require($dir.'test-helper.php'); | ||
make_bytecode($dir.'a15-included_files.phpt', $dir.'a15-included_files.phb'); | ||
?> | ||
--FILE-- | ||
<?php | ||
$i = 0; | ||
include("a15-included_files.phb"); | ||
print_r( get_included_files() ); | ||
include_once("a15-included_files.phb"); | ||
unlink(dirname(__FILE__).'/a15-included_files.phb'); | ||
exit; | ||
//--CODE-- | ||
echo $i++ ? "error\n" : " ok\n"; | ||
?> | ||
--EXPECTREGEX-- | ||
ok | ||
Array | ||
\( | ||
\[0\] => \S+a15-included_files\.php | ||
\[1\] => \S+a15-included_files\.phb | ||
\) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--TEST-- | ||
Test basic syntax | ||
--SKIPIF-- | ||
<?php | ||
$dir = dirname(__FILE__).'/'; | ||
require($dir.'test-helper.php'); | ||
make_bytecode($dir.'a20-basic.phpt', $dir.'a20-basic.phb'); | ||
?> | ||
--FILE-- | ||
<?php | ||
include("a20-basic.phb"); | ||
unlink(dirname(__FILE__).'/a20-basic.phb'); | ||
exit; | ||
//--CODE-- | ||
echo "test line 1\n"; | ||
echo "test line".' ', 4 / 2, "\n"; | ||
?> | ||
test line 3 | ||
--EXPECT-- | ||
test line 1 | ||
test line 2 | ||
test line 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--TEST-- | ||
Test constants | ||
--SKIPIF-- | ||
<?php | ||
$dir = dirname(__FILE__).'/'; | ||
require($dir.'test-helper.php'); | ||
make_bytecode($dir.'a21-const.phpt', $dir.'a21-const.phb'); | ||
?> | ||
--FILE-- | ||
<?php | ||
include("a21-const.phb"); | ||
unlink(dirname(__FILE__).'/a21-const.phb'); | ||
exit; | ||
//--CODE-- | ||
define("AAA", '1'); | ||
define("BBB", '222', 1); | ||
define("PI", 3.1415926); | ||
define("True", True); | ||
error_reporting(E_ALL & !E_NOTICE); | ||
echo AAA, "\n", aaa, "\n", BBB, "\n", bbb."\n"; | ||
echo "Pi=".PI, "\n"; | ||
var_dump(True); | ||
echo __LINE__, "\n"; | ||
?> | ||
--EXPECT-- | ||
1 | ||
aaa | ||
222 | ||
222 | ||
Pi=3.1415926 | ||
bool(true) | ||
10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--TEST-- | ||
Test variables | ||
--SKIPIF-- | ||
<?php | ||
$dir = dirname(__FILE__).'/'; | ||
require($dir.'test-helper.php'); | ||
make_bytecode($dir.'a22-vars.phpt', $dir.'a22-vars.phb'); | ||
?> | ||
--FILE-- | ||
<?php | ||
include("a22-vars.phb"); | ||
unlink(dirname(__FILE__).'/a22-vars.phb'); | ||
exit; | ||
//--CODE-- | ||
$a = 2; | ||
$b = $a * $a; | ||
$c = ++$a; | ||
$d = $c * $a / 5; | ||
$s = "A string\n2nd line"; | ||
$arr = array($a, $b, $d); | ||
$x = 'c'; | ||
$$x *= 10; | ||
var_dump($c); | ||
var_dump($d); | ||
echo "$s\n"; | ||
var_dump($arr); | ||
$arr2[ $s{0} ] = &$a; | ||
$a = ($c % 10) ? "yes" : "no"; | ||
echo $arr2['A'], "\n"; | ||
$z = "_SELF"; | ||
echo $_SERVER["PHP{$z}"], "\n"; | ||
?> | ||
--EXPECTREGEX-- | ||
int\(30\) | ||
float\(1\.8\) | ||
A string | ||
2nd line | ||
array\(3\) \{ | ||
\[0\]=> | ||
int\(3\) | ||
\[1\]=> | ||
int\(4\) | ||
\[2\]=> | ||
float\(1\.8\) | ||
\} | ||
no | ||
.*a22-vars\.php$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--TEST-- | ||
Test functions | ||
--SKIPIF-- | ||
<?php | ||
$dir = dirname(__FILE__).'/'; | ||
require($dir.'test-helper.php'); | ||
make_bytecode($dir.'a23-func.phpt', $dir.'a23-func.phb'); | ||
?> | ||
--FILE-- | ||
<?php | ||
include("a23-func.phb"); | ||
unlink(dirname(__FILE__).'/a23-func.phb'); | ||
exit; | ||
--CODE-- | ||
function Add($a, $b) { | ||
function Div($x, $y = 100) { return $x / $y; } | ||
|
||
return $a + Div($b); | ||
} | ||
|
||
function uc(&$string) { | ||
ucfirst($string); | ||
return array(7, 8, 1000); | ||
} | ||
|
||
function max2() { | ||
$m = NULL; | ||
for ($i = 0; $i < func_num_args(); $i++) { | ||
$v = func_get_arg($i); | ||
if (is_array($v)) $v = call_user_func_array(__FUNCTION__, $v); | ||
if ($v > $m) $m = $v; | ||
} | ||
return $m; | ||
} | ||
|
||
var_dump( Add(2, 78) ); | ||
$s = "hello world\n"; | ||
$arr = uc($s); | ||
echo $s; | ||
$f = "max2"; | ||
echo $f(2, 7, $s, False, $arr, "56", ord('z')-1), "\n"; | ||
var_dump( max2() ); | ||
?> | ||
--EXPECT-- | ||
float(2.78) | ||
hello world | ||
1000 | ||
NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--TEST-- | ||
Test goto | ||
--SKIPIF-- | ||
<?php | ||
if (version_compare(PHP_VERSION, '5.3', '<')) die("skip PHP 5.3 or later is required"); | ||
$dir = dirname(__FILE__).'/'; | ||
require($dir.'test-helper.php'); | ||
make_bytecode($dir.'a25-goto.phpt', $dir.'a25-goto.phb'); | ||
?> | ||
--FILE-- | ||
<?php | ||
include("a25-goto.phb"); | ||
unlink(dirname(__FILE__).'/a25-goto.phb'); | ||
exit; | ||
//--CODE-- | ||
for ($i = 0; $i < 10; $i++) { | ||
echo "$i\n"; | ||
if ($i == 3) goto Label; | ||
} | ||
|
||
Label: | ||
echo ".\n"; | ||
?> | ||
--EXPECT-- | ||
0 | ||
1 | ||
2 | ||
3 | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--TEST-- | ||
Test break & continue | ||
--SKIPIF-- | ||
<?php | ||
$dir = dirname(__FILE__).'/'; | ||
require($dir.'test-helper.php'); | ||
make_bytecode($dir.'a26-brk_cont.phpt', $dir.'a26-brk_cont.phb'); | ||
?> | ||
--FILE-- | ||
<?php | ||
include("a26-brk_cont.phb"); | ||
unlink(dirname(__FILE__).'/a26-brk_cont.phb'); | ||
exit; | ||
//--CODE-- | ||
for ($i = 5; $i > 0; $i--) { | ||
if ($i == 3) break; | ||
echo "$i\n"; | ||
$j = -$i; | ||
while ($j) { | ||
if (++$j % 2) continue; | ||
echo "$i $j\n"; | ||
} | ||
} | ||
?> | ||
--EXPECT-- | ||
5 | ||
5 -4 | ||
5 -2 | ||
5 0 | ||
4 | ||
4 -2 | ||
4 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--TEST-- | ||
Test exceptions | ||
--SKIPIF-- | ||
<?php | ||
if (version_compare(PHP_VERSION, '5.0.0', '<')) die("skip PHP 5 or later is required"); | ||
$dir = dirname(__FILE__).'/'; | ||
require($dir.'test-helper.php'); | ||
make_bytecode($dir.'a29-exceptions.phpt', $dir.'a29-exceptions.phb'); | ||
?> | ||
--FILE-- | ||
<?php | ||
include("a29-exceptions.phb"); | ||
unlink(dirname(__FILE__).'/a29-exceptions.phb'); | ||
exit; | ||
--CODE-- | ||
function inverse($x) { | ||
if (!$x) { | ||
throw new Exception('Division by zero.'); | ||
} | ||
else return 1/$x; | ||
} | ||
|
||
try { | ||
echo inverse(5) . "\n"; | ||
echo inverse(0) . "\n"; | ||
} catch (Exception $e) { | ||
echo 'Caught exception: ', $e->getMessage(), "\n"; | ||
} | ||
|
||
// Continue execution | ||
echo 'Hello World'; | ||
?> | ||
--EXPECT-- | ||
0.2 | ||
Caught exception: Division by zero. | ||
Hello World |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--TEST-- | ||
Test class basics | ||
--SKIPIF-- | ||
<?php | ||
$dir = dirname(__FILE__).'/'; | ||
require($dir.'test-helper.php'); | ||
make_bytecode($dir.'a30-class.phpt', $dir.'a30-class.phb'); | ||
?> | ||
--FILE-- | ||
<?php | ||
include("a30-class.phb"); | ||
unlink(dirname(__FILE__).'/a30-class.phb'); | ||
exit; | ||
--CODE-- | ||
class A { | ||
var $x; | ||
function A($v) { | ||
$this->x = $v; | ||
} | ||
function foo() { | ||
if (isset($this)) { | ||
echo '$this is defined (', get_class($this), ")\n"; | ||
} else { | ||
echo "\$this is not defined.\n"; | ||
} | ||
} | ||
} | ||
|
||
class B { | ||
var $x; | ||
function B($v) { | ||
$this->x = $v; | ||
} | ||
function bar() { | ||
A::foo(); | ||
} | ||
} | ||
|
||
if (PHP_VERSION >= 5) error_reporting(E_ALL & !E_STRICT); | ||
|
||
$a = new A('x'); | ||
$b = new B(5.5); | ||
echo $a->x, "\n"; | ||
var_dump($b->{$a->x}); | ||
|
||
$a->foo(); | ||
A::foo(); | ||
$b->bar(); | ||
B::bar(); | ||
?> | ||
--EXPECTREGEX-- | ||
x | ||
float\(5\.5\) | ||
\$this is defined \([Aa]\) | ||
\$this is not defined\. | ||
\$this is defined \([Bb]\) | ||
\$this is not defined\. |
Oops, something went wrong.