summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2024-03-12Use `assert_crash_report` in `test_crash_report_pipe`Nobuyoshi Nakada
Instead of using `assert_in_out_err` directly.
2024-03-12[Bug #20277] Remove stale `String` test conditionalsNobuyoshi Nakada
These instance variables for conditional execution have remained unchanged for nearly twenty years, since YARV merger.
2024-03-07Clear all refined CCs on reopening refinement modJohn Hawthorn
In cfd7729ce7a31c8b6ec5dd0e99c67b2932de4732 we started using inline caches for refinements. However, we weren't clearing inline caches when defined on a reopened refinement module. Fixes [Bug #20246]
2024-03-07[Bug #20327] Do not count subsecond to calculate UTC offsetNobuyoshi Nakada
Assume that there will never be any time zones with UTC offsets that are subseconds. Historically, UTC offset has only been used down to the second.
2024-03-04Keep hidden local variables when dumping and loading iseqsJeremy Evans
Fixes [Bug #19975]
2024-03-04[Bug #20324] Uncomparable ranges are not overlappingNobuyoshi Nakada
2024-03-04Support NODE_ONCE for pattern matchingS-H-GAMELINKS
2024-03-04Disable callcc when ASAN is enabledKJ Tsanaktsidis
callcc's implementation is fundamentally incompatible with ASAN. Since callcc is deprecated and almost never used, it's probably OK to disable callcc when ruby is compiled with ASAN. [Bug #20273]
2024-03-01Correctly set anon_kwrest flag for def f(b: 1, **)Jeremy Evans
In cases where a method accepts both keywords and an anonymous keyword splat, the method was not marked as taking an anonymous keyword splat. Fix that in the compiler. Doing that broke handling of nil keyword splats in yjit, so update yjit to handle that. Add a test to check that calling a method that accepts both a keyword argument and an anonymous keyword splat does not modify a passed keyword splat hash. Move the anon_kwrest check from setup_parameters_complex to ignore_keyword_hash_p, and only use it if the keyword hash is already a hash. This should speed things up slightly as it avoids a check previously used for all callers of setup_parameters_complex. Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2024-03-01YJIT: Support opt_invokebuiltin_delegate for leaf builtin (#10152)Takashi Kokubun
2024-03-01Make Struct memory leak test fasterJean Boussier
[Bug #20311] It times out on some platform, so we can reduce iterations. On my machine it completes in 250ms and RSS grows 8X.
2024-03-01Don't pin named structs defined in RubyJean Boussier
[Bug #20311] `rb_define_class_under` assumes it's called from C and that the reference might be held in a C global variable, so it adds the class to the VM root. In the case of `Struct.new('Name')` it's wasteful and make the struct immortal.
2024-03-01Use `File.open` and `File.write` instead of `Kernel#open`Nobuyoshi Nakada
2024-02-28Fix crash report path test on WindowsNobuyoshi Nakada
2024-02-28Fix to use `assert_crash_report` resultsNobuyoshi Nakada
2024-02-28Update regex patterns with rbinstall.rbHiroshi SHIBATA
2024-02-28Use dummy command for IO.popenHiroshi SHIBATA
2024-02-28Also ignore git ls-files command with IO.popen style for tmpdir.gemspec and ↵Hiroshi SHIBATA
tempfile.gemspec
2024-02-27[Bug #20302] Multiple refinements cannot be applied to the same moduleShugo Maeda
In the following code, the iclass tree of refinements in cref should be <iclass of Kernel@M2> -> <iclass of Kernel@M1> -> Kernel. However, the iclass tree was broken because of code for included modules of refinements in rb_using_refinement(). Refinement#include is now removed, so this commit removes such unnecessary code. ```ruby module M1 refine(Kernel) do def f1 = :f1 end end module M2 refine(Kernel) do def f2 = :f2 end end class Foo using M1 using M2 def test p f2 #=> :f2 p f1 # expected => :f1 # actual => undefined local variable or method 'f1' for an instance of Foo end end Foo.new.test ```
2024-02-27Add a failing test for https://bugs.ruby-lang.org/issues/20305.Fable Phippen
This bug demonstrates the issue I reported. It passes on commit https://github.com/ruby/ruby/commit/114e71d06280f9c57b9859ee4405ae89a989ddb6 but does not pass on commit (the immediate child of the above commit) https://github.com/ruby/ruby/commit/1d2d25dcadda0764f303183ac091d0c87b432566
2024-02-27Handle zero-like imaginary part as zero in to_r (#9581)Kenta Murata
Fixes [Bug #5179]
2024-02-26[Bug #20296] Fix the default assertion messageNobuyoshi Nakada
2024-02-26[Bug #20296] Refine the testNobuyoshi Nakada
2024-02-26[Bug #20296] Clear errinfo when `exception: false`Nobuyoshi Nakada
2024-02-23[Bug #20234] Fix segv when parsing begin statement in method definitioneileencodes
In a method definition, the `begin` may not have an `nd_body`. When that happens we get a null expr back from `last_expr_node` which causes a segv for the following examples: ```ruby def (begin;end).foo; end def (begin;else;end).foo; end def (begin;ensure;else;end).foo; end ``` In addition, I've added tests for other cases that weren't causing a segv but appeared untested.` Fixes https://bugs.ruby-lang.org/issues/20234
2024-02-23[Bug #20295] Fix SEGV when parsing invalid regexpyui-knk
2024-02-22Skip under_gc_compact_stress on s390x (#10073)Takashi Kokubun
2024-02-22[Bug #20292] Truncate embedded string to new capacityNobuyoshi Nakada
2024-02-22Cover all warning category optionsNobuyoshi Nakada
2024-02-21YJIT: Grab stack operands after SP change in String#byteslice (#10060)Alan Wu
Previously, `StackOperand`s caching `sp_offset` was held across a jit_prepare_call_with_gc(), which invalidates the offsets. With the right register allocation state, the canary overlapped with the old address of the receiver and YJIT clobbered the receiver writing the canary.
2024-02-21Re-enable test now that dump is all ASCIIKevin Newton
2024-02-22Ensure that exiting thread invokes end-of-life behaviour. (#10039)Samuel Williams
2024-02-20Add memory leak test for eval kwargsJohn Hawthorn
2024-02-20Fix string value in hash literal being forced frozenAlan Wu
We should pass `false` for `hash_key` for value nodes. Credits to `@kddnewton` for noticing and bisecting.
2024-02-21skip a test on non-UTF-8 localeKoichi Sasada
`ruby --parser=prism -W:no-experimental --dump=parsetree -e :hi` prints non-ASCII char(s) so the following test with non UTF-8 locale fails. ``` $ LANG=C make test-all TESTS='-n /parser/ ruby/rubyoptions' -o encs -o exts Run options: --seed=32323 "--ruby=./miniruby -I/home/ko1/ruby/src/master/lib -I. -I.ext/common /home/ko1/ruby/src/master/tool/runruby.rb --extout=.ext -- --disable-gems" --excludes-dir=/home/ko1/ruby/src/master/test/.excludes --name=!/memory_leak/ -n /parser/ [1/1] TestRubyOptions#test_parser_flag = 0.04 s 1) Failure: TestRubyOptions#test_parser_flag [/home/ko1/ruby/src/master/test/ruby/test_rubyoptions.rb:300]: pid 135869 exit 0. 1. [1/2] Assertion for "stdout" | invalid byte sequence in US-ASCII. Finished tests in 0.044362s, 22.5416 tests/s, 225.4157 assertions/s. 1 tests, 10 assertions, 1 failures, 0 errors, 0 skips ruby -v: ruby 3.4.0dev (2024-02-20T17:13:36Z master c0e5de9567) [x86_64-linux] make: *** [uncommon.mk:945: yes-test-all] Error 1 ``` Now simply skip the test if the locale is not UTF-8. (I'm not familiar with encodings so please fix it if needed)
2024-02-20Add pushtoarraykwsplat instruction to avoid unnecessary array allocationJeremy Evans
This is designed to replace the newarraykwsplat instruction, which is no longer used in the parse.y compiler after this commit. This avoids an unnecessary array allocation in the case where ARGSCAT is followed by LIST with keyword: ```ruby a = [] kw = {} [*a, 1, **kw] ``` Previous Instructions: ``` 0000 newarray 0 ( 1)[Li] 0002 setlocal_WC_0 a@0 0004 newhash 0 ( 2)[Li] 0006 setlocal_WC_0 kw@1 0008 getlocal_WC_0 a@0 ( 3)[Li] 0010 splatarray true 0012 putobject_INT2FIX_1_ 0013 putspecialobject 1 0015 newhash 0 0017 getlocal_WC_0 kw@1 0019 opt_send_without_block <calldata!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE> 0021 newarraykwsplat 2 0023 concattoarray 0024 leave ``` New Instructions: ``` 0000 newarray 0 ( 1)[Li] 0002 setlocal_WC_0 a@0 0004 newhash 0 ( 2)[Li] 0006 setlocal_WC_0 kw@1 0008 getlocal_WC_0 a@0 ( 3)[Li] 0010 splatarray true 0012 putobject_INT2FIX_1_ 0013 pushtoarray 1 0015 putspecialobject 1 0017 newhash 0 0019 getlocal_WC_0 kw@1 0021 opt_send_without_block <calldata!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE> 0023 pushtoarraykwsplat 0024 leave ``` pushtoarraykwsplat is designed to be simpler than newarraykwsplat. It does not take a variable number of arguments from the stack, it pops the top of the stack, and appends it to the second from the top, unless the top of the stack is an empty hash. During this work, I found the ARGSPUSH followed by HASH with keyword did not compile correctly, as it pushed the generated hash to the array even if the hash was empty. This fixes the behavior, to use pushtoarraykwsplat instead of pushtoarray in that case: ```ruby a = [] kw = {} [*a, **kw] [{}] # Before [] # After ``` This does not remove the newarraykwsplat instruction, as it is still referenced in the prism compiler (which should be updated similar to this), YJIT (only in the bindings, it does not appear to be implemented), and RJIT (in a couple comments). After those are updated, the newarraykwsplat instruction should be removed.
2024-02-20YJIT: Support `**nil` for cfuncsAlan Wu
Similar to the iseq call support. Fairly straight forward.
2024-02-20Update warning flags before dumpNobuyoshi Nakada
2024-02-20Remove never used methodNobuyoshi Nakada
2024-02-20Remove no longer used methodsNobuyoshi Nakada
`find_object_in_recycled_slot` and `memory_location` have not been used since commit:b99833baec2e567e38758f4fd017c90c7ce57d75.
2024-02-19[Bug #20280] Raise SyntaxError on invalid encoding symbolNobuyoshi Nakada
2024-02-16YJIT: Support empty splatAlan Wu
Previously we rejected empty splat calls to methods with no parameters as `iseq_arity_error` which didn't work well with delegated calls.
2024-02-16YJIT: Support `**nil`Alan Wu
This adds YJIT support for VM_CALL_KW_SPLAT with nil, specifically for when we already know from the context that it's done with a nil. This is enough to support forwarding with `...` when there no keyword arguments are present. Amend the kw_rest support to propagate the type of the parameter to help with this. Test interactions with splat, since the splat array sits lower on the stack when a kw_splat argument is present.
2024-02-16[PRISM] Make prism compiler warning experimentalKevin Newton
2024-02-15Do not show an anonymous class as a receiverYusuke Endoh
2024-02-15Show the method owner in backtracesYusuke Endoh
``` test.rb:1:in 'Object#toplevel_meth': unhandled exception from test.rb:4:in 'Foo.class_meth' from test.rb:6:in 'Foo#instance_meth' from test.rb:11:in 'singleton_meth' from test.rb:13:in '<main>' ``` [Feature #19117]
2024-02-15Do not include a backtick in error messages and backtracesYusuke Endoh
[Feature #16495]
2024-02-15Show the invalid source encoding in messagesNobuyoshi Nakada
2024-02-14YJIT: Simplify Kernel#send guards and admit more cases (#9956)Alan Wu
Previously, our compile time check rejected dynamic symbols (e.g. what String#to_sym could return) even though we could handle them just fine. The runtime guards for the type of method name was also overly restrictive and didn't accept dynamic symbols. Fold the type check into the rb_get_symbol_id() and take advantage of the guard already checking for 0. This also avoids generating the same call twice in case the same method name is presented as different types.
2024-02-13[PRISM] Add eval testsMatt Valentine-House