Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor key actor test #645

Merged
merged 3 commits into from
Mar 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 8 additions & 22 deletions test/reline/helper.rb
Original file line number Diff line number Diff line change
@@ -136,9 +136,14 @@ def input_raw_keys(input, convert = true)
end
end

def assert_line(expected)
expected = convert_str(expected)
assert_equal(expected, @line_editor.line)
def assert_line_around_cursor(before, after)
before = convert_str(before)
after = convert_str(after)
line = @line_editor.line
byte_pointer = @line_editor.instance_variable_get(:@byte_pointer)
actual_before = line.byteslice(0, byte_pointer)
actual_after = line.byteslice(byte_pointer..)
assert_equal([before, after], [actual_before, actual_after])
end

def assert_byte_pointer_size(expected)
@@ -153,25 +158,6 @@ def assert_byte_pointer_size(expected)
EOM
end

def assert_cursor(expected)
# This test satisfies nothing because there is no `@cursor` anymore
# Test editor_cursor_position instead
cursor_x = @line_editor.instance_eval do
line_before_cursor = whole_lines[@line_index].byteslice(0, @byte_pointer)
Reline::Unicode.calculate_width(line_before_cursor)
end
assert_equal(expected, cursor_x)
end

def assert_cursor_max(expected)
# This test satisfies nothing because there is no `@cursor_max` anymore
cursor_max = @line_editor.instance_eval do
line = whole_lines[@line_index]
Reline::Unicode.calculate_width(line)
end
assert_equal(expected, cursor_max)
end

def assert_line_index(expected)
assert_equal(expected, @line_editor.instance_variable_get(:@line_index))
end
1,770 changes: 388 additions & 1,382 deletions test/reline/test_key_actor_emacs.rb

Large diffs are not rendered by default.

1,160 changes: 253 additions & 907 deletions test/reline/test_key_actor_vi.rb

Large diffs are not rendered by default.