summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2025-12-20 17:01:05 -0500
committerPeter Zhu <peter@peterzhu.ca>2025-12-20 18:14:48 -0500
commit483ef3a0d2a6c097ca1606c5cb4a0fae8f3d4f43 (patch)
treec15ef85c345730a0e8e55e965e680baebd745fd4 /test/ruby
parentf42535fa38ff487382db32158908635e1a356d5c (diff)
Test test_remove_instance_variable_re_embed separately
Shape tree pollution could cause this test to flake.
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_object.rb63
1 files changed, 32 insertions, 31 deletions
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb
index 41585ba150..f4dfe2251b 100644
--- a/test/ruby/test_object.rb
+++ b/test/ruby/test_object.rb
@@ -356,40 +356,41 @@ class TestObject < Test::Unit::TestCase
end
def test_remove_instance_variable_re_embed
- require "objspace"
+ assert_separately(%w[-robjspace], "#{<<~"begin;"}\n#{<<~'end;'}")
+ begin;
+ c = Class.new do
+ attr_reader :a, :b, :c
- c = Class.new do
- attr_reader :a, :b, :c
-
- def initialize
- @a = nil
- @b = nil
- @c = nil
+ def initialize
+ @a = nil
+ @b = nil
+ @c = nil
+ end
end
- end
- o1 = c.new
- o2 = c.new
-
- o1.instance_variable_set(:@foo, 5)
- o1.instance_variable_set(:@a, 0)
- o1.instance_variable_set(:@b, 1)
- o1.instance_variable_set(:@c, 2)
- refute_includes ObjectSpace.dump(o1), '"embedded":true'
- o1.remove_instance_variable(:@foo)
- assert_includes ObjectSpace.dump(o1), '"embedded":true'
-
- o2.instance_variable_set(:@a, 0)
- o2.instance_variable_set(:@b, 1)
- o2.instance_variable_set(:@c, 2)
- assert_includes ObjectSpace.dump(o2), '"embedded":true'
-
- assert_equal(0, o1.a)
- assert_equal(1, o1.b)
- assert_equal(2, o1.c)
- assert_equal(0, o2.a)
- assert_equal(1, o2.b)
- assert_equal(2, o2.c)
+ o1 = c.new
+ o2 = c.new
+
+ o1.instance_variable_set(:@foo, 5)
+ o1.instance_variable_set(:@a, 0)
+ o1.instance_variable_set(:@b, 1)
+ o1.instance_variable_set(:@c, 2)
+ refute_includes ObjectSpace.dump(o1), '"embedded":true'
+ o1.remove_instance_variable(:@foo)
+ assert_includes ObjectSpace.dump(o1), '"embedded":true'
+
+ o2.instance_variable_set(:@a, 0)
+ o2.instance_variable_set(:@b, 1)
+ o2.instance_variable_set(:@c, 2)
+ assert_includes ObjectSpace.dump(o2), '"embedded":true'
+
+ assert_equal(0, o1.a)
+ assert_equal(1, o1.b)
+ assert_equal(2, o1.c)
+ assert_equal(0, o2.a)
+ assert_equal(1, o2.b)
+ assert_equal(2, o2.c)
+ end;
end
def test_convert_string