Skip to content

Commit

Permalink
Last typeerror string mismatches for %c fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
enebo committed Nov 2, 2023
1 parent d1ea659 commit 1c29bb7
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 15 deletions.
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/RubyNumeric.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ private static long other2long(IRubyObject arg) throws RaiseException {
if (arg.isNil()) {
throw arg.getRuntime().newTypeError("no implicit conversion from nil to integer");
}
return arg.convertToInteger().getLongValue();

return ((RubyInteger) TypeConverter.convertToType(arg, arg.getRuntime().getInteger(), "to_int")).getLongValue();
}

public static long float2long(RubyFloat flt) {
Expand Down
4 changes: 1 addition & 3 deletions core/src/main/java/org/jruby/util/Sprintf.java
Original file line number Diff line number Diff line change
Expand Up @@ -611,9 +611,7 @@ private static void rubySprintfToBuffer(final ByteList buf, final CharSequence c
n = StringSupport.codeLength(bl.getEncoding(), c);
}
else {
// unsigned bits
RubyInteger intValue = (RubyInteger) TypeConverter.convertToType(arg, runtime.getInteger(), "to_int");
c = (int) intValue.getLongValue() & 0xFFFFFFFF;
c = (int) RubyNumeric.num2long(arg) & 0xFFFFFFFF;
try {
n = StringSupport.codeLength(encoding, c);
} catch (EncodingException e) {
Expand Down
5 changes: 0 additions & 5 deletions spec/tags/ruby/core/file/printf_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/tags/ruby/core/kernel/printf_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/tags/ruby/core/kernel/sprintf_tags.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
fails(compiler):Kernel#sprintf passes some tests for negative %u
fails:Kernel#sprintf other formats c raises TypeError if argument is nil
fails:Kernel.sprintf other formats c raises TypeError if argument is nil
fails:Kernel#sprintf %c raises error when a codepoint isn't representable in an encoding of a format string
fails:Kernel.sprintf %c raises error when a codepoint isn't representable in an encoding of a format string
1 change: 0 additions & 1 deletion spec/tags/ruby/core/string/modulo_tags.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
fails:String#% other formats c raises TypeError if argument is nil
fails:String#% %c raises error when a codepoint isn't representable in an encoding of a format string
1 change: 0 additions & 1 deletion spec/tags/ruby/library/stringio/printf_tags.txt

This file was deleted.

0 comments on commit 1c29bb7

Please sign in to comment.