diff options
author | tomoya ishida <tomoyapenguin@gmail.com> | 2023-05-19 22:48:03 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-05-19 13:48:08 +0000 |
commit | e8c9f727e8a9f0fe9fb1a6d61a60b8c8b479a87b (patch) | |
tree | 8c8d4c9dfd7851f0bbd0da62ad2beb9fdf2b801b /test | |
parent | 875adad948d48d13539075fff526fa5ecb5eba18 (diff) | |
download | ruby-e8c9f727e8a9f0fe9fb1a6d61a60b8c8b479a87b.tar.gz |
[ruby/irb] Simplify each_top_level_statement
(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>
Diffstat (limited to 'test')
-rw-r--r-- | test/irb/test_ruby_lex.rb | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/test/irb/test_ruby_lex.rb b/test/irb/test_ruby_lex.rb index 5413fe51a8..943cce33b5 100644 --- a/test/irb/test_ruby_lex.rb +++ b/test/irb/test_ruby_lex.rb @@ -83,27 +83,22 @@ module TestIRB end def assert_nesting_level(lines, expected, local_variables: []) - ruby_lex = ruby_lex_for_lines(lines, local_variables: local_variables) + indent, _code_block_open = check_state(lines, local_variables: local_variables) error_message = "Calculated the wrong number of nesting level for:\n #{lines.join("\n")}" - assert_equal(expected, ruby_lex.instance_variable_get(:@indent), error_message) + assert_equal(expected, indent, error_message) end def assert_code_block_open(lines, expected, local_variables: []) - ruby_lex = ruby_lex_for_lines(lines, local_variables: local_variables) + _indent, code_block_open = check_state(lines, local_variables: local_variables) error_message = "Wrong result of code_block_open for:\n #{lines.join("\n")}" - assert_equal(expected, ruby_lex.instance_variable_get(:@code_block_open), error_message) + assert_equal(expected, code_block_open, error_message) end - def ruby_lex_for_lines(lines, local_variables: []) + def check_state(lines, local_variables: []) context = build_context(local_variables) ruby_lex = RubyLex.new(context) - - io = proc{ lines.join("\n") } - ruby_lex.set_input do - lines.join("\n") - end - ruby_lex.lex - ruby_lex + _ltype, indent, _continue, code_block_open = ruby_lex.check_code_state(lines.join("\n")) + [indent, code_block_open] end def test_auto_indent |