test(lang): 添加多个语言特性相关的回归测试

- 添加 bug27443 测试:验证 defined() 函数返回正确的布尔类型
- 添加 bug27535 测试:验证循环引用对象不会导致崩溃问题
- 添加 bug29944 测试:验证 switch 语句中定义函数的功能正常
- 添加 bug30578 测试:验证析构函数调用时机与输出缓冲区处理
pull/1/head
韩天峰 5 months ago
parent 27060d9b87
commit 60298d9461
  1. 8
      tests/core/lang/bug27443.phpt
  2. 27
      tests/core/lang/bug27535.phpt
  3. 20
      tests/core/lang/bug29944.phpt
  4. 31
      tests/core/lang/bug30578.phpt

@ -0,0 +1,8 @@
--TEST--
Bug #27443 (defined() returns wrong type)
--FILE--
<?php
echo gettype(defined('test'));
?>
--EXPECT--
boolean

@ -0,0 +1,27 @@
--TEST--
Bug #27535 (Objects pointing to each other cause Apache to crash)
--FILE--
<?php
class Class1
{
public $_Class2_obj;
}
class Class2
{
public $storage = '';
function __construct()
{
$this->storage = new Class1();
$this->storage->_Class2_obj = $this;
}
}
function main() {
$foo = new Class2();
}
?>
--EXPECT--

@ -0,0 +1,20 @@
--TEST--
Bug #29944 (function defined in switch crashes PHP)
--FILE--
<?php
function foo($bar) {
if (preg_match('/\d/', $bar)) return true;
return false;
}
function main() {
$a = 1;
$b = "1";
switch ($a) {
case 1:
echo foo($b);
}
}
?>
--EXPECT--
1

@ -0,0 +1,31 @@
--TEST--
Bug #30578 (Output buffers flushed before calling __destruct functions)
--FILE--
<?php
class Example
{
function __construct()
{
ob_start();
echo "This should be displayed last.\n";
}
function __destruct()
{
$buffered_data = ob_get_contents();
ob_end_clean();
echo "This should be displayed first.\n";
echo "Buffered data: $buffered_data";
}
}
function main() {
error_reporting(E_ALL);
$obj = new Example;
}
?>
--EXPECT--
This should be displayed first.
Buffered data: This should be displayed last.
Loading…
Cancel
Save