1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Alias Set#to_s to #inspect [ruby-core:81753] [Feature #13676]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2017-07-14 08:46:13 +00:00
parent cb1d634d6a
commit d893c123f6
3 changed files with 16 additions and 0 deletions

3
NEWS
View file

@ -110,6 +110,9 @@ with all sufficient information, see the ChangeLog file or Redmine
* Carriage returns are changed to be trimmed properly if trim_mode is specified
and used. Duplicated newlines will be removed on Windows. [Bug #5339] [Bug #11464]
* Set
* Add Set#to_s as alias to #inspect [Feature #13676]
* WEBrick
* Add Server Name Indication (SNI) support [Feature #13729]

View file

@ -569,6 +569,8 @@ class Set
end
end
alias to_s inspect
def pretty_print(pp) # :nodoc:
pp.text sprintf('#<%s: {', self.class.name)
pp.nest(1) {

View file

@ -715,6 +715,17 @@ class TC_Set < Test::Unit::TestCase
assert_equal('#<Set: {#<Set: {0}>, 1, 2, #<Set: {1, 2, #<Set: {...}>}>}>', set2.inspect)
end
def test_to_s
set1 = Set[1, 2]
assert_equal('#<Set: {1, 2}>', set1.to_s)
set2 = Set[Set[0], 1, 2, set1]
assert_equal('#<Set: {#<Set: {0}>, 1, 2, #<Set: {1, 2}>}>', set2.to_s)
set1.add(set2)
assert_equal('#<Set: {#<Set: {0}>, 1, 2, #<Set: {1, 2, #<Set: {...}>}>}>', set2.to_s)
end
def test_compare_by_identity
a1, a2 = "a", "a"
b1, b2 = "b", "b"