1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* MANIFEST: add test_erb.rb

* lib/erb.rb, test/erb/test_erb.rb: don't forget filename,
          if both filename and safe_level given. [ruby-dev:23050]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
seki 2004-02-28 01:52:14 +00:00
parent bf08067ded
commit c85e310795
4 changed files with 49 additions and 1 deletions

View file

@ -1,3 +1,10 @@
Sat Feb 28 10:31:03 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* MANIFEST: add test_erb.rb
* lib/erb.rb, test/erb/test_erb.rb: don't forget filename,
if both filename and safe_level given. [ruby-dev:23050]
Fri Feb 27 20:37:09 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (proc_invoke): no orphan block check is needed when pcall

View file

@ -772,6 +772,7 @@ test/drb/ut_large.rb
test/drb/ut_port.rb
test/drb/ut_safe1.rb
test/drb/ut_timerholder.rb
test/erb/test_erb.rb
test/fileutils/fileasserts.rb
test/fileutils/test_fileutils.rb
test/fileutils/test_nowrite.rb

View file

@ -414,7 +414,7 @@ class ERB
if @safe_level
th = Thread.start {
$SAFE = @safe_level
eval(@src, b)
eval(@src, b, (@filename || '(erb)'), 1)
}
return th.value
else

40
test/erb/test_erb.rb Normal file
View file

@ -0,0 +1,40 @@
require 'test/unit'
require 'erb'
class TestERB < Test::Unit::TestCase
class MyError < RuntimeError ; end
def test_without_filename
erb = ERB.new("<% raise ::TestERB::MyError %>")
e = assert_raise(MyError) {
erb.result
}
assert_equal("(erb):1", e.backtrace[0])
end
def test_with_filename
erb = ERB.new("<% raise ::TestERB::MyError %>")
erb.filename = "test filename"
e = assert_raise(MyError) {
erb.result
}
assert_equal("test filename:1", e.backtrace[0])
end
def test_without_filename_with_safe_level
erb = ERB.new("<% raise ::TestERB::MyError %>", 1)
e = assert_raise(MyError) {
erb.result
}
assert_equal("(erb):1", e.backtrace[0])
end
def test_with_filename_and_safe_level
erb = ERB.new("<% raise ::TestERB::MyError %>", 1)
erb.filename = "test filename"
e = assert_raise(MyError) {
erb.result
}
assert_equal("test filename:1", e.backtrace[0])
end
end