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

ruby-changes:59654

From: Nobuyoshi <ko1@a...>
Date: Thu, 9 Jan 2020 14:47:00 +0900 (JST)
Subject: [ruby-changes:59654] b369f5e8a2 (master): Fixed up 0eeed5bcc5530edb0af2af2ccff09d067c59e8f9

https://git.ruby-lang.org/ruby.git/commit/?id=b369f5e8a2

From b369f5e8a2c1e4bc90c561365d42dc5674f83d6e Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Thu, 9 Jan 2020 10:13:08 +0900
Subject: Fixed up 0eeed5bcc5530edb0af2af2ccff09d067c59e8f9

`Binding#source_location` returns the `__FILE__` when created, and
may not be an absolute or real path.  And in the `eval` context
with an explicit file name, `__dir__` also returns that name.
On the other hand, `__FILE__` in `require`d script file has been
expanded at searching the library.

diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index 207be50..7577a53 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -790,7 +790,9 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L790
     assert_instance_of String, __dir__
     assert_equal(File.dirname(File.realpath(__FILE__)), __dir__)
     bug8436 = '[ruby-core:55123] [Bug #8436]'
-    assert_equal(__dir__, eval("__dir__", binding, *binding.source_location), bug8436)
+    file, line = *binding.source_location
+    file = File.realpath(file)
+    assert_equal(__dir__, eval("__dir__", binding, file, line), bug8436)
     bug8662 = '[ruby-core:56099] [Bug #8662]'
     assert_equal("arbitrary", eval("__dir__", binding, "arbitrary/file.rb"), bug8662)
     assert_equal("arbitrary", Object.new.instance_eval("__dir__", "arbitrary/file.rb"), bug8662)
-- 
cgit v0.10.2


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

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