diff options
| author | Gil Desmarais <gildesmarais@users.noreply.github.com> | 2025-12-11 17:38:39 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-12 01:38:39 +0900 |
| commit | b5604833a37bf8cac132906fbf8297d6d4ae9976 (patch) | |
| tree | 6384e8c560b4b74ce97b150c1862d868985f80c3 /test/ruby | |
| parent | 3831a82d1916025f7dcdebcb9b66a0cd4fc98f00 (diff) | |
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
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_set.rb | 11 |
1 files changed, 11 insertions, 0 deletions
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] |
