ruby-changes:51487
From: nobu <ko1@a...>
Date: Tue, 19 Jun 2018 17:45:23 +0900 (JST)
Subject: [ruby-changes:51487] nobu:r63697 (trunk): describe about NameError by #private_constant
nobu 2018-06-19 17:45:17 +0900 (Tue, 19 Jun 2018) New Revision: 63697 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63697 Log: describe about NameError by #private_constant Modified files: trunk/spec/ruby/language/constants_spec.rb Index: spec/ruby/language/constants_spec.rb =================================================================== --- spec/ruby/language/constants_spec.rb (revision 63696) +++ spec/ruby/language/constants_spec.rb (revision 63697) @@ -613,6 +613,41 @@ describe "Module#private_constant marked https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/constants_spec.rb#L613 defined?(PRIVATE_CONSTANT_IN_OBJECT).should == "constant" end end + + describe "NameError by #private_constant" do + it "has :receiver and :name attributes" do + lambda do + ConstantVisibility::PrivConstClass::PRIVATE_CONSTANT_CLASS + end.should raise_error(NameError) {|e| + e.receiver.should == ConstantVisibility::PrivConstClass + e.name.should == :PRIVATE_CONSTANT_CLASS + } + + lambda do + ConstantVisibility::PrivConstModule::PRIVATE_CONSTANT_MODULE + end.should raise_error(NameError) {|e| + e.receiver.should == ConstantVisibility::PrivConstModule + e.name.should == :PRIVATE_CONSTANT_MODULE + } + end + + it "has the defined class as the :name attribute" do + exception = nil + lambda do + ConstantVisibility::PrivConstClassChild::PRIVATE_CONSTANT_CLASS + end.should raise_error(NameError) {|e| + e.receiver.should == ConstantVisibility::PrivConstClass + e.name.should == :PRIVATE_CONSTANT_CLASS + } + + lambda do + ConstantVisibility::PrivConstModuleChild::PRIVATE_CONSTANT_MODULE + end.should raise_error(NameError) {|e| + e.receiver.should == ConstantVisibility::PrivConstModule + e.name.should == :PRIVATE_CONSTANT_MODULE + } + end + end end describe "Module#public_constant marked constants" do -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/