summaryrefslogtreecommitdiff
path: root/test/irb
Commit message (Collapse)AuthorAgeFilesLines
* [ruby/irb] Print deprecation warning for `help` commandHEADmasterStan Lo2023-05-181-12/+26
| | | | | | | | (https://github.com/ruby/irb/pull/567) * Give show_doc its own command class * Print deprecation warning for `help` command
* [ruby/irb] Fix Test timedout in test_debug_cmdtomoya ishida2023-05-171-2/+5
| | | | | | | | (https://github.com/ruby/irb/pull/582) * Suppress Reline::IOGate.cursor_pos writing escape sequence in test_debug_cmd * Force use Reline::GeneralIO as Reline::IOGate and remove RUBY_DEBUG_NO_RELINE option for debug test
* [ruby/irb] Use a more tolerant way to check Locale#find's returnStan Lo2023-04-261-4/+4
| | | | | | | path (https://github.com/ruby/irb/pull/572) https://github.com/ruby/irb/commit/0b648adf38
* [ruby/irb] Add tests for Locale#find and Locale#loadStan Lo2023-04-261-0/+35
| | | | | | (https://github.com/ruby/irb/pull/570) https://github.com/ruby/irb/commit/710d5b1af5
* [ruby/irb] Fix Locale's encoding lookup for Japanese encodingsStan Lo2023-04-261-2/+2
| | | | | | | | | | | | | | (https://github.com/ruby/irb/pull/568) In https://github.com/ruby/irb/commit/3ee79e89adb8e21b63d796e53bcc86281685076d, `encoding_aliases.rb` was introduced to return the correct encoding object for `ujis` and `euc` encodings. However, the return value of `@@legacy_encoding_alias_map[@encoding_name]` is always overridden by a second look up with `Encoding.find(@encoding_name)`. So the logic didn't work as expected. This commit fixes the problem.
* Revert "Temporary skipped failing assertions"Hiroshi SHIBATA2023-04-261-2/+2
| | | | This reverts commit e7cdce83e8c8797c481ccb54c260c0db1e1afa7c.
* Temporary skipped failing assertionsHiroshi SHIBATA2023-04-251-2/+2
|
* [ruby/irb] Add tests for Locale classStan Lo2023-04-251-0/+83
| | | | | | (https://github.com/ruby/irb/pull/566) https://github.com/ruby/irb/commit/df32e024be
* [ruby/irb] Simplify the help command's implementationStan Lo2023-04-241-3/+5
| | | | | | | | | | | | (https://github.com/ruby/irb/pull/564) The current method-redefining approach brings little benefit, makes it harder to understand the code, and causes warnings like: > warning: method redefined; discarding old execute This patch simplifies it while displaying more helpful message when rdoc couldn't be loaded.
* [ruby/irb] Filter out top-level methods when using `lsStan Lo2023-04-241-1/+4
| | | | | | | | | <Class/Module>` (https://github.com/ruby/irb/pull/562) Instead of always printing methods inherited from Class or Module, IRB by default should filter them out unless `<Class/Module>` is specified to be either of those.
* [ruby/irb] Fix RubyLex's heredoc_with_hembexpr test to avoid rippertomoya ishida2023-04-071-3/+3
| | | | | | | tokenizing issue (https://github.com/ruby/irb/pull/558) https://github.com/ruby/irb/commit/f68e891ed1
* [ruby/irb] Drop Ruby 2.6 supportStan Lo2023-04-055-64/+7
| | | | | | | | | | | | | | (https://github.com/ruby/irb/pull/555) * Remove all Ruby 2.6 support * Drop Ruby 2.6 specific testing conditions * Only run Ruby 2.7+ on CI * Bump Ruby requirement to 2.7+ https://github.com/ruby/irb/commit/3f714b616c
* [ruby/irb] Don't check RUBY_ENGINE when deciding whether to accept kargsStan Lo2023-04-021-2/+0
| | | | | | | | | | Ruby implementations like JRuby and TruffleRuby already indicate their compatibility target with RUBY_VERSION. We don't need to exclude them from accepting keyword arguments as long as they target 2.7+. https://github.com/ruby/irb/commit/bf20faa4e6 Co-authored-by: Kevin Menard <kevin@nirvdrum.com>
* [ruby/irb] Drop unnecessary pends for trufflerubyStan Lo2023-03-312-2/+1
| | | | https://github.com/ruby/irb/commit/2517039812
* [ruby/irb] Fix 2 minor issues in test suitelukeg2023-03-172-233/+237
| | | | | | | | * undefine Kernel#irb_original_require in without_rdoc method * Don't rescue all LoadErrors/NameErrors in test_rendering.rb, just the one for require 'yamatanooroti' https://github.com/ruby/irb/commit/52b79806ea
* [ruby/irb] Support inspecting BasicObjectStan Lo2023-03-131-1/+13
| | | | | | (https://github.com/ruby/irb/pull/541) https://github.com/ruby/irb/commit/1dc2a406a3
* [ruby/irb] Improve method completion for string and regexp thattomoya ishida2023-03-061-0/+4
| | | | | | | | | | | | | | | | | | | | | | | includes word break characters (https://github.com/ruby/irb/pull/523) * Improve method completion for string and regexp that includes word break characters * Remove completion-test's assert_not_include because candidates no longer include every possible methods * Add comment about string's method completion regexp Co-authored-by: Stan Lo <stan001212@gmail.com> * Add comment about regexp's method completion regexp Co-authored-by: Stan Lo <stan001212@gmail.com> --------- https://github.com/ruby/irb/commit/aa8128c533 Co-authored-by: Stan Lo <stan001212@gmail.com>
* [ruby/irb] Drop chained methods' completion supportStan Lo2023-03-041-2/+0
| | | | | | | | | | | | | | | | (https://github.com/ruby/irb/pull/529) Consider completion for this example: `foo.bar.b` Without type information, it is hard to know the return value of the `bar` method, so the current implementation interates through `ObjectSpace` to get all possible candidates for the second method. In small projects, the performance and accuracy are acceptable. But in bigger projects, the performance is unacceptable and the accuracy is mostly poor. So this commit drops the support for chained methods' completion.
* [ruby/irb] Remove no longer necessary TruffleRuby test exclusions.Kevin Menard2023-03-031-3/+1
| | | | | | | | (https://github.com/ruby/irb/pull/527) https://github.com/ruby/irb/commit/8473d0bc0f Co-authored-by: Stan Lo <stan.lo@shopify.com>
* [ruby/irb] Avoid slow symbol completion when completion target is antomoya ishida2023-03-031-0/+2
| | | | | | | empty symbol (https://github.com/ruby/irb/pull/534) https://github.com/ruby/irb/commit/35697f3ef3
* [ruby/irb] Fix prompt test not to change STDIO.external_encodingtomoya ishida2023-03-031-3/+5
| | | | | | (https://github.com/ruby/irb/pull/535) https://github.com/ruby/irb/commit/09f16259db
* [ruby/irb] Fix warnings because of `@context.main.delete`Nobuyoshi Nakada2023-03-031-2/+5
| | | | | | | | | | | If the main object of the context has `#delete` method, the following warning is printed. ``` irb: warn: can't alias delete from irb_delete. ``` https://github.com/ruby/irb/commit/00b39be61f
* [ruby/irb] Handle long inspect and control character in prompttomoya ishida2023-03-021-0/+17
| | | | | | | | | | | string (https://github.com/ruby/irb/pull/528) * Handle long inspect and control characters in prompt string * Add constants for prompt truncate length, omission and replace pattern * Simply compare string instead of regexp in prompt truncation test
* [ruby/irb] Display and prioritise instance methods in `lsStan Lo2023-02-281-0/+60
| | | | | | | <module/class>` (https://github.com/ruby/irb/pull/496) https://github.com/ruby/irb/commit/e3d21f9329
* [ruby/irb] Provide more useful message whenStan Lo2023-02-271-5/+57
| | | | | | | | | | | | | | | | | | | | | | | | | `IRB::Inspector#inspect_value` errors (https://github.com/ruby/irb/pull/511) **Before** ``` irb(main):001:0> c = Cat.new "foo" (Object doesn't support #inspect) => ``` **After** ``` irb(main):001:0> c = Cat.new "foo" An error occurred when inspecting the object: #<NoMethodError: undefined method `is_a?' for foo:Cat if obj.is_a?(String) ^^^^^^> Result of Kernel#inspect: #<Cat:0x0000000109090d80 @name="foo"> => ```
* [ruby/irb] Cleanup completion testsStan Lo2023-02-241-18/+0
| | | | | | | | | | | | | | | | | | (https://github.com/ruby/irb/pull/520) * Remove redundant completion test The test case was introduced to guard an old implementation, which relied on `Module#name`. Commit: https://github.com/ruby/irb/commit/8827d182746396dbf4499c2c1c8c0e9bf8375b7c However, the current implementation has avoided calling `Module#name` completely, so the test case is no longer necessary. Commit: https://github.com/ruby/irb/commit/88311ce3c84251e6f420246cd14efc96e00888be * Remove unnecessary pend
* [ruby/irb] Improve RubyLex's testsStan Lo2023-02-211-58/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (https://github.com/ruby/irb/pull/484) * Improve assert_indenting helper Instead of putting assertions inside the `auto_indent` block, we can just make `auto_indent` return the calculated space count, and use it for assertion outside of the `auto_indent` block call. This simplifies the setup code and makes the intention easier to understand. * Introduce assert_row_indenting helper 1. Helper users shouldn't need to write 2 assertions for the current and the next line's indentation. 2. With this new approach, we can generate clearer error message for both cases: When the current line's space count doesn't match ``` Incorrect spaces calculation for line: ``` > def each_top_level_statement ``` All lines: ``` def each_top_level_statement ``` <0> expected but was <nil> ``` When the next line's space count doesn't match ``` Incorrect spaces calculation for line after the current line: ``` def each_top_level_statement > ``` All lines: ``` def each_top_level_statement ``` <3> expected but was <2> ``` * Replace assert_indenting with assert_row_indenting
* [ruby/irb] Fix colorize backtick symboltomoya ishida2023-02-121-0/+1
| | | | | | | | (https://github.com/ruby/irb/pull/508) https://github.com/ruby/irb/commit/dd7f25cd45 Co-authored-by: Stan Lo <stan001212@gmail.com>
* [ruby/irb] Make tests more compatible with TruffleRubyStan Lo2023-02-091-9/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (https://github.com/ruby/irb/pull/514) * Improve encoding error test case The test input IRB currently uses happen to hit a compatibility bug in TruffleRuby, which has been documented in https://github.com/oracle/truffleruby/issues/2848 Although it'll eventually be fixed, we can make the test case support TruffleRuby now by tweaking it just a little bit. Co-authored-by: Kevin Menard <kevin@nirvdrum.com> * Remove redundant TruffleRuby omits/pends Co-authored-by: Kevin Menard <kevin@nirvdrum.com> * Use a different way to test warning emission The test case was added in https://github.com/ruby/irb/commit/d08ef68d2dfbf041d363f65686d78a937954513c to verify that IRB emits Ruby warning as expected. But the subject it uses relies on CRuby's regexp engine, which isn't always used in other language implementations, like TruffleRuby. That's why we ended up skipping TruffleRuby in this test case. Since the test isn't about regexp itself, we can change the testing subject and just remove the special condition for TruffleRuby. Co-authored-by: Kevin Menard <kevin@nirvdrum.com> --------- https://github.com/ruby/irb/commit/6fdf4f3e97 Co-authored-by: Kevin Menard <kevin@nirvdrum.com>
* [ruby/irb] Add tests for workspaces commandsStan Lo2023-02-041-0/+112
| | | | | | (https://github.com/ruby/irb/pull/512) https://github.com/ruby/irb/commit/874dbcad81
* [ruby/irb] Store context in RubyLexStan Lo2023-01-141-14/+17
| | | | | | | | | | | | | | | | | | Some background for this refactor: 1. Through a RubyLex instance's lifetime, the context passed to its methods should be the same. Given that `Context` is only initialised in `Irb#initialize`, this should be true. 2. When `RubyLex` is initialised, the context object should be accessible. This is also true in all 3 of `RubyLex.new`'s invocations. With the above observations, we should be able to store the context in `RubyLex` as an instance variable. And doing so will make `RubyLex`'s instance methods easier to use and maintain. https://github.com/ruby/irb/commit/5c8d3df2df
* [ruby/irb] Avoid calling private methods on the main objectStan Lo2023-01-121-0/+13
| | | | | | | | | | | | (https://github.com/ruby/irb/pull/498) When the main object is frozen, `IRB` wraps a `SimpleDelegator` around it. But because `SimpleDelegator` doesn't delegate private methods, methods like `require_relative` or `const_get` would cause error, which are needed for lazily loading commands. This commit works around this limitation by avoiding those private method calls when setting up command execution.
* [ruby/irb] Drop unused arguments in `RubyLex`Stan Lo2023-01-111-1/+3
| | | | | | | | | | | | | (https://github.com/ruby/irb/pull/504) * Simplify `RubyLex#set_prompt` It's optional argument is never used by any caller. * Remove the optional `p` argument from `RubyLex#set_input` The argument is only used in a test case, which can be easily replaced by a block argument.
* [ruby/irb] Group command test cases with classStan Lo2023-01-051-297/+312
| | | | | | | | | | | (https://github.com/ruby/irb/pull/491) Currently, IRB has 35 test cases for 10 non-debugging commands, with the rest 10 commands untested. So in the long-term, it could have around 70 test cases for all existing commands. With this number of test cases, I think it's easier to manage them by grouping them in classes (by command).
* [ruby/irb] Fix prompt and code mismatchtomoya ishida2023-01-021-0/+32
| | | | | | | | | | | | (https://github.com/ruby/irb/pull/386) * fix prompt and code mismatch * Add test for prompt and code mismatch bug https://github.com/ruby/irb/commit/a5765d8177 Co-authored-by: Stan Lo <stan001212@gmail.com>
* [ruby/irb] Add dynamic prompt test case for quoted heredocStan Lo2022-12-271-0/+18
| | | | | | (https://github.com/ruby/irb/pull/486) https://github.com/ruby/irb/commit/31cfbeacbb
* Sync IRB master: tool/sync_default_gems.rb irbTakashi Kokubun2022-12-262-44/+63
| | | | | | | | | | | It looks like tool/sync_default_gems.rb is not capable of cherry-picking commits from ruby/irb. I just executed `tool/sync_default_gems.rb irb` to fix the sync status. I'm not sure if what's the cause. It could be related to some diff that doesn't exist in ruby/ruby, or it might be related to non-linear history due to merge commits. For next time, I'd like to at least exclude the second possibility, so I disabled merge commits in ruby/irb.
* [ruby/irb] Suppress "switching inspect mode" messagesNobuyoshi Nakada2022-12-261-0/+2
| | | | https://github.com/ruby/irb/commit/565eeb3c19
* [ruby/irb] Remove unnecessary warning check on help commandStan Lo2022-12-261-5/+0
| | | | | | | | It's not an intentional behavior of the command and it behaves differently in different environments. So checking it actually brings more problem than benefit. https://github.com/ruby/irb/commit/b3203bc784
* [ruby/irb] Remove unnecessary test setupStan Lo2022-12-261-4/+0
| | | | https://github.com/ruby/irb/commit/cc6e6d26b6
* [ruby/irb] Add test for the help commandst00122022-12-261-0/+51
| | | | https://github.com/ruby/irb/commit/9cacb5f352
* [ruby/irb] Test colors with enabling colorsNobuyoshi Nakada2022-12-262-0/+22
| | | | https://github.com/ruby/irb/commit/998b7a74fa
* [ruby/irb] PTY module is platform dependentNobuyoshi Nakada2022-12-191-1/+6
| | | | https://github.com/ruby/irb/commit/dbb3dc72ff
* [ruby/irb] Prefer to use File.open instead of Kernel.openHiroshi SHIBATA2022-12-161-2/+2
| | | | https://github.com/ruby/irb/commit/ed9e435a6b
* [ruby/irb] Group show_doc tests and update the expectationStan Lo2022-12-121-32/+34
| | | | | | (https://github.com/ruby/irb/pull/479) https://github.com/ruby/irb/commit/bede04c14a
* [ruby/irb] `show_doc` command should take non-string argument tooStan Lo2022-12-121-2/+2
| | | | | | | | (https://github.com/ruby/irb/pull/478) Given that `show_doc` already supports syntax like `String#gsub`, it should be able to take it in non-string form too, like `edit` and `show_source` do. This ensures users can have a consistent syntax on argument between different commands.
* [ruby/irb] Fix step command (https://github.com/ruby/irb/pull/477)Stan Lo2022-12-091-1/+3
| | | | | | | | The current `next` pre-command workaround on IRB source stepping moves the location by 1 extra line. A better way is to make `debug` skip IRB frames completely, which is what this commit does. It also fixes the step command's test. The `|` in regexp was not escaped so it was always incorrectly matched.
* [ruby/irb] Add show_doc as an alias to the help commandStan Lo2022-12-081-9/+11
| | | | | | | | | | (https://github.com/ruby/irb/pull/475) In the long-term, we want to align with `Pry`, `byebug` and `debug` to use the `help` command to list all commands, which is what `show_cmds` currently does. And `show_doc` will be the command to look up Ruby APIs. By aliasing `show_doc` to the current `help` now, users will have time to get use to it.
* [ruby/irb] Gracefully handle missing command argumentStan Lo2022-12-081-0/+17
| | | | | | | | | | | | | | | | | (https://github.com/ruby/irb/pull/473) * Handle file loading commands' argument error gracefully Currently, if users don't provide an argument to `source`, `irb_load`, and `irb_require`, IRB raises `ArgumentError` with full stacktrace. This is confusing because it looks similar to when IRB has internal issues. The message also isn't helpful on helping users avoid the error. So in this commit, I add a new `CommandArgumentError` for commands to raise explicitly when users' input doesn't satisfy a command's argument requirement. * Gracefully handle `fg` command's argument requirement
* [ruby/irb] Kill PTY process after test is finishedStan Lo2022-12-081-1/+33
| | | | | | | (https://github.com/ruby/irb/pull/471) The killing/waiting logic is borrowed from ruby/debug: https://github.com/ruby/debug/blob/ec5ae5aebd61a99dc84028d8dffa8e7e165c1ec6/test/support/test_case.rb#L107-L136