Skip to content

Commit

Permalink
Merge pull request #1554 from kmuto/fix-test-all
Browse files Browse the repository at this point in the history
fix tests
  • Loading branch information
takahashim authored Aug 19, 2020
2 parents 9e0628a + a79d58b commit bfd9346
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 49 deletions.
115 changes: 70 additions & 45 deletions test/test_book_chapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
class ChapterTest < Test::Unit::TestCase
include BookTestHelper

def setup
I18n.setup
end

def test_initialize
ch = Book::Chapter.new(:book, :number, :name, '/foo/bar', :io)
assert_equal :book, ch.book
Expand Down Expand Up @@ -144,48 +148,56 @@ def test_invalid_encoding

def test_list_index
do_test_index(<<E, Book::ListIndex, :list_index, :list)
//list
//listnum [abc]
//list [def]
//table [def]
//table [others]
//listnum[abc][abc-listnum]{
//}
//list[def][def-list]{
//}
//table[def]{
//}
//table[others]{
//}
E
end

def test_table_index
do_test_index(<<E, Book::TableIndex, :table_index, :table)
//table
//table [abc]
//table [def]
//list [def]
//list [others]
//table[abc]{
//}
//table[def]{
//}
//list[def][def-list]{
//}
//list[others][other-list]{
//}
E
end

def test_footnote_index
content = <<E
//footnote
//footnote [abc][text...]
//footnote [def][text...]
//footnote [xyz]
//list [def]
//list [others]
//footnote[abc][textabc...]
//footnote[def][textdef...]
//footnote[xyz][textxyz...]
//list[def][def-list]{
//}
//list[others][others-list]{
//}
E
do_test_index(content, Book::FootnoteIndex, :footnote_index, :footnote) do |ch|
assert_raises ReVIEW::KeyError do
ch.footnote('xyz')
ch.footnote('xyz2')
end
end
end

def test_bibpaper
do_test_index(<<E, Book::BibpaperIndex, :bibpaper_index, :bibpaper, filename: 'bib.re')
//bibpaper
//bibpaper [abc][text...]
//bibpaper [def][text...]
//bibpaper [xyz]
//list [def]
//list [others]
//bibpaper[abc][text...]
//bibpaper[def][text...]
//bibpaper[xyz][text...]
//list[def][def-list]{
//}
//list[others][others-list]{
//}
E
assert_raises FileNotFound do
do_test_index('', Book::BibpaperIndex, :bibpaper_index, :bibpaper, filename: 'bib')
Expand All @@ -194,11 +206,12 @@ def test_bibpaper

def test_headline_index
do_test_index(<<E, Book::HeadlineIndex, :headline_index, :headline, propagate: false)
==
== x
== abc
== def
=== def
//table others
//table[others]{
//}
E
end

Expand All @@ -222,35 +235,47 @@ def test_column_index

def test_image
do_test_index(<<E, Book::ImageIndex, :image_index, :image)
//image
//image [abc]
//image [def]
//list [def]
//list [others]
//image[abc][abc-image]{
//}
//image[def][abc-image]{
//}
//list[def][def-list]{
//}
//list[others][others-list]{
//}
E

do_test_index(<<E, Book::NumberlessImageIndex, :numberless_image_index, :image, propagate: false)
//numberlessimage
//numberlessimage [abc]
//numberlessimage [def]
//list [def]
//list [others]
//numberlessimage[abc]{
//}
//numberlessimage[def]{
//}
//list[def][def-list]{
//}
//list[others][others-list]{
//}
E

do_test_index(<<E, Book::ImageIndex, :image_index, :image)
//image
//numberlessimage [abc]
//image [def]
//list [def]
//list [others]
//numberlessimage[abc]{
//}
//image[def][def-image]{
//}
//list[def][def-list]{
//}
//list[others][others-list]{
//}
E

do_test_index(<<E, Book::NumberlessImageIndex, :numberless_image_index, :image, propagate: false)
//image
//numberlessimage [abc]
//image [def]
//list [def]
//list [others]
//numberlessimage[abc]{
//}
//image[def][def-image]{
//}
//list[def][def-list]{
//}
//list[others][others-list]{
//}
E
end

Expand Down
1 change: 1 addition & 0 deletions test/test_converter.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'test_helper'
require 'book_test_helper'
require 'review/converter'
require 'review/latexbuilder'

class ConverterTest < Test::Unit::TestCase
include BookTestHelper
Expand Down
1 change: 1 addition & 0 deletions test/test_epubmaker.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'test_helper'
require 'epubmaker'
require 'review/epubmaker'

class EPUBMakerTest < Test::Unit::TestCase
include EPUBMaker
Expand Down
8 changes: 4 additions & 4 deletions test/test_htmlbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -922,11 +922,11 @@ def test_inline_list_href
book = ReVIEW::Book::Base.load
book.config['chapterlink'] = true
book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re ch2.re])
io1 = StringIO.new("//list[sampletest]{\nfoo\n//}\n")
io1 = StringIO.new("//list[sampletest][a]{\nfoo\n//}\n")
io2 = StringIO.new("= BAR\n")
chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
chap2 = ReVIEW::Book::Chapter.new(book, 2, 'ch2', 'ch2.re', io2)
book.parts = [ReVIEW::Book::Part.new(self, nil, [chap1, chap2])]
book.parts = [ReVIEW::Book::Part.new(book, nil, [chap1, chap2])]
builder = ReVIEW::HTMLBuilder.new
comp = ReVIEW::Compiler.new(builder)
builder.bind(comp, chap2, nil)
Expand Down Expand Up @@ -2224,7 +2224,7 @@ def test_inline_hd
io2 = StringIO.new("= test2\n\nfoo\n\n== test2-1\n\nbar\n\n== test2-2\n\nbar\n\n")
chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
chap2 = ReVIEW::Book::Chapter.new(book, 2, 'ch2', 'ch2.re', io2)
book.parts = [ReVIEW::Book::Part.new(self, nil, [chap1, chap2])]
book.parts = [ReVIEW::Book::Part.new(book, nil, [chap1, chap2])]
builder = ReVIEW::HTMLBuilder.new
comp = ReVIEW::Compiler.new(builder)
builder.bind(comp, chap2, nil)
Expand All @@ -2247,7 +2247,7 @@ def test_inline_hd_for_part
io_p1 = StringIO.new("= part1\n\nfoo\n\n== part1-1\n\nbar\n\n== part1-2\n\nbar\n\n")
chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
chap2 = ReVIEW::Book::Chapter.new(book, 2, 'ch2', 'ch2.re', io2)
book.parts = [ReVIEW::Book::Part.new(self, 1, [chap1, chap2], 'part1.re', io_p1)]
book.parts = [ReVIEW::Book::Part.new(book, 1, [chap1, chap2], 'part1.re', io_p1)]
builder = ReVIEW::HTMLBuilder.new
comp = ReVIEW::Compiler.new(builder)
builder.bind(comp, chap2, nil)
Expand Down
1 change: 1 addition & 0 deletions test/test_markdownbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def setup
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
location = Location.new(nil, nil)
@builder.bind(@compiler, @chapter, location)
I18n.setup(@config['language'])
end

def test_quote
Expand Down

0 comments on commit bfd9346

Please sign in to comment.