33 if ( !isset(
$conf[
'parsers'] ) ) {
34 throw new MWException( __METHOD__ .
': no parsers specified' );
40 if ( !is_null( $this->parsers ) ) {
44 if ( isset( $this->conf[
'shortOutput'] ) ) {
45 $this->shortOutput = $this->conf[
'shortOutput'];
48 foreach ( $this->conf[
'parsers']
as $i => $parserConf ) {
49 if ( !is_array( $parserConf ) ) {
51 $parserConf = [
'class' => $parserConf ];
53 $class = $parserConf[
'class'];
55 $this->parsers[$i] =
new $class( $parserConf );
65 foreach ( $this->parsers
as $i =>
$parser ) {
66 $currentResult = call_user_func_array( [ &$this->parsers[$i],
$name ],
$args );
70 if ( is_object( $lastResult ) ) {
71 if ( $lastResult != $currentResult ) {
75 if ( $lastResult !== $currentResult ) {
80 $results[$i] = $currentResult;
81 $lastResult = $currentResult;
84 if (
count( $results ) == 2 ) {
86 foreach ( $this->parsers
as $i =>
$parser ) {
87 $resultsList[] = var_export( $results[$i],
true );
89 $diff =
wfDiff( $resultsList[0], $resultsList[1] );
91 $diff =
'[too many parsers]';
93 $msg =
"ParserDiffTest: results mismatch on call to $name\n";
94 if ( !$this->shortOutput ) {
97 $msg .=
'Results: ' . $this->
formatArray( $results ) .
"\n" .
105 if ( $this->shortOutput ) {
106 foreach ( $array
as $key =>
$value ) {
108 $array[$key] =
"ParserOutput: {$value->getText()}";
112 return var_export( $array,
true );