diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-17 09:28:58 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-17 09:28:58 +0000 |
commit | df33c063fccf1bca9e7d67140b2950e1b434d9b4 (patch) | |
tree | 16638d73ac6d58aad35629be0eb0c03aa6b3894d /test/ruby | |
parent | 08bb3640d750980b634e93972ed3761582f8e364 (diff) | |
download | ruby-df33c063fccf1bca9e7d67140b2950e1b434d9b4.tar.gz |
literal symbol by intern
* compile.c (iseq_compile_each0): literal symbol should not be
affected by redefinition of String#intern method.
* vm_insnhelper.c (rb_vm_str_intern): intern a string into a
symbol directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_literal.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb index 4a447d59fc..9645e3234b 100644 --- a/test/ruby/test_literal.rb +++ b/test/ruby/test_literal.rb @@ -119,6 +119,21 @@ class TestRubyLiteral < Test::Unit::TestCase assert_equal :a3c, :"a#{1+2}c" end + def test_dsymbol_redefined_intern + assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") + begin; + class String + alias _intern intern + def intern + "<#{upcase}>" + end + end + mesg = "literal symbol should not be affected by method redefinition" + str = "foo" + assert_equal(:foo, :"#{str}", mesg) + end; + end + def test_xstring assert_equal "foo\n", `echo foo` s = 'foo' |