mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-12-12 07:55:11 +00:00
cd4ce78d31
Instead of manually crafted $this->testCase properties. Also make use of the dedicated PHPUnit feature to mark as test as passed. While assertTrue( true ) is a very common hack it can be confusing. Change-Id: Ic071bf561929c2a79537111bee18631865f91366
48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Math\Tests\WikiTexVC;
|
|
|
|
use MediaWiki\Extension\Math\WikiTexVC\Parser;
|
|
use MediaWikiUnitTestCase;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Extension\Math\WikiTexVC\Parser
|
|
*/
|
|
class ParserTest extends MediaWikiUnitTestCase {
|
|
|
|
/** @var Parser */
|
|
private $parser;
|
|
|
|
protected function setUp(): void {
|
|
parent::setUp();
|
|
$this->parser = new Parser();
|
|
}
|
|
|
|
public function provideTestCases() {
|
|
yield [ '' ];
|
|
yield [ 'a' ];
|
|
yield [ 'a^2' ];
|
|
yield [ 'a^2+b^{2}' ];
|
|
yield [ 'l_a^2+l_b^2=l_c^2' ];
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideTestCases
|
|
*/
|
|
public function testSimpleParse( string $input ) {
|
|
$this->parser->parse( $input, [ 'debug' => true ] );
|
|
$this->addToAssertionCount( 1 );
|
|
}
|
|
|
|
public function testExample() {
|
|
$this->parser->parse( '\\sin(x)+{}{}\\cos(x)^2 newcommand', [ 'debug' => true ] );
|
|
$this->addToAssertionCount( 1 );
|
|
}
|
|
|
|
public function testSpecific() {
|
|
$resultR = $this->parser->parse( '\\reals' );
|
|
$resultS = $this->parser->parse( '\\mathbb{R}' );
|
|
$this->assertEquals( $resultR, $resultS, 'Should parse texVC specific functions' );
|
|
}
|
|
}
|