Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5978567
MMLRenderTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
20 KB
Referenced Files
None
Subscribers
None
MMLRenderTest.php
View Options
<?php
namespace
MediaWiki\Extension\Math\Tests\WikiTexVC
;
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
;
use
MediaWikiIntegrationTestCase
;
/**
* These are some specific testcases by MML-Rendering by WikiTexVC.
* They are explicitly described here instead of in JSON files because
* Mathoid or LaTeXML do not generate suitable results for reference.
* @covers \MediaWiki\Extension\Math\WikiTexVC\TexVC
*/
class
MMLRenderTest
extends
MediaWikiIntegrationTestCase
{
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
);
}
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
);
}
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
);
}
public
function
testBoldUnicode
()
{
$input
=
"
\\
mathbf{4}, {
\\
bf Q} {
\\
bf a}"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
'𝐚'
,
$mathMLtexVC
);
$this
->
assertStringContainsString
(
'𝐐'
,
$mathMLtexVC
);
$this
->
assertStringContainsString
(
'𝟒'
,
$mathMLtexVC
);
}
public
function
testNoLimits
()
{
$input
=
"
\\
displaystyle
\i
nt
\\
nolimits_0^
\i
nfty f(x) dx"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
'movablelimits="false"'
,
$mathMLtexVC
);
$this
->
assertStringNotContainsString
(
"nolimits"
,
$mathMLtexVC
);
}
public
function
testGenfracStretching
()
{
$input
=
"
\\
tbinom{n}{k}
\\
dbinom{n}{k}
\\
binom{n}{k}"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringNotContainsString
(
"maxsize"
,
$mathMLtexVC
);
}
public
function
testBracketSizesOpen
()
{
$input
=
"
\b
igl(
\B
igl(
\b
iggl(
\B
iggl( "
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
'minsize'
,
$mathMLtexVC
);
$this
->
assertStringContainsString
(
'maxsize'
,
$mathMLtexVC
);
}
public
function
testBracketSizesClose
()
{
$input
=
"
\b
igr)
\B
igr)
\b
iggr)
\B
iggr) "
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
'minsize'
,
$mathMLtexVC
);
$this
->
assertStringContainsString
(
'maxsize'
,
$mathMLtexVC
);
}
public
function
testLimOperatorSpacing
()
{
$input
=
"
\l
iminf v,
\l
imsup w
\i
njlim x
\p
rojlim 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
);
}
public
function
testTrimNull
()
{
$input
=
"
\\
bigl(
\\
begin{smallmatrix}a&b
\\\\
c&d
\\
end{smallmatrix}
\\
bigr)"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"mtable"
,
$mathMLtexVC
);
}
public
function
testApplyOperator1
()
{
$input
=
"
\s
up x"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"<mo>⁡</mo>"
,
$mathMLtexVC
);
}
public
function
testApplyOperator2
()
{
$input
=
"
\s
up"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringNotContainsString
(
"<mo>⁡</mo>"
,
$mathMLtexVC
);
}
public
function
testApplyOperator3
()
{
$input
=
"
\s
up
\s
in"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"<mo>⁡</mo>"
,
$mathMLtexVC
);
}
public
function
testApplyFunction1
()
{
$input
=
"
\s
in x"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"<mo>⁡</mo>"
,
$mathMLtexVC
);
}
public
function
testApplyFunction2
()
{
$input
=
"
\s
in"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringNotContainsString
(
"<mo>⁡</mo>"
,
$mathMLtexVC
);
}
public
function
testApplyFunction3
()
{
$input
=
"
\s
in{x}"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"<mo>⁡</mo>"
,
$mathMLtexVC
);
}
public
function
testApplyFunction4
()
{
$input
=
"
\s
in
\s
in"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"<mo>⁡</mo>"
,
$mathMLtexVC
);
}
public
function
testApplyFunction5
()
{
$input
=
"
\c
os(x)"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"<mo>⁡</mo>"
,
$mathMLtexVC
);
}
public
function
testApplyFunction6
()
{
$input
=
"
\s
in
\c
os^2"
;
$mathMLtexVC
=
preg_replace
(
'/
\s
+/'
,
''
,
$this
->
generateMML
(
$input
)
);
$this
->
assertStringContainsString
(
"<msup><mi>cos</mi><mrow"
,
$mathMLtexVC
);
$this
->
assertStringContainsString
(
"sin"
,
$mathMLtexVC
);
}
public
function
testSpacesNoMstyle
()
{
$input
=
"
\b
mod
\,
\!
"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"mspace"
,
$mathMLtexVC
);
$this
->
assertStringNotContainsString
(
"mstyle"
,
$mathMLtexVC
);
}
public
function
testBigl
()
{
$input
=
"
\b
igl("
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
TexClass
::
OPEN
,
$mathMLtexVC
);
}
public
function
testMsupNumChild1
()
{
$input
=
"
\s
um^{^N}_{k}"
;
$mathMLtexVC
=
str_replace
(
[
"
\n
"
,
" "
],
""
,
$this
->
generateMML
(
$input
)
);
$this
->
assertStringContainsString
(
"<msup><mi/><mrow"
,
$mathMLtexVC
);
}
public
function
testMsupNumChild2
()
{
$input
=
"
\s
um^{a^N}_{k}"
;
$mathMLtexVC
=
str_replace
(
[
"
\n
"
,
" "
],
""
,
$this
->
generateMML
(
$input
)
);
$this
->
assertStringNotContainsString
(
"<msup><mi/><mrow"
,
$mathMLtexVC
);
}
public
function
testUndersetNumChild
()
{
$input
=
"
\u
nderset{
\m
athrm{def}}{}"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringNotContainsString
(
"munder"
,
$mathMLtexVC
);
}
public
function
testUndersetNumChild2
()
{
$input
=
"
\u
nderset{
\m
athrm{def}}{
\m
athrm{g}}"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"munder"
,
$mathMLtexVC
);
}
public
function
testAlignLeft
()
{
$input
=
"
\b
egin{align} f(x) & = (a+b)^2
\\
& = a^2+2ab+b^2
\\
\\
end{align} "
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"mtable"
,
$mathMLtexVC
);
}
public
function
testLeftRightAttributes
()
{
$input
=
"
\\
left(
\\
right)
\\
left[
\\
right]"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"<mo"
,
$mathMLtexVC
);
$this
->
assertStringNotContainsString
(
"stretchy"
,
$mathMLtexVC
);
}
public
function
testIntbar1
()
{
$input
=
"
\i
ntbar"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"<mo"
,
$mathMLtexVC
);
$this
->
assertStringContainsString
(
"⨍"
,
$mathMLtexVC
);
}
public
function
testIntBar2
()
{
$input
=
"
\i
ntBar"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"<mo"
,
$mathMLtexVC
);
$this
->
assertStringContainsString
(
"⨎"
,
$mathMLtexVC
);
}
public
function
testAtop
()
{
$input
=
"{ a
\a
top b }"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"<mfrac linethickness=
\"
0
\"
>"
,
$mathMLtexVC
);
}
public
function
testChoose
()
{
$input
=
"{ a
\c
hoose b }"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"<mfrac linethickness=
\"
0
\"
>"
,
$mathMLtexVC
);
$this
->
assertStringContainsString
(
")"
,
$mathMLtexVC
);
$this
->
assertStringContainsString
(
"("
,
$mathMLtexVC
);
}
public
function
testOver
()
{
$input
=
"{a
\o
ver b }"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"<mfrac>"
,
$mathMLtexVC
);
}
public
function
testBigcup
()
{
$input
=
"
\b
igcup_{i=_1}^n E_i"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"munderover"
,
$mathMLtexVC
);
}
public
function
testBigcap
()
{
$input
=
"
\b
igcap_{i=_1}^n E_i"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"munderover"
,
$mathMLtexVC
);
}
public
function
testScriptAlignment
()
{
$input
=
"
\l
og_{10} f"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringNotContainsString
(
"<mo></mo>"
,
$mathMLtexVC
);
$this
->
assertStringContainsString
(
"<msub>"
,
$mathMLtexVC
);
}
public
function
testNotOperatorname
()
{
$input
=
"
\\
not
\o
peratorname{R}"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"<mpadded width=
\"
0
\"
>"
,
$mathMLtexVC
);
$this
->
assertStringContainsString
(
"<mtext>⧸</mtext>"
,
$mathMLtexVC
);
}
public
function
testUnder
()
{
$input
=
"
\\
underbrace{ a+b+
\\
cdots+z }_{26}"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"<munder>"
,
$mathMLtexVC
);
$this
->
assertStringNotContainsString
(
"<msub>"
,
$mathMLtexVC
);
}
public
function
testSumDisplaystyle
()
{
$input
=
"
\s
um_{k=1}^N k^2"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"<mstyle displaystyle=
\"
true
\"
scriptlevel=
\"
0
\"
>"
,
$mathMLtexVC
);
}
public
function
testSumTextstyle
()
{
$input
=
"
\\
textstyle
\s
um_{k=1}^N k^2"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"<mstyle displaystyle=
\"
false
\"
scriptlevel=
\"
0
\"
>"
,
$mathMLtexVC
);
}
public
function
testPilcrow
()
{
$input
=
"
\P
"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"<mo>¶</mo>
\n
</math>"
,
$mathMLtexVC
);
}
public
function
testLesserThan
()
{
$input
=
"<,
\\
nless,"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"<mo><</mo>"
,
$mathMLtexVC
);
}
public
function
testSidesetError
()
{
$input
=
"
\\
sideset{_1^2}{_3^4}"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"merror"
,
$mathMLtexVC
);
}
public
function
testEmptySidesetDQ
()
{
$input
=
"
\\
sideset{}{}a_b"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringNotContainsString
(
"merror"
,
$mathMLtexVC
);
}
public
function
testEmptySidesetUQ
()
{
$input
=
"
\\
sideset{}{}a^b"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringNotContainsString
(
"merror"
,
$mathMLtexVC
);
}
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}
\p
rod_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
);
}
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
,
);
}
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
,
);
}
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
,
);
}
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
,
);
}
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
,
);
}
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
);
}
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
);
}
public
function
testStyle1
()
{
$input
=
"
\\
displaystyle
\{
U(
\o
mega )
\c
dot
\s
igma _{H}(
\o
mega )
\}
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
);
}
public
function
testSpaceText
()
{
$input
=
"
\\
text{if}~n
\ \\
text{is even} "
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"<mtext"
,
$mathMLtexVC
);
$this
->
assertStringNotContainsString
(
" "
,
$mathMLtexVC
);
}
public
function
testSpaceOther
()
{
// It is expected to render CR as whitespace
$input
=
"
\,
e_{x}=
\s
um _{t=1}^{
\i
nfty }
\
_{t}p_{x}"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"<mspace"
,
$mathMLtexVC
);
}
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
);
}
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
);
}
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>"
;
}
public
function
testOperatorAccentPlain
()
{
// T384794
$input
=
"
\\
operatorname{a}'"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$posSupEnd
=
strpos
(
$mathMLtexVC
,
"</msup>"
);
$posFunApply
=
strpos
(
$mathMLtexVC
,
"⁡</mo>"
);
$posAccent
=
strpos
(
$mathMLtexVC
,
"′</mo>"
);
$posA
=
strpos
(
$mathMLtexVC
,
"a</mi>"
);
$this
->
assertGreaterThan
(
$posSupEnd
,
$posFunApply
,
"Function application should be last"
);
$this
->
assertGreaterThan
(
$posAccent
,
$posSupEnd
,
"Accent needs to be within msup"
);
$this
->
assertGreaterThan
(
$posA
,
$posAccent
,
"Accent should follow a"
);
}
public
function
testOperatorAccentApplied
()
{
// T384794
$input
=
"
\\
operatorname{a}'x"
;
$mathMLtexVC
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"mo"
,
$mathMLtexVC
);
$this
->
assertStringContainsString
(
"msup"
,
$mathMLtexVC
);
$this
->
assertStringContainsString
(
"x2061;"
,
$mathMLtexVC
);
}
public
function
testAmsDelim1
()
{
$input
=
"
\\
ulcorner a
\\
urcorner"
;
$mml
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"⌜"
,
$mml
);
$this
->
assertStringContainsString
(
"⌝"
,
$mml
);
}
public
function
testlVert
()
{
$input
=
"
\\
lVert a
\\
rVert"
;
$mml
=
$this
->
generateMML
(
$input
);
$this
->
assertStringContainsString
(
"‖"
,
$mml
);
$this
->
assertStringNotContainsString
(
"OPEN"
,
$mml
);
$this
->
assertStringNotContainsString
(
"CLOSE"
,
$mml
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 20:27 (4 d, 10 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
f7/d1/d53f391d73b560dbb0c2b76f0397
Default Alt Text
MMLRenderTest.php (20 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment