Revision
5254
Author
watson1978@gmail.com
Date
2011-03-05 06:09:55 -0800 (Sat, 05 Mar 2011)

Log Message

Array#insert will check the number of arguments at the beginning.

Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions

assert_raise(ArgumentError) { [0].freeze.insert }

puts :ok
}}}

Modified Paths

Diff

Modified: MacRuby/trunk/array.c (5253 => 5254)


--- MacRuby/trunk/array.c	2011-03-05 03:05:02 UTC (rev 5253)
+++ MacRuby/trunk/array.c	2011-03-05 14:09:55 UTC (rev 5254)
@@ -1023,13 +1023,13 @@
 static VALUE
 rary_insert_m(VALUE ary, SEL sel, int argc, VALUE *argv)
 {
+    if (argc < 1) {
+	rb_raise(rb_eArgError, "wrong number of arguments (at least 1)");
+    }
     rary_modify(ary);
     if (argc == 1) {
 	return ary;
     }
-    if (argc < 1) {
-	rb_raise(rb_eArgError, "wrong number of arguments (at least 1)");
-    }
     long pos = NUM2LONG(argv[0]);
     if (pos == -1) {
 	pos = RARRAY_LEN(ary);