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 );
66 if (
count( $results ) > 0 ) {
67 if ( is_object( $lastResult ) ) {
68 if ( $lastResult != $currentResult ) {
72 if ( $lastResult !== $currentResult ) {
77 $results[] = $currentResult;
78 $lastResult = $currentResult;
81 if (
count( $results ) == 2 ) {
83 foreach ( $this->parsers
as $i =>
$parser ) {
84 $resultsList[] = var_export( $results[$i],
true );
86 $diff =
wfDiff( $resultsList[0], $resultsList[1] );
88 $diff =
'[too many parsers]';
90 $msg =
"ParserDiffTest: results mismatch on call to $name\n";
91 if ( !$this->shortOutput ) {
94 $msg .=
'Results: ' . $this->
formatArray( $results ) .
"\n" .
102 if ( $this->shortOutput ) {
103 foreach ( $array
as $key =>
$value ) {
105 $array[$key] =
"ParserOutput: {$value->getText()}";
109 return var_export( $array,
true );
115 $parser->setFunctionHook( $id, $callback, $flags );