Debian Codegraph @

extensions/Math/tests/phpunit/unit/WikiTexVC/Nodes/CurlyTest.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Extension\Math\Tests\WikiTexVC\Nodes;
4
5 use MediaWiki\Extension\Math\WikiTexVC\Nodes\DQ;
6 use MediaWiki\Extension\Math\WikiTexVC\Nodes\Literal;
7 use MediaWiki\Extension\Math\WikiTexVC\Nodes\TexArray;
8 use MediaWikiUnitTestCase;
9
10 /**
11 * @covers \MediaWiki\Extension\Math\WikiTexVC\Nodes\TexArray
12 */
13 class CurlyTest extends MediaWikiUnitTestCase {
14
15 public function testRenderTexCurly() {
16 $curly = TexArray::newCurly();
17 $this->assertEquals( '{}', $curly->render(), 'Should render a curly with empty tex array' );
18 }
19
20 public function testRenderListCurly() {
21 $curly = TexArray::newCurly(
22 new Literal( 'hello' ),
23 new Literal( ' ' ),
24 new Literal( 'world' )
25 );
26 $this->assertEquals( '{hello world}', $curly->render(), 'Should render a list' );
27 }
28
29 public function testGetters() {
30 $curly = TexArray::newCurly( new Literal( 'b' ) );
31 $this->assertNotEmpty( $curly->getArgs() );
32 }
33
34 public function testNoExtraCurliesDQ() {
35 $dq = new DQ( new Literal( 'a' ),
36 TexArray::newCurly( new Literal( 'b' ) ) );
37 $this->assertEquals( 'a_{b}', $dq->render(), 'Should not create extra curlies from dq' );
38 }
39
40 public function testNoExtraCurliesCurly() {
41 $curly = TexArray::newCurly( new Literal( 'a' ) );
42 $this->assertEquals( '{a}', $curly->inCurlies(), 'Should not create extra curlies from curly' );
43 }
44
45 public function testExtractIdentifierModsCurly() {
46 $curly = TexArray::newCurly( new Literal( 'b' ) );
47 $this->assertEquals( 'b', $curly->getModIdent(), 'Should extract identifier modifications' );
48 }
49
50 public function testExtractSubscirpts() {
51 $curly = TexArray::newCurly( new Literal( 'b' ) );
52 $this->assertEquals( 'b', $curly->extractSubscripts(), 'Should extract subscripts' );
53 }
54 }