summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2019-10-11test/ruby/test_rubyoptions.rb (test_encoding): skipped on AndroidYusuke Endoh
On Android, nl_langinfo() always returns UTF-8 even when LANG is C.
2019-10-10test/ruby/test_file_exhaustive.rb: check the owner of the root directoryYusuke Endoh
The root directory may be owned by the current user, for example, in chroot environment.
2019-10-10Fixed numbered parameter checkNobuyoshi Nakada
* parse.y (struct local_vars): moved numbered parameter NODEs for nesting check to separate per local variable scopes, as numbered parameters should belong to local variable scopes. [Bug #16248]
2019-10-07Allow ruby2_keywords to be used with bmethodsJeremy Evans
There are libraries that use define_method with argument splats where they would like to pass keywords through the method. To more easily allow such libraries to use ruby2_keywords to handle backwards compatibility, it is necessary for ruby2_keywords to support bmethods. Notes: Merged: https://github.com/ruby/ruby/pull/2532
2019-10-07Add: Array#intersection methodPrajjwal Singh
Notes: Merged: https://github.com/ruby/ruby/pull/2533
2019-10-06Revert "tailcall optimization again (#2528)"Koichi Sasada
This reverts commit f62f90367fc3bce6714e7c34cbd040e14e43fe07.
2019-10-06tailcall optimization again (#2528)wanabe
This is follow up of r67315.
2019-10-02Treat return in block in class/module as LocalJumpError (#2511)Jeremy Evans
return directly in class/module is an error, so return in proc in class/module should also be an error. I believe the previous behavior was an unintentional oversight during the addition of top-level return in 2.4. Notes: Merged-By: jeremyevans <code@jeremyevans.net>
2019-10-02Iseq#to_binary: dump flag for **nil (#2508)Alan Wu
RUBY_ISEQ_DUMP_DEBUG=to_binary and the attached test case was failing. Dump the flag to make sure `**nil` can round-trip properly.
2019-10-01Fix for wrong fnmatch pattternNobuyoshi Nakada
* dir.c (file_s_fnmatch): ensure that pattern does not contain a NUL character. https://hackerone.com/reports/449617
2019-10-01remove `unused var` warningKoichi Sasada
2019-09-30Add rb_enumeratorize_with_size_kw and related macrosJeremy Evans
Currently, there is not a way to create a sized enumerator in C with a different set of arguments than provided by Ruby, and correctly handle keyword arguments. This function allows that. The need for this is fairly uncommon, but it occurs at least in Enumerator.produce, which takes arugments from Ruby but calls rb_enumeratorize_with_size with a different set of arguments. Notes: Merged: https://github.com/ruby/ruby/pull/2509
2019-09-30test/ruby/test_io.rb: supress a "method redefined" warningYusuke Endoh
by explicitly removing the old definition.
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-30Suppress keyword argument warning from #stepNobuyoshi Nakada
* numeric.c (num_step): pass the extracted argument from keyword argument, not the last argument itself which should have been warned already.
2019-09-27Fix warning when doing Struct.new(:x, keyword_init: true){}Jeremy Evans
This is due to calling rb_mod_module_eval directly instead of using rb_funcall_passing_block. The problem with calling directly is it does not create a new VM frame, so rb_mod_module_eval was called with no arguments, but with the keyword given VM frame flag set, which causes problems internally. Notes: Merged: https://github.com/ruby/ruby/pull/2500
2019-09-27Correctly issue ArgumentError when calling method that accepts no keywordsJeremy Evans
If a method accepts no keywords and was called with a keyword, an ArgumentError was not always issued previously. Force methods that accept no keywords to go through setup_parameters_complex so that an ArgumentError is raised if keywords are provided. Notes: Merged: https://github.com/ruby/ruby/pull/2501
2019-09-27Drop eliminated catch-entriesNobuyoshi Nakada
Drop catch table entries used in eliminated block, as well as call_infos. [Bug #16184]
2019-09-27More tests for [Feature #16150]Nobuyoshi Nakada
2019-09-26Fix more keyword separation issuesJeremy Evans
This fixes instance_exec and similar methods. It also fixes Enumerator::Yielder#yield, rb_yield_block, and a couple of cases with Proc#{<<,>>}. This support requires the addition of rb_yield_values_kw, similar to rb_yield_values2, for passing the keyword flag. Unlike earlier attempts at this, this does not modify the rb_block_call_func type or add a separate function type. The functions of type rb_block_call_func are called by Ruby with a separate VM frame, and we can get the keyword flag information from the VM frame flags, so it doesn't need to be passed as a function argument. These changes require the following VM functions accept a keyword flag: * vm_yield_with_cref * vm_yield * vm_yield_with_block Notes: Merged: https://github.com/ruby/ruby/pull/2493
2019-09-26Add compaction support to `rb_ast_t`Aaron Patterson
This commit adds compaction support to `rb_ast_t`.
2019-09-26Fix keyword argument separation issues in Enumerator::Generator#eachJeremy Evans
This requires adding rb_proc_call_kw to pass the keyword flag. Notes: Merged: https://github.com/ruby/ruby/pull/2491
2019-09-27Kernel#open may be redefinedNobuyoshi Nakada
2019-09-26Fix keyword argument separation issues in Fiber#resumeJeremy Evans
Notes: Merged: https://github.com/ruby/ruby/pull/2484
2019-09-26Fix keyword argument separation issues in Thread.newJeremy Evans
Notes: Merged: https://github.com/ruby/ruby/pull/2484
2019-09-26Fix keyword argument separation issues in Proc#{<<,>>}Jeremy Evans
This requires adding rb_proc_call_with_block_kw. Notes: Merged: https://github.com/ruby/ruby/pull/2484
2019-09-26Fix keyword argument sepration issues when IO#open calls #to_openJeremy Evans
Notes: Merged: https://github.com/ruby/ruby/pull/2484
2019-09-26Fix Module#name news and add a testJean Boussier
Notes: Merged: https://github.com/ruby/ruby/pull/2488
2019-09-26RubyVM::MJIT.pause(wait: true) should waitTakashi Kokubun
for all compilations and compaction. Prior to this commit, the last-compiled code has not been used because MJIT worker is stopped before setting the code, and compaction has also been skipped. But it was not intentional and `wait: true` pause should wait until those two things by its feature.
2019-09-26[EXPERIMENTAL] Expression with modifier `in`Nobuyoshi Nakada
[Feature #15865] Notes: Merged: https://github.com/ruby/ruby/pull/2485
2019-09-25Add Module#ruby2_keywords for passing keywords through regular argument splatsJeremy Evans
This approach uses a flag bit on the final hash object in the regular splat, as opposed to a previous approach that used a VM frame flag. The hash flag approach is less invasive, and handles some cases that the VM frame flag approach does not, such as saving the argument splat array and splatting it later: ruby2_keywords def foo(*args) @args = args bar end def bar baz(*@args) end def baz(*args, **kw) [args, kw] end foo(a:1) #=> [[], {a: 1}] foo({a: 1}, **{}) #=> [[{a: 1}], {}] foo({a: 1}) #=> 2.7: [[], {a: 1}] # and warning foo({a: 1}) #=> 3.0: [[{a: 1}], {}] It doesn't handle some cases that the VM frame flag handles, such as when the final hash object is replaced using Hash#merge, but those cases are probably less common and are unlikely to properly support keyword argument separation. Use ruby2_keywords to handle argument delegation in the delegate library. Notes: Merged: https://github.com/ruby/ruby/pull/2477
2019-09-25Make rb_scan_args handle keywords more similar to Ruby methods (#2460)Jeremy Evans
Cfuncs that use rb_scan_args with the : entry suffer similar keyword argument separation issues that Ruby methods suffer if the cfuncs accept optional or variable arguments. This makes the following changes to : handling. * Treats as **kw, prompting keyword argument separation warnings if called with a positional hash. * Do not look for an option hash if empty keywords are provided. For backwards compatibility, treat an empty keyword splat as a empty mandatory positional hash argument, but emit a a warning, as this behavior will be removed in Ruby 3. The argument number check needs to be moved lower so it can correctly handle an empty positional argument being added. * If the last argument is nil and it is necessary to treat it as an option hash in order to make sure all arguments are processed, continue to treat the last argument as the option hash. Emit a warning in this case, as this behavior will be removed in Ruby 3. * If splitting the keyword hash into two hashes, issue a warning, as we will not be splitting hashes in Ruby 3. * If the keyword argument is required to fill a mandatory positional argument, continue to do so, but emit a warning as this behavior will be going away in Ruby 3. * If keyword arguments are provided and the last argument is not a hash, that indicates something wrong. This can happen if a cfunc is calling rb_scan_args multiple times, and providing arguments that were not passed to it from Ruby. Callers need to switch to the new rb_scan_args_kw function, which allows passing of whether keywords were provided. This commit fixes all warnings caused by the changes above. It switches some function calls to *_kw versions with appropriate kw_splat flags. If delegating arguments, RB_PASS_CALLED_KEYWORDS is used. If creating new arguments, RB_PASS_KEYWORDS is used if the last argument is a hash to be treated as keywords. In open_key_args in io.c, use rb_scan_args_kw. In this case, the arguments provided come from another C function, not Ruby. The last argument may or may not be a hash, so we can't set keyword argument mode. However, if it is a hash, we don't want to warn when treating it as keywords. In Ruby files, make sure to appropriately use keyword splats or literal keywords when calling Cfuncs that now issue keyword argument separation warnings through rb_scan_args. Also, make sure not to pass nil in place of an option hash. Work around Kernel#warn warnings due to problems in the Rubygems override of the method. There is an open pull request to fix these issues in Rubygems, but part of the Rubygems tests for their override fail on ruby-head due to rb_scan_args not recognizing empty keyword splats, which this commit fixes. Implementation wise, adding rb_scan_args_kw is kind of a pain, because rb_scan_args takes a variable number of arguments. In order to not duplicate all the code, the function internals need to be split into two functions taking a va_list, and to avoid passing in a ton of arguments, a single struct argument is used to handle the variables previously local to the function. Notes: Merged-By: jeremyevans <code@jeremyevans.net>
2019-09-25Changed numbered parameters semanticsNobuyoshi Nakada
* `_1` (and no other numbered parameters) to work as `|x|`. * giving up `_0`. [ruby-core:95074] [Bug #16178]
2019-09-24Make numbered parameters exclusive in a scopeNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/2431
2019-09-24Changed numbered parameter prefixNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/2431
2019-09-23Make public_send and rb_f_send handle keyword argument separationJeremy Evans
Kernel#send takes a different optimized code path that was already handled. Notes: Merged: https://github.com/ruby/ruby/pull/2481
2019-09-21Make Kernel#{Pathname,BigDecimal,Complex} return argument if given correct typeJeremy Evans
This is how Kernel#{Array,String,Float,Integer,Hash,Rational} work. BigDecimal and Complex instances are always frozen, so this should not cause backwards compatibility issues for those. Pathname instances are not frozen, so potentially this could cause backwards compatibility issues by not returning a new object. Based on a patch from Joshua Ballanco, some minor changes by me. Fixes [Bug #7522] Notes: Merged: https://github.com/ruby/ruby/pull/2473
2019-09-21Fix Module#class_variables for singleton classes of classes/modulesJeremy Evans
Module#class_variables should reflect class variable lookup. For singleton classes of classes/modules, this means the lookup should be: * Singleton Class * Class * All Ancestors of Class Note that this doesn't include modules included in the singleton class, because class variable lookup doesn't include those. Singleton classes of other objects do not have this behavior and always just search all ancestors of the singleton class, so do not change the behavior for them. Fixes [Bug #8297] Notes: Merged: https://github.com/ruby/ruby/pull/2478
2019-09-21test/ruby/test_assignment.rb: use bug number for assert messageYusuke Endoh
to suppress variable unused warning
2019-09-20Handle keyword argument separation for Enumerator#sizeJeremy Evans
When Object#to_enum is passed a block, the block is called to get a size with the arguments given to to_enum. This calls the block with the same keyword flag as to_enum is called with. This requires adding rb_check_funcall_kw and rb_check_funcall_default_kw to handle keyword flags.
2019-09-20Make passing empty keywords to dig pass empty keywords to next dig methodJeremy Evans
If defined in Ruby, dig would be defined as def dig(arg, *rest) end, it would not use keywords. If the last dig argument was an empty hash, it could be treated as keyword arguments by the next dig method. Allow dig to pass along the empty keyword flag if called with an empty keyword, to suppress the previous behavior and force treating the hash as a positional argument and not keywords. Also handle the case where dig calls method_missing, passing the empty keyword flag to that as well. This requires adding rb_check_funcall_with_hook_kw functions, so that dig can specify how arguments are treated. It also adds kw_splat arguments to a couple static functions.
2019-09-20Allows calling a private method only with bare `self`Nobuyoshi Nakada
2019-09-20Allow calling a private accessor with `self.`Nobuyoshi Nakada
[Feature #11297] [Feature #16123] Notes: Merged: https://github.com/ruby/ruby/pull/2474
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-09-19Separate Time#inspect from to_s and show subsec [Feature #15958]NARUSE, Yui
2019-09-19Fixed reserved numbered parameter warningNobuyoshi Nakada
2019-09-19DEBUG: cxxanyargsNobuyoshi Nakada
2019-09-19DEBUGNobuyoshi Nakada