Sfoglia il codice sorgente

Make {{|=}} build correctly; add a test for this.

tags/v0.3
Ben Kurtovic 11 anni fa
parent
commit
6c2898d7bd
2 ha cambiato i file con 9 aggiunte e 1 eliminazioni
  1. +1
    -1
      mwparserfromhell/parser/builder.py
  2. +8
    -0
      tests/test_builder.py

+ 1
- 1
mwparserfromhell/parser/builder.py Vedi File

@@ -83,7 +83,7 @@ class Builder(object):
tokens.TemplateClose)):
self._tokens.append(token)
value = self._pop()
if not key:
if key is None:
key = self._wrap([Text(str(default))])
return Parameter(key, value, showkey)
else:


+ 8
- 0
tests/test_builder.py Vedi File

@@ -72,6 +72,14 @@ class TestBuilder(TreeEqualityTestCase):
wrap([Template(wraptext("foo"), params=[
Parameter(wraptext("bar"), wraptext("baz"))])])),

([tokens.TemplateOpen(), tokens.TemplateParamSeparator(),
tokens.TemplateParamSeparator(), tokens.TemplateParamEquals(),
tokens.TemplateParamSeparator(), tokens.TemplateClose()],
wrap([Template(wrap([]), params=[
Parameter(wraptext("1"), wrap([]), showkey=False),
Parameter(wrap([]), wrap([]), showkey=True),
Parameter(wraptext("2"), wrap([]), showkey=False)])])),

([tokens.TemplateOpen(), tokens.Text(text="foo"),
tokens.TemplateParamSeparator(), tokens.Text(text="bar"),
tokens.TemplateParamEquals(), tokens.Text(text="baz"),


Caricamento…
Annulla
Salva