From c0a636b6f94d7f95ed95a7abf7c2936bbd3fc5a7 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 16 Jan 2002 09:25:59 +0000 Subject: * st.c: primes should be primes. * eval.c (is_defined): method defined? check should honor protected too. * eval.c (block_pass): should not pass tainted block, if $SAFE > 0. * variable.c (rb_mod_remove_cvar): should pass the char*. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- sample/test.rb | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'sample/test.rb') diff --git a/sample/test.rb b/sample/test.rb index 7022b4de98..fc2eb5ae0f 100644 --- a/sample/test.rb +++ b/sample/test.rb @@ -1313,17 +1313,31 @@ test_ok(defined?($x) == 'global-variable')# returns description foo=5 test_ok(defined?(foo)) # local variable -test_ok(defined?(Array)) # constant +test_ok(defined?(Array)) # constant test_ok(defined?(Object.new)) # method -test_ok(!defined?(Object.print)) # private method -test_ok(defined?(1 == 2)) # operator expression +test_ok(!defined?(Object.print))# private method +test_ok(defined?(1 == 2)) # operator expression + +class Foo + def foo + p :foo + end + protected :foo + def bar(f) + test_ok(defined?(self.foo)) + test_ok(defined?(f.foo)) + end +end +f = Foo.new +test_ok(defined?(f.foo) == nil) +f.bar(f) def defined_test return !defined?(yield) end test_ok(defined_test) # not iterator -test_ok(!defined_test{}) # called as iterator +test_ok(!defined_test{}) # called as iterator test_check "alias" class Alias0 -- cgit v1.2.3