diff options
author | aycabta <aycabta@gmail.com> | 2020-08-17 10:41:31 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2020-08-18 14:38:02 +0900 |
commit | a30dea5852b5ece74e435d912596983d2654580a (patch) | |
tree | f466677f437c8aa230e8cec87e1de38b54ed5f1a /test | |
parent | 43c648c8325db536715a8e827951ac48114eb6bd (diff) | |
download | ruby-a30dea5852b5ece74e435d912596983d2654580a.tar.gz |
[ruby/irb] Support shortening lambda notetion for nesting level of prompt
https://github.com/ruby/irb/commit/f1a775af47
Diffstat (limited to 'test')
-rw-r--r-- | test/irb/test_ruby_lex.rb | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/test/irb/test_ruby_lex.rb b/test/irb/test_ruby_lex.rb index 51a0bd1351..14b43f5718 100644 --- a/test/irb/test_ruby_lex.rb +++ b/test/irb/test_ruby_lex.rb @@ -5,7 +5,7 @@ require 'ostruct' module TestIRB class TestRubyLex < Test::Unit::TestCase - Row = Struct.new(:content, :current_line_spaces, :new_line_spaces) + Row = Struct.new(:content, :current_line_spaces, :new_line_spaces, :nesting_level) class MockIO def initialize(params, &assertion) @@ -34,6 +34,15 @@ module TestIRB ruby_lex.set_auto_indent(context) end + def assert_nesting_level(lines, expected) + ruby_lex = RubyLex.new() + io = proc{ lines.join("\n") } + ruby_lex.set_input(io, io) + ruby_lex.lex + 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) + end + def test_auto_indent input_with_correct_indents = [ Row.new(%q(def each_top_level_statement), nil, 2), @@ -237,10 +246,10 @@ module TestIRB def test_tlambda input_with_correct_indents = [ - Row.new(%q(if true), nil, 2), - Row.new(%q( -> {), nil, 4), - Row.new(%q( }), 2, 2), - Row.new(%q(end), 0, 0), + Row.new(%q(if true), nil, 2, 1), + Row.new(%q( -> {), nil, 4, 2), + Row.new(%q( }), 2, 2, 1), + Row.new(%q(end), 0, 0, 0), ] lines = [] @@ -248,6 +257,7 @@ module TestIRB lines << row.content assert_indenting(lines, row.current_line_spaces, false) assert_indenting(lines, row.new_line_spaces, true) + assert_nesting_level(lines, row.nesting_level) end end end |