mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-12-25 13:52:58 +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
55 lines
1.7 KiB
PHP
55 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Math\Tests\WikiTexVC\Nodes;
|
|
|
|
use MediaWiki\Extension\Math\WikiTexVC\Nodes\DQ;
|
|
use MediaWiki\Extension\Math\WikiTexVC\Nodes\Literal;
|
|
use MediaWiki\Extension\Math\WikiTexVC\Nodes\TexArray;
|
|
use MediaWikiUnitTestCase;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Extension\Math\WikiTexVC\Nodes\TexArray
|
|
*/
|
|
class CurlyTest extends MediaWikiUnitTestCase {
|
|
|
|
public function testRenderTexCurly() {
|
|
$curly = TexArray::newCurly();
|
|
$this->assertEquals( '{}', $curly->render(), 'Should render a curly with empty tex array' );
|
|
}
|
|
|
|
public function testRenderListCurly() {
|
|
$curly = TexArray::newCurly(
|
|
new Literal( 'hello' ),
|
|
new Literal( ' ' ),
|
|
new Literal( 'world' )
|
|
);
|
|
$this->assertEquals( '{hello world}', $curly->render(), 'Should render a list' );
|
|
}
|
|
|
|
public function testGetters() {
|
|
$curly = TexArray::newCurly( new Literal( 'b' ) );
|
|
$this->assertNotEmpty( $curly->getArgs() );
|
|
}
|
|
|
|
public function testNoExtraCurliesDQ() {
|
|
$dq = new DQ( new Literal( 'a' ),
|
|
TexArray::newCurly( new Literal( 'b' ) ) );
|
|
$this->assertEquals( 'a_{b}', $dq->render(), 'Should not create extra curlies from dq' );
|
|
}
|
|
|
|
public function testNoExtraCurliesCurly() {
|
|
$curly = TexArray::newCurly( new Literal( 'a' ) );
|
|
$this->assertEquals( '{a}', $curly->inCurlies(), 'Should not create extra curlies from curly' );
|
|
}
|
|
|
|
public function testExtractIdentifierModsCurly() {
|
|
$curly = TexArray::newCurly( new Literal( 'b' ) );
|
|
$this->assertEquals( 'b', $curly->getModIdent(), 'Should extract identifier modifications' );
|
|
}
|
|
|
|
public function testExtractSubscirpts() {
|
|
$curly = TexArray::newCurly( new Literal( 'b' ) );
|
|
$this->assertEquals( 'b', $curly->extractSubscripts(), 'Should extract subscripts' );
|
|
}
|
|
}
|