test/test_latexbuilder.rb in review-5.1.1 vs test/test_latexbuilder.rb in review-5.2.0

- old
+ new

@@ -18,10 +18,12 @@ 'review_version' => '4' ) @config['pdfmaker']['image_scale2width'] = nil @book = Book::Base.new @book.config = @config + @log_io = StringIO.new + ReVIEW.logger = ReVIEW::Logger.new(@log_io) @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') @@ -1370,11 +1372,11 @@ @builder.instance_eval { @logger = ReVIEW::Logger.new(io) } actual = compile_block("//indepimage[sample_img_nofile_][sample photo]\n") expected = <<-EOS \\begin{reviewdummyimage} ---[[path = sample\\textunderscore{}img\\textunderscore{}nofile\\textunderscore{} (not exist)]]-- +{-}{-}[[path = sample\\reviewbackslash{}textunderscore\\{\\}img\\reviewbackslash{}textunderscore\\{\\}nofile\\reviewbackslash{}textunderscore\\{\\} (not exist)]]{-}{-} \\reviewindepimagecaption{図: sample photo} \\end{reviewdummyimage} EOS assert_equal expected, actual assert_match(/WARN --: :1: image not bound: sample_img_nofile_/, io.string) @@ -1431,14 +1433,14 @@ 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 + assert_equal 'no rows in the table', e.message e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") } - assert_equal ':3: error: no rows in the table', e.message + assert_equal 'no rows in the table', e.message end def test_customize_cellwidth actual = compile_block("//tsize[2,3,5]\n//table{\nA\tB\tC\n//}\n") expected = <<-EOS @@ -2250,12 +2252,12 @@ //#{type}{ //} //} EOS - e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) } - assert_match(/minicolumn cannot be nested:/, e.message) + assert_raises(ReVIEW::ApplicationError) { compile_block(src) } + assert_match(/minicolumn cannot be nested:/, @log_io.string) end end def test_minicolumn_blocks_nest_error2 %w[note memo tip info warning important caution notice].each do |type| @@ -2267,12 +2269,12 @@ //} //} EOS - e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) } - assert_match(/minicolumn cannot be nested:/, e.message) + assert_raises(ReVIEW::ApplicationError) { compile_block(src) } + assert_match(/minicolumn cannot be nested:/, @log_io.string) end end def test_minicolumn_blocks_nest_error3 %w[memo tip info warning important caution notice].each do |type| @@ -2283,12 +2285,12 @@ //note{ //} //} EOS - e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) } - assert_match(/minicolumn cannot be nested:/, e.message) + assert_raises(ReVIEW::ApplicationError) { compile_block(src) } + assert_match(/minicolumn cannot be nested:/, @log_io.string) end end def test_inline_raw0 assert_equal 'normal', compile_inline('@<raw>{normal}') @@ -2425,23 +2427,29 @@ assert_match(/WARN --: :1: word not bound: N/, io.string) end end def test_inline_unknown - e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") } - assert_equal ':1: error: unknown image: n', e.message - e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") } - assert_equal ':1: error: unknown footnote: n', e.message - e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") } - assert_equal ':1: error: unknown headline: n', e.message + assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") } + assert_match(/unknown image: n/, @log_io.string) + + @log_io.string = '' + assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") } + assert_match(/unknown footnote: n/, @log_io.string) + + @log_io.string = '' + assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") } + assert_match(/unknown headline: n/, @log_io.string) %w[list table column].each do |name| - e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") } - assert_equal ":1: error: unknown #{name}: n", e.message + @log_io.string = '' + assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") } + assert_match(/unknown #{name}: n/, @log_io.string) end %w[chap chapref title].each do |name| - e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") } - assert_equal ':1: error: key not found: "n"', e.message + @log_io.string = '' + assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") } + assert_match(/key not found: "n"/, @log_io.string) end end def test_appendix_list @chapter.instance_eval do @@ -2586,11 +2594,11 @@ def test_nest_error_close1 src = <<-EOS //beginchild EOS e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) } - assert_equal ":1: error: //beginchild is shown, but previous element isn't ul, ol, or dl", e.message + assert_equal "//beginchild is shown, but previous element isn't ul, ol, or dl", e.message end def test_nest_error_close2 src = <<-EOS * foo @@ -2604,11 +2612,11 @@ : foo //beginchild EOS e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) } - assert_equal ':12: error: //beginchild of dl,ol,ul misses //endchild', e.message + assert_equal '//beginchild of dl,ol,ul misses //endchild', e.message end def test_nest_error_close3 src = <<-EOS * foo @@ -2624,10 +2632,10 @@ //beginchild //endchild EOS e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) } - assert_equal ':14: error: //beginchild of ol,ul misses //endchild', e.message + assert_equal '//beginchild of ol,ul misses //endchild', e.message end def test_nest_ul src = <<-EOS * UL1