- 新增单个trait简单方法测试用例,验证const数组和方法调用功能 - 添加decimal类型toString方法测试用例,验证浮点数转字符串功能 - 更新版本号从1057到1058pull/1/head
parent
5fa7b61cc8
commit
bbb43664fc
3 changed files with 64 additions and 1 deletions
@ -0,0 +1,14 @@ |
||||
--TEST-- |
||||
decimal: literal |
||||
--FILE-- |
||||
<?php |
||||
use decimal_types; |
||||
|
||||
function main() |
||||
{ |
||||
$a = 0.1 + 0.2; |
||||
var_dump($a->toString()); |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
string(3) "0.3" |
||||
@ -0,0 +1,49 @@ |
||||
--TEST-- |
||||
Single Trait with simple trait method |
||||
--FILE-- |
||||
<?php |
||||
trait THello { |
||||
private const array CONST_ARRAY = [ |
||||
'test_fn_1' => ['toInt' => 123,], |
||||
'test_fn_2' => ['toInt' => 234, ], |
||||
'test_fn_3' => ['toInt' => 333,], |
||||
]; |
||||
|
||||
public function run(string $key1) { |
||||
var_dump(isset(self::CONST_ARRAY[$key1]['toInt'])); |
||||
var_dump(self::CONST_ARRAY[$key1]); |
||||
} |
||||
} |
||||
|
||||
class TraitsTest { |
||||
use THello; |
||||
|
||||
function hello1() { |
||||
$this->run('test_fn_2'); |
||||
} |
||||
} |
||||
|
||||
class Test extends TraitsTest { |
||||
function hello2() { |
||||
$this->run('test_fn_2'); |
||||
} |
||||
} |
||||
|
||||
function main() { |
||||
$o1 = new TraitsTest(); |
||||
$o1->hello1(); |
||||
$o2 = new Test(); |
||||
$o2->hello2(); |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
bool(true) |
||||
array(1) { |
||||
["toInt"]=> |
||||
int(234) |
||||
} |
||||
bool(true) |
||||
array(1) { |
||||
["toInt"]=> |
||||
int(234) |
||||
} |
||||
@ -1 +1 @@ |
||||
1057 |
||||
1058 |
||||
|
||||
Loading…
Reference in new issue