summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-16 03:00:44 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-16 03:00:44 +0000
commit817eb7d17d3f1327dfb4c706ef6604dd1483ece7 (patch)
tree472b40718e5ce09a4f83fae65d4675ab2f835426 /test
parente2ca7837d1d8afbbcb2387d1c22a016e799024e4 (diff)
* vm_insnhelper.c (argument_error): use line number at the beginning
of lambda, not the first code ob its body. [ruby-core:43314][Bug #6151] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_lambda.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_lambda.rb b/test/ruby/test_lambda.rb
index ae12c6d609..40bd134e2f 100644
--- a/test/ruby/test_lambda.rb
+++ b/test/ruby/test_lambda.rb
@@ -70,4 +70,23 @@ class TestLambdaParameters < Test::Unit::TestCase
BasicObject.new.instance_eval {->() {called = true}.()}
assert_equal(true, called, bug5966)
end
+
+ def test_location_on_error
+ bug6151 = '[ruby-core:43314]'
+ called = 0
+ line, f = __LINE__, lambda do
+ called += 1
+ true
+ end
+ e = assert_raise(ArgumentError) do
+ f.call(42)
+ end
+ assert_send([e.backtrace.first, :start_with?, "#{__FILE__}:#{line}:"], bug6151)
+ assert_equal(0, called)
+ e = assert_raise(ArgumentError) do
+ 42.times(&f)
+ end
+ assert_send([e.backtrace.first, :start_with?, "#{__FILE__}:#{line}:"], bug6151)
+ assert_equal(0, called)
+ end
end