test/test_topbuilder.rb in review-5.3.0 vs test/test_topbuilder.rb in review-5.4.0
- old
+ new
@@ -149,11 +149,12 @@
def test_inline_in_table
actual = compile_block("//table{\n★1☆\t▲2☆\n------------\n★3☆\t▲4☆<>&\n//}\n")
expected = <<-EOS
◆→開始:表←◆
-★★1☆☆\t★▲2☆☆
+★1☆\t▲2☆
+------------
★3☆\t▲4☆<>&
◆→終了:表←◆
EOS
assert_equal expected, actual
@@ -504,11 +505,12 @@
def test_table
actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
expected = <<-EOS
◆→開始:表←◆
-★aaa☆\t★bbb☆
+aaa\tbbb
+------------
ccc\tddd<>&
◆→終了:表←◆
EOS
assert_equal expected, actual
@@ -516,31 +518,56 @@
actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
expected = <<-EOS
◆→開始:表←◆
表1.1 FOO
-★aaa☆\t★bbb☆
+aaa\tbbb
+------------
ccc\tddd<>&
◆→終了:表←◆
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
◆→開始:表←◆
-★aaa☆\t★bbb☆
+aaa\tbbb
+------------
ccc\tddd<>&
表1.1 FOO
◆→終了:表←◆
EOS
assert_equal expected, actual
end
+ def test_table_th_bold
+ @config['textmaker']['th_bold'] = true
+ actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
+ expected = <<-EOS
+◆→開始:表←◆
+★aaa☆\t★bbb☆
+ccc\tddd<>&
+◆→終了:表←◆
+
+EOS
+ assert_equal expected, actual
+
+ actual = compile_block("//table{\naaa\tbbb\nccc\tddd<>&\n//}\n")
+ expected = <<-EOS
+◆→開始:表←◆
+★aaa☆\tbbb
+★ccc☆\tddd<>&
+◆→終了:表←◆
+
+EOS
+ assert_equal expected, actual
+ end
+
def test_empty_table
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
assert_equal 'no rows in the table', e.message
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
@@ -559,10 +586,32 @@
actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
expected = <<-EOS
◆→開始:表←◆
foo
+aaa\tbbb
+------------
+ccc\tddd<>&
+◆→終了:表←◆
+
+◆→開始:表←◆
+aaa\tbbb
+------------
+ccc\tddd<>&
+◆→終了:表←◆
+
+EOS
+ assert_equal expected, actual
+ end
+
+ def test_emtable_thbold
+ @config['textmaker']['th_bold'] = true
+ actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
+ expected = <<-EOS
+◆→開始:表←◆
+foo
+
★aaa☆\t★bbb☆
ccc\tddd<>&
◆→終了:表←◆
◆→開始:表←◆
@@ -572,15 +621,47 @@
EOS
assert_equal expected, actual
end
+ def test_imgtable
+ def @chapter.image(_id)
+ item = Book::Index::Item.new('sampleimg', 1)
+ item.instance_eval { @path = './images/chap1-sampleimg.png' }
+ item
+ end
+
+ actual = compile_block("//imgtable[sampleimg][sample photo]{\nfoo\n//}\n")
+ expected = <<-EOS
+◆→開始:表←◆
+表1.1 sample photo
+
+◆→./images/chap1-sampleimg.png←◆
+◆→終了:表←◆
+
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['table'] = 'bottom'
+ actual = compile_block("//imgtable[sampleimg][sample photo]{\nfoo\n//}\n")
+ expected = <<-EOS
+◆→開始:表←◆
+◆→./images/chap1-sampleimg.png←◆
+
+表1.1 sample photo
+◆→終了:表←◆
+
+EOS
+ assert_equal expected, actual
+ end
+
def test_table_row_separator
src = "//table{\n1\t2\t\t3 4| 5\n------------\na b\tc d |e\n//}\n"
expected = <<-EOS
◆→開始:表←◆
-★1☆ ★2☆ ★3 4| 5☆
+1 2 3 4| 5
+------------
a b c d |e
◆→終了:表←◆
EOS
actual = compile_block(src)
@@ -588,33 +669,36 @@
@config['table_row_separator'] = 'singletab'
actual = compile_block(src)
expected = <<-EOS
◆→開始:表←◆
-★1☆ ★2☆ ★☆ ★3 4| 5☆
+1 2 3 4| 5
+------------
a b c d |e
◆→終了:表←◆
EOS
assert_equal expected, actual
@config['table_row_separator'] = 'spaces'
actual = compile_block(src)
expected = <<-EOS
◆→開始:表←◆
-★1☆ ★2☆ ★3☆ ★4|☆ ★5☆
+1 2 3 4| 5
+------------
a b c d |e
◆→終了:表←◆
EOS
assert_equal expected, actual
@config['table_row_separator'] = 'verticalbar'
actual = compile_block(src)
expected = <<-EOS
◆→開始:表←◆
-★1 2 3 4☆ ★5☆
+1 2 3 4 5
+------------
a b c d e
◆→終了:表←◆
EOS
assert_equal expected, actual
@@ -967,10 +1051,67 @@
EOS
assert_equal expected, actual
end
+ def test_image_dummy
+ actual = compile_block("//image[dummy][sample photo]{\nDUMMY\n//}\n")
+ expected = <<-EOS
+◆→開始:図←◆
+DUMMY
+
+図1.1 sample photo
+◆→終了:図←◆
+
+EOS
+ assert_equal expected, actual
+ end
+
+ def test_indepimage
+ def @chapter.image(_id)
+ item = Book::Index::Item.new('sampleimg', 1)
+ item.instance_eval { @path = './images/chap1-sampleimg.png' }
+ item
+ end
+
+ actual = compile_block("//indepimage[sampleimg][sample photo]{\nfoo\n//}\n")
+ expected = <<-EOS
+◆→開始:図←◆
+◆→./images/chap1-sampleimg.png←◆
+
+図 sample photo
+◆→終了:図←◆
+
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['image'] = 'top'
+ actual = compile_block("//indepimage[sampleimg][sample photo]{\nfoo\n//}\n")
+ expected = <<-EOS
+◆→開始:図←◆
+図 sample photo
+
+◆→./images/chap1-sampleimg.png←◆
+◆→終了:図←◆
+
+EOS
+ assert_equal expected, actual
+ end
+
+ def test_indepimage_dummy
+ actual = compile_block("//indepimage[dummy][sample photo]{\nDUMMY\n//}\n")
+ expected = <<-EOS
+◆→開始:図←◆
+DUMMY
+
+図 sample photo
+◆→終了:図←◆
+
+EOS
+ assert_equal expected, actual
+ end
+
def test_texequation
actual = compile_block("//texequation{\n\\sin\n1^{2}\n//}\n")
expected = <<-EOS
◆→開始:TeX式←◆
\\sin
@@ -981,15 +1122,14 @@
assert_equal expected, actual
end
def test_inline_w
Dir.mktmpdir do |dir|
- File.open(File.join(dir, 'words.csv'), 'w') do |f|
- f.write <<EOB
+ File.write(File.join(dir, 'words.csv'), <<EOB
"F","foo"
"B","bar""\\<>_@<b>{BAZ}"
EOB
- end
+ )
@book.config['words_file'] = File.join(dir, 'words.csv')
io = StringIO.new
@builder.instance_eval { @logger = ReVIEW::Logger.new(io) }
actual = compile_block('@<w>{F} @<w>{B} @<wb>{B} @<w>{N}')