Add more detailed testcases for Color, Pagecolor and Definecolor

* case 2: "colors"
* in MMLGenerationTexUtilTest.php
* Updated the keyfiles etc

Bug: T327391
Change-Id: Id3232f21dea9813ec5adcacca58e912cf116ab72
This commit is contained in:
Stegmujo 2023-02-27 17:21:59 +01:00
parent 64c3f6893a
commit 8f81eabc83
3 changed files with 31 additions and 21 deletions

View file

@ -15,13 +15,13 @@
"\\mbox{a}": "tex", "\\mbox{a}": "tex",
"\\text{a}": "tex", "\\text{a}": "tex",
"\\vbox{ab}": "tex", "\\vbox{ab}": "tex",
"\\color{red}{red}": "tex", "a {b \\color{red} c} d": "tex",
"\\pagecolor{red}{red}": "tex", "\\pagecolor{red} e^{i \\pi}": "tex",
"{\\bf a }": "tex", "{\\bf a }": "tex",
"{\\cal a }": "tex", "{\\cal a }": "tex",
"{\\it a }": "tex", "{\\it a }": "tex",
"{\\rm a }": "tex", "{\\rm a }": "tex",
"\\definecolor{ultramarine}{RGB}{0,32,96}": "tex", "\\definecolor{ultramarine}{RGB}{0,32,96} a {b \\color{ultramarine} c} d": "tex",
"\\acute{a}": "tex", "\\acute{a}": "tex",
"\\bar{a}": "tex", "\\bar{a}": "tex",
"\\bcancel{a}": "tex", "\\bcancel{a}": "tex",
@ -136,7 +136,7 @@
"\\ce{\\frac{a}{b}}": "chem", "\\ce{\\frac{a}{b}}": "chem",
"\\ce{\\overset{a}{b}}": "chem", "\\ce{\\overset{a}{b}}": "chem",
"\\ce{\\underset{a}{b}}": "chem", "\\ce{\\underset{a}{b}}": "chem",
"\\ce{\\color{red}{red}}": "chem", "\\ce{a {b \\color{red} c} d}": "chem",
"\\ce{\\underbrace{a}}": "chem", "\\ce{\\underbrace{a}}": "chem",
"\\ce{\\Alpha}": "chem", "\\ce{\\Alpha}": "chem",
"\\ce{\\Beta}": "chem", "\\ce{\\Beta}": "chem",

View file

@ -140,9 +140,6 @@ class MMLGenerationTexUtilTest extends MediaWikiUnitTestCase {
private const SAMPLE_ARGS_RIGHT = [ private const SAMPLE_ARGS_RIGHT = [
"big_literals" => '(', "big_literals" => '(',
"color_function" => '{red}{red}',
"mhchem_macro_2pc" => '{red}{red}',
"definecolor_function" => '{ultramarine}{RGB}{0,32,96}',
"fun_ar2nb" => '{_1^2}{_3^4}\\sum', "fun_ar2nb" => '{_1^2}{_3^4}\\sum',
"left_function" => '( \\right.', "left_function" => '( \\right.',
"mhchem_bond" => '{-}', "mhchem_bond" => '{-}',
@ -158,6 +155,10 @@ class MMLGenerationTexUtilTest extends MediaWikiUnitTestCase {
"\\atop" => "{ a \\atop b }", "\\atop" => "{ a \\atop b }",
"\\choose" => "{ a \\choose b }", "\\choose" => "{ a \\choose b }",
"\\over" => "{a \\over b }", "\\over" => "{a \\over b }",
"\\color" => "a {b \\color{red} c} d",
"\\ce{\\color}" => "\\ce{a {b \\color{red} c} d}",
"\\definecolor" => "\\definecolor{ultramarine}{RGB}{0,32,96} a {b \\color{ultramarine} c} d",
"\\pagecolor" => "\\pagecolor{red} e^{i \\pi}",
"\\hline" => "\n\\begin{array}{|c||c|} a & b \\\\\n\\hline\n1&2 \n\\end{array}\n", "\\hline" => "\n\\begin{array}{|c||c|} a & b \\\\\n\\hline\n1&2 \n\\end{array}\n",
"\\nolimits" => " \mathop{\\rm cos}\\nolimits^2", "\\nolimits" => " \mathop{\\rm cos}\\nolimits^2",
// "\\limits" =>" \mathop{\\rm cos}\\limits^2", // "\\limits" =>" \mathop{\\rm cos}\\limits^2",
@ -220,7 +221,12 @@ class MMLGenerationTexUtilTest extends MediaWikiUnitTestCase {
$indexCtr = 0; $indexCtr = 0;
foreach ( $group as $case ) { foreach ( $group as $case ) {
$title = "set#" . $overAllCtr . ": " . $category . $indexCtr; $title = "set#" . $overAllCtr . ": " . $category . $indexCtr;
$finalCase = $refAssociative[$case] ?? $case; if ( $refAssociative[$case] ) {
$finalCase = $refAssociative[$case];
} else {
$type = str_starts_with( $case, "ce" ) ? "chem" : "tex";
$finalCase = (object)[ "tex" => $case , "type" => $type, "ctr" => null ];
}
$finalCase->ctr = $overAllCtr; $finalCase->ctr = $overAllCtr;
$finalCases[$title] = [ $title, $finalCase ]; $finalCases[$title] = [ $title, $finalCase ];
@ -250,8 +256,12 @@ class MMLGenerationTexUtilTest extends MediaWikiUnitTestCase {
private static function addArgs( $set, $entry ) { private static function addArgs( $set, $entry ) {
if ( isset( self::ENTRY_ARGS[$entry] ) ) { if ( isset( self::ENTRY_ARGS[$entry] ) ) {
// Some entries have specific mappings for non-group related arguments // Some entries have specific mappings for non-group related arguments
if ( str_starts_with( $set, "mhchem" ) ) {
return '\\ce{' . self::ENTRY_ARGS[$entry] . '}';
} else {
return ( self::ENTRY_ARGS[$entry] ); return ( self::ENTRY_ARGS[$entry] );
} }
}
$count = !isset( self::ARG_CNTS[$set] ) ? 0 : self::ARG_CNTS[$set]; $count = !isset( self::ARG_CNTS[$set] ) ? 0 : self::ARG_CNTS[$set];
$argsR = ''; $argsR = '';
$argsL = ''; $argsL = '';

File diff suppressed because one or more lines are too long