diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2022-10-22 01:25:00 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-22 01:25:00 -0600 |
| commit | 3d0c8accb95166f786fbcf3801c679b13042523b (patch) | |
| tree | cb7a97db5d741e74a30e68d53d2a91df272ff6e8 /test/reader_test.rb | |
| parent | 939fdf4a89022d484dbc6650cee901d75a3a8550 (diff) | |
resolves #4368 redo loop rather than using recursion to locate next line to process (PR #4372)
Diffstat (limited to 'test/reader_test.rb')
| -rw-r--r-- | test/reader_test.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/reader_test.rb b/test/reader_test.rb index 9014fa1f..21cd8bd9 100644 --- a/test/reader_test.rb +++ b/test/reader_test.rb @@ -146,6 +146,10 @@ class ReaderTest < Minitest::Test assert reader.next_line_empty? end + test 'peek_line should return nil if next entry is nil' do + assert_nil (Asciidoctor::Reader.new [nil]).peek_line + end + test 'peek_line should return next line if there are lines remaining' do reader = Asciidoctor::Reader.new SAMPLE_DATA assert_equal SAMPLE_DATA.first, reader.peek_line @@ -2819,6 +2823,39 @@ class ReaderTest < Minitest::Test assert_empty logger end end + + test 'should not fail to process preprocessor directive that evaluates to false and has a large number of lines' do + lines = (%w(data) * 5000) * ?\n + input = <<~EOS + before + + ifdef::attribute-not-set[] + #{lines} + endif::attribute-not-set[] + + after + EOS + + doc = Asciidoctor.load input + assert_equal 2, doc.blocks.size + assert_equal 'before', doc.blocks[0].source + assert_equal 'after', doc.blocks[1].source + end + + test 'should not fail to process lines if reader contains a nil entry' do + input = ['before', '', '', '', 'after'] + doc = Asciidoctor.load input, extensions: proc { + preprocessor do + process do |_, reader| + reader.source_lines[2] = nil + nil + end + end + } + assert_equal 2, doc.blocks.size + assert_equal 'before', doc.blocks[0].source + assert_equal 'after', doc.blocks[1].source + end end end end |
