aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_symbol.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_symbol.rb')
-rw-r--r--test/ruby/test_symbol.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb
index 66c62cb298..0a055db2c9 100644
--- a/test/ruby/test_symbol.rb
+++ b/test/ruby/test_symbol.rb
@@ -199,6 +199,35 @@ class TestSymbol < Test::Unit::TestCase
assert_raise(TypeError) { a = :foo; def a.foo; end }
end
+ SymbolsForEval = [
+ :foo,
+ "dynsym_#{Random.rand(10000)}_#{Time.now}".to_sym
+ ]
+
+ def test_instance_eval
+ bug11086 = '[ruby-core:68961] [Bug #11086]'
+ SymbolsForEval.each do |sym|
+ assert_nothing_raised(TypeError, sym, bug11086) {
+ sym.instance_eval {}
+ }
+ assert_raise(TypeError, sym, bug11086) {
+ sym.instance_eval {def foo; end}
+ }
+ end
+ end
+
+ def test_instance_exec
+ bug11086 = '[ruby-core:68961] [Bug #11086]'
+ SymbolsForEval.each do |sym|
+ assert_nothing_raised(TypeError, sym, bug11086) {
+ sym.instance_exec {}
+ }
+ assert_raise(TypeError, sym, bug11086) {
+ sym.instance_exec {def foo; end}
+ }
+ end
+ end
+
def test_frozen_symbol
assert_equal(true, :foo.frozen?)
assert_equal(true, :each.frozen?)