From cd339692eff0568d15b8971738d2e35610d1ae8b Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 11 Feb 2012 03:04:23 +0000 Subject: * compile.c (defined_expr): guard the whole expression. [ruby-dev:45021][Bug#5786] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_defined.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_defined.rb b/test/ruby/test_defined.rb index bae85c9265..2552626b9e 100644 --- a/test/ruby/test_defined.rb +++ b/test/ruby/test_defined.rb @@ -113,15 +113,27 @@ class TestDefined < Test::Unit::TestCase def a? defined?(A) end + def b? + defined?(A::B) + end end def test_autoloaded_noload loaded = $".dup $".clear + loadpath = $:.dup + $:.clear x = TestAutoloadedNoload.new assert_equal("constant", x.a?) + assert_nil(x.b?) assert_equal([], $") ensure $".replace(loaded) + $:.replace(loadpath) + end + + def test_exception + bug5786 = '[ruby-dev:45021]' + assert_nil(defined?(raise("[Bug#5786]")::A), bug5786) end end -- cgit v1.2.3