[ruby/rdoc] Update tests for ruby/rdoc#1247
(https://github.com/ruby/rdoc/pull/1248) https://github.com/ruby/rdoc/commit/94b9858000
This commit is contained in:
parent
408f536890
commit
1254850a61
@ -103,13 +103,13 @@ class RDoc::Markup::TextFormatterTestCase < RDoc::Markup::FormatterTestCase
|
|||||||
# Test case that calls <tt>@to.accept_table</tt>
|
# Test case that calls <tt>@to.accept_table</tt>
|
||||||
|
|
||||||
def test_accept_table_align
|
def test_accept_table_align
|
||||||
header = ['AA', 'BB', 'CCCCC']
|
header = ['AA', 'BB', 'CCCCC', 'DDDDD']
|
||||||
body = [
|
body = [
|
||||||
['', 'bbb', 'c'],
|
['', 'bbb', 'c', ''],
|
||||||
['aaaa', 'b', ''],
|
['aaaa', 'b', '', 'dd'],
|
||||||
['a', '', 'cc']
|
['a', '', 'cc', 'dd']
|
||||||
]
|
]
|
||||||
aligns = [nil, :left, :right]
|
aligns = [nil, :left, :right, :center]
|
||||||
@to.start_accepting
|
@to.start_accepting
|
||||||
@to.accept_table header, body, aligns
|
@to.accept_table header, body, aligns
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
require_relative 'helper'
|
require_relative 'helper'
|
||||||
|
|
||||||
class TestRDocMarkupToAnsi < RDoc::Markup::TextFormatterTestCase
|
class RDocMarkupToAnsiTest < RDoc::Markup::TextFormatterTestCase
|
||||||
|
|
||||||
add_visitor_tests
|
add_visitor_tests
|
||||||
add_text_tests
|
add_text_tests
|
||||||
@ -350,11 +350,11 @@ words words words words
|
|||||||
|
|
||||||
def accept_table_align
|
def accept_table_align
|
||||||
expected = "\e[0m" + <<-EXPECTED
|
expected = "\e[0m" + <<-EXPECTED
|
||||||
AA |BB |CCCCC
|
AA |BB |CCCCC|DDDDD
|
||||||
----|---|-----
|
----|---|-----|-----
|
||||||
|bbb| c
|
|bbb| c|
|
||||||
aaaa|b |
|
aaaa|b | | dd
|
||||||
a | | cc
|
a | | cc| dd
|
||||||
EXPECTED
|
EXPECTED
|
||||||
assert_equal expected, @to.end_accepting
|
assert_equal expected, @to.end_accepting
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
require_relative 'helper'
|
require_relative 'helper'
|
||||||
|
|
||||||
class TestRDocMarkupToBs < RDoc::Markup::TextFormatterTestCase
|
class RDocMarkupToBsTest < RDoc::Markup::TextFormatterTestCase
|
||||||
|
|
||||||
add_visitor_tests
|
add_visitor_tests
|
||||||
add_text_tests
|
add_text_tests
|
||||||
@ -351,11 +351,11 @@ words words words words
|
|||||||
|
|
||||||
def accept_table_align
|
def accept_table_align
|
||||||
expected = <<-EXPECTED
|
expected = <<-EXPECTED
|
||||||
AA |BB |CCCCC
|
AA |BB |CCCCC|DDDDD
|
||||||
----|---|-----
|
----|---|-----|-----
|
||||||
|bbb| c
|
|bbb| c|
|
||||||
aaaa|b |
|
aaaa|b | | dd
|
||||||
a | | cc
|
a | | cc| dd
|
||||||
EXPECTED
|
EXPECTED
|
||||||
assert_equal expected, @to.end_accepting
|
assert_equal expected, @to.end_accepting
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
require_relative 'helper'
|
require_relative 'helper'
|
||||||
|
|
||||||
class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
|
class RDocMarkupToHtmlTest < RDoc::Markup::FormatterTestCase
|
||||||
|
|
||||||
add_visitor_tests
|
add_visitor_tests
|
||||||
|
|
||||||
@ -956,31 +956,34 @@ EXPECTED
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_accept_table
|
def test_accept_table
|
||||||
header = %w[Col1 Col2 Col3]
|
header = %w[Col1 Col2 Col3 Col4]
|
||||||
body = [
|
body = [
|
||||||
%w[cell1_1 cell1_2 cell1_3],
|
%w[cell1_1 cell1_2 cell1_3 cell1_4],
|
||||||
%w[cell2_1 cell2_2 cell2_3],
|
%w[cell2_1 cell2_2 cell2_3 cell2_4],
|
||||||
['<script>alert("foo");</script>',],
|
['<script>alert("foo");</script>'],
|
||||||
%w[+code+ _em_ **strong**],
|
%w[+code+ _em_ **strong** C1],
|
||||||
]
|
]
|
||||||
aligns = [:left, :right, nil]
|
aligns = [:left, :right, nil, :center]
|
||||||
@to.start_accepting
|
@to.start_accepting
|
||||||
@to.accept_table(header, body, aligns)
|
@to.accept_table(header, body, aligns)
|
||||||
res = @to.end_accepting
|
res = @to.end_accepting
|
||||||
assert_include(res[%r<<th[^<>]*>Col1</th>>], 'align="left"')
|
assert_include(res[%r<<th[^<>]*>Col1</th>>], 'align="left"')
|
||||||
assert_include(res[%r<<th[^<>]*>Col2</th>>], 'align="right"')
|
assert_include(res[%r<<th[^<>]*>Col2</th>>], 'align="right"')
|
||||||
assert_not_include(res[%r<<th[^<>]*>Col3</th>>], 'align=')
|
assert_not_include(res[%r<<th[^<>]*>Col3</th>>], 'align=')
|
||||||
|
assert_include(res[%r<<th[^<>]*>Col4</th>>], 'align="center"')
|
||||||
assert_include(res[%r<<td[^<>]*>cell1_1</td>>], 'align="left"')
|
assert_include(res[%r<<td[^<>]*>cell1_1</td>>], 'align="left"')
|
||||||
assert_include(res[%r<<td[^<>]*>cell1_2</td>>], 'align="right"')
|
assert_include(res[%r<<td[^<>]*>cell1_2</td>>], 'align="right"')
|
||||||
assert_not_include(res[%r<<td[^<>]*>cell1_3</td>>], 'align=')
|
assert_not_include(res[%r<<td[^<>]*>cell1_3</td>>], 'align=')
|
||||||
assert_include(res[%r<<td[^<>]*>cell2_1</td>>], 'align="left"')
|
assert_include(res[%r<<td[^<>]*>cell2_1</td>>], 'align="left"')
|
||||||
assert_include(res[%r<<td[^<>]*>cell2_2</td>>], 'align="right"')
|
assert_include(res[%r<<td[^<>]*>cell2_2</td>>], 'align="right"')
|
||||||
assert_not_include(res[%r<<td[^<>]*>cell2_3</td>>], 'align=')
|
assert_not_include(res[%r<<td[^<>]*>cell2_3</td>>], 'align=')
|
||||||
|
assert_include(res[%r<<td[^<>]*>cell2_4</td>>], 'align="center"')
|
||||||
assert_not_include(res, '<script>')
|
assert_not_include(res, '<script>')
|
||||||
assert_include(res[%r<<td[^<>]*>.*script.*</td>>], '<script>')
|
assert_include(res[%r<<td[^<>]*>.*script.*</td>>], '<script>')
|
||||||
assert_include(res[%r<<td[^<>]*>.*code.*</td>>], '<code>code</code>')
|
assert_include(res[%r<<td[^<>]*>.*code.*</td>>], '<code>code</code>')
|
||||||
assert_include(res[%r<<td[^<>]*>.*em.*</td>>], '<em>em</em>')
|
assert_include(res[%r<<td[^<>]*>.*em.*</td>>], '<em>em</em>')
|
||||||
assert_include(res[%r<<td[^<>]*>.*strong.*</td>>], '<strong>strong</strong>')
|
assert_include(res[%r<<td[^<>]*>.*strong.*</td>>], '<strong>strong</strong>')
|
||||||
|
assert_include(res[%r<<td[^<>]*>C1</td>>], 'C1')
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_escaped(unexpected, code)
|
def assert_escaped(unexpected, code)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
require_relative 'helper'
|
require_relative 'helper'
|
||||||
|
|
||||||
class TestRDocMarkupToMarkdown < RDoc::Markup::TextFormatterTestCase
|
class RDocMarkupToMarkdownTest < RDoc::Markup::TextFormatterTestCase
|
||||||
|
|
||||||
add_visitor_tests
|
add_visitor_tests
|
||||||
add_text_tests
|
add_text_tests
|
||||||
@ -348,11 +348,11 @@ words words words words
|
|||||||
|
|
||||||
def accept_table_align
|
def accept_table_align
|
||||||
expected = <<-EXPECTED
|
expected = <<-EXPECTED
|
||||||
AA |BB |CCCCC
|
AA |BB |CCCCC|DDDDD
|
||||||
----|---|-----
|
----|---|-----|-----
|
||||||
|bbb| c
|
|bbb| c|
|
||||||
aaaa|b |
|
aaaa|b | | dd
|
||||||
a | | cc
|
a | | cc| dd
|
||||||
EXPECTED
|
EXPECTED
|
||||||
assert_equal expected, @to.end_accepting
|
assert_equal expected, @to.end_accepting
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
require_relative 'helper'
|
require_relative 'helper'
|
||||||
|
|
||||||
class TestRDocMarkupToRDoc < RDoc::Markup::TextFormatterTestCase
|
class RDocMarkupToRDocTest < RDoc::Markup::TextFormatterTestCase
|
||||||
|
|
||||||
add_visitor_tests
|
add_visitor_tests
|
||||||
add_text_tests
|
add_text_tests
|
||||||
@ -348,11 +348,11 @@ words words words words
|
|||||||
|
|
||||||
def accept_table_align
|
def accept_table_align
|
||||||
expected = <<-EXPECTED
|
expected = <<-EXPECTED
|
||||||
AA |BB |CCCCC
|
AA |BB |CCCCC|DDDDD
|
||||||
----|---|-----
|
----|---|-----|-----
|
||||||
|bbb| c
|
|bbb| c|
|
||||||
aaaa|b |
|
aaaa|b | | dd
|
||||||
a | | cc
|
a | | cc| dd
|
||||||
EXPECTED
|
EXPECTED
|
||||||
assert_equal expected, @to.end_accepting
|
assert_equal expected, @to.end_accepting
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user