1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/spec/ruby/language/fixtures/constant_visibility.rb
eregon 1d15d5f080 Move spec/rubyspec to spec/ruby for consistency
* Other ruby implementations use the spec/ruby directory.
  [Misc #13792] [ruby-core:82287]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-20 20:18:52 +00:00

98 lines
1.9 KiB
Ruby

module ConstantVisibility
module ModuleContainer
module PrivateModule
end
private_constant :PrivateModule
class PrivateClass
end
private_constant :PrivateClass
end
class ClassContainer
module PrivateModule
end
private_constant :PrivateModule
class PrivateClass
end
private_constant :PrivateClass
end
module PrivConstModule
PRIVATE_CONSTANT_MODULE = true
private_constant :PRIVATE_CONSTANT_MODULE
def self.private_constant_from_self
PRIVATE_CONSTANT_MODULE
end
def self.defined_from_self
defined? PRIVATE_CONSTANT_MODULE
end
module Nested
def self.private_constant_from_scope
PRIVATE_CONSTANT_MODULE
end
def self.defined_from_scope
defined? PRIVATE_CONSTANT_MODULE
end
end
end
class PrivConstClass
PRIVATE_CONSTANT_CLASS = true
private_constant :PRIVATE_CONSTANT_CLASS
def self.private_constant_from_self
PRIVATE_CONSTANT_CLASS
end
def self.defined_from_self
defined? PRIVATE_CONSTANT_CLASS
end
module Nested
def self.private_constant_from_scope
PRIVATE_CONSTANT_CLASS
end
def self.defined_from_scope
defined? PRIVATE_CONSTANT_CLASS
end
end
end
class PrivConstModuleChild
include PrivConstModule
def private_constant_from_include
PRIVATE_CONSTANT_MODULE
end
def defined_from_include
defined? PRIVATE_CONSTANT_MODULE
end
end
class PrivConstClassChild < PrivConstClass
def private_constant_from_subclass
PRIVATE_CONSTANT_CLASS
end
def defined_from_subclass
defined? PRIVATE_CONSTANT_CLASS
end
end
def self.reset_private_constants
Object.send :private_constant, :PRIVATE_CONSTANT_IN_OBJECT
end
end
class Object
PRIVATE_CONSTANT_IN_OBJECT = true
private_constant :PRIVATE_CONSTANT_IN_OBJECT
end