test/test_idgxmlbuilder.rb in review-1.2.0 vs test/test_idgxmlbuilder.rb in review-1.3.0

- old
+ new

@@ -9,18 +9,18 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase include ReVIEW def setup @builder = IDGXMLBuilder.new() - @param = { + @config = { "secnolevel" => 2, "inencoding" => "UTF-8", "outencoding" => "UTF-8", "nolf" => true, "tableopt" => "10" } - ReVIEW.book.param = @param + ReVIEW.book.config = @config @compiler = ReVIEW::Compiler.new(@builder) @chapter = Book::Chapter.new(Book::Base.new(nil), 1, '-', nil, StringIO.new) location = Location.new(nil, nil) @builder.bind(@compiler, @chapter, location) end @@ -29,11 +29,11 @@ @builder.headline(1,"test","this is test.") assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><title id="test" aid:pstyle="h1">第1章 this is test.</title><?dtp level="1" section="第1章 this is test."?>|, @builder.raw_result end def test_headline_level1_without_secno - @param["secnolevel"] = 0 + @config["secnolevel"] = 0 @builder.headline(1,"test","this is test.") assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><title id="test" aid:pstyle="h1">this is test.</title><?dtp level="1" section="this is test."?>|, @builder.raw_result end def test_headline_level2 @@ -46,11 +46,11 @@ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><title id="test" aid:pstyle="h3">this is test.</title><?dtp level="3" section="this is test."?>|, @builder.raw_result end def test_headline_level3_with_secno - @param["secnolevel"] = 3 + @config["secnolevel"] = 3 @builder.headline(3,"test","this is test.") assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><title id="test" aid:pstyle="h3">1.0.1 this is test.</title><?dtp level="3" section="1.0.1 this is test."?>|, @builder.raw_result end def test_label @@ -92,21 +92,21 @@ ret = @builder.table(["<b>1</b>\t<i>2</i>", "<b>3</b>\t<i>4</i>&lt;&gt;&amp;"]) assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="2"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><b>1</b></td><td xyh="2,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><i>2</i></td><td xyh="1,2,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><b>3</b></td><td xyh="2,2,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><i>4</i>&lt;&gt;&amp;</td></tbody></table>|, @builder.raw_result end def test_inline_in_table_without_cellwidth - @param["tableopt"] = nil + @config["tableopt"] = nil ret = @builder.table(["<b>1</b>\t<i>2</i>", "------------", "<b>3</b>\t<i>4</i>&lt;&gt;&amp;"]) assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><table><tbody><tr type="header"><b>1</b>\t<i>2</i></tr><tr type="lastline"><b>3</b>\t<i>4</i>&lt;&gt;&amp;</tr></tbody></table>|, @builder.raw_result - @param["tableopt"] = 10 + @config["tableopt"] = 10 end def test_inline_in_table_without_header_and_cellwidth - @param["tableopt"] = nil + @config["tableopt"] = nil ret = @builder.table(["<b>1</b>\t<i>2</i>", "<b>3</b>\t<i>4</i>&lt;&gt;&amp;"]) assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><table><tbody><tr><b>1</b>\t<i>2</i></tr><tr type="lastline"><b>3</b>\t<i>4</i>&lt;&gt;&amp;</tr></tbody></table>|, @builder.raw_result - @param["tableopt"] = 10 + @config["tableopt"] = 10 end def test_inline_br ret = @builder.inline_br("") assert_equal %Q|\n|, ret @@ -170,13 +170,13 @@ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><quote><p>foobar</p><p>buz</p></quote>|, @builder.raw_result end def test_quote_deprecated lines = ["foo","","buz"] - ReVIEW.book.param["deprecated-blocklines"] = true + ReVIEW.book.config["deprecated-blocklines"] = true @builder.quote(lines) - ReVIEW.book.param["deprecated-blocklines"] = nil + ReVIEW.book.config["deprecated-blocklines"] = nil assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><quote>foo\n\nbuz</quote>|, @builder.raw_result end def test_note @builder.note(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_") @@ -192,13 +192,13 @@ @builder.term(["test1", "test1.5", "", "test<i>2</i>"]) assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><term><p>test1test1.5</p><p>test<i>2</i></p></term>|, @builder.raw_result end def test_term_deprecated - ReVIEW.book.param["deprecated-blocklines"] = true + ReVIEW.book.config["deprecated-blocklines"] = true @builder.term(["test1", "test1.5", "", "test<i>2</i>"]) - ReVIEW.book.param["deprecated-blocklines"] = nil + ReVIEW.book.config["deprecated-blocklines"] = nil assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><term>test1\ntest1.5\n\ntest<i>2</i></term>|, @builder.raw_result end def test_notice @builder.notice(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_") @@ -224,11 +224,11 @@ @builder.emlist(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_") assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b>&lt;&amp;&gt;_</caption><pre>test1\ntest1.5\n\ntest<i>2</i>\n</pre></list>|, @builder.raw_result end def test_emlist_listinfo - @param["listinfo"] = true + @config["listinfo"] = true @builder.emlist(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_") assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b>&lt;&amp;&gt;_</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>|, @builder.raw_result end def test_emlist_with_tab @@ -252,26 +252,26 @@ def test_list_listinfo def @chapter.list(id) Book::ListIndex::Item.new("samplelist",1) end - @param["listinfo"] = true + @config["listinfo"] = true @builder.list(["test1", "test1.5", "", "test<i>2</i>"], "samplelist", "this is @<b>{test}<&>_") assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><codelist><caption>リスト1.1 this is <b>test</b>&lt;&amp;&gt;_</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></codelist>|, @builder.raw_result end def test_insn - @param["listinfo"] = true + @config["listinfo"] = true @builder.insn(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_") - @param["listinfo"] = nil + @config["listinfo"] = nil assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><insn><floattitle type="insn">this is <b>test</b>&lt;&amp;&gt;_</floattitle><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></insn>|, @builder.raw_result end def test_box - @param["listinfo"] = true + @config["listinfo"] = true @builder.box(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_") - @param["listinfo"] = nil + @config["listinfo"] = nil assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><box><caption aid:pstyle="box-title">this is <b>test</b>&lt;&amp;&gt;_</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>|, @builder.raw_result end def test_flushright @builder.flushright(["foo", "bar", "","buz"]) @@ -291,88 +291,88 @@ end def test_image def @chapter.image(id) item = Book::ImageIndex::Item.new("sampleimg",1) - item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]} + item.instance_eval{@path="./images/chap1-sampleimg.png"} item end @builder.image_image("sampleimg","sample photo",nil) assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" /><caption>図1.1 sample photo</caption></img>|, @builder.raw_result end def test_image_with_metric def @chapter.image(id) item = Book::ImageIndex::Item.new("sampleimg",1) - item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]} + item.instance_eval{@path="./images/chap1-sampleimg.png"} item end @builder.image_image("sampleimg","sample photo","scale=1.2") assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /><caption>図1.1 sample photo</caption></img>|, @builder.raw_result end def test_image_with_metric2 def @chapter.image(id) item = Book::ImageIndex::Item.new("sampleimg",1) - item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]} + item.instance_eval{@path="./images/chap1-sampleimg.png"} item end @builder.image_image("sampleimg","sample photo","scale=1.2, html::class=\"sample\", latex::ignore=params, idgxml::ostyle=object") assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" scale="1.2" ostyle="object" /><caption>図1.1 sample photo</caption></img>|, @builder.raw_result end def test_indepimage def @chapter.image(id) item = Book::ImageIndex::Item.new("sampleimg",1) - item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]} + item.instance_eval{@path="./images/chap1-sampleimg.png"} item end @builder.indepimage("sampleimg","sample photo",nil) assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" /><caption>sample photo</caption></img>|, @builder.raw_result end def test_indepimage_without_caption def @chapter.image(id) item = Book::ImageIndex::Item.new("sampleimg",1) - item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]} + item.instance_eval{@path="./images/chap1-sampleimg.png"} item end @builder.indepimage("sampleimg",nil,nil) assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" /></img>|, @builder.raw_result end def test_indepimage_with_metric def @chapter.image(id) item = Book::ImageIndex::Item.new("sampleimg",1) - item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]} + item.instance_eval{@path="./images/chap1-sampleimg.png"} item end @builder.indepimage("sampleimg","sample photo","scale=1.2") assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /><caption>sample photo</caption></img>|, @builder.raw_result end def test_indepimage_with_metric2 def @chapter.image(id) item = Book::ImageIndex::Item.new("sampleimg",1) - item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]} + item.instance_eval{@path="./images/chap1-sampleimg.png"} item end @builder.indepimage("sampleimg","sample photo","scale=1.2, html::class=\"sample\", latex::ignore=params, idgxml::ostyle=\"object\"") assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" scale="1.2" ostyle="object" /><caption>sample photo</caption></img>|, @builder.raw_result end def test_indepimage_without_caption_but_with_metric def @chapter.image(id) item = Book::ImageIndex::Item.new("sampleimg",1) - item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]} + item.instance_eval{@path="./images/chap1-sampleimg.png"} item end @builder.indepimage("sampleimg",nil,"scale=1.2") assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /></img>|, @builder.raw_result @@ -396,11 +396,11 @@ ===[/column] EOS expect =<<-EOS <?xml version="1.0" encoding="UTF-8"?> -<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><column><title aid:pstyle="column-title">prev column</title><p>inside prev column</p></column><column><title aid:pstyle="column-title">test</title><p>inside column</p></column></doc> +<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><column id="column-1"><title aid:pstyle="column-title">prev column</title><p>inside prev column</p></column><column id="column-2"><title aid:pstyle="column-title">test</title><p>inside column</p></column></doc> EOS assert_equal expect, column_helper(review) end def test_column_2 @@ -411,11 +411,11 @@ === next level EOS expect =<<-EOS <?xml version="1.0" encoding="UTF-8"?> -<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><column><title aid:pstyle="column-title">test</title><p>inside column</p></column><title aid:pstyle=\"h3\">next level</title><?dtp level="3" section="next level"?></doc> +<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><column id="column-1"><title aid:pstyle="column-title">test</title><p>inside column</p></column><title aid:pstyle=\"h3\">next level</title><?dtp level="3" section="next level"?></doc> EOS assert_equal expect, column_helper(review) end @@ -555,48 +555,34 @@ assert_equal "nor\nmal", @builder.inline_raw("|idgxml|nor\\nmal") end def test_block_raw0 @builder.raw("<>!\"\\n& ") - expect =<<-EOS -<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><>!" -& -EOS + expect = %Q(<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><>!\"\n& ) assert_equal expect.chomp, @builder.raw_result end def test_block_raw1 @builder.raw("|idgxml|<>!\"\\n& ") - expect =<<-EOS -<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><>!" -& -EOS + expect = %Q(<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><>!\"\n& ) assert_equal expect.chomp, @builder.raw_result end def test_block_raw2 @builder.raw("|idgxml, latex|<>!\"\\n& ") - expect =<<-EOS -<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><>!\" -& -EOS + expect = %Q(<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><>!\"\n& ) assert_equal expect.chomp, @builder.raw_result end def test_block_raw3 @builder.raw("|latex, html|<>!\"\\n& ") - expect =<<-EOS -<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"> -EOS + expect = %Q(<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">) assert_equal expect.chomp, @builder.raw_result end def test_block_raw4 @builder.raw("|idgxml <>!\"\\n& ") - expect =<<-EOS -<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">|idgxml <>!\" -& -EOS + expect = %Q(<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">|idgxml <>!\"\n& ) assert_equal expect.chomp, @builder.raw_result end end