summaryrefslogtreecommitdiff
path: root/test/ruby/test_method.rb
AgeCommit message (Collapse)Author
2020-10-03Fix assert_ruby_status usage in 174ae0f5775cc7af7d197963a8f87b7d1972c268Kazuhiro NISHIYAMA
2020-10-03Remove known use-after-poison bugNobuyoshi Nakada
9eda6547812cbda23a73ba3b2620520b0de2bdd6 was fixed by b9488accf9e2cbf5f7c47b42b3eb23469f0aa58d.
2020-08-27Fix Method#super_method for aliased methodsJeremy Evans
Previously, Method#super_method looked at the called_id to determine the method id to use, but that isn't correct for aliased methods, because the super target depends on the original method id, not the called_id. Additionally, aliases can reference methods defined in other classes and modules, and super lookup needs to start in the super of the defined class in such cases. This adds tests for Method#super_method for both types of aliases, one that uses VM_METHOD_TYPE_ALIAS and another that does not. Both check that the results for calling super methods return the expected values. To find the defined class for alias methods, add an rb_ prefix to find_defined_class_by_owner in vm_insnhelper.c and make it non-static, so that it can be called from method_super_method in proc.c. This bug was original discovered while researching [Bug #11189]. Fixes [Bug #17130] Notes: Merged: https://github.com/ruby/ruby/pull/3458 Merged-By: jeremyevans <code@jeremyevans.net>
2020-06-09Work around infinite loop when overriding method visibility in prepended ↵Jeremy Evans
module (#3201) For ZSUPER methods with no defined class for the method entry, start the next lookup at the superclass of the origin class of the method owner, instead of the superclass of the method owner. Fixes [Bug #16942] Notes: Merged-By: jeremyevans <code@jeremyevans.net>
2020-03-22Merge pull request #2721 from jeremyevans/method-inspect-chain-alias-11188Jeremy Evans
Correctly show defined class for aliases of aliases Notes: Merged-By: jeremyevans <code@jeremyevans.net>
2020-03-09Don't display singleton class in Method#inspect unless method defined thereJeremy Evans
Previously, if an object has a singleton class, and you call Object#method on the object, the resulting string would include the object's singleton class, even though the method was not defined in the singleton class. Change this so the we only show the singleton class if the method is defined in the singleton class. Fixes [Bug #15608] Notes: Merged: https://github.com/ruby/ruby/pull/2949 Merged-By: jeremyevans <code@jeremyevans.net>
2020-01-29refactoring: use Proc and Constant.Koichi Sasada
2020-01-28support multi-run for test/ruby/test_method.rbKoichi Sasada
need to restore a method.
2020-01-09Fixed up 0eeed5bcc5530edb0af2af2ccff09d067c59e8f9Nobuyoshi Nakada
`Binding#source_location` returns the `__FILE__` when created, and may not be an absolute or real path. And in the `eval` context with an explicit file name, `__dir__` also returns that name. On the other hand, `__FILE__` in `require`d script file has been expanded at searching the library.
2020-01-03Make eval(code, binding) use (eval) as __FILE__ and 1 as __LINE__Jeremy Evans
This removes the warning that was added in 3802fb92ff8c83eed3e867db20f72c53932f542d, and switches the behavior so that the eval does not use the binding's __FILE__ and __LINE__ implicitly. Fixes [Bug #4352] Notes: Merged: https://github.com/ruby/ruby/pull/2816
2019-12-04Make {Method,UnboundMethod}#super_method handle clone/bind/unbindJeremy Evans
This wasn't working previously because the iclass entry wasn't being copied, and without an iclass entry, super_method returns nil. Fixes [Bug #15629] Notes: Merged: https://github.com/ruby/ruby/pull/2723
2019-11-21Refined inspection of argument forwardingNobuyoshi Nakada
2019-11-20Add tests of argument forwarding's parameters and inspectKazuhiro NISHIYAMA
2019-11-20Update representation (discussed on ruby tracker)zverok
Notes: Merged: https://github.com/ruby/ruby/pull/2618
2019-11-20Method parameters inspectzverok
Example: def m(a, b=nil, *c, d:, e: nil, **rest, &block) end p method(:m) #=> #<Method: m(a, b=<default>, *c, d:, e: <default>, **rest, &block) ...> Notes: Merged: https://github.com/ruby/ruby/pull/2618
2019-11-18Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans
This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby. Notes: Merged: https://github.com/ruby/ruby/pull/2476
2019-11-12Revert "Method reference operator"Nobuyoshi Nakada
This reverts commit 67c574736912003c377218153f9d3b9c0c96a17b. [Feature #16275]
2019-10-01remove `unused var` warningKoichi Sasada
2019-09-30Use assert_operator instead of mere assertNobuyoshi Nakada
2019-09-30Now `use_symbol` is always trueNobuyoshi Nakada
2019-09-30Emulate method_list (chkbuild) on test-all.Koichi Sasada
chkbuild (CI process) shows methods list before running tests and sometimes it can fails. This commit a code part to emulate this method listing feature.
2019-09-20Allows calling a private method only with bare `self`Nobuyoshi Nakada
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-30Make Method/Proc#parameters handle **nil syntaxJeremy Evans
Use a [:nokey] entry in this case. Notes: Merged: https://github.com/ruby/ruby/pull/2395
2019-08-30Make the dot-colon method reference frozenMaciej Mensfeld
[Feature #16103] Close: https://github.com/ruby/ruby/pull/2267
2019-08-30proc.c: Add UnboundMethod#bind_callYusuke Endoh
`umethod.bind_call(obj, ...)` is semantically equivalent to `umethod.bind(obj).call(...)`. This idiom is used in some libraries to call a method that is overridden. The added method does the same without allocation of intermediate Method object. [Feature #15955] ``` class Foo def add_1(x) x + 1 end end class Bar < Foo def add_1(x) # override x + 2 end end obj = Bar.new p obj.add_1(1) #=> 3 p Foo.instance_method(:add_1).bind(obj).call(1) #=> 2 p Foo.instance_method(:add_1).bind_call(obj, 1) #=> 2 ```
2019-08-29Freeze method reference operator objectNobuyoshi Nakada
[Feature #16103]
2019-07-14Method#inspect with source location.Koichi Sasada
Method#inspect shows with source location. [Feature #14145]
2019-04-26Hide internal IDsNobuyoshi Nakada
* parse.y (internal_id): number the ID serial for internal use by counting down from the neary maximum value, not to accidentally match permanent IDs. [Bug #15768] Notes: Fixed: [Bug #15786]
2019-04-08range.c: force hash values fixablenobu
* range.c (method_hash): force hash values fixable on LLP64 environment. [ruby-core:92191] [Bug #15756] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-06proc.c: call respond_to_missing? with a symbolnobu
[ruby-core:91683] [Bug #15640] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-10test/ruby/test_method.rb: Remove unreachable callkazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-10proc.c: check if callablenobu
* proc.c: check the argument at composition, expect a Proc, Method, or callable object. [ruby-core:90591] [Bug #15428] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-31Method reference operatornobu
Introduce the new operator for method reference, `.:`. [Feature #12125] [Feature #13581] [EXPERIMENTAL] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-27test_method.rb: do not kill RubyCI openSUSE machinek0kubun
with NoMemoryError on TestMethod#test_splat_long_array. https://rubyci.org/logs/rubyci.s3.amazonaws.com/opensuseleap/ruby-trunk/log/20181227T080002Z.log.html.gz Maybe better to check /proc/meminfo instead of /etc/os-release. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-22Proc#<< and Proc#>>nobu
[Feature #6284] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-22proc.c: Support any callable when composing Procsnobu
* proc.c (proc_compose): support any object with a call method rather than supporting only procs. [Feature #6284] * proc.c (compose): use the function call on the given object rather than rb_proc_call_with_block in order to support any object. * test/ruby/test_proc.rb: Add test cases for composing Procs with callable objects. * test/ruby/test_method.rb: Add test cases for composing Methods with callable objects. From: Paul Mucur <paul@altmetric.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-22proc.c: Implement Method#* for Method compositionnobu
* proc.c (rb_method_compose): Implement Method#* for Method composition, which delegates to Proc#*. * test/ruby/test_method.rb: Add test cases for Method composition. From: Paul Mucur <mudge@mudge.name> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-03proc.c: fix segfault when no singleton classnobu
* proc.c (rb_obj_singleton_method): bail out if the receiver does not have the singleton class without accessing the origin class not to segfault. [Bug #14658] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-03Fix Kernel#singleton_method with Module#Prependnobu
* proc.c (rb_obj_singleton_method): search the method entry from the origin class, for fix prepended modules. [Bug #14658] From: Vasiliy Ermolovich <younash@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-30proc: fix super_method segfault after bindnormal
* proc.c: handle undefined iclass [ruby-core:85231] [Bug #14421] From: Eric Wong <e@80x24.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12Unneeded assertiona_matsuda
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12Add Method#=== that invokes #calla_matsuda
Patch by osyo via [Feature #14142] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-09fix backtrace on argment error.ko1
* vm_backtrace.c (rb_backtrace_use_iseq_first_lineno_for_last_location): added. It modifies last location's line as corresponding iseq's first line number. * vm_args.c (raise_argument_error): use added function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-06proc.c: super_method of included methodnobu
* proc.c (method_super_method): search the next super method along the included ancestor chain. [ruby-core:83114] [Bug #13973] * vm_method.c (rb_callable_method_entry_without_refinements): return the defined class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-14proc.c: infect inspect resultnobu
* proc.c (method_inspect): the result should be infected by the object. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-14test/ruby/test_method.rb: refined [ruby-core:81666] [Bug #13656]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-14proc.c: skip prepended modulesnobu
* proc.c (method_super_method): skip prepended modules and continue from the super class of the original class. [ruby-core:81666] [Bug #13656] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-25proc.c: follow the original classnobu
* proc.c (mnew_internal): follow the original class, not to loop the prepended module. [ruby-core:77591] [Bug #12832] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56489 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