diff options
author | Nobuyoshi Nakada <[email protected]> | 2020-08-17 22:57:40 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2020-08-17 22:57:40 +0900 |
commit | b52a501ca786a54fdaadf1a60fef517c55dd6ca3 (patch) | |
tree | 83a9d5e70f9f52f4c03fbda2f00ce286b0ee2603 /test/ruby/test_io.rb | |
parent | 27f7b047e07ceb9ee963e5d74ab0399b5e94ac4c (diff) |
Ensure the shortcut cached in the class
As well as the other places using RCLASS_IV_INDEX_TBL.
`IO#reopen` seems the only case that the class of an object can be
changed.
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r-- | test/ruby/test_io.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 8c7fe69128..82f122489a 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2489,6 +2489,17 @@ class TestIO < Test::Unit::TestCase end end + def test_reopen_ivar + assert_ruby_status([], "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + f = File.open(IO::NULL) + f.instance_variable_set(:@foo, 42) + f.reopen(STDIN) + f.instance_variable_defined?(:@foo) + f.instance_variable_get(:@foo) + end; + end + def test_foreach a = [] IO.foreach("|" + EnvUtil.rubybin + " -e 'puts :foo; puts :bar; puts :baz'") {|x| a << x } |