diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-15 17:44:37 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-15 17:44:37 +0000 |
commit | 30ed82e7724093bb3c2015a818c28c3592134bba (patch) | |
tree | 5445b9e26d9ee173fa3735007f3e2b42791d2ec5 /spec/ruby/language/constants_spec.rb | |
parent | f941bdf263dcc16ea4e6b4576341882b89567c0b (diff) | |
download | ruby-30ed82e7724093bb3c2015a818c28c3592134bba.tar.gz |
Update to ruby/spec@595645f
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/language/constants_spec.rb')
-rw-r--r-- | spec/ruby/language/constants_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/ruby/language/constants_spec.rb b/spec/ruby/language/constants_spec.rb index 45d87ce52f..1f1e254fb8 100644 --- a/spec/ruby/language/constants_spec.rb +++ b/spec/ruby/language/constants_spec.rb @@ -425,6 +425,28 @@ describe "Constant resolution within a singleton class (class << obj)" do end end +describe "top-level constant lookup" do + context "on a class" do + ruby_version_is "" ... "2.5" do + it "searches Object successfully after searching other scopes" do + ->() { + String::Hash.should == Hash + }.should complain(/toplevel constant Hash referenced by/) + end + end + + ruby_version_is "2.5" do + it "does not search Object after searching other scopes" do + ->() { String::Hash }.should raise_error(NameError) + end + end + end + + it "searches Object unsuccessfully when searches on a module" do + ->() { Enumerable::Hash }.should raise_error(NameError) + end +end + describe "Module#private_constant marked constants" do it "remain private even when updated" do |