mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-12-12 07:55:11 +00:00
ba47c32e1d
For development history of this changeset see: Id96a4b1b55e3959aab81f4ba436c5ac125f2a1bb Bug: T312528 Change-Id: I61cfdbd63f8d50b072ada05927a134686fdd53d3
51 lines
1.5 KiB
PHP
51 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Math\Tests\TexVC\Nodes;
|
|
|
|
use ArgumentCountError;
|
|
use MediaWiki\Extension\Math\TexVC\Nodes\Fun1nb;
|
|
use MediaWiki\Extension\Math\TexVC\Nodes\Literal;
|
|
use MediaWikiUnitTestCase;
|
|
use TypeError;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Extension\Math\TexVC\Nodes\Fun1nb
|
|
*/
|
|
class Fun1nbTest extends MediaWikiUnitTestCase {
|
|
|
|
public function testEmptyFun1nb() {
|
|
$this->expectException( ArgumentCountError::class );
|
|
new Fun1nb();
|
|
throw new ArgumentCountError( 'Should not create an empty fun1nb' );
|
|
}
|
|
|
|
public function testOneArgumentFun1nb() {
|
|
$this->expectException( ArgumentCountError::class );
|
|
new Fun1nb( '\\f' );
|
|
throw new ArgumentCountError( 'Should not create a fun1nb with one argument' );
|
|
}
|
|
|
|
public function testIncorrectTypeFun1nb() {
|
|
$this->expectException( TypeError::class );
|
|
new Fun1nb( '\\f', 'x' );
|
|
throw new TypeError( 'Should not create a fun1nb with incorrect type' );
|
|
}
|
|
|
|
public function testBasicFunctionFun1nb() {
|
|
$fun1nb = new Fun1nb( '\\f', new Literal( 'a' ) );
|
|
$this->assertEquals( '\\f {a} ', $fun1nb->render(), 'Should create a basic function' );
|
|
}
|
|
|
|
public function testGetters() {
|
|
$fun1nb = new Fun1nb( '\\f', new Literal( 'a' ) );
|
|
$this->assertNotEmpty( $fun1nb->getFname() );
|
|
$this->assertNotEmpty( $fun1nb->getArg() );
|
|
}
|
|
|
|
public function testCurliesFun1nb() {
|
|
$f = new Fun1nb( '\\f', new Literal( 'a' ) );
|
|
$this->assertEquals( '{\\f {a} }', $f->inCurlies(),
|
|
'Should create exactly one set of curlies' );
|
|
}
|
|
}
|