test/test_plaintextbuilder.rb in review-3.1.0 vs test/test_plaintextbuilder.rb in review-3.2.0
- old
+ new
@@ -141,16 +141,38 @@
assert_equal 'test test2', actual
end
def test_inline_in_table
actual = compile_block("//table{\n★1☆\t▲2☆\n------------\n★3☆\t▲4☆<>&\n//}\n")
- assert_equal %Q(★1☆\t▲2☆\n★3☆\t▲4☆<>&\n\n), actual
+ expected = <<-EOS
+★1☆\t▲2☆
+★3☆\t▲4☆<>&
+
+EOS
+ assert_equal expected, actual
end
def test_dlist_beforeulol
actual = compile_block(" : foo\n foo.\n\npara\n\n : foo\n foo.\n\n 1. bar\n\n : foo\n foo.\n\n * bar\n")
- assert_equal %Q(foo\nfoo.\n\npara\n\nfoo\nfoo.\n\n1 bar\n\nfoo\nfoo.\n\nbar\n\n), actual
+ expected = <<-EOS
+foo
+foo.
+
+para
+
+foo
+foo.
+
+1 bar
+
+foo
+foo.
+
+bar
+
+EOS
+ assert_equal expected, actual
end
def test_paragraph
actual = compile_block("foo\nbar\n")
assert_equal %Q(foobar\n), actual
@@ -161,16 +183,25 @@
assert_equal %Q(\tfoobar\n), actual
end
def test_flushright
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
- assert_equal %Q(foobar\nbuz\n\n), actual
+ expected = <<-EOS
+foobar
+buz
+
+EOS
+ assert_equal expected, actual
end
def test_noindent
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
- assert_equal %Q(foobar\nfoo2bar2\n), actual
+ expected = <<-EOS
+foobar
+foo2bar2
+EOS
+ assert_equal expected, actual
end
def test_comment
actual = compile_block('//comment[コメント]')
assert_equal '', actual
@@ -185,24 +216,128 @@
def test_list
def @chapter.list(_id)
Book::ListIndex::Item.new('test', 1)
end
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
- assert_equal %Q(リスト1.1 this is test<&>_\n\nfoo\nbar\n\n), actual
+ expected = <<-EOS
+リスト1.1 this is test<&>_
+
+foo
+bar
+
+EOS
+ assert_equal expected, actual
end
def test_listnum
def @chapter.list(_id)
Book::ListIndex::Item.new('test', 1)
end
actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
- assert_equal %Q(リスト1.1 this is test<&>_\n\n 1: foo\n 2: bar\n\n), actual
+ expected = <<-EOS
+リスト1.1 this is test<&>_
+
+ 1: foo
+ 2: bar
+
+EOS
+ assert_equal expected, actual
end
+ def test_source
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
+ expected = <<-EOS
+foo/bar/test.rb
+foo
+bar
+
+buz
+
+EOS
+ assert_equal expected, actual
+ end
+
+ def test_source_empty_caption
+ actual = compile_block("//source[]{\nfoo\nbar\n\nbuz\n//}\n")
+ expected = <<-EOS
+foo
+bar
+
+buz
+
+EOS
+ assert_equal expected, actual
+ end
+
+ def test_box
+ actual = compile_block("//box{\nfoo\nbar\n//}\n")
+ expected = <<-EOS
+foo
+bar
+
+EOS
+ assert_equal expected, actual
+
+ actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
+ expected = <<-EOS
+FOO
+foo
+bar
+
+EOS
+ assert_equal expected, actual
+ end
+
+ def test_cmd
+ actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
+ expected = <<-EOS
+lineA
+lineB
+
+EOS
+ assert_equal expected, actual
+
+ actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
+ expected = <<-EOS
+cap1
+lineA
+lineB
+
+EOS
+ assert_equal expected, actual
+ end
+
+ def test_emlist
+ actual = compile_block("//emlist{\nlineA\nlineB\n//}\n")
+ expected = <<-EOS
+lineA
+lineB
+
+EOS
+ assert_equal expected, actual
+ end
+
+ def test_emlist_caption
+ actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
+ expected = <<-EOS
+cap1
+lineA
+lineB
+
+EOS
+ assert_equal expected, actual
+ end
+
def test_emlistnum
actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
- assert_equal %Q(this is test<&>_\n 1: foo\n 2: bar\n\n), actual
+ expected = <<-EOS
+this is test<&>_
+ 1: foo
+ 2: bar
+
+EOS
+ assert_equal expected, actual
end
def test_bib
def @chapter.bibpaper(_id)
Book::BibpaperIndex::Item.new('samplebib', 1, 'sample bib')
@@ -211,58 +346,145 @@
assert_equal '1 ', compile_inline('@<bib>{samplebib}')
end
def test_table
actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
- assert_equal %Q(aaa\tbbb\nccc\tddd<>&\n\n),
- actual
+ expected = <<-EOS
+aaa\tbbb
+ccc\tddd<>&
+
+EOS
+ assert_equal expected, actual
+
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
+ expected = <<-EOS
+表1.1 FOO
+
+aaa\tbbb
+ccc\tddd<>&
+
+EOS
+ assert_equal expected, actual
end
+ def test_empty_table
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n//}\n" }
+ assert_equal ':2: error: no rows in the table', e.message
+
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n------------\n//}\n" }
+ assert_equal ':3: error: no rows in the table', e.message
+ end
+
def test_inline_table
def @chapter.table(_id)
Book::TableIndex::Item.new('sampletable', 1)
end
actual = compile_block("@<table>{sampletest}\n")
assert_equal "表1.1\n", actual
end
def test_emtable
actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
- assert_equal %Q(foo\n\naaa\tbbb\nccc\tddd<>&\n\naaa\tbbb\nccc\tddd<>&\n\n),
- actual
+ expected = <<-EOS
+foo
+
+aaa\tbbb
+ccc\tddd<>&
+
+aaa\tbbb
+ccc\tddd<>&
+
+EOS
+ assert_equal expected, actual
end
def test_major_blocks
actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
- expected = %Q(A\nB\n\ncaption\nA\n\n)
+ expected = <<-EOS
+A
+B
+
+caption
+A
+
+EOS
assert_equal expected, actual
actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
- expected = %Q(A\nB\n\ncaption\nA\n\n)
+ expected = <<-EOS
+A
+B
+
+caption
+A
+
+EOS
assert_equal expected, actual
actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
- expected = %Q(A\nB\n\ncaption\nA\n\n)
+ expected = <<-EOS
+A
+B
+
+caption
+A
+
+EOS
assert_equal expected, actual
actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
- expected = %Q(A\nB\n\ncaption\nA\n\n)
+ expected = <<-EOS
+A
+B
+
+caption
+A
+
+EOS
assert_equal expected, actual
actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
- expected = %Q(A\nB\n\ncaption\nA\n\n)
+ expected = <<-EOS
+A
+B
+
+caption
+A
+
+EOS
assert_equal expected, actual
actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
- expected = %Q(A\nB\n\ncaption\nA\n\n)
+ expected = <<-EOS
+A
+B
+
+caption
+A
+
+EOS
assert_equal expected, actual
actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
- expected = %Q(A\nB\n\ncaption\nA\n\n)
+ expected = <<-EOS
+A
+B
+
+caption
+A
+
+EOS
assert_equal expected, actual
actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
- expected = %Q(A\nB\n\ncaption\nA\n\n)
+ expected = <<-EOS
+A
+B
+
+caption
+A
+
+EOS
assert_equal expected, actual
end
def test_image
def @chapter.image(_id)