class IDGXMLBuidlerTest

Public Instance Methods

column_helper(review) click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 375
def column_helper(review)
  compile_block(review)
end
setup() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 11
def setup
  @builder = IDGXMLBuilder.new()
  @config = ReVIEW::Configure.values
  @config.merge!({
    "secnolevel" => 2,
    "nolf" => true,
    "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)
  @builder.bind(@compiler, @chapter, location)
  I18n.setup("ja")
end
test_block_raw0() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 576
def test_block_raw0
  actual = compile_block("//raw[<>!\"\\n& ]\n")
  expected = %Q(<>!\"\n& )
  assert_equal expected, actual
end
test_block_raw1() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 582
def test_block_raw1
  actual = compile_block("//raw[|idgxml|<>!\"\\n& ]\n")
  expected = %Q(<>!\"\n& )
  assert_equal expected.chomp, actual
end
test_block_raw2() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 588
def test_block_raw2
  actual = compile_block("//raw[|idgxml, latex|<>!\"\\n& ]\n")
  expected = %Q(<>!\"\n& )
  assert_equal expected.chomp, actual
end
test_block_raw3() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 594
def test_block_raw3
  actual = compile_block("//raw[|latex, html|<>!\"\\n& ]\n")
  expected = %Q()
  assert_equal expected.chomp, actual
end
test_block_raw4() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 600
def test_block_raw4
  actual = compile_block("//raw[|idgxml <>!\"\\n& ]\n")
  expected = %Q(|idgxml <>!\"\n& )
  assert_equal expected.chomp, actual
end
test_box() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 265
def test_box
  @config["listinfo"] = true
  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>&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>|, actual
end
test_centering() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 277
def test_centering
  actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
  assert_equal %Q<p align='center'>foobar</p><p align='center'>buz</p>|, actual
end
test_column_1() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 379
  def test_column_1
    review =<<-EOS
===[column] prev column

inside prev column

===[column] test

inside column

===[/column]
EOS
    expected ="<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>
".chomp
    assert_equal expected, column_helper(review)
  end
test_column_2() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 397
  def test_column_2
    review =<<-EOS
===[column] test

inside column

=== next level
EOS
    expected ="<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"?>
".chomp

    assert_equal expected, column_helper(review)
  end
test_column_3() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 412
  def test_column_3
    review =<<-EOS
===[column] test

inside column

===[/column_dummy]
EOS
    assert_raise(ReVIEW::CompileError) do
      column_helper(review)
    end
  end
test_emlist() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 219
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>&lt;&amp;&gt;_</caption><pre>test1\ntest1.5\n\ntest<i>2</i>\n</pre></list>|, actual
end
test_emlist_listinfo() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 224
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>&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>|, actual
end
test_emlist_with_4tab() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 235
def test_emlist_with_4tab
  @config["tabwidth"] = 4
  actual = compile_block("//emlist[this is @<b>{test}<&>_]{\n\ttest1\n\t\ttest1.5\n\n\ttest@<i>{2}\n//}\n")
  assert_equal %Q<list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b>&lt;&amp;&gt;_</caption><pre>    test1\n        test1.5\n\n    test<i>2</i>\n</pre></list>|, actual
end
test_emlist_with_tab() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 230
def test_emlist_with_tab
  actual = compile_block("//emlist[this is @<b>{test}<&>_]{\n\ttest1\n\t\ttest1.5\n\n\ttest@<i>{2}\n//}\n")
  assert_equal %Q<list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b>&lt;&amp;&gt;_</caption><pre>        test1\n                test1.5\n\n        test<i>2</i>\n</pre></list>|, actual
end
test_flushright() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 272
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
test_headline_level1() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 28
def test_headline_level1
  actual = compile_block("={test} this is test.\n")
  assert_equal %Q<title id="test" aid:pstyle="h1">第1章 this is test.</title><?dtp level="1" section="第1章 this is test."?>|, actual
end
test_headline_level1_without_secno() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 33
def test_headline_level1_without_secno
  @config["secnolevel"] = 0
  actual = compile_block("={test} this is test.\n")
  assert_equal %Q<title id="test" aid:pstyle="h1">this is test.</title><?dtp level="1" section="this is test."?>|, actual
end
test_headline_level2() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 39
def test_headline_level2
  actual = compile_block("=={test} this is test.\n")
  assert_equal %Q<title id="test" aid:pstyle="h2">1.1 this is test.</title><?dtp level="2" section="1.1 this is test."?>|, actual
end
test_headline_level3() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 44
def test_headline_level3
  actual = compile_block("==={test} this is test.\n")
  assert_equal %Q<title id="test" aid:pstyle="h3">this is test.</title><?dtp level="3" section="this is test."?>|, actual
end
test_headline_level3_with_secno() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 50
def test_headline_level3_with_secno
  @config["secnolevel"] = 3
  actual = compile_block("==={test} this is test.\n")
  assert_equal %Q<title id="test" aid:pstyle="h3">1.0.1 this is test.</title><?dtp level="3" section="1.0.1 this is test."?>|, actual
end
test_href() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 66
def test_href
  actual = compile_inline("@<href>{http://github.com,GitHub}")
  assert_equal %Q<a linkurl='http://github.com'>GitHub</a>|, actual
end
test_href_without_label() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 71
def test_href_without_label
  actual = compile_inline("@<href>{http://github.com}")
  assert_equal %Q<a linkurl='http://github.com'>http://github.com</a>|, actual
end
test_image() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 287
def test_image
  def @chapter.image(id)
    item = Book::ImageIndex::Item.new("sampleimg",1)
    item.instance_eval{@path="./images/chap1-sampleimg.png"}
    item
  end

  actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
  assert_equal %Q<img><Image href="file://images/chap1-sampleimg.png" /><caption>図1.1 sample photo</caption></img>|, actual
end
test_image_with_metric() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 298
def test_image_with_metric
  def @chapter.image(id)
    item = Book::ImageIndex::Item.new("sampleimg",1)
    item.instance_eval{@path="./images/chap1-sampleimg.png"}
    item
  end

  actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
  assert_equal %Q<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /><caption>図1.1 sample photo</caption></img>|, actual
end
test_image_with_metric2() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 309
def test_image_with_metric2
  def @chapter.image(id)
    item = Book::ImageIndex::Item.new("sampleimg",1)
    item.instance_eval{@path="./images/chap1-sampleimg.png"}
    item
  end

  actual = compile_block("//image[sampleimg][sample photo][scale=1.2, html::class=sample, latex::ignore=params, idgxml::ostyle=object]{\n//}\n")
  assert_equal %Q<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" ostyle="object" /><caption>図1.1 sample photo</caption></img>|, actual
end
test_indepimage() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 320
def test_indepimage
  def @chapter.image(id)
    item = Book::ImageIndex::Item.new("sampleimg",1)
    item.instance_eval{@path="./images/chap1-sampleimg.png"}
    item
  end

  actual = compile_block("//indepimage[sampleimg][sample photo]\n")
  assert_equal %Q<img><Image href="file://images/chap1-sampleimg.png" /><caption>sample photo</caption></img>|, actual
end
test_indepimage_with_metric() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 342
def test_indepimage_with_metric
  def @chapter.image(id)
    item = Book::ImageIndex::Item.new("sampleimg",1)
    item.instance_eval{@path="./images/chap1-sampleimg.png"}
    item
  end

  actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
  assert_equal %Q<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /><caption>sample photo</caption></img>|, actual
end
test_indepimage_with_metric2() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 353
def test_indepimage_with_metric2
  def @chapter.image(id)
    item = Book::ImageIndex::Item.new("sampleimg",1)
    item.instance_eval{@path="./images/chap1-sampleimg.png"}
    item
  end

  actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2, html::class=\"sample\", latex::ignore=params, idgxml::ostyle=\"object\"]\n")
  assert_equal %Q<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" ostyle="object" /><caption>sample photo</caption></img>|, actual
end
test_indepimage_without_caption() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 331
def test_indepimage_without_caption
  def @chapter.image(id)
    item = Book::ImageIndex::Item.new("sampleimg",1)
    item.instance_eval{@path="./images/chap1-sampleimg.png"}
    item
  end

  actual = compile_block("//indepimage[sampleimg]\n")
  assert_equal %Q<img><Image href="file://images/chap1-sampleimg.png" /></img>|, actual
end
test_indepimage_without_caption_but_with_metric() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 364
def test_indepimage_without_caption_but_with_metric
  def @chapter.image(id)
    item = Book::ImageIndex::Item.new("sampleimg",1)
    item.instance_eval{@path="./images/chap1-sampleimg.png"}
    item
  end

  actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
  assert_equal %Q<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /></img>|, actual
end
test_inline_balloon() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 145
def test_inline_balloon
  actual = compile_inline("@<balloon>{@maru[1]test}")
  assert_equal %Q<balloon>&#x2460;test</balloon>|, actual
end
test_inline_br() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 110
def test_inline_br
  actual = compile_inline("@<br>{}")
  assert_equal %Q\n|, actual
end
test_inline_href() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 76
def test_inline_href
  actual = compile_inline("@<href>{http://github.com, Git\\,Hub}")
  assert_equal %Q<a linkurl='http://github.com'>Git,Hub</a>|, actual
end
test_inline_imgref() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 551
def test_inline_imgref
  def @chapter.image(id)
    item = Book::ImageIndex::Item.new("sampleimg", 1, 'sample photo')
    item.instance_eval{@path="./images/chap1-sampleimg.png"}
    item
  end

  actual = compile_block "@<imgref>{sampleimg}\n"
  expected = "<p><span type='image'>図1.1「sample photo」</span></p>"
  assert_equal expected, actual
end
test_inline_imgref2() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 563
def test_inline_imgref2
  def @chapter.image(id)
    item = Book::NumberlessImageIndex::Item.new("sampleimg", 1)
    item.instance_eval{@path="./images/chap1-sampleimg.png"}
    item
  end

  actual = compile_block "@<imgref>{sampleimg}\n"
  expected = "<p><span type='image'>図1.1</span></p>"
  assert_equal expected, actual
end
test_inline_in_table() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 86
def test_inline_in_table
  actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n------------\n@<b>{3}\t@<i>{4}<>&\n//}\n")
  assert_equal %Q<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="2"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><b>1</b></td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><i>2</i></td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><b>3</b></td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><i>4</i>&lt;&gt;&amp;</td></tbody></table>|, actual
end
test_inline_in_table_without_cellwidth() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 96
def test_inline_in_table_without_cellwidth
  @config["tableopt"] = nil
  actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n------------\n@<b>{3}\t@<i>{4}<>&\n//}\n")
  assert_equal %Q<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>|, actual
  @config["tableopt"] = 10
end
test_inline_in_table_without_header() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 91
def test_inline_in_table_without_header
  actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n@<b>{3}\t@<i>{4}<>&\n//}\n")
  assert_equal %Q<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>|, actual
end
test_inline_in_table_without_header_and_cellwidth() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 103
def test_inline_in_table_without_header_and_cellwidth
  @config["tableopt"] = nil
  actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n@<b>{3}\t@<i>{4}<>&\n//}\n")
  assert_equal %Q<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>|, actual
  @config["tableopt"] = 10
end
test_inline_kw() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 125
def test_inline_kw
  actual = compile_inline("@<kw>{ISO, International Organization for Standardization } @<kw>{Ruby<>}")
  assert_equal %Q<keyword>ISO(International Organization for Standardization)</keyword><index value="ISO" /><index value="International Organization for Standardization" /> <keyword>Ruby&lt;&gt;</keyword><index value="Ruby&lt;&gt;" />|, actual
end
test_inline_m() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 150
def test_inline_m
  actual = compile_inline("@<m>{\\sin} @<m>{\\frac{1\\}{2\\}}")
  assert_equal %Q<replace idref="texinline-1"><pre>\\sin</pre></replace> <replace idref="texinline-2"><pre>\\frac{1}{2}</pre></replace>|, actual
end
test_inline_maru() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 130
def test_inline_maru
  actual = compile_inline("@<maru>{1}@<maru>{20}@<maru>{A}@<maru>{z}")
  assert_equal %Q&#x2460;&#x2473;&#x24b6;&#x24e9;|, actual
end
test_inline_raw() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 81
def test_inline_raw
  actual = compile_inline("@<raw>{@<tt>{inline\}}")
  assert_equal %Q@<tt>{inline}|, actual
end
test_inline_raw0() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 527
def test_inline_raw0
  assert_equal "normal", compile_inline("@<raw>{normal}")
end
test_inline_raw1() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 531
def test_inline_raw1
  assert_equal "body", compile_inline("@<raw>{|idgxml|body}")
end
test_inline_raw2() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 535
def test_inline_raw2
  assert_equal "body", compile_inline("@<raw>{|idgxml, latex|body}")
end
test_inline_raw3() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 539
def test_inline_raw3
  assert_equal "", compile_inline("@<raw>{|latex, html|body}")
end
test_inline_raw4() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 543
def test_inline_raw4
  assert_equal "|idgxml body", compile_inline("@<raw>{|idgxml body}")
end
test_inline_raw5() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 547
def test_inline_raw5
  assert_equal "nor\nmal", compile_inline("@<raw>{|idgxml|nor\\nmal}")
end
test_inline_ref() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 61
def test_inline_ref
  actual = compile_inline("@<ref>{外部参照<>&}")
  assert_equal %Q<ref idref='外部参照&lt;&gt;&amp;'>「●● 外部参照&lt;&gt;&amp;」</ref>|, actual
end
test_inline_ruby() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 120
def test_inline_ruby
  actual = compile_inline("@<ruby>{coffin, bed}")
  assert_equal %Q<GroupRuby><aid:ruby xmlns:aid="http://ns.adobe.com/AdobeInDesign/3.0/"><aid:rb>coffin</aid:rb><aid:rt>bed</aid:rt></aid:ruby></GroupRuby>|, actual
end
test_inline_ttb() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 135
def test_inline_ttb
  actual = compile_inline("@<ttb>{test * <>\"}")
  assert_equal %Q<tt style='bold'>test * &lt;&gt;&quot;</tt>|, actual
end
test_inline_ttbold() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 140
def test_inline_ttbold
  actual = compile_inline("@<ttbold>{test * <>\"}")
  assert_equal %Q<tt style='bold'>test * &lt;&gt;&quot;</tt>|, actual
end
test_inline_uchar() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 115
def test_inline_uchar
  actual = compile_inline("test @<uchar>{2460} test2")
  assert_equal %Qtest &#x2460; test2|, actual
end
test_insn() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 258
def test_insn
  @config["listinfo"] = true
  actual = compile_block("//insn[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
  @config["listinfo"] = nil
  assert_equal %Q<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>|, actual
end
test_label() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 56
def test_label
  actual = compile_block("//label[label_test]\n")
  assert_equal %Q<label id='label_test' />|, actual
end
test_list() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 241
def test_list
  def @chapter.list(id)
    Book::ListIndex::Item.new("samplelist",1)
  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>&lt;&amp;&gt;_</caption><pre>test1\ntest1.5\n\ntest<i>2</i>\n</pre></codelist>|, actual
end
test_list_listinfo() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 249
def test_list_listinfo
  def @chapter.list(id)
    Book::ListIndex::Item.new("samplelist",1)
  end
  @config["listinfo"] = true
  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>&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>|, actual
end
test_memo() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 182
def test_memo
  actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
  assert_equal %Q<memo><title aid:pstyle='memo-title'>this is <b>test</b>&lt;&amp;&gt;_</title><p>test1test1.5</p><p>test<i>2</i></p></memo>|, actual
end
test_noindent() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 282
def test_noindent
  actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
  assert_equal %Q<p aid:pstyle="noindent" noindent='1'>foobar</p><p>foo2bar2</p>|, actual
end
test_note() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 177
def test_note
  actual = compile_block("//note[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
  assert_equal %Q<note><title aid:pstyle='note-title'>this is <b>test</b>&lt;&amp;&gt;_</title><p>test1test1.5</p><p>test<i>2</i></p></note>|, actual
end
test_notice() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 199
def test_notice
  actual = compile_block("//notice[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
  assert_equal %Q<notice-t><title aid:pstyle='notice-title'>this is <b>test</b>&lt;&amp;&gt;_</title><p>test1test1.5</p><p>test<i>2</i></p></notice-t>|, actual
end
test_notice_without_caption() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 204
def test_notice_without_caption
  actual = compile_block("//notice{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
  assert_equal %Q<notice><p>test1test1.5</p><p>test<i>2</i></p></notice>|, actual
end
test_ol() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 514
  def test_ol
    src =<<-EOS
  3. AAA
  3. BBB
EOS

    expected ="<ol><li aid:pstyle="ol-item" olnum="1" num="3">AAA</li><li aid:pstyle="ol-item" olnum="2" num="3">BBB</li></ol>
".chomp
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_paragraph() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 155
def test_paragraph
  actual = compile_block("foo\nbar\n")
  assert_equal %Q<p>foobar</p>|, actual
end
test_point() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 209
def test_point
  actual = compile_block("//point[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
  assert_equal %Q<point-t><title aid:pstyle='point-title'>this is <b>test</b>&lt;&amp;&gt;_</title><p>test1test1.5</p><p>test<i>2</i></p></point-t>|, actual
end
test_point_without_caption() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 214
def test_point_without_caption
  actual = compile_block("//point{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
  assert_equal %Q<point><p>test1test1.5</p><p>test<i>2</i></p></point>|, actual
end
test_quote() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 165
def test_quote
  actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
  assert_equal %Q<quote><p>foobar</p><p>buz</p></quote>|, actual
end
test_quote_deprecated() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 170
def test_quote_deprecated
  @book.config["deprecated-blocklines"] = true
  actual = compile_block("//quote{\nfoo\n\nbuz\n//}\n")
  @book.config["deprecated-blocklines"] = nil
  assert_equal %Q<quote>foo\n\nbuz</quote>|, actual
end
test_tabbed_paragraph() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 160
def test_tabbed_paragraph
  actual = compile_block("\tfoo\nbar\n")
  assert_equal %Q<p inlist="1">foobar</p>|, actual
end
test_term() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 187
def test_term
  actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
  assert_equal %Q<term><p>test1test1.5</p><p>test<i>2</i></p></term>|, actual
end
test_term_deprecated() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 192
def test_term_deprecated
  @book.config["deprecated-blocklines"] = true
  actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
  @book.config["deprecated-blocklines"] = nil
  assert_equal %Q<term>test1\ntest1.5\n\ntest<i>2</i></term>|, actual
end
test_ul() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 425
  def test_ul
    src =<<-EOS
  * AAA
  * BBB
EOS

    expected ="<ul><li aid:pstyle="ul-item">AAA</li><li aid:pstyle="ul-item">BBB</li></ul>
".chomp
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_ul_cont() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 438
  def test_ul_cont
    src =<<-EOS
  * AAA
    -AA
  * BBB
    -BB
EOS

    expected ="<ul><li aid:pstyle="ul-item">AAA-AA</li><li aid:pstyle="ul-item">BBB-BB</li></ul>
".chomp
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_ul_nest1() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 453
  def test_ul_nest1
    src =<<-EOS
  * AAA
  ** AA
EOS

    expected ="<ul><li aid:pstyle="ul-item">AAA<ul2><li aid:pstyle="ul-item">AA</li></ul2></li></ul>
".chomp
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_ul_nest2() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 466
  def test_ul_nest2
    src =<<-EOS
  * AAA
  ** AA
  * BBB
  ** BB
EOS

    expected ="<ul><li aid:pstyle="ul-item">AAA<ul2><li aid:pstyle="ul-item">AA</li></ul2></li><li aid:pstyle="ul-item">BBB<ul2><li aid:pstyle="ul-item">BB</li></ul2></li></ul>
".chomp
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_ul_nest3() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 481
  def test_ul_nest3
    src =<<-EOS
  ** AAA
  * AA
  * BBB
  ** BB
EOS

    expected ="<ul><li aid:pstyle="ul-item"><ul2><li aid:pstyle="ul-item">AAA</li></ul2></li><li aid:pstyle="ul-item">AA</li><li aid:pstyle="ul-item">BBB<ul2><li aid:pstyle="ul-item">BB</li></ul2></li></ul>
".chomp
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_ul_nest4() click to toggle source
# File ../../../../../test/test_idgxmlbuilder.rb, line 496
  def test_ul_nest4
    src =<<-EOS
  * A
  ** B
  ** C
  *** D
  ** E
  * F
  ** G
EOS

    expected ="<ul><li aid:pstyle="ul-item">A<ul2><li aid:pstyle="ul-item">B</li><li aid:pstyle="ul-item">C<ul3><li aid:pstyle="ul-item">D</li></ul3></li><li aid:pstyle="ul-item">E</li></ul2></li><li aid:pstyle="ul-item">F<ul2><li aid:pstyle="ul-item">G</li></ul2></li></ul>
".chomp
    actual = compile_block(src)
    assert_equal expected, actual
  end