[前][次][番号順一覧][スレッド一覧]

ruby-changes:31792

From: tmm1 <ko1@a...>
Date: Wed, 27 Nov 2013 14:39:55 +0900 (JST)
Subject: [ruby-changes:31792] tmm1:r43871 (trunk): * test/ruby/test_eval.rb (class TestEval): Add test for shared eval

tmm1	2013-11-27 14:39:38 +0900 (Wed, 27 Nov 2013)

  New Revision: 43871

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43871

  Log:
    * 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]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_eval.rb
    trunk/test/ruby/test_iseq.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43870)
+++ ChangeLog	(revision 43871)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Nov 27 14:37:33 2013  Aman Gupta <ruby@t...>
+
+	* 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@t...>
 
 	* hash.c (hash_aset_str): Use rb_fstring() to de-duplicate hash string
Index: test/ruby/test_eval.rb
===================================================================
--- test/ruby/test_eval.rb	(revision 43870)
+++ test/ruby/test_eval.rb	(revision 43871)
@@ -473,4 +473,16 @@ class TestEval < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_eval.rb#L473
     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
Index: test/ruby/test_iseq.rb
===================================================================
--- test/ruby/test_iseq.rb	(revision 43870)
+++ test/ruby/test_iseq.rb	(revision 43871)
@@ -116,4 +116,14 @@ class TestISeq < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_iseq.rb#L116
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]