Skip to content

Commit

Permalink
GH-1551 - Adding regression specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasallan committed Apr 21, 2014
1 parent 8cd70f6 commit 05865c1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/RubyFixnum.java
Expand Up @@ -300,7 +300,8 @@ public RubyString to_s(IRubyObject[] args) {
@JRubyMethod
@Override
public RubyString to_s() {
RubyString str = getRuntime().newString(String.valueOf(value));
ByteList bl = ConvertBytes.longToByteList(value, 10);
RubyString str = getRuntime().newString(bl);
if (getRuntime().is1_9()) str.setEncoding(USASCIIEncoding.INSTANCE);
return str;
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/ConvertBytes.java
Expand Up @@ -138,7 +138,7 @@ public static final ByteList longToByteList(long i, int radix, byte[] digitmap)
} while ((i /= radix) > 0);
if (neg) buf[--pos] = (byte)'-';

return new ByteList(buf, pos, len - pos, false);
return new ByteList(buf, pos, len - pos);
}

private static final ByteList intToUnsignedByteList(int i, int shift, byte[] digitmap) {
Expand Down
@@ -0,0 +1,8 @@
describe "Fixnum#to_s" do
it "returns muttable string" do
str = 100.to_s
str.should == '100'
str[0] = '2'
str.should == '200'
end
end

0 comments on commit 05865c1

Please sign in to comment.