diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-12-12 10:31:47 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-12-12 10:31:47 +0000 |
commit | e82f4195d49b730a48031738694391dbb3e41091 (patch) | |
tree | a3761ebf102d08a532532674de1611b6e9e603d3 /test/erb | |
parent | 4d3677e14bf0adf8ddeabfff395831b8e032209c (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.rb | 19 |
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(" !"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", ERB::Util.html_escape(" !\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~")) |