34 if ( !isset(
$conf[
'parsers'] ) ) {
35 throw new MWException( __METHOD__ .
': no parsers specified' );
41 if ( !is_null( $this->parsers ) ) {
45 if ( isset( $this->conf[
'shortOutput'] ) ) {
46 $this->shortOutput = $this->conf[
'shortOutput'];
49 foreach ( $this->conf[
'parsers']
as $i => $parserConf ) {
50 if ( !is_array( $parserConf ) ) {
52 $parserConf = [
'class' => $parserConf ];
54 $class = $parserConf[
'class'];
56 $this->parsers[$i] =
new $class( $parserConf );
66 foreach ( $this->parsers
as $i =>
$parser ) {
67 $currentResult = call_user_func_array( [ &$this->parsers[$i],
$name ],
$args );
71 if ( is_object( $lastResult ) ) {
72 if ( $lastResult != $currentResult ) {
76 if ( $lastResult !== $currentResult ) {
81 $results[$i] = $currentResult;
82 $lastResult = $currentResult;
85 if (
count( $results ) == 2 ) {
87 foreach ( $this->parsers
as $i =>
$parser ) {
88 $resultsList[] = var_export( $results[$i],
true );
90 $diff =
wfDiff( $resultsList[0], $resultsList[1] );
92 $diff =
'[too many parsers]';
94 $msg =
"ParserDiffTest: results mismatch on call to $name\n";
95 if ( !$this->shortOutput ) {
98 $msg .=
'Results: ' . $this->
formatArray( $results ) .
"\n" .
106 if ( $this->shortOutput ) {
107 foreach ( $array
as $key =>
$value ) {
109 $array[$key] =
"ParserOutput: {$value->getText()}";
113 return var_export( $array,
true );