test/test_latexbuilder.rb in review-4.1.0 vs test/test_latexbuilder.rb in review-4.2.0
- old
+ new
@@ -432,10 +432,26 @@
buz
\\end{reviewcmd}
\\end{reviewlistblock}
EOS
assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//cmd[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
+ expected = <<-EOS
+
+\\begin{reviewlistblock}
+\\begin{reviewcmd}
+foo
+bar
+
+buz
+\\end{reviewcmd}
+\\reviewcmdcaption{cap1}
+\\end{reviewlistblock}
+EOS
+ assert_equal expected, actual
end
def test_cmd_lst
@book.config['highlight'] = {}
@book.config['highlight']['latex'] = 'listings'
@@ -507,10 +523,26 @@
buz
\\end{reviewemlist}
\\end{reviewlistblock}
EOS
assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//emlist[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
+ expected = <<-EOS
+
+\\begin{reviewlistblock}
+\\begin{reviewemlist}
+foo
+bar
+
+buz
+\\end{reviewemlist}
+\\reviewemlistcaption{cap1}
+\\end{reviewlistblock}
+EOS
+ assert_equal expected, actual
end
def test_emlist_empty_caption
actual = compile_block("//emlist[]{\nfoo\nbar\n\nbuz\n//}\n")
expected = <<-EOS
@@ -573,10 +605,26 @@
4: buz
\\end{reviewemlist}
\\end{reviewlistblock}
EOS
assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//emlistnum[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
+ expected = <<-EOS
+
+\\begin{reviewlistblock}
+\\begin{reviewemlist}
+ 1: foo
+ 2: bar
+ 3:
+ 4: buz
+\\end{reviewemlist}
+\\reviewemlistcaption{cap1}
+\\end{reviewlistblock}
+EOS
+ assert_equal expected, actual
end
def test_list
actual = compile_block("//list[id1][cap1]{\nfoo\nbar\n\nbuz\n//}\n")
expected = <<-EOS
@@ -589,10 +637,25 @@
buz
\\end{reviewlist}
\\end{reviewlistblock}
EOS
assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//list[id1][cap1]{\nfoo\nbar\n\nbuz\n//}\n")
+ expected = <<-EOS
+\\begin{reviewlistblock}
+\\begin{reviewlist}
+foo
+bar
+
+buz
+\\end{reviewlist}
+\\reviewlistcaption{リスト1.1: cap1}
+\\end{reviewlistblock}
+EOS
+ assert_equal expected, actual
end
def test_list_lst
@book.config['highlight'] = {}
@book.config['highlight']['latex'] = 'listings'
@@ -601,10 +664,20 @@
\\begin{reviewlistlst}[caption={cap1},language={sql}]
SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
\\end{reviewlistlst}
EOS
assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ # XXX: caption_position won't work with highlight
+ actual = compile_block("//list[id1][cap1][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
+ expected = <<-EOS
+\\begin{reviewlistlst}[caption={cap1},language={sql}]
+SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
+\\end{reviewlistlst}
+EOS
+ assert_equal expected, actual
end
def test_list_lst_with_lang
@book.config['highlight'] = {}
@book.config['highlight']['latex'] = 'listings'
@@ -633,10 +706,28 @@
7: end
\\end{reviewlist}
\\end{reviewlistblock}
EOS
assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
+ expected = <<-EOS
+\\begin{reviewlistblock}
+\\begin{reviewlist}
+ 1: class Foo
+ 2: def foo
+ 3: bar
+ 4:
+ 5: buz
+ 6: end
+ 7: end
+\\end{reviewlist}
+\\reviewlistcaption{リスト1.1: ruby}
+\\end{reviewlistblock}
+EOS
+ assert_equal expected, actual
end
def test_listnum_linenum
actual = compile_block("//firstlinenum[100]\n//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
expected = <<-EOS
@@ -670,11 +761,27 @@
end
end
\\end{reviewlistnumlst}
EOS
assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ # XXX: caption_position won't work with highlight
+ actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
+ expected = <<-EOS
+\\begin{reviewlistnumlst}[caption={ruby},language={}]
+class Foo
+ def foo
+ bar
+
+ buz
end
+end
+\\end{reviewlistnumlst}
+EOS
+ assert_equal expected, actual
+ end
def test_listnum_lst_linenum
@book.config['highlight'] = {}
@book.config['highlight']['latex'] = 'listings'
actual = compile_block("//firstlinenum[100]\n//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
@@ -704,10 +811,25 @@
buz
\\end{reviewsource}
\\end{reviewlistblock}
EOS
assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
+ expected = <<-EOS
+\\begin{reviewlistblock}
+\\begin{reviewsource}
+foo
+bar
+
+buz
+\\end{reviewsource}
+\\reviewsourcecaption{foo/bar/test.rb}
+\\end{reviewlistblock}
+EOS
+ assert_equal expected, actual
end
def test_source_empty_caption
actual = compile_block("//source[]{\nfoo\nbar\n\nbuz\n//}\n")
expected = <<-EOS
@@ -734,10 +856,23 @@
buz
\\end{reviewsourcelst}
EOS
assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ # XXX: caption_position won't work with highlight
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
+ expected = <<-EOS
+\\begin{reviewsourcelst}[title={foo/bar/test.rb},language={}]
+foo
+bar
+
+buz
+\\end{reviewsourcelst}
+EOS
+ assert_equal expected, actual
end
def test_quote
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
expected = <<-EOS
@@ -886,10 +1021,22 @@
EOS
assert_equal expected, actual
actual = compile_block("//image[sampleimg][sample photo][]{\n//}\n")
assert_equal expected, actual
+
+ @book.config['pdfmaker']['use_original_image_size'] = nil
+ @config['caption_position']['image'] = 'top'
+ actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
+ expected = <<-EOS
+\\begin{reviewimage}%%sampleimg
+\\reviewimagecaption{sample photo}
+\\label{image:chap1:sampleimg}
+\\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
+\\end{reviewimage}
+EOS
+ assert_equal expected, actual
end
def test_image_with_metric
def @chapter.image(_id)
item = Book::Index::Item.new('sampleimg', 1)
@@ -1006,10 +1153,21 @@
EOS
assert_equal expected, actual
actual = compile_block("//indepimage[sampleimg][sample photo][]\n")
assert_equal expected, actual
+
+ @book.config['pdfmaker']['use_original_image_size'] = nil
+ @config['caption_position']['image'] = 'top'
+ actual = compile_block("//indepimage[sampleimg][sample photo]\n")
+ expected = <<-EOS
+\\begin{reviewimage}%%sampleimg
+\\reviewindepimagecaption{図: sample photo}
+\\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
+\\end{reviewimage}
+EOS
+ assert_equal expected, actual
end
def test_indepimage_without_caption
def @chapter.image(_id)
item = Book::Index::Item.new('sampleimg', 1)
@@ -1134,10 +1292,25 @@
ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
\\end{reviewtable}
\\end{table}
EOS
assert_equal expected, actual
+
+ @config['caption_position']['table'] = 'bottom'
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
+ expected = <<-EOS
+\\begin{table}%%foo
+\\begin{reviewtable}{|l|l|}
+\\hline
+\\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
+ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
+\\end{reviewtable}
+\\reviewtablecaption{FOO}
+\\label{table:chap1:foo}
+\\end{table}
+EOS
+ assert_equal expected, actual
end
def test_empty_table
e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n//}\n" }
assert_equal ':2: error: no rows in the table', e.message
@@ -1245,10 +1418,30 @@
\\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
\\end{reviewtable}
EOS
assert_equal expected, actual
+
+ @config['caption_position']['table'] = 'bottom'
+ actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
+ expected = <<-EOS
+\\begin{table}%%
+\\begin{reviewtable}{|l|l|}
+\\hline
+\\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
+ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
+\\end{reviewtable}
+\\reviewtablecaption*{foo}
+\\end{table}
+
+\\begin{reviewtable}{|l|l|}
+\\hline
+\\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
+ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
+\\end{reviewtable}
+EOS
+ assert_equal expected, actual
end
def test_imgtable
def @chapter.image(_id)
item = Book::Index::Item.new('sampleimg', 1, 'sample img')
@@ -1283,10 +1476,25 @@
EOS
assert_equal expected, actual
actual = compile_block("//imgtable[sampleimg][test for imgtable][]{\n//}\n")
assert_equal expected, actual
+
+ @book.config['pdfmaker']['use_original_image_size'] = nil
+ @config['caption_position']['table'] = 'bottom'
+ actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
+
+ expected = <<-EOS
+\\begin{table}[h]%%sampleimg
+\\label{table:chap1:sampleimg}
+\\begin{reviewimage}%%sampleimg
+\\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
+\\end{reviewimage}
+\\reviewimgtablecaption{test for imgtable}
+\\end{table}
+EOS
+ assert_equal expected, actual
end
def test_imgtable_with_metrics
def @chapter.image(_id)
item = Book::Index::Item.new('sampleimg', 1, 'sample img')
@@ -2036,9 +2244,24 @@
\\begin{reviewequationblock}
\\reviewequationcaption{式1.1: The Equivalence of Mass \\reviewit{and} Energy}
\\begin{equation*}
e=mc^2
\\end{equation*}
+\\end{reviewequationblock}
+EOS
+ actual = compile_block(src)
+ assert_equal expected, actual
+
+ @config['caption_position']['equation'] = 'bottom'
+ expected = <<-EOS
+
+\\reviewequationref{1.1}
+
+\\begin{reviewequationblock}
+\\begin{equation*}
+e=mc^2
+\\end{equation*}
+\\reviewequationcaption{式1.1: The Equivalence of Mass \\reviewit{and} Energy}
\\end{reviewequationblock}
EOS
actual = compile_block(src)
assert_equal expected, actual
end