robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
3.4 KiB125 linesraw
1local t = require('test.testutil')
2local n = require('test.functional.testnvim')()
3local Screen = require('test.functional.ui.screen')
4
5local describe, it, before_each, finally = t.describe, t.it, t.before_each, t.finally
6local clear = n.clear
7local command = n.command
8local feed = n.feed
9local write_file = t.write_file
10
11before_each(clear)
12
13describe('debugger', function()
14  local screen
15
16  before_each(function()
17    screen = Screen.new(999, 7)
18  end)
19
20  -- oldtest: Test_Debugger_breakadd_expr()
21  -- This doesn't seem to work as documented. The breakpoint is not
22  -- triggered until the next function call.
23  it(':breakadd expr', function()
24    write_file(
25      'XbreakExpr.vim',
26      [[
27      func Foo()
28        eval 1
29        eval 2
30      endfunc
31
32      let g:Xtest_var += 1
33      call Foo()
34      let g:Xtest_var += 1
35      call Foo()]]
36    )
37    finally(function()
38      os.remove('XbreakExpr.vim')
39    end)
40
41    command('edit XbreakExpr.vim')
42    command(':let g:Xtest_var = 10')
43    command(':breakadd expr g:Xtest_var')
44    local initial_screen = [[
45      ^func Foo(){MATCH: *}|
46        eval 1{MATCH: *}|
47        eval 2{MATCH: *}|
48      endfunc{MATCH: *}|
49      {MATCH: *}|
50      let g:Xtest_var += 1{MATCH: *}|
51      {MATCH: *}|
52    ]]
53    screen:expect(initial_screen)
54
55    feed(':source %<CR>')
56    screen:expect([[
57      Breakpoint in "Foo" line 1{MATCH: *}|
58      Entering Debug mode.  Type "cont" to continue.{MATCH: *}|
59      Oldval = "10"{MATCH: *}|
60      Newval = "11"{MATCH: *}|
61      {MATCH:.*}XbreakExpr.vim[7]..function Foo{MATCH: *}|
62      line 1: eval 1{MATCH: *}|
63      >^{MATCH: *}|
64    ]])
65    feed('cont<CR>')
66    screen:expect([[
67      >cont{MATCH: *}|
68      Breakpoint in "Foo" line 1{MATCH: *}|
69      Oldval = "11"{MATCH: *}|
70      Newval = "12"{MATCH: *}|
71      {MATCH:.*}XbreakExpr.vim[9]..function Foo{MATCH: *}|
72      line 1: eval 1{MATCH: *}|
73      >^{MATCH: *}|
74    ]])
75    feed('cont<CR>')
76    screen:expect(initial_screen)
77
78    -- Check the behavior without the g: prefix.
79    -- The Oldval and Newval don't look right here.
80    command(':breakdel *')
81    command(':breakadd expr Xtest_var')
82    feed(':source %<CR>')
83    screen:expect([[
84      Breakpoint in "Foo" line 1{MATCH: *}|
85      Entering Debug mode.  Type "cont" to continue.{MATCH: *}|
86      Oldval = "13"{MATCH: *}|
87      Newval = "(does not exist)"{MATCH: *}|
88      {MATCH:.*}XbreakExpr.vim[7]..function Foo{MATCH: *}|
89      line 1: eval 1{MATCH: *}|
90      >^{MATCH: *}|
91    ]])
92    feed('cont<CR>')
93    screen:expect([[
94      {MATCH:.*}XbreakExpr.vim[7]..function Foo{MATCH: *}|
95      line 1: eval 1{MATCH: *}|
96      >cont{MATCH: *}|
97      Breakpoint in "Foo" line 2{MATCH: *}|
98      {MATCH:.*}XbreakExpr.vim[7]..function Foo{MATCH: *}|
99      line 2: eval 2{MATCH: *}|
100      >^{MATCH: *}|
101    ]])
102    feed('cont<CR>')
103    screen:expect([[
104      >cont{MATCH: *}|
105      Breakpoint in "Foo" line 1{MATCH: *}|
106      Oldval = "14"{MATCH: *}|
107      Newval = "(does not exist)"{MATCH: *}|
108      {MATCH:.*}XbreakExpr.vim[9]..function Foo{MATCH: *}|
109      line 1: eval 1{MATCH: *}|
110      >^{MATCH: *}|
111    ]])
112    feed('cont<CR>')
113    screen:expect([[
114      {MATCH:.*}XbreakExpr.vim[9]..function Foo{MATCH: *}|
115      line 1: eval 1{MATCH: *}|
116      >cont{MATCH: *}|
117      Breakpoint in "Foo" line 2{MATCH: *}|
118      {MATCH:.*}XbreakExpr.vim[9]..function Foo{MATCH: *}|
119      line 2: eval 2{MATCH: *}|
120      >^{MATCH: *}|
121    ]])
122    feed('cont<CR>')
123    screen:expect(initial_screen)
124  end)
125end)