skipped ?? false ) { MMLTestUtilHTML::generateHTMLtableRow( self::$GENERATEDHTMLFILE, [ $tc->ctr, $tc->input, "skipped", "skipped" ], false, self::$GENERATEHTML ); $this->assertTrue( true ); return; } # Fetch result from WikiTexVC(PHP) $resultT = $texVC->check( $tc->input, [ 'debug' => false, 'usemathrm' => $tc->usemathrm ?? false, 'oldtexvc' => $tc->oldtexvc ?? false ] ); $mathMLtexVC = MMLTestUtil::getMMLwrapped( $resultT["input"] ); if ( self::$SELECTEDFILE == 0 ) { // File 0 has no refs, is just for checking basics. MMLTestUtilHTML::generateHTMLtableRow( self::$GENERATEDHTMLFILE, [ $tc->ctr, $tc->input,$tc->mmlLaTeXML ?? "tbd" ,"tbd", $mathMLtexVC, -0.0 ], false, self::$GENERATEHTML ); $this->assertTrue( true ); return; } $mmlComparator = new MMLComparator(); $compRes = $mmlComparator->compareMathML( $tc->mmlMathoid, $mathMLtexVC ); MMLTestUtilHTML::generateHTMLtableRow( self::$GENERATEDHTMLFILE, [ $tc->ctr, $tc->input,$tc->mmlLaTeXML ?? "tbd" ,$tc->mmlMathoid ?? "tbd", $mathMLtexVC, $compRes['similarityF'] ], false, self::$GENERATEHTML ); if ( !self::$SKIPXMLVALIDATION ) { if ( !$tc->mmlMathoid ) { $this->fail( "No Mathoid reference found for: " . $tc->input ); } if ( $compRes['similarityF'] >= self::$SIMILARITYTRESH ) { $this->assertTrue( true ); } else { $this->assertXmlStringEqualsXmlString( $tc->mmlMathoid, $mathMLtexVC ); } } else { $this->assertTrue( true ); } } public static function provideTestCases() { switch ( self::$SELECTEDFILE ) { case 0: return self::provideTestCases1(); case 1: return self::provideTestCases2(); default: self::throwException( new InvalidArgumentException( "No correct file specified" ) ); return []; } } /** * Provide testcases and filter and format them for * the first testfile 'tex-2-mml.json'. * @return array */ public static function provideTestCases1() { $res = MMLTestUtil::getJSON( self::$FILENAME1 ); $f = $res->{self::$SELECTEDCATEGORY1}; // Adding running indices for location of tests. $indexCtr = 0; foreach ( $f as $tc ) { $tc[1]->ctr = $indexCtr; $indexCtr += 1; } // Filtering results by index if necessary if ( self::$APPLYFILTER ) { $f = array_slice( $f, self::$FILTERSTART, self::$FILTERLENGTH ); } return $f; } /** * Provide testcases and filter and format them for * the second testfile 'ParserTest.json'. * @return array */ public static function provideTestCases2() { $res = MMLTestUtil::getJSON( self::$FILENAME2 ); $f = []; // Adding running indices for location of tests. $indexCtr = 0; foreach ( $res as $tc ) { $tc->ctr = $indexCtr; $tc->input = $tc->tex; // Just to have uniform access here $indexCtr += 1; array_push( $f, [ "title N/A", $tc ] ); } // Filtering results by index if necessary if ( self::$APPLYFILTER ) { $f = array_slice( $f, self::$FILTERSTART, self::$FILTERLENGTH ); } return $f; } }