Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions test/cgi/test_cgi_escape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -353,30 +353,6 @@ def test_escape_html_uses_native_implementation
assert_equal CGI::EscapeExt, CGI.method(:h).owner
assert_equal CGI::EscapeExt, CGI.method(:unescape_html).owner
end

def test_escape_html_allocates_same_as_escapeHTML
omit "C extension not available" unless defined?(CGI::EscapeExt) && CGI::EscapeExt.method_defined?(:escapeHTML)

input = "'&\"<>hello world"
n = 100

# Warm up
2.times { n.times { CGI.escapeHTML(input) } }
2.times { n.times { CGI.escape_html(input) } }

GC.disable
before = GC.stat(:total_allocated_objects)
n.times { CGI.escapeHTML(input) }
camel_allocs = GC.stat(:total_allocated_objects) - before

before = GC.stat(:total_allocated_objects)
n.times { CGI.escape_html(input) }
snake_allocs = GC.stat(:total_allocated_objects) - before
GC.enable

assert_equal camel_allocs, snake_allocs,
"escape_html allocated #{snake_allocs} objects vs escapeHTML #{camel_allocs} — alias may not be using the C extension"
end
end

class CGIEscapePureRubyTest < Test::Unit::TestCase
Expand Down
Loading