summaryrefslogtreecommitdiff
path: root/sample/test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'sample/test.rb')
-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