Parser tests for recent change in <ref> behavior, plus fix for failure of that behavior when the first ref is set to exactly "0"

This commit is contained in:
Brion Vibber 2006-11-03 15:34:46 +00:00
parent 658fe31872
commit ff99847497
2 changed files with 49 additions and 1 deletions

View file

@ -291,7 +291,7 @@ function wfCite() {
);
} else {
// We've been here before
if ( empty($this->mRefs[$key]['text']) and !empty($str)) {
if ( $this->mRefs[$key]['text'] === null && $str !== '' ) {
// If no text found before, use this text
$this->mRefs[$key]['text'] = $str;
};

View file

@ -136,3 +136,51 @@ Templating<ref>Text<!--comment--></ref>
<p>1337
</p>
!! end
!! test
Blank ref followed by ref with content
!! input
<ref name="blank"/>
<ref name="blank">content</ref>
<references/>
!! result
<p><sup id="_ref-blank_0" class="reference"><a href="#_note-blank" title="">[1]</a></sup>
</p><p><sup id="_ref-blank_1" class="reference"><a href="#_note-blank" title="">[1]</a></sup>
</p>
<ol class="references"><li id="_note-blank">↑ <a href="#_ref-blank_0" title=""><sup>1.0</sup></a> <a href="#_ref-blank_1" title=""><sup>1.1</sup></a> content</li></ol>
!! end
!! test
Regression: non-blank ref "0" followed by ref with content
!! input
<ref name="blank">0</ref>
<ref name="blank">content</ref>
<references/>
!! result
<p><sup id="_ref-blank_0" class="reference"><a href="#_note-blank" title="">[1]</a></sup>
</p><p><sup id="_ref-blank_1" class="reference"><a href="#_note-blank" title="">[1]</a></sup>
</p>
<ol class="references"><li id="_note-blank">↑ <a href="#_ref-blank_0" title=""><sup>1.0</sup></a> <a href="#_ref-blank_1" title=""><sup>1.1</sup></a> 0</li></ol>
!! end
!! test
Regression sanity check: non-blank ref "1" followed by ref with content
!! input
<ref name="blank">1</ref>
<ref name="blank">content</ref>
<references/>
!! result
<p><sup id="_ref-blank_0" class="reference"><a href="#_note-blank" title="">[1]</a></sup>
</p><p><sup id="_ref-blank_1" class="reference"><a href="#_note-blank" title="">[1]</a></sup>
</p>
<ol class="references"><li id="_note-blank">↑ <a href="#_ref-blank_0" title=""><sup>1.0</sup></a> <a href="#_ref-blank_1" title=""><sup>1.1</sup></a> 1</li></ol>
!! end