Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7400014
MhchemBasicMMLTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
9 KB
Referenced Files
None
Subscribers
None
MhchemBasicMMLTest.php
View Options
<?php
namespace
MediaWiki\Extension\Math\WikiTexVC\Mhchem
;
use
MediaWiki\Extension\Math\WikiTexVC\TexVC
;
use
MediaWikiUnitTestCase
;
/**
* Some simple tests for testing MML output of TeXVC for
* equations containing mhchem. Test parsing the new TeX-commands introduced
* to WikiTexVC for parsing texified mhchem output.
*
* @covers \MediaWiki\Extension\Math\WikiTexVC\TexVC
*
*/
final
class
MhchemBasicMMLTest
extends
MediaWikiUnitTestCase
{
public
function
testGUIStyleNotation
()
{
$input
=
"{
\d
isplaystyle
\c
e{ C6H5-CHO }}"
;
$texVC
=
new
TexVC
();
$options
=
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
];
$warnings
=
[];
$res
=
$texVC
->
check
(
$input
,
$options
,
$warnings
,
true
);
$mml
=
$res
[
'input'
]->
renderMML
();
$this
->
assertStringContainsString
(
'<mpadded'
,
$mml
);
$this
->
assertStringContainsString
(
'<mphantom'
,
$mml
);
}
public
static
function
provideTestCasesLetters
()
{
return
[
[
"Alpha"
,
"A"
],
[
"Beta"
,
"B"
],
[
"Chi"
,
"X"
],
[
"Epsilon"
,
"E"
],
[
"Eta"
,
"H"
],
[
"Iota"
,
"I"
],
[
"Kappa"
,
"K"
],
[
"Mu"
,
"M"
],
[
"Nu"
,
"N"
],
[
"Omicron"
,
"O"
],
[
"Rho"
,
"P"
],
[
"Tau"
,
"T"
],
[
"Zeta"
,
"Z"
]
];
}
/**
* @dataProvider provideTestCasesLetters
*/
public
function
testmhchemLetters
(
$case
,
$result
)
{
$input
=
"
\c
e{
\\
"
.
$case
.
"
\c
a }"
;
$texVC
=
new
TexVC
();
$options
=
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
];
$warnings
=
[];
$res
=
$texVC
->
check
(
$input
,
$options
,
$warnings
,
true
);
$mml
=
$res
[
'input'
]->
renderMML
();
$this
->
assertStringContainsString
(
'<mi'
,
$mml
);
$this
->
assertStringContainsString
(
$result
.
'</mi>'
,
$mml
);
$this
->
assertStringContainsString
(
'∼</mo>'
,
$mml
);
}
public
function
testHarpoonsLeftRight
()
{
$input
=
"A
\\
longLeftrightharpoons L"
;
$texVC
=
new
TexVC
();
$options
=
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
];
$warnings
=
[];
$res
=
$texVC
->
check
(
$input
,
$options
,
$warnings
,
true
);
$mml
=
$res
[
'input'
]->
renderMML
();
$this
->
assertStringContainsString
(
'<mpadded height="0" depth="0">'
,
$mml
);
$this
->
assertStringContainsString
(
'<mspace '
,
$mml
);
}
public
function
testHarpoonsRightLeft
()
{
$input
=
"A
\\
longRightleftharpoons R"
;
$texVC
=
new
TexVC
();
$options
=
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
];
$warnings
=
[];
$res
=
$texVC
->
check
(
$input
,
$options
,
$warnings
,
true
);
$mml
=
$res
[
'input'
]->
renderMML
();
$this
->
assertStringContainsString
(
'−</mo>'
,
$mml
);
$this
->
assertStringContainsString
(
'⇀'
,
$mml
);
$this
->
assertStringContainsString
(
'<mpadded height="0" depth="0">'
,
$mml
);
$this
->
assertStringContainsString
(
'<mspace '
,
$mml
);
}
public
function
testArrowsLeftRight
()
{
$input
=
"A
\\
longleftrightarrows C"
;
$texVC
=
new
TexVC
();
$options
=
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
];
$warnings
=
[];
$res
=
$texVC
->
check
(
$input
,
$options
,
$warnings
,
true
);
$mml
=
$res
[
'input'
]->
renderMML
();
$this
->
assertStringContainsString
(
'<mo stretchy="false">⟵</mo>'
,
$mml
);
$this
->
assertStringContainsString
(
'<mo stretchy="false">⟶</mo>'
,
$mml
);
$this
->
assertStringContainsString
(
'<mpadded height="0" depth="0">'
,
$mml
);
$this
->
assertStringContainsString
(
'<mspace '
,
$mml
);
}
public
function
testTripleDash
()
{
$input
=
"
\\
tripledash
\\
frac{a}{b}"
;
$texVC
=
new
TexVC
();
$options
=
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
];
$warnings
=
[];
$res
=
$texVC
->
check
(
$input
,
$options
,
$warnings
,
true
);
$this
->
assertStringContainsString
(
'<mo>—</mo>'
,
$res
[
'input'
]->
renderMML
()
);
}
public
function
testMathchoiceDisplaystyle
()
{
$input
=
"
\\
displaystyle{
\\
mathchoice{a}{b}{c}{d}}"
;
$texVC
=
new
TexVC
();
$options
=
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
];
$warnings
=
[];
$res
=
$texVC
->
check
(
$input
,
$options
,
$warnings
,
true
);
$this
->
assertStringContainsString
(
'<mstyle displaystyle="true" scriptlevel="0"><mi>a</mi></mstyle>'
,
$res
[
'input'
]->
renderMML
()
);
}
public
function
testMathchoiceTextstyle
()
{
$input
=
"
\\
textstyle{
\\
mathchoice{a}{b}{c}{d}}"
;
$texVC
=
new
TexVC
();
$options
=
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
];
$warnings
=
[];
$res
=
$texVC
->
check
(
$input
,
$options
,
$warnings
,
true
);
$this
->
assertStringContainsString
(
'<mstyle displaystyle="false" scriptlevel="0"><mi>b</mi></mstyle>'
,
$res
[
'input'
]->
renderMML
()
);
}
public
function
testMathchoiceScriptstyle
()
{
$input
=
"
\\
scriptstyle{
\\
mathchoice{a}{b}{c}{d}}"
;
$texVC
=
new
TexVC
();
$options
=
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
];
$warnings
=
[];
$res
=
$texVC
->
check
(
$input
,
$options
,
$warnings
,
true
);
$this
->
assertStringContainsString
(
'<mstyle displaystyle="false" scriptlevel="1"><mi>c</mi></mstyle>'
,
$res
[
'input'
]->
renderMML
()
);
}
public
function
testMathchoiceScriptScriptstyle
()
{
$input
=
"
\\
scriptscriptstyle{
\\
mathchoice{a}{b}{c}{d}}"
;
$texVC
=
new
TexVC
();
$options
=
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
];
$warnings
=
[];
$res
=
$texVC
->
check
(
$input
,
$options
,
$warnings
,
true
);
$this
->
assertStringContainsString
(
'<mstyle displaystyle="false" scriptlevel="2"><mi>d</mi></mstyle>'
,
$res
[
'input'
]->
renderMML
()
);
}
public
function
testMskip
()
{
$input
=
"
\\
ce{Cr^{+3}(aq)}"
;
$texVC
=
new
TexVC
();
$options
=
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
];
$warnings
=
[];
$checkRes
=
$texVC
->
check
(
$input
,
$options
,
$warnings
,
true
);
$this
->
assertStringContainsString
(
'<mspace width="0.111em"></mspace>'
,
$checkRes
[
"input"
]->
renderMML
()
);
}
public
function
testMkern
()
{
$input
=
"
\\
ce{A, B}"
;
$texVC
=
new
TexVC
();
$options
=
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
];
$warnings
=
[];
$checkRes
=
$texVC
->
check
(
$input
,
$options
,
$warnings
,
true
);
$this
->
assertStringContainsString
(
'<mspace width="0.333em"></mspace>'
,
$checkRes
[
"input"
]->
renderMML
()
);
}
public
function
testRaise
()
{
$input
=
"
\\
raise{.2em}{-}"
;
$texVC
=
new
TexVC
();
$warnings
=
[];
$checkRes
=
$texVC
->
check
(
$input
,
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
],
$warnings
,
true
);
$this
->
assertStringContainsString
(
'<mpadded height="+.2em" depth="-.2em" voffset="+.2em">'
,
$checkRes
[
"input"
]->
renderMML
()
);
}
public
function
testLower
()
{
$input
=
"
\\
lower{1em}{-}"
;
$texVC
=
new
TexVC
();
$warnings
=
[];
$checkRes
=
$texVC
->
check
(
$input
,
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
],
$warnings
,
true
);
$this
->
assertStringContainsString
(
'<mpadded height="-1em" depth="+1em" voffset="-1em">'
,
$checkRes
[
"input"
]->
renderMML
()
);
}
public
function
testLower2
()
{
$input
=
"
\\
lower{-1em}{b}"
;
$texVC
=
new
TexVC
();
$warnings
=
[];
$checkRes
=
$texVC
->
check
(
$input
,
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
],
$warnings
,
true
);
$this
->
assertStringContainsString
(
'<mpadded height="+1em" depth="-1em" voffset="+1em">'
,
$checkRes
[
"input"
]->
renderMML
()
);
}
public
function
testLlap
()
{
$input
=
"
\\
llap{4}"
;
$texVC
=
new
TexVC
();
$warnings
=
[];
$checkRes
=
$texVC
->
check
(
$input
,
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
],
$warnings
,
true
);
$this
->
assertStringContainsString
(
'<mpadded width="0" lspace="-1width"><mn>4</mn></mpadded>'
,
$checkRes
[
"input"
]->
renderMML
()
);
}
public
function
testRlap
()
{
$input
=
"
\\
rlap{-}"
;
$texVC
=
new
TexVC
();
$warnings
=
[];
$checkRes
=
$texVC
->
check
(
$input
,
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
],
$warnings
,
true
);
$this
->
assertStringContainsString
(
'−</mo></mpadded>'
,
$checkRes
[
"input"
]->
renderMML
()
);
}
public
function
testSmash1
()
{
$input
=
"
\c
e{
\\
smash[t]{2}}"
;
$texVC
=
new
TexVC
();
$warnings
=
[];
$checkRes
=
$texVC
->
check
(
$input
,
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
],
$warnings
,
true
);
$this
->
assertStringContainsString
(
'<mpadded height="0">'
,
$checkRes
[
"input"
]->
renderMML
()
);
}
public
function
testSmash2
()
{
$input
=
"
\c
e{
\\
smash[b]{x}}"
;
$texVC
=
new
TexVC
();
$warnings
=
[];
$checkRes
=
$texVC
->
check
(
$input
,
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
],
$warnings
,
true
);
$this
->
assertStringContainsString
(
'<mpadded depth="0">'
,
$checkRes
[
"input"
]->
renderMML
()
);
}
public
function
testSmash3
()
{
$input
=
"
\c
e{
\\
smash[bt]{2}}"
;
$texVC
=
new
TexVC
();
$warnings
=
[];
$checkRes
=
$texVC
->
check
(
$input
,
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
],
$warnings
,
true
);
$this
->
assertStringContainsString
(
'<mpadded height="0" depth="0">'
,
$checkRes
[
"input"
]->
renderMML
()
);
}
public
function
testSmash4
()
{
$input
=
"
\c
e{
\\
smash[tb]{2}}"
;
$texVC
=
new
TexVC
();
$warnings
=
[];
$checkRes
=
$texVC
->
check
(
$input
,
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
],
$warnings
,
true
);
$this
->
assertStringContainsString
(
'<mpadded height="0" depth="0">'
,
$checkRes
[
"input"
]->
renderMML
()
);
}
public
function
testSmash5
()
{
$input
=
"
\c
e{
\\
smash{2}}"
;
$texVC
=
new
TexVC
();
$warnings
=
[];
$checkRes
=
$texVC
->
check
(
$input
,
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
],
$warnings
,
true
);
$ar
=
$checkRes
[
"input"
]->
renderMML
();
$this
->
assertStringContainsString
(
'<mpadded height="0" depth="0"'
,
$ar
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 21, 16:26 (9 h, 13 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
7e/d2/de12514ee05fdfe357f2363756af
Default Alt Text
MhchemBasicMMLTest.php (9 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment