diff options
author | eileencodes <eileencodes@gmail.com> | 2022-09-30 15:37:18 -0400 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2022-09-30 13:57:59 -0700 |
commit | 0ab0229c1162308509b36cafbf6eaafd7ae054d7 (patch) | |
tree | 9232e7d3604258fa0c05569187bec4a475e70031 /test/ruby | |
parent | a44040c9e47a9cb41807b0ec5d665d656d60db84 (diff) | |
download | ruby-0ab0229c1162308509b36cafbf6eaafd7ae054d7.tar.gz |
Fix frozen object inspect
In the rails/rails CI build for Ruby master we found that some tests
were failing due to inspect on a frozen object being incorrect.
An object's instance variable count was incorrect when frozen causing
the object's inspect to not splat out the object.
This fixes the issue and adds a test for inspecting frozen objects.
Co-Authored-By: Jemma Issroff <jemmaissroff@gmail.com>
Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_object.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb index 83208bbcdb..a9d5d4b13e 100644 --- a/test/ruby/test_object.rb +++ b/test/ruby/test_object.rb @@ -993,4 +993,13 @@ class TestObject < Test::Unit::TestCase end EOS end + + def test_frozen_inspect + obj = Object.new + obj.instance_variable_set(:@a, "a") + ins = obj.inspect + obj.freeze + + assert_equal(ins, obj.inspect) + end end |