Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Symbol#inspect of UTF_16/UTF_32 #4994

Merged
merged 1 commit into from
Jan 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions core/src/main/java/org/jruby/RubySymbol.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,27 +256,22 @@ public IRubyObject inspect(ThreadContext context) {
}

final RubyString inspect(final Ruby runtime) {
ByteList result = new ByteList(symbolBytes.getRealSize() + 1);
result.setEncoding(symbolBytes.getEncoding());
result.append((byte)':');
result.append(symbolBytes);

// TODO: 1.9 rb_enc_symname_p
Encoding resenc = runtime.getDefaultInternalEncoding();
if (resenc == null) resenc = runtime.getDefaultExternalEncoding();

RubyString str = RubyString.newString(runtime, result);
RubyString str = RubyString.newString(runtime, symbolBytes);

if (isPrintable() && (resenc.equals(symbolBytes.getEncoding()) || str.isAsciiOnly()) && isSymbolName19(symbol)) {
return str;
if (!(isPrintable() && (resenc.equals(symbolBytes.getEncoding()) || str.isAsciiOnly()) && isSymbolName19(symbol))) {
str = str.inspect(runtime);
}

str = str.inspect(runtime);
ByteList bytes = str.getByteList();
bytes.set(0, ':');
bytes.set(1, '"');
ByteList result = new ByteList(str.getByteList().getRealSize() + 1);
result.setEncoding(str.getEncoding());
result.append((byte)':');
result.append(str.getBytes());

return str;
return RubyString.newString(runtime, result);
}

@Deprecated
Expand Down
1 change: 0 additions & 1 deletion test/mri/excludes/TestSymbol.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
exclude :test_ascii_incomat_inspect, "needs investigation"
exclude :test_inspect, "needs investigation"
exclude :test_to_proc_arg, "we have plans to do different caching here, see 69662ab8cd1616a2ee076488226a473648fc6267"
exclude :test_to_proc_binding, "needs investigation #4303"
Expand Down