summaryrefslogtreecommitdiff
path: root/test/erb
diff options
context:
space:
mode:
authorseki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-30 12:40:52 +0000
committerseki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-30 12:40:52 +0000
commitb72ef21cd3459c67761f6295670802c00a179a41 (patch)
treeebfaceb8de8601fbfb2c9100ab1eeea1108a6850 /test/erb
parentb104173c4c7ebee13ddd869d7285f601a0ef8722 (diff)
[ruby-dev:34497] ERB::Util#url_encode bug fix. Reported by rubikitch.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/erb')
-rw-r--r--test/erb/test_erb.rb36
1 files changed, 22 insertions, 14 deletions
diff --git a/test/erb/test_erb.rb b/test/erb/test_erb.rb
index b2099af..aac3386 100644
--- a/test/erb/test_erb.rb
+++ b/test/erb/test_erb.rb
@@ -44,15 +44,15 @@ class TestERBCore < Test::Unit::TestCase
@erb = ERB
end
- def test_01
- _test_01(nil)
- _test_01(0)
- _test_01(1)
- _test_01(2)
- _test_01(3)
+ def test_core
+ _test_core(nil)
+ _test_core(0)
+ _test_core(1)
+ _test_core(2)
+ _test_core(3)
end
- def _test_01(safe)
+ def _test_core(safe)
erb = @erb.new("hello")
assert_equal(erb.result, "hello")
@@ -157,14 +157,14 @@ EOS
assert_equal(ans, erb.result)
end
- def test_02_safe_04
+ def test_safe_04
erb = @erb.new('<%=$SAFE%>', 4)
assert_equal(erb.result(TOPLEVEL_BINDING.taint), '4')
end
class Foo; end
- def test_03_def_class
+ def test_def_class
erb = @erb.new('hello')
cls = erb.def_class
assert_equal(Object, cls.superclass)
@@ -177,7 +177,7 @@ EOS
assert(cls.new.respond_to?('erb'))
end
- def test_04_percent
+ def test_percent
src = <<EOS
%n = 1
<%= n%>
@@ -220,7 +220,7 @@ EOS
class Bar; end
- def test_05_def_method
+ def test_def_method
assert(! Bar.new.respond_to?('hello'))
Bar.module_eval do
extend ERB::DefMethod
@@ -237,7 +237,7 @@ EOS
assert(Bar.new.respond_to?('hello_world'))
end
- def test_06_escape
+ def test_escape
src = <<EOS
1.<%% : <%="<%%"%>
2.%%> : <%="%%>"%>
@@ -274,7 +274,7 @@ EOS
assert_equal(ans, ERB.new(src, nil, '%').result)
end
- def test_07_keep_lineno
+ def test_keep_lineno
src = <<EOS
Hello,
% x = "World"
@@ -378,7 +378,7 @@ EOS
end
end
- def test_08_explicit
+ def test_explicit
src = <<EOS
<% x = %w(hello world) -%>
NotSkip <%- y = x -%> NotSkip
@@ -410,4 +410,12 @@ EOS
assert_equal(ans, ERB.new(src, nil, '-').result)
assert_equal(ans, ERB.new(src, nil, '-%').result)
end
+
+ def test_url_encode
+ assert_equal("Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide",
+ ERB::Util.url_encode("Programming Ruby: The Pragmatic Programmer's Guide"))
+
+ assert_equal("%A5%B5%A5%F3%A5%D7%A5%EB",
+ ERB::Util.url_encode("\xA5\xB5\xA5\xF3\xA5\xD7\xA5\xEB".force_encoding("EUC-JP")))
+ end
end