Skip to content

Commit

Permalink
Alias Set#to_s to inspect
Browse files Browse the repository at this point in the history
to support Ruby 2.5 and stated in this feature https://bugs.ruby-lang.org/issues/13676.
ruby/ruby@d893c12.
jruby#4876.
  • Loading branch information
ChrisBr committed Jan 7, 2018
1 parent b9c1195 commit 0cefb4c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ext/set/RubySet.java
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ public final IRubyObject inspect() {

// Returns a string containing a human-readable representation of the set.
// e.g. "#<Set: {element1, element2, ...}>"
@JRubyMethod(name = "inspect")
@JRubyMethod(name = "inspect", alias = "to_s")
public RubyString inspect(ThreadContext context) {
final Ruby runtime = context.runtime;

Expand Down
13 changes: 13 additions & 0 deletions spec/ruby/core/set/to_s_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require File.expand_path('../shared/inspect', __FILE__)
require 'set'

ruby_version_is "2.5" do
describe "Set#to_s" do
it_behaves_like :set_inspect, :to_s

it "is an alias of inspect" do
set = Set.new
set.method(:to_s).should == set.method(:inspect)
end
end
end

0 comments on commit 0cefb4c

Please sign in to comment.