diff options
Diffstat (limited to 'test/erb/test_erb.rb')
-rw-r--r-- | test/erb/test_erb.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/erb/test_erb.rb b/test/erb/test_erb.rb index fb5e9b611e..555345a140 100644 --- a/test/erb/test_erb.rb +++ b/test/erb/test_erb.rb @@ -73,12 +73,28 @@ class TestERB < Test::Unit::TestCase assert_equal("", ERB::Util.html_escape("")) assert_equal("abc", ERB::Util.html_escape("abc")) assert_equal("<<", ERB::Util.html_escape("<\<")) + assert_equal("'&"><", ERB::Util.html_escape("'&\"><")) assert_equal("", ERB::Util.html_escape(nil)) assert_equal("123", ERB::Util.html_escape(123)) end + def test_html_escape_to_s + object = Object.new + def object.to_s + "object" + end + assert_equal("object", ERB::Util.html_escape(object)) + end + + def test_html_escape_extension + assert_nil(ERB::Util.method(:html_escape).source_location) + end if RUBY_ENGINE == 'ruby' + def test_concurrent_default_binding + # This test randomly fails with JRuby -- NameError: undefined local variable or method `template2' + pend if RUBY_ENGINE == 'jruby' + template1 = 'one <%= ERB.new(template2).result %>' eval 'template2 = "two"', TOPLEVEL_BINDING @@ -236,6 +252,8 @@ EOS end def test_invalid_trim_mode + pend if RUBY_ENGINE == 'truffleruby' + assert_warning(/#{__FILE__}:#{__LINE__ + 1}/) do @erb.new("", trim_mode: 'abc-def') end @@ -695,6 +713,18 @@ EOS erb = Marshal.load(Marshal.dump(erb)) assert_raise(ArgumentError) {erb.result} end + + def test_multi_line_comment_lineno + erb = ERB.new(<<~EOS) + <%= __LINE__ %> + <%# + %><%= __LINE__ %> + EOS + assert_equal <<~EOS, erb.result + 1 + 3 + EOS + end end class TestERBCoreWOStrScan < TestERBCore |