mirror of
https://github.com/peklaiho/madlisp.git
synced 2024-11-26 07:04:27 +00:00
40 lines
928 B
PHP
40 lines
928 B
PHP
<?php
|
|
/**
|
|
* MadLisp language
|
|
* @link http://madlisp.com/
|
|
* @copyright Copyright (c) 2020 Pekka Laiho
|
|
*/
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use MadLisp\Hash;
|
|
use MadLisp\MadLispException;
|
|
use MadLisp\Util;
|
|
|
|
class UtilTest extends TestCase
|
|
{
|
|
public function testMakeHash()
|
|
{
|
|
$hash = Util::makeHash(['a', 1, 'b', 2]);
|
|
|
|
$this->assertInstanceOf(Hash::class, $hash);
|
|
$this->assertSame(['a' => 1, 'b' => 2], $hash->getData());
|
|
}
|
|
|
|
public function testMakeHashUnevenArgs()
|
|
{
|
|
$this->expectException(MadLispException::class);
|
|
$this->expectExceptionMessage('uneven number of arguments for hash');
|
|
|
|
Util::makeHash(['a', 1, 'b', 2, 'c']);
|
|
}
|
|
|
|
public function testMakeHashInvalidKey()
|
|
{
|
|
$this->expectException(MadLispException::class);
|
|
$this->expectExceptionMessage('invalid key for hash (not string)');
|
|
|
|
Util::makeHash([1, 2]);
|
|
}
|
|
}
|