| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Extension\Math\Tests\WikiTexVC; |
| 4 |
|
| 5 |
use MediaWiki\Extension\Math\WikiTexVC\TexVC; |
| 6 |
use MediaWikiUnitTestCase; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
class AllTest extends MediaWikiUnitTestCase { |
| 15 |
|
| 16 |
private $texVC; |
| 17 |
|
| 18 |
protected function setUp(): void { |
| 19 |
parent::setUp(); |
| 20 |
$this->texVC = new TexVC(); |
| 21 |
} |
| 22 |
|
| 23 |
public static function provideTestCases() { |
| 24 |
$DELIMITERS1 = [ '(', ')', '[', ']', '\\{', '\\}', '|' ]; |
| 25 |
$delim2 = '\\backslash\\downarrow\\Downarrow\\langle\\lbrace\\lceil\\lfloor' . |
| 26 |
'\\llcorner\\lrcorner\\rangle\\rbrace\\rceil\\rfloor\\rightleftharpoons' . |
| 27 |
'\\twoheadleftarrow\\twoheadrightarrow\\ulcorner\\uparrow\\Uparrow' . |
| 28 |
'\\updownarrow\\Updownarrow\\urcorner\\Vert\\vert\\lbrack\\rbrack'; |
| 29 |
$DELIMITERS2 = array_map( static function ( $f ) { |
| 30 |
return '\\' . $f; |
| 31 |
}, explode( '\\', $delim2 ) ); |
| 32 |
array_shift( $DELIMITERS2 ); |
| 33 |
|
| 34 |
$delim3 = '\\darr\\dArr\\Darr\\lang\\rang\\uarr\\uArr\\Uarr'; |
| 35 |
$DELIMITERS3 = array_map( static function ( $f ) { |
| 36 |
return '\\' . $f; |
| 37 |
}, explode( '\\', $delim3 ) ); |
| 38 |
array_shift( $DELIMITERS3 ); |
| 39 |
|
| 40 |
return [ |
| 41 |
'Box functions' => [ |
| 42 |
[ |
| 43 |
"input" => |
| 44 |
"\\text {-0-9a-zA-Z+*,=():/;?.!'` \u{0080}-\u{00FF}} " . |
| 45 |
"\\mbox {-0-9a-zA-Z+*,=():/;?.!'` \u{0080}-\u{00FF}} " . |
| 46 |
"\\hbox {-0-9a-zA-Z+*,=():/;?.!'` \u{0080}-\u{00FF}} " . |
| 47 |
"\\vbox {-0-9a-zA-Z+*,=():/;?.!'` \u{0080}-\u{00FF}} ", |
| 48 |
"output" => |
| 49 |
"{\\text{-0-9a-zA-Z+*,=():/;?.!'` \u{0080}-\u{00FF}}}" . |
| 50 |
"{\\mbox{-0-9a-zA-Z+*,=():/;?.!'` \u{0080}-\u{00FF}}}" . |
| 51 |
"{\\hbox{-0-9a-zA-Z+*,=():/;?.!'` \u{0080}-\u{00FF}}}" . |
| 52 |
"{\\vbox{-0-9a-zA-Z+*,=():/;?.!'` \u{0080}-\u{00FF}}}" |
| 53 |
] |
| 54 |
], |
| 55 |
'Box functions (2)' => [ |
| 56 |
[ |
| 57 |
'input' => '{\\text{ABC}}{\\mbox{ABC}}{\\hbox{ABC}}{\\vbox{ABC}}', |
| 58 |
'skipOcaml' => true |
| 59 |
] |
| 60 |
], |
| 61 |
'LaTeX functions' => [ |
| 62 |
[ |
| 63 |
'input' => |
| 64 |
'\\arccos \\arcsin \\arctan \\arg \\cosh \\cos \\cot \\coth ' . |
| 65 |
'\\csc \\deg \\det \\dim \\exp \\gcd \\hom \\inf \\ker \\lg ' . |
| 66 |
'\\lim \\liminf \\limsup \\ln \\log \\max \\min \\Pr \\sec ' . |
| 67 |
'\\sin \\sinh \\sup \\tan \\tanh ' |
| 68 |
] |
| 69 |
], |
| 70 |
'MediaWiki functions' => [ |
| 71 |
[ |
| 72 |
'input' => '\\arccot \\arcsec \\arccsc \\sgn \\sen ', |
| 73 |
'output' => |
| 74 |
'\\operatorname {arccot} \\operatorname {arcsec} ' . |
| 75 |
'\\operatorname {arccsc} \\operatorname {sgn} ' . |
| 76 |
'\\operatorname {sen} ' |
| 77 |
] |
| 78 |
], |
| 79 |
'MediaWiki functions args' => [ |
| 80 |
[ |
| 81 |
'input' => '\\arccot(x)\\sen(x)\\sen{x}', |
| 82 |
'output' => |
| 83 |
'\\operatorname {arccot} (x)\\operatorname {sen} (x)\\operatorname {sen} {x}' |
| 84 |
] |
| 85 |
], |
| 86 |
'Literals (1)' => [ |
| 87 |
[ |
| 88 |
'input' => |
| 89 |
'\\aleph \\alpha \\amalg \\And \\angle \\approx ' . |
| 90 |
'\\approxeq \\ast \\asymp \\backepsilon \\backprime ' . |
| 91 |
'\\backsim \\backsimeq \\barwedge \\Bbbk \\because \\beta ' . |
| 92 |
'\\beth \\between \\bigcap \\bigcirc \\bigcup \\bigodot ' . |
| 93 |
'\\bigoplus \\bigotimes \\bigsqcup \\bigstar ' . |
| 94 |
'\\bigtriangledown \\bigtriangleup \\biguplus \\bigvee ' . |
| 95 |
'\\bigwedge \\blacklozenge \\blacksquare \\blacktriangle ' . |
| 96 |
'\\blacktriangledown \\blacktriangleleft \\blacktriangleright ' . |
| 97 |
'\\bot \\bowtie \\Box \\boxdot \\boxminus \\boxplus ' . |
| 98 |
'\\boxtimes \\bullet \\bumpeq \\Bumpeq \\cap \\Cap \\cdot ' . |
| 99 |
'\\cdots \\centerdot \\checkmark \\chi \\circ \\circeq ' . |
| 100 |
'\\circlearrowleft \\circlearrowright \\circledast ' . |
| 101 |
'\\circledcirc \\circleddash \\circledS \\clubsuit \\colon ' . |
| 102 |
'\\complement \\cong \\coprod \\cup \\Cup ' . |
| 103 |
'\\curlyeqprec \\curlyeqsucc \\curlyvee \\curlywedge ' . |
| 104 |
'\\curvearrowleft \\curvearrowright \\dagger \\daleth ' . |
| 105 |
'\\dashv \\ddagger \\ddots \\delta \\Delta ' . |
| 106 |
'\\diagdown \\diagup \\diamond \\Diamond \\diamondsuit ' . |
| 107 |
'\\digamma \\displaystyle \\div \\divideontimes \\doteq ' . |
| 108 |
'\\doteqdot \\dotplus \\dots \\dotsb \\dotsc \\dotsi \\dotsm ' . |
| 109 |
'\\dotso \\doublebarwedge \\downdownarrows \\downharpoonleft ' . |
| 110 |
'\\downharpoonright \\ell \\emptyset \\epsilon \\eqcirc ' . |
| 111 |
'\\eqsim \\eqslantgtr \\eqslantless \\equiv \\eta \\eth ' . |
| 112 |
'\\exists \\fallingdotseq \\Finv \\flat \\forall \\frown ' . |
| 113 |
'\\Game \\gamma \\Gamma \\geq \\geqq \\geqslant \\gets \\gg ' . |
| 114 |
'\\ggg \\gimel \\gnapprox \\gneq \\gneqq \\gnsim \\gtrapprox ' . |
| 115 |
'\\gtrdot \\gtreqless \\gtreqqless \\gtrless \\gtrsim ' . |
| 116 |
'\\gvertneqq \\hbar \\heartsuit \\hookleftarrow ' . |
| 117 |
'\\hookrightarrow \\hslash \\iff \\iiiint \\iiint \\iint ' . |
| 118 |
'\\Im \\imath \\implies \\in \\infty \\injlim \\int ' . |
| 119 |
'\\intercal \\iota \\jmath \\kappa \\lambda \\Lambda \\land ' . |
| 120 |
'\\ldots \\leftarrow \\Leftarrow \\leftarrowtail ' . |
| 121 |
'\\leftharpoondown \\leftharpoonup \\leftleftarrows ' . |
| 122 |
'\\leftrightarrow \\Leftrightarrow \\leftrightarrows ' . |
| 123 |
'\\leftrightharpoons \\leftrightsquigarrow \\leftthreetimes ' . |
| 124 |
'\\leq \\leqq \\leqslant \\lessapprox \\lessdot ' . |
| 125 |
'\\lesseqgtr \\lesseqqgtr \\lessgtr \\lesssim \\limits \\ll ' . |
| 126 |
'\\Lleftarrow \\lll \\lnapprox \\lneq \\lneqq \\lnot \\lnsim ' . |
| 127 |
'\\longleftarrow \\Longleftarrow \\longleftrightarrow ' . |
| 128 |
'\\Longleftrightarrow \\longmapsto \\longrightarrow ' . |
| 129 |
'\\Longrightarrow \\looparrowleft \\looparrowright \\lor ' . |
| 130 |
'\\lozenge \\Lsh \\ltimes \\lVert \\lvertneqq \\mapsto ' . |
| 131 |
'\\measuredangle \\mho \\mid \\mod \\models \\mp \\mu ' . |
| 132 |
'\\multimap \\nabla \\natural \\ncong \\nearrow \\neg \\neq ' . |
| 133 |
'\\nexists \\ngeq \\ngeqq \\ngeqslant \\ngtr \\ni ' . |
| 134 |
'\\nleftarrow \\nLeftarrow \\nleftrightarrow ' . |
| 135 |
'\\nLeftrightarrow \\nleq \\nleqq \\nleqslant \\nless \\nmid ' . |
| 136 |
'\\nolimits \\not \\notin \\nparallel \\nprec \\npreceq ' . |
| 137 |
'\\nrightarrow \\nRightarrow \\nshortmid \\nshortparallel ' . |
| 138 |
'\\nsim \\nsubseteq \\nsubseteqq \\nsucc \\nsucceq ' . |
| 139 |
'\\nsupseteq \\nsupseteqq \\ntriangleleft \\ntrianglelefteq ' . |
| 140 |
'\\ntriangleright \\ntrianglerighteq \\nu \\nvdash \\nVdash ' . |
| 141 |
'\\nvDash \\nVDash \\nwarrow \\odot \\oint \\omega \\Omega ' . |
| 142 |
'\\ominus \\oplus \\oslash \\otimes ' . |
| 143 |
'\\P \\parallel \\partial ' . |
| 144 |
'\\perp \\phi \\Phi \\pi \\Pi \\pitchfork \\pm \\prec ' . |
| 145 |
'\\precapprox \\preccurlyeq \\preceq \\precnapprox ' . |
| 146 |
'\\precneqq \\precnsim \\precsim \\prime \\prod \\projlim ' . |
| 147 |
'\\propto \\psi \\Psi \\qquad \\quad \\Re \\rho \\rightarrow ' . |
| 148 |
'\\Rightarrow \\rightarrowtail \\rightharpoondown ' . |
| 149 |
'\\rightharpoonup \\rightleftarrows \\rightrightarrows ' . |
| 150 |
'\\rightsquigarrow \\rightthreetimes \\risingdotseq ' . |
| 151 |
'\\Rrightarrow \\Rsh \\rtimes \\rVert \\S ' . |
| 152 |
'\\scriptscriptstyle \\scriptstyle \\searrow \\setminus ' . |
| 153 |
'\\sharp \\shortmid \\shortparallel \\sigma \\Sigma \\sim ' . |
| 154 |
'\\simeq \\smallfrown \\smallsetminus \\smallsmile \\smile ' . |
| 155 |
'\\spadesuit \\sphericalangle \\sqcap \\sqcup \\sqsubset ' . |
| 156 |
'\\sqsubseteq \\sqsupset \\sqsupseteq \\square \\star ' . |
| 157 |
'\\subset \\Subset \\subseteq \\subseteqq \\subsetneq ' . |
| 158 |
'\\subsetneqq \\succ \\succapprox \\succcurlyeq \\succeq ' . |
| 159 |
'\\succnapprox \\succneqq \\succnsim \\succsim \\sum ' . |
| 160 |
'\\supset \\Supset \\supseteq \\supseteqq \\supsetneq ' . |
| 161 |
'\\supsetneqq \\surd \\swarrow \\tau \\textstyle ' . |
| 162 |
'\\therefore \\theta \\Theta ' . |
| 163 |
'\\thickapprox \\thicksim \\times \\to \\top \\triangle ' . |
| 164 |
'\\triangledown \\triangleleft \\trianglelefteq \\triangleq ' . |
| 165 |
'\\triangleright \\trianglerighteq ' . |
| 166 |
'\\upharpoonleft \\upharpoonright \\uplus \\upsilon ' . |
| 167 |
'\\Upsilon \\upuparrows \\varDelta \\varepsilon \\varGamma ' . |
| 168 |
'\\varinjlim \\varkappa \\varLambda \\varliminf \\varlimsup ' . |
| 169 |
'\\varnothing \\varOmega \\varphi \\varPhi \\varpi \\varPhi ' . |
| 170 |
'\\varprojlim \\varpropto \\varrho \\varsigma \\varSigma ' . |
| 171 |
'\\varsubsetneq \\varsubsetneqq \\varsupsetneq ' . |
| 172 |
'\\varsupsetneqq \\vartheta \\varTheta \\vartriangle ' . |
| 173 |
'\\vartriangleleft \\vartriangleright \\varUpsilon \\varXi ' . |
| 174 |
'\\vdash \\Vdash \\vDash \\vdots \\vee ' . |
| 175 |
'\\veebar \\vline \\Vvdash \\wedge ' . |
| 176 |
'\\wp \\wr \\xi \\Xi \\zeta ' |
| 177 |
] |
| 178 |
], |
| 179 |
'Literals (2)' => [ |
| 180 |
[ |
| 181 |
'input' => |
| 182 |
'\\AA\\Coppa\\coppa\\Digamma\\euro\\geneuro\\geneuronarrow' . |
| 183 |
'\\geneurowide\\Koppa\\koppa\\officialeuro\\Sampi\\sampi' . |
| 184 |
'\\Stigma\\stigma\\textvisiblespace\\varstigma', |
| 185 |
'output' => |
| 186 |
'\\mbox{\\AA} \\mbox{\\Coppa} \\mbox{\\coppa} ' . |
| 187 |
'\\mbox{\\Digamma} \\mbox{\\euro} \\mbox{\\geneuro} ' . |
| 188 |
'\\mbox{\\geneuronarrow} \\mbox{\\geneurowide} ' . |
| 189 |
'\\mbox{\\Koppa} \\mbox{\\koppa} \\mbox{\\officialeuro} ' . |
| 190 |
'\\mbox{\\Sampi} \\mbox{\\sampi} \\mbox{\\Stigma} ' . |
| 191 |
'\\mbox{\\stigma} \\mbox{\\textvisiblespace} ' . |
| 192 |
'\\mbox{\\varstigma} ' |
| 193 |
] |
| 194 |
], |
| 195 |
'Literals (2\')' => [ |
| 196 |
[ |
| 197 |
|
| 198 |
'input' => |
| 199 |
'\\mbox{\\AA} \\mbox{\\Coppa} \\mbox{\\coppa} ' . |
| 200 |
'\\mbox{\\Digamma} \\mbox{\\euro} \\mbox{\\geneuro} ' . |
| 201 |
'\\mbox{\\geneuronarrow} \\mbox{\\geneurowide} ' . |
| 202 |
'\\mbox{\\Koppa} \\mbox{\\koppa} \\mbox{\\officialeuro} ' . |
| 203 |
'\\mbox{\\Sampi} \\mbox{\\sampi} \\mbox{\\Stigma} ' . |
| 204 |
'\\mbox{\\stigma} \\mbox{\\textvisiblespace} ' . |
| 205 |
'\\mbox{\\varstigma} ', |
| 206 |
'skipOcaml' => true |
| 207 |
] |
| 208 |
], |
| 209 |
'Literals (2) MJ' => [ |
| 210 |
[ |
| 211 |
'usemathrm' => true, |
| 212 |
'input' => |
| 213 |
'\\AA\\Coppa\\coppa\\Digamma\\euro\\geneuro\\geneuronarrow' . |
| 214 |
'\\geneurowide\\Koppa\\koppa\\officialeuro\\Sampi\\sampi' . |
| 215 |
'\\Stigma\\stigma\\textvisiblespace\\varstigma', |
| 216 |
'output' => |
| 217 |
'\\mathrm {\\AA} \\mathrm {\\Coppa} \\mathrm {\\coppa} ' . |
| 218 |
'\\mathrm {\\Digamma} \\mathrm {\\euro} \\mathrm {\\geneuro} ' . |
| 219 |
'\\mathrm {\\geneuronarrow} \\mathrm {\\geneurowide} ' . |
| 220 |
'\\mathrm {\\Koppa} \\mathrm {\\koppa} \\mathrm {\\officialeuro} ' . |
| 221 |
'\\mathrm {\\Sampi} \\mathrm {\\sampi} \\mathrm {\\Stigma} ' . |
| 222 |
'\\mathrm {\\stigma} \\mathrm {\\textvisiblespace} ' . |
| 223 |
'\\mathrm {\\varstigma} ' |
| 224 |
] |
| 225 |
], |
| 226 |
'Literals (2\') MJ' => [ |
| 227 |
[ |
| 228 |
'usemathrm' => true, |
| 229 |
|
| 230 |
'input' => |
| 231 |
'\\mathrm {\\AA} \\mathrm {\\Coppa} \\mathrm {\\coppa} ' . |
| 232 |
'\\mathrm {\\Digamma} \\mathrm {\\euro} \\mathrm {\\geneuro} ' . |
| 233 |
'\\mathrm {\\geneuronarrow} \\mathrm {\\geneurowide} ' . |
| 234 |
'\\mathrm {\\Koppa} \\mathrm {\\koppa} \\mathrm {\\officialeuro} ' . |
| 235 |
'\\mathrm {\\Sampi} \\mathrm {\\sampi} \\mathrm {\\Stigma} ' . |
| 236 |
'\\mathrm {\\stigma} \\mathrm {\\textvisiblespace} ' . |
| 237 |
'\\mathrm {\\varstigma} ', |
| 238 |
'skipOcaml' => true |
| 239 |
] |
| 240 |
], |
| 241 |
'Literals (3)' => [ |
| 242 |
[ |
| 243 |
'oldtexvc' => true, |
| 244 |
'input' => |
| 245 |
'\\C\\H\\N\\Q\\R\\Z\\alef\\alefsym\\Alpha\\and\\ang\\Beta' . |
| 246 |
'\\bull\\Chi\\clubs\\cnums\\Complex\\Dagger\\diamonds\\Doteq' . |
| 247 |
'\\doublecap\\doublecup\\empty\\Epsilon\\Eta\\exist\\ge' . |
| 248 |
'\\gggtr\\hArr\\harr\\Harr\\hearts\\image\\infin\\Iota\\isin' . |
| 249 |
'\\Kappa\\larr\\Larr\\lArr\\le\\lrarr\\Lrarr\\lrArr\\Mu' . |
| 250 |
'\\natnums\\ne\\Nu\\O\\omicron\\Omicron\\or\\part\\plusmn' . |
| 251 |
'\\rarr\\Rarr\\rArr\\real\\reals\\Reals\\restriction\\Rho' . |
| 252 |
'\\sdot\\sect\\spades\\sub\\sube\\supe\\Tau\\thetasym' . |
| 253 |
'\\varcoppa\\weierp\\Zeta', |
| 254 |
'output' => |
| 255 |
'\\mathbb {C} \\mathbb {H} \\mathbb {N} \\mathbb {Q} ' . |
| 256 |
'\\mathbb {R} \\mathbb {Z} \\aleph \\aleph \\mathrm {A} ' . |
| 257 |
'\\land \\angle \\mathrm {B} \\bullet \\mathrm {X} ' . |
| 258 |
'\\clubsuit \\mathbb {C} \\mathbb {C} \\ddagger ' . |
| 259 |
'\\diamondsuit \\doteqdot \\Cap \\Cup \\emptyset ' . |
| 260 |
'\\mathrm {E} \\mathrm {H} \\exists \\geq \\ggg ' . |
| 261 |
'\\Leftrightarrow \\leftrightarrow \\Leftrightarrow ' . |
| 262 |
'\\heartsuit \\Im \\infty \\mathrm {I} \\in \\mathrm {K} ' . |
| 263 |
'\\leftarrow \\Leftarrow \\Leftarrow \\leq ' . |
| 264 |
'\\leftrightarrow \\Leftrightarrow \\Leftrightarrow ' . |
| 265 |
'\\mathrm {M} \\mathbb {N} \\neq \\mathrm {N} \\emptyset ' . |
| 266 |
'oO\\lor \\partial \\pm ' . |
| 267 |
'\\rightarrow \\Rightarrow \\Rightarrow \\Re \\mathbb {R} ' . |
| 268 |
'\\mathbb {R} \\upharpoonright \\mathrm {P} \\cdot ' . |
| 269 |
'\\S \\spadesuit \\subset \\subseteq \\supseteq ' . |
| 270 |
'\\mathrm {T} \\vartheta \\mbox{\\coppa} \\wp \\mathrm {Z} ' |
| 271 |
] |
| 272 |
], |
| 273 |
'Big' => [ |
| 274 |
self::bigs( $DELIMITERS1, $DELIMITERS2 ), |
| 275 |
], |
| 276 |
'Delimiters (1)' => [ |
| 277 |
[ |
| 278 |
'input' => implode( '', $DELIMITERS1 ) . implode( ' ', $DELIMITERS2 ) . ' ' |
| 279 |
], |
| 280 |
], |
| 281 |
'Delimiters (2)' => [ |
| 282 |
[ |
| 283 |
'input' => |
| 284 |
'\\darr\\dArr\\Darr\\lang\\rang\\uarr\\uArr\\Uarr', |
| 285 |
'output' => |
| 286 |
'\\downarrow \\Downarrow \\Downarrow \\langle \\rangle ' . |
| 287 |
'\\uparrow \\Uparrow \\Uparrow ' |
| 288 |
] |
| 289 |
], |
| 290 |
'Delimiters (3)' => [ |
| 291 |
[ |
| 292 |
'input' => |
| 293 |
'\\left' . implode( '\\left', $DELIMITERS1 ) . |
| 294 |
'\\right' . implode( '\\right', array_reverse( $DELIMITERS1 ) ) |
| 295 |
] |
| 296 |
], |
| 297 |
'Delimiters (4)' => [ |
| 298 |
[ |
| 299 |
'input' => |
| 300 |
'\\left' . implode( ' \\left', $DELIMITERS2 ) . |
| 301 |
' \\right' . implode( ' \\right', array_reverse( $DELIMITERS2 ) ) . ' ' |
| 302 |
] |
| 303 |
], |
| 304 |
'Delimiters (5)' => [ |
| 305 |
[ |
| 306 |
'input' => |
| 307 |
'\\left\\darr \\left\\dArr \\left\\Darr \\left\\lang ' . |
| 308 |
'\\right\\rang \\right\\uarr \\right\\uArr \\right\\Uarr ', |
| 309 |
'output' => |
| 310 |
'\\left\\downarrow \\left\\Downarrow \\left\\Downarrow ' . |
| 311 |
'\\left\\langle \\right\\rangle ' . |
| 312 |
'\\right\\uparrow \\right\\Uparrow \\right\\Uparrow ' |
| 313 |
] |
| 314 |
], |
| 315 |
'FUN_AR1' => [ |
| 316 |
[ |
| 317 |
'input' => |
| 318 |
'\\acute{A}\\bar{A}\\bcancel{A}\\bmod{A}\\boldsymbol{A}' . |
| 319 |
'\\breve{A}\\cancel{A}\\check{A}\\ddot{A}\\dot{A}\\emph{A}' . |
| 320 |
'\\grave{A}\\hat{A}\\hphantom{A}\\mathbb{A}\\mathbf{A}' . |
| 321 |
'\\mathcal{A}\\mathclose{A}\\mathfrak{A}\\mathit{A}' . |
| 322 |
'\\mathop{A}\\mathopen{A}\\mathord{A}\\mathpunct{A}' . |
| 323 |
'\\mathrm{A}\\mathsf{A}\\mathtt{A}' . |
| 324 |
'\\operatorname{A}\\overleftarrow{A}\\overleftrightarrow{A}' . |
| 325 |
'\\overline{A}\\overrightarrow{A}\\phantom{A}\\pmod{A}\\sqrt{A}' . |
| 326 |
'\\textbf{A}\\textit{A}\\textrm{A}\\textsf{A}\\texttt{A}' . |
| 327 |
'\\tilde{A}\\underline{A}\\vec{A}\\vphantom{A}\\widehat{A}' . |
| 328 |
'\\widetilde{A}\\xcancel{A}', |
| 329 |
'output' => |
| 330 |
'{\\acute {A}}{\\bar {A}}{\\bcancel {A}}{\\bmod {A}}' . |
| 331 |
'{\\boldsymbol {A}}{\\breve {A}}{\\cancel {A}}{\\check {A}}' . |
| 332 |
'{\\ddot {A}}{\\dot {A}}{\\emph {A}}{\\grave {A}}{\\hat {A}}' . |
| 333 |
'{\\hphantom {A}}\\mathbb {A} \\mathbf {A} {\\mathcal {A}}' . |
| 334 |
'{\\mathclose {A}}{\\mathfrak {A}}{\\mathit {A}}' . |
| 335 |
'\\mathop {A} {\\mathopen {A}}{\\mathord {A}}' . |
| 336 |
'{\\mathpunct {A}}\\mathrm {A} {\\mathsf {A}}' . |
| 337 |
'{\\mathtt {A}}\\operatorname {A} {\\overleftarrow {A}}' . |
| 338 |
'{\\overleftrightarrow {A}}{\\overline {A}}' . |
| 339 |
'{\\overrightarrow {A}}{\\phantom {A}}{\\pmod {A}}{\\sqrt {A}}' . |
| 340 |
'{\\textbf {A}}{\\textit {A}}{\\textrm {A}}{\\textsf {A}}' . |
| 341 |
'{\\texttt {A}}{\\tilde {A}}{\\underline {A}}{\\vec {A}}' . |
| 342 |
'{\\vphantom {A}}{\\widehat {A}}{\\widetilde {A}}{\\xcancel {A}}', |
| 343 |
'skipOcaml' => 'double spacing and extra braces', |
| 344 |
] |
| 345 |
], |
| 346 |
'FUN_AR1NB (1)' => [ |
| 347 |
[ |
| 348 |
'input' => '\\operatorname {sin} ', |
| 349 |
'skipOcaml' => 'missing space' |
| 350 |
] |
| 351 |
], |
| 352 |
'FUN_AR1NB (2)' => [ |
| 353 |
[ |
| 354 |
'input' => '\\mathbb {A} \\mathbf {B} \\mathrm {C} ', |
| 355 |
'skipOcaml' => 'extra braces' |
| 356 |
] |
| 357 |
], |
| 358 |
'FUN_AR1NB (3)' => [ |
| 359 |
[ |
| 360 |
'input' => '\\overbrace {A} _{b}^{c}\\underbrace {C} _{d}^{e}', |
| 361 |
'skipOcaml' => 'ocaml bug' |
| 362 |
] |
| 363 |
], |
| 364 |
'FUN_AR1NB (4)' => [ |
| 365 |
[ |
| 366 |
'input' => '\\xleftarrow{A}\\xrightarrow{A}', |
| 367 |
'output' => '\\xleftarrow {A} \\xrightarrow {A} ' |
| 368 |
] |
| 369 |
], |
| 370 |
'FUN_AR1NB (5)' => [ |
| 371 |
[ |
| 372 |
'input' => '\\mathrel{A}\\mathbin{A}', |
| 373 |
'output' => '\\mathrel {A} \\mathbin {A} ' |
| 374 |
] |
| 375 |
], |
| 376 |
'FUN_AR1OPT' => [ |
| 377 |
[ |
| 378 |
'input' => |
| 379 |
'\\sqrt{2}\\sqrt[3]{2}' . |
| 380 |
'\\xleftarrow{above}\\xleftarrow[below]{above}' . |
| 381 |
'\\xrightarrow{above}\\xrightarrow[below]{above}', |
| 382 |
'output' => |
| 383 |
'{\\sqrt {2}}{\\sqrt[{3}]{2}}' . |
| 384 |
'\\xleftarrow {above} {\\xleftarrow[{below}]{above}}' . |
| 385 |
'\\xrightarrow {above} {\\xrightarrow[{below}]{above}}', |
| 386 |
'skipOcaml' => 'spacing' |
| 387 |
] |
| 388 |
], |
| 389 |
'FUN_AR2' => [ |
| 390 |
[ |
| 391 |
'input' => |
| 392 |
'\\binom{A}{B}\\cancelto{A}{B}\\cfrac{A}{B}\\dbinom{A}{B}' . |
| 393 |
'\\dfrac{A}{B}\\frac{A}{B}\\overset{A}{B}\\stackrel{A}{B}' . |
| 394 |
'\\tbinom{A}{B}\\tfrac{A}{B}\\underset{A}{B}', |
| 395 |
'output' => |
| 396 |
'{\\binom {A}{B}}{\\cancelto {A}{B}}{\\cfrac {A}{B}}' . |
| 397 |
'{\\dbinom {A}{B}}{\\dfrac {A}{B}}{\\frac {A}{B}}' . |
| 398 |
'{\\overset {A}{B}}{\\stackrel {A}{B}}{\\tbinom {A}{B}}' . |
| 399 |
'{\\tfrac {A}{B}}{\\underset {A}{B}}', |
| 400 |
'skipOcaml' => 'double spacing' |
| 401 |
] |
| 402 |
], |
| 403 |
'FUN_AR2nb' => [ |
| 404 |
[ |
| 405 |
'input' => '\\sideset{_\\dagger^*}{_\\dagger^*}\\prod', |
| 406 |
'output' => '\\sideset {_{\\dagger }^{*}}{_{\\dagger }^{*}}\\prod ' |
| 407 |
] |
| 408 |
], |
| 409 |
'FUN_INFIX (1)' => [ |
| 410 |
[ |
| 411 |
'input' => '\\left({a\\atop 1}{b\\atop m}{c\\atop n}\\right)', |
| 412 |
'output' => '\\left({a \\atop 1}{b \\atop m}{c \\atop n}\\right)' |
| 413 |
] |
| 414 |
], |
| 415 |
'FUN_INFIX (2)' => [ |
| 416 |
[ |
| 417 |
'input' => '{1\\,0\\choose0\\,1}', |
| 418 |
'output' => '{1\\,0 \\choose 0\\,1}' |
| 419 |
] |
| 420 |
], |
| 421 |
'FUN_INFIX (3)' => [ |
| 422 |
[ |
| 423 |
'input' => '{a\\over b}', |
| 424 |
'output' => '{a \\over b}' |
| 425 |
] |
| 426 |
], |
| 427 |
'FUN_INFIX (4)' => [ |
| 428 |
[ |
| 429 |
'input' => 'a\\over b', |
| 430 |
'output' => '{a \\over b}' |
| 431 |
] |
| 432 |
], |
| 433 |
'DECLh' => [ [ |
| 434 |
'input' => '{abc \\rm def \\it ghi \\cal jkl \\bf mno}', |
| 435 |
'output' => '{abc{\\rm {def{\\it {ghi{\\cal {jkl{\\bf {mno}}}}}}}}}' |
| 436 |
] |
| 437 |
], |
| 438 |
'litsq_zq' => [ [ |
| 439 |
'input' => ']^2', |
| 440 |
'output' => ']^{2}' |
| 441 |
] |
| 442 |
], |
| 443 |
'Matrices' => [ |
| 444 |
self::matrices(), |
| 445 |
], |
| 446 |
'Matrices (2)' => [ |
| 447 |
[ |
| 448 |
'input' => '{\\begin{array}{|c|}\\hline {\\!n\\!}\\\\\\hline \\end{array}}' |
| 449 |
] |
| 450 |
], |
| 451 |
'Matrices (3)' => [ |
| 452 |
[ |
| 453 |
'input' => '\\begin{alignedat} { 3 } a & b & c \\end{alignedat}', |
| 454 |
'output' => '{\\begin{alignedat}{3}a&b&c\\end{alignedat}}' |
| 455 |
] |
| 456 |
], |
| 457 |
'Color (1)' => [ |
| 458 |
[ |
| 459 |
'input' => '\\definecolor {mycolor}{rgb}{0.1,.2,0.}\\color {mycolor}' |
| 460 |
] |
| 461 |
], |
| 462 |
'Color (2)' => [ |
| 463 |
[ |
| 464 |
'input' => |
| 465 |
'\\color {blue}\\color [named]{blue}\\color [gray]{0.5}' . |
| 466 |
'\\color [rgb]{0,1,0}\\color [cmyk]{1,0,0,0}' |
| 467 |
] |
| 468 |
], |
| 469 |
'Color (3)' => [ |
| 470 |
[ |
| 471 |
'input' => |
| 472 |
'\\pagecolor {blue}\\pagecolor [named]{blue}' . |
| 473 |
'\\pagecolor [gray]{0.5}\\pagecolor [rgb]{0,1,0}' . |
| 474 |
'\\pagecolor [cmyk]{1,0,0,0}' |
| 475 |
] |
| 476 |
], |
| 477 |
'Color (4)' => [ |
| 478 |
[ |
| 479 |
'input' => |
| 480 |
'\\definecolor{mycolor}{rgb}{0.1,.2,0.}\\color[CMYK]{0,1,0,1}', |
| 481 |
'output' => |
| 482 |
'\\definecolor {mycolor}{rgb}{0.1,.2,0.}\\color [cmyk]{0,1,0,1}' |
| 483 |
] |
| 484 |
], |
| 485 |
'Color (5)' => [ |
| 486 |
[ |
| 487 |
'input' => |
| 488 |
'\\definecolor{mycolor}{RGB}{255,102,51}' . |
| 489 |
'\\pagecolor [RGB]{51,102,255}', |
| 490 |
'output' => |
| 491 |
'\\definecolor {mycolor}{rgb}{1,0.4,0.2}' . |
| 492 |
'\\pagecolor [rgb]{0.2,0.4,1}' |
| 493 |
] |
| 494 |
] |
| 495 |
]; |
| 496 |
} |
| 497 |
|
| 498 |
private static function bigs( $DELIMITERS1, $DELIMITERS2 ) { |
| 499 |
$bigs = explode( '\\', '\\big\\Big\\bigg\\Bigg\\biggl\\Biggl\\biggr\\Biggr' . |
| 500 |
'\\bigl\\Bigl\\bigr\\Bigr' ); |
| 501 |
array_shift( $bigs ); |
| 502 |
$BIGS = $bigs; |
| 503 |
|
| 504 |
$DELIMITERS = array_merge( $DELIMITERS1, $DELIMITERS2, [ '\\darr', '\\uarr' ] ); |
| 505 |
|
| 506 |
$input = implode( '', array_map( static function ( $b ) use ( $DELIMITERS ) { |
| 507 |
return implode( '', array_map( static function ( $d ) use ( $DELIMITERS, $b ) { |
| 508 |
return '\\' . $b . $d; |
| 509 |
}, $DELIMITERS ) ); |
| 510 |
}, $BIGS ) ); |
| 511 |
$output = implode( '', array_map( static function ( $b ) use ( $DELIMITERS ) { |
| 512 |
return implode( '', array_map( static function ( $d ) use ( $DELIMITERS, $b ) { |
| 513 |
if ( $d === '\\darr' ) { |
| 514 |
$d = '\\downarrow'; |
| 515 |
} |
| 516 |
if ( $d === '\\uarr' ) { |
| 517 |
$d = '\\uparrow'; |
| 518 |
} |
| 519 |
if ( substr( $d, 0, 1 ) === '\\' && strlen( $d ) > 2 ) { |
| 520 |
$d = $d . ' '; |
| 521 |
} |
| 522 |
return '{\\' . $b . ' ' . $d . '}'; |
| 523 |
}, $DELIMITERS ) ); |
| 524 |
}, $BIGS ) ); |
| 525 |
|
| 526 |
return [ 'input' => $input, 'output' => $output ]; |
| 527 |
} |
| 528 |
|
| 529 |
private static function argi( $env ) { |
| 530 |
switch ( $env ) { |
| 531 |
case 'array': |
| 532 |
return '{|c||c|}'; |
| 533 |
case 'alignedat': |
| 534 |
case 'alignat': |
| 535 |
return '{3}'; |
| 536 |
default: |
| 537 |
return ''; |
| 538 |
} |
| 539 |
} |
| 540 |
|
| 541 |
private static function matrices() { |
| 542 |
$ENV = [ 'matrix', 'pmatrix', 'bmatrix', 'Bmatrix', 'vmatrix', 'Vmatrix', |
| 543 |
'array', 'align', 'alignat', 'smallmatrix', 'cases' ]; |
| 544 |
|
| 545 |
$input = implode( '', array_map( static function ( $env ) { |
| 546 |
return '\\begin{' . $env . '}' . AllTest::argi( $env ) . ' a & b \\\\\\hline c & d \\end{' . $env . '}'; |
| 547 |
}, $ENV ) ); |
| 548 |
$output = implode( '', array_map( static function ( $env ) { |
| 549 |
if ( $env === 'align' ) { |
| 550 |
$env = 'aligned'; |
| 551 |
} |
| 552 |
if ( $env === 'alignat' ) { |
| 553 |
$env = 'alignedat'; |
| 554 |
} |
| 555 |
return '{\\begin{' . $env . '}' . AllTest::argi( $env ) . 'a&b\\\\\\hline c&d\\end{' . $env . '}}'; |
| 556 |
}, $ENV ) ); |
| 557 |
|
| 558 |
return [ 'input' => $input, 'output' => $output ]; |
| 559 |
} |
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
public function testRunCases( $tc ) { |
| 565 |
$tc['output'] = $tc['output'] ?? $tc['input']; |
| 566 |
if ( !array_key_exists( 'skipJs', $tc ) || !$tc['skipJs'] ) { |
| 567 |
$message = 'output should be correct'; |
| 568 |
$result = $this->texVC->check( $tc['input'], [ |
| 569 |
'debug' => true, |
| 570 |
'usemathrm' => $tc['usemathrm'] ?? false, |
| 571 |
'oldtexvc' => $tc['oldtexvc'] ?? false |
| 572 |
] ); |
| 573 |
$this->assertEquals( '+', $result['status'], $message ); |
| 574 |
$this->assertEquals( $tc['output'], $result['output'], $message ); |
| 575 |
} |
| 576 |
if ( !array_key_exists( 'skipReparse', $tc ) || !$tc['skipReparse'] ) { |
| 577 |
|
| 578 |
|
| 579 |
$message = 'should parse its own output'; |
| 580 |
$result1 = $this->texVC->check( $tc['output'], [ 'debug' => true ] ); |
| 581 |
$result2 = $this->texVC->check( $result1['output'], [ 'debug' => true ] ); |
| 582 |
$this->assertEquals( '+', $result2['status'], $message ); |
| 583 |
$this->assertEquals( $result2['output'], $result1['output'], $message ); |
| 584 |
} |
| 585 |
} |
| 586 |
} |