summaryrefslogtreecommitdiff
path: root/test/rdoc/test_rdoc_parser.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/rdoc/test_rdoc_parser.rb')
-rw-r--r--test/rdoc/test_rdoc_parser.rb62
1 files changed, 47 insertions, 15 deletions
diff --git a/test/rdoc/test_rdoc_parser.rb b/test/rdoc/test_rdoc_parser.rb
index 5f3b786314..338693f97a 100644
--- a/test/rdoc/test_rdoc_parser.rb
+++ b/test/rdoc/test_rdoc_parser.rb
@@ -33,8 +33,18 @@ class TestRDocParser < RDoc::TestCase
end
def test_class_binary_large_japanese_rdoc
- file_name = File.expand_path '../test.ja.large.rdoc', __FILE__
- assert [email protected]?(file_name)
+ skip "Encoding not implemented" unless Object.const_defined? :Encoding
+
+ capture_io do
+ begin
+ extenc, Encoding.default_external =
+ Encoding.default_external, Encoding::US_ASCII
+ file_name = File.expand_path '../test.ja.largedoc', __FILE__
+ assert [email protected]?(file_name)
+ ensure
+ Encoding.default_external = extenc
+ end
+ end
end
def test_class_binary_japanese_rdoc
@@ -51,7 +61,7 @@ class TestRDocParser < RDoc::TestCase
assert_equal @RP::Simple, @RP.can_parse(readme_file_name)
- assert_nil @RP.can_parse(@binary_dat)
+ assert_equal @RP::Simple, @RP.can_parse(@binary_dat)
jtest_file_name = File.expand_path '../test.ja.txt', __FILE__
assert_equal @RP::Simple, @RP.can_parse(jtest_file_name)
@@ -61,20 +71,12 @@ class TestRDocParser < RDoc::TestCase
readme_file_name = File.expand_path '../README', __FILE__
assert_equal @RP::Simple, @RP.can_parse(readme_file_name)
- end
- def test_class_can_parse_forbidden
- skip 'chmod not supported' if Gem.win_platform?
-
- Tempfile.open 'forbidden' do |io|
- begin
- File.chmod 0000, io.path
+ jtest_largerdoc_file_name = File.expand_path '../test.ja.largedoc', __FILE__
+ assert_equal @RP::Simple, @RP.can_parse(jtest_largerdoc_file_name)
- assert_nil @RP.can_parse io.path
- ensure
- File.chmod 0400, io.path
- end
- end
+ @RP.alias_extension 'rdoc', 'largedoc'
+ assert_equal @RP::Simple, @RP.can_parse(jtest_largerdoc_file_name)
end
def test_class_for_executable
@@ -82,6 +84,7 @@ class TestRDocParser < RDoc::TestCase
content = "#!/usr/bin/env ruby -w\n"
open 'app', 'w' do |io| io.write content end
app = @store.add_file 'app'
+
parser = @RP.for app, 'app', content, @options, :stats
assert_kind_of RDoc::Parser::Ruby, parser
@@ -90,6 +93,23 @@ class TestRDocParser < RDoc::TestCase
end
end
+ def test_class_for_forbidden
+ skip 'chmod not supported' if Gem.win_platform?
+
+ Tempfile.open 'forbidden' do |io|
+ begin
+ File.chmod 0000, io.path
+ forbidden = @store.add_file io.path
+
+ parser = @RP.for forbidden, 'forbidden', '', @options, :stats
+
+ assert_nil parser
+ ensure
+ File.chmod 0400, io.path
+ end
+ end
+ end
+
def test_can_parse_modeline
readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
@@ -126,6 +146,18 @@ class TestRDocParser < RDoc::TestCase
File.unlink readme_ext
end
+ def test_check_modeline_coding
+ readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
+
+ open readme_ext, 'w' do |io|
+ io.puts "# -*- coding: utf-8 -*-"
+ end
+
+ assert_nil @RP.check_modeline readme_ext
+ ensure
+ File.unlink readme_ext
+ end
+
def test_check_modeline_with_other
readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"