2022-08-17 13:26:25 +00:00
|
|
|
<?php
|
|
|
|
|
2023-11-24 09:30:05 +00:00
|
|
|
namespace MediaWiki\Extension\Math\Tests\WikiTexVC\Nodes;
|
2022-08-17 13:26:25 +00:00
|
|
|
|
|
|
|
use ArgumentCountError;
|
2023-11-24 09:30:05 +00:00
|
|
|
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;
|
2022-08-17 13:26:25 +00:00
|
|
|
use MediaWikiUnitTestCase;
|
|
|
|
use TypeError;
|
|
|
|
|
|
|
|
/**
|
2023-11-24 09:30:05 +00:00
|
|
|
* @covers \MediaWiki\Extension\Math\WikiTexVC\Nodes\FQ
|
2022-08-17 13:26:25 +00:00
|
|
|
*/
|
|
|
|
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' );
|
|
|
|
}
|
|
|
|
|
2022-10-10 13:34:23 +00:00
|
|
|
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() );
|
|
|
|
}
|
|
|
|
|
2024-01-02 23:17:47 +00:00
|
|
|
public function testRenderEmptyFq() {
|
2024-02-17 23:02:37 +00:00
|
|
|
$fq = new FQ( TexArray::newCurly(), new Literal( 'b' ), new Literal( 'c' ) );
|
|
|
|
$result = $fq->renderMML();
|
|
|
|
$this->assertStringContainsString( 'msubsup', $result );
|
|
|
|
$this->assertStringContainsString( ( new MMLmrow() )->getEmpty(), $result );
|
2023-03-21 15:06:32 +00:00
|
|
|
}
|
2024-01-02 23:17:47 +00:00
|
|
|
|
|
|
|
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() );
|
|
|
|
}
|
2022-08-17 13:26:25 +00:00
|
|
|
}
|