瀏覽代碼

Tokenizer tests for headings. Also, add an integration test.

tags/v0.2
Ben Kurtovic 11 年之前
父節點
當前提交
6070eff657
共有 2 個檔案被更改,包括 116 行新增0 行删除
  1. +109
    -0
      tests/tokenizer/headings.mwtest
  2. +7
    -0
      tests/tokenizer/integration.mwtest

+ 109
- 0
tests/tokenizer/headings.mwtest 查看文件

@@ -0,0 +1,109 @@
name: level_1
label: a basic level-1 heading
input: "= Heading ="
output: [HeadingStart(level=1), Text(text=" Heading "), HeadingEnd()]

---

name: level_2
label: a basic level-2 heading
input: "== Heading =="
output: [HeadingStart(level=2), Text(text=" Heading "), HeadingEnd()]

---

name: level_3
label: a basic level-3 heading
input: "=== Heading ==="
output: [HeadingStart(level=3), Text(text=" Heading "), HeadingEnd()]

---

name: level_4
label: a basic level-4 heading
input: "==== Heading ===="
output: [HeadingStart(level=4), Text(text=" Heading "), HeadingEnd()]

---

name: level_5
label: a basic level-5 heading
input: "===== Heading ====="
output: [HeadingStart(level=5), Text(text=" Heading "), HeadingEnd()]

---

name: level_6
label: a basic level-6 heading
input: "====== Heading ======"
output: [HeadingStart(level=6), Text(text=" Heading "), HeadingEnd()]

---

name: level_7
label: a level-6 heading that pretends to be a level-7 heading
input: "======= Heading ======="
output: [HeadingStart(level=6), Text(text="= Heading ="), HeadingEnd()]

---

name: level_3_2
label: a level-2 heading that pretends to be a level-3 heading
input: "=== Heading =="
output: [HeadingStart(level=2), Text(text="= Heading "), HeadingEnd()]

---

name: level_4_6
label: a level-4 heading that pretends to be a level-6 heading
input: "==== Heading ======"
output: [HeadingStart(level=4), Text(text=" Heading =="), HeadingEnd()]

---

name: newline_before
label: a heading that starts after a newline
input: "This is some text.\n== Foobar ==\nbaz"
output: [Text(text="This is some text.\n"), HeadingStart(level=2), Text(text=" Foobar "), HeadingEnd(), Text(text="\nbaz")]

---

name: text_after
label: text on the same line after
input: "This is some text.\n== Foobar == baz"
output: [Text(text="This is some text.\n"), HeadingStart(level=2), Text(text=" Foobar "), HeadingEnd(), Text(text=" baz")]

---

name: invalid_text_before
label: invalid headings: text on the same line before
input: "This is some text. == Foobar ==\nbaz"
output: [Text(text="This is some text. == Foobar ==\nbaz")]

---

name: invalid_newline_middle
label: invalid headings: newline in the middle
input: "This is some text.\n== Foo\nbar =="
output: [Text(text="This is some text.\n== Foo\nbar ==")]

---

name: invalid_newline_end
label: invalid headings: newline in the middle
input: "This is some text.\n=== Foo\n==="
output: [Text(text="This is some text.\n=== Foo\n===")]

---

name: invalid_nesting
label: invalid headings: attempts at nesting
input: "== Foo === Bar === Baz =="
output: [HeadingStart(level=2), Text(text=" Foo === Bar === Baz "), HeadingEnd()]

---

name: incomplete
label: a heading that starts but doesn't finish
input: "Foobar. \n== Heading "
output: [Text(text="Foobar. \n== Heading ")]

+ 7
- 0
tests/tokenizer/integration.mwtest 查看文件

@@ -2,3 +2,10 @@ name: empty
label: sanity check that parsing an empty string yields nothing
input: ""
output: []

---

name: rich_heading
label: a heading with templates/wikilinks in it
input: "== Head{{ing}} [[with]] {{{funky|{{stuf}}}}} =="
output: [HeadingStart(level=2), Text(text=" Head"), TemplateOpen(), Text(text="ing"), TemplateClose(), Text(text=" "), WikilinkOpen(), Text(text="with"), WikilinkClose(), Text(text=" "), ArgumentOpen(), Text(text="funky"), ArgumentSeparator(), TemplateOpen(), Text(text="stuf"), TemplateClose(), ArgumentClose(), Text(text=" "), HeadingEnd()]

Loading…
取消
儲存