Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add spec for TRUE/FALSE/NIL constants that are no longer defined #853

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion language/predefined_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,8 @@ def obj.foo2; yield; end
DATA IO If the main program file contains the directive __END__, then
the constant DATA will be initialized so that reading from it will
return lines following __END__ from the source file.
FALSE FalseClass Synonym for false (deprecated, removed in Ruby 3).
NIL NilClass Synonym for nil (deprecated, removed in Ruby 3).
RUBY_PLATFORM String The identifier of the platform running this program. This string
is in the same form as the platform identifier used by the GNU
configure utility (which is not a coincidence).
Expand All @@ -1116,9 +1118,55 @@ def obj.foo2; yield; end
the value.
TOPLEVEL_BINDING Binding A Binding object representing the binding at Ruby’s top level—
the level where programs are initially executed.
TRUE TrueClass Synonym for true (deprecated, removed in Ruby 3).
=end

describe "The predefined global constants" do
describe "TRUE" do
ruby_version_is "3.0" do
it "is no longer defined" do
Object.const_defined?(:TRUE).should == false
end
end

ruby_version_is ""..."3.0" do
it "includes TRUE" do
Object.const_defined?(:TRUE).should == true
-> { TRUE }.should complain(/constant ::TRUE is deprecated/)
end
end
end

describe "FALSE" do
ruby_version_is "3.0" do
it "is no longer defined" do
Object.const_defined?(:FALSE).should == false
end
end

ruby_version_is ""..."3.0" do
it "includes FALSE" do
Object.const_defined?(:FALSE).should == true
-> { FALSE }.should complain(/constant ::FALSE is deprecated/)
end
end
end

describe "NIL" do
ruby_version_is "3.0" do
it "is no longer defined" do
Object.const_defined?(:NIL).should == false
end
end

ruby_version_is ""..."3.0" do
it "includes NIL" do
Object.const_defined?(:NIL).should == true
-> { NIL }.should complain(/constant ::NIL is deprecated/)
end
end
end

it "includes STDIN" do
Object.const_defined?(:STDIN).should == true
end
Expand Down Expand Up @@ -1146,7 +1194,6 @@ def obj.foo2; yield; end
it "includes TOPLEVEL_BINDING" do
Object.const_defined?(:TOPLEVEL_BINDING).should == true
end

end

describe "The predefined global constant" do
Expand Down