aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2020-07-25 00:43:19 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2020-07-25 00:43:19 -0400
commitc8074b47b7826d7018f4984fa1de1d0f6d19e83d (patch)
treeb3dd2467a8bfd6f1702adbd09e86f768040dd3a1 /test
parent44beff91b257a9d7874e20790d50a8568990d9e6 (diff)
downloadtextadept-c8074b47b7826d7018f4984fa1de1d0f6d19e83d.tar.gz
textadept-c8074b47b7826d7018f4984fa1de1d0f6d19e83d.zip
Added find incremental test for whole word option.
Diffstat (limited to 'test')
-rw-r--r--test/test.lua13
1 files changed, 11 insertions, 2 deletions
diff --git a/test/test.lua b/test/test.lua
index 505382a8..84e1c7e9 100644
--- a/test/test.lua
+++ b/test/test.lua
@@ -2167,16 +2167,17 @@ function test_ui_find_incremental()
}, '\n'))
assert_equal(buffer.current_pos, POS(1))
ui.find.incremental = true
+ if not CURSES then ui.find.focus() end
ui.find.find_entry_text = 'f' -- simulate 'f' keypress
if CURSES then events.emit(events.FIND_TEXT_CHANGED) end -- simulate
assert_equal(buffer.selection_start, POS(1) + 1)
assert_equal(buffer.selection_end, buffer.selection_start + 1)
ui.find.find_entry_text = 'fo' -- simulate 'o' keypress
ui.find.find_entry_text = 'foo' -- simulate 'o' keypress
- if CURSES then events.emit(events.FIND, ui.find.find_entry_text, true) end
+ if CURSES then events.emit(events.FIND_TEXT_CHANGED) end -- simulate
assert_equal(buffer.selection_start, POS(1) + 1)
assert_equal(buffer.selection_end, buffer.selection_start + 3)
- if CURSES then events.emit(events.FIND_TEXT_CHANGED) end -- simulate
+ events.emit(events.FIND, ui.find.find_entry_text, true) -- simulate Find Next
assert_equal(buffer.selection_start, buffer:position_from_line(LINE(2)))
assert_equal(buffer.selection_end, buffer.selection_start + 3)
ui.find.find_entry_text = 'fooq' -- simulate 'q' keypress
@@ -2195,6 +2196,14 @@ function test_ui_find_incremental()
assert_equal(buffer.selection_start, POS(1) + 1)
assert_equal(buffer.selection_end, buffer.selection_start + 3)
ui.find.match_case = false
+ ui.find.whole_word = true
+ ui.find.find_entry_text = 'foob'
+ if CURSES then events.emit(events.FIND_TEXT_CHANGED) end -- simulate
+ assert(buffer.selection_empty, 'no text should be found')
+ ui.find.find_entry_text = 'foobar'
+ if CURSES then events.emit(events.FIND_TEXT_CHANGED) end -- simulate
+ assert_equal(buffer:get_sel_text(), 'foobar')
+ ui.find.whole_word = false
ui.find.find_entry_text = '' -- reset
ui.find.incremental = false -- reset
buffer:close(true)