summaryrefslogtreecommitdiff
path: root/test/irb/test_context.rb
AgeCommit message (Collapse)Author
2024-05-28[Bug #20511] Update reline-0.5.7 (#10848)Hiroshi SHIBATA
* Update reline-0.5.7 * Update irb-1.13.1
2023-11-30[ruby/irb] Page evaluation result's outputStan Lo
(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
2023-11-29[ruby/irb] Use gem repl_type_completor, remove type_completiontomoya ishida
implementation (https://github.com/ruby/irb/pull/772) https://github.com/ruby/irb/commit/a4868a5373
2023-11-28[ruby/irb] Rescue errors from main.to_s/inspect when formattingKasumi Hanazuki
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
2023-11-15Revert "Tests of irb is still broken."Hiroshi SHIBATA
This reverts commit 5398bbcbab702907430ee019d07f5dcf2b0ce4af. We explicitly load rubygems at rubygems_ext.rb https://github.com/rubygems/rubygems/commit/8840d8507be72ff32bcbbdfb14e0b54efb364ffa
2023-11-10Tests of irb is still broken.Hiroshi SHIBATA
Revert "[ruby/irb] Revert "Skip TypeCompletion test in ruby ci" This reverts commit 589e2b6782f17d5a1d55021c0395d5d73224e9da.
2023-11-10[ruby/irb] Revert "Skip TypeCompletion test in ruby ciHiroshi SHIBATA
(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
2023-11-08[ruby/irb] Skip TypeCompletion test in ruby citomoya ishida
(https://github.com/ruby/irb/pull/748) https://github.com/ruby/irb/commit/d394af0bbc
2023-11-08[ruby/irb] Type based completion using Prism and RBStomoya ishida
(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
2023-10-12[ruby/irb] Decouple RubyLex from prompt and line_notomoya ishida
(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
2023-09-30[ruby/irb] Fix Reline's test failure running with `make test-alltomoya ishida
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
2023-08-29[ruby/irb] Fix test warnings (https://github.com/ruby/irb/pull/698)Stan Lo
* Encoding should be saved before creating Irb objects * Fix unused local warning https://github.com/ruby/irb/commit/036ec31034
2023-08-29[ruby/irb] Print deprecation message for prompt_n methodsStan Lo
(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
2023-08-29[ruby/irb] Remove unused `PROMPT_N`Summer ☀️
(https://github.com/ruby/irb/pull/685) https://github.com/ruby/irb/commit/66e69fa0dc
2023-08-11[ruby/irb] Move assignment check to RubyLexStan Lo
(https://github.com/ruby/irb/pull/670) Since assignment check relies on tokenization with `Ripper`, it feels like the responsibility of `RubyLex`. `Irb#eval_input` should simply get the result when calling `each_top_level_statement` on `RubyLex`. https://github.com/ruby/irb/commit/89d1adb3fd
2023-06-27[ruby/irb] Remove keyword exception from Context#evaluate becausetomoya ishida
the value is always nil (https://github.com/ruby/irb/pull/617) https://github.com/ruby/irb/commit/62691384f8
2023-06-13[ruby/irb] Stanardise test class names with `Test` postfix insteadStan Lo
of prefix (https://github.com/ruby/irb/pull/603) https://github.com/ruby/irb/commit/359cb28def
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-03-13[ruby/irb] Support inspecting BasicObjectStan Lo
(https://github.com/ruby/irb/pull/541) https://github.com/ruby/irb/commit/1dc2a406a3
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] 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-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-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>
2022-11-17Drop Ruby 2.5 supportst0012
Because it has reached EOL for more than 1.5 years and it won't be supported by the next reline version either.
2022-11-15[ruby/irb] Remove duplicated TestInputMethod definitionsst0012
https://github.com/ruby/irb/commit/4b831d02e1
2022-11-03[ruby/irb] Provide a base test class and let tests restore encodingsStan Lo
conveniently (https://github.com/ruby/irb/pull/429) * Create a base TestIRB::TestCase class * Save/restore encodings for tests that initializes InputMethod classes Because `RelineInputMethod#initializes` calls `set_encoding`, which changes stdio/out/err and Encoding's default encoding values, we need to make sure any test that directly or indirectly (e.g. through Context) initializes `RelineInputMethod` restores encodings. `ReadlineInputMethod` also changes encodings but currently no tests cover it. * Remove unnecessary TestHelper module Since we now have a base TestCase, without_rdoc can just live there. https://github.com/ruby/irb/commit/c2874ec121
2022-10-18[ruby/irb] Always use local variables in current context to parse code ↵tomoya ishida
(https://github.com/ruby/irb/pull/397) * Use local_variables for colorize, code_block_open check, nesting_level and assignment_expression check * Check if expression is an assignment BEFORE evaluating it. evaluate might define new localvars and change result of assignment_expression? * Add local_variables dependent code test * pend local variable dependent test on truffleruby code_block_open is not working on truffleruby * Always pass context to RubyLex#lex * Rename local_variable_assign_code generator method name * Add assignment expression truncate test * Add Context#local_variables and make generate_local_variables_assign_code more simple * Update lib/irb/input-method.rb Co-authored-by: Stan Lo <stan001212@gmail.com> * Add a comment why assignment expression check should be done before evaluate https://github.com/ruby/irb/commit/c8b3877281 Co-authored-by: Stan Lo <stan001212@gmail.com> Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2022-06-29[ruby/irb] Properly reset USE_COLORIZE after changing it in testsst0012
Some context tests assigns USE_COLORIZE to false and never change it back. This can potentially affect other tests' result as the default should be nil (activated) instead. https://github.com/ruby/irb/commit/986eb16ece
2022-06-28[ruby/irb] Centralize coloring control (https://github.com/ruby/irb/pull/374)Stan Lo
* Use colorable: argument as the only coloring control * Centalize color controling logic at Color.colorable? There are 2 requirements for coloring output: 1. It's supported on the platform 2. The user wants it: `IRB.conf[:USE_COLORIZE] == true` Right now we check 1 and 2 separately whenever we colorize things. But it's error-prone because while 1 is the default of `colorable` parameter, 2 always need to manually checked. When 2 is overlooked, it causes issues like https://github.com/ruby/irb/pull/362 And there's 0 case where we may want to colorize even when the user disables it. So I think we should merge 2 into `Color.colorable?` so it can be automatically picked up. * Add tests for all inspect modes * Simplify inspectors' coloring logic * Replace use_colorize? with Color.colorable? * Remove Context#use_colorize cause it's redundant https://github.com/ruby/irb/commit/1c53023ac4
2022-06-26[ruby/irb] Set prompt mode explictlyNobuyoshi Nakada
Fix https://github.com/ruby/irb/pull/353 https://github.com/ruby/irb/commit/7db93f9326
2022-06-26[ruby/irb] Require stringio to use StringIONobuyoshi Nakada
https://github.com/ruby/irb/commit/e024ab716b
2022-06-26[ruby/irb] Ensure stdout is a TTY before calling winsizePeter Jones
When outputting a (possibly truncated) value, IRB will query the window size. However, if IRB was piped to another process, stdout will no longer be a TTY and will not support the `winsize` method. This fix ensure that stdout is a TTY. https://github.com/ruby/irb/commit/125de5eeea
2021-12-21[ruby/irb] Check colorize option correctly to clear char attr and don't use ↵aycabta
it for tests https://github.com/ruby/irb/commit/de561cafeb
2021-10-11[ruby/irb] Set default return_formataycabta
https://github.com/ruby/irb/commit/7ee15bc668
2021-08-30[ruby/irb] Relax backtrace nest levelsNobuyoshi Nakada
https://github.com/ruby/irb/commit/fb637bc68f
2021-08-30[ruby/irb] Added the extra stdout message with test-unitHiroshi SHIBATA
https://github.com/ruby/irb/commit/b153d587a1
2021-08-30[ruby/irb] Use capture_output instead of capture_ioHiroshi SHIBATA
https://github.com/ruby/irb/commit/077e4ae7de
2021-08-30[ruby/irb] Use pend instead of skipHiroshi SHIBATA
https://github.com/ruby/irb/commit/f441ce35bf
2021-08-30Add --autocomplete / --noautocomplete optionsaycabta
2021-02-03[ruby/irb] follow up the actual line numberNobuhiro IMAI
https://github.com/ruby/irb/commit/7aed8fe3b1
2021-01-19[ruby/irb] Stub a screen size for test_contextTakashi Kokubun
http://ci.rvm.jp/logfiles/brlog.trunk-random1.20210119-074232 https://github.com/ruby/irb/commit/ea87592d4a
2021-01-18[ruby/irb] Support GitHub ActionsTakashi Kokubun
https://github.com/ruby/irb/commit/8e9e6c4037
2021-01-18[ruby/irb] skip a failling test on TruffleRubyNobuhiro IMAI
* due to the difference of backtrace pointed out by @aycabta https://github.com/ruby/irb/commit/5e00a0ae61
2021-01-18[ruby/irb] handle repeated exception separatelyNobuhiro IMAI
https://github.com/ruby/irb/commit/fcf6b34bc5
2021-01-08[ruby/irb] Fix BACK_TRACE_LIMIT logicaycabta
https://github.com/ruby/irb/commit/30dc5d43fe
2021-01-08[ruby/irb] Use Exception#full_message to show backtrace in the correct orderaycabta
[Bug #17466] https://github.com/ruby/irb/commit/1c76845cca
2021-01-08[ruby/irb] refactoring an error handling in `IRB::Inspector`Nobuhiro IMAI
* moved rescue clause to `#inspect_value` to catch all failures in inspectors * test with all (currently five kind of) inspect modes - tweaked the input due to only `Marshal` can inspect(dump) a `BasicObject` https://github.com/ruby/irb/commit/9d112fab8e
2020-12-28[ruby/irb] Fix failing testsTakashi Kokubun
https://github.com/ruby/irb/commit/7723ade899