test/test_idgxmlbuilder.rb in review-2.1.0 vs test/test_idgxmlbuilder.rb in review-2.2.0
- old
+ new
@@ -11,13 +11,13 @@
def setup
@builder = IDGXMLBuilder.new()
@config = ReVIEW::Configure.values
@config.merge!({
- "secnolevel" => 2,
- "tableopt" => "10"
- })
+ "secnolevel" => 2,
+ "tableopt" => "10"
+ })
@book = Book::Base.new(nil)
@book.config = @config
@compiler = ReVIEW::Compiler.new(@builder)
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
location = Location.new(nil, nil)
@@ -112,10 +112,19 @@
actual = compile_block("//tsize[2,3]\n//table{\nA\tB\tC\n//}\n")
assert_equal %Q|<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="3"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">A</td><td xyh="2,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="8.503">B</td><td xyh="3,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">C</td></tbody></table>|, actual
actual = compile_block("//tsize[2]\n//table{\nA\tB\tC\n//}\n")
assert_equal %Q|<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="3"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">A</td><td xyh="2,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="11.338">B</td><td xyh="3,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="11.338">C</td></tbody></table>|, actual
+
+ actual = compile_block("//tsize[|idgxml|2]\n//table{\nA\tB\tC\n//}\n")
+ assert_equal %Q|<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="3"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">A</td><td xyh="2,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="11.338">B</td><td xyh="3,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="11.338">C</td></tbody></table>|, actual
+
+ actual = compile_block("//tsize[|idgxml,html|2]\n//table{\nA\tB\tC\n//}\n")
+ assert_equal %Q|<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="3"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">A</td><td xyh="2,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="11.338">B</td><td xyh="3,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="11.338">C</td></tbody></table>|, actual
+
+ actual = compile_block("//tsize[|html|2]\n//table{\nA\tB\tC\n//}\n")
+ assert_equal %Q|<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="3"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">A</td><td xyh="2,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">B</td><td xyh="3,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">C</td></tbody></table>|, actual
end
def test_customize_mmtopt
actual = compile_block("//table{\nA\n//}\n")
assert_equal %Q|<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="28.345">A</td></tbody></table>|, actual
@@ -242,10 +251,15 @@
def test_emlist
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
assert_equal %Q|<list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b><&>_</caption><pre>test1\ntest1.5\n\ntest<i>2</i>\n</pre></list>|, actual
end
+ def test_emlistnum
+ actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
+ assert_equal %Q|<list type='emlistnum'><caption aid:pstyle='emlistnum-title'>this is <b>test</b><&>_</caption><pre><span type='lineno'> 1: </span>test1\n<span type='lineno'> 2: </span>test1.5\n<span type='lineno'> 3: </span>\n<span type='lineno'> 4: </span>test<i>2</i>\n</pre></list>|, actual
+ end
+
def test_emlist_listinfo
@config["listinfo"] = true
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
assert_equal %Q|<list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b><&>_</caption><pre><listinfo line="1" begin="1">test1\n</listinfo><listinfo line="2">test1.5\n</listinfo><listinfo line="3">\n</listinfo><listinfo line="4" end="4">test<i>2</i>\n</listinfo></pre></list>|, actual
end
@@ -267,10 +281,26 @@
end
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
assert_equal %Q|<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre>test1\ntest1.5\n\ntest<i>2</i>\n</pre></codelist>|, actual
end
+ def test_listnum
+ def @chapter.list(id)
+ Book::ListIndex::Item.new("samplelist",1)
+ end
+ actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
+ assert_equal %Q|<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre><span type='lineno'> 1: </span>test1\n<span type='lineno'> 2: </span>test1.5\n<span type='lineno'> 3: </span>\n<span type='lineno'> 4: </span>test<i>2</i>\n</pre></codelist>|, actual
+ end
+
+ def test_listnum_linenum
+ def @chapter.list(id)
+ Book::ListIndex::Item.new("samplelist",1)
+ end
+ actual = compile_block("//firstlinenum[100]\n//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
+ assert_equal %Q|<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre><span type='lineno'>100: </span>test1\n<span type='lineno'>101: </span>test1.5\n<span type='lineno'>102: </span>\n<span type='lineno'>103: </span>test<i>2</i>\n</pre></codelist>|, actual
+ end
+
def test_list_listinfo
def @chapter.list(id)
Book::ListIndex::Item.new("samplelist",1)
end
@config["listinfo"] = true
@@ -290,10 +320,16 @@
actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
@config["listinfo"] = nil
assert_equal %Q|<box><caption aid:pstyle="box-title">this is <b>test</b><&>_</caption><listinfo line="1" begin="1">test1\n</listinfo><listinfo line="2">test1.5\n</listinfo><listinfo line="3">\n</listinfo><listinfo line="4" end="4">test<i>2</i>\n</listinfo></box>|, actual
end
+ def test_box_non_listinfo
+ @config["listinfo"] = nil
+ actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
+ assert_equal %Q|<box><caption aid:pstyle="box-title">this is <b>test</b><&>_</caption>test1\ntest1.5\n\ntest<i>2</i>\n</box>|, actual
+ end
+
def test_flushright
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal %Q|<p align='right'>foobar</p><p align='right'>buz</p>|, actual
end
@@ -443,10 +479,38 @@
assert_raise(ReVIEW::CompileError) do
column_helper(review)
end
end
+ def test_column_ref
+ review =<<-EOS
+===[column]{foo} test
+
+inside column
+
+=== next level
+
+this is @<column>{foo}.
+EOS
+ expected =<<-EOS.chomp
+<column id="column-1"><title aid:pstyle="column-title">test</title><?dtp level="9" section="test"?><p>inside column</p></column><title aid:pstyle="h3">next level</title><?dtp level="3" section="next level"?><p>this is コラム「test」.</p>
+EOS
+
+ assert_equal expected, column_helper(review)
+ end
+
+ def test_column_in_aother_chapter_ref
+ def @chapter.column_index
+ items = [Book::ColumnIndex::Item.new("chap1|column", 1, "column_cap")]
+ Book::ColumnIndex.new(items)
+ end
+
+ actual = compile_inline("test @<column>{chap1|column} test2")
+ expected = "test コラム「column_cap」 test2"
+ assert_equal expected, actual
+ end
+
def test_ul
src =<<-EOS
* AAA
* BBB
EOS
@@ -624,6 +688,27 @@
actual = compile_block("//raw[|idgxml <>!\"\\n& ]\n")
expected = %Q(|idgxml <>!\"\n& )
assert_equal expected.chomp, actual
end
+ def test_comment
+ actual = compile_block("//comment[コメント]")
+ assert_equal %Q||, actual
+ end
+
+ def test_comment_for_draft
+ @config["draft"] = true
+ actual = compile_block("//comment[コメント]")
+ assert_equal %Q|<msg>コメント</msg>|, actual
+ end
+
+ def test_inline_comment
+ actual = compile_inline("test @<comment>{コメント} test2")
+ assert_equal %Q|test test2|, actual
+ end
+
+ def test_inline_comment_for_draft
+ @config["draft"] = true
+ actual = compile_inline("test @<comment>{コメント} test2")
+ assert_equal %Q|test <msg>コメント</msg> test2|, actual
+ end
end