aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby
Commit message (Collapse)AuthorAgeFilesLines
* Revert the related commits about `Tempfile.open` change.Hiroshi SHIBATA2020-09-091-1/+4
| | | | | Start with https://github.com/ruby/ruby/commit/fa21985a7a2f8f52a8bd82bd12a724e9dca74934 to https://github.com/ruby/ruby/commit/d7492a0be885ea9f2b9f71e3e95582f9a859c439
* Make it possible to dump and load an exception objectYusuke Endoh2020-09-061-0/+31
| | | | | | | | | | | | | | | | | | | | | A backtrace object in an exception had never supported marshalling correctly: `Marshal.load(Marshal.dump(exc)).backtrace_locations` dumped core. An Exception object has two hidden instance varibles for backtrace data: one is "bt", which has an Array of Strings, and the other is "bt_locations", which has an Array of Thread::Backtrace::Locations. However, Exception's dump outputs data so that the two variables are the same Array of Strings. Thus, "bt_locations" had a wrong-type object. For the compatibility, it is difficult to change the dump format. This changeset fixes the issue by ignoring data for "bt_locations" at the loading phase if "bt_locations" refers to the same object as "bt". Future work: Exception's dump should output "bt_locations" appropriately. https://bugs.ruby-lang.org/issues/17150
* Added Symbol#nameNobuyoshi Nakada2020-09-041-0/+6
| | | https://bugs.ruby-lang.org/issues/16150#change-87446
* Add category to `rb_warn_deprecated`eileencodes2020-09-021-2/+14
| | | | | | | | | | | | | | | PR https://github.com/ruby/ruby/pull/3418 added a category to `rb_warn_deprecated_to_remove` but not to `rb_warn_deprecated`. This adds the same code to `rb_warn_deprecated` so that those warnings also get a category. This change also adds tests for `rb_warn_deprecated` and updates the tests for `rb_warn_deprecated_to_remove` to have clearer names. I've fixed the call to `rb_method_entry` as we need to be using the instance method, not singleton. Feature: https://bugs.ruby-lang.org/issues/17122
* Fix constant names set using const_set on a singleton classMarc-Andre Lafortune2020-09-021-2/+8
| | | | Fixes [Bug #14895]
* Reapply "Special case Range#max for integer beginning and Float::Infinity ↵Marc-Andre Lafortune2020-09-011-0/+6
| | | | | | end" (tests) Reverted in e080a4cdee
* Support passing a category to `Warning.warn`eileencodes2020-09-011-3/+21
| | | | | | | | | | | | | | | | | | | | | | This change adds a `category` kwarg to make it easier to monkey patch `Warning.warn`. Warnings already have a category, but that warning isn't exposed. This implements a way to get the category so that warnings with a specific category, like deprecated, can be treated differently than other warnings in an application. The change here does an arity check on the method to support backwards compatibility for applications that may already have a warning monkey patch. For our usecase we want to `raise` for deprecation warnings in order to get the behavior for the next Ruby version. For example, now that we fixed all our warnings and deployed Ruby 2.7 to production, we want to be able to have deprecation warnings behave like they would in 3.0: raise an error. For other warnings, like uninialized constants, that behavior won't be removed from Ruby in the next version, so we don't need to raise errors. Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
* Revert "Fix Range#{max,minmax} for range with integer beginning and ↵Jeremy Evans2020-09-011-11/+2
| | | | | | non-integer end" This reverts commit 8900a25581822759daca528d46a75e0b743fc22e.
* Revert "Special case Range#max for integer beginning and Float::Infinity end"Jeremy Evans2020-09-011-6/+0
| | | | This reverts commit 05bf811c2839628aaef3d565daedb28be80d47ef.
* Prohibit setter method names in endless method definitionYusuke Endoh2020-08-311-0/+1
| | | | https://bugs.ruby-lang.org/issues/16746#note-26
* The deprecation of enumerators with block has been withdrawnNobuyoshi Nakada2020-08-311-66/+34
| | | | https://bugs.ruby-lang.org/issues/6670#change-75907
* Simplify Tempfile.open calls with a block as they now unlink the file ↵Benoit Daloze2020-08-291-4/+1
| | | | automatically
* Fix Method#super_method for aliased methodsJeremy Evans2020-08-271-0/+80
| | | | | | | | | | | | | | | | | | | | | | | | 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]
* [stringio] fix stringio codepoint enumerator off by one errorYoann Lecuyer2020-08-271-0/+13
|
* Fixed error messages at non-ascii %string terminatorNobuyoshi Nakada2020-08-261-0/+2
|
* register_fstring: avoid duping the passed string when possibleJean Boussier2020-08-191-0/+16
| | | | | | | | If the passed string is frozen, bare and not shared, then there is no need to duplicate it. Ref: 4ab69ebbd7cef8539f687e1f948845d076461dc6 Ref: https://bugs.ruby-lang.org/issues/11386
* Ensure the shortcut cached in the classNobuyoshi Nakada2020-08-171-0/+11
| | | | | | As well as the other places using RCLASS_IV_INDEX_TBL. `IO#reopen` seems the only case that the class of an object can be changed.
* rb_str_{index,rindex}_m: Handle /\K/ in patternKasumi Hanazuki2020-08-131-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | When the pattern Regexp given to String#index and String#rindex contain a /\K/ (lookbehind) operator, these methods return the position where the beginning of the lookbehind pattern matches, while they are expected to return the position where the \K matches. ``` # without patch "abcdbce".index(/b\Kc/) # => 1 "abcdbce".rindex(/b\Kc/) # => 4 ``` This patch fixes this problem by using BEG(0) instead of the return value of rb_reg_search. ``` # with patch "abcdbce".index(/b\Kc/) # => 2 "abcdbce".rindex(/b\Kc/) # => 5 ``` Fixes [Bug #17118]
* rb_str_{partition,rpartition}_m: Handle /\K/ in patternKasumi Hanazuki2020-08-131-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | When the pattern given to String#partition and String#rpartition contain a /\K/ (lookbehind) operator, the methods return strings sliced at incorrect positions. ``` # without patch "abcdbce".partition(/b\Kc/) # => ["a", "c", "cdbce"] "abcdbce".rpartition(/b\Kc/) # => ["abcd", "c", "ce"] ``` This patch fixes the problem by using BEG(0) instead of the return value of rb_reg_search. ``` # with patch "abcdbce".partition(/b\Kc/) # => ["ab", "c", "dbce"] "abcdbce".rpartition(/b\Kc/) # => ["abcdb", "c", "e"] ``` As a side-effect this patch makes String#partition 2x faster when the pattern is a costly Regexp by performing Regexp search only once, which was unexpectedly done twice in the original implementation. Fixes [Bug #17119]
* Fix corruption in ARGF.inplacePeter Zhu2020-08-121-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | Extension string stored in `ARGF.inplace` is created using an api designed for C string constants to create a Ruby string that points at another Ruby string. When the original string is swept, the extension string gets corrupted. Reproduction script (on MacOS): ```ruby #!/usr/bin/ruby -pi.bak BEGIN { GC.start(full_mark: true) arr = [] 1000000.times do |x| arr << "fooo#{x}" end } puts "hello" ``` Co-Authored-By: Matt Valentine-House <31869+eightbitraptor@users.noreply.github.com>
* string.c(rb_str_split_m): Handle /\K/ correctlyKasumi Hanazuki2020-08-121-0/+5
| | | | | | | Use BEG(0) instead of the result of rb_reg_search to handle the cases when the separator Regexp contains /\K/ (lookbehind) operator. Fixes [Bug #17113]
* Enable s390x invokebuiltin JIT test againTakashi Kokubun2020-08-111-1/+0
|
* [Feature #16513] TracePoint#inspect returns "... file:line" (#3391)Nguyễn Quang Minh2020-08-061-2/+2
| | | | | | | | | * Fix debug documents to match Thread#to_s change (Feature #16412 ticket) * TracePoint#inspect returns "... file:line" (Feature #16513) * Guard older version of Ruby in Tracepoint inspection tests * Focus on current thread only when running TracePoint inspection test
* Apply timeout-scale to test_thr_kill.Jun Aruga2020-08-061-1/+1
|
* Added NUL-contained casesNobuyoshi Nakada2020-07-311-0/+17
|
* Fix Array#flatten for recursive array when given positive depth [Bug #17092]Marc-Andre Lafortune2020-07-301-3/+11
|
* Fix Time#ceil when result should be the same as the receiverJeremy Evans2020-07-281-0/+5
| | | | Fixes [Bug #17025]
* 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]
* Respect visibility in non-array Enumerable#inject [Bug #13592]Nobuyoshi Nakada2020-07-241-0/+56
|
* Fix Time#to_a behavior with timezone [Bug #17046]S.H2020-07-241-0/+6
|
* Improved Enumerable::Lazy#flat_mapNobuyoshi Nakada2020-07-231-0/+4
| | | | | | | | | | | | | | | | | | | | |compare-ruby|built-ruby| |:-------|-----------:|---------:| |num3 | 96.333k| 160.732k| | | -| 1.67x| |num10 | 96.615k| 159.150k| | | -| 1.65x| |ary2 | 103.836k| 172.787k| | | -| 1.66x| |ary10 | 109.249k| 177.252k| | | -| 1.62x| |ary20 | 106.628k| 177.371k| | | -| 1.66x| |ary50 | 107.135k| 162.282k| | | -| 1.51x| |ary100 | 106.513k| 177.626k| | | -| 1.67x|
* Test for weeknumber with timezone [Bug #17042]Nobuyoshi Nakada2020-07-231-0/+1
|
* Switch reserved for numbered parameter warning to SyntaxErrorJeremy Evans2020-07-221-7/+6
|
* Special case Range#max for integer beginning and Float::Infinity endJeremy Evans2020-07-191-0/+6
| | | | | | | | | Popular Ruby libraries such as Rails and Rubocop relying on the previous behavior, even though it is technically a bug. The correct behavior is probably raising RangeError, since that is what an endless range raises. Related to [Bug #17017]
* Fix Range#max for beginless Integer ranges [Bug #17034]Michael Kohl2020-07-191-0/+4
| | | | | | | | | * Fix Range#max for beginless Integer ranges * Update test/ruby/test_range.rb * Fix formatting https://github.com/ruby/ruby/pull/3328 Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
* Optimize Array#min (#3324)Kenta Murata2020-07-181-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The benchmark result is below: | |compare-ruby|built-ruby| |:---------------|-----------:|---------:| |ary2.min | 39.105M| 39.442M| | | -| 1.01x| |ary10.min | 23.995M| 30.762M| | | -| 1.28x| |ary100.min | 6.249M| 10.783M| | | -| 1.73x| |ary500.min | 1.408M| 2.714M| | | -| 1.93x| |ary1000.min | 828.397k| 1.465M| | | -| 1.77x| |ary2000.min | 332.256k| 570.504k| | | -| 1.72x| |ary3000.min | 338.079k| 573.868k| | | -| 1.70x| |ary5000.min | 168.217k| 286.114k| | | -| 1.70x| |ary10000.min | 85.512k| 143.551k| | | -| 1.68x| |ary20000.min | 43.264k| 71.935k| | | -| 1.66x| |ary50000.min | 17.317k| 29.107k| | | -| 1.68x| |ary100000.min | 9.072k| 14.540k| | | -| 1.60x| |ary1000000.min | 872.930| 1.436k| | | -| 1.64x| compare-ruby is 9f4b7fc82e.
* Optimize Array#max (#3325)Kenta Murata2020-07-181-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The benchmark result is below: | |compare-ruby|built-ruby| |:---------------|-----------:|---------:| |ary2.max | 38.837M| 40.830M| | | -| 1.05x| |ary10.max | 23.035M| 32.626M| | | -| 1.42x| |ary100.max | 5.490M| 11.020M| | | -| 2.01x| |ary500.max | 1.324M| 2.679M| | | -| 2.02x| |ary1000.max | 699.167k| 1.403M| | | -| 2.01x| |ary2000.max | 284.321k| 570.446k| | | -| 2.01x| |ary3000.max | 282.613k| 571.683k| | | -| 2.02x| |ary5000.max | 145.120k| 285.546k| | | -| 1.97x| |ary10000.max | 72.102k| 142.831k| | | -| 1.98x| |ary20000.max | 36.065k| 72.077k| | | -| 2.00x| |ary50000.max | 14.343k| 29.139k| | | -| 2.03x| |ary100000.max | 7.586k| 14.472k| | | -| 1.91x| |ary1000000.max | 726.915| 1.495k| | | -| 2.06x|
* Fixed infinite loop at error in printing cause [Bug #17033]Nobuyoshi Nakada2020-07-151-0/+20
|
* Fix Range#{max,minmax} for range with integer beginning and non-integer endJeremy Evans2020-07-131-2/+11
| | | | | | | | | | | | | Previously, for inclusive ranges, the max would show up as the end of the range, even though the end was not an integer and would not be the maximum value. For exclusive ranges, max/minmax would previously raise a TypeError, even though it is possible to get the correct maximum. This change to max/minmax also uncovered a similar error in cover?, which calls max in certain cases, so adjust the code there so that cover? still works as expected. Fixes [Bug #17017]
* Fixed yday and wday with timezone [Bug #17024]Nobuyoshi Nakada2020-07-121-0/+2
|
* Encode ' as &apos; when using encode(xml: :attr)Jeremy Evans2020-07-102-6/+6
| | | | Fixes [Bug #16922]
* Fix an inaccurate comment in test_jitTakashi Kokubun2020-07-101-1/+3
|
* Make sure vm_call_cfunc uses inlined ccTakashi Kokubun2020-07-101-0/+16
| | | | | | | | which is checked by the first guard. When JIT-inlined cc and operand cd->cc are different, the JIT-ed code might wrongly dispatch cd->cc even while class check is done with another cc inlined by JIT. This fixes SEGV on railsbench.
* Added `NODE_SPECIAL_EXCESSIVE_COMMA` info to `ARGS` of ↵manga_osyo2020-07-081-0/+15
| | | | `RubyVM::AbstractSyntaxTree`.
* Add operator info to `OP_ASGN2` of `RubyVM::AbstractSyntaxTree`.manga_osyo2020-07-061-0/+11
|
* Check ROBJECT_EMBED on guards-merged ivar accessTakashi Kokubun2020-07-041-0/+28
| | | | | | Fix CI failure like http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/3043247 introduced by a69dd699ee630dd1086627dbca15a218a8538b6f
* Fix non-numeric exclusive Range#minmax bugSam Bostock2020-07-041-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | The implementation of Range#minmax added in d5c60214c45 causes the following incorrect behaviour: ('a'...'c').minmax => ["a", ["a", "b"]] instead of ('a'...'c').minmax => ["a", "b"] This is because the C implementation of Range#minmax (range_minmax) directly delegates to the C implementation of Range#min (range_min) and Range#max (range_max), without changing the execution context. Range#max's C implementation (range_max), when given a non-numeric exclusive range, delegates to super, which is meant to call Enumerable#max. However, because range_max is called directly by range_minmax, super calls Enumerable#minmax instead, causing the incorrect nesting. Perhaps it is possible to change the execution context in an optimized manner, but the simplest solution seems to be to just explicitly delegate from Range#minmax to Range#min and Range#max.
* Make Kernel#then, #yield_self, #frozen? builtin (#3283)Takashi Kokubun2020-07-031-1/+1
| | | | | * Make Kernel#then, #yield_self, #frozen? builtin * Fix test_jit
* Rewrite Kernel#tap with Ruby (#3281)Takashi Kokubun2020-07-031-12/+4
| | | | | | | | | | | | * Rewrite Kernel#tap with Ruby This was good for VM too, but of course my intention is to unblock JIT's inlining of a block over yield (inlining invokeyield has not been committed though). * Fix test_settracefunc About the :tap deletions, the :tap events are actually traced (we already have a TracePoint test for builtin methods), but it's filtered out by tp.path == "xyzzy" (it became "<internal:kernel>"). We could trace tp.path == "<internal:kernel>" cases too, but the lineno is impacted by kernel.rb changes and I didn't want to make it fragile for kernel.rb lineno changes.
* Suppress "assigned but unused variable" warningsKazuki Tsujimoto2020-06-271-4/+4
|