mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parent
d7406ccc2c
commit
eb67c603ca
Notes:
git
2020-09-04 22:19:24 +09:00
Merged: https://github.com/ruby/ruby/pull/3514 Merged-By: nobu <nobu@ruby-lang.org>
3 changed files with 14 additions and 0 deletions
7
NEWS.md
7
NEWS.md
|
@ -165,6 +165,12 @@ Outstanding ones only.
|
|||
* Symbol#to_proc now returns a lambda Proc.
|
||||
[[Feature #16260]]
|
||||
|
||||
* New method
|
||||
|
||||
* Symbol#name, which returns the name of the symbol if it is
|
||||
named. The returned string cannot be modified.
|
||||
[[Feature #16150]]
|
||||
|
||||
* Warning
|
||||
|
||||
* Modified method
|
||||
|
@ -343,6 +349,7 @@ Excluding feature bug fixes.
|
|||
[Feature #16378]: https://bugs.ruby-lang.org/issues/16378
|
||||
[Feature #16828]: https://bugs.ruby-lang.org/issues/16828
|
||||
[Bug #14541]: https://bugs.ruby-lang.org/issues/14541
|
||||
[Feature #16150]: https://bugs.ruby-lang.org/issues/16150
|
||||
[Feature #16175]: https://bugs.ruby-lang.org/issues/16175
|
||||
[Feature #15973]: https://bugs.ruby-lang.org/issues/15973
|
||||
[Feature #16614]: https://bugs.ruby-lang.org/issues/16614
|
||||
|
|
1
string.c
1
string.c
|
@ -11539,6 +11539,7 @@ Init_String(void)
|
|||
rb_define_method(rb_cSymbol, "inspect", sym_inspect, 0);
|
||||
rb_define_method(rb_cSymbol, "to_s", rb_sym_to_s, 0);
|
||||
rb_define_method(rb_cSymbol, "id2name", rb_sym_to_s, 0);
|
||||
rb_define_method(rb_cSymbol, "name", rb_sym2str, 0);
|
||||
rb_define_method(rb_cSymbol, "intern", sym_to_sym, 0);
|
||||
rb_define_method(rb_cSymbol, "to_sym", sym_to_sym, 0);
|
||||
rb_define_method(rb_cSymbol, "to_proc", rb_sym_to_proc, 0);
|
||||
|
|
|
@ -105,6 +105,12 @@ class TestSymbol < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_name
|
||||
assert_equal("foo", :foo.name)
|
||||
assert_same(:foo.name, :foo.name)
|
||||
assert_predicate(:foo.name, :frozen?)
|
||||
end
|
||||
|
||||
def test_to_proc
|
||||
assert_equal %w(1 2 3), (1..3).map(&:to_s)
|
||||
[
|
||||
|
|
Loading…
Add table
Reference in a new issue