]> code.delx.au - gnu-emacs-elpa/blob - packages/realgud/test/test-loc-regexp-gub.el
Add 'packages/realgud/' from commit 'd811316e6a0f4eeee8a1347f504c196c86baa2cb'
[gnu-emacs-elpa] / packages / realgud / test / test-loc-regexp-gub.el
1 (require 'test-simple)
2 (require 'load-relative)
3 (load-file "./regexp-helper.el")
4 (load-file "../realgud/common/regexp.el")
5 (load-file "../realgud/debugger/gub/init.el")
6
7 (declare-function realgud-cmdbuf-info-loc-regexp 'realgud-buffer-command)
8 (declare-function cmdbuf-loc-match 'realgud-regexp)
9 (declare-function realgud-loc-pat-regexp 'realgud-regexp)
10 (declare-function realgud-loc-pat-file-group 'realgud-regexp)
11 (declare-function realgud-loc-pat-line-group 'realgud-regexp)
12 (declare-function realgud-cmdbuf-info-file-group 'realgud-regexp)
13 (declare-function realgud-cmdbuf-info-line-group 'realgud-regexp)
14 (declare-function realgud-cmdbuf-info 'realgud-regexp)
15 (declare-function make-realgud-cmdbuf-info 'realgud-regexp)
16 (declare-function __FILE__ 'load-relative)
17
18 (test-simple-start)
19
20 (eval-when-compile
21 (defvar dbg-name)
22 (defvar realgud-pat-hash)
23 (defvar loc-pat)
24 (defvar test-dbgr)
25 (defvar test-text)
26 )
27
28 ;; Some setup usually done in setting up the buffer.
29 ;; We customize this for the debugger trepan. Others may follow.
30 ;; FIXME: encapsulate this.
31 (setq dbg-name "gub")
32 (setq loc-pat (gethash "loc" (gethash dbg-name realgud-pat-hash)))
33
34 (setq test-dbgr (make-realgud-cmdbuf-info
35 :debugger-name dbg-name
36 :loc-regexp (realgud-loc-pat-regexp loc-pat)
37 :file-group (realgud-loc-pat-file-group loc-pat)
38 :line-group (realgud-loc-pat-line-group loc-pat)))
39
40
41 (setq test-text "interp/testdata/square.go:15:6")
42 (assert-t (numberp (cmdbuf-loc-match test-text test-dbgr)) "basic location")
43
44 (note "extract file name")
45 (assert-equal 0 (cmdbuf-loc-match test-text test-dbgr))
46 (assert-equal "interp/testdata/square.go"
47 (match-string (realgud-cmdbuf-info-file-group test-dbgr)
48 test-text))
49
50 (assert-equal "15"
51 (match-string
52 (realgud-cmdbuf-info-line-group test-dbgr)
53 test-text) "extract line number")
54
55 (setq test-text " interp/testdata/square.go:15:6")
56 (assert-nil (numberp (cmdbuf-loc-match test-text test-dbgr))
57 "location starts with blank")
58
59
60 (end-tests)