aboutsummaryrefslogtreecommitdiffstats
path: root/test/irb
Commit message (Collapse)AuthorAgeFilesLines
* [ruby/irb] Disable pager in eval_history testtomoya ishida2023-12-031-0/+1
| | | | | | (https://github.com/ruby/irb/pull/799) https://github.com/ruby/irb/commit/ee85e84935
* [ruby/irb] Implement `history` commandGary Tou2023-12-021-0/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (https://github.com/ruby/irb/pull/761) * Implement `history` command Lists IRB input history with indices. Also aliased as `hist`. * Add tests for `history` command * Address feedback: `puts` with multiple arguments instead of `join`ing * Address feedback: Handle nil from splitting an empty input string * Refactor line truncation * Add `-g` grep option to `history` command * Add `history` command to README * Remove unused `*args` parameter * Allow spaces to be included in grep * Allow `/` to be included in grep regex * Handle `input` being an empty string * Exclude "#{index}: " from matching the grep regex * Add new line after joining https://github.com/ruby/irb/commit/3f9eacbfa9
* [ruby/irb] Scrub past history input before splithogelog2023-12-011-2/+19
| | | | | | | | | | (https://github.com/ruby/irb/pull/795) * Scrub past history input before split * Don't rewrite ENV["LANG"] https://github.com/ruby/irb/commit/0f344f66d9
* [ruby/irb] Page evaluation result's outputStan Lo2023-11-305-11/+50
| | | | | | | | | | | | | | (https://github.com/ruby/irb/pull/784) * Page evaluation result's output This will make it easier to work with long output that exceeds the terminal's height. * Use consistent TERM in rendering tests This makes sure we get consistent result on all platforms. https://github.com/ruby/irb/commit/4fedce93d3
* [ruby/irb] Use gem repl_type_completor, remove type_completiontomoya ishida2023-11-296-1086/+84
| | | | | | | implementation (https://github.com/ruby/irb/pull/772) https://github.com/ruby/irb/commit/a4868a5373
* [ruby/irb] Change show_source tests into integration testsPeter Zhu2023-11-282-228/+263
| | | | | | | | | | | | | | * Remove trailing spaces * Migrate show_source tests to integration tests Because show_source tests often need to define class and/or methods, they can easily leak state to other tests. Changing them to integration tests will ensure that they are run in a clean environment. * Fix NoMethodError caused by SourceFinder#method_target https://github.com/ruby/irb/commit/3c39f13397c72a8db24e50afdcb8942e6c4ea12f
* [ruby/irb] This enhancement allows a user to add the -s flag if theypaulreece2023-11-281-0/+138
| | | | | | | | want to access a methods origin definition. It allows for chaining of multiple esses to further go up the classes as needed. (https://github.com/ruby/irb/pull/770) https://github.com/ruby/irb/commit/eec1329d5a
* [ruby/irb] Rescue errors from main.to_s/inspect when formattingKasumi Hanazuki2023-11-281-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | prompt (https://github.com/ruby/irb/pull/791) Currently, IRB just terminates if `main.to_s` raises while IRB constructs the prompt string. This can easily happen if the user wants to start an IRB session in the instance scope of an uninitialized object, for example: ``` class C def initialize binding.irb @values = [] end def to_s = @values.join(',') # raises if uninitialized end C.new ``` This patch makes IRB rescue from such an exception and displays the class name of the exception instead of `main.to_s` to indicate some error has occurred. We may display more detailed information about the exception, but this patch chooses not to do so because 1) the prompt has limited space, 2) users can evaluate `to_s` in IRB to examine the error if they want, and 3) obtaining the details can also raise, which requires nested exception handling and can be complicated. https://github.com/ruby/irb/commit/412ab26067
* [ruby/irb] Hide debugger hint after the input is submittedStan Lo2023-11-271-2/+6
| | | | | | | | | | (https://github.com/ruby/irb/pull/789) If `output_modifier_proc`'s `complete` arg is true, it means the input is submitted. In that case, debugger hint doesn't provide value to users and adds noise to the output. So we hide it in such case. https://github.com/ruby/irb/commit/f86d9dbe2f
* [ruby/irb] Display aliases in help messageStan Lo2023-11-261-0/+10
| | | | | | | | | | | | | | | | | (https://github.com/ruby/irb/pull/788) Similar to Pry, it displays user-defined aliases in the help message with a dedicated section. With the current default aliases, it looks like: ``` ...other sections... Aliases $ Alias for `show_source` @ Alias for `whereami` ``` https://github.com/ruby/irb/commit/2a0eacc891
* [ruby/irb] Support disabling pagerStan Lo2023-11-263-10/+7
| | | | | | | | | | | (https://github.com/ruby/irb/pull/783) With either `IRB.conf[:USE_PAGER] = false` or `--no-pager` commnad line flag. I decided use `--no-pager` instead of `--use-pager` because it matches with Pry and git's command line flags. https://github.com/ruby/irb/commit/df1c3b9042
* [ruby/irb] Fix exception(backtrace=nil) prints nothingtomoya ishida2023-11-251-5/+2
| | | | | | (https://github.com/ruby/irb/pull/782) https://github.com/ruby/irb/commit/fa9ecf9a5b
* [ruby/irb] Fix flaky test casehogelog2023-11-251-6/+4
| | | | | | | test_autocomplete_with_multiple_doc_namespaces (https://github.com/ruby/irb/pull/786) https://github.com/ruby/irb/commit/85c6ddeb7d
* [ruby/irb] Handle handle_exception's exceptiontomoya ishida2023-11-231-2/+23
| | | | | | (https://github.com/ruby/irb/pull/780) https://github.com/ruby/irb/commit/d42138c477
* [ruby/irb] Hint debugger command in irb:rdbg sessionStan Lo2023-11-231-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | (https://github.com/ruby/irb/pull/768) When user enters irb:rdbg session, they don't get the same hint that the `debug` gem provides, like ``` (rdbg) n # next command ``` This means that users may accidentally execute commands when they want to retrieve the value of a variable. So this commit adds a Reline output modifier to add a simiar hint: ``` irb:rdbg(main):002> n # debug command ``` It is not exactly the same as `debug`'s because in this case the importance is to help users distinguish between value evaluation and debugger command execution. https://github.com/ruby/irb/commit/fdf24de851
* [ruby/irb] Enable Setting Completer Type through `IRB_COMPLETOR`ima1zumi2023-11-211-0/+28
| | | | | | | | | | | | | | | | (https://github.com/ruby/irb/pull/771) I propose introducing the capability to set the IRB completion kinds via an environment variable, specifically `IRB_COMPLETOR=type`. This feature aims to enhance the Rails console experience by allowing Rails users to specify their preferred completion more conveniently. Currently, when using the Rails console, there's no straightforward way to globally set the type completion across a Rails application repository. It's possible to configure this setting by placing a `.irbrc` file at the project root. However, using a .irbrc file is not ideal as it allows for broad configurations and can potentially affect the production environment. My suggestion focuses on allowing users to set the completion to 'type' in a minimal. This enhancement would be particularly beneficial for teams writing RBS in their Rails applications. This type completer, integrated with RBS, would enhance completion accuracy, improving the Rails console experience. https://github.com/ruby/irb/commit/032f6da25f
* [ruby/irb] Fix irb crash on `{}.` completiontomoya ishida2023-11-182-2/+17
| | | | | | (https://github.com/ruby/irb/pull/764) https://github.com/ruby/irb/commit/07e4d540cc
* Fix IRB tests (#8925)Hiroshi SHIBATA2023-11-152-10/+11
| | | | | | | | | | | | | | | * Revert "Fixup da2c2931a60" This reverts commit e1978a905a32af2d48b6e9efb6d0fe1656fddc5b. * Revert "Skip Type completion tests related with IRB::VERSION" This reverts commit da2c2931a602da22bc1fd10dc41f5c3a117bf502. * require irb/version to test IRB::VERSION --------- Co-authored-by: tompng <tomoyapenguin@gmail.com>
* Fixup da2c2931a60Hiroshi SHIBATA2023-11-151-10/+8
|
* Skip Type completion tests related with IRB::VERSIONHiroshi SHIBATA2023-11-152-3/+5
|
* Revert "Tests of irb is still broken."Hiroshi SHIBATA2023-11-155-9/+0
| | | | | | | | This reverts commit 5398bbcbab702907430ee019d07f5dcf2b0ce4af. We explicitly load rubygems at rubygems_ext.rb https://github.com/rubygems/rubygems/commit/8840d8507be72ff32bcbbdfb14e0b54efb364ffa
* Tests of irb is still broken.Hiroshi SHIBATA2023-11-105-0/+9
| | | | | | Revert "[ruby/irb] Revert "Skip TypeCompletion test in ruby ci" This reverts commit 589e2b6782f17d5a1d55021c0395d5d73224e9da.
* [ruby/irb] Revert "Skip TypeCompletion test in ruby ciHiroshi SHIBATA2023-11-105-9/+0
| | | | | | | | | (https://github.com/ruby/irb/pull/748)" (https://github.com/ruby/irb/pull/755) This reverts commit https://github.com/ruby/irb/commit/d394af0bbce4. https://github.com/ruby/irb/commit/a9d0145115
* [ruby/irb] Add command line option to select which completor to usetomoya ishida2023-11-091-0/+16
| | | | | | | | | | (https://github.com/ruby/irb/pull/754) * Add command line option to select which completor to use * Add test for completor argv https://github.com/ruby/irb/commit/1dec2708c9
* [ruby/irb] Skip TypeCompletion test in ruby citomoya ishida2023-11-085-0/+9
| | | | | | (https://github.com/ruby/irb/pull/748) https://github.com/ruby/irb/commit/d394af0bbc
* [ruby/irb] Type based completion using Prism and RBStomoya ishida2023-11-087-5/+1107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (https://github.com/ruby/irb/pull/708) * Add completor using prism and rbs * Add TypeCompletion test * Switchable completors: RegexpCompletor and TypeCompletion::Completor * Add completion info to irb_info * Complete reserved words * Fix [*] (*) {**} and prism's change of KeywordParameterNode * Fix require, frozen_string_literal * Drop prism<=0.16.0 support * Add Completor.last_completion_error for debug report * Retrieve `self` and `Module.nesting` in more safe way * Support BasicObject * Handle lvar and ivar get exception correctly * Skip ivar reference test of non-self object in ruby < 3.2 * BaseScope to RootScope, move method objects constant under Methods * Remove unused Splat struct * Drop deeply nested array/hash type calculation from actual object. Now, calculation depth is 1 * Refactor loading rbs in test, change preload_in_thread not to cache Thread object * Use new option added in prism 0.17.1 to parse code with localvars * Add Prism version check and warn when :type completor cannot be enabled * build_type_completor should skip truffleruby (because endless method definition is not supported) https://github.com/ruby/irb/commit/1048c7ed7a
* [ruby/irb] Use IRB's own doc for doc dialog testsStan Lo2023-10-301-16/+20
| | | | | | | | | | | | (https://github.com/ruby/irb/pull/743) * Use IRB's own doc for doc dialog tests * Run doc dialog tests for older Rubies too * Remove unnecessary CI setups https://github.com/ruby/irb/commit/97a2b86f0a
* [ruby/irb] Minor refactors around irb.rbStan Lo2023-10-211-4/+4
| | | | | | | | | | | | | | | | (https://github.com/ruby/irb/pull/736) * Remove dead method * Simplify IRB.version * Move private Irb methods together * Centralise @CONF initialization/assignment in init.rb * Move attr_* calls above initialize method https://github.com/ruby/irb/commit/cf23be4395
* [ruby/irb] Suppress "Switch to inspect mode" messagesNobuyoshi Nakada2023-10-161-0/+1
| | | | | | | This message is displayed if STDIN is not a tty. The parallel test is the case. https://github.com/ruby/irb/commit/e26e90e3fb
* [ruby/irb] Restore encoding in InputCompletor testtomoya ishida2023-10-141-0/+2
| | | | | | (https://github.com/ruby/irb/pull/732) https://github.com/ruby/irb/commit/ef77c232cf
* [ruby/irb] Restore IRB::InputCompletor for compatibilitytomoya ishida2023-10-141-0/+25
| | | | | | (https://github.com/ruby/irb/pull/730) https://github.com/ruby/irb/commit/77265efc5f
* [ruby/irb] Fix require path completion disturbing string methodtomoya ishida2023-10-121-0/+3
| | | | | | | completion (https://github.com/ruby/irb/pull/726) https://github.com/ruby/irb/commit/e42dc74ce0
* [ruby/irb] Fix test runner exit bugtomoya ishida2023-10-122-10/+5
| | | | | | | | | | (https://github.com/ruby/irb/pull/728) * Remove useless test setup and teardown that sets MAIN_CONTEXT to nil * Avoid adding command methods to main object in test https://github.com/ruby/irb/commit/f204829a08
* [ruby/irb] Decouple RubyLex from prompt and line_notomoya ishida2023-10-122-23/+23
| | | | | | | | | | | | (https://github.com/ruby/irb/pull/701) * Remove instance variable prompt and line_no from RubyLex * Fix prompt test * Rename prompt generating method and make it private https://github.com/ruby/irb/commit/1ceb97fe2e
* [ruby/irb] Rename current completor to RegexpCompletor andtomoya ishida2023-10-112-156/+170
| | | | | | | | | | | | | | | | | | | | | | | | | refactored for future extension (https://github.com/ruby/irb/pull/707) * Move completion implementation to completion/regexp_completor for future extension * Remove constant CompletionProc and PerfectMatchedProc and add a class method * Move document display logic to InputCompletor. Each completor only need to implement `completion_caididates` and `doc_namespace` * Move display_document logic to RelineInputMethod * Use RegexpCompletor directly. Not through class method of InputCompletor. * RegexpCompletor extends BaseCompletor, move back definition to completion.rb * Move display_document test to input_method test * Stop re-initialize completor on each completion phase * Store completor to ReadlineInputMethod's iver https://github.com/ruby/irb/commit/1e98521483
* [ruby/irb] Clear all context usages in RubyLexStan Lo2023-10-042-28/+10
| | | | | | | | | | | | | | | | (https://github.com/ruby/irb/pull/684) After this change, `RubyLex` will not interact with `Context` directly in any way. This decoupling has a few benefits: - It makes `RubyLex` easier to test as it no longer has a dependency on `Context`. We can see this from the removal of `build_context` from `test_ruby_lex.rb`. - It will make `RubyLex` easier to understand as it will not be affected by state changes in `Context` objects. - It allows `RubyLex` to be used in places where `Context` is not available. https://github.com/ruby/irb/commit/d5b262a076
* [ruby/irb] Fix Reline's test failure running with `make test-alltomoya ishida2023-09-304-3/+5
| | | | | | | | | | | TESTS='reline irb'` (https://github.com/ruby/irb/pull/722) * Specify TestInputMethod in test to avoid RelineInputMethod to be used * Reset Reline in teardown to avoid test failure of `make test-all TESTS="irb reline"` https://github.com/ruby/irb/commit/5d67967eb1
* [ruby/irb] Disable pager in show-source testtomoya ishida2023-09-261-20/+4
| | | | | | (https://github.com/ruby/irb/pull/720) https://github.com/ruby/irb/commit/5669efa4c1
* [ruby/irb] Page show_source's outputStan Lo2023-09-221-6/+8
| | | | | | (https://github.com/ruby/irb/pull/719) https://github.com/ruby/irb/commit/3cedc5cb62
* [ruby/irb] Test should not depend on user's irbrc file specified bytomoya ishida2023-09-171-0/+1
| | | | | | | ENV['IRBRC'] (https://github.com/ruby/irb/pull/717) https://github.com/ruby/irb/commit/1d2d35dd33
* [ruby/irb] Test should not depend on user's irbrc filetomoya ishida2023-09-161-0/+4
| | | | | | (https://github.com/ruby/irb/pull/714) https://github.com/ruby/irb/commit/02703c46f9
* [ruby/irb] Handle Concurrent Sessions and Saving Readline::HISTORYChad Schroeder2023-09-161-36/+57
| | | | | | | | | | | | | | | | | | | | | | (https://github.com/ruby/irb/pull/651) * handle concurrent sessions and saving Readline::HISTORY, fixes https://github.com/ruby/irb/pull/510 * separate tests * don't mutate the HISTORY object on the class * avoid repeated .to_i calls * remove intermediary history array * work with array, fix test comment --------- https://github.com/ruby/irb/commit/1681ada328 Co-authored-by: Stan Lo <stan001212@gmail.com>
* [ruby/irb] Improve help/show_cmds message during debuggerStan Lo2023-08-291-0/+33
| | | | | | | | | | | integration (https://github.com/ruby/irb/pull/693) * `help` should display debugger's help during irb:rdbg session * Update `show_cmds`'s output when in irb:rdbg session https://github.com/ruby/irb/commit/4029c2e564
* [ruby/irb] Add --nomultiline indent and prompt testtomoya ishida2023-08-291-0/+29
| | | | | | (https://github.com/ruby/irb/pull/699) https://github.com/ruby/irb/commit/9b4aea753b
* [ruby/irb] Fix test warnings (https://github.com/ruby/irb/pull/698)Stan Lo2023-08-292-2/+2
| | | | | | | | * Encoding should be saved before creating Irb objects * Fix unused local warning https://github.com/ruby/irb/commit/036ec31034
* [ruby/irb] Print deprecation message for prompt_n methodsStan Lo2023-08-291-0/+12
| | | | | | | | | | | (https://github.com/ruby/irb/pull/691) They were removed in #685, but we should still keep them to avoid breaking changes to tools like Chef. https://github.com/chef/chef/blob/533ff089479763f29045e4e6ddf388b73fc99338/lib/chef/shell.rb#L138 https://github.com/ruby/irb/commit/b585e0c835
* [ruby/irb] Remove unused `PROMPT_N`Summer ☀️2023-08-293-15/+6
| | | | | | (https://github.com/ruby/irb/pull/685) https://github.com/ruby/irb/commit/66e69fa0dc
* [ruby/irb] Fix deprecation test when ran multiple timesPeter Zhu2023-08-261-4/+3
| | | | | | (https://github.com/ruby/irb/pull/695) https://github.com/ruby/irb/commit/ae0e5bb80f
* [ruby/irb] Deprecate RubyLex and warn about referencing to itStan Lo2023-08-242-10/+18
| | | | | | | | | | (https://github.com/ruby/irb/pull/692) `RubyLex` has always been a private component of IRB, so we should explicitly discourage usages of it. Also, it should be placed under the `IRB` module like other components. https://github.com/ruby/irb/commit/069b5625f7
* [ruby/irb] Avoid overriding user's `irb_name` setting in debuggerStan Lo2023-08-213-6/+37
| | | | | | | | | | | | | | integration (https://github.com/ruby/irb/pull/688) * Avoid overriding user's irb_name setting in debugger integration Instead of always setting `irb_name` to `irb:rdbg`, it should respect the user's setting and only append `:rdbg` to it. * Introduce write_rc test helper https://github.com/ruby/irb/commit/2ce7593351