mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-12-19 02:50:44 +00:00
a102a4ed52
To reduce the complexity of the parse tree we remove the curly element which is used for grouping in TeX. Instead, we use use an attribute which defines if the group is put into curly brackets or not. The functionality of the curly element is transferred to the TexArray which was the only possible child of the curly element before. To ease the transition, we add a special constructor to TexArray. We could not measure any performance implications of this change. Bug: T333973 Change-Id: Idcb58694022831113bdc437576bb9f48658fff2f
70 lines
2.3 KiB
PHP
70 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Math\Tests\WikiTexVC\Nodes;
|
|
|
|
use ArgumentCountError;
|
|
use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmrow;
|
|
use MediaWiki\Extension\Math\WikiTexVC\Nodes\FQ;
|
|
use MediaWiki\Extension\Math\WikiTexVC\Nodes\Literal;
|
|
use MediaWiki\Extension\Math\WikiTexVC\Nodes\TexArray;
|
|
use MediaWikiUnitTestCase;
|
|
use TypeError;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Extension\Math\WikiTexVC\Nodes\FQ
|
|
*/
|
|
class FQTest extends MediaWikiUnitTestCase {
|
|
|
|
public function testEmptyFQ() {
|
|
$this->expectException( ArgumentCountError::class );
|
|
new FQ();
|
|
throw new ArgumentCountError( 'Should not create an empty fq' );
|
|
}
|
|
|
|
public function testOneArgumentFQ() {
|
|
$this->expectException( ArgumentCountError::class );
|
|
new FQ( new Literal( 'a' ) );
|
|
throw new ArgumentCountError( 'Should not create a fq with one argument' );
|
|
}
|
|
|
|
public function testIncorrectTypeFQ() {
|
|
$this->expectException( TypeError::class );
|
|
new FQ( 'a', 'b', 'c' );
|
|
throw new TypeError( 'Should not create a fq with incorrect type' );
|
|
}
|
|
|
|
public function testBasicFQ() {
|
|
$fq = new FQ( new Literal( 'a' ), new Literal( 'b' ), new Literal( 'c' ) );
|
|
$this->assertEquals( 'a_{b}^{c}', $fq->render(), 'Should create a basic fq' );
|
|
}
|
|
|
|
public function testGetters() {
|
|
$fq = new FQ( new Literal( 'a' ), new Literal( 'b' ), new Literal( 'c' ) );
|
|
$this->assertNotEmpty( $fq->getBase() );
|
|
$this->assertNotEmpty( $fq->getUp() );
|
|
$this->assertNotEmpty( $fq->getDown() );
|
|
}
|
|
|
|
public function testRenderEmptyFq() {
|
|
$fq = new FQ( TexArray::newCurly(), new Literal( 'b' ), new Literal( 'c' ) );
|
|
$result = $fq->renderMML();
|
|
$this->assertStringContainsString( 'msubsup', $result );
|
|
$this->assertStringContainsString( ( new MMLmrow() )->getEmpty(), $result );
|
|
}
|
|
|
|
public function testLatin() {
|
|
$fq = new FQ( new Literal( 'a' ), new Literal( 'b' ), new Literal( 'c' ) );
|
|
$this->assertStringContainsString( 'msubsup', $fq->renderMML() );
|
|
}
|
|
|
|
public function testSum() {
|
|
$fq = new FQ( new Literal( '\sum' ), new Literal( 'b' ), new Literal( 'c' ) );
|
|
$this->assertStringContainsString( 'munderover', $fq->renderMML() );
|
|
}
|
|
|
|
public function testGreek() {
|
|
$fq = new FQ( new Literal( '\\alpha' ), new Literal( 'b' ), new Literal( 'c' ) );
|
|
$this->assertStringContainsString( 'msubsup', $fq->renderMML() );
|
|
}
|
|
}
|