Skip to content

Commit

Permalink
Removed NIL/TRUE/FALSE
Browse files Browse the repository at this point in the history
Deprerecated constants which had been warned since 2.4.
  • Loading branch information
nobu committed Apr 17, 2020
1 parent 3152977 commit 62554ca
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 39 deletions.
15 changes: 0 additions & 15 deletions object.c
Expand Up @@ -4692,11 +4692,6 @@ InitVM_Object(void)
rb_define_method(rb_cNilClass, "nil?", rb_true, 0);
rb_undef_alloc_func(rb_cNilClass);
rb_undef_method(CLASS_OF(rb_cNilClass), "new");
/*
* An obsolete alias of +nil+
*/
rb_define_global_const("NIL", Qnil);
rb_deprecate_constant(rb_cObject, "NIL");

rb_define_method(rb_cModule, "freeze", rb_mod_freeze, 0);
rb_define_method(rb_cModule, "===", rb_mod_eqq, 1);
Expand Down Expand Up @@ -4781,11 +4776,6 @@ InitVM_Object(void)
rb_define_method(rb_cTrueClass, "===", rb_equal, 1);
rb_undef_alloc_func(rb_cTrueClass);
rb_undef_method(CLASS_OF(rb_cTrueClass), "new");
/*
* An obsolete alias of +true+
*/
rb_define_global_const("TRUE", Qtrue);
rb_deprecate_constant(rb_cObject, "TRUE");

rb_cFalseClass = rb_define_class("FalseClass", rb_cObject);
rb_cFalseClass_to_s = rb_fstring_enc_lit("false", rb_usascii_encoding());
Expand All @@ -4798,11 +4788,6 @@ InitVM_Object(void)
rb_define_method(rb_cFalseClass, "===", rb_equal, 1);
rb_undef_alloc_func(rb_cFalseClass);
rb_undef_method(CLASS_OF(rb_cFalseClass), "new");
/*
* An obsolete alias of +false+
*/
rb_define_global_const("FALSE", Qfalse);
rb_deprecate_constant(rb_cObject, "FALSE");
}

#include "kernel.rbinc"
Expand Down
24 changes: 0 additions & 24 deletions spec/ruby/language/predefined_spec.rb
Expand Up @@ -1091,8 +1091,6 @@ 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.
NIL NilClass Synonym for nil.
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 @@ -1110,31 +1108,9 @@ 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.
=end

describe "The predefined global constants" do
it "includes TRUE" do
Object.const_defined?(:TRUE).should == true
-> {
TRUE.should equal(true)
}.should complain(/constant ::TRUE is deprecated/)
end

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

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

it "includes STDIN" do
Object.const_defined?(:STDIN).should == true
end
Expand Down

0 comments on commit 62554ca

Please sign in to comment.