Debian Codegraph @

extensions/Math/tests/phpunit/unit/WikiTexVC/ParserTest.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Extension\Math\Tests\WikiTexVC;
4
5 use MediaWiki\Extension\Math\WikiTexVC\Parser;
6 use MediaWikiUnitTestCase;
7
8 /**
9 * @covers \MediaWiki\Extension\Math\WikiTexVC\Parser
10 */
11 class ParserTest extends MediaWikiUnitTestCase {
12
13 /** @var Parser */
14 private $parser;
15
16 protected function setUp(): void {
17 parent::setUp();
18 $this->parser = new Parser();
19 }
20
21 public function provideTestCases() {
22 yield [ '' ];
23 yield [ 'a' ];
24 yield [ 'a^2' ];
25 yield [ 'a^2+b^{2}' ];
26 yield [ 'l_a^2+l_b^2=l_c^2' ];
27 }
28
29 /**
30 * @dataProvider provideTestCases
31 */
32 public function testSimpleParse( string $input ) {
33 $this->parser->parse( $input, [ 'debug' => true ] );
34 $this->addToAssertionCount( 1 );
35 }
36
37 public function testExample() {
38 $this->parser->parse( '\\sin(x)+{}{}\\cos(x)^2 newcommand', [ 'debug' => true ] );
39 $this->addToAssertionCount( 1 );
40 }
41
42 public function testSpecific() {
43 $resultR = $this->parser->parse( '\\reals' );
44 $resultS = $this->parser->parse( '\\mathbb{R}' );
45 $this->assertEquals( $resultR, $resultS, 'Should parse texVC specific functions' );
46 }
47 }