Permalink
Browse files

Added sanity checks for type and frozen.

Fixes tests:

String#setbyte raises a TypeError unless the second argument is an Integer FAILED
String#setbyte raises a RuntimeError if self is frozen FAILED
  • Loading branch information...
1 parent f055fc1 commit 382c7ae9c6db7c851d78d2191ea0108eb34090a1 @carsonmcdonald carsonmcdonald committed Oct 17, 2011
Showing with 4 additions and 0 deletions.
  1. +4 −0 kernel/common/string.rb
View
@@ -1405,6 +1405,10 @@ def scan(pattern)
# This method is specifically part of 1.9 but we enable it in 1.8 also
# because we need it internally.
def setbyte(index, byte)
+ raise TypeError, "can't convert #{byte.class} into Integer" unless byte.instance_of?(Fixnum)
+
+ Rubinius.check_frozen
+
index = size + index if index < 0
@data[index] = byte
end

0 comments on commit 382c7ae

Please sign in to comment.