flesh out some tests for word movements

[?]
Jul 12, 2022, 1:44 AM
NUZFHX6IUV2KXZOIJQTD5VIU7ELDQCFPDXYBUNQGWLKH3OMYND5QC

Dependencies

Change contents

  • edit in text_tests.lua at line 63
    [2.320]
    [6.287]
    end
    function test_move_left()
    io.write('\ntest_move_left')
    App.screen.init{width=120, height=60}
    Lines = load_array{'a'}
    Cursor1 = {line=1, pos=2}
    Margin_right = 0; Margin_width = Margin_left
    App.draw()
    App.run_after_keychord('left')
    check_eq(Cursor1.pos, 1, 'F - test_move_left')
    end
    function test_move_right()
    io.write('\ntest_move_right')
    App.screen.init{width=120, height=60}
    Lines = load_array{'a'}
    Cursor1 = {line=1, pos=1}
    Margin_right = 0; Margin_width = Margin_left
    App.draw()
    App.run_after_keychord('right')
    check_eq(Cursor1.pos, 2, 'F - test_move_right')
  • edit in text_tests.lua at line 87
    [5.93]
    [3.2]
    function test_move_left_to_previous_line()
    io.write('\ntest_move_left_to_previous_line')
    App.screen.init{width=120, height=60}
    Lines = load_array{'abc', 'def'}
    Cursor1 = {line=2, pos=1}
    Margin_right = 0; Margin_width = Margin_left
    App.draw()
    App.run_after_keychord('left')
    check_eq(Cursor1.line, 1, 'F - test_move_left_to_previous_line/line')
    check_eq(Cursor1.pos, 4, 'F - test_move_left_to_previous_line/pos') -- past end of line
    end
    function test_move_right_to_next_line()
    io.write('\ntest_move_right_to_next_line')
    App.screen.init{width=120, height=60}
    Lines = load_array{'abc', 'def'}
    Cursor1 = {line=1, pos=4} -- past end of line
    Margin_right = 0; Margin_width = Margin_left
    App.draw()
    App.run_after_keychord('right')
    check_eq(Cursor1.line, 2, 'F - test_move_right_to_next_line/line')
    check_eq(Cursor1.pos, 1, 'F - test_move_right_to_next_line/pos')
    end
    function test_move_to_start_of_word()
    io.write('\ntest_move_to_start_of_word')
    App.screen.init{width=120, height=60}
    Lines = load_array{'abc'}
    Cursor1 = {line=1, pos=3}
    Margin_right = 0; Margin_width = Margin_left
    App.draw()
    App.run_after_keychord('M-left')
    check_eq(Cursor1.pos, 1, 'F - test_move_to_start_of_word')
    end
    function test_move_to_start_of_previous_word()
    io.write('\ntest_move_to_start_of_previous_word')
    App.screen.init{width=120, height=60}
    Lines = load_array{'abc def'}
    Cursor1 = {line=1, pos=4} -- at the space between words
    Margin_right = 0; Margin_width = Margin_left
    App.draw()
    App.run_after_keychord('M-left')
    check_eq(Cursor1.pos, 1, 'F - test_move_to_start_of_previous_word')
    end
    function test_skip_to_previous_word()
    io.write('\ntest_skip_to_previous_word')
    App.screen.init{width=120, height=60}
    Lines = load_array{'abc def'}
    Cursor1 = {line=1, pos=5} -- at the start of second word
    Margin_right = 0; Margin_width = Margin_left
    App.draw()
    App.run_after_keychord('M-left')
    check_eq(Cursor1.pos, 1, 'F - test_skip_to_previous_word')
    end
    function test_move_to_start_of_word_on_previous_line()
    io.write('\ntest_move_to_start_of_word_on_previous_line')
    App.screen.init{width=120, height=60}
    Lines = load_array{'abc def', 'ghi'}
    Cursor1 = {line=2, pos=1}
    Margin_right = 0; Margin_width = Margin_left
    App.draw()
    App.run_after_keychord('M-left')
    check_eq(Cursor1.line, 1, 'F - test_move_to_start_of_word_on_previous_line/line')
    check_eq(Cursor1.pos, 5, 'F - test_move_to_start_of_word_on_previous_line/pos')
    end
    function test_move_past_end_of_word()
    io.write('\ntest_move_past_end_of_word')
    App.screen.init{width=120, height=60}
    Lines = load_array{'abc def'}
    Cursor1 = {line=1, pos=1}
    Margin_right = 0; Margin_width = Margin_left
    App.draw()
    App.run_after_keychord('M-right')
    check_eq(Cursor1.pos, 4, 'F - test_move_past_end_of_word')
    end
    function test_skip_to_next_word()
    io.write('\ntest_skip_to_next_word')
    App.screen.init{width=120, height=60}
    Lines = load_array{'abc def'}
    Cursor1 = {line=1, pos=4} -- at the space between words
    Margin_right = 0; Margin_width = Margin_left
    App.draw()
    App.run_after_keychord('M-right')
    check_eq(Cursor1.pos, 8, 'F - test_skip_to_next_word')
    end
    function test_move_past_end_of_word_on_next_line()
    io.write('\ntest_move_past_end_of_word_on_next_line')
    App.screen.init{width=120, height=60}
    Lines = load_array{'abc def', 'ghi'}
    Cursor1 = {line=1, pos=8}
    Margin_right = 0; Margin_width = Margin_left
    App.draw()
    App.run_after_keychord('M-right')
    check_eq(Cursor1.line, 2, 'F - test_move_past_end_of_word_on_next_line/line')
    check_eq(Cursor1.pos, 4, 'F - test_move_past_end_of_word_on_next_line/pos')
    end