aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_refinement.rb
Commit message (Collapse)AuthorAgeFilesLines
* reset cache before iteratingKoichi Sasada2020-12-221-6/+26
| | | | | | | | cee02d754d76563635c1db90d2ab6c01f8492470 resets pCMC and `me` will be a invalidated and continuing the invalidated `me`, it will break the data structure. This patch tris to clear all methods of specified class before manipulating the `me`s. [Issue #17417]
* fix refinements/prepend bugKoichi Sasada2020-12-191-0/+27
| | | | | replaced method entry should be invalidated. [Bug #17386]
* test/ruby: Check warning messages at a finer granularityNobuyoshi Nakada2020-12-171-1/+1
| | | | | Instead of suppressing all warnings wholly in each test scripts by setting `$VERBOSE` to `nil` in `setup` methods.
* Revert "Prevent SystemStackError when calling super in module with activated ↵Jeremy Evans2020-09-221-31/+0
| | | | | | | | | | | | | | refinement" This reverts commit eeef16e190cdabc2ba474622720f8e3df7bac43b. This also reverts the spec change. Preventing the SystemStackError would be nice, but there is valid code that the fix breaks, and it is probably more common than cases that cause the SystemStackError. Fixes [Bug #17182]
* Prevent SystemStackError when calling super in module with activated refinementJeremy Evans2020-07-271-0/+31
| | | | | | | | | Without this, if a refinement defines a method that calls super and includes a module with a module that calls super and has a activated refinement at the point super is called, the module method super call will end up calling back into the refinement method, creating a loop. Fixes [Bug #17007]
* test/ruby/test_refinement.rb: suppress warning yb $VEROBSE = nilYusuke Endoh2020-06-191-0/+3
| | | | | | | | http://rubyci.s3.amazonaws.com/ubuntu2004/ruby-master/log/20200619T003004Z.log.html.gz ``` /home/chkbuild/chkbuild/tmp/build/20200619T003004Z/ruby/test/ruby/test_refinement.rb:2428: warning: method redefined; discarding old foo /home/chkbuild/chkbuild/tmp/build/20200619T003004Z/ruby/test/ruby/test_refinement.rb:2418: warning: previous definition of foo was here ```
* Allow refining a frozen classJeremy Evans2020-06-181-0/+33
| | | | | | | | Doing so modifies the class's method table, but not in a way that should be detectable from Ruby, so it may be safe to avoid checking if the class is frozen. Fixes [Bug #11669]
* test/ruby/test_refinement.rb: extend the timeoutYusuke Endoh2020-04-211-1/+1
| | | | https://rubyci.org/logs/rubyci.s3.amazonaws.com/debian-riscv64/ruby-master/log/20200420T083601Z.fail.html.gz
* Check if bindable against the refined target [Bug #16617]Nobuyoshi Nakada2020-02-091-0/+19
|
* use Minitest::Unit.current_repeat_count to skip multi-run.Koichi Sasada2020-01-281-6/+2
|
* support multi-run for test/ruby/test_refinement.rbKoichi Sasada2020-01-281-0/+8
| | | | | | | | Give up to support multi-run: * test_method_should_use_refinements * test_instance_method_should_use_refinements I hope someone can revisit it.
* Make prepending a refined module after inclusion not break refinementsJeremy Evans2019-11-281-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | After the previous commit, this was still broken. The reason it was broken is that a refined module that hasn't been prepended to yet keeps the refined methods in the module's method table. When prepending, the module's method table is moved to the origin iclass, and then the refined methods are moved from the method table to a new method table in the module itself. Unfortunately, that means that if a class has included the module, prepending breaks the refinements, because when the methods are moved from the origin iclass method table to the module method table, they are removed from the method table from the iclass created when the module was included earlier. Fix this by always creating an origin class when including a module that has any refinements, even if the refinements are not currently used. I wasn't sure the best way to do that. The approach I choose was to use an object flag. The flag is set on the module when Module#refine is called, and if the flag is present when the module is included in another module or class, an origin iclass is created for the module. Fixes [Bug #13446]
* Honor refinements for modules that prepend other modulesJeremy Evans2019-11-281-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This previously did not work, and the reason it did not work is that: 1) Refining a module or class that prepends other modules places the refinements in the class itself and not the origin iclass. 2) Inclusion of a module that prepends other modules skips the module itself, including only iclasses for the prepended modules and the origin iclass. Those two behaviors combined meant that the method table for the refined methods for the included module never ends up in the method lookup chain for the class including the module. Fix this by not skipping the module itself when the module is included. This requires some code rearranging in rb_include_class_new to make sure the correct method tables and origin settings are used for the created iclass. As origin iclasses shouldn't be exposed to Ruby, this also requires skipping modules that have origin iclasses in Module#ancestors (classes that have origin iclasses were already skipped). Fixes [Bug #16242]
* Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans2019-11-181-1/+0
| | | | | | 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.
* Revert "Method reference operator"Nobuyoshi Nakada2019-11-121-1/+1
| | | | | This reverts commit 67c574736912003c377218153f9d3b9c0c96a17b. [Feature #16275]
* Allow calling a private method with `self.`Dylan Thacker-Smith2019-09-201-1/+1
| | | | | | | | | | 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]
* Search refinement module along nested usingsNobuyoshi Nakada2019-08-171-0/+28
| | | | [Bug #16107]
* Suppress unused variable warningsNobuyoshi Nakada2019-06-301-0/+2
|
* Fix SystemStackError when calling a method in an unused refinementJeremy Evans2019-06-111-0/+32
| | | | Fixes [Bug #15720]
* Ignore warnings about mismatched indentations.Hiroshi SHIBATA2019-06-011-1/+1
|
* Ignore warnings about argument prefix with operator symbol.Hiroshi SHIBATA2019-06-011-7/+7
|
* added assertion with method ref operatornobu2019-01-281-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add refinements support to method/instance_method.nobu2019-01-281-2/+39
| | | | | | | | [Fix GH-2034] From: manga_osyo <manga.osyo@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_refinement.rb: increase timeout for RubyCIk0kubun2018-12-301-1/+1
| | | | | | https://rubyci.org/logs/rubyci.s3.amazonaws.com/amazon/ruby-trunk/log/20181229T153003Z.fail.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Enable refinements at Object#respond_to?nobu2018-11-221-2/+2
| | | | | | | | [Feature #15327] [Fix GH-2020] From: osyo-manga <manga.osyo@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Enable refinements to public_send.nobu2018-11-221-0/+33
| | | | | | | | [Feature #15326] [Fix GH-2019] From: manga_osyo <manga.osyo@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_args.c: to_proc refinementsnobu2018-01-241-0/+116
| | | | | | | | * vm_args.c (vm_to_proc): enable #to_proc by refinements at Proc passing as a block. patched by osyo (manga osyo). [Feature #14223] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_method.c: fix super in refined modulenobu2017-12-261-0/+19
| | | | | | | | | * vm_method.c (rb_method_entry_complement_defined_class): clone the original method entry of refined module instance method with the active ICLASS, to track super method chain. [ruby-dev:50390] [Bug #14232] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61484 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Modules should not have subclasses.shugo2017-12-021-0/+19
| | | | | | | | | When refining a module, the module was set to the superclass of its refinement, and a segmentation fault occurred. The superclass of the refinement should be an iclass of the module. [ruby-core:83617] [Bug #14070] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * remove trailing spaces.svn2017-11-291-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Unused module refinement shouldn't break method search.shugo2017-11-291-0/+26
| | | | | | | | Use rb_callable_method_entry_t::defined_class instead of rb_callable_method_entry_t::owner, because the superclass of iclass should be searched for modules. [ruby-core:83613] [Bug #14068] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_refinement.rb: test for r59946nobu2017-10-011-0/+15
| | | | | | | | * test/ruby/test_refinement.rb (test_dsym_literal): test for r59946, interning dynamic symbol should not be affected by refinements too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval.c: check typenobu2017-09-301-0/+21
| | | | | | | * eval.c (ignored_block): check argument type, which must be Module. [ruby-dev:50270] [Bug #13956] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* refinements in string interpolationnobu2017-09-181-0/+13
| | | | | | | | | | | | | | * compile.c (iseq_compile_each0): insert to_s method call, so that refinements activated at the caller should take place. [Feature #13812] * insns.def (tostring): fix up converted object to a string, infect and fallback. * insns.def (branchiftype): new instruction for conversion. branches if TOS is an instance of the given type. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_method.c: alias warning at refined methodnobu2017-08-171-0/+17
| | | | | | | | * vm_method.c (rb_method_entry_make): suppress a warning at refined method which will not be redefined. [ruby-core:82385] [Bug #13817] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* visibility of inherited methodnobu2017-07-291-0/+44
| | | | | | | | | | * vm_insnhelper.c (vm_call_method_each_type): honor the original visibility of inherited methods when a refinement is defined but not activated. [ruby-core:82209] [Bug #13776] Author: Mon_Ouie (Mon ouïe) <mon.ouie@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* class.c: prohibit refinement modulenobu2017-03-251-0/+14
| | | | | | | | * class.c (ensure_includable): cannot include refinement module, or the type and the class do not match. [ruby-core:79632] [Bug #13236] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_args.c: pass blocknobu2017-03-181-0/+25
| | | | | | | * vm_args.c (refine_sym_proc_call): pass block to the method when using refinements. [ruby-core:80219] [Bug #13325] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c: super to module in refinementnobu2017-02-191-0/+32
| | | | | | | | * vm_insnhelper.c (vm_call_zsuper): method defined in module in refinement is not callable as-is. dispatch again. [ruby-core:79588] [Bug #13227] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_method.c: resolve refined method to undefnobu2017-01-181-0/+19
| | | | | | | * vm_method.c (rb_undef): resolve the method entry which refines a prepended method entry. [ruby-core:78944] [Bug #13096] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c: zsuper in refinementsnobu2016-12-081-0/+21
| | | | | | | * vm_insnhelper.c (vm_call_zsuper): prevent infinite recursion zsuper in refinements. [ruby-core:77161] [Bug #12729] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_eval.c: fix refined method when prependednobu2016-11-101-0/+14
| | | | | | | * vm_eval.c (vm_call0_body): refined module should not be skipped as prepended. [ruby-core:78073] [Bug #12920] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/ruby/test_refinement.rb (test_refine_alias_in_subclass):shugo2016-11-051-0/+25
| | | | | | | add a test to check that alias in subclasses can be refined. [ruby-core:69374] [Bug #11186] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_refinement.rb: Symbol#to_proc testnobu2016-10-231-0/+5
| | | | | | | * test/ruby/test_refinement.rb (test_symbol_proc): a Symbol is converted to a Proc in the caller's context. [Feature #9451] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c: refinements with sendnobu2016-10-191-2/+2
| | | | | | | * vm_insnhelper.c (vm_call_opt_send): enable refinements with Kernel#send and BasicObject#__send__. [Feature #11476] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_refinement.rb: test_symbol_procnobu2016-10-151-0/+8
| | | | | | | * test/ruby/test_refinement.rb (test_symbol_proc): move from test_symbol.rb [Feature #9451] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_refinement.rb: using without evalnobu2016-10-151-6/+6
| | | | | | | * test/ruby/test_refinement.rb (FooExtClient, FooExtClient2): no needs to eval, using works in a class block now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * eval.c (rb_mod_refine): refine modules as well.shugo2016-09-231-7/+54
| | | | | | [ruby-core:76199] [Feature #12534] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * eval.c (rb_mod_s_used_modules): rename Module.used_refinements toshugo2016-09-081-8/+8
| | | | | | Module.used_modules. [Feature #7418] [ruby-core:49805] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * insns.def (setclassvariable, setconstant): warn when self is ashugo2016-09-081-0/+16
| | | | | | refinement. [Bug #10103] [ruby-core:64143] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56101 b2dd03c8-39d4-4d8f-98ff-823fe69b080e