-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit_test.lua
69 lines (51 loc) · 2.06 KB
/
init_test.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
-- Copyright 2020-2025 Mitchell. See LICENSE.
local debugger = require('debugger')
test('debugger.toggle_breakpoint should set a breakpoint', function()
local f<close> = test.tmpfile(true)
debugger.toggle_breakpoint()
local breakpoint_lines = test.get_marked_lines(debugger.MARK_BREAKPOINT)
local line = buffer:line_from_position(buffer.current_pos)
test.assert_equal(breakpoint_lines, {line})
end)
test('debugger.toggle_breakpoint should remove a breakpoint', function()
local f<close> = test.tmpfile(true)
debugger.toggle_breakpoint()
debugger.toggle_breakpoint()
local breakpoint_lines = test.get_marked_lines(debugger.MARK_BREAKPOINT)
test.assert_equal(breakpoint_lines, {})
end)
test('debugger.remove_breakpoint should prompt for a breakpoint to remove', function()
local f<close> = test.tmpfile(true)
debugger.toggle_breakpoint()
-- Note: this test suite has toggled lots of breakpoints, so the list contains more than just
-- this test file's breakpoint.
local select_all_items = function(opts)
local items = {}
for i = 1, #opts.items do items[#items + 1] = i end
return items
end
local _<close> = test.mock(ui.dialogs, 'list', select_all_items)
debugger.remove_breakpoint()
local breakpoint_lines = test.get_marked_lines(debugger.MARK_BREAKPOINT)
test.assert_equal(breakpoint_lines, {})
end)
retry(0)
test('debugger.set_watch should prompt for a watch expression to add', function()
local f<close> = test.tmpfile(true)
local expr = 'expr'
local input_expr = test.stub(expr, 1)
local _<close> = test.mock(ui.dialogs, 'input', input_expr)
debugger.set_watch()
test.assert_equal(input_expr.called, true)
end)
test('debugger.remove_watch should prompt for a watch to remove', function()
local f<close> = test.tmpfile(true)
local expr = 'expr'
debugger.set_watch(expr)
local select_first_item = test.stub(1)
local _<close> = test.mock(ui.dialogs, 'list', select_first_item)
debugger.remove_watch()
test.assert_equal(select_first_item.called, true)
local dialog_opts = select_first_item.args[1]
test.assert_contains(dialog_opts.items, expr)
end)