aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-17 09:28:58 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-17 09:28:58 +0000
commitbeef21384ca6357a41e31b4ae96206e39c784af7 (patch)
tree16638d73ac6d58aad35629be0eb0c03aa6b3894d /test/ruby
parent82839e18cc99457db60220b0c19a3f120258750e (diff)
downloadruby-beef21384ca6357a41e31b4ae96206e39c784af7.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.rb15
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'