第1章 this is test.|, actual
end
def test_headline_level1_without_secno
@config["secnolevel"] = 0
actual = compile_block("={test} this is test.\n")
assert_equal %Q|this is test.|, actual
end
def test_headline_level2
actual = compile_block("=={test} this is test.\n")
assert_equal %Q|1.1 this is test.|, actual
end
def test_headline_level3
actual = compile_block("==={test} this is test.\n")
assert_equal %Q|this is test.|, actual
end
def test_headline_level3_with_secno
@config["secnolevel"] = 3
actual = compile_block("==={test} this is test.\n")
assert_equal %Q|1.0.1 this is test.|, actual
end
def test_label
actual = compile_block("//label[label_test]\n")
assert_equal %Q||, actual
end
def test_inline_ref
actual = compile_inline("@{外部参照<>&}")
assert_equal %Q|「●● 外部参照<>&」|, actual
end
def test_href
actual = compile_inline("@{http://github.com,GitHub}")
assert_equal %Q|GitHub|, actual
end
def test_href_without_label
actual = compile_inline("@{http://github.com}")
assert_equal %Q|http://github.com|, actual
end
def test_inline_href
actual = compile_inline("@{http://github.com, Git\\,Hub}")
assert_equal %Q|Git,Hub|, actual
end
def test_inline_raw
actual = compile_inline("@{@{inline\}}")
assert_equal %Q|@{inline}|, 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
2
3
4<>&
|, actual
end
def test_inline_in_table_without_header
actual = compile_block("//table{\n@{1}\t@{2}\n@{3}\t@{4}<>&\n//}\n")
assert_equal %Q|
1
2
3
4<>&
|, actual
end
def test_inline_in_table_without_cellwidth
@config["tableopt"] = nil
actual = compile_block("//table{\n@{1}\t@{2}\n------------\n@{3}\t@{4}<>&\n//}\n")
assert_equal %Q|
1\t2
3\t4<>&
|, actual
@config["tableopt"] = 10
end
def test_inline_in_table_without_header_and_cellwidth
@config["tableopt"] = nil
actual = compile_block("//table{\n@{1}\t@{2}\n@{3}\t@{4}<>&\n//}\n")
assert_equal %Q|
1\t2
3\t4<>&
|, actual
@config["tableopt"] = 10
end
def test_inline_br
actual = compile_inline("@ {}")
assert_equal %Q|\n|, actual
end
def test_inline_uchar
actual = compile_inline("test @{2460} test2")
assert_equal %Q|test ① test2|, actual
end
def test_inline_ruby
actual = compile_inline("@{coffin, bed}")
assert_equal %Q|coffinbed|, actual
end
def test_inline_kw
actual = compile_inline("@{ISO, International Organization for Standardization } @{Ruby<>}")
assert_equal %Q|ISO(International Organization for Standardization)Ruby<>|, actual
end
def test_inline_maru
actual = compile_inline("@{1}@{20}@{A}@{z}")
assert_equal %Q|①⑳Ⓐⓩ|, actual
end
def test_inline_ttb
actual = compile_inline("@{test * <>\"}")
assert_equal %Q|test * <>"|, actual
end
def test_inline_ttbold
actual = compile_inline("@{test * <>\"}")
assert_equal %Q|test * <>"|, actual
end
def test_inline_balloon
actual = compile_inline("@{@maru[1]test}")
assert_equal %Q|①test|, actual
end
def test_inline_m
actual = compile_inline("@{\\sin} @{\\frac{1\\}{2\\}}")
assert_equal %Q|
\\sin
\\frac{1}{2}
|, actual
end
def test_paragraph
actual = compile_block("foo\nbar\n")
assert_equal %Q|
foobar
|, actual
end
def test_tabbed_paragraph
actual = compile_block("\tfoo\nbar\n")
assert_equal %Q|
foobar
|, actual
end
def test_quote
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal %Q|
foobar
buz
|, actual
end
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|foo\n\nbuz|, actual
end
def test_note
actual = compile_block("//note[this is @{test}<&>_]{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
assert_equal %Q|this is test<&>_
test1test1.5
test2
|, actual
end
def test_memo
actual = compile_block("//memo[this is @{test}<&>_]{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
assert_equal %Q|this is test<&>_
test1test1.5
test2
|, actual
end
def test_term
actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
assert_equal %Q|
test1test1.5
test2
|, actual
end
def test_term_deprecated
@book.config["deprecated-blocklines"] = true
actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
@book.config["deprecated-blocklines"] = nil
assert_equal %Q|test1\ntest1.5\n\ntest2|, actual
end
def test_notice
actual = compile_block("//notice[this is @{test}<&>_]{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
assert_equal %Q|this is test<&>_
test1test1.5
test2
|, actual
end
def test_notice_without_caption
actual = compile_block("//notice{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
assert_equal %Q|
test1test1.5
test2
|, actual
end
def test_point
actual = compile_block("//point[this is @{test}<&>_]{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
assert_equal %Q|this is test<&>_
test1test1.5
test2
|, actual
end
def test_point_without_caption
actual = compile_block("//point{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
assert_equal %Q|
test1test1.5
test2
|, actual
end
def test_emlist
actual = compile_block("//emlist[this is @{test}<&>_]{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
assert_equal %Q|
this is test<&>_
test1\ntest1.5\n\ntest2\n
|, actual
end
def test_emlist_listinfo
@config["listinfo"] = true
actual = compile_block("//emlist[this is @{test}<&>_]{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
assert_equal %Q|
this is test<&>_
test1\ntest1.5\n\ntest2\n
|, actual
end
def test_emlist_with_tab
actual = compile_block("//emlist[this is @{test}<&>_]{\n\ttest1\n\t\ttest1.5\n\n\ttest@{2}\n//}\n")
assert_equal %Q|
this is test<&>_
test1\n test1.5\n\n test2\n
|, actual
end
def test_emlist_with_4tab
@config["tabwidth"] = 4
actual = compile_block("//emlist[this is @{test}<&>_]{\n\ttest1\n\t\ttest1.5\n\n\ttest@{2}\n//}\n")
assert_equal %Q|
this is test<&>_
test1\n test1.5\n\n test2\n
|, actual
end
def test_list
def @chapter.list(id)
Book::ListIndex::Item.new("samplelist",1)
end
actual = compile_block("//list[samplelist][this is @{test}<&>_]{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
assert_equal %Q|
リスト1.1 this is test<&>_
test1\ntest1.5\n\ntest2\n
|, actual
end
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 @{test}<&>_]{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
assert_equal %Q|
リスト1.1 this is test<&>_
test1\ntest1.5\n\ntest2\n
|, actual
end
def test_insn
@config["listinfo"] = true
actual = compile_block("//insn[this is @{test}<&>_]{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
@config["listinfo"] = nil
assert_equal %Q|this is test<&>_test1\ntest1.5\n\ntest2\n|, actual
end
def test_box
@config["listinfo"] = true
actual = compile_block("//box[this is @{test}<&>_]{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
@config["listinfo"] = nil
assert_equal %Q|
this is test<&>_
test1\ntest1.5\n\ntest2\n|, actual
end
def test_flushright
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal %Q|
foobar
buz
|, actual
end
def test_centering
actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal %Q|
foobar
buz
|, actual
end
def test_noindent
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
assert_equal %Q|
foobar
foo2bar2
|, actual
end
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|
図1.1 sample photo
|, actual
end
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|
図1.1 sample photo
|, actual
end
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|
図1.1 sample photo
|, actual
end
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|
sample photo
|, actual
end
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||, actual
end
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|
sample photo
|, actual
end
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|
sample photo
|, actual
end
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||, actual
end
def column_helper(review)
compile_block(review)
end
def test_column_1
review =<<-EOS
===[column] prev column
inside prev column
===[column] test
inside column
===[/column]
EOS
expected =<<-EOS.chomp
prev column
inside prev column
test
inside column
EOS
assert_equal expected, column_helper(review)
end
def test_column_2
review =<<-EOS
===[column] test
inside column
=== next level
EOS
expected =<<-EOS.chomp
test
inside column
next level
EOS
assert_equal expected, column_helper(review)
end
def test_column_3
review =<<-EOS
===[column] test
inside column
===[/column_dummy]
EOS
assert_raise(ReVIEW::CompileError) do
column_helper(review)
end
end
def test_ul
src =<<-EOS
* AAA
* BBB
EOS
expected =<<-EOS.chomp
AAA
BBB
EOS
actual = compile_block(src)
assert_equal expected, actual
end
def test_ul_cont
src =<<-EOS
* AAA
-AA
* BBB
-BB
EOS
expected =<<-EOS.chomp
AAA-AA
BBB-BB
EOS
actual = compile_block(src)
assert_equal expected, actual
end
def test_ul_nest1
src =<<-EOS
* AAA
** AA
EOS
expected =<<-EOS.chomp
AAA
AA
EOS
actual = compile_block(src)
assert_equal expected, actual
end
def test_ul_nest2
src =<<-EOS
* AAA
** AA
* BBB
** BB
EOS
expected =<<-EOS.chomp
AAA
AA
BBB
BB
EOS
actual = compile_block(src)
assert_equal expected, actual
end
def test_ul_nest3
src =<<-EOS
** AAA
* AA
* BBB
** BB
EOS
expected =<<-EOS.chomp
AAA
AA
BBB
BB
EOS
actual = compile_block(src)
assert_equal expected, actual
end
def test_ul_nest4
src =<<-EOS
* A
** B
** C
*** D
** E
* F
** G
EOS
expected =<<-EOS.chomp
A
B
C
D
E
F
G
EOS
actual = compile_block(src)
assert_equal expected, actual
end
def test_ol
src =<<-EOS
3. AAA
3. BBB
EOS
expected =<<-EOS.chomp
AAA
BBB
EOS
actual = compile_block(src)
assert_equal expected, actual
end
def test_inline_raw0
assert_equal "normal", compile_inline("@{normal}")
end
def test_inline_raw1
assert_equal "body", compile_inline("@{|idgxml|body}")
end
def test_inline_raw2
assert_equal "body", compile_inline("@{|idgxml, latex|body}")
end
def test_inline_raw3
assert_equal "", compile_inline("@{|latex, html|body}")
end
def test_inline_raw4
assert_equal "|idgxml body", compile_inline("@{|idgxml body}")
end
def test_inline_raw5
assert_equal "nor\nmal", compile_inline("@{|idgxml|nor\\nmal}")
end
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 "@{sampleimg}\n"
expected = "
図1.1「sample photo」
"
assert_equal expected, actual
end
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 "@{sampleimg}\n"
expected = "
図1.1
"
assert_equal expected, actual
end
def test_block_raw0
actual = compile_block("//raw[<>!\"\\n& ]\n")
expected = %Q(<>!\"\n& )
assert_equal expected, actual
end
def test_block_raw1
actual = compile_block("//raw[|idgxml|<>!\"\\n& ]\n")
expected = %Q(<>!\"\n& )
assert_equal expected.chomp, actual
end
def test_block_raw2
actual = compile_block("//raw[|idgxml, latex|<>!\"\\n& ]\n")
expected = %Q(<>!\"\n& )
assert_equal expected.chomp, actual
end
def test_block_raw3
actual = compile_block("//raw[|latex, html|<>!\"\\n& ]\n")
expected = %Q()
assert_equal expected.chomp, actual
end
def test_block_raw4
actual = compile_block("//raw[|idgxml <>!\"\\n& ]\n")
expected = %Q(|idgxml <>!\"\n& )
assert_equal expected.chomp, actual
end
end