aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby
Commit message (Collapse)AuthorAgeFilesLines
* Add `Warning.[]` and `Warning.[]=`Nobuyoshi Nakada2019-12-131-0/+6
|
* Improved the test for Thread#inspect [Feature #16412]Nobuyoshi Nakada2019-12-131-1/+5
|
* [cygwin] fix File.absolute_path? testNobuyoshi Nakada2019-12-121-2/+5
| | | | | Paths start with the root are absolute on cygwin, regardless the drive letter.
* Cygwin path cannot be mapped to a UNC as-isNobuyoshi Nakada2019-12-121-1/+1
|
* Make super in instance_eval in method in module raise TypeErrorJeremy Evans2019-12-121-0/+23
| | | | | | | | | | | | | | | | | | | | | | | This makes behavior the same as super in instance_eval in method in class. The reason this wasn't implemented before is that there is a check to determine if the self in the current context is of the expected class, and a module itself can be included in multiple classes, so it doesn't have an expected class. Implementing this requires giving iclasses knowledge of which class created them, so that super call in the module method knows the expected class for super calls. This reference is called includer, and should only be set for iclasses. Note that the approach Ruby uses in this check is not robust. If you instance_eval another object of the same class and call super, instead of an TypeError, you get super called with the instance_eval receiver instead of the method receiver. Truly fixing super would require keeping a reference to the super object (method receiver) in each frame where scope has changed, and using that instead of current self when calling super. Fixes [Bug #11636]
* Do not load files in build directoryKazuhiro NISHIYAMA2019-12-112-21/+21
| | | | related https://bugs.ruby-lang.org/issues/16177
* Fix Enumerator::Lazy#with_indexJeremy Evans2019-12-111-2/+15
| | | | | | | | | | | | | | | | * Make it correctly handle lambdas * Make it iterate over the block if block is given The original implementation was flawed, based on lazy_set_method instead of lazy_add_method. Note that there is no implicit map when passing a block, the return value of the block passed to with_index is ignored, just as it is for Enumerator#with_index. Also like Enumerator#with_index, when called with a block, the return value is an enumerator without the index. Fixes [Bug #16414]
* test/ruby/test_keywords.rb: suppress a warningYusuke Endoh2019-12-101-1/+1
| | | | | | | https://rubyci.org/logs/rubyci.s3.amazonaws.com/ubuntu1604/ruby-master/log/20191210T003005Z.log.html.gz ``` .../test/ruby/test_keyword.rb:2711: warning: `*' interpreted as argument prefix ```
* Add Proc#ruby2_keywordsJeremy Evans2019-12-091-0/+39
| | | | | | | | | | | | This allows passing keywords through a normal argument splat in a Proc. While needing ruby2_keywords support for methods is more common, there is code that delegates keywords through normal argument splats in procs, including code in Rails. For that reason, it makes sense to expose this for procs as well. Internally, ruby2_keywords is not tied to methods, but iseqs, so this just allows for setting the ruby2_keywords for the iseq related to the proc.
* test/ruby/test_file_exhaustive.rb: shorten the name of temporary dirYusuke Endoh2019-12-071-1/+1
| | | | | | | | | ``` 1) Error: TestFileExhaustive#test_socket_p: ArgumentError: too long unix socket path (109bytes given but 108bytes max) /export/home/users/chkbuild/cb-sunc/tmp/build/20191207T024036Z/ruby/test/ruby/test_file_exhaustive.rb:155:in `initialize' ```
* Detect started threads when require onlyKazuhiro NISHIYAMA2019-12-061-0/+28
|
* add additional CF info for CI envKoichi Sasada2019-12-051-1/+1
| | | | | | | | | Introduce new RUBY_DEBUG option 'ci' to inform Ruby interpreter that an interpreter is running on CI environment. With this option, `rb_bug()` shows more information includes method entry information, local variables information for each control frame.
* Make TracePoint.stat a singleton method again (#2726)Alan Wu2019-12-041-0/+4
| | | [Bug #16399]
* implement Range#count卜部昌平2019-12-041-0/+4
| | | | As matz requested in [Bug #16366].
* Make {Method,UnboundMethod}#super_method handle clone/bind/unbindJeremy Evans2019-12-041-0/+30
| | | | | | | | 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]
* Revert "Regexp#match{?} with nil raises TypeError as String, Symbol (#1506)"NARUSE, Yui2019-12-043-12/+2
| | | | | This reverts commit 2a22a6b2d8465934e75520a7fdcf522d50890caf. Revert [Feature #13083]
* Revert "Revert nil error and adding deprecation message"NARUSE, Yui2019-12-041-2/+2
| | | | This reverts commit 452bee3ee8d68059fabd9b1c7a75661b14e3933e.
* Make Enumerator::Chain#each treat lambdas as lambdaJeremy Evans2019-12-031-0/+16
| | | | | | | | Previously, lambdas were converted to procs because of how rb_block_call works. Switch to rb_funcall_with_block, which handles procs as procs and lambdas as lambdas. Fixes [Bug #15613]
* Do not lose existing constant visibility when autoloadingJeremy Evans2019-12-031-0/+60
| | | | | | | | | | This copies the private/deprecate constant visibility across the autoload. It still is backwards compatible with setting the private/deprecate constant visibility in the autoloaded file. However, if you explicitly set public constant in the autoloaded file, that will be reset after the autoload. Fixes [Bug #11055]
* Fixed stack overflow [Bug #16382]Nobuyoshi Nakada2019-12-031-0/+11
| | | | | Get rid of infinite recursion in expanding a load path to the real path while loading a transcoder.
* Check MJIT support in one placeTakashi Kokubun2019-12-011-2/+0
| | | | | to fix test failure on trunk-no-mjit https://gist.github.com/ko1/32ab982ffd7555988818773c08f97123
* Skip --jit-debug= test on mswinTakashi Kokubun2019-12-011-1/+2
| | | | | it fails like https://ci.appveyor.com/project/ruby/ruby/builds/29235837/job/v0apdjj4qx8afars
* Use build dir for testing --jit-debugTakashi Kokubun2019-12-011-1/+2
| | | | to fix failure like https://github.com/ruby/ruby/runs/327745536
* Allow specifying arbitrary MJIT flags by --jit-debugTakashi Kokubun2019-12-011-0/+6
| | | | | | | | This is a secret feature for me. It's only for testing and any behavior with this flag override is unsupported. I needed this because I sometimes want to add debug options but do not want to disable optimizations, for using Linux perf.
* Relax test strictness for error message from KeyErrorYuki Nishijima2019-11-301-1/+1
|
* ENV.update should not call block on existing keysNobuyoshi Nakada2019-11-301-1/+1
| | | | [Bug #16192]
* Supress class variable overtaken warning when original modules are the sameJeremy Evans2019-11-291-0/+23
| | | | | This issue was exposed by recent commits to better support including refined modules.
* Make single line pattern matching void expressionNobuyoshi Nakada2019-11-301-2/+2
| | | | | Instead of returning `nil`, raise a syntax error if its value is used. [Feature #16355]
* check interrupts at each frame pop timing.Koichi Sasada2019-11-291-1/+3
| | | | | | | | | | | | | | | | | | Asynchronous events such as signal trap, finalization timing, thread switching and so on are managed by "interrupt_flag". Ruby's threads check this flag periodically and if a thread does not check this flag, above events doesn't happen. This checking is CHECK_INTS() (related) macro and it is placed at some places (laeve instruction and so on). However, at the end of C methods, C blocks (IMEMO_IFUNC) etc there are no checking and it can introduce uninterruptible thread. To modify this situation, we decide to place CHECK_INTS() at vm_pop_frame(). It increases interrupt checking points. [Bug #16366] This patch can introduce unexpected events...
* Reduce duplicated warnings for the change of Ruby 3 keyword argumentsYusuke Endoh2019-11-292-29/+140
| | | | | | | | | | | | | | | By this change, the following code prints only one warning. ``` def foo(**opt); end 100.times { foo({kw:1}) } ``` A global variable `st_table *caller_to_callees` is a map from caller to a set of callee methods. It remembers that a warning is already printed for each pair of caller and callee. [Feature #16289]
* vm_method.c: add top-level ruby2_keywordsYusuke Endoh2019-11-291-0/+12
| | | | | | This is a top-level version of Module#ruby2_keywords. It can be used for functions (top-level methods) that delegates arguments. [Feature #16364]
* * remove trailing spaces. [ci skip]git2019-11-291-1/+1
|
* fastpath for ivar read of FL_EXIVAR objects.Koichi Sasada2019-11-291-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | vm_getivar() provides fastpath for T_OBJECT by caching an index of ivar. This patch also provides fastpath for FL_EXIVAR objects. FL_EXIVAR objects have an each ivar array and index can be cached as T_OBJECT. To access this ivar array, generic_iv_tbl is exposed by rb_ivar_generic_ivtbl() (declared in variable.h which is newly introduced). Benchmark script: Benchmark.driver(repeat_count: 3){|x| x.executable name: 'clean', command: %w'../clean/miniruby' x.executable name: 'trunk', command: %w'./miniruby' objs = [Object.new, 'str', {a: 1, b: 2}, [1, 2]] objs.each.with_index{|obj, i| rep = obj.inspect rep = 'Object.new' if /\#/ =~ rep x.prelude str = %Q{ v#{i} = #{rep} def v#{i}.foo @iv # ivar access method (attr_reader) end v#{i}.instance_variable_set(:@iv, :iv) } puts str x.report %Q{ v#{i}.foo } } } Result: v0.foo # T_OBJECT clean: 85387141.8 i/s trunk: 85249373.6 i/s - 1.00x slower v1.foo # T_STRING trunk: 57894407.5 i/s clean: 39957178.6 i/s - 1.45x slower v2.foo # T_HASH trunk: 56629413.2 i/s clean: 39227088.9 i/s - 1.44x slower v3.foo # T_ARRAY trunk: 55797530.2 i/s clean: 38263572.9 i/s - 1.46x slower
* Added Symbol#start_with? and Symbol#end_with? method. [Feature #16348]NARUSE, Yui2019-11-281-0/+23
|
* 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]
* Raise `NoMatchingPatternError` when expr `in` pat doesn't matchNobuyoshi Nakada2019-11-281-1/+4
| | | | | | | | * `expr in pattern` should raise `NoMatchingError` when unmatched * `expr in pattern` should return `nil`. (this is unspecified, but this feature is experimental, at all) [Feature #16355]
* Don't modify rest array when using ruby2_keywordsJeremy Evans2019-11-271-0/+9
| | | | | | Previously, the rest array was modified, but it turns out that is not necessary. Not modifying the rest array fixes cases when the rest array is used more than once.
* Skip test_validate_gemspec when tarball and git installed tooKazuhiro NISHIYAMA2019-11-231-1/+1
| | | | | | `git --version` failed as expected when git is not installed, but unexpectedly pass when git installed and pwd is not in git working directory. So use `git rev-parse` instead, and it failed when git installed too.
* Refined inspection of argument forwardingNobuyoshi Nakada2019-11-211-2/+4
|
* Add tests of argument forwarding's parameters and inspectKazuhiro NISHIYAMA2019-11-201-0/+5
|
* Update representation (discussed on ruby tracker)zverok2019-11-201-20/+20
|
* Fix test_module.rbzverok2019-11-201-1/+1
|
* Method parameters inspectzverok2019-11-201-6/+63
| | | | | | | | | 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) ...>
* Fix memory corruption in Enumerable#reverse_each [ruby-dev:50867] [Bug #16354]Kazuki Tsujimoto2019-11-191-0/+13
|
* Avoid needless object allocationKazuki Tsujimoto2019-11-192-1/+3
|
* Add a testKazuhiro NISHIYAMA2019-11-191-3/+23
| | | | | | and rename from b.rb [ruby-core:95055] [Bug #16177]
* pack is not using invokebuiltin anymoreTakashi Kokubun2019-11-181-6/+3
|
* catch up last commit.Koichi Sasada2019-11-181-1/+1
| | | | Array#pack uses `opt_invokebuiltin_delegate_leave` now.
* Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans2019-11-1823-484/+51
| | | | | | 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.