diff options
author | Matt Valentine-House <matt@eightbitraptor.com> | 2022-12-07 16:01:37 +0000 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-12-09 22:11:00 +0900 |
commit | 181d4bee5e03a30596e78b2d7aa0396887a53881 (patch) | |
tree | b7357b6f4faa53ff7150b4c63eee23d6a9c010d5 /test/ruby | |
parent | 7c438328d59e70fee82100caaa931ff163bd8daf (diff) | |
download | ruby-181d4bee5e03a30596e78b2d7aa0396887a53881.tar.gz |
Use rb_inspect instead of +PRIsVALUE for Object.inspect
In order to preserve the values when TrueClass, FalseClass or NilClass
are stored in ivars
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 891ceff0c9..26256b80db 100644 --- a/test/ruby/test_object.rb +++ b/test/ruby/test_object.rb @@ -853,6 +853,15 @@ class TestObject < Test::Unit::TestCase x.instance_variable_set(:@bar, 42) assert_match(/\A#<Object:0x\h+ (?:@foo="value", @bar=42|@bar=42, @foo="value")>\z/, x.inspect) + # Bug: [ruby-core:19167] + x = Object.new + x.instance_variable_set(:@foo, NilClass) + assert_match(/\A#<Object:0x\h+ @foo=NilClass>\z/, x.inspect) + x.instance_variable_set(:@foo, TrueClass) + assert_match(/\A#<Object:0x\h+ @foo=TrueClass>\z/, x.inspect) + x.instance_variable_set(:@foo, FalseClass) + assert_match(/\A#<Object:0x\h+ @foo=FalseClass>\z/, x.inspect) + # #inspect does not call #to_s anymore feature6130 = '[ruby-core:43238]' x = Object.new |