diff options
author | tmm1 <tmm1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-27 05:39:38 +0000 |
---|---|---|
committer | tmm1 <tmm1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-27 05:39:38 +0000 |
commit | fdcc476e217eac6143e7d1585900955c7ceda737 (patch) | |
tree | b045085d385f64e906e5c3024bb38418f6630a85 /test | |
parent | 0c3b3e9237e8fae4bdfd9e577b1f6275918e1abb (diff) | |
download | ruby-fdcc476e217eac6143e7d1585900955c7ceda737.tar.gz |
* test/ruby/test_eval.rb (class TestEval): Add test for shared eval
filenames via rb_fstring().
* test/ruby/test_iseq.rb (class TestISeq): Add test for shared
iseq labels via rb_fstring(). [Bug #9159]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_eval.rb | 12 | ||||
-rw-r--r-- | test/ruby/test_iseq.rb | 10 |
2 files changed, 22 insertions, 0 deletions
diff --git a/test/ruby/test_eval.rb b/test/ruby/test_eval.rb index cba9ce42f8..abf65613b1 100644 --- a/test/ruby/test_eval.rb +++ b/test/ruby/test_eval.rb @@ -473,4 +473,16 @@ class TestEval < Test::Unit::TestCase fname = "\u{3042}".encode("euc-jp") assert_equal(fname, eval("__FILE__", nil, fname, 1)) end + + def test_eval_location_fstring + o = Object.new + o.instance_eval "def foo() end", "generated code" + o.instance_eval "def bar() end", "generated code" + + a, b = o.method(:foo).source_location[0], + o.method(:bar).source_location[0] + + assert_equal a.object_id, b.object_id, + "#{a.inspect}.object_id != #{b.inspect}.object_id" + end end diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb index f8f186175f..fdc223b751 100644 --- a/test/ruby/test_iseq.rb +++ b/test/ruby/test_iseq.rb @@ -116,4 +116,14 @@ class TestISeq < Test::Unit::TestCase assert_equal("block in test_location", iseq.label) assert_equal(line+1, iseq.first_lineno) end + + def test_label_fstring + c = Class.new{ def foobar() end } + + a, b = eval("# encoding: us-ascii\n'foobar'.freeze"), + ISeq.of(c.instance_method(:foobar)).label + + assert_equal a.object_id, b.object_id, + "#{a.inspect}.object_id != #{b.inspect}.object_id" + end end |