summaryrefslogtreecommitdiff
path: root/test/ruby/test_module.rb
AgeCommit message (Collapse)Author
2019-11-20Fix test_module.rbzverok
Notes: Merged: https://github.com/ruby/ruby/pull/2618
2019-10-16Warn for calling public/protected/private/module_function without arguments ↵Jeremy Evans
inside method Calling these methods without an argument does not have the desired effect inside a method. Fixes [Bug #13249] Notes: Merged: https://github.com/ruby/ruby/pull/2562
2019-09-26Fix Module#name news and add a testJean Boussier
Notes: Merged: https://github.com/ruby/ruby/pull/2488
2019-09-20Allow calling a private method with `self.`Dylan Thacker-Smith
This makes it consistent with calling private attribute assignment methods, which currently is allowed (e.g. `self.value =`). Calling a private method in this way can be useful when trying to assign the return value to a local variable with the same name. [Feature #11297] [Feature #16123] Notes: Merged: https://github.com/ruby/ruby/pull/2474
2019-08-29Show the previous definition location,Nobuyoshi Nakada
when reopened class/module redefinition mismatched the previous definition. [Feature #11460]
2019-08-14Don't accidentally name anonymous module/classAlan Wu
b00f280d4b9569e7153365d7e1c522b3d6b3c6cf introduced an accidental behavior change in that defining a module/class under `m` gives `m` a name when `m` is anonymous. `ruby -ve 'Module.new { class self::A; end; p name }'` outputs a name similar to `Module#inspect` when it should output `nil` like in Ruby 2.6.x. * variable.c: Use `make_temporary_path` instead of `save_temporary_path` when getting the name of the parent module. * variable.c (rb_set_class_path): Delegate to `rb_set_class_path_string` instead of duplicating the logic. [Bug #16097] Notes: Merged: https://github.com/ruby/ruby/pull/2337
2019-08-09introduce RCLASS_CLONED flag for inline cache.Koichi Sasada
Methods on duplicated class/module refer same constant inline cache (IC). Constant access lookup should be done for cloned class/modules but inline cache doesn't check it. To check it, this patch introduce new RCLASS_CLONED flag which are set when if class/module is cloned (both orig and dst). [Bug #15877]
2019-08-01Make attr* methods define public methods if self in caller is not same as ↵Jeremy Evans
receiver Previously, attr* methods could be private even if not in the private section of a class/module block. This uses the same approach that ruby started using for define_method in 1fc33199736f316dd71d0c551edbf514528ddde6. Fixes [Bug #4537]
2019-07-14Method#inspect with source location.Koichi Sasada
Method#inspect shows with source location. [Feature #14145]
2019-06-23Module#constant_source_location [Feature #10771]Nobuyoshi Nakada
2019-06-01Fix FrozenError when assigning frozen class to constantNobuyoshi Nakada
* variable.c (set_namespace_path): modules/classes can get named by assignment to constant, even if frozen. [Bug #15891]
2019-04-08object.c: fix searching nested const pathsnobu
* object.c (rb_mod_const_get, rb_mod_const_defined): nested const paths should not search from toplevel constants. [ruby-core:92202] [Bug #15758] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-08test_module.rb: fix a typonobu
* test/ruby/test_module.rb (TestModule#test_nested_get): fix a typo. nested module's name is a qualified path. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-28Fix `Module#const_defined?` on inherited constantsnobu
[Fix GH-2061] From: manga_osyo <manga.osyo@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-08Check by #name [ruby-core:90853] [Bug #15497]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-08Defer escaping control char in error messagesnobu
* eval_error.c (print_errinfo): defer escaping control char in error messages until writing to stderr, instead of quoting at building the message. [ruby-core:90853] [Bug #15497] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-18should use defined_class.ko1
* vm_insnhelper.c (vm_call_method_each_type): we should use me->defined_class instead of me->owner because me->owner doesn't has correct ancestors list. [Bug #15427] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66436 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-13Fix problem about notimplemented caseusa
Re-revert r64340, and take care about notimplemented case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-13Revert "Support optional inherit argument for Module#method_defined?"kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-13Support optional inherit argument for Module#method_defined?usa
Module has many introspection methods for methods and constants that either return an array or return true or false for whether the method or constant is defined. Most of these methods support an optional argument that controls whether to consider inheritance. Currently, the following Module methods support such a argument: * const_defined? * constants * instance_methods * private_instance_methods * protected_instance_methods * public_instance_methods and the following methods do not: * method_defined? * private_method_defined? * protected_method_defined? * public_method_defined? This patch supports such an argument for the *method_defined? methods. While you can currently work around the lack of support via: mod.instance_methods(false).include?(:method_name) This patch allows the simpler and more efficient: mod.method_defined?(:method_name, false) One case where you want to exclude inheritance when checking for a method definition is when you want to replace a method that may already exist. To avoid a verbose warning, you want to remove the method only if it is already defined: remove_method(:foo) if method_defined?(:foo, false) define_method(:foo){} You can't call remove_method without checking for the method definition, as that can raise a NameError, and you don't want to include inheritance because remove_method will still raise a NameError if the method is defined by an ancestor and not by the module itself. [ruby-core:88140] [Feature #14944] From: Jeremy Evans <code@jeremyevans.net> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-06const_missing on private constantsnobu
* variable.c (rb_const_search): call #const_missing method on private constants, as well as uninitialized constants. [Feature #14328] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-19variable.c: fix receiver on private constantnobu
* variable.c (rb_const_search): fix NameError :receiver attribute on private constant, should raise with the included module, not the ICLASS. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-17Remove the disabled old tests for Ruby 1.8/1.9 feature changemame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-12Fix setting method visibility on method wrapped with prependnobu
Ignore prepended modules when looking for already defined methods on a class to set the visibility on. [Fix GH-1834] From: Dylan Thacker-Smith <Dylan.Smith@shopify.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-10insns.def: cache nil constnobu
* insns.def (getinlinecache): Qnil is a valid value as a constant. this can be observable when accessing a deprecated constant which is nil. non-nil constant is warned just once for each location, but every time if it is nil. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12Add FrozenError as a subclass of RuntimeErrorshyouhei
FrozenError will be used instead of RuntimeError for exceptions raised when there is an attempt to modify a frozen object. The reason for this change is to differentiate exceptions related to frozen objects from generic exceptions such as those generated by Kernel#raise without an exception class. From: Jeremy Evans <code@jeremyevans.net> Signed-off-by: Urabe Shyouhei <shyouhei@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-29Make Module#{define|alias|undef|remove}_method public [#14133]marcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-29Make Module#attr{accessor|reader|writer|} public [#14132]marcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-14* test/ruby/test_module.rb: Method tables are not guaranteed to beheadius
ordered. * test/ruby/test_struct.rb: Ditto. * test/ruby/test_thread.rb: Thread locals are not guaranteed to be ordered. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-06include and prepend check no argsnobu
* eval.c (rb_mod_include, rb_mod_prepend): check if arguments are given, as well as Kernel#extend. [ruby-dev:49854] [Bug #12887] [Fix GH-1470] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-09variable.c: fix deprecated constant messagenobu
* variable.c (rb_const_search): warn with the actual class/module name which defines the deprecated constant. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-09variable.c: fix private constant messagenobu
* variable.c (rb_const_search): raise with the actual class/module name which defines the private constant. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-19variable.c: exclude private constantsnobu
* variable.c (rb_local_constants_i): exclude private constants when excluding inherited constants too. [Bug #12345] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-27variable.c: hidden constantsnobu
* variable.c (rb_local_constants_i): exclude hidden constants. [ruby-core:75575] [Bug #12389] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55182 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-17Use Integer instead of Fixnum and Bignum.akr
* object.c, numeric.c, enum.c, ext/-test-/bignum/mul.c, lib/rexml/quickpath.rb, lib/rexml/text.rb, lib/rexml/xpath_parser.rb, lib/rubygems/specification.rb, lib/uri/generic.rb, bootstraptest/test_eval.rb, basictest/test.rb, test/-ext-/bignum/test_big2str.rb, test/-ext-/bignum/test_div.rb, test/-ext-/bignum/test_mul.rb, test/-ext-/bignum/test_str2big.rb, test/csv/test_data_converters.rb, test/date/test_date.rb, test/json/test_json_generate.rb, test/minitest/test_minitest_mock.rb, test/openssl/test_cipher.rb, test/rexml/test_jaxen.rb, test/ruby/test_array.rb, test/ruby/test_basicinstructions.rb, test/ruby/test_bignum.rb, test/ruby/test_case.rb, test/ruby/test_class.rb, test/ruby/test_complex.rb, test/ruby/test_enum.rb, test/ruby/test_eval.rb, test/ruby/test_iseq.rb, test/ruby/test_literal.rb, test/ruby/test_math.rb, test/ruby/test_module.rb, test/ruby/test_numeric.rb, test/ruby/test_range.rb, test/ruby/test_rational.rb, test/ruby/test_refinement.rb, test/ruby/test_rubyvm.rb, test/ruby/test_struct.rb, test/ruby/test_variable.rb, test/rubygems/test_gem_specification.rb, test/thread/test_queue.rb: Use Integer instead of Fixnum and Bignum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-15vm_insnhelper.c: deprecated constant in classnobu
* vm_insnhelper.c (vm_get_ev_const): warn deprecated constant even in the class context. [ruby-core:75505] [Bug #12382] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-01test_name use Integer instead of Fixnum.akr
* test/ruby/test_module.rb (test_name): Use Integer instead of Fixnum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-09assertions.rb: set default internal encodingnobu
* test/lib/test/unit/assertions.rb (assert_raise_with_message): set default internal encoding to the excpected message, which affects String#inspect in messages. * test/lib/test/unit/assertions.rb (assert_warning): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-31test_module.rb: sort constantsnobu
* test/ruby/test_module.rb (test_classpath): since r53376, all results of Module#constants should be sorted to compare. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-30* test/ruby/test_module.rb (test_classpath): r53376 may changenaruse
the order of m.constants. `make TESTS='-v ruby/test_class.rb ruby/test_module.rb' test-all` may fail after that. http://rubyci.s3.amazonaws.com/tk2-243-31075/ruby-trunk/log/20151230T164202Z.log.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-30object.c: fix prepend cmpnobu
* object.c (rb_class_inherited_p): search the corresponding ancestor to prepended module from prepending class itself. [ruby-core:72493] [Bug #11878] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-18* vm_method.c (rb_method_entry_make, check_override_opt_method):shugo
should check whether a newly created method override a optimize method in case the method is defined in a prepended module of a built-in class. [ruby-core:72226] [Bug #11836] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-17* vm.c (rb_vm_check_redefinition_opt_method): should check the realshugo
class instead of the origin iclass. [ruby-core:72188] [Bug #11826] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16Add frozen_string_literal: false for all filesnaruse
When you change this to true, you may need to add more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-18* method.h: introduce the folliwing field and macros.ko1
* rb_method_definition_t::complemented_count to count shared method entries because of complemented method entries and separate from alias_count. Shared `def' only by complemented method entries should not prevent method re-definition warning. * METHOD_ENTRY_COMPLEMENTED(me) to represent complemented method entry. * METHOD_ENTRY_COMPLEMENTED_SET(me) to check it as complemented me. * vm_insnhelper.c (aliased_callable_method_entry): should also check me->def->complemented_count. * vm_method.c (method_definition_addref_complement): add to count complemented method entries number. * vm_method.c (rb_method_definition_release): release `def' iff alias_count == 0 and complemented_count == 0. * test/ruby/test_module.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-17revert r52614, r52615, r52617 because they cause serious errorsko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-17* method.h: introduce rb_method_definition_t::complemented_count.ko1
* vm_method.c (method_definition_addref_complement): introduced. def->alias_count is used to decide warn or do not warn at method redefinition. Complented methods should not prevent redefiniton warnings. * vm_method.c (rb_method_definition_release): release def iff alias_count == 0 && complemented_count == 0. * test/ruby/test_module.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-15vm_method.c: check if frozen [Fix GH-1096]nobu
* vm_method.c (set_method_visibility): should fail if the receiver is frozen. [ruby-core:71489] [Bug #11687] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-30* vm_method.c: added documentation of protected/private methods.hsbt
[fix GH-1072] * test/ruby/test_module.rb: added testcase for method_defined? [fix GH-1071] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-28encoding for inspectnobu
* test/ruby/test_{exception,module,object}.rb: inspect result depend on the default external encoding. [Feature #10881] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e