aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-25 16:34:00 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-25 16:34:00 +0000
commit0b5685a69b4203367d6145cdcf37914f54573012 (patch)
treeb16bf7b52747aa21ce52d1112666cec85ca425bc /test
parent4f180097d31c3532455366a23fe5830b32f5eb0a (diff)
downloadruby-0b5685a69b4203367d6145cdcf37914f54573012.tar.gz
* string.c (sym_find): Add Symbol.find(str), which returns whether given
string is defined as symbol or not. [Feature #7854] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_symbol.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb
index 7f261b68bb..70358ea1bc 100644
--- a/test/ruby/test_symbol.rb
+++ b/test/ruby/test_symbol.rb
@@ -1,4 +1,5 @@
require 'test/unit'
+require_relative 'envutil'
class TestSymbol < Test::Unit::TestCase
# [ruby-core:3573]
@@ -206,4 +207,18 @@ class TestSymbol < Test::Unit::TestCase
assert_equal(true, "foo#{Time.now.to_i}".to_sym.frozen?)
assert_equal(true, :foo.to_sym.frozen?)
end
+
+ def test_sym_find
+ assert_separately(%w[--disable=gems], <<-"end;")
+ assert_equal :intern, Symbol.find("intern")
+ assert_raise(TypeError){ Symbol.find(true) }
+
+ str = "__noexistent__"
+ assert_equal nil, Symbol.find(str)
+ assert_equal nil, Symbol.find(str)
+ sym = str.intern
+ assert_equal str, sym.to_s
+ assert_equal sym, Symbol.find(str)
+ end;
+ end
end