summaryrefslogtreecommitdiff
path: root/test/ruby/test_refinement.rb
AgeCommit message (Collapse)Author
2021-09-11Use Test::Unit::Runner instead of MiniTest::UnitHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/4813
2021-09-11Use MiniTestHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/4813
2021-08-20Module#ancestors should not return superclasses of refinementsShugo Maeda
[ruby-core:86949] [Bug #14744] Reported by Eregon (Benoit Daloze). Thanks!
2021-05-21Avoid setting the visibility of refinement method entriesAlan Wu
Since refinement search is always performed, these entries should always be public. The method entry that the refinement search returns decides the visibility. Fixes [Bug #17822] Notes: Merged: https://github.com/ruby/ruby/pull/4515
2021-05-14test/ruby/test_refinement.rb: prevent "assigned but unused variable"Yusuke Endoh
2021-05-11Method cache: fix refinement entry handlingAlan Wu
To invalidate some callable method entries, we replace the entry in the class. Most types of method entries are on the method table of the origin class, but refinement entries without an orig_me are housed in the method table of the class itself. They are there because refinements take priority over prepended methods. By unconditionally inserting a copy of the refinement entry into the origin class, clearing the method cache created situations where there are refinement entry duplicates in the lookup chain, leading to infinite loops and other problems. Update the replacement logic to use the right class that houses the method entry. Also, be more selective about cache invalidation when moving refinement entries for prepend. This avoids calling clear_method_cache_by_id_in_class() before refinement entries are in the place it expects. [Bug #17806] Notes: Merged: https://github.com/ruby/ruby/pull/4386 Merged-By: XrXr
2020-12-22reset cache before iteratingKoichi Sasada
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] Notes: Merged: https://github.com/ruby/ruby/pull/3964
2020-12-19fix refinements/prepend bugKoichi Sasada
replaced method entry should be invalidated. [Bug #17386]
2020-12-17test/ruby: Check warning messages at a finer granularityNobuyoshi Nakada
Instead of suppressing all warnings wholly in each test scripts by setting `$VERBOSE` to `nil` in `setup` methods. Notes: Merged: https://github.com/ruby/ruby/pull/3925 Merged-By: nobu <nobu@ruby-lang.org>
2020-09-22Revert "Prevent SystemStackError when calling super in module with activated ↵Jeremy Evans
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] Notes: Merged: https://github.com/ruby/ruby/pull/3564
2020-07-27Prevent SystemStackError when calling super in module with activated refinementJeremy Evans
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] Notes: Merged: https://github.com/ruby/ruby/pull/3309
2020-06-19test/ruby/test_refinement.rb: suppress warning yb $VEROBSE = nilYusuke Endoh
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 ```
2020-06-18Allow refining a frozen classJeremy Evans
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] Notes: Merged: https://github.com/ruby/ruby/pull/3175
2020-04-21test/ruby/test_refinement.rb: extend the timeoutYusuke Endoh
https://rubyci.org/logs/rubyci.s3.amazonaws.com/debian-riscv64/ruby-master/log/20200420T083601Z.fail.html.gz
2020-02-09Check if bindable against the refined target [Bug #16617]Nobuyoshi Nakada
2020-01-28use Minitest::Unit.current_repeat_count to skip multi-run.Koichi Sasada
2020-01-28support multi-run for test/ruby/test_refinement.rbKoichi Sasada
Give up to support multi-run: * test_method_should_use_refinements * test_instance_method_should_use_refinements I hope someone can revisit it.
2019-11-28Make prepending a refined module after inclusion not break refinementsJeremy Evans
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] Notes: Merged: https://github.com/ruby/ruby/pull/2550
2019-11-28Honor refinements for modules that prepend other modulesJeremy Evans
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] Notes: Merged: https://github.com/ruby/ruby/pull/2550
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-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-17Search refinement module along nested usingsNobuyoshi Nakada
[Bug #16107] Notes: Merged: https://github.com/ruby/ruby/pull/2373
2019-06-30Suppress unused variable warningsNobuyoshi Nakada
2019-06-11Fix SystemStackError when calling a method in an unused refinementJeremy Evans
Fixes [Bug #15720]
2019-06-01Ignore warnings about mismatched indentations.Hiroshi SHIBATA
2019-06-01Ignore warnings about argument prefix with operator symbol.Hiroshi SHIBATA
2019-01-28added assertion with method ref operatornobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-28Add refinements support to method/instance_method.nobu
[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
2018-12-30test_refinement.rb: increase timeout for RubyCIk0kubun
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
2018-11-22Enable refinements at Object#respond_to?nobu
[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
2018-11-22Enable refinements to public_send.nobu
[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
2018-01-24vm_args.c: to_proc refinementsnobu
* 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
2017-12-26vm_method.c: fix super in refined modulenobu
* 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
2017-12-02Modules should not have subclasses.shugo
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
2017-11-29* remove trailing spaces.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-29Unused module refinement shouldn't break method search.shugo
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
2017-10-01test_refinement.rb: test for r59946nobu
* 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
2017-09-30eval.c: check typenobu
* 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
2017-09-18refinements in string interpolationnobu
* 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
2017-08-17vm_method.c: alias warning at refined methodnobu
* 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
2017-07-29visibility of inherited methodnobu
* 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
2017-03-25class.c: prohibit refinement modulenobu
* 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
2017-03-18vm_args.c: pass blocknobu
* 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
2017-02-19vm_insnhelper.c: super to module in refinementnobu
* 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
2017-01-18vm_method.c: resolve refined method to undefnobu
* 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
2016-12-08vm_insnhelper.c: zsuper in refinementsnobu
* 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
2016-11-10vm_eval.c: fix refined method when prependednobu
* 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
2016-11-05* test/ruby/test_refinement.rb (test_refine_alias_in_subclass):shugo
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
2016-10-23test_refinement.rb: Symbol#to_proc testnobu
* 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