summaryrefslogtreecommitdiff
path: root/test/irb
AgeCommit message (Collapse)Author
2022-10-28[ruby/irb] Suppress "switching inspect mode" messages Nobuyoshi Nakada
https://github.com/ruby/irb/commit/565eeb3c19
2022-10-27[ruby/irb] Fix warnings in test_cmd.rbPeter Zhu
Fixes this warning: warning: assigned but unused variable - err https://github.com/ruby/irb/commit/298fcb57a3
2022-10-27[ruby/irb] Remove unnecessary test setup Stan Lo
2022-10-27[ruby/irb] Suppress warning for test which uses a locale non-existing on ↵Benoit Daloze
GitHub Actions
2022-10-27[ruby/irb] Remove unecesary and harmful pend for TruffleRuby in ↵Benoit Daloze
TestRaiseNoBacktraceException * Specifically the second one causes `$HOME` to be unset, which breaks `File.expand_path('~')`. https://github.com/ruby/irb/commit/61963305f5
2022-10-27[ruby/irb] Add missing require Stan Lo
2022-10-27[ruby/irb] Add test for IRB::InputCompletor::PerfectMatchedProcst0012
This proc displays rdoc document when the input matches certain symbols perfectly, like "String". It's commonly triggered with autocompletion but only has 1 test case. So this commit increases its test coverage. https://github.com/ruby/irb/commit/d85d719313
2022-10-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-10-26[ruby/irb] Rename test_helper.rb to helper.rbPeter Zhu
The name test_helper.rb conflicts with the test_helper.rb in JSON, causing build failures. This commit renames test_helper.rb to helper.rb. https://github.com/ruby/irb/commit/b6a92bf6b3 Co-Authored-By: Stan Lo <stan001212@gmail.com>
2022-10-26[ruby/irb] Don't insert new methods to Test::Unit::TestCasest0012
Ruby CI runs irb and other Ruby core/stdlib tests in the same process. So adding irb-specific helper to Test::Unit::TestCase could potentially pollute other components' tests and should be avoided.
2022-10-26[ruby/irb] Suppress warningsStan Lo
Co-authored-by: Peter Zhu <peter@peterzhu.ca>
2022-10-26[ruby/irb] Add test for the help commandst0012
2022-10-26[ruby/irb] Extract without_rdoc helperst0012
2022-10-25[ruby/irb] Make sure Encoding's defaults are restored Stan Lo
2022-10-24[ruby/irb] Restore standard input/output encodings after input method tests Stan Lo
2022-10-24[ruby/irb] Add a test case to cover rdoc unintalled scenario st0012
2022-10-24[ruby/irb] Add tests for RelineInputMethod st0012
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-10-18[ruby/irb] Fix code terminated check with heredoc and backtick ↵tomoya ishida
(https://github.com/ruby/irb/pull/390) * Fix backtick method def method call handled as backtick open * Fix handling heredoc in check_string_literal * Sort result of lexer.parse by pos in ruby<2.7. It's not sorted when the given code includes heredoc. * Update lib/irb/ruby-lex.rb Co-authored-by: Stan Lo <stan001212@gmail.com> * Update lib/irb/ruby-lex.rb Co-authored-by: Stan Lo <stan001212@gmail.com> * Add check_string_literal test for heredoc code that does not end with newline https://github.com/ruby/irb/commit/44bc712460 Co-authored-by: Stan Lo <stan001212@gmail.com>
2022-10-17[ruby/irb] Remove unnecessary coloring support checkst0012
https://github.com/ruby/irb/commit/ddd7dbe2c5
2022-10-08Move `error` from top_stmts and top_stmt to stmtyui-knk
By this change, syntax error is recovered smaller units. In the case below, "DEFN :bar" is same level with "CLASS :Foo" now. ``` module Z class Foo foo. end def bar end end ``` [Feature #19013] Notes: Merged: https://github.com/ruby/ruby/pull/6512
2022-10-08[ruby/irb] Sort constant completion's candidatesst0012
https://github.com/ruby/irb/commit/ee9b33c817
2022-10-08[ruby/irb] Correct assert_equal's usage in completion testsst0012
https://test-unit.github.io/test-unit/en/Test/Unit/Assertions.html#assert_equal-instance_method https://github.com/ruby/irb/commit/00f90d40ad
2022-10-08[ruby/irb] Add constant completion testst0012
https://github.com/ruby/irb/commit/39f8fcb058
2022-10-08[ruby/irb] Regroup completion testsst0012
https://github.com/ruby/irb/commit/71631287c8
2022-10-08[ruby/irb] Add tests for primitive types' method completionst0012
https://github.com/ruby/irb/commit/2e12fac38e
2022-10-05[ruby/irb] Fixed sort of variables in completionImir Kiyamov
https://github.com/ruby/irb/commit/5842888255
2022-10-03[ruby/irb] Change to explicit method call in completion ↵osyo-manga
(https://github.com/ruby/irb/pull/369) Ensure that methods are called even when local variables are defined. see: https://github.com/ruby/irb/issues/368 https://github.com/ruby/irb/commit/c34d54b8bb
2022-10-01[ruby/irb] Fix ripper_lex_without_warning duplicated heredoc tokentompng
https://github.com/ruby/irb/commit/45b539af39
2022-09-22[ruby/irb] Update expected colorize result that were uncolored beforetompng
https://github.com/ruby/irb/commit/52446eb77f
2022-09-22[ruby/irb] Scan every single characters in IRB::Color.scantompng
https://github.com/ruby/irb/commit/d14e56a65d
2022-09-21[ruby/irb] Fix completion testsStan Lo
https://github.com/ruby/irb/commit/eb1691f636
2022-09-21[ruby/irb] Handle non-String $LOAD_PATH values more carefullyst0012
In addition to String values, $LOAD_PATH can also take objects that respond_to the `to_path` method, like Pathname objects. So `irb` should be able to handle those objects too. And if $LOAD_PATH contains objects that can't be converted into String, `irb` should simply ignore it. https://github.com/ruby/irb/commit/b2f562176b
2022-09-21backup IRBRC environmental variable. It's used by test methods when it's ↵Hiroshi SHIBATA
defined. Notes: Merged: https://github.com/ruby/ruby/pull/6411
2022-09-21Fix the missing locale errorHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/6411
2022-09-17[ruby/irb] Support --noscript option to not use first non-option argument as ↵Jeremy Evans
script Also add --script option to turn the option back on. Previously there wasn't a way to get an interactive IRB session and access arguments provided on the command line. Additionally, handle `-` as script as stdin. In Unix-like tools, `-` means to take standard input instead of a file. This doesn't result in exactly the same output for: ``` echo 'p ARGV' > args.rb; irb args.rb a b c ``` and ``` echo 'p ARGV' | irb - a b c ``` Due to how irb handles whether stdin is a tty. However, this change allows use of `-` as a argument, instead of giving an unrecognized switch error. This required some small changes to context.rb (to handle `-` as standard input) and input-method.rb (to have FileInputMethod accept IO arguments in addition to strings). Implements [Feature #15371] https://github.com/ruby/irb/commit/4192683ba2
2022-09-15[ruby/irb] Refine assertion for failuresNobuyoshi Nakada
https://github.com/ruby/irb/commit/fd047512b3
2022-09-15[ruby/irb] `Dir.mktmpdir` creates a directory including the process IDNobuyoshi Nakada
https://github.com/ruby/irb/commit/a15f68ffdb
2022-09-14[ruby/irb] Fix history file saving with concurrent irb sessions when history ↵Jeremy Evans
file doesn't exist If history file didn't exist when irb was started, @loaded_history_mtime would be nil. However, if the history file didn't exist before, but it exists when saving history, that means the history file was modified, and we should handle it the same way as we handle the other case where the history file was modified. Fixes #388 https://github.com/ruby/irb/commit/8d277aafcb
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-12-20[ruby/irb] Remove unnecessary space in regexpaycabta
https://github.com/ruby/irb/commit/c24a8e2483
2021-12-20[ruby/irb] Add East Asian Ambiguous Width to irb_info commandaycabta
https://github.com/ruby/irb/commit/4cade4b7e5
2021-12-03[ruby/irb] Examine indentation of in keyword when trying to type includeKaíque Kandy Koga
Use in_keyword_case_scope? Return fast https://github.com/ruby/irb/commit/8acc7f8dc7
2021-12-02Compatibility with IRBschneems
Instead of accessing the struct as an array, access it via methods. There are other places inside of this file already using this API (for example https://github.com/ruby/ruby/blob/e0a5c3d2b71dfad038d7562fdd33f02ffd79232d/lib/irb/ruby-lex.rb#L829-L830). This commit moves all struct array-ish calls to use their method calls instead. It is also ~1.23 faster accessing values via a method instead of as an array according to this microbenchmark: ```ruby Elem = Struct.new(:pos, :event, :tok, :state, :message) do def initialize(pos, event, tok, state, message = nil) super(pos, event, tok, State.new(state), message) end # ... def to_a a = super a.pop unless a.empty? a end end class ElemClass attr_accessor :pos, :event, :tok, :state, :message def initialize(pos, event, tok, state, message = nil) @pos = pos @event = event @tok = tok @state = State.new(state) @message = message end def to_a if @message [@pos, @event, @tok, @state, @message] else [@pos, @event, @tok, @state] end end end # stub state class creation for now class State; def initialize(val); end; end ``` ```ruby Benchmark.ips do |x| x.report("struct") { struct[1] } x.report("class ") { from_class.event } x.compare! end; nil ``` ``` Warming up -------------------------------------- struct 1.624M i/100ms class 1.958M i/100ms Calculating ------------------------------------- struct 17.139M (± 2.6%) i/s - 86.077M in 5.025801s class 21.104M (± 3.4%) i/s - 105.709M in 5.015193s Comparison: class : 21103826.3 i/s struct: 17139201.5 i/s - 1.23x (± 0.00) slower ``` Notes: Merged: https://github.com/ruby/ruby/pull/5093
2021-11-05Skip TestIRB::TestInit#test_recovery_sigint on SolarisYusuke Endoh
The test randomly gets stuck on Solaris: http://rubyci.s3.amazonaws.com/solaris11-sunc/ruby-master/log/20211105T060014Z.fail.html.gz ``` 1) Error: TestIRB::TestInit#test_recovery_sigint: Timeout::Error: execution of assert_in_out_err expired timeout (100.0 sec) pid 3195 killed by SIGTERM (signal 15) | Switch to inspect mode. | exit | ``` I investigated the issue but I couldn't figure it out. This random failure is noisy, which makes it difficult to track the CI. So I skip the test on Soalris. Contribution is welcome.