summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-01-16 09:25:59 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-01-16 09:25:59 +0000
commitc0a636b6f94d7f95ed95a7abf7c2936bbd3fc5a7 (patch)
tree55cf5527b0186a806844bf63754fd6e27cebd45e /sample
parent17e1cfef8cae430ecce87ea3338b29992bd12665 (diff)
* 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
Diffstat (limited to 'sample')
-rw-r--r--sample/test.rb22
1 files changed, 18 insertions, 4 deletions
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