summaryrefslogtreecommitdiff
path: root/test/irb
AgeCommit message (Collapse)Author
2023-06-13[ruby/irb] Use symbol.inspect instead of ":"+symbol.id2name to avoidtomoya ishida
completion candidates including newline characters (https://github.com/ruby/irb/pull/539) https://github.com/ruby/irb/commit/aaf0c46645
2023-06-05[ruby/irb] Fixed string escaping omissionsima1zumi
(https://github.com/ruby/irb/pull/599) I received a `RegexpError` when I typed `::Array[`. ::Array[/Users/mi/ghq/github.com/ruby/irb/lib/irb/completion.rb:236:in `retrieve_completion_data': premature end of char-class: /^Array[/ (RegexpError)
2023-06-02[ruby/irb] Require `test/lib` helpers from main test helperStan Lo
(https://github.com/ruby/irb/pull/595) Because they are handled differently in `ruby/irb` and `ruby/ruby`.
2023-06-01[ruby/irb] Improve debug command testsStan Lo
(https://github.com/ruby/irb/pull/594) * Use require_relative for envutil.rb Requiring test helper files with `require_relative` allows running the tests with `ruby -Itest test/irb/test_debug_cmd.rb` without having to set up the load path. * Replace reline hack with TERM=dumb
2023-05-23[ruby/irb] Allow `show_source` for private methodsTSUYUSATO Kitsune
(https://github.com/ruby/irb/pull/589) * Allow `show_source` for private methods Fix https://github.com/ruby/irb/pull/577 * Pend tests on TruffleRuby It seems `eval(..., __LINE__ + 1)` does not work. Other similar tests are also pended on TruffleRuby, so I think it is acceptable. * Use `private_method_defined?` instead of `defined?`
2023-05-21[ruby/irb] Fix typo (https://github.com/ruby/irb/pull/587)ima1zumi
* Fix typo * s/braking/breaking/g Co-authored-by: Stan Lo <stan001212@gmail.com> --------- https://github.com/ruby/irb/commit/5f8e69f5f2 Co-authored-by: Stan Lo <stan001212@gmail.com>
2023-05-20[ruby/irb] Add assertion for dynamic_prompt's assertion executionStan Lo
(https://github.com/ruby/irb/pull/586) Because the assertions for `dynamic_prompt` lives inside a block given to `RubyLex`, they could be skipped unnoticed if the setup is not correct. This commit adds a simple assertion to check if the block was actually executed.
2023-05-20[ruby/irb] Fix dynamic_prompt test not executed, remove unnecessarytomoya ishida
set_input (https://github.com/ruby/irb/pull/585) https://github.com/ruby/irb/commit/b5f3efdcf0
2023-05-19[ruby/irb] Simplify each_top_level_statementtomoya ishida
(https://github.com/ruby/irb/pull/576) * Simplify each_top_level_statement, reduce instance vars * Update lib/irb/ruby-lex.rb Co-authored-by: Stan Lo <stan001212@gmail.com> * Remove unused ltype from TestRubyLex#check_state response * Remove unnecessary const path of TerminateLineInput * Combine duplicated code state check into method --------- https://github.com/ruby/irb/commit/172453cec4 Co-authored-by: Stan Lo <stan001212@gmail.com>
2023-05-18[ruby/irb] Refactor RubyLex's input/io methodsStan Lo
(https://github.com/ruby/irb/pull/583) 1. Make `RubyLex#set_input` simply assign the input block. This matches the behavior of `RubyLex#set_prompt`. 2. Merge `RubyLex#set_input`'s IO configuration logic with `#set_auto_indent` into `#configure_io`.
2023-05-18[ruby/irb] Print deprecation warning for `help` commandStan Lo
(https://github.com/ruby/irb/pull/567) * Give show_doc its own command class * Print deprecation warning for `help` command
2023-05-17[ruby/irb] Fix Test timedout in test_debug_cmdtomoya ishida
(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
2023-04-26[ruby/irb] Use a more tolerant way to check Locale#find's returnStan Lo
path (https://github.com/ruby/irb/pull/572) https://github.com/ruby/irb/commit/0b648adf38
2023-04-26[ruby/irb] Add tests for Locale#find and Locale#loadStan Lo
(https://github.com/ruby/irb/pull/570) https://github.com/ruby/irb/commit/710d5b1af5
2023-04-26[ruby/irb] Fix Locale's encoding lookup for Japanese encodingsStan Lo
(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.
2023-04-26Revert "Temporary skipped failing assertions"Hiroshi SHIBATA
This reverts commit e7cdce83e8c8797c481ccb54c260c0db1e1afa7c.
2023-04-25Temporary skipped failing assertionsHiroshi SHIBATA
2023-04-25[ruby/irb] Add tests for Locale classStan Lo
(https://github.com/ruby/irb/pull/566) https://github.com/ruby/irb/commit/df32e024be
2023-04-24[ruby/irb] Simplify the help command's implementationStan Lo
(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.
2023-04-24[ruby/irb] Filter out top-level methods when using `lsStan Lo
<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.
2023-04-07[ruby/irb] Fix RubyLex's heredoc_with_hembexpr test to avoid rippertomoya ishida
tokenizing issue (https://github.com/ruby/irb/pull/558) https://github.com/ruby/irb/commit/f68e891ed1
2023-04-05[ruby/irb] Drop Ruby 2.6 supportStan Lo
(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
2023-04-02[ruby/irb] Don't check RUBY_ENGINE when deciding whether to accept kargsStan Lo
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>
2023-03-31[ruby/irb] Drop unnecessary pends for trufflerubyStan Lo
https://github.com/ruby/irb/commit/2517039812
2023-03-17[ruby/irb] Fix 2 minor issues in test suitelukeg
* 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
2023-03-13[ruby/irb] Support inspecting BasicObjectStan Lo
(https://github.com/ruby/irb/pull/541) https://github.com/ruby/irb/commit/1dc2a406a3
2023-03-06[ruby/irb] Improve method completion for string and regexp thattomoya ishida
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>
2023-03-04[ruby/irb] Drop chained methods' completion supportStan Lo
(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.
2023-03-03[ruby/irb] Remove no longer necessary TruffleRuby test exclusions.Kevin Menard
(https://github.com/ruby/irb/pull/527) https://github.com/ruby/irb/commit/8473d0bc0f Co-authored-by: Stan Lo <stan.lo@shopify.com>
2023-03-03[ruby/irb] Avoid slow symbol completion when completion target is antomoya ishida
empty symbol (https://github.com/ruby/irb/pull/534) https://github.com/ruby/irb/commit/35697f3ef3
2023-03-03[ruby/irb] Fix prompt test not to change STDIO.external_encodingtomoya ishida
(https://github.com/ruby/irb/pull/535) https://github.com/ruby/irb/commit/09f16259db
2023-03-03[ruby/irb] Fix warnings because of `@context.main.delete`Nobuyoshi Nakada
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
2023-03-02[ruby/irb] Handle long inspect and control character in prompttomoya ishida
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
2023-02-28[ruby/irb] Display and prioritise instance methods in `lsStan Lo
<module/class>` (https://github.com/ruby/irb/pull/496) https://github.com/ruby/irb/commit/e3d21f9329
2023-02-27[ruby/irb] Provide more useful message whenStan Lo
`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"> => ```
2023-02-24[ruby/irb] Cleanup completion testsStan Lo
(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
2023-02-21[ruby/irb] Improve RubyLex's testsStan Lo
(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
2023-02-12[ruby/irb] Fix colorize backtick symboltomoya ishida
(https://github.com/ruby/irb/pull/508) https://github.com/ruby/irb/commit/dd7f25cd45 Co-authored-by: Stan Lo <stan001212@gmail.com>
2023-02-09[ruby/irb] Make tests more compatible with TruffleRubyStan Lo
(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>
2023-02-04[ruby/irb] Add tests for workspaces commandsStan Lo
(https://github.com/ruby/irb/pull/512) https://github.com/ruby/irb/commit/874dbcad81
2023-01-14[ruby/irb] Store context in RubyLexStan Lo
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
2023-01-12[ruby/irb] Avoid calling private methods on the main objectStan Lo
(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.
2023-01-11[ruby/irb] Drop unused arguments in `RubyLex`Stan Lo
(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.
2023-01-05[ruby/irb] Group command test cases with classStan Lo
(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).
2023-01-02[ruby/irb] Fix prompt and code mismatchtomoya ishida
(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>
2022-12-27[ruby/irb] Add dynamic prompt test case for quoted heredocStan Lo
(https://github.com/ruby/irb/pull/486) https://github.com/ruby/irb/commit/31cfbeacbb
2022-12-26Sync IRB master: tool/sync_default_gems.rb irbTakashi Kokubun
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.
2022-12-26[ruby/irb] Suppress "switching inspect mode" messagesNobuyoshi Nakada
https://github.com/ruby/irb/commit/565eeb3c19
2022-12-26[ruby/irb] Remove unnecessary warning check on help commandStan Lo
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
2022-12-26[ruby/irb] Remove unnecessary test setupStan Lo
https://github.com/ruby/irb/commit/cc6e6d26b6