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

ruby-changes:49366

From: mame <ko1@a...>
Date: Tue, 26 Dec 2017 18:04:31 +0900 (JST)
Subject: [ruby-changes:49366] mame:r61481 (trunk): test/ruby/test_proc.rb: Add a test for Binding#source_location

mame	2017-12-26 18:04:26 +0900 (Tue, 26 Dec 2017)

  New Revision: 61481

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61481

  Log:
    test/ruby/test_proc.rb: Add a test for Binding#source_location

  Modified files:
    trunk/test/ruby/test_proc.rb
Index: test/ruby/test_proc.rb
===================================================================
--- test/ruby/test_proc.rb	(revision 61480)
+++ test/ruby/test_proc.rb	(revision 61481)
@@ -397,6 +397,21 @@ class TestProc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_proc.rb#L397
     assert_equal([1, 2, 3], b.eval("[x, y, z]"))
   end
 
+  def test_binding_source_location
+    b, expected_location = binding, [__FILE__, __LINE__]
+    assert_equal(expected_location, b.source_location)
+
+    file, lineno = method(:source_location_test).to_proc.binding.source_location
+    assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
+    assert_equal(@@line_of_source_location_test, lineno, 'Bug #2427')
+  end
+
+  def test_source_location
+    file, lineno = method(:source_location_test).source_location
+    assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
+    assert_equal(@@line_of_source_location_test, lineno, 'Bug #2427')
+  end
+
   def test_proc_lambda
     assert_raise(ArgumentError) { proc }
     assert_raise(ArgumentError) { lambda }

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

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