test/test_builder.rb in review-4.2.0 vs test/test_builder.rb in review-5.0.0

- old
+ new

@@ -22,11 +22,11 @@ assert Builder.new end def test_bind b = Builder.new - chap = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.load, nil, '-', nil) + chap = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.new, nil, '-', nil) assert_nothing_raised do b.bind(nil, chap, nil) end end @@ -35,11 +35,11 @@ assert_raises(NoMethodError) do # XXX: OK? b.result end b = Builder.new - chapter = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.load, nil, '-', nil) + chapter = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.new, nil, '-', nil) b.bind(nil, chapter, nil) assert_equal '', b.result end def test_print_and_puts @@ -80,11 +80,11 @@ assert_equal [:text, text], @b.compile_inline(text) end def test_inline_missing_ref b = Builder.new - chapter = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.load, 1, 'chap1', nil, StringIO.new) + chapter = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.new, 1, 'chap1', nil, StringIO.new) b.bind(nil, chapter, nil) e = assert_raises(ReVIEW::ApplicationError) { b.inline_list('unknown|list1') } assert_equal ': error: unknown list: unknown|list1', e.message e = assert_raises(ReVIEW::ApplicationError) { b.inline_table('unknown|table1') } assert_equal ': error: unknown table: unknown|table1', e.message @@ -94,22 +94,31 @@ assert_equal ': error: unknown column: unknown|column1', e.message e = assert_raises(ReVIEW::ApplicationError) { b.inline_fn('unknown|footnote1') } assert_equal ': error: unknown footnote: unknown|footnote1', e.message end - class XBuilder < Builder - def list_header(id, caption) - end + def test_nest_error + b = XBuilder.new + b.children = nil + assert_equal '', b.solve_nest('') + b.children = ['dl'] + e = assert_raises(ReVIEW::ApplicationError) { b.solve_nest('') } + assert_equal ': error: //beginchild of dl misses //endchild', e.message + b.children = ['ul', 'dl', 'ol'] + e = assert_raises(ReVIEW::ApplicationError) { b.solve_nest('') } + assert_equal ': error: //beginchild of ol,dl,ul misses //endchild', e.message - def list_body(lines) - end + assert_equal "\u0001→/ol←\u0001", b.endchild + assert_equal "\u0001→/dl←\u0001", b.endchild + assert_equal "\u0001→/ul←\u0001", b.endchild + e = assert_raises(ReVIEW::ApplicationError) { b.endchild } + assert_equal ": error: //endchild is shown, but any opened //beginchild doesn't exist", e.message + end - def listnum_body(lines) - end + class XBuilder < Builder + attr_accessor :children - def source_header(caption) - end - - def source_body(lines) + def puts(s) + s end end end