ruby-changes:64012
From: Nobuyoshi <ko1@a...>
Date: Tue, 8 Dec 2020 11:44:41 +0900 (JST)
Subject: [ruby-changes:64012] ea18c8bb96 (master): Made method-local instance variables local variables
https://git.ruby-lang.org/ruby.git/commit/?id=ea18c8bb96 From ea18c8bb96c019a609b37671ceec5f51d61476cd Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 8 Dec 2020 11:43:42 +0900 Subject: Made method-local instance variables local variables diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb index cf18af1..d614dc6 100644 --- a/test/ruby/test_dir.rb +++ b/test/ruby/test_dir.rb @@ -88,60 +88,52 @@ class TestDir < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_dir.rb#L88 end def test_chdir - @pwd = Dir.pwd - @env_home = ENV["HOME"] - @env_logdir = ENV["LOGDIR"] + pwd = Dir.pwd + env_home = ENV["HOME"] + env_logdir = ENV["LOGDIR"] ENV.delete("HOME") ENV.delete("LOGDIR") assert_raise(Errno::ENOENT) { Dir.chdir(@nodir) } assert_raise(ArgumentError) { Dir.chdir } - ENV["HOME"] = @pwd + ENV["HOME"] = pwd Dir.chdir do - assert_equal(@pwd, Dir.pwd) + assert_equal(pwd, Dir.pwd) assert_raise(RuntimeError) { Dir.chdir(@root) } - assert_equal(@pwd, Dir.pwd) + assert_equal(pwd, Dir.pwd) Dir.chdir(@root) do assert_equal(@root, Dir.pwd) end - assert_equal(@pwd, Dir.pwd) + assert_equal(pwd, Dir.pwd) end ensure begin - Dir.chdir(@pwd) + Dir.chdir(pwd) rescue - abort("cannot return the original directory: #{ @pwd }") - end - if @env_home - ENV["HOME"] = @env_home - else - ENV.delete("HOME") - end - if @env_logdir - ENV["LOGDIR"] = @env_logdir - else - ENV.delete("LOGDIR") + abort("cannot return the original directory: #{ pwd }") end + ENV["HOME"] = env_home + ENV["LOGDIR"] = env_logdir end def test_chdir_conflict - @pwd = Dir.pwd + pwd = Dir.pwd q = Queue.new t = Thread.new do q.pop - Dir.chdir(@pwd) rescue $! + Dir.chdir(pwd) rescue $! end - Dir.chdir(@pwd) do + Dir.chdir(pwd) do q.push nil assert_instance_of(RuntimeError, t.value) end t = Thread.new do q.pop - Dir.chdir(@pwd){} rescue $! + Dir.chdir(pwd){} rescue $! end - Dir.chdir(@pwd) do + Dir.chdir(pwd) do q.push nil assert_instance_of(RuntimeError, t.value) end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/