1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 17:52:45 +01:00
psalm/tests/TypeParseTest.php
2016-09-09 16:38:32 -04:00

37 lines
990 B
PHP

<?php
namespace Psalm\Tests;
use Psalm\Type;
use PhpParser;
use PhpParser\ParserFactory;
use PHPUnit_Framework_TestCase;
class TypeParseTest extends PHPUnit_Framework_TestCase
{
protected static $_parser;
public static function setUpBeforeClass()
{
self::$_parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
}
private static function getAtomic($string)
{
return array_values(Type::parseString($string)->types)[0];
}
public function testIntOrString()
{
$this->assertEquals('int|string', (string) Type::parseString('int|string'));
$this->assertEquals('array<int,int>', (string) Type::parseString('array<int,int>'));
$this->assertEquals('array<int,string>', (string) Type::parseString('array<int,string>'));
$this->assertEquals('array<int,static>', (string) Type::parseString('array<int,static>'));
$this->assertEquals('B<int>', (string) Type::parseString('B<int>'));
}
}