2023-03-02 10:40:10 +00:00
|
|
|
<?php
|
|
|
|
|
2023-11-24 09:30:05 +00:00
|
|
|
namespace MediaWiki\Extension\Math\Tests\WikiTexVC;
|
2023-03-02 10:40:10 +00:00
|
|
|
|
2023-11-24 09:30:05 +00:00
|
|
|
use MediaWiki\Extension\Math\WikiTexVC\MMLmappings\TexConstants\Tag;
|
|
|
|
use MediaWiki\Extension\Math\WikiTexVC\MMLmappings\TexConstants\TexClass;
|
|
|
|
use MediaWiki\Extension\Math\WikiTexVC\MMLmappings\Util\MMLTestUtil;
|
|
|
|
use MediaWiki\Extension\Math\WikiTexVC\TexVC;
|
2023-03-02 10:40:10 +00:00
|
|
|
use MediaWikiUnitTestCase;
|
|
|
|
|
|
|
|
/**
|
2023-11-24 09:30:05 +00:00
|
|
|
* These are some specific testcases by MML-Rendering by WikiTexVC.
|
2023-03-02 10:40:10 +00:00
|
|
|
* They are explicitly described here instead of in JSON files because
|
|
|
|
* Mathoid or LaTeXML do not generate suitable results for reference.
|
2023-11-24 09:30:05 +00:00
|
|
|
* @covers \MediaWiki\Extension\Math\WikiTexVC\TexVC
|
2023-03-02 10:40:10 +00:00
|
|
|
*/
|
|
|
|
class MMLRenderTest extends MediaWikiUnitTestCase {
|
2024-10-29 10:30:51 +00:00
|
|
|
|
|
|
|
public function testMathFRakUnicode() {
|
|
|
|
$input = "\\mathfrak{O}, \\mathfrak{K}, \\mathfrak{t}, \\mathfrak{C}";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( '𝔒', $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( '𝔎', $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( '𝔱', $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( 'ℭ', $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
2023-12-01 14:29:36 +00:00
|
|
|
public function testMathCalUnicode() {
|
|
|
|
$input = "\\mathcal{O}, \\mathcal{K}, \\mathcal{t}, \\mathcal{c}";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( '𝒪', $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( '𝒦', $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( '𝓉', $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( '𝒸', $mathMLtexVC );
|
|
|
|
}
|
2023-11-24 16:30:19 +00:00
|
|
|
|
2023-11-30 13:54:17 +00:00
|
|
|
public function testDoubleStruckLiteralUnicode() {
|
|
|
|
$input = "\\mathbb{Q}, \\R, \\Complex, \\mathbb{4}";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( 'ℚ', $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( 'ℝ', $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( 'ℂ', $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( '𝟜', $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
2023-11-24 16:30:19 +00:00
|
|
|
public function testNoLimits() {
|
|
|
|
$input = "\\displaystyle \int\\nolimits_0^\infty f(x) dx";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( 'movablelimits="false"', $mathMLtexVC );
|
|
|
|
$this->assertStringNotContainsString( "nolimits", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
2023-11-20 12:53:22 +00:00
|
|
|
public function testGenfracStretching() {
|
|
|
|
$input = "\\tbinom{n}{k} \\dbinom{n}{k} \\binom{n}{k}";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringNotContainsString( "maxsize", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
2023-11-30 14:33:46 +00:00
|
|
|
public function testBracketSizesOpen() {
|
2023-11-15 11:08:20 +00:00
|
|
|
$input = "\bigl( \Bigl( \biggl( \Biggl( ";
|
2023-11-30 14:33:46 +00:00
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( 'minsize', $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( 'maxsize', $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testBracketSizesClose() {
|
|
|
|
$input = "\bigr) \Bigr) \biggr) \Biggr) ";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( 'minsize', $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( 'maxsize', $mathMLtexVC );
|
2023-11-15 11:08:20 +00:00
|
|
|
}
|
|
|
|
|
2023-11-03 11:15:54 +00:00
|
|
|
public function testLimOperatorSpacing() {
|
|
|
|
$input = "\liminf v, \limsup w \injlim x \projlim y";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "lim inf", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "lim sup", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "inj lim", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "proj lim", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
2023-11-03 14:25:21 +00:00
|
|
|
public function testTrimNull() {
|
|
|
|
$input = "\\bigl( \\begin{smallmatrix}a&b\\\\ c&d\\end{smallmatrix} \\bigr)";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "mtable", $mathMLtexVC );
|
|
|
|
}
|
2023-10-11 09:19:29 +00:00
|
|
|
|
|
|
|
public function testApplyOperator1() {
|
|
|
|
$input = "\sup x";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mo>⁡</mo>", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testApplyOperator2() {
|
|
|
|
$input = "\sup";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringNotContainsString( "<mo>⁡</mo>", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testApplyOperator3() {
|
|
|
|
$input = "\sup \sin";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mo>⁡</mo>", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testApplyFunction1() {
|
|
|
|
$input = "\sin x";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mo>⁡</mo>", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testApplyFunction2() {
|
|
|
|
$input = "\sin";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringNotContainsString( "<mo>⁡</mo>", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testApplyFunction3() {
|
|
|
|
$input = "\sin{x}";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mo>⁡</mo>", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testApplyFunction4() {
|
|
|
|
$input = "\sin \sin";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mo>⁡</mo>", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testApplyFunction5() {
|
|
|
|
$input = "\cos(x)";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mo>⁡</mo>", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
2023-10-11 09:20:34 +00:00
|
|
|
public function testSpacesNoMstyle() {
|
|
|
|
$input = "\bmod \, \!";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "mspace", $mathMLtexVC );
|
|
|
|
$this->assertStringNotContainsString( "mstyle", $mathMLtexVC );
|
|
|
|
}
|
2023-10-05 10:08:15 +00:00
|
|
|
|
2023-10-11 09:21:53 +00:00
|
|
|
public function testBigl() {
|
|
|
|
$input = "\bigl(";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( TexClass::OPEN, $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
2023-10-26 14:48:19 +00:00
|
|
|
public function testMsupNumChild1() {
|
|
|
|
$input = "\sum^{^N}_{k}";
|
|
|
|
$mathMLtexVC = str_replace( [ "\n", " " ], "", $this->generateMML( $input ) );
|
|
|
|
$this->assertStringContainsString( "<msup><mi/><mrow", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testMsupNumChild2() {
|
|
|
|
$input = "\sum^{a^N}_{k}";
|
|
|
|
$mathMLtexVC = str_replace( [ "\n", " " ], "", $this->generateMML( $input ) );
|
|
|
|
$this->assertStringNotContainsString( "<msup><mi/><mrow", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testUndersetNumChild() {
|
|
|
|
$input = "\underset{\mathrm{def}}{}";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringNotContainsString( "munder", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testUndersetNumChild2() {
|
|
|
|
$input = "\underset{\mathrm{def}}{\mathrm{g}}";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "munder", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
2023-10-13 10:43:42 +00:00
|
|
|
public function testAlignLeft() {
|
|
|
|
$input = " \begin{align} f(x) & = (a+b)^2 \\ & = a^2+2ab+b^2 \\ \\end{align} ";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
2024-10-12 21:59:22 +00:00
|
|
|
$this->assertStringContainsString( "columnalign=\"right left right", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "columnspacing=\"0em 2em 0em", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "rowspacing=\"3pt\"", $mathMLtexVC );
|
2023-10-13 10:43:42 +00:00
|
|
|
$this->assertStringContainsString( "mtable", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
2023-10-13 10:41:37 +00:00
|
|
|
public function testLeftRightAttributes() {
|
|
|
|
$input = "\\left( \\right) \\left[ \\right]";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mo", $mathMLtexVC );
|
|
|
|
$this->assertStringNotContainsString( "stretchy", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
2023-10-10 09:31:12 +00:00
|
|
|
public function testIntbar1() {
|
|
|
|
$input = "\intbar";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mo", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "⨍", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testIntBar2() {
|
|
|
|
$input = "\intBar";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mo", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "⨎", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
2023-10-05 10:08:15 +00:00
|
|
|
public function testAtop() {
|
|
|
|
$input = "{ a \atop b }";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mfrac linethickness=\"0\">", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testChoose() {
|
|
|
|
$input = "{ a \choose b }";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mfrac linethickness=\"0\">", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( ")", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "(", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testOver() {
|
|
|
|
$input = "{a \over b }";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mfrac>", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
2023-09-27 11:32:33 +00:00
|
|
|
public function testBigcup() {
|
|
|
|
$input = "\bigcup_{i=_1}^n E_i";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "munderover", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testBigcap() {
|
|
|
|
$input = "\bigcap_{i=_1}^n E_i";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "munderover", $mathMLtexVC );
|
|
|
|
}
|
2023-09-21 11:59:58 +00:00
|
|
|
|
2023-09-28 13:31:00 +00:00
|
|
|
public function testScriptAlignment() {
|
|
|
|
$input = "\log_{10} f";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringNotContainsString( "<mo></mo>", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "<msub>", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
2023-09-25 13:38:10 +00:00
|
|
|
public function testNotOperatorname() {
|
|
|
|
$input = "\\not\operatorname{R}";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mpadded width=\"0\">", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "<mtext>⧸</mtext>", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
2023-09-21 11:59:58 +00:00
|
|
|
public function testUnder() {
|
|
|
|
$input = "\\underbrace{ a+b+\\cdots+z }_{26}";
|
2023-09-21 10:33:50 +00:00
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
2024-03-10 20:59:19 +00:00
|
|
|
$this->assertStringContainsString( "<munder>", $mathMLtexVC );
|
|
|
|
$this->assertStringNotContainsString( "<msub>", $mathMLtexVC );
|
2023-09-21 10:33:50 +00:00
|
|
|
}
|
2023-09-19 09:32:55 +00:00
|
|
|
|
2023-09-21 11:59:58 +00:00
|
|
|
public function testSumDisplaystyle() {
|
|
|
|
$input = "\sum_{k=1}^N k^2";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mstyle displaystyle=\"true\" scriptlevel=\"0\">", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSumTextstyle() {
|
|
|
|
$input = "\\textstyle \sum_{k=1}^N k^2";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mstyle displaystyle=\"false\" scriptlevel=\"0\">", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
2023-09-20 14:40:57 +00:00
|
|
|
public function testPilcrow() {
|
|
|
|
$input = "\P";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
2024-03-10 20:59:19 +00:00
|
|
|
$this->assertStringContainsString( "<mo>¶</mo>\n</math>", $mathMLtexVC );
|
2023-09-20 14:40:57 +00:00
|
|
|
}
|
|
|
|
|
2023-09-19 09:32:55 +00:00
|
|
|
public function testLesserThan() {
|
|
|
|
$input = "<, \\nless,";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
2023-09-20 14:40:57 +00:00
|
|
|
$this->assertStringContainsString( "<mo><</mo>", $mathMLtexVC );
|
2023-09-19 09:32:55 +00:00
|
|
|
}
|
|
|
|
|
2023-03-02 10:40:10 +00:00
|
|
|
public function testSidesetError() {
|
|
|
|
$input = "\\sideset{_1^2}{_3^4}";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
2023-09-20 14:40:57 +00:00
|
|
|
$this->assertStringContainsString( "merror", $mathMLtexVC );
|
2023-03-02 10:40:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testSidesetSum() {
|
|
|
|
$input = "\\sideset{_1^2}{_3^4}\\sum";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringNotContainsString( "merror", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "mmultiscripts", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "<mprescripts/>", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( ">∑", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSidesetProd() {
|
|
|
|
$input = "\\sideset{_1^2}{_3^4}\\prod";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringNotContainsString( "merror", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "mmultiscripts", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "<mprescripts/>", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( ">∏", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSidesetFQ() {
|
|
|
|
$input = "\\sideset{_1^2}{_3^4}\prod_a^b";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringNotContainsString( "merror", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "mmultiscripts", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "<mprescripts/>", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( ">∏", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "<mi>a</mi>", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "<mi>b</mi>", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "movablelimits", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
2023-03-02 14:28:26 +00:00
|
|
|
public function testLimitsProd() {
|
|
|
|
$input = "\\prod\\limits_{j=1}^k A_{\\alpha_j}";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "munderover", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "∏", $mathMLtexVC, );
|
|
|
|
$this->assertStringContainsString( "msub", $mathMLtexVC, );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testLimitsSum() {
|
|
|
|
$input = "\\sum\\limits_{j=1}^k A_{\\alpha_j}";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "munderover", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "∑", $mathMLtexVC, );
|
|
|
|
$this->assertStringContainsString( "msub", $mathMLtexVC, );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testLimitsLim() {
|
|
|
|
$input = "\\lim_{x \\to 2}";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "lim", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "munder", $mathMLtexVC, );
|
|
|
|
}
|
|
|
|
|
2023-03-16 12:24:05 +00:00
|
|
|
public function testRenderSpaceSemicolon() {
|
|
|
|
$input = "{\\;}";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "mspace", $mathMLtexVC, );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSpacesAndCommas() {
|
|
|
|
$input = "{a}{b , c}\\,";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mo>,", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "mspace", $mathMLtexVC, );
|
|
|
|
}
|
|
|
|
|
2023-03-21 15:06:32 +00:00
|
|
|
public function testPrecedingSubscriptsFQ() {
|
|
|
|
$input = "{}_1^2\\!\\Omega_3^4";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mrow " . Tag::CLASSTAG . "=\"ORD\"/>", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "msubsup", $mathMLtexVC, );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testPrecedingSubscriptsDQ() {
|
|
|
|
$input = "{}_pF_q";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mrow " . Tag::CLASSTAG . "=\"ORD\"/>", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "msub", $mathMLtexVC, );
|
|
|
|
}
|
|
|
|
|
2023-03-21 14:03:16 +00:00
|
|
|
public function testPilcrowAndSectionSign() {
|
|
|
|
$input = "\\P P \\S S";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mi>P", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "<mi>S", $mathMLtexVC, );
|
|
|
|
$this->assertStringContainsString( "¶", $mathMLtexVC, );
|
|
|
|
$this->assertStringContainsString( "§", $mathMLtexVC, );
|
|
|
|
}
|
|
|
|
|
2023-03-15 14:33:34 +00:00
|
|
|
public function testDerivatives1() {
|
|
|
|
$input = "b_{f''}";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mo>″", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "msup", $mathMLtexVC, );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testDerivatives2() {
|
|
|
|
$input = "f''''(x)";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mo>⁗", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "msup", $mathMLtexVC, );
|
|
|
|
}
|
|
|
|
|
2023-03-17 13:57:03 +00:00
|
|
|
public function testLimitsTextstyle() {
|
|
|
|
$input = "\\textstyle \\lim_{n \\to \\infty}x_n";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "lim", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "munder", $mathMLtexVC, );
|
|
|
|
$this->assertStringContainsString( "movablelimits=\"true\"", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
2023-03-22 09:01:32 +00:00
|
|
|
public function testColorGeneration1() {
|
|
|
|
$input = "\\color{Dandelion}{Dandelion}";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "#FDBC42", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testColorGeneration2() {
|
|
|
|
$input = "\\color{ForestGreen}{ForestGreen}";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "#009B55", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testColorGeneration3() {
|
|
|
|
$input = "\\color{Rhodamine}{Rhodamine}";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "#EF559F", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
2023-04-05 09:28:40 +00:00
|
|
|
public function testStyle1() {
|
|
|
|
$input = "\\displaystyle \{U(\omega )\cdot \sigma _{H}(\omega )\} z";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mstyle displaystyle=\"true\" scriptlevel=\"0\">", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "<mi>z</mi>", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "</mstyle>", $mathMLtexVC, );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testStyle2() {
|
|
|
|
$input = "\\displaystyle abc \\textstyle def";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mstyle displaystyle=\"false\" scriptlevel=\"0\">", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "</mstyle>", $mathMLtexVC, );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testStyle3() {
|
|
|
|
$input = "\\scriptstyle{abc} def \\textstyle ghi";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mstyle displaystyle=\"false\" scriptlevel=\"1\">", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "</mstyle>", $mathMLtexVC, );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testStyle4() {
|
|
|
|
$input = "\\textstyle b > \\textstyle \\delta";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$count = 0;
|
|
|
|
str_replace( "<mstyle displaystyle", "", $mathMLtexVC, $count );
|
|
|
|
$this->assertEquals( 2, $count );
|
|
|
|
}
|
|
|
|
|
2023-09-27 11:35:09 +00:00
|
|
|
public function testSpaceText() {
|
|
|
|
$input = "\\text{if}~n\ \\text{is even} ";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mspace", $mathMLtexVC );
|
2023-09-29 10:11:01 +00:00
|
|
|
$this->assertStringNotContainsString( " ", $mathMLtexVC );
|
2023-09-27 11:35:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testSpaceOther() {
|
|
|
|
// It is expected to render CR as whitespace
|
2023-04-05 09:55:25 +00:00
|
|
|
$input = "\,e_{x}=\sum _{t=1}^{\infty }\ _{t}p_{x}";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
2023-09-27 11:35:09 +00:00
|
|
|
$this->assertStringContainsString( "<mspace", $mathMLtexVC );
|
2023-04-05 09:55:25 +00:00
|
|
|
}
|
|
|
|
|
2023-04-05 11:53:51 +00:00
|
|
|
public function testGenfracDQ() {
|
|
|
|
$input = "\\binom{m}{k - j}_{\!\!q}";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "<mi>q</mi>", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "msub", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testDQZeroArgs() {
|
|
|
|
$input = "nF^{_{}}/RT";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "msup", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testMatrixDQ() {
|
|
|
|
$input = "\\begin{pmatrix} S \\\\Se\\\\Te\\end{pmatrix}_2";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "mtable", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "msub", $mathMLtexVC );
|
|
|
|
$this->assertStringContainsString( "<mn>2</mn>", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
2023-04-05 10:07:04 +00:00
|
|
|
public function testAttributeDuplicate() {
|
|
|
|
// This checks that there is some non-erronous output caused by double class attributes
|
|
|
|
$input = "\\mu_{\\operatorname{\\inf}}";
|
|
|
|
$mathMLtexVC = $this->generateMML( $input );
|
|
|
|
$this->assertStringContainsString( "μ", $mathMLtexVC );
|
|
|
|
}
|
|
|
|
|
2023-03-02 10:40:10 +00:00
|
|
|
private function generateMML( $input, $chem = false ) {
|
|
|
|
$texVC = new TexVC();
|
|
|
|
$resultT = $texVC->check( $input, [
|
|
|
|
'debug' => false,
|
|
|
|
'usemathrm' => false,
|
|
|
|
'oldtexvc' => false,
|
|
|
|
'usemhchem' => $chem
|
|
|
|
] );
|
|
|
|
|
|
|
|
return MMLTestUtil::getMMLwrapped( $resultT["input"] ) ?? "<math> error texvc </math>";
|
|
|
|
}
|
|
|
|
}
|