From b5604833a37bf8cac132906fbf8297d6d4ae9976 Mon Sep 17 00:00:00 2001 From: Gil Desmarais Date: Thu, 11 Dec 2025 17:38:39 +0100 Subject: Fix Set#^ to not mutate its argument (#15296) * test(set): add test Set#xor does not mutate other_set * Fix Set#^ to not mutate its argument --- test/ruby/test_set.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_set.rb b/test/ruby/test_set.rb index 6dec0d41ae..e8ac3e329e 100644 --- a/test/ruby/test_set.rb +++ b/test/ruby/test_set.rb @@ -703,6 +703,17 @@ class TC_Set < Test::Unit::TestCase } end + def test_xor_does_not_mutate_other_set + a = Set[1] + b = Set[1, 2] + original_b = b.dup + + result = a ^ b + + assert_equal(original_b, b) + assert_equal(Set[2], result) + end + def test_eq set1 = Set[2,3,1] set2 = Set[1,2,3] -- cgit v1.2.3