mirror of
https://github.com/php-win-ext/phpy.git
synced 2026-04-24 00:48:11 +02:00
84f0b2dd88
* fix core dump when "new PyType"
* add test code
---------
Co-authored-by: 弄月 <{ID}+{username}@users.noreply.github.com>
34 lines
766 B
PHP
34 lines
766 B
PHP
<?php
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class IterTest extends TestCase
|
|
{
|
|
function testIter()
|
|
{
|
|
$os = PyCore::import('os');
|
|
$uname = $os->uname();
|
|
|
|
$iter = PyCore::iter($uname);
|
|
$this->assertTrue($iter instanceof PyIter);
|
|
|
|
$list = [];
|
|
while ($next = PyCore::next($iter)) {
|
|
$list[] = PyCore::scalar($next);
|
|
}
|
|
$this->assertIsArray($list);
|
|
$this->assertEquals(count($list), 5);
|
|
}
|
|
|
|
function testNewIter()
|
|
{
|
|
try {
|
|
new PyIter;
|
|
} catch (Error $error) {
|
|
$this->assertStringContainsString('private PyIter::__construct()', $error->getMessage());
|
|
$success = false;
|
|
}
|
|
$this->assertFalse($success);
|
|
}
|
|
}
|