mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-12-12 16:05:09 +00:00
ba47c32e1d
For development history of this changeset see: Id96a4b1b55e3959aab81f4ba436c5ac125f2a1bb Bug: T312528 Change-Id: I61cfdbd63f8d50b072ada05927a134686fdd53d3
52 lines
1.5 KiB
PHP
52 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Math\Tests\TexVC\Nodes;
|
|
|
|
use ArgumentCountError;
|
|
use MediaWiki\Extension\Math\TexVC\Nodes\DQ;
|
|
use MediaWiki\Extension\Math\TexVC\Nodes\Literal;
|
|
use MediaWiki\Extension\Math\TexVC\Nodes\TexNode;
|
|
use MediaWikiUnitTestCase;
|
|
use RuntimeException;
|
|
use TypeError;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Extension\Math\TexVC\Nodes\DQ
|
|
*/
|
|
class DQTest extends MediaWikiUnitTestCase {
|
|
|
|
public function testEmptyDQ() {
|
|
$this->expectException( ArgumentCountError::class );
|
|
new DQ();
|
|
throw new ArgumentCountError( 'Should not create an empty dq' );
|
|
}
|
|
|
|
public function testOneArgumentDQ() {
|
|
$this->expectException( ArgumentCountError::class );
|
|
new DQ( new Literal( 'a' ) );
|
|
throw new ArgumentCountError( 'Should not create a dq with one argument' );
|
|
}
|
|
|
|
public function testIncorrectTypeDQ() {
|
|
$this->expectException( TypeError::class );
|
|
new DQ( 'a', 'b' );
|
|
throw new RuntimeException( 'Should not create a dq with incorrect type' );
|
|
}
|
|
|
|
public function testBasicDQ() {
|
|
$dq = new DQ( new Literal( 'a' ), new Literal( 'b' ) );
|
|
$this->assertEquals( 'a_{b}', $dq->render(), 'Should create a basic dq' );
|
|
}
|
|
|
|
public function testGetters() {
|
|
$dq = new DQ( new Literal( 'a' ), new Literal( 'b' ) );
|
|
$this->assertNotEmpty( $dq->getBase() );
|
|
$this->assertNotEmpty( $dq->getDown() );
|
|
}
|
|
|
|
public function testEmptyBaseDQ() {
|
|
$dq = new DQ( new TexNode(), new Literal( 'b' ) );
|
|
$this->assertEquals( '_{b}', $dq->render(), 'Should create an empty base dq' );
|
|
}
|
|
}
|