Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Array#{rotate, rotate!} raises a TypeError if not passed an integer a…

…rgument
  • Loading branch information...
commit f66a573c2c90188aeaab9fffff42675a09c79fdf 1 parent 7a854cb
@Watson1978 Watson1978 authored
Showing with 9 additions and 10 deletions.
  1. +9 −8 array.c
  2. +0 −2  spec/frozen/tags/macruby/core/array/rotate_tags.txt
View
17 array.c
@@ -1396,13 +1396,14 @@ ary_rotate(VALUE ary, long cnt)
VALUE
rary_rotate_bang(VALUE ary, SEL sel, int argc, VALUE *argv)
{
- VALUE n;
long cnt = 1;
- rb_scan_args(argc, argv, "01", &n);
- if (!NIL_P(n)) {
- cnt = NUM2LONG(n);
+ switch (argc) {
+ case 1: cnt = NUM2LONG(argv[0]);
+ case 0: break;
+ default: rb_scan_args(argc, argv, "01", NULL);
}
+
rb_ary_modify(ary);
ary_rotate(ary, cnt);
return ary;
@@ -1427,12 +1428,12 @@ VALUE
rary_rotate(VALUE ary, SEL sel, int argc, VALUE *argv)
{
VALUE rotated;
- VALUE n;
long cnt = 1;
- rb_scan_args(argc, argv, "01", &n);
- if (!NIL_P(n)) {
- cnt = NUM2LONG(n);
+ switch (argc) {
+ case 1: cnt = NUM2LONG(argv[0]);
+ case 0: break;
+ default: rb_scan_args(argc, argv, "01", NULL);
}
rotated = rb_ary_dup(ary);
View
2  spec/frozen/tags/macruby/core/array/rotate_tags.txt
@@ -1,2 +0,0 @@
-fails:Array#rotate with an argument n raises a TypeError if not passed an integer-like argument
-fails:Array#rotate! with an argument n raises a TypeError if not passed an integer-like argument
Please sign in to comment.
Something went wrong with that request. Please try again.