diff options
| author | Stan Lo <stan001212@gmail.com> | 2023-02-22 03:38:03 +0800 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2023-02-21 19:38:09 +0000 |
| commit | 50e77b6a9c0ebbb1c5f2a9b075b7afb2fbe19fb4 (patch) | |
| tree | 620d6540b150bb0dcc2474f840ddf3fbf6f59a09 /spec/ruby | |
| parent | 5baef075067cff551c8b3b00c86714b8c98acc65 (diff) | |
[ruby/irb] Improve RubyLex's tests
(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
Diffstat (limited to 'spec/ruby')
0 files changed, 0 insertions, 0 deletions
