Skip to content

Commit 813237a

Browse files
authored
Merge pull request #92 from nobu/tests
Fix tests on JRuby and TruffleRuby
2 parents ebd04d1 + 7b5a139 commit 813237a

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

ext/java/org/jruby/ext/cgi/escape/CGIEscape.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ static IRubyObject optimized_escape(Ruby runtime, RubyString str, boolean escape
339339

340340
int buf = 0;
341341
Ruby runtime = context.runtime;
342-
342+
343343
for (i = 0; i < len; ++i) {
344344
int c = cstrBytes[cstr + i] & 0xFF;
345345
int clen = 0;

lib/cgi/core.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,8 @@ def read_from_cmdline
629629
string = unless ARGV.empty?
630630
ARGV.join(' ')
631631
else
632-
if STDIN.tty?
633-
STDERR.print(
632+
if stdinput.tty?
633+
$stderr.print(
634634
%|(offline mode: enter name=value pairs on standard input)\n|
635635
)
636636
end

test/cgi/test_cgi_escape.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def setup
300300
remove_method :escapeHTML
301301
alias _unescapeHTML unescapeHTML
302302
remove_method :unescapeHTML
303-
end if defined?(CGI::EscapeExt)
303+
end if defined?(CGI::EscapeExt) and CGI::EscapeExt.method_defined?(:escapeHTML)
304304
end
305305

306306
def teardown
@@ -309,7 +309,7 @@ def teardown
309309
remove_method :_escapeHTML
310310
alias unescapeHTML _unescapeHTML
311311
remove_method :_unescapeHTML
312-
end if defined?(CGI::EscapeExt)
312+
end if defined?(CGI::EscapeExt) and CGI::EscapeExt.method_defined?(:_escapeHTML)
313313
end
314314

315315
include CGIEscapeTest::UnescapeHTMLTests

test/cgi/test_cgi_new.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_tag_maker_functionality
5757
'html4Fr' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">',
5858
'html5' => '<!DOCTYPE HTML>'
5959
}
60-
60+
6161
html_versions.each do |version, expected_doctype|
6262
cgi = CGI.new(tag_maker: version)
6363
assert_respond_to(cgi, :doctype, "HTML generation methods should be loaded for #{version}")
@@ -80,11 +80,11 @@ def test_string_tag_maker_equivalent
8080

8181
cgi1 = CGI.new('html5')
8282
cgi2 = CGI.new(tag_maker: 'html5')
83-
83+
8484
# Both should have HTML generation methods loaded
8585
assert_respond_to(cgi1, :doctype)
8686
assert_respond_to(cgi2, :doctype)
87-
87+
8888
# Both should produce the same doctype
8989
assert_equal(cgi1.doctype, cgi2.doctype)
9090
assert_equal('<!DOCTYPE HTML>', cgi1.doctype)
@@ -96,13 +96,13 @@ def test_offline_mode
9696
ENV.delete('QUERY_STRING')
9797
ENV.delete('SERVER_SOFTWARE')
9898
ENV.delete('SERVER_PROTOCOL')
99-
99+
100100
# Create test input
101101
test_input = "name=value&test=123"
102102
$stdin = StringIO.new(test_input)
103-
103+
104104
cgi = CGI.new
105-
105+
106106
# In offline mode, it should read from stdin
107107
assert_equal("value", cgi['name'])
108108
assert_equal("123", cgi['test'])
@@ -145,7 +145,7 @@ def test_object_structure
145145
)
146146

147147
cgi = CGI.new
148-
148+
149149
# Test documented instance variables and methods exist
150150
assert_kind_of(Hash, cgi.cookies)
151151
assert_kind_of(Hash, cgi.params)
@@ -182,7 +182,7 @@ def test_encoding_error_block_handling
182182
'REQUEST_METHOD' => 'POST',
183183
'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
184184
'CONTENT_LENGTH' => test_input.length.to_s,
185-
'SERVER_SOFTWARE' => 'Apache 2.2.0',
185+
'SERVER_SOFTWARE' => 'Apache 2.2.0',
186186
'SERVER_PROTOCOL' => 'HTTP/1.1',
187187
)
188188

@@ -208,7 +208,7 @@ def test_class_vs_instance_charset
208208

209209
# Class default should be UTF-8
210210
assert_equal(Encoding::UTF_8, CGI.accept_charset)
211-
211+
212212
# Instance with no option should use class default internally
213213
cgi = CGI.new
214214
assert_equal(Encoding::UTF_8, cgi.instance_variable_get(:@accept_charset))
@@ -257,10 +257,10 @@ def test_option_assignment
257257
assert_equal('EUC-JP', cgi1.instance_variable_get(:@accept_charset))
258258
assert_equal(512 * 1024, cgi2.instance_variable_get(:@max_multipart_length))
259259
assert_respond_to(cgi3, :doctype)
260-
260+
261261
assert_equal('ISO-8859-1', cgi4.instance_variable_get(:@accept_charset))
262262
assert_equal(256 * 1024, cgi4.instance_variable_get(:@max_multipart_length))
263263
assert_respond_to(cgi4, :doctype)
264264
assert_equal('<!DOCTYPE HTML>', cgi4.doctype)
265265
end
266-
end
266+
end

0 commit comments

Comments
 (0)