]> code.delx.au - gnu-emacs-elpa/blob - packages/realgud/test/test-regexp-trepan.el
Add 'packages/realgud/' from commit 'd811316e6a0f4eeee8a1347f504c196c86baa2cb'
[gnu-emacs-elpa] / packages / realgud / test / test-regexp-trepan.el
1 (require 'test-simple)
2 (load-file "../realgud/debugger/trepan/init.el")
3 (load-file "./regexp-helper.el")
4
5 (test-simple-start)
6
7 (set (make-local-variable 'bps-pat)
8 (gethash "brkpt-set" realgud:trepan-pat-hash))
9 (set (make-local-variable 'dbg-bt-pat)
10 (gethash "debugger-backtrace" realgud:trepan-pat-hash))
11 (set (make-local-variable 'prompt-pat)
12 (gethash "prompt" realgud:trepan-pat-hash))
13 (set (make-local-variable 'lang-bt-pat)
14 (gethash "lang-backtrace" realgud:trepan-pat-hash))
15 (set (make-local-variable 'ctrl-pat)
16 (gethash "control-frame" realgud:trepan-pat-hash))
17
18 ;; FIXME: we get a void variable somewhere in here when running
19 ;; even though we define it in lexical-let. Dunno why.
20 ;; setq however will workaround this.
21 (set (make-local-variable 'text)
22 " from /usr/local/bin/irb:12:in `<main>'")
23
24 (note "traceback location matching")
25
26 (setq text " from /usr/local/bin/irb:12:in `<main>'")
27
28 (assert-t (numberp (loc-match text lang-bt-pat))
29 "basic traceback location")
30 (assert-equal "/usr/local/bin/irb"
31 (match-string (realgud-loc-pat-file-group lang-bt-pat) text)
32 "extract traceback file name")
33
34 (assert-equal "12"
35 (match-string (realgud-loc-pat-line-group
36 lang-bt-pat) text)
37 "extract traceback line number")
38
39 (note "debugger-backtrace")
40 (set (make-local-variable 's1)
41 "--> #0 METHOD Object#require(path) in file <internal:lib/require> at line 28
42 #1 TOP Object#<top /tmp/linecache.rb> in file /tmp/linecache.rb
43 ")
44
45 (set (make-local-variable 'frame-re)
46 (realgud-loc-pat-regexp dbg-bt-pat))
47 (set (make-local-variable 'num-group)
48 (realgud-loc-pat-num dbg-bt-pat))
49 (set (make-local-variable 'file-group)
50 (realgud-loc-pat-file-group dbg-bt-pat))
51 (set (make-local-variable 'line-group)
52 (realgud-loc-pat-line-group dbg-bt-pat))
53
54 (assert-equal 0 (string-match frame-re s1))
55 (assert-equal "0" (substring s1
56 (match-beginning num-group)
57 (match-end num-group)))
58 (assert-equal "<internal:lib/require>"
59 (substring s1
60 (match-beginning file-group)
61 (match-end file-group)))
62 (assert-equal "28"
63 (substring s1
64 (match-beginning line-group)
65 (match-end line-group)))
66 (setq pos (match-end 0))
67
68 (assert-equal 77 (string-match frame-re s1 pos))
69 (assert-equal "1" (substring s1
70 (match-beginning num-group)
71 (match-end num-group)))
72 (assert-equal "/tmp/linecache.rb"
73 (substring s1
74 (match-beginning file-group)
75 (match-end file-group)))
76
77 (note "prompt")
78 (prompt-match "(trepan): ")
79 (prompt-match "((trepan)): " nil "nested debugger prompt: %s")
80 (prompt-match "((trepan@55)): " "@55" "nested debugger prompt with addr: %s")
81 (prompt-match "((trepan@main)): " "@main"
82 "nested debugger prompt with method: %s")
83 (setq prompt-str "trepan:")
84 (assert-nil (loc-match prompt-str prompt-pat)
85 (format "invalid prompt %s" prompt-str))
86
87
88 (note "control-frame")
89 (assert-equal 0 (loc-match
90 "c:0026 p:0181 s:0136 b:0136 l:000135 d:000135 METHOD /trepan-0.0.1/app/frame.rb:132 "
91 ctrl-pat)
92 )
93 (assert-equal 0 (loc-match
94 "c:0030 p:0041 s:0144 b:0144 l:00226c d:00226c METHOD /gems/trepan-0.0.1/processor/eval.rb:15 "
95 ctrl-pat)
96 )
97 (assert-equal 0 (loc-match
98 "c:0015 p:0139 s:0070 b:0070 l:000063 d:000069 BLOCK /gems/app/core.rb:121"
99 ctrl-pat)
100 )
101
102 (setq text "Breakpoint 1 set at VM offset 2 of instruction sequence \"<top /usr/local/bin/irb>\",
103 line 9 in file /usr/local/bin/irb.
104 ")
105
106
107 (assert-t (numberp (loc-match text bps-pat))
108 "basic breakpoint location")
109
110
111 (assert-equal "/usr/local/bin/irb"
112 (match-string (realgud-loc-pat-file-group
113 bps-pat) text)
114 "extract breakpoint file name")
115
116 (assert-equal "9"
117 (match-string (realgud-loc-pat-line-group
118 bps-pat) text)
119 "extract breakpoint line number")
120
121 (end-tests)