summaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
2024-04-20[ruby/zlib] Clear temporary directoryNobuyoshi Nakada
https://github.com/ruby/zlib/commit/1bed54dcf7
2024-04-20[ruby/irb] Remove exit command workaround, handle IRB_EXIT intomoya ishida
debug_readline (https://github.com/ruby/irb/pull/923) * Remove exit and exti! command workaround when executed outside of IRB Command was a method. It could be executed outside of IRB. Workaround for it is no longer needed. * Handle IRB_EXIT in debug mode * Add exit and exit! command in rdbg mode https://github.com/ruby/irb/commit/0b5dd6afd0
2024-04-20ensure ibf_load_setup is only passed String paramsZack Deveau
In cases where RubyVM::InstructionSequence.load_from_binary() is passed a param other than a String, we attempt to call the RSTRING_LENINT macro on it which can cause a segfault. ex: ``` var_0 = 0 RubyVM::InstructionSequence.load_from_binary(var_0) ``` This commit adds a type check to raise unless we are provided a String.
2024-04-19[ruby/irb] Add MultiIRB commands testKuniaki Igarashi
(https://github.com/ruby/irb/pull/929) https://github.com/ruby/irb/commit/c6bbc424c3
2024-04-19[ruby/reline] Implement `show-all-if-ambiguous` featureMari Imaizumi
(https://github.com/ruby/reline/pull/683) https://github.com/ruby/reline/commit/0fe4fdc794
2024-04-18[ruby/irb] Fix % escape in prompt formattomoya ishida
(https://github.com/ruby/irb/pull/927) https://github.com/ruby/irb/commit/08eee25d28
2024-04-18[ruby/irb] Accept " " for colorizing "\t" testtomoya ishida
(https://github.com/ruby/irb/pull/924) https://github.com/ruby/irb/commit/c8182fa490
2024-04-18Add a hint of `ASCII-8BIT` being `BINARY`Jean Boussier
[Feature #18576] Since outright renaming `ASCII-8BIT` is deemed to backward incompatible, the next best thing would be to only change its `#inspect`, particularly in exception messages.
2024-04-18[ruby/ipaddr] Add IPAddr.cidr to return ip address in cidr notationBen Fritsch
https://github.com/ruby/ipaddr/commit/f5b006741f
2024-04-17[ruby/prism] Add a reflection API for determining the fields of a nodeKevin Newton
https://github.com/ruby/prism/commit/f3f9950a74
2024-04-17[ruby/reline] Refactor nomultiline and multiline mode differencetomoya ishida
(https://github.com/ruby/reline/pull/653) * Support multiline input in Reline.readline internally, reduce multiline-singleline branch * Add readline(singleline) prompt test with force inserting multiline text https://github.com/ruby/reline/commit/97846095d7
2024-04-17relax unused block warning for duck typingKoichi Sasada
if a method `foo` uses a block, other (unrelated) method `foo` can receives a block. So try to relax the unused block warning condition. ```ruby class C0 def f = yield end class C1 < C0 def f = nil end [C0, C1].f{ block } # do not warn ```
2024-04-17[Feature #20335] `Thread.each_caller_location` argumentsNobuyoshi Nakada
Accecpt the same arguments as `caller` and `caller_locations`.
2024-04-17skip on Prism generated iseqKoichi Sasada
2024-04-17test_uplus_minus: Use a different string literalJean Boussier
This test fail relatively frequently and it's unclear what is happening. ``` str: {"address":"0x7fbdeb26d4e0", "type":"STRING", "shape_id":1, "slot_size":40, "class":"0x7fbdd1e0ec50", "frozen":true, "embedded":true, "fstring":true, "bytesize":3, "value":"bar", "encoding":"UTF-8", "coderange":"7bit", "memsize":40, "flags":{"wb_protected":true, "old":true, "uncollectible":true, "marked":true}} bar: {"address":"0x7fbdd0a8b138", "type":"STRING", "shape_id":1, "slot_size":40, "class":"0x7fbdd1e0ec50", "frozen":true, "embedded":true, "fstring":true, "bytesize":3, "value":"bar", "encoding":"UTF-8", "coderange":"7bit", "memsize":40, "flags":{"wb_protected":true}} ``` The `"bar".freeze` literal correctly put an old-gen fstring on the stack. But `-%w(b a r).join('')` returns a young-gen fstring, which suggest it somehow failed to find the old one in the `frozen_strings` table. This could be caused by another test corrupting the table, or corrupting the `"bar"` fstring. By using a different literal value we can learn whether the bug is specific to `"bar"` (used in many tests) or more general.
2024-04-17`ISeq#to_a` respects `use_block` statusKoichi Sasada
```ruby b = RubyVM::InstructionSequence.compile('def f = yield; def g = nil').to_a pp b #=> ... {:use_block=>true}, ... ```
2024-04-17[ruby/stringio] strio_read: preserve buffer encoding on partialJean byroot Boussier
reads (https://github.com/ruby/stringio/pull/95) [[Bug #20418]](https://bugs.ruby-lang.org/issues/20418) Ruby IO#read preserves the encoding on partial read, but change it when reading the whole IO from commit https://github.com/ruby/ruby/commit/0ca7036682da: > * io.c (read_all): should associate default external encoding. > * io.c (io_read): should NOT associate default external encoding. https://github.com/ruby/stringio/commit/073172da31 Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2024-04-16[ruby/reline] Implement changing editing modeMari Imaizumi
(https://github.com/ruby/reline/pull/681) https://github.com/ruby/reline/commit/501b9a6c5f
2024-04-16[rubygems/rubygems] Honor a specified path as the temporary diretory if givenNobuyoshi Nakada
## The problem Currently the tests are executed in the fixed name directory "tmp" under the top source directory. However it makes the tests fail when the source path contains symlinks. Or unable to even start if the top source directory is read-only, e.g., remote-mounting in read-only mode from virtual machines. Also, with the fixed directory, there is no way to avoid `pend` in `TestGemPackage#test_extract_symlink_parent_doesnt_delete_user_dir`. ## The fix Instead of creating the fixed name directory, this PR allows to use a different path given with the environment variable "GEM_TEST_TMPDIR". The default path is, as well as the current behavior, "tmp" from the top source directory. ### Caveat It is the caller's responsibility to make the directory safe (owned, world unwritable, or sticky) when setting the environment variable. https://github.com/rubygems/rubygems/commit/bf00850656
2024-04-16[Bug #20325] `Enumerator.product.size` is 0 if any size is 0Nobuyoshi Nakada
2024-04-15[rubygems/rubygems] Bump rb-sysdependabot[bot]
Bumps [rb-sys](https://github.com/oxidize-rb/rb-sys) from 0.9.91 to 0.9.94. - [Release notes](https://github.com/oxidize-rb/rb-sys/releases) - [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.91...v0.9.94) --- updated-dependencies: - dependency-name: rb-sys dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> https://github.com/rubygems/rubygems/commit/04cf565ebe
2024-04-15[rubygems/rubygems] Bump rb-sysdependabot[bot]
Bumps [rb-sys](https://github.com/oxidize-rb/rb-sys) from 0.9.91 to 0.9.94. - [Release notes](https://github.com/oxidize-rb/rb-sys/releases) - [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.91...v0.9.94) --- updated-dependencies: - dependency-name: rb-sys dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> https://github.com/rubygems/rubygems/commit/ac952f030b
2024-04-15Emit a performance warning when redefining specially optimized methodsJean Boussier
This makes it easier to notice a dependency is causing interpreter or JIT deoptimization. ```ruby Warning[:performance] = true class String def freeze super end end ``` ``` ./test.rb:4: warning: Redefining 'String#freeze' disable multiple interpreter and JIT optimizations ```
2024-04-15[ruby/reline] Fix vi_to_column which was brokentomoya ishida
(https://github.com/ruby/reline/pull/679) https://github.com/ruby/reline/commit/9e93ad52e7
2024-04-15Include more debug information in test_uplus_minusJean Boussier
2024-04-15Add more assertions in `test_uplus_minus`Jean Boussier
Not along after 1b830740ba8371c4bcfdfc6eb2cb7e0ae81a84e0 CI started to rarely fail this test: ``` TestString#test_uplus_minus: Test::Unit::AssertionFailedError: uminus deduplicates [Feature #13077]. 1) Failure: TestString#test_uplus_minus [/tmp/ruby/src/trunk/test/ruby/test_string.rb:3368]: ``` It's unclear what is going on, but one possibility is that `"bar".freeze` might no longer compile correctly. Another possibility is that another test redefine `String#freeze`, causing `opt_str_freeze` to no longer return an `fstring`.
2024-04-15`super{}` doesn't use blockKoichi Sasada
`super(){}`, `super{}` and `super(&b)` doesn't use the given block so warn unused block warning when calling a method which doesn't use block with above `super` expressions. e.g.: `def f = super{B1}` (warn on `f{B2}` because `B2` is not used.
2024-04-15fix incorrect warning.Koichi Sasada
`super()` (not zsuper) passes the passed block and it can be used. ```ruby class C0 def foo; yield; end end class C1 < C0 def foo; super(); end end C1.new.foo{p :block} #=> :block ```
2024-04-15show warning for unused blockKoichi Sasada
With verbopse mode (-w), the interpreter shows a warning if a block is passed to a method which does not use the given block. Warning on: * the invoked method is written in C * the invoked method is not `initialize` * not invoked with `super` * the first time on the call-site with the invoked method (`obj.foo{}` will be warned once if `foo` is same method) [Feature #15554] `Primitive.attr! :use_block` is introduced to declare that primitive functions (written in C) will use passed block. For minitest, test needs some tweak, so use https://github.com/minitest/minitest/commit/ea9caafc0754b1d6236a490d59e624b53209734a for `test-bundled-gems`.
2024-04-15Emit `warn` event for duplicated hash keys on ripperyui-knk
Need to use `rb_warn` macro instead of calling `rb_compile_warn` directly to emit `warn` event on ripper.
2024-04-14[ruby/reline] Refactor waiting_proc and waiting_operator_proctomoya ishida
(https://github.com/ruby/reline/pull/649) * Fix waiting_proc precedence * Fix waiting_operator bugs * Add waiting_proc and vi_waiting_operator test * Fix vi waiting operator arg number vi_arg and vi_waiting_operator_arg should be multiplied * Implement `yy` copies whole line in vi_command mode * Simplify incremental search cancel test * Add complex vi test with waiting_proc and vi_waiting_operator, split test input https://github.com/ruby/reline/commit/777dffae1c
2024-04-14[ruby/irb] Allow defining custom commands in IRBStan Lo
(https://github.com/ruby/irb/pull/886) This is a feature that has been requested for a long time. It is now possible to define custom commands in IRB. Example usage: ```ruby require "irb/command" class HelloCommand < IRB::Command::Base description "Prints hello world" category "My commands" help_message "It doesn't do more than printing hello world." def execute puts "Hello world" end end IRB::Command.register(:hello, HelloCommand) ``` https://github.com/ruby/irb/commit/888643467c
2024-04-14[ruby/reline] Support `menu-complete-backward` command for upwardMichael J. Giarlo
navigation (https://github.com/ruby/reline/pull/677) Fixes https://github.com/ruby/reline/pull/675 This commit extracts the upward navigation condition in `LineEditor#input_key` to a new private method, and adds a new alias. This change allows Reline to support upward navigation in when a user has configured `inputrc` to map Shift-Tab to `menu-complete-backward`, a common setting in Bash (>= 4.x). Instead of special-casing upward navigation in `LineEditor#input_key`, we now allow it to be processed by the branch that calls `process_key`. The extracted method no longer includes the editing mode check since this check is already made by `#wrap_method_call` by the time `#completion_journey_up` (or `#menu_complete_backward`) is called. Since upward navigation is happening in a method other than `#input_key` now, the `completion_occurs` variable that used to be local to `#input_key` is changed to an instance variable so that the new method can change its value. (I see many examples of mutating such instance variables in `LineEditor`, so I assumed this would be an uncontroversial change consistent with the coding practices already in place.) Test coverage of this change has been added to the emacs and vi `KeyActor` tests. Many thanks to @ima1zumi for their very helpful comments on #675 which encouraged me to contribute this work! https://github.com/ruby/reline/commit/2ccdb374a4
2024-04-14Resize ary when `Array#sort!` block modifies embedded aryZack Deveau
In cases where `rb_ary_sort_bang` is called with a block and tmp is an embedded array, we need to account for the block potentially impacting the capacity of ary. ex: ``` var_0 = (1..70).to_a var_0.sort! do |var_0_block_129, var_1_block_129| var_0.pop var_1_block_129 <=> var_0_block_129 end.shift(3) ``` The above example can put the array into a corrupted state resulting in a heap buffer overflow and possible segfault: ``` ERROR: AddressSanitizer: heap-buffer-overflow on address [...] WRITE of size 560 at 0x60b0000034f0 thread T0 [...] ``` This commit adds a conditional to determine when the capacity of ary has been modified by the provided block. If this is the case, ensure that the capacity of ary is adjusted to handle at minimum the len of tmp.
2024-04-12[PRISM] Enable passing test_parenthesised_statement_argumentKevin Newton
2024-04-12[ruby/prism] Better error message on statement inside argument listKevin Newton
https://github.com/ruby/prism/commit/3b1a99526a
2024-04-12[PRISM] Enable passing tests from latest prismKevin Newton
2024-04-12[PRISM] Emit parse warnings before raising syntax errorsKevin Newton
2024-04-12[PRISM] Enable more passing testsKevin Newton
2024-04-12[ruby/prism] Better error message on invalid defKevin Newton
https://github.com/ruby/prism/commit/d398e7d22c
2024-04-12[ruby/prism] Syntax error for block argument on yieldKevin Newton
https://github.com/ruby/prism/commit/9feeafbc67
2024-04-12[ruby/prism] Fix up embdoc lexing on EOFKevin Newton
https://github.com/ruby/prism/commit/8ee43be26d
2024-04-12Refactor how object IDs work for special constsPeter Zhu
We don't need to treat static symbols in any special way since they can't be confused with other special consts or GC managed objects.
2024-04-12[PRISM] Enable passing tests for prismKevin Newton
2024-04-12[ruby/prism] Create the warning for unreachable statementsKevin Newton
https://github.com/ruby/prism/commit/e17c86b886
2024-04-12[PRISM] Ensure no void warnings in rubyoptions testKevin Newton
2024-04-12[ruby/prism] Implement the void statement warningKevin Newton
https://github.com/ruby/prism/commit/802ff71cd4
2024-04-12[ruby/prism] Fix parser translation's heredoc whitespace calculationStan Lo
Given this example: ```rb <<~HEREDOC #{x} HEREDOC ``` Both the parser gem and Prism's translation layer would generate the following AST: ``` s(:dstr, s(:begin, s(:int, 1)), s(:str, " a\n")) ``` However, the parser gem inserts a empty string node into this node's location, like: ``` <Parser::Source::Map::Heredoc:0x0000000104ce73b8 @expression=#<Parser::Source::Range (string) 0...10>, @heredoc_body=#<Parser::Source::Range (string) 11...20>, @heredoc_end=#<Parser::Source::Range (string) 20...27>, @node=s(:dstr, s(:str, ""), s(:begin, s(:int, 1)), s(:str, " a\n"))> ``` This is required to calculate the correct whitespace for the heredoc body. We need to adjust the translation layer to account for this. With this fix, we also won't need to ignore the tilde heredoc fixture anymore. https://github.com/ruby/prism/commit/e7372e3ba5
2024-04-12Sync latest prismKevin Newton
2024-04-12[ruby/irb] Pass statements to Context#evaluateStan Lo
(https://github.com/ruby/irb/pull/920) This has a few benefits: - We can keep hiding the evaluation logic inside the Context level, which has always been the convention until #824 was merged recently. - Although not an official API, gems like `debug` and `mission_control-jobs` patch `Context#evaluate` to wrap their own logic around it. This implicit contract was broken after #824, and this change restores it. In addition to the refactor, I also converted some context-level evaluation tests into integration tests, which are more robust and easier to maintain. https://github.com/ruby/irb/commit/b32aee4068