diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-29 16:08:16 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-29 16:08:16 +0000 |
commit | 3fa5bd38af50fb3d98de0ea51043d73f8d06a24b (patch) | |
tree | d473b71cc6925ee1e17727215e9f9a66e3f24802 /spec/ruby/language/defined_spec.rb | |
parent | 1e658d45e1f8dbadab18f9c35b5cfb5a5fec98bf (diff) | |
download | ruby-3fa5bd38af50fb3d98de0ea51043d73f8d06a24b.tar.gz |
Update to ruby/spec@83063a3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/language/defined_spec.rb')
-rw-r--r-- | spec/ruby/language/defined_spec.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/spec/ruby/language/defined_spec.rb b/spec/ruby/language/defined_spec.rb index 08fa2d8fe3..98f4ee8829 100644 --- a/spec/ruby/language/defined_spec.rb +++ b/spec/ruby/language/defined_spec.rb @@ -505,6 +505,10 @@ describe "The defined? keyword for variables" do DefinedSpecs::Basic.new.global_variable_read.should be_nil end + it "returns 'global-variable' for a global variable that has been assigned nil" do + DefinedSpecs::Basic.new.global_variable_defined_as_nil.should == "global-variable" + end + # MRI appears to special case defined? for $! and $~ in that it returns # 'global-variable' even when they are not set (or they are always "set" # but the value may be nil). In other words, 'defined?($~)' will return @@ -752,8 +756,16 @@ describe "The defined? keyword for a scoped constant" do defined?(DefinedSpecs::String).should be_nil end - it "returns nil when a constant is defined on top-level but not on the class" do - defined?(DefinedSpecs::Basic::String).should be_nil + ruby_version_is ""..."2.6" do + it "returns 'constant' when a constant is defined on top-level but not on the class" do + defined?(DefinedSpecs::Basic::String).should == 'constant' + end + end + + ruby_version_is "2.6" do + it "returns nil when a constant is defined on top-level but not on the class" do + defined?(DefinedSpecs::Basic::String).should be_nil + end end it "returns 'constant' if the scoped-scoped constant is defined" do |