test(aot): 添加对象链接操作符测试用例

- 创建了 TestAttrRef 类用于测试属性引用功能
- 实现了构造函数中的数组排序和切片操作逻辑
- 添加了主函数用于实例化测试对象并传入参数
- 定义了预期输出验证数组操作结果的正确性
pull/1/head
韩天峰 7 months ago
parent 548f7ce496
commit 209b9cb81d
  1. 63
      tests/aot/attr-ref.phpt

@ -0,0 +1,63 @@
--TEST--
object link operator
--FILE--
<?php
class TestAttrRef
{
private $k = null;
public $nums = null;
/**
* @param Integer $k
* @param Integer[] $nums
*/
function __construct($k, $nums)
{
$this->k = $k;
$this->nums = $nums;
rsort($this->nums);
var_dump($this->nums);
$this->nums = [34, 5, 8, 2];
var_dump($this->nums);
$this->nums = array_slice($this->nums, 0, $k);
var_dump($this->nums);
}
}
function main()
{
$k = 3;
$nums = [4, 5, 8, 2];
$obj = new TestAttrRef($k, $nums);
}
?>
--EXPECT--
array(4) {
[0]=>
int(8)
[1]=>
int(5)
[2]=>
int(4)
[3]=>
int(2)
}
array(4) {
[0]=>
int(34)
[1]=>
int(5)
[2]=>
int(8)
[3]=>
int(2)
}
array(3) {
[0]=>
int(34)
[1]=>
int(5)
[2]=>
int(8)
}
Loading…
Cancel
Save