diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | test/ruby/test_eval.rb | 12 | ||||
-rw-r--r-- | test/ruby/test_iseq.rb | 10 |
3 files changed, 29 insertions, 0 deletions
@@ -1,3 +1,10 @@ +Wed Nov 27 14:37:33 2013 Aman Gupta <ruby@tmm1.net> + + * 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] + Wed Nov 27 14:24:55 2013 Aman Gupta <ruby@tmm1.net> * hash.c (hash_aset_str): Use rb_fstring() to de-duplicate hash string 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 |