summaryrefslogtreecommitdiff
path: root/test/erb
diff options
context:
space:
mode:
Diffstat (limited to 'test/erb')
-rw-r--r--test/erb/test_erb.rb30
-rw-r--r--test/erb/test_erb_command.rb18
2 files changed, 34 insertions, 14 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("&lt;&lt;", ERB::Util.html_escape("<\<"))
+ assert_equal("&#39;&amp;&quot;&gt;&lt;", 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
diff --git a/test/erb/test_erb_command.rb b/test/erb/test_erb_command.rb
index 0baa59ddd5..6bf252c5cd 100644
--- a/test/erb/test_erb_command.rb
+++ b/test/erb/test_erb_command.rb
@@ -4,27 +4,17 @@ require 'test/unit'
class TestErbCommand < Test::Unit::TestCase
def test_var
- assert_in_out_err(["-I#{File.expand_path('../../lib', __dir__)}", "-w",
+ pend if RUBY_ENGINE == 'truffleruby'
+ assert_in_out_err(["-I#{File.expand_path('../../lib', __dir__)}",
File.expand_path("../../libexec/erb", __dir__),
"var=hoge"],
"<%=var%>", ["hoge"])
end
def test_template_file_encoding
- assert_in_out_err(["-I#{File.expand_path('../../lib', __dir__)}", "-w",
+ pend if RUBY_ENGINE == 'truffleruby'
+ assert_in_out_err(["-I#{File.expand_path('../../lib', __dir__)}",
File.expand_path("../../libexec/erb", __dir__)],
"<%=''.encoding.to_s%>", ["UTF-8"])
end
-
- # These interfaces will be removed at Ruby 2.7.
- def test_deprecated_option
- warnings = [
- "warning: -S option of erb command is deprecated. Please do not use this.",
- /\n.+\/libexec\/erb:\d+: warning: Passing safe_level with the 2nd argument of ERB\.new is deprecated\. Do not use it, and specify other arguments as keyword arguments\.\n/,
- ]
- assert_in_out_err(["-I#{File.expand_path('../../lib', __dir__)}", "-w",
- File.expand_path("../../libexec/erb", __dir__),
- "-S", "0"],
- "hoge", ["hoge"], warnings)
- end
end