Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7401865
MhchemBasicMMLTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
MhchemBasicMMLTest.php
View Options
<?php
namespace
MediaWiki\Extension\Math\WikiTexVC\Mhchem
;
use
MediaWiki\Extension\Math\WikiTexVC\TexVC
;
use
MediaWikiIntegrationTestCase
;
/**
* 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
MediaWikiIntegrationTestCase
{
public
static
function
provideTestCasesLetters
():
array
{
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"
]
];
}
public
static
function
provideTexVCCheckData
():
array
{
$letters
=
[];
foreach
(
self
::
provideTestCasesLetters
()
as
$value
)
{
$letters
[]
=
[
"
\c
e{
\\
"
.
$value
[
0
]
.
"
\c
a }"
,
[
'<mi'
,
$value
[
1
]
.
'</mi>'
,
'∼</mo>'
]
];
}
return
$letters
+
[
[
"{
\d
isplaystyle
\c
e{ C6H5-CHO }}"
,
[
'<mpadded'
,
'<mphantom'
]
],
[
"A
\\
longLeftrightharpoons L"
,
[
'<mpadded height="0" depth="0">'
,
'<mspace '
]
],
[
"A
\\
longRightleftharpoons R"
,
[
'−</mo>'
,
'⇀'
,
'<mpadded height="0" depth="0">'
,
'<mspace '
,
]
],
[
"A
\\
longleftrightarrows C"
,
[
'<mo stretchy="false">⟵</mo>'
,
'<mo stretchy="false">⟶</mo>'
,
'<mpadded height="0" depth="0">'
,
'<mspace '
]
],
[
"
\\
tripledash
\\
frac{a}{b}"
,
[
'<mo>—</mo>'
]
],
[
"
\\
displaystyle{
\\
mathchoice{a}{b}{c}{d}}"
,
[
'<mstyle displaystyle="true" scriptlevel="0"><mi>a</mi></mstyle>'
]
],
[
"
\\
textstyle{
\\
mathchoice{a}{b}{c}{d}}"
,
[
'<mstyle displaystyle="false" scriptlevel="0"><mi>b</mi></mstyle>'
]
],
[
"
\\
scriptstyle{
\\
mathchoice{a}{b}{c}{d}}"
,
[
'<mstyle displaystyle="false" scriptlevel="1"><mi>c</mi></mstyle>'
]
],
[
"
\\
scriptscriptstyle{
\\
mathchoice{a}{b}{c}{d}}"
,
[
'<mstyle displaystyle="false" scriptlevel="2"><mi>d</mi></mstyle>'
]
],
[
"
\\
ce{Cr^{+3}(aq)}"
,
[
'<mspace width="0.111em"></mspace>'
]
],
[
"
\\
ce{A, B}"
,
[
'<mspace width="0.333em"></mspace>'
]
],
[
"
\\
raise{.2em}{-}"
,
[
'<mpadded height="+.2em" depth="-.2em" voffset="+.2em">'
]
],
[
"
\\
lower{1em}{-}"
,
[
'<mpadded height="-1em" depth="+1em" voffset="-1em">'
]
],
[
"
\\
lower{-1em}{b}"
,
[
'<mpadded height="+1em" depth="-1em" voffset="+1em">'
]
],
[
"
\\
llap{4}"
,
[
'<mpadded width="0" lspace="-1width"><mn>4</mn></mpadded>'
]
],
[
"
\\
rlap{-}"
,
[
'−</mo></mpadded>'
]
],
[
"
\c
e{
\\
smash[t]{2}}"
,
[
'<mpadded height="0">'
]
],
[
"
\c
e{
\\
smash[b]{x}}"
,
[
'<mpadded depth="0">'
]
],
[
"
\c
e{
\\
smash[bt]{2}}"
,
[
'<mpadded height="0" depth="0">'
]
],
[
"
\c
e{
\\
smash[tb]{2}}"
,
[
'<mpadded height="0" depth="0">'
]
],
[
"
\c
e{
\\
smash{2}}"
,
[
'<mpadded height="0" depth="0"'
]
],
];
}
/** @dataProvider provideTexVCCheckData */
public
function
testTexVCCheck
(
string
$input
,
array
$output
)
{
$texVC
=
new
TexVC
();
$options
=
[
"usemhchem"
=>
true
,
"usemhchemtexified"
=>
true
];
$warnings
=
[];
$res
=
$texVC
->
check
(
$input
,
$options
,
$warnings
,
true
);
foreach
(
$output
as
$value
)
{
$this
->
assertStringContainsString
(
$value
,
$res
[
'input'
]->
toMMLtree
()
);
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 21, 17:42 (14 h, 16 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
fb/b0/3ce5e6e252f4630310e194a1bc35
Default Alt Text
MhchemBasicMMLTest.php (3 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment