@@ -33,8 +33,18 @@ def test_class_binary_japanese_text
3333 end
3434
3535 def test_class_binary_large_japanese_rdoc
36- file_name = File . expand_path '../test.ja.large.rdoc' , __FILE__
37- assert !@RP . binary? ( file_name )
36+ skip "Encoding not implemented" unless Object . const_defined? :Encoding
37+
38+ capture_io do
39+ begin
40+ extenc , Encoding . default_external =
41+ Encoding . default_external , Encoding ::US_ASCII
42+ file_name = File . expand_path '../test.ja.largedoc' , __FILE__
43+ assert !@RP . binary? ( file_name )
44+ ensure
45+ Encoding . default_external = extenc
46+ end
47+ end
3848 end
3949
4050 def test_class_binary_japanese_rdoc
@@ -51,7 +61,7 @@ def test_class_can_parse
5161
5262 assert_equal @RP ::Simple , @RP . can_parse ( readme_file_name )
5363
54- assert_nil @RP . can_parse ( @binary_dat )
64+ assert_equal @RP :: Simple , @RP . can_parse ( @binary_dat )
5565
5666 jtest_file_name = File . expand_path '../test.ja.txt' , __FILE__
5767 assert_equal @RP ::Simple , @RP . can_parse ( jtest_file_name )
@@ -61,27 +71,20 @@ def test_class_can_parse
6171
6272 readme_file_name = File . expand_path '../README' , __FILE__
6373 assert_equal @RP ::Simple , @RP . can_parse ( readme_file_name )
64- end
6574
66- def test_class_can_parse_forbidden
67- skip 'chmod not supported' if Gem . win_platform?
68-
69- Tempfile . open 'forbidden' do |io |
70- begin
71- File . chmod 0000 , io . path
75+ jtest_largerdoc_file_name = File . expand_path '../test.ja.largedoc' , __FILE__
76+ assert_equal @RP ::Simple , @RP . can_parse ( jtest_largerdoc_file_name )
7277
73- assert_nil @RP . can_parse io . path
74- ensure
75- File . chmod 0400 , io . path
76- end
77- end
78+ @RP . alias_extension 'rdoc' , 'largedoc'
79+ assert_equal @RP ::Simple , @RP . can_parse ( jtest_largerdoc_file_name )
7880 end
7981
8082 def test_class_for_executable
8183 temp_dir do
8284 content = "#!/usr/bin/env ruby -w\n "
8385 open 'app' , 'w' do |io | io . write content end
8486 app = @store . add_file 'app'
87+
8588 parser = @RP . for app , 'app' , content , @options , :stats
8689
8790 assert_kind_of RDoc ::Parser ::Ruby , parser
@@ -90,6 +93,23 @@ def test_class_for_executable
9093 end
9194 end
9295
96+ def test_class_for_forbidden
97+ skip 'chmod not supported' if Gem . win_platform?
98+
99+ Tempfile . open 'forbidden' do |io |
100+ begin
101+ File . chmod 0000 , io . path
102+ forbidden = @store . add_file io . path
103+
104+ parser = @RP . for forbidden , 'forbidden' , '' , @options , :stats
105+
106+ assert_nil parser
107+ ensure
108+ File . chmod 0400 , io . path
109+ end
110+ end
111+ end
112+
93113 def test_can_parse_modeline
94114 readme_ext = File . join Dir . tmpdir , "README.EXT.#{ $$} "
95115
@@ -126,6 +146,18 @@ def test_check_modeline
126146 File . unlink readme_ext
127147 end
128148
149+ def test_check_modeline_coding
150+ readme_ext = File . join Dir . tmpdir , "README.EXT.#{ $$} "
151+
152+ open readme_ext , 'w' do |io |
153+ io . puts "# -*- coding: utf-8 -*-"
154+ end
155+
156+ assert_nil @RP . check_modeline readme_ext
157+ ensure
158+ File . unlink readme_ext
159+ end
160+
129161 def test_check_modeline_with_other
130162 readme_ext = File . join Dir . tmpdir , "README.EXT.#{ $$} "
131163
0 commit comments