[macruby-changes] [5254] MacRuby/trunk/array.c

source_changes at macosforge.org source_changes at macosforge.org
Sat Mar 5 06:09:58 PST 2011


Revision: 5254
          http://trac.macosforge.org/projects/ruby/changeset/5254
Author:   watson1978 at 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:
--------------
    MacRuby/trunk/array.c

Modified: MacRuby/trunk/array.c
===================================================================
--- 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);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20110305/d5b798ea/attachment.html>


More information about the macruby-changes mailing list