summaryrefslogtreecommitdiff
path: root/test/erb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-12 10:31:47 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-12 10:31:47 +0000
commite82f4195d49b730a48031738694391dbb3e41091 (patch)
treea3761ebf102d08a532532674de1611b6e9e603d3 /test/erb
parent4d3677e14bf0adf8ddeabfff395831b8e032209c (diff)
erb: lineno and location setters
* lib/erb.rb (ERB#lineno): accessor for line number to eval. * lib/erb.rb (ERB#location=): setter of file name and line number. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/erb')
-rw-r--r--test/erb/test_erb.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/erb/test_erb.rb b/test/erb/test_erb.rb
index 65efd39191..107ad1a0da 100644
--- a/test/erb/test_erb.rb
+++ b/test/erb/test_erb.rb
@@ -39,6 +39,25 @@ class TestERB < Test::Unit::TestCase
assert_match(/\Atest filename:1\b/, e.backtrace[0])
end
+ def test_with_filename_lineno
+ erb = ERB.new("<% raise ::TestERB::MyError %>")
+ erb.filename = "test filename"
+ erb.lineno = 100
+ e = assert_raise(MyError) {
+ erb.result
+ }
+ assert_match(/\Atest filename:101\b/, e.backtrace[0])
+ end
+
+ def test_with_location
+ erb = ERB.new("<% raise ::TestERB::MyError %>")
+ erb.location = ["test filename", 200]
+ e = assert_raise(MyError) {
+ erb.result
+ }
+ assert_match(/\Atest filename:201\b/, e.backtrace[0])
+ end
+
def test_html_escape
assert_equal(" !&quot;\#$%&amp;&#39;()*+,-./0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",
ERB::Util.html_escape(" !\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"))