aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_array.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_array.rb')
-rw-r--r--test/ruby/test_array.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index 8a8af491c9..49628215b5 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -1378,6 +1378,22 @@ class TestArray < Test::Unit::TestCase
end
end
+ def test_sort_bang_with_freeze
+ ary = []
+ o1 = Object.new
+ o1.singleton_class.class_eval {
+ define_method(:<=>) {|v|
+ ary.freeze
+ 1
+ }
+ }
+ o2 = o1.dup
+ ary << o1 << o2
+ orig = ary.dup
+ assert_raise(RuntimeError, "frozen during comparison") {ary.sort!}
+ assert_equal(orig, ary, "must not be modified once frozen")
+ end
+
def test_to_a
a = @cls[ 1, 2, 3 ]
a_id = a.__id__