Array#replace will raise RuntimeError when was frozen object.
Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions
a = [ 1, 2, 3].freeze
assert_raise(RuntimeError){ a.replace(42) }
puts :ok
}}}
--- MacRuby/trunk/array.c 2011-02-26 01:27:10 UTC (rev 5248)
+++ MacRuby/trunk/array.c 2011-03-04 07:40:52 UTC (rev 5249)
@@ -2170,8 +2170,8 @@
static VALUE
rary_replace(VALUE rcv, SEL sel, VALUE other)
{
+ rary_modify(rcv);
other = to_ary(other);
- rary_modify(rcv);
rary_remove_all(RARY(rcv));
rary_concat(rcv, other, 0, RARRAY_LEN(other));
return rcv;