1 (require 'load-relative)
3 (load-file "../realgud/common/buffer/command.el")
4 (load-file "../realgud/debugger/trepan/init.el")
5 (load-file "./regexp-helper.el")
7 (declare-function cmdbuf-loc-match 'realgud-regexp)
8 (declare-function make-realgud-cmdbuf-info 'realgud-regexp)
9 (declare-function realgud-cmdbuf-info 'realgud-regexp)
10 (declare-function realgud-cmdbuf-info-file-group 'realgud-regexp)
11 (declare-function realgud-cmdbuf-info-line-group 'realgud-regexp)
12 (declare-function realgud-loc-pat-file-group 'realgud-regexp)
13 (declare-function realgud-loc-pat-line-group 'realgud-regexp)
14 (declare-function realgud-loc-pat-regexp 'realgud-regexp)
15 (declare-function __FILE__ 'load-relative)
21 (defvar realgud-pat-hash)
26 ; Some setup usually done in setting up the buffer.
27 ; We customize this for the debugger trepan. Others may follow.
28 ; FIXME: encapsulate this.
29 (setq dbg-name "trepan")
30 (setq loc-pat (gethash "loc" (gethash dbg-name realgud-pat-hash)))
32 (setq test-dbgr (make-realgud-cmdbuf-info
33 :debugger-name dbg-name
34 :loc-regexp (realgud-loc-pat-regexp loc-pat)
35 :file-group (realgud-loc-pat-file-group loc-pat)
36 :line-group (realgud-loc-pat-line-group loc-pat)))
39 (lexical-let ((text ".. (./dbgr.rb:73)")
40 (text2 "C> ((eval):1 via /tmp/eval2.rb:2)")
41 (text3 "-- (<internal:prelude>:28 remapped prelude.rb:28)")
42 (text4 "-- (/src/external-vcs/dbgrr/processor/command/info_subcmd/registers_subcmd/dfp.rb:2)\nrequire_relative %w(.. .. base subsubcmd)\n")
45 (assert-t (numberp (cmdbuf-loc-match text test-dbgr)) "basic location")
46 (assert-equal "./dbgr.rb"
47 (match-string (realgud-cmdbuf-info-file-group test-dbgr)
48 text) "extract file name")
50 (match-string (realgud-cmdbuf-info-line-group test-dbgr)
51 text) "extract line number")
52 (assert-t (numberp (cmdbuf-loc-match text4 test-dbgr)) "more complex location")
56 (assert-t (numberp (cmdbuf-loc-match text2 test-dbgr)) "basic 'via' location")
57 (assert-equal "/tmp/eval2.rb"
58 (match-string (realgud-cmdbuf-info-file-group test-dbgr)
60 "extract via file name")
61 (assert-equal "2" (match-string (realgud-cmdbuf-info-line-group test-dbgr)
63 "extract via line number")
66 (assert-t (numberp (cmdbuf-loc-match text3 test-dbgr)) "basic 'via' location")
69 (setq text "--> #0 METHOD Object#square(x) in file ./trepan.rb at line 73")
70 (assert-nil (numberp (cmdbuf-loc-match text test-dbgr)) "unmatched location")