$elem ) { $group[$key] = [ $elem , $references[ $key ] ]; if ( count( $group ) >= self::CHUNKSIZE ) { yield "Group $groupNo" => [ $group ]; $groupNo++; $group = []; } } if ( count( $group ) > 0 ) { yield "Group $groupNo" => [ $group ]; } } /** * @dataProvider provideTestCases */ public function testRunCases( $testcase ) { if ( !$this::ACTIVE ) { $this->markTestSkipped( "All MediaWiki formulae en test not active and skipped. This is expected." ); } $texVC = new TexVC(); foreach ( $testcase as $hash => [ $tex, $ref ] ) { try { $result = $texVC->check( $tex, [ "debug" => false, "usemathrm" => false, "oldtexvc" => false ] ); $this->assertEquals( '+', $result["status"], $hash . " failed. Input: " . $tex ); if ( preg_match( '/\\\\definecolor \{/m', $ref ) ) { // crop long numbers in color codes from 16 to 14 digits // while this heuristic might produce false positivies in general, it is sufficient // for this dataset $ref = preg_replace( '/(0.\d{14})\d{2}([,\}])/m', '$1$2', $ref ); } $this->assertEquals( $ref, $result["output"], $hash . " does not match reference." ); $r1 = $texVC->check( $result["output"] ); $this->assertEquals( "+", $r1["status"], "error rechecking output: " . $tex . " -> " . $result["output"] ); } catch ( PhpPegJs\SyntaxError $ex ) { $message = "Syntax error: " . $ex->getMessage() . ' at line ' . $ex->grammarLine . ' column ' . $ex->grammarColumn . ' offset ' . $ex->grammarOffset; $this->assertTrue( false, $message ); } } } }