test/test_latexbuilder.rb in review-1.4.0 vs test/test_latexbuilder.rb in review-1.5.0
- old
+ new
@@ -22,10 +22,11 @@
@book.config = @config
@compiler = ReVIEW::Compiler.new(@builder)
@chapter = Book::Chapter.new(@book, 1, 'chap1', nil, StringIO.new)
location = Location.new(nil, nil)
@builder.bind(@compiler, @chapter, location)
+ I18n.setup("ja")
end
def test_headline_level1
actual = compile_block("={test} this is test.\n")
assert_equal %Q|\\chapter{this is test.}\n\\label{chap:chap1}\n|, actual
@@ -232,15 +233,29 @@
def test_cmd_caption
actual = compile_block("//cmd[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal %Q|\n\\reviewcmdcaption{cap1}\n\\begin{reviewcmd}\nfoo\nbar\n\nbuz\n\\end{reviewcmd}\n|, actual
end
+ def test_cmd_lst
+ @book.config["highlight"] = {}
+ @book.config["highlight"]["latex"] = "listings"
+ actual = compile_block("//cmd{\nfoo\nbar\n\nbuz\n//}\n")
+ assert_equal %Q|\\vspace{-1.5em}\\begin{reviewcmdlst}[title={\\relax},language={}]\nfoo\nbar\n\nbuz\n\\end{reviewcmdlst}\n|, actual
+ end
+
def test_emlist
actual = compile_block("//emlist{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal %Q|\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n|, actual
end
+ def test_emlist_lst
+ @book.config["highlight"] = {}
+ @book.config["highlight"]["latex"] = "listings"
+ actual = compile_block("//emlist[][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
+ assert_equal %Q|\n\\vspace{-1.5em}\\begin{reviewemlistlst}[title={\\relax},language={sql}]\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n\\end{reviewemlistlst}\n|, actual
+ end
+
def test_emlist_caption
actual = compile_block("//emlist[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal %Q|\n\\reviewemlistcaption{cap1}\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n|, actual
end
@@ -253,10 +268,22 @@
@config["tabwidth"] = 4
actual = compile_block("//emlist{\n\tfoo\n\t\tbar\n\n\tbuz\n//}\n")
assert_equal %Q|\n\\begin{reviewemlist}\n foo\n bar\n\n buz\n\\end{reviewemlist}\n|, actual
end
+ def test_listnum
+ actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
+ assert_equal %Q|\\reviewlistcaption{リスト1.1: ruby}\n\\reviewlistcaption{ruby}\n\\begin{reviewlist}\n 1: class Foo\n 2: def foo\n 3: bar\n 4: \n 5: buz\n 6: end\n 7: end\n\\end{reviewlist}\n|, actual
+ end
+
+ def test_listnum_lst
+ @book.config["highlight"] = {}
+ @book.config["highlight"]["latex"] = "listings"
+ actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
+ assert_equal %Q|\\begin{reviewlistnumlst}[caption={ruby},language={}]\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n\\end{reviewlistnumlst}\n|, actual
+ end
+
def test_quote
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal %Q|\n\\begin{quote}\nfoobar\n\nbuz\n\\end{quote}\n|, actual
end
@@ -633,9 +660,33 @@
end
def test_inline_endash
actual = compile_inline("- -- --- ----")
assert_equal "{-} {-}{-} {-}{-}{-} {-}{-}{-}{-}", actual
+ 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 "@<imgref>{sampleimg}\n"
+ expected = "\n\\reviewimageref{1.1}{image:chap1:sampleimg}「sample photo」\n"
+ 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 "@<imgref>{sampleimg}\n"
+ expected = "\n\\reviewimageref{1.1}{image:chap1:sampleimg}\n"
+ assert_equal expected, actual
end
def test_block_raw0
actual = compile_block("//raw[<>!\"\\n& ]\n")
expected = %Q(<>!\"\n& )