From 3802fb92ff8c83eed3e867db20f72c53932f542d Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 26 Dec 2017 10:10:41 +0000 Subject: parse.y: warning for locations * parse.y (gettable_gen): warn for __FILE__/__LINE__ when eval with binding only. promote use of Binding#source_location instead. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_eval.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_eval.rb b/test/ruby/test_eval.rb index 0bc0390d64..eba00f80bd 100644 --- a/test/ruby/test_eval.rb +++ b/test/ruby/test_eval.rb @@ -503,6 +503,12 @@ class TestEval < Test::Unit::TestCase assert_same a, b end + def test_eval_location_binding + assert_warning(/__FILE__ in eval/) do + assert_equal(__FILE__, eval("__FILE__", binding)) + end + end + def test_fstring_instance_eval bug = "[ruby-core:78116] [Bug #12930]".freeze assert_same bug, (bug.instance_eval {self}) -- cgit v1.2.3