summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2022-08-12Remove Numeric#ceildivKouhei Yanagita
Notes: Merged: https://github.com/ruby/ruby/pull/5965
2022-08-12Add Numeric#ceildiv and Integer#ceildivKouhei Yanagita
Notes: Merged: https://github.com/ruby/ruby/pull/5965
2022-08-11Fix inspect for unicode codepoint 0x85Jeremy Evans
This is an inelegant hack, by manually checking for this specific code point in rb_str_inspect. Some testing indicates that this is the only code point affected. It's possible a better fix would be inside of lower-level encoding code, such that rb_enc_isprint would return false and not true for codepoint 0x85. Fixes [Bug #16842] Notes: Merged: https://github.com/ruby/ruby/pull/4229
2022-08-11Fix Array#[] with ArithmeticSequence with negative steps (#5739)Jeremy Evans
* Fix Array#[] with ArithmeticSequence with negative steps Previously, Array#[] when called with an ArithmeticSequence with a negative step did not handle all cases correctly, especially cases involving infinite ranges, inverted ranges, and/or exclusive ends. Fixes [Bug #18247] * Add Array#slice tests for ArithmeticSequence with negative step to test_array Add tests of rb_arithmetic_sequence_beg_len_step C-API function. * Fix ext/-test-/arith_seq/beg_len_step/depend * Rename local variables * Fix a variable name Co-authored-by: Kenta Murata <3959+mrkn@users.noreply.github.com> Notes: Merged-By: mrkn <mrkn@ruby-lang.org>
2022-08-10Revert "Add {Method,UnboundMethod}#{public?,private?,protected?}"Jeremy Evans
This reverts commit 27278150685e738f84105d09843d3ba371146c7a and 58dc8bf8f15df9a33d191074e8a5d4946a3d59d5. Visibility is an attribute of the method entry in a class, not an attribute of the Method object. Fixes [#18729] Fixes [#18751] Fixes [#18435] Notes: Merged: https://github.com/ruby/ruby/pull/5974
2022-08-04Fix inconsistency with opt_aref_withJohn Hawthorn
opt_aref_with is an optimized instruction for accessing a Hash using a non-frozen string key (ie. from a file without frozen_string_literal). It attempts to avoid allocating the string, and instead silently using a frozen string (hash string keys are always fstrings). Because this is just an optimization, it should be invisible to the user. However, previously this optimization was could be seen via hashes with default procs. For example, previously: h = Hash.new { |h, k| k.frozen? } str = "foo" h[str] # false h["foo"] # true when optimizations enabled This commit checks that the Hash doesn't have a default proc when using opt_aref_with. Notes: Merged: https://github.com/ruby/ruby/pull/6196
2022-08-03Harden Queue#pop timeout testsJean Boussier
They occasionaly fail with; ``` FLeaked thread: TestThreadQueue#test_queue_pop_timeout: #<Thread:0x0000000108e38e48 /Users/runner/work/ruby/ruby/src/test/ruby/test_thread_queue.rb:123 sleep> .Finished thread: TestThreadQueue#test_deny_pushers: #<Thread:0x0000000108e38e48 /Users/runner/work/ruby/ruby/src/test/ruby/test_thread_queue.rb:123 dead> ... Retrying... 1) Failure: TestThreadQueue#test_sized_queue_pop_timeout [/Users/runner/work/ruby/ruby/src/test/ruby/test_thread_queue.rb:157]: <#<Thread:0x00000001084bc7e8 /Users/runner/work/ruby/ruby/src/test/ruby/test_thread_queue.rb:156 sleep>> expected but was <nil>. 2) Failure: TestThreadQueue#test_queue_pop_timeout [/Users/runner/work/ruby/ruby/src/test/ruby/test_thread_queue.rb:124]: <#<Thread:0x00000001083ff058 /Users/runner/work/ruby/ruby/src/test/ruby/test_thread_queue.rb:123 sleep>> expected but was <nil>. ``` I'm hoping joining for longer should help avoid this. Notes: Merged: https://github.com/ruby/ruby/pull/6210
2022-08-02Implement Queue#pop(timeout: sec)Jean Boussier
[Feature #18774] As well as `SizedQueue#pop(timeout: sec)` If both `non_block=true` and `timeout:` are supplied, ArgumentError is raised. Notes: Merged: https://github.com/ruby/ruby/pull/6185
2022-08-02[Bug #17767] Now `ENV.clone` raises `TypeError` as well as `ENV.dup`Nobuyoshi Nakada
One year ago, the former method has been deprecated while the latter has become an error. Then the 3.1 released, it is enough time to make also the former an error. Notes: Merged: https://github.com/ruby/ruby/pull/6155
2022-07-30Implement Enumerator::Product and Enumerator.product [Feature #18685]Akinori MUSHA
Notes: Merged: https://github.com/ruby/ruby/pull/6197
2022-07-28YJIT: Teach getblockparamproxy to handle the no-block case without exiting ↵Matthew Draper
(#6191) Teach getblockparamproxy to handle the no-block case without exiting Co-authored-by: John Hawthorn <john@hawthorn.email> Co-authored-by: John Hawthorn <john@hawthorn.email> Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2022-07-28Skip randomly failing tests with FreeBSD 12Hiroshi SHIBATA
2022-07-25Wait the test thread to sleepNobuyoshi Nakada
Revert "Synchronize the test thread sleep" This reverts commit 307835fe314fea6e946a8c9b25bb3912680ed7d1.
2022-07-25Synchronize the test thread sleepNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6176
2022-07-21Do not chomp trailing line separator IO#each with nil separator and chompJeremy Evans
nil separator means no sepator, so chomp should not remove a line separator. Partially Fixes [Bug #18770] Notes: Merged: https://github.com/ruby/ruby/pull/6164
2022-07-21Revert "Do not chomp trailing line separator IO#each with nil separator and ↵Jeremy Evans
chomp" This reverts commit 04f86ad0b5d2fe4711ff300d855228a6aed55f33. This is causing CI issues, reverting for now.
2022-07-21Do not have class/module keywords look up ancestors of ObjectJeremy Evans
Fixes case where Object includes a module that defines a constant, then using class/module keyword to define the same constant on Object itself. Implements [Feature #18832] Notes: Merged: https://github.com/ruby/ruby/pull/6048
2022-07-21Do not chomp trailing line separator IO#each with nil separator and chompJeremy Evans
nil separator means no sepator, so chomp should not remove a line separator. Partially Fixes [Bug #18770] Notes: Merged: https://github.com/ruby/ruby/pull/5959
2022-07-21Make String#each_line work correctly with paragraph separator and chompJeremy Evans
Previously, it was including one newline when chomp was used, which is inconsistent with IO#each_line behavior. This makes behavior consistent with IO#each_line, chomping all paragraph separators (multiple consecutive newlines), but not single newlines. Partially Fixes [Bug #18768] Notes: Merged: https://github.com/ruby/ruby/pull/5960
2022-07-20Ensure _id2ref finds symbols with the correct typeDaniel Colson
Prior to this commit it was possible to call `ObjectSpace._id2ref` with an offset static symbol object_id and get back a new, incorrectly tagged symbol: ``` > sensible_sym = ObjectSpace._id2ref(:a.object_id) => :a > nonsense_sym = ObjectSpace._id2ref(:a.object_id + 40) => :a > sensible_sym == nonsense_sym => false ``` `nonsense_sym` ends up tagged with `RUBY_ID_INSTANCE` instead of `RB_ID_LOCAL`. That means we can do silly things like: ``` > foo = Object.new > foo.instance_variable_set(:a, 123) (irb):2:in `instance_variable_set': `a' is not allowed as an instance variable name (NameError) > foo.instance_variable_set(ObjectSpace._id2ref(:a.object_id + 40), 123) => 123 > foo.instance_variables => [:a] ``` This was happening because `get_id_entry` ignores the tag bits when looking up the symbol. So `rb_id2str(symid)` would return a value and then we'd continue on with the nonsense `symid`. This commit prevents the situation by checking that the `symid` actually matches what we get back from `get_id_entry`. Now we get a `RangeError` for the nonsense id: ``` > ObjectSpace._id2ref(:a.object_id) => :a > ObjectSpace._id2ref(:a.object_id + 40) (irb):1:in `_id2ref': 0x000000000013f408 is not symbol id value (RangeError) ``` Co-authored-by: John Hawthorn <jhawthorn@github.com> Notes: Merged: https://github.com/ruby/ruby/pull/6147
2022-07-20Match +YJIT in Ruby desc when testing segv (#6141)Noah Gibbs
In test_bug_reporter and test_rubyoptions we intentionally test child processes that cause SEGV. We run them with YJIT if the parent uses YJIT so that the text description matches the parent RUBY_DESCRIPTION. Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2022-07-20[Bug #18905] Check symbol name types more strictlyNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6149
2022-07-18[Bug #18922] Normalize time at 24:00:00 UTCNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6146 Merged-By: nobu <nobu@ruby-lang.org>
2022-07-15YJIT: Add send unit tests (#6143)Noah Gibbs
Add send unit tests for YJIT Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2022-07-15Implement Objects on VWAPeter Zhu
This commit implements Objects on Variable Width Allocation. This allows Objects with more ivars to be embedded (i.e. contents directly follow the object header) which improves performance through better cache locality. Notes: Merged: https://github.com/ruby/ruby/pull/6117
2022-07-14MJIT: Merge mjit_worker.c back to mjit.c (#6138)Takashi Kokubun
Since #6006, we no longer avoid executing GC on mjit_worker.c and thus there's no need to carefully change how we write code whether you're in mjit.c or mjit_worker.c anymore. Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2022-07-12[Feature #18901] Don't run size pool move tests without VWAMatt Valentine-House
Notes: Merged: https://github.com/ruby/ruby/pull/6099
2022-07-12[Feature #18901] Support size pool movement for ArraysMatt Valentine-House
This commit enables Arrays to move between size pools during compaction. This can occur if the array is mutated such that it would fit in a different size pool when embedded. The move is carried out in two stages: 1. The RVALUE is moved to a destination heap during object movement phase of compaction 2. The array data is re-embedded and the original buffer free'd if required. This happens during the update references step Notes: Merged: https://github.com/ruby/ruby/pull/6099
2022-07-11Replace use of double_heap in tests with expand_heapMatt Valentine-House
Notes: Merged: https://github.com/ruby/ruby/pull/6107
2022-07-10Use NO_JIT_DESCRIPTION only when neededTakashi Kokubun
Apparently 203801566a186b7b1cbe899a06d0832923a1bdf9 broke YJIT's CI.
2022-07-10Fix #5872 for MJIT GitHub ActionsTakashi Kokubun
If you run tests with RUN_OPTS=--mjit, the test fixes in https://github.com/ruby/ruby/pull/5872 don't work.
2022-07-08[Bug #18890] Suppress warnings and fix the messageNobuyoshi Nakada
``` test/ruby/test_parse.rb:1384: warning: assigned but unused variable - obj test/ruby/test_pattern_matching.rb:1162: warning: unused literal ignored test/ruby/test_pattern_matching.rb:1165: warning: unused literal ignored test/ruby/test_pattern_matching.rb:1161: warning: assigned but unused variable - a test/ruby/test_pattern_matching.rb:1164: warning: assigned but unused variable - b ``` And a newline should be significant here.
2022-07-07Thread#value: handle threads killed by a forkJean Boussier
[Bug #18902] When a thread is killed because we forked, the `value` if left to `Qundef`. Returning it woudl crash the VM. Notes: Merged: https://github.com/ruby/ruby/pull/6103
2022-07-07[Bug #18892] Reset `ARGF.lineno` after reading shebangNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6097
2022-07-06[Bug #18898] Fallback invalid external encoding to the defaultNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6093 Merged-By: nobu <nobu@ruby-lang.org>
2022-07-06[Bug #18890] newline should be insignificant after pattern labelNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6087
2022-07-05Synchronize the test thread not to die before assertionsNobuyoshi Nakada
2022-06-30[Bug #18877] Let `lex_ctxt` not to eat escaped whitespaceNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6065
2022-06-29Refactor tests for moving strings with compactionPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/6077
2022-06-29[Bug #18884] `class` cannot be just followed by modifiersNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6064 Merged-By: nobu <nobu@ruby-lang.org>
2022-06-22Fix infinite loop when b_return TracePoint throwsAlan Wu
Previously, we didn't pop the frame that runs the TracePoint hook for b_return events for blocks running as methods (bmethods). In case the hook raises, that formed an infinite loop during stack unwinding in hook_before_rewind(). [Bug #18060] Notes: Merged: https://github.com/ruby/ruby/pull/4638
2022-06-20Include JIT information in crash reportsChris Seaton
Since enabling YJIT or MJIT drastically changes what could go wrong at runtime, it's good to be front and center about whether they are enabled when dumping a crash report. Previously, `RUBY_DESCRIPTION` and the description printed when crashing can be different when a JIT is on. Introduce a new internal data global, `rb_dynamic_description`, and set it to be the same as `RUBY_DESCRIPTION` during initialization; use it when crashing. * version.c: Init_ruby_description(): Initialize and use `rb_dynamic_description`. * error.c: Change crash reports to use `rb_dynamic_description`. * ruby.c: Call `Init_ruby_description()` earlier. Slightly more work for when we exit right after printing the description but that was deemed acceptable. * include/ruby/version.h: Talk about how JIT info is not in `ruby_description`. * test/-ext-/bug_reporter/test_bug_reporter.rb: Remove handling for crash description being different from `RUBY_DESCRIPTION`. * test/ruby/test_rubyoptions.rb: ditto Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Co-authored-by: Alan Wu <alanwu@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/5872
2022-06-20[Feature #18788] Support options as `String` to `Regexp.new`Nobuyoshi Nakada
`Regexp.new` now supports passing the regexp flags not only as an `Integer`, but also as a `String. Unknown flags raise errors. Notes: Merged: https://github.com/ruby/ruby/pull/6039
2022-06-20Warn suspicious flag to `Regexp.new`Nobuyoshi Nakada
Now second argument should be `true`, `false`, `nil` or Integer. This flag is confused with third argument some times. Notes: Merged: https://github.com/ruby/ruby/pull/6039
2022-06-20Prevent a warning "possibly useless use of a literal in void context"Yusuke Endoh
2022-06-20Prevent a warning "Expected ... to define AutoloadTest but it didn't"Yusuke Endoh
related: [Bugs #18813] and eca31d24d606a73def3674938112dc3c5b79c445
2022-06-18[Bug #18813] Warn when autoload has to lookup in parent namespaceJean Boussier
This is a verbose mode only warning. Notes: Merged: https://github.com/ruby/ruby/pull/6038
2022-06-17Skip failing test on FreeBSD [ci skip]Nobuyoshi Nakada
2022-06-16Allow calling protected methods from refinementsJohn Hawthorn
Previously protected methods on refinements could never be called because they were seen as being "defined" on the hidden refinement ICLASS. This commit updates calling refined protected methods so that they are considered to be defined on the original class (the one being refined). This ended up using the same behaviour that was used to check whether a call to super was allowed, so I extracted that into a method. [Bug #18806] Notes: Merged: https://github.com/ruby/ruby/pull/5966
2022-06-17Respect the encoding of the source [Bug #18827]Nobuyoshi Nakada
Do not override the input string encoding at the time of preparation, the source encoding is not determined from the input yet. Notes: Merged: https://github.com/ruby/ruby/pull/6015